Midnight Sun CTF 2021 Quals ------ Backup-frank
题目给了一个pdf文档
这应该是一个PEM文本的截图,从第一行可以看出这是rsa私钥,有了私钥就好说了,直接解密就可以
但是只有部分数据可见,现在的任务应当就是恢复完整的PEM文本
先从图片里提取文字:
把pdf转化为图片,使用imagemagick,采用这条命令安装:sudo apt-get install imagemagick
再用tesseract-ocr提取图片中的文字,采用这条命令可以安装该软件:sudo apt-get install tesseract-ocr
convert -density 400 ./RSA_key.pdf ./abcd.png tesseract abcd.png abc
如果执行convert命令报错
convert: not authorized `./RSA_key.pdf' @ error/constitute.c/ReadImage/412. convert: no images defined `./abcd.png' @ error/convert.c/ConvertImageCommand/3210.
改为<policy domain="coder" rights="read|write" pattern="PDF" />,
我们看下生成的abc.txt的内容:
----- BEGIN RSA PRIVATE KEY—————
’C n}: \l‘J-IIJHMJ rC 'Irll(.u11CI:n-Q.-'1m‘-PHUDY
Redacted for security reasons
YZE7xr0bE94J04cqritOcE+dJ4W0mf4HumhaSE1ywcp9xN8xBucN5an1Xt8MEbj
me?udUNRvTDYHdFkv26P1K4XhesBduRpQBES/TxN4YD42td2P8PCShanOSJLWuY
chYOagwbEHBZLQLXIJne5+GUcle?X?OENRTxBHpYJgZSm/CDeUSBKHUVIyeGHK
qJGjzIAO3KvaOzjBYWi/MGKCBIeeonBURKR70P7ijGRFZDymef8r23?4uISy
RHLKFOfngnU/j8L?DWm5SGOCJOZrlkavxPAUZzLOKCAQEAwM/HdumsrXfiOfiCSA
tYLA/+JquxLxGW4nL88dgL61RVWP24PZzWPNwafWohay562+cchFMGrlquoH
Dh7A4X45WB+MBdeYTSOVzFslrlbjoPprnsLleAkCSzloOFUkmvszDfiDaLXGi
OthqsichyPGEyVHGRYv2L3UPYAhdmeYbsbcfiRuhva9tVUUMc+nFny51054vC8M
YTnyYZJqO/SOARYNtBBGBleTQowlePnthgtSka/RK+gBnKthmihi/JyngNg
T/p/FleaXfisjnTprfoXXQ]2ExC3qu/lynFltpLBpZANQ/rbc2N2NtOIBW4oJ
X2krUOKCAOBRprTEWofHJZk?A6eaL?AkthJquRlyor?Yd1wOQdaiqu020AbW
SbnblesiGGme2SIUan214ULC8?srWNBdel/WOXaZiszjrctwaZmVUQBlOu
pDer4ButBBIOthEan+pMiC93anrG/EBUBLyFZKX/CBWIBa/wa/mmCBIugtb
PCZNQIrNeaHMdoPeercjSZqXXKYIOSSXUGpMSGjEUaHiTqSZaSQJRZEsSQBOceV
squUEDPbeEhpGIUVVHarDBk2CCGiL+v0508200jmGbe1/posPNfDH1YHuthA
rVoRpE14r1M+FIXOGSGSOf12RHVBBdfFAoIBAOCUFi7Lv3+dHMJj0h4HyL23rL6y
yZXEgEjMd1EXODPQlaJSnSbSQGS+/R04051+rw5ixrquXRngtMCDtJINQuY+MiU
XFEsLtt9N4XAYOWNm/IaUGsuICBdYthBDDQ?M+FZqqulIlplFbBNpKhatfY7Yg
t226w7?B+0M18T6rIpeLOLxRSpEJmCCfojMSgVRGMFDTIHCQHpIXLJpePhlOyWOF
ywaauJBnYESIZZAZZCdefrY/unZXeWRKSZFN4d+jSmengCXwKQmXuq/pXjIaB
XqIBB+n35wDFGOX732iPBGugiDbhsQfivdoRBAtqumCTLBquXhrnuUSMMUS
————— END RSA PRIVATE KEY-----
不是很理想,可能因为我参数设置的有问题
还是用photoshop分离图片,再tesseract提取文字,从图片的大小和行间距离,可以估测出整个文本在50行左右,那应该就是rsa 4096位的加密,我们把隐藏的文本用0代替
----- BEGIN RSA PRIVATE KEY-----
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
YZE7xr0bE94J04cqr1tQCE+dJ4w0mf4vahaSE1ywcp9xN8xBucNSan1Xt8MEbj
me7udUNRvTDYHdFkv26P1K4Xhes8duRpOBES/TxN4YD42td2P8PCSthv05JLWuY
chYOa9wbEH82L91x1JneB+0Vcle7X7OENRTxBHpYJgZBm/cDeUsBKHleyeGHK
qJGjzIAO3KvaOzjGYWi/MGKCBleeonOURKR7oP7ijORFZDymef8r2374uISy
RHLKFOfWQTnO/j8L7DWm55dOcJOZr1KbDvxPAuZZLQKCAOEAwM/Hdvm8rX6Q6C8A
tYLA/+JstxLxGWAnLSBdg161RVWPz4PZzWPNwafW0hay562+cCTXFMOrlquoH
Dh7A4X45W0+MBJdeTSonFslrlbjoPprnsLleAkCSzloOFUkmvszD6DaLXOi
OthqsichyPGEyVHORYvZL3UPYAhdmeYbsbc6Ruhva9tVUUMc+nFny51054vC8M
YTnyYZJqo/SoAR7wt6806ZlsTOowlePn1hYgtSka/RK+anKyFhmihi/JyOgJNg
T/p/FleaX6sjnTprfoXXQj2ExC3uH1/1ynF1tpLBp2AN9/rbc2N2Nt0I3W4oJ
X2krUOKCAOBRprTEWcfHJZk7A6eaL7AsztJquRlyor7Yd1w00daiqu020Abw
Sbnb18msiGGmeZSIUan214ULCB7srWNBdel/WGXaZiszjrctwaZmVU0310u
pDer4ButBBIOt95Ean+pM1C93anrG/E8uBLyF2KX/c8WIBa/WpE/mmCSlvgtb
PCZNQLrNeaHMdOPeercj52qxxKYIoSSXUGpMSGjEUaHiTqSZaSQJR2655080ceV
squUEDPbeEhpOIUVVHarDBkZCCOiL+v0508200jmObel/posPNfDHlYHuthA
rVoRpE14r1M+FIXOOSOSOf12RHVBBdfFAoIBAOCUFi7Lv3+dHMJj0h4HyL23rL6y
yZXE9E]Md1ExoDP91aJSnSbSQGS+/R040si+rwSixrquXRngtMCDtJ1N0uY+MiU
XFEsLtt9N4XAYOWNm/1aUGsuICBdYthSDD97M+FZquqII1p1Fb3NpKhath7Yg
t226w77B+0M18T6rIpeLOLxRSpEJmCCfojM89VRGMFb7IHc9leXIJpePthyWOF
ywaauJBnYEsIzZAZZch4frY/uaneWRK82rN4d+JSmef9NCXwK9mXuq/pXjlaB
XqI86+n35wDFGOX7321PBGugiDbhsOGvdoRBAtqumCTLBquXhranSMMUS
----- END RSA PRIVATE KEY-----
修正后的数据:
----- BEGIN RSA PRIVATE KEY-----
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
YZE7xr0bE94JO4cqritQcE+dJ4WOmf4HvmhaSElywcp9xN8xBucN5DnxlXt8MEbj
me7udUNRvTDYHdFkv26P1K4Xhes8duRpQBES/TxN4YD42td2P8PCShLnvQ5JLWuY
cCnYQa9wbEH8zL9lxlJne5+0Vc1Bd7X7OENRTxBHpYJg28m/cDeUs8KHUvlyeGHK
qJGjzIAO3KXjvQzj0YWi/MGKCBleeoVz0URKR7oP7Gxj0RF2DypmLf8r2374uISy
RHLKFQfW9TnO/j8L7DWm55dOcJOZr1kbDvxPAu2zLQKCAQEAwM/Hdvm8rX6Q6C8A
tYLA/+JvWsxLxGW4nL88dgl61RVWPz4PZzWPNQwbfWohay562+ccTxFM0rlxuDoH
Dh7A4X45W0+MBJbdYTSoVzFs1r1bjoPpwBnsL1pNAkC5zloQFUkmvpzBD6DaLx0i
OhZtqsichyPGEyVH0RYv2L3UPYAhdmeYbsbc6Ruhva9tVUUMc+nFyKf51Os4vC8M
YTnyYZJqo/5oAR7wt6806ZlsTQowlbSPn1hYgtSka/RK+gBnKyFhmihi/Jy0gJNg
T/p/Fb1DaX6sjnTpPbxfHXX9j2ExC3uH1/1ynF1tpLBp2AN9/rbc2N2NtOI3W4oJ
X2krUQKCAQBRxpFTEWofHJZk7A6eaL7AkzQtJkWqRlyor7Yd1wOQdaiqDdO20AbW
Sbnb18msiGGwPm25IUFqa214ULC87srWNBdw51/W0XaZiGzmjrctfHwZmVUQ31Ou
pDWve4ButBBIOt9sEnTq+pMiC93nPprG/E8uBLyF2KX/c8WIBa/WpE/mmC3lvgtb
PC2N9lrNeaHM4QPeRrfcj52qxxKYIo55XUGpMSGjEUaHiTqSZa5QJR26s5Q8OceV
sq5fUEDPbxHEhp0IUVVHarDBk2CC0iL+vQso82QQjm0ybJ1/posPNfDHlYHuqhSA
rVoRpE14r1M+FIXO0S05Qfl2RHV8BdfFAoIBAQCUFi7Lv3+dHMJj0h4HyL23rL6y
yZXE9EjMd1ExoDP91aJSnSbS9GS+/Ro4Osi+rw5ixryqBXRn9tMCDtJ1NQuY+MiU
XFEsltt9N4XAY0WNm/1aUGsuICBdYbKh3DD97M+FZqzUqlI1p1Fb3NpKhatfY7Yg
t2Z6w77B+OMi8T6rIpeLOLxR5pEJmCCfojM8gVRGMFb7IHc9Hp1XlJpePh1OyWQF
ywaauJBnYEsIz2A22cMp4frY/unZxeWRK82rN4d+jSYmyf9NCXwK9mXuq/pXjlaB
XqIB6+n3swDFGQX732iPBGu9iDbhsQ6vdoRBAtqcHmCTLB2dqXhrnvUSMMUS
-----END RSA PRIVATE KEY-----
from Crypto.PublicKey import RSA key = RSA.generate(4096) print("n:"+hex(key.n)) print("e:"+hex(key.e)) print("d:"+hex(key.d)) print("p:"+hex(key.p)) print("q:"+hex(key.q)) print("dp:"+hex(key.d%(key.p-1))) print("dq:"+hex(key.d%(key.q-1))) print("q_mod_p:"+hex()) pem = key.export_key('PEM') print(pem.decode())
n:0xf3779047cb9162773e6869864a61825d857cc0741552728aa0c1ce60fdef5cb98bf1dba733a3da44d76efe6d862fe4186b95a2a7a4e876ca643720b01f29b19d4a7ae4d704fb410e42c50c785201724864a4e540dcbd526fef35f5265fab85790445a970e99088ab1546da3479e50bc7b8d5e581bbbeb6e93a701f7382d0f5929e4489bf8cfac2f7981ab9ea31f9ed0d3054681cb8194be101780e79354657c5c55de334c750b5f7cad5b6d02d2f3ea7d210907185652132a6bb1844df31ed9b3e5d8de2c85f35941ee30ae8b37ab650778916fe6f145da867a3efe35f6d3676bbe6db617792f345b0aa0d423e3ca8a794a8cbc2bb24c69481ff052fc34ee50e5fc0178702153bed7cf00a89c64c994f631d2d127c256f1e53b4f4bd15c873ab85a0c712c5580c93495d5305608ef0be6453a06d42bbcf43e0844b2cf630449ed8f00ce2f9c3fb904c2d370e97e6a023de3cbc097e31cec433e3382a9aaa0d544d92ec55e6582558dfea12219b6ca90be165c02c27437d802b64287de8268c179e37c72946aa3cc8f372f486b39af88a1860833d6e9d19870683fdee3e3da2fdd47dc0d06a068e663803cae652f6dccb35e7a1f80d150779aaf8dcf487892c617a5d71e0d1384e210c8487c34ce31bad9b8d961b13f632fcd8a298b5085a26818829ac721dae84c2731b2d646ac745e3a0b70325bac496492534a6b6418c7c71
e:0x10001
d:0x173ac8346172ecaf2df02e6956bd78ffcd55bad31899b63e0dda900367172884b79a8af7a810b129b2586fc429727653f227e3ce1508ed14a07d360c37dcf58a6969d25dc5a6e76d21e7c529d1c13b9336af1904984b240b740a74ea85644b26e1c677c54333bc267eb034ef9ed5c0cafc92c4041dd2b3870b41596edf036afae348eccfaef6da155f98e53638307d72adb2d000357c8c65da8b06ee7fabc7822233b412fc157257432e22f437eb7311f61408841c532ad8b759d095f9a9bcdefc13570f5548e846caafa501d0e61b711006af7ff53f3f346b37141360ae7decd43ed19dba17f64826f402b1d858574b2dfef0fa127b0ecb6a9fd771d833b5dcfa95beb9a32bdd09fc18129226b1f0b64bcb0c425c5cc33a44a438fbc4c0f909c8ec4044a43cb3a1c6639a9f0afb3d506d94a8e70667bc69f9f434c27cdec499d4b13f3dccd279b16ad6c32105bd865ba5339c19c3cdd253a846830bb604da99f65c1ea663a958c8ebbfc577ef38674fa02ff07ec389869c1601318773a0bea189fde7a39ca18f415f733e71f0c72ccac05a54b592c45569615cce25b0326fb1aac9c67a5cfe80093c7792f891f7ecb1f96998aad43eb724aede5415a16d6db8e66d0583afca0a5144a65c19d3fa4fe4be2616bba8489d28892ad6785ddcaf15209575673f6f7af2b00ad8e0ff3843818200e595a3af990d6b4b0be327e66065
p:0xf526647d4a05fb185f375985b8c0b53de3aa3c6e44ff7846546b70fc1a585510f086424aa8e761fbaf13f39ceabf741ef82ec1d9beae64b2bd0a513f9f15597c12b33acd4c0e5ebd3271bdb85895150a9e9d71bff17b9a4dd4535916c98123883a6df7341f8b1518886eb606fbc39d304b337523927d37b20b2b16e9d14376233dfcd865ffd07c5b49f9fbbc5aaae3455c39a554eaeeaa2e21b73eed023e54939bb1eedeae839c7ba434d7369507f2486aa1575a65344babc2c8cff5c4cc2e26d0d232c2790f1558010f1cf74c3059474ed050475bd8c9c9bac9cd8844345dbae3aba6da3e6b5313d9649810c303e121dae953b03b6be2596eb1a63a4b16a9b3
q:0xfe3e1a658d6b90ac211dfdda0987d2356c3bdf82fcc326a92ab46cde58dfdab197ae6da79fed2bdcc004a227bff120af30539a815ddd66910aa8bdebccb75f8bb145df051859067efcbd3c5837c35a7ed6ed6459d90a9e5b001f849711b31a3cb4095d04884bc16e21d2595f7f8221988c05261e12d1670610f0d3fa4f9f51a24e5233af68dd70e25028097c8d36c3837d97734337fc8ab504cebb37d5aea8853906113b7cd6615367aeb6c2e78ca1ce1434f86e5f8e0f247ece88641ba8844b9b0368af57b8cb95b4f7892abc47fe01aaa9d4b81fedb284889a9ebf084fab2492c834cf3ae5ea8fd04e4540fb843bddeb34d4bbd2679daa04b050c28d77a74b
dp:0x4519ca4f8a92ff0112adbe5d340395d2d91e7e2432ecb3d1573065cb99fd7614ed475ade4297de059c870a2f1bf85559f968ec995ce739592c72010ee6df94b6a56ac1d36671d2808ffc8196b9d963f1f75db7d77bd0f460a5cdcc99e0b8b6f44a4bfed74160e9d45d789f747e78d810e9d19a5e298784307a776de1006c7c9b5878b1e2a665f4f7a2758560c549d000180be3af78fd4718f3c5fc45c0512373ebfa0eb3d40b230bb2f0760d5b9abecf6cc707a1624f8858e4f1c7b4a6014bad03458cab46865ae4d07f9b1195f736e323b3123ddb04d3743a6371bccc44da7ab87c04ef159318faca575189bffe92f2010baddc4a1391dcd597db9c28d83d83
dq:0x495ae7c8d735eae70f2315243ccdb863fb9786d4c753132b8a0bc6c19c88f2137d7d315c44f36c4d6405b2379fd4d5a6565e38dd0c951dcbc974885fa9905afbf628ffc0fb966c1e6593bffe80105862f2664a26f64d6f053892df71ab04af1446a9d0f1c6d57cb8e6ff47141bb913326d6beae4906f64b7465a05ff59cbd104f06e1d45860f264bd5eec755ed749892aec0ecdbbf22996ec33556a5347d115866ec8e3a48b99e192f78247935cfc8bba9eee2a30de4f20f889ad49575b9787a4bfe7ecce0958bffe4d7eaf6ae9e62f65e246420bfed982d4f30b58eceba15da1693b750f76070fe0f8f15c23b0f9b2a5b7bc1c9735abc0ddb0e782eba1c84e3
q_inv:0xe39926fc8bdeecd7dacfac2fd1976a41812be27740d42b1b8c5ce827ccfe8de5d6861e200d30d8eb1086be32e918ca56fb95687574280e61adb71582c7470e6db48e8c593cb1cf2fcdf9a3dc6b850e70275956a2806c9b4d04b01dd2ce810ea7d39e563b6756e6ac77de3734c852a84a34e1c426f83eddd48fc1be7b37450ec53643b66ea712bcc6f8ad8afd6c45acaa02fac5f316bddee37a738cdb38c575e8ca1d4199e3ae9faf6c5e0ac668e52da2961c69fb9732a95d1d0e1e62ba8c0f53d7bdc4ad9ad88b568a85c630828a6340c8b85462044611d655ca31f933031f466ddd084e72e55985b81b1d0d531c7a64994cdda1efeafcc55108ecd97648497c
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEA83eQR8uRYnc+aGmGSmGCXYV8wHQVUnKKoMHOYP3vXLmL8dun
M6PaRNdu/m2GL+QYa5Wip6TodspkNyCwHymxnUp65NcE+0EOQsUMeFIBckhkpOVA
3L1Sb+819SZfq4V5BEWpcOmQiKsVRto0eeULx7jV5YG7vrbpOnAfc4LQ9ZKeRIm/
jPrC95gaueox+e0NMFRoHLgZS+EBeA55NUZXxcVd4zTHULX3ytW20C0vPqfSEJBx
hWUhMqa7GETfMe2bPl2N4shfNZQe4wros3q2UHeJFv5vFF2oZ6Pv419tNna75tth
d5LzRbCqDUI+PKinlKjLwrskxpSB/wUvw07lDl/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K4oLxsGciPITfX0xXETzbE1k
BbI3n9TVplZeON0MlR3LyXSIX6mQWvv2KP/A+5ZsHmWTv/6AEFhi8mZKJvZNbwU4
kt9xqwSvFEap0PHG1Xy45v9HFBu5EzJta+rkkG9kt0ZaBf9Zy9EE8G4dRYYPJkvV
7sdV7XSYkq7A7Nu/IpluwzVWpTR9EVhm7I46SLmeGS94JHk1z8i7qe7iow3k8g+I
mtSVdbl4ekv+fszglYv/5Nfq9q6eYvZeJGQgv+2YLU8wtY7OuhXaFpO3UPdgcP4P
jxXCOw+bKlt7wclzWrwN2w54LrochOMCggEBAOOZJvyL3uzX2s+sL9GXakGBK+J3
QNQrG4xc6CfM/o3l1oYeIA0w2OsQhr4y6RjKVvuVaHV0KA5hrbcVgsdHDm20joxZ
PLHPL835o9xrhQ5wJ1lWooBsm00EsB3SzoEOp9OeVjtnVuasd943NMhSqEo04cQm
+D7d1I/Bvns3RQ7FNkO2bqcSvMb4rYr9bEWsqgL6xfMWvd7jenOM2zjFdejKHUGZ
466fr2xeCsZo5S2ilhxp+5cyqV0dDh5iuowPU9e9xK2a2ItWioXGMIKKY0DIuFRi
BEYR1lXKMfkzAx9Gbd0ITnLlWYW4Gx0NUxx6ZJlM3aHv6vzFUQjs2XZISXw=
-----END RSA PRIVATE KEY-----
用这个脚本解密base64:
from Crypto.Util.number import bytes_to_long, isPrime import base64 s1 = '''YZE7xr0bE94JO4cqritQcE+dJ4WOmf4HvmhaSElywcp9xN8xBucN5DnxlXt8MEbj me7udUNRvTDYHdFkv26P1K4Xhes8duRpQBES/TxN4YD42td2P8PCShLnvQ5JLWuY cCnYQa9wbEH8zL9lxlJne5+0Vc1Bd7X7OENRTxBHpYJg28m/cDeUs8KHUvlyeGHK qJGjzIAO3KXjvQzj0YWi/MGKCBleeoVz0URKR7oP7Gxj0RF2DypmLf8r2374uISy RHLKFQfW9TnO/j8L7DWm55dOcJOZr1kbDvxPAu2zLQKCAQEAwM/Hdvm8rX6Q6C8A tYLA/+JvWs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Wudlj8fddt9d70PRgpc3MmeC4tvRKS/7XQWDp1F14n3R+ eNgQ6dGaXimHhDB6d23hAGx8m1h4seKmZfT3onWFYMVJ0AAYC+OveP1HGPPF/EXA USNz6/oOs9QLIwuy8HYNW5q+z2zHB6FiT4hY5PHHtKYBS60DRYyrRoZa5NB/mxGV 9zbjI7MSPdsE03Q6Y3G8zETaerh8BO8Vkxj6yldRib/+kvIBC63cShOR3NWX25wo 2D2DAoIBAEla58jXNernDyMVJDzNuGP7l4bUx1MTK4oLxsGciPITfX0xXETzbE1k BbI3n9TVplZeON0MlR3LyXSIX6mQWvv2KP/A+5ZsHmWTv/6AEFhi8mZKJvZNbwU4 kt9xqwSvFEap0PHG1Xy45v9HFBu5EzJta+rkkG9kt0ZaBf9Zy9EE8G4dRYYPJkvV 7sdV7XSYkq7A7Nu/IpluwzVWpTR9EVhm7I46SLmeGS94JHk1z8i7qe7iow3k8g+I mtSVdbl4ekv+fszglYv/5Nfq9q6eYvZeJGQgv+2YLU8wtY7OuhXaFpO3UPdgcP4P jxXCOw+bKlt7wclzWrwN2w54LrochOMCggEBAOOZJvyL3uzX2s+sL9GXakGBK+J3 QNQrG4xc6CfM/o3l1oYeIA0w2OsQhr4y6RjKVvuVaHV0KA5hrbcVgsdHDm20joxZ PLHPL835o9xrhQ5wJ1lWooBsm00EsB3SzoEOp9OeVjtnVuasd943NMhSqEo04cQm +D7d1I/Bvns3RQ7FNkO2bqcSvMb4rYr9bEWsqgL6xfMWvd7jenOM2zjFdejKHUGZ 466fr2xeCsZo5S2ilhxp+5cyqV0dDh5iuowPU9e9xK2a2ItWioXGMIKKY0DIuFRi BEYR1lXKMfkzAx9Gbd0ITnLlWYW4Gx0NUxx6ZJlM3aHv6vzFUQjs2XZISXw=''' s1=s1.replace("\n",s1) s2=s2.replace("\n",s2) s1=(hex(bytes_to_long(base64.b64decode(s1))))[2:] s2=(hex(bytes_to_long(base64.b64decode(s2))))[2:] i=0 ans1="" ans2="" while(i<len(s1)): if(i+0x60<len(s1)):ans1+=(s1[i:i+0x60]+"\n") else:ans1 += s1[i:] i+=0x60 i=0 while(i<len(s2)): if(i+0x60<len(s2)):ans2+=(s2[i:i+0x60]+"\n") else:ans2+=s2[i:] i+=0x60 print(ans1) print('\n'*5) print(ans2)
这是构造的pem文件base64解密后的数据:
308209280201000282020100f3779047cb9162773e6869864a61825d857cc0741552728aa0c1ce60fdef5cb98bf1dba7
33a3da44d76efe6d862fe4186b95a2a7a4e876ca643720b01f29b19d4a7ae4d704fb410e42c50c785201724864a4e540
dcbd526fef35f5265fab85790445a970e99088ab1546da3479e50bc7b8d5e581bbbeb6e93a701f7382d0f5929e4489bf
8cfac2f7981ab9ea31f9ed0d3054681cb8194be101780e79354657c5c55de334c750b5f7cad5b6d02d2f3ea7d2109071
85652132a6bb1844df31ed9b3e5d8de2c85f35941ee30ae8b37ab650778916fe6f145da867a3efe35f6d3676bbe6db61
7792f345b0aa0d423e3ca8a794a8cbc2bb24c69481ff052fc34ee50e5fc0178702153bed7cf00a89c64c994f631d2d12
7c256f1e53b4f4bd15c873ab85a0c712c5580c93495d5305608ef0be6453a06d42bbcf43e0844b2cf630449ed8f00ce2
f9c3fb904c2d370e97e6a023de3cbc097e31cec433e3382a9aaa0d544d92ec55e6582558dfea12219b6ca90be165c02c
27437d802b64287de8268c179e37c72946aa3cc8f372f486b39af88a1860833d6e9d19870683fdee3e3da2fdd47dc0d0
6a068e663803cae652f6dccb35e7a1f80d150779aaf8dcf487892c617a5d71e0d1384e210c8487c34ce31bad9b8d961b
13f632fcd8a298b5085a26818829ac721dae84c2731b2d646ac745e3a0b70325bac496492534a6b6418c7c7102030100
0102820200173ac8346172ecaf2df02e6956bd78ffcd55bad31899b63e0dda900367172884b79a8af7a810b129b2586f
c429727653f227e3ce1508ed14a07d360c37dcf58a6969d25dc5a6e76d21e7c529d1c13b9336af1904984b240b740a74
ea85644b26e1c677c54333bc267eb034ef9ed5c0cafc92c4041dd2b3870b41596edf036afae348eccfaef6da155f98e5
3638307d72adb2d000357c8c65da8b06ee7fabc7822233b412fc157257432e22f437eb7311f61408841c532ad8b759d0
95f9a9bcdefc13570f5548e846caafa501d0e61b711006af7ff53f3f346b37141360ae7decd43ed19dba17f64826f402
b1d858574b2dfef0fa127b0ecb6a9fd771d833b5dcfa95beb9a32bdd09fc18129226b1f0b64bcb0c425c5cc33a44a438
fbc4c0f909c8ec4044a43cb3a1c6639a9f0afb3d506d94a8e70667bc69f9f434c27cdec499d4b13f3dccd279b16ad6c3
2105bd865ba5339c19c3cdd253a846830bb604da99f65c1ea663a958c8ebbfc577ef38674fa02ff07ec389869c160131
8773a0bea189fde7a39ca18f415f733e71f0c72ccac05a54b592c45569615cce25b0326fb1aac9c67a5cfe80093c7792
f891f7ecb1f96998aad43eb724aede5415a16d6db8e66d0583afca0a5144a65c19d3fa4fe4be2616bba8489d28892ad6
785ddcaf15209575673f6f7af2b00ad8e0ff3843818200e595a3af990d6b4b0be327e660650282010100f526647d4a05
fb185f375985b8c0b53de3aa3c6e44ff7846546b70fc1a585510f086424aa8e761fbaf13f39ceabf741ef82ec1d9beae
64b2bd0a513f9f15597c12b33acd4c0e5ebd3271bdb85895150a9e9d71bff17b9a4dd4535916c98123883a6df7341f8b
1518886eb606fbc39d304b337523927d37b20b2b16e9d14376233dfcd865ffd07c5b49f9fbbc5aaae3455c39a554eaee
aa2e21b73eed023e54939bb1eedeae839c7ba434d7369507f2486aa1575a65344babc2c8cff5c4cc2e26d0d232c2790f
1558010f1cf74c3059474ed050475bd8c9c9bac9cd8844345dbae3aba6da3e6b5313d9649810c303e121dae953b03b6b
e2596eb1a63a4b16a9b30282010100fe3e1a658d6b90ac211dfdda0987d2356c3bdf82fcc326a92ab46cde58dfdab197
ae6da79fed2bdcc004a227bff120af30539a815ddd66910aa8bdebccb75f8bb145df051859067efcbd3c5837c35a7ed6
ed6459d90a9e5b001f849711b31a3cb4095d04884bc16e21d2595f7f8221988c05261e12d1670610f0d3fa4f9f51a24e
5233af68dd70e25028097c8d36c3837d97734337fc8ab504cebb37d5aea8853906113b7cd6615367aeb6c2e78ca1ce14
34f86e5f8e0f247ece88641ba8844b9b0368af57b8cb95b4f7892abc47fe01aaa9d4b81fedb284889a9ebf084fab2492
c834cf3ae5ea8fd04e4540fb843bddeb34d4bbd2679daa04b050c28d77a74b028201004519ca4f8a92ff0112adbe5d34
0395d2d91e7e2432ecb3d1573065cb99fd7614ed475ade4297de059c870a2f1bf85559f968ec995ce739592c72010ee6
df94b6a56ac1d36671d2808ffc8196b9d963f1f75db7d77bd0f460a5cdcc99e0b8b6f44a4bfed74160e9d45d789f747e
78d810e9d19a5e298784307a776de1006c7c9b5878b1e2a665f4f7a2758560c549d000180be3af78fd4718f3c5fc45c0
512373ebfa0eb3d40b230bb2f0760d5b9abecf6cc707a1624f8858e4f1c7b4a6014bad03458cab46865ae4d07f9b1195
f736e323b3123ddb04d3743a6371bccc44da7ab87c04ef159318faca575189bffe92f2010baddc4a1391dcd597db9c28
d83d8302820100495ae7c8d735eae70f2315243ccdb863fb9786d4c753132b8a0bc6c19c88f2137d7d315c44f36c4d64
05b2379fd4d5a6565e38dd0c951dcbc974885fa9905afbf628ffc0fb966c1e6593bffe80105862f2664a26f64d6f0538
92df71ab04af1446a9d0f1c6d57cb8e6ff47141bb913326d6beae4906f64b7465a05ff59cbd104f06e1d45860f264bd5
eec755ed749892aec0ecdbbf22996ec33556a5347d115866ec8e3a48b99e192f78247935cfc8bba9eee2a30de4f20f88
9ad49575b9787a4bfe7ecce0958bffe4d7eaf6ae9e62f65e246420bfed982d4f30b58eceba15da1693b750f76070fe0f
8f15c23b0f9b2a5b7bc1c9735abc0ddb0e782eba1c84e30282010100e39926fc8bdeecd7dacfac2fd1976a41812be277
40d42b1b8c5ce827ccfe8de5d6861e200d30d8eb1086be32e918ca56fb95687574280e61adb71582c7470e6db48e8c59
3cb1cf2fcdf9a3dc6b850e70275956a2806c9b4d04b01dd2ce810ea7d39e563b6756e6ac77de3734c852a84a34e1c426
f83eddd48fc1be7b37450ec53643b66ea712bcc6f8ad8afd6c45acaa02fac5f316bddee37a738cdb38c575e8ca1d4199
e3ae9faf6c5e0ac668e52da2961c69fb9732a95d1d0e1e62ba8c0f53d7bdc4ad9ad88b568a85c630828a6340c8b85462
044611d655ca31f933031f466ddd084e72e55985b81b1d0d531c7a64994cdda1efeafcc55108ecd97648497c
这是题目中pem文件base64解密后的数据:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
61913bc6bd1b13de093b872aae2b50704f9d27858e99fe07be685a484972c1ca7dc4df3106e70de439f1957b7c3046e3
99eeee754351bd30d81dd164bf6e8fd4ae1785eb3c76e469401112fd3c4de180f8dad7763fc3c24a12e7bd0e492d6b98
7029d841af706c41fcccbf65c652677b9fb455cd4177b5fb3843514f1047a58260dbc9bf703794b3c28752f9727861ca
a891a3cc800edca5e3bd0ce3d185a2fcc18a08195e7a8573d1444a47ba0fec6c63d111760f2a662dff2bdb7ef8b884b2
4472ca1507d6f539cefe3f0bec35a6e7974e709399af591b0efc4f02edb32d0282010100c0cfc776f9bcad7e90e82f00
b582c0ffe26f5acc4bc465b89cbf3c76097ad515563f3e0f67358f350c1b7d6a216b2e7adbe71c4f114cd2b971b83a07
0e1ec0e17e395b4f8c0496dd6134a857316cd6bd5b8e83e9c019ec2f5a4d0240b9ce5a10154926be9cc10fa0da2d7d22
3a166daac89c8723c6132547d1162fd8bdd43d80217667986ec6dce91ba1bdaf6d55450c73e9c5c8a7f9d4eb38bc2f0c
6139f261926aa3fe68011ef0b7af34e9996c4d0a3095b48f9f585882d4a46bf44afa00672b21619a2862fc9cb4809360
4ffa7f15bd43697eac8e74e93dbc5f1d75fd8f61310b7b87d7fd729c5d6da4b069d8037dfeb6dcd8dd8db4e2375b8a09
5f692b510282010051c69153116a1f1c9664ec0e9e68bec093342d2645aa465ca8afb61dd7039075a8aa0dd3b6d006d6
49b9dbd7c9ac8861b03e6db921416a6b6d7850b0bceecad6341770e75fd6d17699886ce68eb72d7c7c19995510df53ae
a435af7b806eb410483adf6c1274eafa93220bdde73e9ac6fc4f2e04bc85d8a5ff73c58805afd6a44fe6982de5be0b5b
3c2d8df65acd79a1cce103de46b7dc8f9daac71298228e795d41a93121a3114687893a9265ae50251dbab3943c39c795
b2ae5f5040cf6f11c4869d085155476ab0c1936082d222febd0b28f364108e6d326c9d7fa68b0f35f0c79581eeaa1480
ad5a11a44d78af533e1485ced12d3941f97644757c05d7c5028201010094162ecbbf7f9d1cc263d21e07c8bdb7acbeb2
c995c4f448cc775131a033fdd5a2529d26d2f464befd1a383ac8beaf0e62c6bcaa057467f6d3020ed275350b98f8c894
5c512c96db7d3785c063458d9bfd5a506b2e20205d61b2a1dc30fdeccf8566acd4aa5235a7515bdcda4a85ab5f63b620
b7667ac3bec1f8e322f13eab22978b38bc51e6910998209fa2333c8154463056fb20773d1e9d57949a5e3e1d4ec96405
cb069ab89067604b08cf6036d9c329e1fad8fee9d9c5e5912bcdab37877e8d2626c9ff4d097c0af665eeabfa578e5681
5ea201ebe9f7b300c51905fbdf688f046bbd8836e1b10eaf76844102da9c1e60932c1d9da9786b9ef51230c512
可以看出私钥元素之间的分隔标志大都有0282..,并且在29行到49行的数据是:
q的一部分数据(后1784位):
0x61913bc6bd1b13de093b872aae2b50704f9d27858e99fe07be685a484972c1ca7dc4df3106e70de439f1957b7c3046e399eeee754351bd30d81dd164bf6e8fd4ae1785eb3c76e469401112fd3c4de180f8dad7763fc3c24a12e7bd0e492d6b987029d841af706c41fcccbf65c652677b9fb455cd4177b5fb3843514f1047a58260dbc9bf703794b3c28752f9727861caa891a3cc800edca5e3bd0ce3d185a2fcc18a08195e7a8573d1444a47ba0fec6c63d111760f2a662dff2bdb7ef8b884b24472ca1507d6f539cefe3f0bec35a6e7974e709399af591b0efc4f02edb32d
完整的dp:
0xc0cfc776f9bcad7e90e82f00b582c0ffe26f5acc4bc465b89cbf3c76097ad515563f3e0f67358f350c1b7d6a216b2e7adbe71c4f114cd2b971b83a070e1ec0e17e395b4f8c0496dd6134a857316cd6bd5b8e83e9c019ec2f5a4d0240b9ce5a10154926be9cc10fa0da2d7d223a166daac89c8723c6132547d1162fd8bdd43d80217667986ec6dce91ba1bdaf6d55450c73e9c5c8a7f9d4eb38bc2f0c6139f261926aa3fe68011ef0b7af34e9996c4d0a3095b48f9f585882d4a46bf44afa00672b21619a2862fc9cb48093604ffa7f15bd43697eac8e74e93dbc5f1d75fd8f61310b7b87d7fd729c5d6da4b069d8037dfeb6dcd8dd8db4e2375b8a095f692b51
完整的dq:
0x51c69153116a1f1c9664ec0e9e68bec093342d2645aa465ca8afb61dd7039075a8aa0dd3b6d006d649b9dbd7c9ac8861b03e6db921416a6b6d7850b0bceecad6341770e75fd6d17699886ce68eb72d7c7c19995510df53aea435af7b806eb410483adf6c1274eafa93220bdde73e9ac6fc4f2e04bc85d8a5ff73c58805afd6a44fe6982de5be0b5b3c2d8df65acd79a1cce103de46b7dc8f9daac71298228e795d41a93121a3114687893a9265ae50251dbab3943c39c795b2ae5f5040cf6f11c4869d085155476ab0c1936082d222febd0b28f364108e6d326c9d7fa68b0f35f0c79581eeaa1480ad5a11a44d78af533e1485ced12d3941f97644757c05d7c5
完整的q_inv:
0x94162ecbbf7f9d1cc263d21e07c8bdb7acbeb2c995c4f448cc775131a033fdd5a2529d26d2f464befd1a383ac8beaf0e62c6bcaa057467f6d3020ed275350b98f8c8945c512c96db7d3785c063458d9bfd5a506b2e20205d61b2a1dc30fdeccf8566acd4aa5235a7515bdcda4a85ab5f63b620b7667ac3bec1f8e322f13eab22978b38bc51e6910998209fa2333c8154463056fb20773d1e9d57949a5e3e1d4ec96405cb069ab89067604b08cf6036d9c329e1fad8fee9d9c5e5912bcdab37877e8d2626c9ff4d097c0af665eeabfa578e56815ea201ebe9f7b300c51905fbdf688f046bbd8836e1b10eaf76844102da9c1e60932c1d9da9786b9ef51230c512
现在我们利用dp来恢复整个私钥
可以一一求出p和q,也可以求出p后,通过q=inverse(q_inv,p)求出q(因为(q*q_inv)%p=1)
因为(p-1)>dp,所以Kp<e,Kq也是一样,许多情况下e等于65537,因此K完全是可以遍历得到的(如果e不等于65537该怎么办呢)
from Crypto.Util.number import isPrime,inverse e=65537 dp=0xc0cfc776f9bcad7e90e82f00b582c0ffe26f5acc4bc465b89cbf3c76097ad515563f3e0f67358f350c1b7d6a216b2e7adbe71c4f114cd2b971b83a070e1ec0e17e395b4f8c0496dd6134a857316cd6bd5b8e83e9c019ec2f5a4d0240b9ce5a10154926be9cc10fa0da2d7d223a166daac89c8723c6132547d1162fd8bdd43d80217667986ec6dce91ba1bdaf6d55450c73e9c5c8a7f9d4eb38bc2f0c6139f261926aa3fe68011ef0b7af34e9996c4d0a3095b48f9f585882d4a46bf44afa00672b21619a2862fc9cb48093604ffa7f15bd43697eac8e74e93dbc5f1d75fd8f61310b7b87d7fd729c5d6da4b069d8037dfeb6dcd8dd8db4e2375b8a095f692b51 dq=0x51c69153116a1f1c9664ec0e9e68bec093342d2645aa465ca8afb61dd7039075a8aa0dd3b6d006d649b9dbd7c9ac8861b03e6db921416a6b6d7850b0bceecad6341770e75fd6d17699886ce68eb72d7c7c19995510df53aea435af7b806eb410483adf6c1274eafa93220bdde73e9ac6fc4f2e04bc85d8a5ff73c58805afd6a44fe6982de5be0b5b3c2d8df65acd79a1cce103de46b7dc8f9daac71298228e795d41a93121a3114687893a9265ae50251dbab3943c39c795b2ae5f5040cf6f11c4869d085155476ab0c1936082d222febd0b28f364108e6d326c9d7fa68b0f35f0c79581eeaa1480ad5a11a44d78af533e1485ced12d3941f97644757c05d7c5 q_inv=0x94162ecbbf7f9d1cc263d21e07c8bdb7acbeb2c995c4f448cc775131a033fdd5a2529d26d2f464befd1a383ac8beaf0e62c6bcaa057467f6d3020ed275350b98f8c8945c512c96db7d3785c063458d9bfd5a506b2e20205d61b2a1dc30fdeccf8566acd4aa5235a7515bdcda4a85ab5f63b620b7667ac3bec1f8e322f13eab22978b38bc51e6910998209fa2333c8154463056fb20773d1e9d57949a5e3e1d4ec96405cb069ab89067604b08cf6036d9c329e1fad8fee9d9c5e5912bcdab37877e8d2626c9ff4d097c0af665eeabfa578e56815ea201ebe9f7b300c51905fbdf688f046bbd8836e1b10eaf76844102da9c1e60932c1d9da9786b9ef51230c512 for k in range(1,e): if ((e*dp)-1)%k==0: p=((e * dp - 1) // k)+1 if (isPrime(p)): q=inverse(q_inv,p) if(isPrime(q)): print("p="+hex(p)) print("q="+hex(q)) ''' p=0xfeb9137abe16be4b0ba2b2cddd178624ece1b98c31219240a9b76365a1379a07bcbb33cdd38595f4aa024748dc11c05f2bcfe7d6f3a28df7302fc8d760acceea3d27e35001183f9645dccb02fb45ef74e2ca88f074ef2daa93876f15287e987e683f642727ac02a6eb4eee49aff450c1d1631eec4b16e3726e0d4c53f57f956d9a4f8f1fdcd29b643d52294a2939af817874e1ffd2c414d542618d5bb1436f51a47ef0667205e5eb0fe4d15a86c7c382fb1632255730e10dbb96cff3129c318be32543253f8554abd40f65ef174c694649883acc77ca56bc44650bd10ba857598be4a70d05c4073be71dc6c5540e4538f10a024f7bc2d48724b08940933b0cbb q=0xc0983a7397809b7ff43cff86ceb61c08d01aa5447b18d48a3e8aff15c93ce8071361913bc6bd1b13de093b872aae2b50704f9d27858e99fe07be685a484972c1ca7dc4df3106e70de439f1957b7c3046e399eeee754351bd30d81dd164bf6e8fd4ae1785eb3c76e469401112fd3c4de180f8dad7763fc3c24a12e7bd0e492d6b987029d841af706c41fcccbf65c652677b9fb455cd4177b5fb3843514f1047a58260dbc9bf703794b3c28752f9727861caa891a3cc800edca5e3bd0ce3d185a2fcc18a08195e7a8573d1444a47ba0fec6c63d111760f2a662dff2bdb7ef8b884b24472ca1507d6f539cefe3f0bec35a6e7974e709399af591b0efc4f02edb32d '''
现在可以恢复完整的pem文件了,脚本如下:
from Crypto.Util.number import inverse from Crypto.PublicKey import RSA e=65537 p=0xfeb9137abe16be4b0ba2b2cddd178624ece1b98c31219240a9b76365a1379a07bcbb33cdd38595f4aa024748dc11c05f2bcfe7d6f3a28df7302fc8d760acceea3d27e35001183f9645dccb02fb45ef74e2ca88f074ef2daa93876f15287e987e683f642727ac02a6eb4eee49aff450c1d1631eec4b16e3726e0d4c53f57f956d9a4f8f1fdcd29b643d52294a2939af817874e1ffd2c414d542618d5bb1436f51a47ef0667205e5eb0fe4d15a86c7c382fb1632255730e10dbb96cff3129c318be32543253f8554abd40f65ef174c694649883acc77ca56bc44650bd10ba857598be4a70d05c4073be71dc6c5540e4538f10a024f7bc2d48724b08940933b0cbb q=0xc0983a7397809b7ff43cff86ceb61c08d01aa5447b18d48a3e8aff15c93ce8071361913bc6bd1b13de093b872aae2b50704f9d27858e99fe07be685a484972c1ca7dc4df3106e70de439f1957b7c3046e399eeee754351bd30d81dd164bf6e8fd4ae1785eb3c76e469401112fd3c4de180f8dad7763fc3c24a12e7bd0e492d6b987029d841af706c41fcccbf65c652677b9fb455cd4177b5fb3843514f1047a58260dbc9bf703794b3c28752f9727861caa891a3cc800edca5e3bd0ce3d185a2fcc18a08195e7a8573d1444a47ba0fec6c63d111760f2a662dff2bdb7ef8b884b24472ca1507d6f539cefe3f0bec35a6e7974e709399af591b0efc4f02edb32d N=p*q d = inverse(e,(p-1)*(q-1)) key = RSA.construct((N,e,d,p,q)) pem = key.export_key('PEM') print(pem.decode()) ''' -----BEGIN RSA PRIVATE KEY----- MIIJKQIBAAKCAgEAv6JGqJG+nS5TvPPZLXBSrgMy27wnMuSJdk4lSFc84m3vvRXx 9ltER7UOQN2iL422Sp3kMYMvRIjflNvAzqfcgVuMwINdVO+1bbhedvFqeQKcMDfE lA+WDwULLIdwhZumyqoPjvRfdyfv8IcwPEBi/AthGKzfwaTlEiSnbNAM+nGGJt7K hEfokOuEQ2vStk6zuYHz/4sgUzsnTw9GTS277DzDZOmM7jQ/qY0RsLR/b8VeYNB9 T2pNZPrV63FEoKYJzZCeRqbZuQoAtKhecsUf/gzMv3TgHO41ISGTHl9bFk3fa00r kDAAf8N3zjXuslzQcWgGr4ucN6NQru8YE1DmAVJwGGl/tOwKk6rvT060qStPG2a5 y396CLXQFDLDUrSOA4qsW3WF+k3HHKnWCyOwm9x3WwTUbjMt5duWXpUkcg2hU+2V 5zLBgm3FoN1JxGxgrnQDB81OWhSw2GSVKULIGEG5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