Skip to content

Instantly share code, notes, and snippets.

@grittyninja
Created September 26, 2016 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grittyninja/4608b40dc8c91740494db6a28c53c1cc to your computer and use it in GitHub Desktop.
Save grittyninja/4608b40dc8c91740494db6a28c53c1cc to your computer and use it in GitHub Desktop.
pintools - count
#!/usr/bin/env python2
import os
import string
import operator
import commands
charset = "_{}" + string.ascii_letters + string.digits
offset = 24 # true condition - false condition
tmp = ""
cm = ""
def main():
state = 0
flag = ""
while 1:
detect = 0
for c in charset:
tmp = flag + c
fd = open("guess", "w")
fd.write(tmp + '\n')
fd.close()
commands.getstatusoutput("env -i ./pin -ifeellucky -t source/tools/ManualExamples/obj-intel64/inscount0.so -- ./wirth < guess")
fd = open("inscount.out", "r")
count = int(fd.read().split(" ")[1])
fd.close()
print '[+] count : ', count, c
if count - state == -offset:
flag += cm; detect = 1
break
elif count - state == offset:
flag += c; detect = 1
break
state = count
cm = c
print "flag:", flag
if not(detect):
break
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment