Created
September 12, 2013 16:24
-
-
Save donovanhide/6540272 to your computer and use it in GitHub Desktop.
Solution to problem 3 in https://canyoufindit.co.uk/ The key file is corrupt. Rebuild it using pycrypto.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Crypto.PublicKey import RSA | |
| import binascii | |
| badKey="""-----BEGIN RSA PRIVATE KEY----- | |
| MIIC2gIBAAKBgDfABK8+joDLdbFTDJ+y3PTTzkqCi1L2qEjgxdg1iyZshJTeKUck | |
| SYVyKBeOBtB3FwwqXVa6iNEHJeLFewFE6ulEOIcatVp11Zg0ibMfnqTivbd6t8/z | |
| 3KzqrFksg9xQiicMactmTqFkm8ro5ODc2NTQzMjEwLy4tLCslBOCOVHxAgMBAAEC | |
| gYATW12FB2BtQbecmSxh6rWjYENZRZhgdvoZS8oF9xlYfwdNtRF5/RR1/BwFia++ | |
| BAuBktgTu/KzORsjcNPzrd0uTCbTG6hW8YPK2ROVOOeAMHek8Nl3+SW5wdePKuWw | |
| MdjDDjqxXDns+ZC1d2Cpz5V+x+2znOYL0bsEKei0sWl7LQKBgDfABK8+joDLdbFT | |
| DJ+y3PTTzkqCi1L2qEjgxdg1iyZshJTeKUckSYVyKBeOBtB3FwwqXVa6iNEHJeLF | |
| ewFE6uhVSior5HGPArFhsOQ0v9ob1NCV7P8M99qN4XplmX/xs05HgQCVh9aMWtio | |
| pKCcmJSQjIiEgHx4dHBsU9JB+TvkAkB3dy53aHRzaXNpbGd1b2VjdHNyZWhzcmku | |
| ZW9jdS4va2xidGVoY2VsIHkgICAgICAgICAgICAgICAgICAgIAuPAkATpSSd/C5S | |
| IEAbUPk+ZYAdt7OYVzay7ViAiaukhkt+/sJG+m8GmHnAKyLf9ohx3/aIcd/2iHHf | |
| 9ohx3/ayirJPAkAIefJYEpdAoRjJQCHPGUpOVjLiyQMyPcnsutG+ctAGGU8lZTDU | |
| yUim9V7iwqTE4sKkxOLCpMTiwqTE4sKkxOFNAoGAFInzTsAOkauW3crd1XfxMhxi | |
| tUkapdQqlwvFhZuouNIybfEOfW6WkjtghBDyqf50cEFWXMJ7Vk8mr6cwTosPvYKU | |
| VXKUCblretLTeU95TlbkprizPky++5b7pQuSi3mpLMi+6VgvcjTthfXPYNg2JjJp | |
| gmteC4felYL/2FTAmT8= | |
| -----END RSA PRIVATE KEY-----""" | |
| crypttext=long("2910404C21CF8BF4CC93B7D4A518BABF34B42A8AB0047627998D633E653AF63A873C8FABBE8D095ED125D4539706932425E78C261E2AB9273D177578F20E38AFEF124E068D230BA64AEB8FF80256EA015AA3BFF102FE652A4CBD33B4036F519E5899316A6250840D141B8535AB560BDCBDE8A67A09B7C97CB2FA308DFFBAD9F9",16) | |
| key=RSA.importKey(badKey) | |
| cipher=RSA.construct((key.n,key.e,key.d)) | |
| plaintext=cipher.decrypt(crypttext) | |
| print binascii.unhexlify((hex(plaintext))[2:-1]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ python fixkey.py | |
| ww.whtregesiet.rocu./knegiam0231 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment