csci5271/ha2/6/crack.py
Michael Zhang d7cb704a4a
f
2018-01-29 17:30:43 -06:00

27 lines
693 B
Python

import requests
import string
import sys
def gethash(uname):
r = requests.get("https://192.168.16.1/mac-cookie.php?username={}".format(uname), verify=False)
return r.text.strip().split("with the MAC ")[1].split(".")[0]
username = "olololololololololololololololo"[:19]
key = ""
for i in range(19, -1, -1):
userseg = username[:i]
keyseg = key[:(19 - i)]
basehash = gethash(userseg)
for c in string.printable:
cand = userseg + keyseg + c
if basehash == gethash(cand):
key += c
print "added '{}'".format(c)
break
else:
print "failed on i={}".format(i)
sys.exit(1)
print "key = '{}'".format(key)