Skip to content

Instantly share code, notes, and snippets.

Created April 19, 2023 13:29
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
altitude alert
import csv
import requests
import argparse
from bs4 import BeautifulSoup
from colorama import Fore, Style, init
known_security_vendors = [
'symantec', 'mcafee', 'trendmicro', 'kaspersky', 'bitdefender',
'sophos', 'avast', 'avg', 'avira', 'comodo', 'eset', 'f-secure',
'fortinet', 'bit9', 'malwarebytes', 'panda security', 'webroot',
'sentinelone', 'fireeye', 'crowdstrike', 'trendmicro'
def download_altitudes(url, output_filename):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
table_rows ='table tbody tr')
data = []
for row in table_rows:
cells = row.find_all('td')
minifilter = cells[0].get_text(strip=True)
altitude = cells[1].get_text(strip=True)
company = cells[2].get_text(strip=True)
data.append([minifilter, altitude, company])
with open(output_filename, 'w', newline='', encoding='utf-8') as csvfile:
csv_writer = csv.writer(csvfile)
csv_writer.writerow(['Minifilter', 'Altitude', 'Company'])
print(f"Data has been written to {output_filename}")
def parse_vendors(altitudes_csv, min_altitude, max_altitude):
vendors = []
with open(altitudes_csv, 'r', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
altitude = float(row['Altitude'])
if min_altitude <= altitude <= max_altitude:
except ValueError:
# Skip the row if the altitude value cannot be converted to a float
return list(set(vendors))
def lookup_drivers(input_filename, altitudes_csv):
drivers = []
with open(input_filename, 'r', encoding='utf-8') as file:
drivers = [line.strip() for line in file]
found_drivers = []
with open(altitudes_csv, 'r', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
if row['Minifilter'] in drivers:
vendors_320000_329998 = parse_vendors(altitudes_csv, 320000, 329998)
for driver in found_drivers:
if any([vendor.lower() in driver['Company'].lower() for vendor in known_security_vendors]):
print(Fore.RED + f"{driver['Minifilter']}, {driver['Altitude']}, {driver['Company']}")
elif driver['Company'] in vendors_320000_329998:
print(Fore.RED + f"{driver['Minifilter']}, {driver['Altitude']}, {driver['Company']}")
print(f"{driver['Minifilter']}, {driver['Altitude']}, {driver['Company']}")
def main():
parser = argparse.ArgumentParser(description='Download and lookup driver altitudes.')
parser.add_argument('-d', '--download', action='store_true', help='Download altitudes data and save it to a CSV file')
parser.add_argument('-l', '--lookup', metavar='FILE', help='Lookup drivers from a file and display their altitudes and companies')
args = parser.parse_args()
url = ''
output_filename = 'allocated_altitudes.csv'
download_altitudes(url, output_filename)
if args.lookup:
lookup_drivers(args.lookup, output_filename)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment