Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.13 KB | None | 0 0
  1. import os, signal
  2. def signal_handler(signal, frame):
  3.     print "\n[-] Exiting"
  4.     exit()
  5. signal.signal(signal.SIGINT, signal_handler)
  6. print '''
  7.  
  8.  
  9.  
  10. '''
  11. a=raw_input("######## mi9 ##########\n 1. sniffe specific Host \n 2.sniffe capture entire using CIDR notation\n 3.sniffe port number \n 4.specfic protocol\n 5.port range \n 6. packet size\n 7. Capture port number  \n 8.read capture\n 9.exit \n >> ")
  12. try :
  13.     c = int(a)
  14.     if c==1:
  15.         c1=int(raw_input("1.Sourece\n2.destination\n>> "))
  16.         if c1==1:
  17.             ip=raw_input("Enter ip Address")
  18.             os.system('tcpdump src '+str(ip))
  19.         elif c1==2:
  20.             ip=raw_input("Enter ip Address")
  21.             os.system("tcpdump dst "+str(ip))
  22.    
  23.    
  24.     elif c==2:
  25.         ip=raw_input("Enter ip Address")
  26.         CIDR=raw_input("Enter CIDR   ")
  27.         os.system('tcpdump net '+str(ip)+str(CIDR))  
  28.    
  29.     elif c==3:
  30.         c2=int(raw_input("1.Source Port \n2.Destination \n3.cobmbine src and DST \n >>"))
  31.         if c2==1:
  32.             port=raw_input("Enter Source port :   ")
  33.             os.system('tcpdump src port '+port)
  34.         elif c2==2:
  35.             port=raw_input("Enter Destination  port :   ")
  36.             os.system('tcpdump dst port '+port)
  37.  
  38.  
  39.  
  40.         elif c2==3:
  41.             SRC_port=raw_input("Enter SOURCE port : ") 
  42.             DST_port=raw_input("Enter Destination port :")
  43.             print "[*] Sniffing from : "+SRC_port+" to : "+DST_port
  44.             os.system('tcpdump src '+SRC_port+' and dst'+DST_port) 
  45.         else:
  46.             print "[-] Invalid Option :/"
  47.        
  48.     elif c==4:
  49.         c3=int(raw_input("1.TCP \n 2.UDP \n 3.ICMP\n >>"))
  50.         if c3==1:
  51.             print "[*] Sniffing TCP "
  52.             os.system('tcpdump -X tcp')
  53.         elif c3==2:
  54.             print "[*] Sniffing UDP "
  55.             os.system("tcpdump -X udp")
  56.         elif c3==3:
  57.             print "[*] Sniffing ICMP "
  58.             os.system("tcpdump -X icmp")
  59.        
  60.        
  61.    
  62.     elif c==5:
  63.         c4=int(raw_input("1. specify port range \n 2.Filtering \n >> "))
  64.         if c4==1:
  65.             B_port=raw_input("Enter Begin  port on range   :")
  66.             end_port=raw_input("Enter last port  ")
  67.             os.system('tcpdump -x portrange {}-{}'.format(B_port,end_port))
  68.         elif c4==2:
  69.             port=raw_input("Enter port to filter  ")
  70.             os.system('tcpdump -X not port {}'.format(port))
  71.    
  72.    
  73.     elif c==6:
  74.         packet=raw_input("Enter size   ")
  75.         c5=int(raw_input("1.les than \n 2. greater than  \n >>"))
  76.         #packet=raw_input("Enter size   ")
  77.         if c5==1:  
  78.             os.system('tcpdump -X less {}'.format(packet))
  79.         elif c5==2:
  80.             os.system('tcpdump -X greater {}'.format(packet))
  81.         elif c5==3:
  82.             os.system('tcpdump -X <= {}'.format(int(packet)))
  83.         elif c5==4:
  84.             os.system('tcpdump -X >= {}'.format(packet))
  85.  
  86.            
  87.          
  88.     elif c==7:
  89.         c6=int(raw_input("1. capture by ip \n 2. capture by port \n >>"))
  90.         if c6==1:
  91.             ip=raw_input("Enter ip address :  ")
  92.             path=raw_input("Enter path to save capture file")
  93.             os.system('tcpdump -s 1514 host {} -w {}'.format(ip,path))
  94.         elif c6==2:
  95.             ip=raw_input("Enter port  : ")
  96.             path=raw_input("Enter path to save capture file")
  97.             os.system('tcpdump port {} -w {}'.format(ip,path))
  98.  
  99.    
  100.     elif c==8:
  101.         path=raw_input("Enter path to save capture file")              
  102.         os.system('tcpdump -r {}'.format(path))
  103.     elif c==9:
  104.         print "[*] Exiting "
  105.         exit(0)
  106. except Exception as e :
  107.     print "[-] Something went wrong :/ \n[-] details"
  108.     print e
  109.     exit(-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement