[BJDCTF 2nd] RSA0

[BJDCTF 2nd] RSA0_第1张图片

用Kali 建立nc链接(netcat) ,输入命令:

nc node3.buuoj.cn 26795

[BJDCTF 2nd] RSA0_第2张图片

写一个python脚本,最基础的RSA解密:

import gmpy2

a = 17839485742288159490770594403223959506106066258437739880982659333683995845270563841302021816962866262860643393607761157660326673074130119745189078538024794
b = 13925522055438249871771865539218308516971559152975535380286706930725529443082767129138723574734972074921858592043662074705396992568268727439238998442940

p = (a+b)//2
q = (a-b)//2

e = 10101277
c = 77129328871246299214149178459502609472817933949322129616955058830227478168658339355217656339889044962754931128590247932209241620439313497424320804108322253398060553740189712996127586210788685718061821766152864824199289687702528176825649256975774303563372017542907300913205952518771255316185434795207104871893
n = p*q
phi = (p-1)*(q-1)

d = gmpy2.invert(e,phi)
m = pow(c,d,n)

print(m)
print(hex(m))
print(bytes.fromhex(hex(m)[2:]))

得到 flag{43bcccb6-a29d-4867-b499-24baf2fa76c2}

你可能感兴趣的:(RSA加密)