UNCTF2019:BABYRSA
下载附件,解压后有一个加密文件和rsa.py代码如下:
flag = open('flag.txt','r').read()
N = 221
e = 5
enc = b''
for i in flag:
enc += bytes([pow(ord(i),e,N)])
encrypt = open('encrypt','wb')
encrypt.write(enc)
encrypt.close()
知道加密脚本我们反向编写脚本获取flag:
flag="" N = 221 e = 5 with open('encrypt','rb') as fp: encrypt=fp.read() encrypt=bytes.decode(encrypt) for i in encrypt: for x in range(0,255): if pow(x,e,N)==ord(i): flag+=chr(x) break print(flag)
得到flag为:UNCTF{10023493ff87a9f246eb09d4f573e060}

浙公网安备 33010602011771号