diff --git a/AirlockTools.py b/AirlockTools.py index 0995fe8..de6960b 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -1,6 +1,10 @@ import dotenv import os import utils.getdeviceevents +import utils.allowlist +import urllib3 + +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) dotenv.load_dotenv() @@ -18,12 +22,13 @@ def apivalidation(): def menu(): print("\n--- Main Menu ---") print("1. Get All Events for Single Device") - print("2. Policy Enforcement Readiness") - print("3. Get Device with Highest Blocks in 7 Days") + print("2. Get Execution Histories for Allow List") while True: choice = input("Enter Menu Item: ") if choice == '1': utils.getdeviceevents.devicehistory(url) + if choice == '2': + utils.allowlist.allowlistexechistories(url) if __name__ == "__main__": apivalidation() \ No newline at end of file diff --git a/utils/__pycache__/allowlist.cpython-313.pyc b/utils/__pycache__/allowlist.cpython-313.pyc new file mode 100644 index 0000000..f029c4b Binary files /dev/null and b/utils/__pycache__/allowlist.cpython-313.pyc differ diff --git a/utils/__pycache__/getdeviceevents.cpython-313.pyc b/utils/__pycache__/getdeviceevents.cpython-313.pyc index 3b24f94..a7fc471 100644 Binary files a/utils/__pycache__/getdeviceevents.cpython-313.pyc and b/utils/__pycache__/getdeviceevents.cpython-313.pyc differ diff --git a/utils/allowlist.py b/utils/allowlist.py new file mode 100644 index 0000000..c8bbbdb --- /dev/null +++ b/utils/allowlist.py @@ -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']) \ No newline at end of file