#!/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 with open("../include/Crypto_Config.h", "r") as header: for line in header: if "SALT" in line: mo = re.search(r'"(.*)"', line) SALT = mo.groups()[0] 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}) print(result.text)