-
-
Save Jinmo/c7f9413eeb70a5e4abb4147a339d3733 to your computer and use it in GitHub Desktop.
Christmas CTF 2016 yumyum
This file contains 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
import ctypes | |
from gmpy2 import invert | |
libc = ctypes.CDLL('libc.so.6') | |
serial = "!qw/LF6V|RY'/]e/bqFVtB9;Z}]{-" | |
printable = range(32, 128) | |
for seed in range(80000): | |
libc.srand(seed) | |
r = [libc.rand() for i in range(len(serial))] | |
try: | |
s = ([(((((ord(x) + 566051) % 0xbf) * invert(17161, 0xbf)) - 415) % 0xbf * invert(y % 1031, 0xbf) % 0xbf) for x, y, in zip(serial, r)]) | |
if all(c in printable for c in s): | |
print bytearray(s) | |
except: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment