Tags: rsa
Rating: 4.0
# RSA [700]
Here's given challenge zip: [RSA.zip](https://github.com/ozancetin/CTF-Writeups/blob/master/2019/RADARCTF/RSA/RSA.zip?raw=true)
Description:
```Show me your skills in RSA :P```
Here's solution python code
```python
#Python 2.7
import base64
import gmpy
#using with http://www.factordb.com/index.php for quick factorization for n = 7576962585305391589
p = 2045145391
q = 3704852779
e = 65537
n = p*q
ciphertexts = [1265683495754363029,1422867845936871540,7495962311923944330,6022768970112931054,229419552321932918,3656561926651753920,1772755866314518285,3365937215125857045,3360046468411685558,6665584816246982093,3989488349327732617,1904335850816135360,229419552321932918,31373686508890875,1772755866314518285,5055644333261405616,2288021297643029596,4671539261359863152,6643261674820189024,2766406176382193863,1642404682569206145,4025985104428009243,5398532251800069162,1221909921620717475,2288021297643029596,4671539261359863152,664769064133108811,2766406176382193863,515730720669796421,4822403277214863482,4131241857203411167,1873316133056870954,6851707709007888739,2526668656292689836,3596520484061456107,5493129668520855853,1259752622063528705,5484928886036822898,4688751828022785921,3365937215125857045,3360046468411685558,3958106079999151020,5523706116292801963,5055277716378667184,3031183450926368572,267859843632490692,1852208473064098919,888076521181220671,6238421347230771761,5942983273531489288,140608813077386938,2849086260420177433,7178491026098905107,3316744354054117337,1764251739829230819,339799054600629373]
phi = (p - 1) * (q - 1)
d = gmpy.invert(e,phi)
#d = 4406608918927534373
result =[]
for ct in ciphertexts:
pt = str(pow(ct, d, n))
result.append(pt)
result_final = ''.join(result)
#After decrypt all ciphertexts as a decimals, split and convert to ascii, then decode base32
#And last part again convert decimal to ascii
decimal_list = [result_final[i:i+2] for i in range(0, len(result_final), 2)]
decimal_list = map(int, decimal_list)
ascii_list = []
for i in decimal_list:
ascii_list.append(chr(i))
base32_flag = ''.join(ascii_list)
Decoded_Base32 = base64.b32decode(base32_flag)
decimal2_list = Decoded_Base32.split()
decimal2_list = map(int, decimal2_list)
flag_list = []
for x in decimal2_list:
flag_list.append(chr(x))
FinalFlag = ''.join(flag_list)
print FinalFlag
```
Flag : ```radar{factor1ng_c@n_cr@ck_rsa}```