-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path31.py
More file actions
35 lines (29 loc) · 1.04 KB
/
31.py
File metadata and controls
35 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import convert
import mac
import string
from time import time
import urllib
def timeSignatureGuess(fileName, signature, address, port):
paramString = urllib.urlencode({"signature": signature, "file": fileName})
start = time()
response = urllib.urlopen(address+":"+str(port)+"/?"+paramString)
end = time()
elapsed = end-start
if response.getcode() == 200:
return float('inf')
return elapsed
def guessSignature(filename, address, port):
signatureGuess = ""
while timeSignatureGuess(filename, convert.byteStringToHex(signatureGuess), address, port) < float('inf'):
maxTime = 0
maxDigit = -1
for nextByte in range(256):
guessTime = timeSignatureGuess(filename, convert.byteStringToHex(signatureGuess)+string.rjust(hex(nextByte)[2:], 2, '0'), address, port)
if guessTime > maxTime:
maxTime = guessTime
maxDigit = nextByte
signatureGuess += chr(maxDigit)
print convert.byteStringToHex(signatureGuess)
return convert.byteStringToHex(signatureGuess)
if __name__ == "__main__":
print guessSignature("foo", "http://localhost", 8080)