Skip to content

Instantly share code, notes, and snippets.

@Jinmo

Jinmo/yumyum.py Secret

Created December 25, 2016 05:16
Show Gist options
  • Save Jinmo/c7f9413eeb70a5e4abb4147a339d3733 to your computer and use it in GitHub Desktop.
Save Jinmo/c7f9413eeb70a5e4abb4147a339d3733 to your computer and use it in GitHub Desktop.
Christmas CTF 2016 yumyum
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