ivanvza / arpy

Mac OSX ARP spoof (MiTM) tool that can also plug into Gource
MIT License
262 stars 53 forks source link

Suggestion: Add an exit handler to revert port forwarding #19

Open awhipp opened 5 years ago

awhipp commented 5 years ago

Easiest way to do this is create an exit handler with the atexit package. Below is an example that I used in my fork of this branch:

def exit_handler():
        if not dns_sniff_gource:
            print(bcolours.OKBLUE + '[Info] Disabling IP Forwarding...' + bcolours.ENDC)
        os.system('sysctl -w net.inet.ip.forwarding=0 > /dev/null')
        os.system('sudo sysctl -w net.inet.ip.forwarding=0 > /dev/null ')
        print(bcolours.OKBLUE + '[Info] Application Ended Gracefully.' + bcolours.ENDC)

atexit.register(exit_handler)