diff --git a/wifite/args.py b/wifite/args.py index af6b618..5228e3f 100755 --- a/wifite/args.py +++ b/wifite/args.py @@ -154,6 +154,11 @@ class Arguments(object): help=self._verbose('Number of deauth packets to send (default: ' + '{G}%d{W})' % self.config.num_deauths)) + glob.add_argument('--demon', + action='store_true', + dest='demon', + help=Color.s('Puts device back in managed mode after quitting (default: '+ + '{G}off{W})')) def _add_eviltwin_args(self, group): pass diff --git a/wifite/attack/wep.py b/wifite/attack/wep.py index cef71cf..fd47219 100755 --- a/wifite/attack/wep.py +++ b/wifite/attack/wep.py @@ -5,7 +5,7 @@ from ..model.attack import Attack from ..tools.airodump import Airodump from ..tools.aireplay import Aireplay, WEPAttackType from ..tools.aircrack import Aircrack -from ..tools.ifconfig import Ifconfig +from ..tools.ip import Ip from ..config import Configuration from ..util.color import Color from ..util.input import raw_input @@ -67,7 +67,7 @@ class AttackWEP(Attack): if self.fake_auth(): # We successfully authenticated! # Use our interface's MAC address for the attacks. - client_mac = Ifconfig.get_mac(Configuration.interface) + client_mac = Ip.get_mac(Configuration.interface) # Keep us authenticated fakeauth_proc = Aireplay(self.target, 'fakeauth') elif len(airodump_target.clients) == 0: @@ -303,7 +303,7 @@ class AttackWEP(Attack): Color.p('\r{+} {O}Deauthenticating *broadcast*{W} (all clients)...') Aireplay.deauth(target.bssid, essid=target.essid) - attacking_mac = Ifconfig.get_mac(Configuration.interface) + attacking_mac = Ip.get_mac(Configuration.interface) for client in target.clients: if attacking_mac.lower() == client.station.lower(): continue # Don't deauth ourselves. diff --git a/wifite/config.py b/wifite/config.py index 9759ff5..3213fc7 100755 --- a/wifite/config.py +++ b/wifite/config.py @@ -48,6 +48,7 @@ class Configuration(object): cls.random_mac = False # Should generate a random Mac address at startup. cls.no_deauth = False # Deauth hidden networks & WPA handshake targets cls.num_deauths = 1 # Number of deauth packets to send to each target. + cls.demon = False # Don't put back interface back in managed mode cls.encryption_filter = ['WEP', 'WPA', 'WPS'] @@ -173,6 +174,7 @@ class Configuration(object): @classmethod def parse_settings_args(cls, args): '''Parses basic settings/configurations from arguments.''' + if args.random_mac: cls.random_mac = True Color.pl('{+} {C}option:{W} using {G}random mac address{W} ' + @@ -206,6 +208,10 @@ class Configuration(object): Color.pl('{+} {C}option:{W} will {R}not{W} {O}deauth{W} clients ' + 'during scans or captures') + if args.demon == True: + cls.demon = True + Color.pl('{+} {C}option:{W} will put interface back to managed mode') + if args.num_deauths and args.num_deauths > 0: cls.num_deauths = args.num_deauths Color.pl('{+} {C}option:{W} send {G}%d{W} deauth packets when deauthing' % ( @@ -474,14 +480,15 @@ class Configuration(object): Macchanger.reset_if_changed() from .tools.airmon import Airmon if cls.interface is not None and Airmon.base_interface is not None: - Color.pl('{!} {O}Note:{W} Leaving interface in Monitor Mode!') - Color.pl('{!} To disable Monitor Mode when finished: ' + + if not cls.demon: + Color.pl('{!} {O}Note:{W} Leaving interface in Monitor Mode!') + Color.pl('{!} To disable Monitor Mode when finished: ' + '{C}airmon-ng stop %s{W}' % cls.interface) - - # Stop monitor mode - #Airmon.stop(cls.interface) - # Bring original interface back up - #Airmon.put_interface_up(Airmon.base_interface) + else: + # Stop monitor mode + Airmon.stop(cls.interface) + # Bring original interface back up + Airmon.put_interface_up(Airmon.base_interface) if Airmon.killed_network_manager: Color.pl('{!} You can restart NetworkManager when finished ({C}service network-manager start{W})') diff --git a/wifite/tools/airmon.py b/wifite/tools/airmon.py index 37071bd..33a3fb2 100755 --- a/wifite/tools/airmon.py +++ b/wifite/tools/airmon.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from .dependency import Dependency -from .ifconfig import Ifconfig +from .ip import Ip from .iw import Iw from ..util.process import Process from ..util.color import Color @@ -113,9 +113,9 @@ class Airmon(Dependency): Manually put interface into monitor mode (no airmon-ng or vif). Fix for bad drivers like the rtl8812AU. ''' - Ifconfig.down(iface) + Ip.down(iface) Iw.mode(iface, 'monitor') - Ifconfig.up(iface) + Ip.up(iface) # /sys/class/net/wlan0/type iface_type_path = os.path.join('/sys/class/net', iface, 'type') @@ -132,9 +132,9 @@ class Airmon(Dependency): Manually put interface into managed mode (no airmon-ng or vif). Fix for bad drivers like the rtl8812AU. ''' - Ifconfig.down(iface) + Ip.down(iface) Iw.mode(iface, 'managed') - Ifconfig.up(iface) + Ip.up(iface) # /sys/class/net/wlan0/type iface_type_path = os.path.join('/sys/class/net', iface, 'type') @@ -216,20 +216,20 @@ class Airmon(Dependency): @staticmethod def stop(iface): - Color.p('{!} {R}disabling {O}monitor mode{O} on {R}%s{O}... ' % iface) + Color.p('{!}{W} Disabling {O}monitor{W} mode on {R}%s{W}...\n' % iface) airmon_output = Process(['airmon-ng', 'stop', iface]).stdout() (disabled_iface, enabled_iface) = Airmon._parse_airmon_stop(airmon_output) if not disabled_iface and iface in Airmon.BAD_DRIVERS: - Color.p('{O}"bad driver" detected{W} ') + Color.p('{!} {O}"bad driver" detected{W} ') disabled_iface = Airmon.stop_bad_driver(iface) if disabled_iface: - Color.pl('{G}disabled %s{W}' % disabled_iface) + Color.pl('{+}{W} Disabled monitor mode on {G}%s{W}' % disabled_iface) else: - Color.pl('{O}could not disable on {R}%s{W}' % iface) + Color.pl('{!} {O}Could not disable {R}%s{W}' % iface) return (disabled_iface, enabled_iface) @@ -373,9 +373,9 @@ class Airmon(Dependency): @staticmethod def put_interface_up(iface): - Color.p('{!} {O}putting interface {R}%s up{O}...' % (iface)) - Ifconfig.up(iface) - Color.pl(' {G}done{W}') + Color.p('{!}{W} Putting interface {R}%s{W} {G}up{W}...\n' % (iface)) + Ip.up(iface) + Color.pl('{+}{W} Done !') @staticmethod def start_network_manager(): diff --git a/wifite/tools/dependency.py b/wifite/tools/dependency.py index 7ca314d..dcf4c04 100755 --- a/wifite/tools/dependency.py +++ b/wifite/tools/dependency.py @@ -28,7 +28,7 @@ class Dependency(object): from .airodump import Airodump from .aircrack import Aircrack from .aireplay import Aireplay - from .ifconfig import Ifconfig + from .ip import Ip from .iw import Iw from .bully import Bully from .reaver import Reaver @@ -42,7 +42,7 @@ class Dependency(object): # Aircrack Aircrack, #Airodump, Airmon, Aireplay, # wireless/net tools - Iw, Ifconfig, + Iw, Ip, # WPS Reaver, Bully, # Cracking/handshakes diff --git a/wifite/tools/ifconfig.py b/wifite/tools/ip.py similarity index 61% rename from wifite/tools/ifconfig.py rename to wifite/tools/ip.py index 7ace58d..a06c475 100755 --- a/wifite/tools/ifconfig.py +++ b/wifite/tools/ip.py @@ -5,17 +5,17 @@ import re from .dependency import Dependency -class Ifconfig(Dependency): +class Ip(Dependency): dependency_required = True - dependency_name = 'ifconfig' - dependency_url = 'apt-get install net-tools' + dependency_name = 'ip' + dependency_url = 'apt-get install ip' @classmethod def up(cls, interface, args=[]): '''Put interface up''' from ..util.process import Process - command = ['ifconfig', interface] + command = ['ip', 'link', 'set', interface] if type(args) is list: command.extend(args) elif type(args) is 'str': @@ -33,7 +33,7 @@ class Ifconfig(Dependency): '''Put interface down''' from ..util.process import Process - pid = Process(['ifconfig', interface, 'down']) + pid = Process(['ip', 'link', 'set', interface, 'down']) pid.wait() if pid.poll() != 0: raise Exception('Error putting interface %s down:\n%s\n%s' % (interface, pid.stdout(), pid.stderr())) @@ -43,19 +43,11 @@ class Ifconfig(Dependency): def get_mac(cls, interface): from ..util.process import Process - output = Process(['ifconfig', interface]).stdout() + output = Process(['ip', 'link show', interface]).stdout() - # Mac address separated by dashes - mac_dash_regex = ('[a-zA-Z0-9]{2}-' * 6)[:-1] - match = re.search(' ({})'.format(mac_dash_regex), output) + match = re.search(r'([a-fA-F0-9]{2}[-:]){5}[a-fA-F0-9]{2}', output) if match: - return match.group(1).replace('-', ':') - - # Mac address separated by colons - mac_colon_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1] - match = re.search(' ({})'.format(mac_colon_regex), output) - if match: - return match.group(1) + return match.group(0).replace('-', ':') raise Exception('Could not find the mac address for %s' % interface) diff --git a/wifite/tools/iwconfig.py b/wifite/tools/iwconfig.py deleted file mode 100755 index e82f56d..0000000 --- a/wifite/tools/iwconfig.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from .dependency import Dependency - -class Iwconfig(Dependency): - dependency_required = True - dependency_name = 'iwconfig' - dependency_url = 'apt-get install wireless-tools' - - - @classmethod - def mode(cls, iface, mode_name): - from ..util.process import Process - - pid = Process(['iwconfig', iface, 'mode', mode_name]) - pid.wait() - - return pid.poll() - - - @classmethod - def get_interfaces(cls, mode=None): - from ..util.process import Process - - interfaces = set() - iface = '' - - (out, err) = Process.call('iwconfig') - for line in out.split('\n'): - if len(line) == 0: continue - - if not line.startswith(' '): - iface = line.split(' ')[0] - if '\t' in iface: - iface = iface.split('\t')[0].strip() - - iface = iface.strip() - if len(iface) == 0: - continue - - if mode is None: - interfaces.add(iface) - - if mode is not None and 'Mode:{}'.format(mode) in line and len(iface) > 0: - interfaces.add(iface) - - return list(interfaces) - diff --git a/wifite/tools/macchanger.py b/wifite/tools/macchanger.py index 593a941..c9c9a87 100755 --- a/wifite/tools/macchanger.py +++ b/wifite/tools/macchanger.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from .dependency import Dependency -from ..tools.ifconfig import Ifconfig +from ..tools.ip import Ip from ..util.color import Color class Macchanger(Dependency): @@ -20,7 +20,7 @@ class Macchanger(Dependency): Color.clear_entire_line() Color.p('\r{+} {C}macchanger{W}: taking interface {C}%s{W} down...' % iface) - Ifconfig.down(iface) + Ip.down(iface) Color.clear_entire_line() Color.p('\r{+} {C}macchanger{W}: changing mac address of interface {C}%s{W}...' % iface) @@ -38,7 +38,7 @@ class Macchanger(Dependency): Color.clear_entire_line() Color.p('\r{+} {C}macchanger{W}: bringing interface {C}%s{W} up...' % iface) - Ifconfig.up(iface) + Ip.up(iface) return True @@ -56,7 +56,7 @@ class Macchanger(Dependency): Color.pl('\r{+} {C}macchanger{W}: resetting mac address on %s...' % iface) # -p to reset to permanent MAC address if cls.down_macch_up(iface, ['-p']): - new_mac = Ifconfig.get_mac(iface) + new_mac = Ip.get_mac(iface) Color.clear_entire_line() Color.pl('\r{+} {C}macchanger{W}: reset mac address back to {C}%s{W} on {C}%s{W}' % (new_mac, iface)) @@ -76,7 +76,7 @@ class Macchanger(Dependency): # -e to keep vendor bytes the same if cls.down_macch_up(iface, ['-e']): cls.is_changed = True - new_mac = Ifconfig.get_mac(iface) + new_mac = Ip.get_mac(iface) Color.clear_entire_line() Color.pl('\r{+} {C}macchanger{W}: changed mac address to {C}%s{W} on {C}%s{W}' % (new_mac, iface))