From 942efd38e8f1e4fd34ba8ccc6e49b7cece6af33f Mon Sep 17 00:00:00 2001 From: brotoskyj Date: Thu, 28 Aug 2025 12:27:15 -0400 Subject: [PATCH] Working preflight --- AirlockTools.py | 18 ++++++++++-------- allowlistandgroup.py | 22 ++++++++++++++++++++++ utils/allowlist.py | 2 +- 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 allowlistandgroup.py diff --git a/AirlockTools.py b/AirlockTools.py index ad50df5..00d2e6f 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -371,17 +371,19 @@ def menu_prepare_to_enforce(): print(ct.colorText(f"Please choose Parent Allowlist","white")) allowlist_parent_tuple = utils.allowlist.listAllowlists(url) + #print(allowlist_parent_tuple) allowlist_parent = allowlist_parent_tuple[1][allowlist_parent_tuple[0]] print(ct.colorText(f"Please choose Child Allowlist","white")) allowlist_child_tuple = utils.allowlist.listAllowlists(url) + #print(allowlist_child_tuple) allowlist_child = allowlist_child_tuple[1][allowlist_child_tuple[0]] elif choice == "6": - if os.path.exists(f"preflight\\final_pathexclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and parentallowlist != " " and childallowlist != " ": + if os.path.exists(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and allowlist_parent != " " and allowlist_child != " ": - pathexclusions = tryToReadCSV(f"preflight\\final_pathexclusions_{first_policy}_{second_policy}.csv") + pathexclusions = tryToReadCSV(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv") allowbyhash = tryToReadCSV(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") print(ct.colorText(f"===========================================================================================================================================","red")) @@ -395,14 +397,14 @@ def menu_prepare_to_enforce(): if confirmation.strip().upper() == "I AGREE": print(ct.colorText("Proceeding with the code...", "yellow")) - pathexcludelist = pathexclusions['longestcfp'].unique().tolist - utils.policyfunctions.addPath(childallowlist,pathexcludelist) + pathexcludelist = pathexclusions['longestcfp'].unique().tolist() + utils.policyfunctions.addPath(allowlist_child,pathexcludelist) - parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['target_column'].tolist() - utils.policyfunctions.addHash(parentallowlist,parentallowlisthashlist) + parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['sha256'].tolist() + utils.policyfunctions.addHash(allowlist_parent,parentallowlisthashlist) - childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['target_column'].tolist() - utils.policyfunctions.addHash(childallowlist,childallowlisthashlist) + childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['sha256'].tolist() + utils.policyfunctions.addHash(allowlist_child, childallowlisthashlist) else: print(ct.colorText("Operation aborted. You MUST EXPLICITLY AGREE to proceed.", "red")) diff --git a/allowlistandgroup.py b/allowlistandgroup.py new file mode 100644 index 0000000..c079723 --- /dev/null +++ b/allowlistandgroup.py @@ -0,0 +1,22 @@ +import requests +import dotenv +import json +import os +import utils.pretty as ct + +url = 'https://172.17.22.240:3129' +policiesnames = [] +policyids=[] +dotenv.load_dotenv() +endpoint = url + '/v1/application' +print(ct.colorText("[+] Grabbing All Allowlists", "cyan")) +payload = {} +headers = { + "X-APIKey": os.getenv('APIKEY') +} +response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False) +parse_text = json.loads(response.text) +for index, list in enumerate(parse_text['response']['applications'], start=1): + if index >= 38: + print(list) +#Need else and catch for upper bound \ No newline at end of file diff --git a/utils/allowlist.py b/utils/allowlist.py index 328c41b..1731b27 100644 --- a/utils/allowlist.py +++ b/utils/allowlist.py @@ -116,7 +116,7 @@ def listAllowlists(url): if choice < 38: print(ct.colorText("Please only choose an allowlist designed for this use - '38+'","red")) elif choice >= 38: - choice = int(choice) - 1 + choice = int(choice) - 38 return choice, policiesnames #Need else and catch for upper bound