2019-11-25 22:45:01 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import requests
|
|
|
|
import sys
|
|
|
|
import hashlib
|
|
|
|
import time
|
|
|
|
import re
|
|
|
|
|
|
|
|
IP = sys.argv[1]
|
|
|
|
|
|
|
|
# read the salt from the header file
|
2019-11-26 22:03:44 +01:00
|
|
|
with open("../data/etc/auth", "r") as authFile:
|
|
|
|
lineno = 0
|
|
|
|
for line in authFile:
|
|
|
|
if lineno == 1:
|
|
|
|
SALT = line.strip()
|
|
|
|
lineno += 1
|
2019-11-25 22:45:01 +01:00
|
|
|
|
|
|
|
print(f'SALT = "{SALT}"')
|
|
|
|
|
|
|
|
# read and store the password from the user
|
|
|
|
pwd = input("Enter password: ")
|
|
|
|
|
|
|
|
# request and parse a challenge from the server
|
|
|
|
challenge = requests.get(f"http://{IP}/challenge").json()
|
|
|
|
|
|
|
|
nonce = int(challenge['nonce'])
|
|
|
|
|
|
|
|
print(f"Nonce: {nonce}")
|
|
|
|
|
|
|
|
# build response string
|
|
|
|
responsestr = pwd + ":" + str(nonce) + ":" + SALT
|
|
|
|
|
|
|
|
m = hashlib.sha256()
|
|
|
|
m.update(responsestr.encode('utf-8'))
|
|
|
|
response = m.hexdigest()
|
|
|
|
|
|
|
|
result = requests.get(f"http://{IP}/authtest", {"response": response})
|
2019-11-26 22:03:44 +01:00
|
|
|
print(result.text)
|