# 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 . import dotenv import os import utils.getdeviceevents import utils.allowlist import utils.hashfunctions import utils.pathfunctions import urllib3 import pandas as pd urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) dotenv.load_dotenv() url = "https://172.17.22.240:3129" badpublisherlist = ["Brave Software, Inc.", "Zoom Video Communications, Inc."] path_exclusion_constant = 3 threat_tolerance_constant = 4 def apivalidation(): print(ct.colorText(r""" _____ .__ .__ __ ___________ .__ / _ \ |__|______| | ____ ____ | | __ \__ ___/___ ____ | | ______ / /_\ \| \_ __ \ | / _ \_/ ___\| |/ / | | / _ \ / _ \| | / ___/ / | \ || | \/ |_( <_> ) \___| < | |( <_> | <_> ) |__\___ \ \____|__ /__||__| |____/\____/ \___ >__|_ \ |____| \____/ \____/|____/____ > \/ \/ \/ \/ """, "cyan")) print(ct.colorText("=================================================================================", "cyan")) print(ct.colorText("======================== Welcome to the Airlock API Tool ========================", "cyan")) print(ct.colorText("=================================================================================", "cyan")) match os.getenv('APIKEY'): case '': print(ct.colorText("Please add your API Key to the .env file", "red")) case _: menu_main() def menu_main(): while True: print(ct.colorText("\n-----------------------------------", "magenta")) print(ct.colorText("------------ Main Menu ------------", "magenta")) print(ct.colorText("-----------------------------------", "magenta")) print(ct.colorText("1. Get All Events for Single Device", "yellow")) print(ct.colorText("2. Placeholder for Local Approval", "yellow")) print(ct.colorText("3. Placeholder for Another Tool", "yellow")) print(ct.colorText("4. Prepare Policy For Enforcement", "yellow")) print(ct.colorText("Q. Quit", "yellow")) choice = input(ct.colorText("\nEnter Menu Item: ", "white")) if choice == '1': utils.getdeviceevents.devicehistory(url,False) if choice == '2': utils.allowlist.allowlistexechistories(url,False) if choice == '3': executionhist = utils.allowlist.allowlistexechistories(url,True) print(executionhist) aggregated = utils.hashfunctions.aggregateHashes(executionhist) print(aggregated) augmented = utils.hashfunctions.augmentAggregatedHashes(url,aggregated) print(augmented) augmented.to_html("augmentedlist.html", index=False) badpublisherlist = [] categorized = utils.hashfunctions.categorizeHashes(augmented, 5, badpublisherlist) categorized[0].to_html("needsreview.html", index=False) categorized[1].to_html("approved.html", index=False) categorized[2].to_html("remaining.html", index=False) if choice == '4': html_file = "augmentedlist.html" augmented_df = pd.read_html(html_file) print(augmented_df) combined_df = pd.concat(augmented_df, ignore_index=True) path_eligible, path_ineligible = utils.pathfunctions.filepathInitialGroup(combined_df) path_eligible.to_html("EligblePaths.html", index=False) path_ineligible.to_html("IneligiblePaths.html",index=False) if choice == '5': executionhist = utils.allowlist.allowlistexechistories(url,True) print(executionhist) aggregated = utils.hashfunctions.aggregateHashes(executionhist) print(aggregated) augmented = utils.hashfunctions.augmentAggregatedHashes(url,aggregated) print(augmented) augmented.to_html("augmentedlist.html", index=False) html_file = "augmentedlist.html" augmented_df = pd.read_html(html_file) combined_df = pd.concat(augmented_df, ignore_index=True) path_eligible, path_ineligible = utils.pathfunctions.filepathInitialGroup(combined_df) path_eligible.to_html("EligblePaths.html", index=False) path_ineligible.to_html("IneligiblePaths.html",index=False) badpublisherlist = [] categorized = utils.hashfunctions.categorizeHashes(augmented, 5, badpublisherlist) categorized[0].to_html("needsreview.html", index=False) categorized[1].to_html("approved.html", index=False) categorized[2].to_html("remaining.html", index=False) if __name__ == "__main__": apivalidation()