Get modulus and exponent from public key
# openssl rsa -pubin -inform PEM -text -noout < key.pub
Factor the modulus with factordb
# python -c 'print 0x52a99e249ee7cf3c0cbf963a009661772bc9cdf6e1e3fbfc6e44a07a5e0f894457a9f81c3ae132ac5683d35b28ba5c324243'
863653476616376575308866344984576466644942572246900013156919
965445304326998194798282228842484732438457170595999523426901Generate a private key and decrypt the flag
#ipythonIn [1]:import gmpyIn [2]:p = 863653476616376575308866344984576466644942572246900013156919In [3]:q = 965445304326998194798282228842484732438457170595999523426901In [4]:e = 65537LIn [5]:d = long(gmpy.invert(e,(p-1)*(q-1)))In [6]:n = p * qIn [7]:from Crypto.PublicKey import RSAIn [8]:key = RSA.construct((n,e,d))In [9:f = open('flag.b64')In [10]:edata = f.read()In [11]:f.close()In [12]:import base64In [13]:key.decrypt(base64.b64decode(edata))Out[13]:
No comments:
Post a Comment