I found the numbers p,q,n,phi(n),e and d used in the RSA ciphered of a message. I have the public PGP key and now i want to find the private key, i found in wikipedia that PGP private key is a pair of (n,d) but i don't know how to generate it. Can someone help me? Thanks a lot.
All numbers and data: https://pastebin.com/raw/5qHUxWZK
The first thing to do now is to analyse the pgp message. It indeed (as you say in the comments) consists of a Public-Key Encrypted Session Key Packet followed by a Sym. Encrypted Integrity Protected Data Packet (Tag 18) see the standard for the format.
Using my own "packet dumper" I found:
Using Python one can quickly decrypt the first part, and we get
0002105f37831ba708b933e2e284cc10e39dfe982a68be7261df90a5845080c6d06e59ad86ab82bb8eb44f0bba75df419544feba9e7c42067d0ecabd978370c246b7c3cb614f3cab957580af5d37cfbfa4e3e6ee4f391a4aff9692f432cd61b753af09a2bae9c7f7fbd0d6f05af7ca173d50efb58cfd14ac0959a24a3321dcd1a2dcbc76f5d219d58740f761502ae93ff343507740b1abcacba1aa9c578ee3d4077a0fff778bf1169a3915fd115a762c3e15e401438fb006708829992b79568a0e1b62bcdf83ed1724a45acebd54113a7fcf57cc1e9d1cba64160755b6fd3275afe6ccc3afdab3fb6748910d51aba3f7099858acb805ad888a9392a7d76e36ac1bebf9906d9c717e236a3d1729c2d75985d0072a179f4baf9b8fbb73871213d94186f150039705b90eefe37a5ea1f085434b70d744f78cd5fc265f4059a138ee7aa34de3d4809e296d22cd2df2952878c94b5b8d40a1f003c2c8c46c873cddc578237e16ca97775f9b0ed775667e3d81a5704933a218255f263784ca38ab442564e7e2cdc38e8345b96266aaa165f1e569a1736adae9a4a3ac1eb6b09f2ada5ffd5520de94c5efcdd69375e28334b966e6aa3ef9d40f05b9ce4e5ded39276d89017adc48ba3835d8e6051af596179abf358911e8e7c821321065f9d8ed681e0ca3159e72203b49c2593b09d0d46a01c27086cb4098114d0999ccbb3e28b7ef333263d28c0e835c6df56495a1553225303498479cc14ab2bf2e088031da51f4f1750f9e2f64095885a16f306a0cffca1de92522e498453937f77bc97ece6d83a2fd567555c1f26ba763b08e6bd65890f6bba115b6633c4d0de8893f1e6f0755a9eb29a5967d9dd3d2fa83229092844aa276599742f35a6506e6cb8d2311b2b755c59f3e63c1b107498dc0bdf9716def62fe10c68890321edf7afb4bbcc73a6ade182c759b24ade2553df740b05b28eb7e2bca209bf200096321160a7384e62871aa342bc3c303dab28fcf0580c51341123908959dd2ba790dbewhich has the right form, written out as bytes (see the PKCS1.5 padding section in the standard).
We can see the cipher algorithm
09meaning AES-256 and a correct checksum0x0dbeat the end. So the key is then known and then you can decrypt the second part of the message using AES-256 in CFB mode with IV the zero block (e.g. useopenssl) and check the repeated bytes 15/16 equaling 17/18.Then you can verify the checksum (SHA-1 digest of all but the last $20$ bytes must equal the final $20$ bytes of the plain text).
The payload then starts at byte $18$ and is of the type compressed data (zlib).
Decompress it (I used
zpipe) and you get a MIME message (mail), from "[email protected]" in Spanish with some code in it (a CTF I gather, I won't spoil it here).There is no need to produce a PGP-secret key; one can just follow the standards and do a bit of coding.