Last active
December 11, 2015 01:09
-
-
Save Penguin2600/4521197 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 socket | |
def doSearch(): | |
hi=100 | |
lo=0 | |
data = s.recv(2048) | |
print "\n" | |
print "Guess: 0" | |
print "==============================\n", repr(data), "\n==============================\n" | |
print "high", hi, "low", lo | |
for i in range(1,8): | |
guess=(hi+lo)/2 | |
s.sendall(str(guess)+'\n') | |
data = s.recv(2048) | |
print "\n" | |
print "Guess: ", i | |
print "high", hi, "low", lo | |
print ">>> ", guess | |
print "==============================\n", repr(data), "\n==============================\n" | |
if (repr(data).find("too much") > 0 ): | |
print "HIGH" | |
hi=guess | |
if (repr(data).find("not enough") > 0 ): | |
print "LOW" | |
lo=guess | |
if (repr(data).find("pass") > 0 ): | |
print "PASS!" | |
return 0 | |
answers=["1\n","1\n","2\n","abs\n","doBin", "lahf\n", "2\n"] | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(("pwnventure.ghostintheshellcode.com", 1979)) | |
for answer in answers: | |
if answer == "doBin": | |
doSearch() | |
else: | |
s.sendall(str(answer)) | |
data = s.recv(2048) | |
print "==============================\n", repr(data), "\n==============================\n" | |
print ">>> ", answer | |
print "Connection closed." | |
s.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment