Merge pull request 'Working on Policy List Grab' (#1) from allowlistsearch into Zar-Branch

Reviewed-on: brotoskyj/AirlockTools#1
This commit was merged in pull request #1.
This commit is contained in:
brotoskyj
2025-08-19 21:31:43 -04:00
4 changed files with 40 additions and 2 deletions
+7 -2
View File
@@ -1,6 +1,10 @@
import dotenv import dotenv
import os import os
import utils.getdeviceevents import utils.getdeviceevents
import utils.allowlist
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
dotenv.load_dotenv() dotenv.load_dotenv()
@@ -18,12 +22,13 @@ def apivalidation():
def menu(): def menu():
print("\n--- Main Menu ---") print("\n--- Main Menu ---")
print("1. Get All Events for Single Device") print("1. Get All Events for Single Device")
print("2. Policy Enforcement Readiness") print("2. Get Execution Histories for Allow List")
print("3. Get Device with Highest Blocks in 7 Days")
while True: while True:
choice = input("Enter Menu Item: ") choice = input("Enter Menu Item: ")
if choice == '1': if choice == '1':
utils.getdeviceevents.devicehistory(url) utils.getdeviceevents.devicehistory(url)
if choice == '2':
utils.allowlist.allowlistexechistories(url)
if __name__ == "__main__": if __name__ == "__main__":
apivalidation() apivalidation()
Binary file not shown.
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
import datetime
import requests
import json
import os
def allowlistexechistories(url):
endpoint = url + '/v1/group'
print("[+] Grabbing All Policies")
payload = {}
headers = {
"X-APIKey": os.getenv('APIKEY')
}
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
parse_text = json.loads(response.text)
policiesnames = []
policyids = []
for index, list in enumerate(parse_text['response']['groups'], start=1):
print(f"{index}. {list['name']}")
policiesnames.append(list['name'])
policyids.append(list['groupid'])
choice = input("Select Policy Group: ")
choice = int(choice) - 1
endpoint = url + '/v1/logging/exechistories'
payload_dict = {
"type":[1,2,6,7],
"policy": [policiesnames[choice]]
}
payload = json.dumps(payload_dict)
print(payload)
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
parse_text = json.loads(response.text)
for item in parse_text['response']['exechistories']:
print(item['checkpoint'])