Created
April 12, 2020 08:13
-
-
Save mrsndmn/521b0903fdeb3a195114d2e81502d0b9 to your computer and use it in GitHub Desktop.
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 random | |
from ctypes import CDLL | |
libc = CDLL("libc.so.6") | |
asciiRange = 0x7E - 0x20 | |
ans = [] | |
with open("ctf.in110", 'r') as f: | |
for line in f: | |
data = list(line) | |
data = data[:-1] | |
# print(data) | |
for i, c in enumerate(data): | |
cur_seed = i + ord(c) | |
libc.srand(cur_seed) | |
not_ok = False | |
for j, cc in enumerate(data): | |
if j == i: | |
continue | |
rint = libc.rand() % asciiRange + 0x20 | |
gen_char = chr(rint) | |
if cc != gen_char: | |
not_ok = True | |
break | |
if not not_ok: | |
ans.append(c) | |
break | |
print("".join(ans)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment