Skip to content

Instantly share code, notes, and snippets.

@tjade273
Last active January 14, 2020 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjade273/8cbde32a06c7948f8902c19f112bff16 to your computer and use it in GitHub Desktop.
Save tjade273/8cbde32a06c7948f8902c19f112bff16 to your computer and use it in GitHub Desktop.
rsa3
from Crypto.PublicKey import RSA
from base64 import b64encode
key = RSA.generate(1024, e=3)
with open('flag.txt', 'rb') as f:
flag = f.read(36)
c = pow(int.from_bytes(flag.ljust(128, b'\0'), 'big'), key.e, key.n)
print(b64encode(c.to_bytes(128, 'big')))
-----BEGIN PUBLIC KEY-----
MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQC0+b3hWC2gzK8MD6ZUluRlYy+j
GwVHeaVWciWNBTcuDDm6qLq00EbhtlalonDumBLA6OJiqCS8tRFVhnRwf58ywTyk
b18UW6+5u+Ljmx4MZqpKVfNGtpwXsfEkasvUt0/OCBpnZ6JrGX6win00/HjJVXvY
tGRMjVfqtvROvrpZeQIBAw==
-----END PUBLIC KEY-----

RSA Challenge Redux

Instructions are pretty simple: decrypt the flag

mLteOOUCPNlJc1DBFP9WEg3A2kZNJIUxVcGgluNdV+XQHhmI6C2Glnaya+/HNxycrIEaQa4GDWmBMlnY8C+7HbKRHpiHVgLdZ8wgMDf9JJQCKSnCIIPmCztcA+8IzZj7uJzQBtRuaPJYgX5EAiudZXbLxg3N4HkY/8MeqiukFdU=
Hint 1:

What is 5^3 mod 10000? More generally how can we find x given x^3 mod N when x^3 < N?

Hint 2:

What is the result of decrypting (256^3 * c) mod N for some ciphertext c? Can we undo this operation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment