27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
import urllib.request
|
|
import json
|
|
|
|
passwords = ['snarfnetadmin', 'SnarfNet2024!', 'SnarfNet2026!', 'admin', 'changeme']
|
|
|
|
for host in ['140.44.4.70', '140.44.4.71']:
|
|
print(f"Testing NPM on {host}:81 ...")
|
|
for pwd in passwords:
|
|
url = f"http://{host}:81/api/tokens"
|
|
payload = json.dumps({"identity": "snarf@snarfnet.net", "secret": pwd}).encode('utf-8')
|
|
req = urllib.request.Request(url, data=payload, headers={"Content-Type": "application/json"}, method="POST")
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=3) as resp:
|
|
data = json.loads(resp.read().decode('utf-8'))
|
|
if "token" in data:
|
|
print(f" SUCCESS! Password: '{pwd}', token: {data['token'][:20]}...")
|
|
break
|
|
except urllib.error.HTTPError as e:
|
|
if e.code == 400:
|
|
pass # Invalid password
|
|
else:
|
|
print(f" HTTP {e.code} on {pwd}")
|
|
except Exception as e:
|
|
print(f" Conn error on {host}: {e}")
|
|
break
|
|
|