21 lines
724 B
Python
21 lines
724 B
Python
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 {}
|
|
|
|
res = s.get('https://14.44.4.1/proxy/network/v2/api/site/default/firewall-policies', headers=headers)
|
|
policies = res.json()
|
|
for p in policies:
|
|
if any(k in p.get('name', '').lower() for k in ['smarthome', 'snarfhome', 'compute', 'drop']):
|
|
print(f"=== {p.get('name')} (Index {p.get('index')}) ===")
|
|
print(json.dumps(p, indent=2))
|
|
|