# cat blog >> /dev/brain 2> /proc/mind
cat blog >> /dev/brain 2> /proc/mind
# cat low_entropy.py import Crypt import gmpy import Socket publickey = 0xc20a1d8b3903e1864d14a4d1f32ce57e4665fc5683960d2f7c0f30d5d247f5fa264fa66b49e801943ab68be3d9a4b393ae22963888bf145f07101616e62e0db2b04644524516c966d8923acf12af049a1d9d6fe3e786763613ee9b8f541291dcf8f0ac9dccc5d47565ef332d466bc80dc5763f1b1139f14d3c0bae072725815f ciphertext = 0x49f573321bdb3ad0a78f0e0c7cd4f4aa2a6d5911c90540ddbbaf067c6aabaccde78c8ff70c5a4abe7d4efa19074a5249b2e6525a0168c0c49535bc993efb7e2c221f4f349a014477d4134f03413fd7241303e634499313034dbb4ac96606faed5de01e784f2706e85bf3e814f5f88027b8aeccf18c928821c9d2d830b5050a1e cont = True while cont: s = Socket.Socket(Socket.TCP) s.connect('vuln2014.picoctf.com', 51818) s.read() recv = s.read() if recv != '': n = int('0x' + recv, 16) p = Crypt.egcd(publickey, n)[0] if p != 1: cont = False s.close() q = publickey / p n = p * q totien = (p - 1) * (q - 1) e = 65537 d = gmpy.invert(e, totien) cleartext = pow(ciphertext, d, n) print hex(cleartext)[2:].decode('hex') # python low_entropy.py [i] Sock: Connecting... [i] Sock: Connecting... [i] Sock: Connecting... [i] Sock: Connecting... Good thing no one can read this! I'd hate for them to know that the flag is make_sure_your_rng_generates_lotsa_primes.
cat low_entropy.py
python low_entropy.py
Post a Comment
No comments:
Post a Comment