Files
AirlockTools/AirlockTools.py
T

100 lines
3.1 KiB
Python

import dotenv
import os
import utils.getdeviceevents
import utils.allowlist
import utils.hashfunctions
import utils.pathfunctions
import utils.allowfunctions
import urllib3
import pandas as pd
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
dotenv.load_dotenv()
url = "https://172.17.22.240:3129"
def apivalidation():
print("=== Welcome to the Airlock API Tool ===")
match os.getenv('APIKEY'):
case '':
print("Please add your API Key to the .env file")
case _:
menu()
def menu():
print("\n--- Main Menu ---")
print("1. Get All Events for Single Device")
print("2. Get Execution Histories for Allow List")
while True:
choice = input("Enter Menu Item: ")
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("z_augmented_list.html", index=False)
badpublisherlist = []
categorized = utils.hashfunctions.categorizeHashes(augmented, 5, badpublisherlist)
categorized[0].to_html("z_needs_review.html", index=False)
categorized[1].to_html("z_approved_hashes.html", index=False)
categorized[2].to_html("z_remaining.html", index=False)
if choice == '4':
html_file = "z_augmented_list.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("z_eligble_paths.html", index=False)
path_ineligible.to_html("z_ineligible_paths.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("z_augmented_list.html", index=False)
html_file = "z_augmented_list.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("z_eligble_paths.html", index=False)
path_ineligible.to_html("z_ineligible_paths.html",index=False)
badpublisherlist = ["Brave Software, Inc.", "Zoom Video Communications, Inc."]
categorized = utils.hashfunctions.categorizeHashes(augmented, 5, badpublisherlist)
categorized[0].to_html("z_needs_review.html", index=False)
categorized[1].to_html("z_approved_hashes.html", index=False)
categorized[2].to_html("z_remaining.html", index=False)
allowpaths = utils.allowfunctions.filter_and_drop(categorized[1],path_eligible,4)
allowpaths.to_html("z_allowed_paths.html", index=False)
if __name__ == "__main__":
apivalidation()