Skip to content

Commit e544c81

Browse files
authored
Merge pull request #438 from ahmed-alnassif/master
feat(macchanger): add --random-mac-vendor flag and improve privacy with --random-mac
2 parents 0fd7bd1 + dc165bf commit e544c81

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

wifite/args.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,12 @@ def _add_global_args(self, glob):
297297
'--random-mac',
298298
action='store_true',
299299
dest='random_mac',
300-
help=Color.s('Randomize wireless card MAC address (default: {G}off{W})'))
300+
help=Color.s('Randomize wireless card MAC address completely (better privacy) (default: {G}off{W})'))
301+
302+
glob.add_argument('--random-mac-vendor',
303+
action='store_true',
304+
dest='random_mac_vendor',
305+
help=Color.s('Randomize wireless card MAC address but keep vendor bytes (better compatibility) (default: {G}off{W})'))
301306

302307
glob.add_argument('-p',
303308
action='store',

wifite/config.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Configuration(object):
4141
pmkid_timeout = None
4242
print_stack_traces = None
4343
random_mac = None
44+
random_mac_vendor = None
4445
require_fakeauth = None
4546
scan_time = None
4647
show_bssids = None
@@ -326,8 +327,8 @@ def get_monitor_mode_interface(cls):
326327
# Interface wasn't defined, select it!
327328
from .tools.airmon import Airmon
328329
cls.interface = Airmon.ask()
329-
if cls.random_mac:
330-
Macchanger.random()
330+
if cls.random_mac or cls.random_mac_vendor:
331+
Macchanger.random(full_random=not cls.random_mac_vendor)
331332

332333
@classmethod
333334
def load_from_arguments(cls):
@@ -578,9 +579,22 @@ def _validate_wpasec_config(cls):
578579
def parse_settings_args(cls, args):
579580
"""Parses basic settings/configurations from arguments."""
580581

581-
if args.random_mac:
582-
cls.random_mac = True
583-
Color.pl('{+} {C}option:{W} using {G}random mac address{W} when scanning & attacking')
582+
if args.random_mac or args.random_mac_vendor:
583+
if args.random_mac and args.random_mac_vendor:
584+
Color.pl('{!} {O}Warning: Cannot use both --random-mac and --random-mac-vendor')
585+
Color.pl('{+} {W}Falling back to {C}--random-mac{W} (full random) for better privacy')
586+
args.random_mac_vendor = False
587+
588+
if args.random_mac:
589+
cls.random_mac = True
590+
cls.random_mac_vendor = False
591+
mode_str = "full random (maximum privacy)"
592+
else:
593+
cls.random_mac_vendor = True
594+
cls.random_mac = False
595+
mode_str = "vendor-preserved (better compatibility)"
596+
597+
Color.pl('{+} {C}option:{W} using {G}random MAC address{W} ({C}%s{W}) when scanning & attacking' % mode_str)
584598

585599
if args.channel:
586600
chn_arg_re = re.compile(r"^\d+((,\d+)|(-\d+,\d+))*(-\d+)?$")

wifite/tools/macchanger.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def reset(cls):
6161
Color.pl('\r{+} {C}macchanger{W}: reset mac address back to {C}%s{W} on {C}%s{W}' % (new_mac, iface))
6262

6363
@classmethod
64-
def random(cls):
64+
def random(cls, full_random=True):
6565
from ..util.process import Process
6666
if not Process.exists('macchanger'):
6767
Color.pl('{!} {R}macchanger: {O}not installed')
@@ -72,7 +72,9 @@ def random(cls):
7272

7373
# -r to use random MAC address
7474
# -e to keep vendor bytes the same
75-
if cls.down_macch_up(iface, ['-e']):
75+
option = "-r" if full_random else "-e"
76+
77+
if cls.down_macch_up(iface, [option]):
7678
cls.is_changed = True
7779
new_mac = Ip.get_mac(iface)
7880

0 commit comments

Comments
 (0)