Tags: crypto rsa
Rating:
This is what we're given:
```
from Crypto.Util.number import *
e=65537
your_e = getPrime(20)
msg=bytes_to_long(b'UDCTF{REDACTED}')
p=getPrime(512)
q=getPrime(512)
n=p*q
assert(msg < n)
ct=pow(msg, e, n)
your_d = inverse(your_e, (p-1)*(q-1))
print(your_e)
print(your_d)
print(n)
print(e)
print(ct)
```
Use the provided RSA textbook -- [https://bitsdeep.com/posts/attacking-rsa-for-fun-and-ctf-points-part-1/](http://) -- it really helps!
We can write a simple Python program based on its explanation about an RSA internal attacker.
Note that // is used for integer division (float division doesn't work because the numbers are too large), and checking modulo makes sure that we don't need to use integer division for that part.
UDCTF{m0d_mult1pl1c4tiv3_inv3r5e_nd_57uff}
```
your_e=548861
your_d=95173232432571941329231712692828118443780574466702093807146321250099677631827067825710345421542241500117509827717221625523077656554170307232963298108032249257829668442277402436905496971410095631707035128294281318370127935482352287840967522858886054571972660826718745245567014905338023490270530223206547055189
n=128923276994737790032784225847154420815473322545569053376748335367791339027988282369445542202224938698537424444443434684524386629219697192340629226569242894844874718895350330788650992608621499779776079293063355076268941953990983854217613662005027668855183281795022629934463967333582234624036115283306256019477
e=65537
c=101925091511033045433108849975441961999589763870098425244810307722908781911184299892072334641669931066841662878745617845011689451171244453969963211155840837507751273716371760271643490363012983256424608885239953158409708266675819028960222627654995967984657602529298637614235721996131897162063485544360691578861
phi = 0
k = (your_e * your_d - 1) // n
for i in range(1000000):
if (your_e * your_d - 1) % k == 0:
# right value of phi found
phi = (your_e * your_d - 1) // k
break
k += 1
d = pow(e, -1 ,phi)
m = pow(c, d, n)
m = format(m, 'x')
for i in range(0, len(m), 2):
print(chr(int(m[i:i+2], 16)), end='')
```