18 lines
569 B
Python
18 lines
569 B
Python
import urllib.request
|
|
import json
|
|
|
|
def test_api_auth(ip):
|
|
url = f"http://{ip}/api/auth"
|
|
data = json.dumps({"password": "snarfnetadmin"}).encode('utf-8')
|
|
req = urllib.request.Request(url, data=data, headers={"Content-Type": "application/json"})
|
|
try:
|
|
with urllib.request.urlopen(req) as resp:
|
|
body = json.loads(resp.read().decode('utf-8'))
|
|
print(f"Server {ip}: Auth response ->", body)
|
|
except Exception as e:
|
|
print(f"Server {ip}: Auth failed -> {e}")
|
|
|
|
test_api_auth("140.44.4.36")
|
|
test_api_auth("140.44.4.65")
|
|
|