feat: add various infrastructure check and automation scripts
This commit is contained in:
27
scripts/dump_unifi_fw.py
Normal file
27
scripts/dump_unifi_fw.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import requests
|
||||
import urllib3
|
||||
import json
|
||||
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
s = requests.Session()
|
||||
s.verify = False
|
||||
|
||||
r = s.post('https://14.44.4.1/api/auth/login', json={'username': 'snarf', 'password': 'Katzir476!!!'})
|
||||
csrf = r.headers.get('x-csrf-token') or r.cookies.get('csrf_token')
|
||||
headers = {'X-CSRF-Token': csrf} if csrf else {}
|
||||
|
||||
r_fw = s.get('https://14.44.4.1/proxy/network/api/s/default/rest/firewallrule', headers=headers)
|
||||
print("Firewall rule status:", r_fw.status_code)
|
||||
print("Firewall rule json:", r_fw.json())
|
||||
|
||||
# Check firewall groups
|
||||
r_fg = s.get('https://14.44.4.1/proxy/network/api/s/default/rest/firewallgroup', headers=headers)
|
||||
print("Firewall groups json:", r_fg.json())
|
||||
|
||||
# Check port forwarding
|
||||
r_pf = s.get('https://14.44.4.1/proxy/network/api/s/default/rest/portforward', headers=headers)
|
||||
print("Port forwards:", r_pf.json())
|
||||
|
||||
c.close() if 'c' in locals() else None
|
||||
|
||||
Reference in New Issue
Block a user