From a0abfb374577e2af1f34a280c20c9bdb353f78ee Mon Sep 17 00:00:00 2001 From: TiredFromTelehack Date: Mon, 21 Oct 2024 22:29:01 +0200 Subject: [PATCH] updated python script --- ipGeo.py | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/ipGeo.py b/ipGeo.py index 82be1ae..23436cb 100644 --- a/ipGeo.py +++ b/ipGeo.py @@ -3,12 +3,31 @@ import requests import json import csv import argparse -from colorama import Fore +from colorama import Fore, Style from datetime import date import ipaddress import subprocess +def display_banner(): + """Display a welcome banner.""" + banner = f""" + {Fore.BLUE + Style.BRIGHT} + +$$$$$$$\\ $$$$$$$\\ $$$$$$$$\\ $$$$$$\\ $$$$$$$\\ $$$$$$$$\\ $$\\ $$\\ $$\\ +$$ __$$\\ $$ __$$\\ $$ _____|$$ __$$\\ $$ __$$\\ $$ _____|$$ | $$ |$$ | +$$ | $$ |$$ | $$ |$$ | $$ / $$ |$$ | $$ |$$ | $$ | $$ |$$ | +$$ | $$ |$$$$$$$ |$$$$$\\ $$$$$$$$ |$$ | $$ |$$$$$\\ $$ | $$ |$$ | +$$ | $$ |$$ __$$< $$ __| $$ __$$ |$$ | $$ |$$ __| $$ | $$ |$$ | +$$ | $$ |$$ | $$ |$$ | $$ | $$ |$$ | $$ |$$ | $$ | $$ |$$ | +$$$$$$$ |$$ | $$ |$$$$$$$$\\ $$ | $$ |$$$$$$$ |$$ | \\$$$$$$ |$$$$$$$$\\ +\\_______/ \\__| \\__|\\________|\\__| \\__|\\_______/ \\__| \\______/ \\________| + + {Style.RESET_ALL}Welcome to the PCAP IP Extractor and Geolocator! + """ + print(banner) + + def get_local_ips(): """Retrieve a list of local IPs and their subnets.""" local_ips = set() @@ -139,14 +158,32 @@ def export_result(data, output_format): print(Fore.GREEN + "\n **Report Exported Successfully!**") +def interactive_mode(): + """Run the script in interactive mode.""" + print(Fore.YELLOW + "Interactive Mode: Please enter the path to the pcap file:") + pcap_file = input("Pcap File Path: ").strip() + print(Fore.YELLOW + "Choose output format (json, csv, txt, md):") + output_format = input("Output Format: ").strip().lower() + + if output_format not in ['json', 'csv', 'txt', 'md']: + print(Fore.RED + "[!] Invalid output format. Defaulting to json.") + output_format = 'json' + + read_pcap(pcap_file, output_format) + + def main(): + display_banner() # Call the display banner function parser = argparse.ArgumentParser(description='Extract IP addresses from pcap files and geolocate them.') - parser.add_argument('pcap', help='Path to the pcap file.') + parser.add_argument('pcap', nargs='?', help='Path to the pcap file.') parser.add_argument('--format', choices=['json', 'csv', 'txt', 'md'], default='json', help='Output format (default: json).') args = parser.parse_args() - read_pcap(args.pcap, args.format) + if args.pcap: + read_pcap(args.pcap, args.format) + else: + interactive_mode() # Enter interactive mode if no arguments are provided if __name__ == "__main__":