题目:
from Crypto.Util.number import *
from secret import flag,p,q
assert q>p
n=p*q
e=10007
assert len(flag)==42
for i in range(6):
m=bytes_to_long(flag[i*7:i*7+7])
print(pow(m,e,n))
print("Encryption using modulus n=",n)
"""
OutPut:
1150947306854980854
243703926267532432
1069319314811079682
688582941857504686
670683629344243145
1195068175327355214
Encryption using modulus n= 1687126110378632809
"""
解法:
分解n
得到p,q
p = 1175078221
q =1435756429
e=10007
则d可求,可解得多组c
解密脚本如下:
import gmpy2
from Crypto.Util.number import *
from functools import reduce
import mpmath
p = 1175078221
q =1435756429
e = 10007
c=[
1150947306854980854,
243703926267532432,
1069319314811079682,
688582941857504686,
670683629344243145,
1195068175327355214
]
flag=b''
d=gmpy2.invert(e,(p-1)*(q-1))
for i in c:
m=pow(i,d,p*q)
flag+=long_to_bytes(m)
print(flag)
print(flag.decode())
0xGame{ChuTiRenDeQQShiJiShangJiuShiQDeZhi}