1.报错信息
root@kali:~/桌面/RSA/easy_rsa/rsatool# python rsatool.py -f PEM -o key.pem -n 13826123222358393307 -d 9793706120266356337
Using (n, d) to initialise RSA instance
n = 13826123222358393307 (0xbfe041d1197381db)
e = 65537 (0x10001)
d = 9793706120266356337 (0x87ea3bd3bd0b9671)
p = 4184799299 (0xf96ef843)
q = 3303891593 (0xc4ed6289)
Saving PEM as key.pem
Traceback (most recent call last):
File "rsatool.py", line 164, in <module>
data = rsa.to_pem()
File "rsatool.py", line 98, in to_pem
return (PEM_TEMPLATE % base64.encodestring(self.to_der()).decode()).encode()
File "rsatool.py", line 107, in to_der
seq.setComponentByPosition(len(seq), Integer(x))
File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/univ.py", line 2267, in __len__
return len(self._componentValues)
File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/base.py", line 214, in plug
raise error.PyAsn1Error('Attempted "%s" operation on ASN.1 schema object' % name)
pyasn1.error.PyAsn1Error: Attempted "__len__" operation on ASN.1 schema object
1.原因在于python 的pyasn1库版本过高,需要安装低版本的库
python -m pip install pyasn1==0.4.5
2.尝试生成私钥
python rsatool.py -f PEM -o key.pem -n 13826123222358393307 -d 9793706120266356337
python rsatool.py -o private.pem -e 65537 -p 275127860351348928173285174381581152299 -q 319576316814478949870590164193048041239
计算出私钥,拿去解密出明文:
openssl rsautl -decrypt -in flag.enc -inkey private.pem
openssl rsa -pubin -text -modulus -in warmup -in pubkey.pem
解密公钥文件,提取出N(即Modulus),E(即Exponent),N不长的话可以直接转10进制,太长用工具转换。