diff --git a/AirlockTools.py b/AirlockTools.py index ecfdedb..3f3131d 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -230,8 +230,12 @@ def menu_prepare_to_enforce(): if not os.path.exists(f"parquet\\condensed_executions_{first_policy}_{second_policy}.parquet"): utils.hashfunctions.condenseExecutions(first_policy,second_policy) - if os.path.exists(f"parquet\\hashes_rep_unknown_{first_policy}_{second_policy}.parquet") & os.path.exists(f"parquet\\hashes_rep_good_{first_policy}_{second_policy}.parquet") & os.path.exists(f"parquet\\hashes_rep_bad_{first_policy}_{second_policy}.parquet"): - utils.hashfunctions.divideSortedHashExecutions(first_policy,second_policy,pups) + if ( + os.path.exists(f"parquet\\hashes_rep_unknown_{first_policy}_{second_policy}.parquet") and + os.path.exists(f"parquet\\hashes_rep_good_{first_policy}_{second_policy}.parquet") and + os.path.exists(f"parquet\\hashes_rep_bad_{first_policy}_{second_policy}.parquet") and + not os.path.exists(f"needs_approved\\hashes_rep_unknown_{first_policy}_{second_policy}.csv") + ):utils.hashfunctions.divideSortedHashExecutions(first_policy,second_policy,pups) elif choice == "3": diff --git a/allowlistandgroup.py b/allowlistandgroup.py deleted file mode 100644 index 5fcf86f..0000000 --- a/allowlistandgroup.py +++ /dev/null @@ -1,22 +0,0 @@ -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 diff --git a/utils/clientfunctions.py b/utils/clientfunctions.py index 324ec8a..c49537a 100644 --- a/utils/clientfunctions.py +++ b/utils/clientfunctions.py @@ -1,9 +1,29 @@ -import json -import requests -import os -import pandas as pd +# Copyright (C) 2025 James Brotosky, Brandon Wickline +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#Local Imports import utils.pretty as ct +#Standard Libary Imports: +import datetime +import json +import os + +#3rd Party Imports: +import pandas as pd +import requests def findAgentID(url): @@ -101,11 +121,7 @@ def getPolicyName(url, groupid): data = pd.DataFrame(result["response"]["groups"]) name = data.loc[data['groupid'] == f"{groupid}", 'name'].values[0] return name -import datetime -import requests -import json -import os -import utils.pretty as ct + def devicehistory(url, outputjson: bool): endpoint = url + '/v1/getexechistory' diff --git a/utils/hashfunctions.py b/utils/hashfunctions.py index 3a3f819..b4e8c84 100644 --- a/utils/hashfunctions.py +++ b/utils/hashfunctions.py @@ -12,15 +12,21 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +#Local Imports +import utils.hashfunctions as hashf +import utils.pathfunctions as pathf +import utils.pretty as ct +from AirlockTools import tryToReadCSV + +#Standard Libary Imports: import gc import json import os + +#3rd Party Imports: import pandas as pd import requests -import utils.pathfunctions as pathf -import utils.hashfunctions as hashf -import utils.pretty as ct -from AirlockTools import tryToReadCSV def aggregateHashes(executions_json) -> pd.DataFrame: """ diff --git a/utils/otpfunctions.py b/utils/otpfunctions.py index 2d03a30..31932f1 100644 --- a/utils/otpfunctions.py +++ b/utils/otpfunctions.py @@ -1,15 +1,35 @@ -import json -import requests -import os -import pandas as pd -import utils.pretty as ct -import math -import time +# Copyright (C) 2025 James Brotosky, Brandon Wickline +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#Local Imports import utils.clientfunctions as clientf import utils.pathfunctions as pathf import utils.policyfunctions as policyf +import utils.pretty as ct from utils.perstscheduler import register_function, run_once_job, recurring_job, reload_jobs, start_scheduler, find_and_prioritize_jobs_by_pid +#Standard Libary Imports: +import json +import math +import os +import time + +#3rd Party Imports: +import pandas as pd +import requests + def getActiveOTP(url): endpoint = url + f'/v1/otp/usage' diff --git a/utils/pathfunctions.py b/utils/pathfunctions.py index e1ddfbb..9c48f3c 100644 --- a/utils/pathfunctions.py +++ b/utils/pathfunctions.py @@ -12,15 +12,20 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import ast -import gc -import os -import pandas as pd -import re + +#Local Imports import utils.pathfunctions as pathf import utils.pretty as ct from AirlockTools import tryToReadCSV +#Standard Libary Imports: +import ast +import gc +import os +import re + +#3rd Party Imports: +import pandas as pd def split_filepaths_grouped(df, col="filename", group_parts=4, min_parts=4): def clean_split(path): diff --git a/utils/perstscheduler.py b/utils/perstscheduler.py index 0a750cf..71e0489 100644 --- a/utils/perstscheduler.py +++ b/utils/perstscheduler.py @@ -1,10 +1,13 @@ -import schedule -import time +#Standard Libary Imports: import json import os +import time from typing import Callable, Any, List, Dict +#3rd Party Imports: +import schedule + # File where all jobs are persisted JOBS_FILE = "scheduling\\jobs.json" diff --git a/utils/policyfunctions.py b/utils/policyfunctions.py index 227a48d..6dee8aa 100644 --- a/utils/policyfunctions.py +++ b/utils/policyfunctions.py @@ -12,23 +12,22 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +#Local Imports +import utils.pretty as ct +#Standard Libary Imports: +import datetime import gc import json import os -import pandas as pd import re -import requests -import utils.pretty as ct -import datetime -import requests -import ijson -from bson import ObjectId -import datetime -import tqdm import sys - - - +#3rd Party Imports: +import ijson +import pandas as pd +import requests +import tqdm +from bson import ObjectId def addHash(url, policy, hash): print(f"Adding the following: {hash} \n to {policy}:") diff --git a/utils/pretty.py b/utils/pretty.py index aaba329..1635dc9 100644 --- a/utils/pretty.py +++ b/utils/pretty.py @@ -12,6 +12,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +#Standard Libary Imports: import os def colorText(text: str, color: str) -> str: