-mac option to randomize mac before attack
Resets mac back after attack using macchanger's -p option. Requested in #2
This commit is contained in:
@@ -30,6 +30,11 @@ class Arguments(object):
|
||||
type=int,
|
||||
help=Color.s('Wireless channel to scan (default: {G}all channels{W})'))
|
||||
glob.add_argument('--channel', help=argparse.SUPPRESS, action='store', dest='channel', type=int)
|
||||
glob.add_argument('-mac',
|
||||
'---random-mac',
|
||||
action='store_true',
|
||||
dest='random_mac',
|
||||
help=Color.s('Randomize wireless card MAC address (default: {G}off{W})'))
|
||||
glob.add_argument('-5',
|
||||
'--5ghz',
|
||||
action='store_true',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from Macchanger import Macchanger
|
||||
|
||||
import os
|
||||
|
||||
@@ -34,6 +35,7 @@ class Configuration(object):
|
||||
Configuration.target_bssid = None # User-defined AP BSSID
|
||||
Configuration.five_ghz = False # Scan 5Ghz channels
|
||||
Configuration.pillage = False # "All" mode to attack everything
|
||||
Configuration.random_mac = False
|
||||
|
||||
Configuration.encryption_filter = ['WEP', 'WPA', 'WPS']
|
||||
|
||||
@@ -98,6 +100,8 @@ class Configuration(object):
|
||||
# Interface wasn't defined, select it!
|
||||
from Airmon import Airmon
|
||||
Configuration.interface = Airmon.ask()
|
||||
if Configuration.random_mac:
|
||||
Macchanger.random()
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -106,6 +110,9 @@ class Configuration(object):
|
||||
from Arguments import Arguments
|
||||
|
||||
args = Arguments(Configuration).args
|
||||
if args.random_mac:
|
||||
Configuration.random_mac = True
|
||||
Color.pl('{+} {C}option:{W} using {G}random mac address{W} when scanning & attacking')
|
||||
if args.channel:
|
||||
Configuration.target_channel = args.channel
|
||||
Color.pl('{+} {C}option:{W} scanning for targets on channel {G}%s{W}' % args.channel)
|
||||
@@ -278,6 +285,7 @@ class Configuration(object):
|
||||
def exit_gracefully(code=0):
|
||||
''' Deletes temp and exist with the given code '''
|
||||
Configuration.delete_temp()
|
||||
Macchanger.reset_if_changed()
|
||||
exit(code)
|
||||
|
||||
@staticmethod
|
||||
|
||||
82
py/Macchanger.py
Normal file
82
py/Macchanger.py
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Interface import Interface
|
||||
from Color import Color
|
||||
|
||||
class Macchanger(object):
|
||||
is_init = False
|
||||
is_changed = False
|
||||
original_mac = None
|
||||
|
||||
@classmethod
|
||||
def init(cls):
|
||||
if cls.is_init: return
|
||||
from Configuration import Configuration
|
||||
iface = Configuration.interface
|
||||
if type(iface) == Interface:
|
||||
iface = iface.name
|
||||
cls.original_mac = Interface.get_mac(iface)
|
||||
|
||||
@classmethod
|
||||
def down_macch_up(cls, macch_option):
|
||||
cls.init()
|
||||
from Process import Process
|
||||
from Configuration import Configuration
|
||||
iface = Configuration.interface
|
||||
|
||||
cmd = ["ifconfig", iface, "down"]
|
||||
Color.clear_entire_line()
|
||||
Color.p("\r{+} {C}macchanger{W}: Taking interface {C}%s{W} down..." % iface)
|
||||
ifdown = Process(cmd)
|
||||
ifdown.wait()
|
||||
if ifdown.poll() != 0:
|
||||
Color.pl("{!} {C}macchanger{W}: Error running %s" % " ".join(cmd))
|
||||
Color.pl("{!} Output: %s, %s" % (ifdown.stdout(), ifdown.stderr()))
|
||||
return False
|
||||
|
||||
cmd = ["macchanger", macch_option, iface]
|
||||
Color.clear_entire_line()
|
||||
Color.p("\r{+} {C}macchanger{W}: Changing MAC address of interface {C}%s{W}..." % iface)
|
||||
macch = Process(cmd)
|
||||
macch.wait()
|
||||
if macch.poll() != 0:
|
||||
Color.pl("{!} {C}macchanger{W}: Error running %s" % " ".join(cmd))
|
||||
Color.pl("{!} Output: %s, %s" % (macch.stdout(), macch.stderr()))
|
||||
return False
|
||||
|
||||
cmd = ["ifconfig", iface, "up"]
|
||||
Color.clear_entire_line()
|
||||
Color.p("\r{+} {C}macchanger{W}: Bringing interface {C}%s{W} up..." % iface)
|
||||
ifup = Process(cmd)
|
||||
ifup.wait()
|
||||
if ifup.poll() != 0:
|
||||
Color.pl("{!} {C}macchanger{W}: Error running %s" % " ".join(cmd))
|
||||
Color.pl("{!} Output: %s, %s" % (ifup.stdout(), ifup.stderr()))
|
||||
return False
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
# --permanent to reset to permanent MAC address
|
||||
if not cls.down_macch_up("-p"): return
|
||||
Color.pl("\r{+} {C}macchanger{W}: Resetting MAC address...")
|
||||
from Configuration import Configuration
|
||||
new_mac = Interface.get_mac(Configuration.interface)
|
||||
Color.clear_entire_line()
|
||||
Color.pl("\r{+} {C}macchanger{W}: Reset MAC address back to {C}%s{W}" % new_mac)
|
||||
|
||||
@classmethod
|
||||
def random(cls):
|
||||
# Use --permanent to use random MAC address
|
||||
if not cls.down_macch_up("-r"): return
|
||||
cls.is_changed = True
|
||||
from Configuration import Configuration
|
||||
new_mac = Interface.get_mac(Configuration.interface)
|
||||
Color.clear_entire_line()
|
||||
Color.pl("\r{+} {C}macchanger{W}: Changed MAC address to {C}%s{W}" % new_mac)
|
||||
|
||||
@classmethod
|
||||
def reset_if_changed(cls):
|
||||
if not cls.is_changed: return
|
||||
cls.reset()
|
||||
Reference in New Issue
Block a user