Created
December 4, 2017 07:34
-
-
Save komang4130/08c90a56eef19bf0049d324a96c6b77d 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 string | |
import subprocess as sp | |
import os | |
def get_inscount(): | |
count = open('./inscount.out').read().strip() | |
count = int(count.split(' ')[1]) | |
return count | |
def mk_input(s): | |
s = ''.join(s) | |
f = open('./input', 'w') | |
print >> f, s.strip() | |
flag = list('?' * 8) | |
charset = ['q','i','e','e','v','t','i','t'] | |
FNULL = open(os.devnull, 'w') | |
min_inscount = 203793 | |
for c in charset: | |
for i in xrange(len(charset)): | |
if flag[i] == '?': | |
flag[i] = c | |
mk_input(flag) | |
tmp = ''.join(flag) | |
cmd = './pin -t inscount0.so -- ./abc < input' | |
sp.call(cmd, shell=True, stdout=FNULL, stderr=FNULL) | |
inscount = get_inscount() | |
if inscount > min_inscount: | |
min_inscount = inscount | |
print 'New flag: ' + tmp | |
break; | |
flag[i] = '?' | |
print 'Flag: ' + ''.join(flag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment