Created
December 7, 2014 08:24
-
-
Save hhc0null/d006a84484304bd765d0 to your computer and use it in GitHub Desktop.
Easy
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
#!/usr/bin/env python2 | |
# too sleepy.....it's kimoi. | |
# N = p*q | |
# C = M*(M+B) mod N | |
import binascii | |
import itertools | |
import string | |
""" | |
793194894181: 868019 913799 | |
792127391761: 875543 904727 | |
531838213717: 597263 890459 | |
""" | |
usestr = string.printable | |
data = [ | |
{'N': 793194894181, 'B': 0xffeee, 'C': 0x8d5051562b, 'p': 868019, 'q': 913799}, | |
{'N': 792127391761, 'B': 0xfffee, 'C': 0x5ffa0ac1a2, 'p': 875543, 'q': 904727}, | |
{'N': 531838213717, 'B': 0xfefef, 'C': 0x6008ddf867, 'p': 597263, 'q': 890459}, | |
] | |
#M = int("0x"+"SECCO".encode('hex'), 16) | |
hint = "N{" | |
C = data[0]['C'] | |
B = data[0]['B'] | |
N = data[0]['N'] | |
flag = "SECCO" | |
for x in itertools.product(usestr, repeat=3): | |
token = "".join(x) | |
token = hint+token | |
token = token.encode('hex') | |
M = int(token ,16) | |
if M*(M+B)%N == C: | |
print "OK" | |
t = hex(M)[2:-1] | |
t = t.decode('hex') | |
flag += t | |
break | |
C = data[1]['C'] | |
B = data[1]['B'] | |
N = data[1]['N'] | |
hint = "}" | |
for x in itertools.product(usestr, repeat=4): | |
token = "".join(x) | |
token = token+hint | |
token = token.encode('hex') | |
M = int(token ,16) | |
if M*(M+B)%N == C: | |
print "OK" | |
t = hex(M)[2:-1] | |
t = t.decode('hex') | |
flag += t | |
break | |
with open('flag.txt', 'w') as f: | |
f.write(flag) |
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
#!/usr/bin/env python2 | |
import ctypes | |
import sys | |
libc = ctypes.cdll.LoadLibrary("/lib/libc.so.6") | |
def f(x): | |
k = libc.rand()&0xff | |
return chr((ord(x)^k)&0xff) | |
# for error | |
for i in range(-3, 3): | |
t = 1416667590+i | |
libc.srand(t) | |
with open(sys.argv[1], 'rb') as fi: | |
ebin = fi.read() | |
with open(sys.argv[2]+"-"+str(t), 'wb') as fo: | |
fo.write("".join(map(f, ebin))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment