Migrated from ifconfig to ip

This commit is contained in:
2019-01-27 17:11:56 +01:00
parent 4baf8f5c46
commit 104e45637b
8 changed files with 49 additions and 94 deletions

View File

@@ -154,6 +154,11 @@ class Arguments(object):
help=self._verbose('Number of deauth packets to send (default: ' + help=self._verbose('Number of deauth packets to send (default: ' +
'{G}%d{W})' % self.config.num_deauths)) '{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): def _add_eviltwin_args(self, group):
pass pass

View File

@@ -5,7 +5,7 @@ from ..model.attack import Attack
from ..tools.airodump import Airodump from ..tools.airodump import Airodump
from ..tools.aireplay import Aireplay, WEPAttackType from ..tools.aireplay import Aireplay, WEPAttackType
from ..tools.aircrack import Aircrack from ..tools.aircrack import Aircrack
from ..tools.ifconfig import Ifconfig from ..tools.ip import Ip
from ..config import Configuration from ..config import Configuration
from ..util.color import Color from ..util.color import Color
from ..util.input import raw_input from ..util.input import raw_input
@@ -67,7 +67,7 @@ class AttackWEP(Attack):
if self.fake_auth(): if self.fake_auth():
# We successfully authenticated! # We successfully authenticated!
# Use our interface's MAC address for the attacks. # 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 # Keep us authenticated
fakeauth_proc = Aireplay(self.target, 'fakeauth') fakeauth_proc = Aireplay(self.target, 'fakeauth')
elif len(airodump_target.clients) == 0: elif len(airodump_target.clients) == 0:
@@ -303,7 +303,7 @@ class AttackWEP(Attack):
Color.p('\r{+} {O}Deauthenticating *broadcast*{W} (all clients)...') Color.p('\r{+} {O}Deauthenticating *broadcast*{W} (all clients)...')
Aireplay.deauth(target.bssid, essid=target.essid) 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: for client in target.clients:
if attacking_mac.lower() == client.station.lower(): if attacking_mac.lower() == client.station.lower():
continue # Don't deauth ourselves. continue # Don't deauth ourselves.

View File

@@ -48,6 +48,7 @@ class Configuration(object):
cls.random_mac = False # Should generate a random Mac address at startup. cls.random_mac = False # Should generate a random Mac address at startup.
cls.no_deauth = False # Deauth hidden networks & WPA handshake targets cls.no_deauth = False # Deauth hidden networks & WPA handshake targets
cls.num_deauths = 1 # Number of deauth packets to send to each target. 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'] cls.encryption_filter = ['WEP', 'WPA', 'WPS']
@@ -173,6 +174,7 @@ class Configuration(object):
@classmethod @classmethod
def parse_settings_args(cls, args): def parse_settings_args(cls, args):
'''Parses basic settings/configurations from arguments.''' '''Parses basic settings/configurations from arguments.'''
if args.random_mac: if args.random_mac:
cls.random_mac = True cls.random_mac = True
Color.pl('{+} {C}option:{W} using {G}random mac address{W} ' + 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 ' + Color.pl('{+} {C}option:{W} will {R}not{W} {O}deauth{W} clients ' +
'during scans or captures') '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: if args.num_deauths and args.num_deauths > 0:
cls.num_deauths = args.num_deauths cls.num_deauths = args.num_deauths
Color.pl('{+} {C}option:{W} send {G}%d{W} deauth packets when deauthing' % ( Color.pl('{+} {C}option:{W} send {G}%d{W} deauth packets when deauthing' % (
@@ -474,14 +480,15 @@ class Configuration(object):
Macchanger.reset_if_changed() Macchanger.reset_if_changed()
from .tools.airmon import Airmon from .tools.airmon import Airmon
if cls.interface is not None and Airmon.base_interface is not None: if cls.interface is not None and Airmon.base_interface is not None:
if not cls.demon:
Color.pl('{!} {O}Note:{W} Leaving interface in Monitor Mode!') Color.pl('{!} {O}Note:{W} Leaving interface in Monitor Mode!')
Color.pl('{!} To disable Monitor Mode when finished: ' + Color.pl('{!} To disable Monitor Mode when finished: ' +
'{C}airmon-ng stop %s{W}' % cls.interface) '{C}airmon-ng stop %s{W}' % cls.interface)
else:
# Stop monitor mode # Stop monitor mode
#Airmon.stop(cls.interface) Airmon.stop(cls.interface)
# Bring original interface back up # Bring original interface back up
#Airmon.put_interface_up(Airmon.base_interface) Airmon.put_interface_up(Airmon.base_interface)
if Airmon.killed_network_manager: if Airmon.killed_network_manager:
Color.pl('{!} You can restart NetworkManager when finished ({C}service network-manager start{W})') Color.pl('{!} You can restart NetworkManager when finished ({C}service network-manager start{W})')

View File

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from .dependency import Dependency from .dependency import Dependency
from .ifconfig import Ifconfig from .ip import Ip
from .iw import Iw from .iw import Iw
from ..util.process import Process from ..util.process import Process
from ..util.color import Color from ..util.color import Color
@@ -113,9 +113,9 @@ class Airmon(Dependency):
Manually put interface into monitor mode (no airmon-ng or vif). Manually put interface into monitor mode (no airmon-ng or vif).
Fix for bad drivers like the rtl8812AU. Fix for bad drivers like the rtl8812AU.
''' '''
Ifconfig.down(iface) Ip.down(iface)
Iw.mode(iface, 'monitor') Iw.mode(iface, 'monitor')
Ifconfig.up(iface) Ip.up(iface)
# /sys/class/net/wlan0/type # /sys/class/net/wlan0/type
iface_type_path = os.path.join('/sys/class/net', iface, '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). Manually put interface into managed mode (no airmon-ng or vif).
Fix for bad drivers like the rtl8812AU. Fix for bad drivers like the rtl8812AU.
''' '''
Ifconfig.down(iface) Ip.down(iface)
Iw.mode(iface, 'managed') Iw.mode(iface, 'managed')
Ifconfig.up(iface) Ip.up(iface)
# /sys/class/net/wlan0/type # /sys/class/net/wlan0/type
iface_type_path = os.path.join('/sys/class/net', iface, 'type') iface_type_path = os.path.join('/sys/class/net', iface, 'type')
@@ -216,20 +216,20 @@ class Airmon(Dependency):
@staticmethod @staticmethod
def stop(iface): 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() airmon_output = Process(['airmon-ng', 'stop', iface]).stdout()
(disabled_iface, enabled_iface) = Airmon._parse_airmon_stop(airmon_output) (disabled_iface, enabled_iface) = Airmon._parse_airmon_stop(airmon_output)
if not disabled_iface and iface in Airmon.BAD_DRIVERS: 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) disabled_iface = Airmon.stop_bad_driver(iface)
if disabled_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: 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) return (disabled_iface, enabled_iface)
@@ -373,9 +373,9 @@ class Airmon(Dependency):
@staticmethod @staticmethod
def put_interface_up(iface): def put_interface_up(iface):
Color.p('{!} {O}putting interface {R}%s up{O}...' % (iface)) Color.p('{!}{W} Putting interface {R}%s{W} {G}up{W}...\n' % (iface))
Ifconfig.up(iface) Ip.up(iface)
Color.pl(' {G}done{W}') Color.pl('{+}{W} Done !')
@staticmethod @staticmethod
def start_network_manager(): def start_network_manager():

View File

@@ -28,7 +28,7 @@ class Dependency(object):
from .airodump import Airodump from .airodump import Airodump
from .aircrack import Aircrack from .aircrack import Aircrack
from .aireplay import Aireplay from .aireplay import Aireplay
from .ifconfig import Ifconfig from .ip import Ip
from .iw import Iw from .iw import Iw
from .bully import Bully from .bully import Bully
from .reaver import Reaver from .reaver import Reaver
@@ -42,7 +42,7 @@ class Dependency(object):
# Aircrack # Aircrack
Aircrack, #Airodump, Airmon, Aireplay, Aircrack, #Airodump, Airmon, Aireplay,
# wireless/net tools # wireless/net tools
Iw, Ifconfig, Iw, Ip,
# WPS # WPS
Reaver, Bully, Reaver, Bully,
# Cracking/handshakes # Cracking/handshakes

View File

@@ -5,17 +5,17 @@ import re
from .dependency import Dependency from .dependency import Dependency
class Ifconfig(Dependency): class Ip(Dependency):
dependency_required = True dependency_required = True
dependency_name = 'ifconfig' dependency_name = 'ip'
dependency_url = 'apt-get install net-tools' dependency_url = 'apt-get install ip'
@classmethod @classmethod
def up(cls, interface, args=[]): def up(cls, interface, args=[]):
'''Put interface up''' '''Put interface up'''
from ..util.process import Process from ..util.process import Process
command = ['ifconfig', interface] command = ['ip', 'link', 'set', interface]
if type(args) is list: if type(args) is list:
command.extend(args) command.extend(args)
elif type(args) is 'str': elif type(args) is 'str':
@@ -33,7 +33,7 @@ class Ifconfig(Dependency):
'''Put interface down''' '''Put interface down'''
from ..util.process import Process from ..util.process import Process
pid = Process(['ifconfig', interface, 'down']) pid = Process(['ip', 'link', 'set', interface, 'down'])
pid.wait() pid.wait()
if pid.poll() != 0: if pid.poll() != 0:
raise Exception('Error putting interface %s down:\n%s\n%s' % (interface, pid.stdout(), pid.stderr())) 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): def get_mac(cls, interface):
from ..util.process import Process from ..util.process import Process
output = Process(['ifconfig', interface]).stdout() output = Process(['ip', 'link show', interface]).stdout()
# Mac address separated by dashes match = re.search(r'([a-fA-F0-9]{2}[-:]){5}[a-fA-F0-9]{2}', output)
mac_dash_regex = ('[a-zA-Z0-9]{2}-' * 6)[:-1]
match = re.search(' ({})'.format(mac_dash_regex), output)
if match: if match:
return match.group(1).replace('-', ':') return match.group(0).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)
raise Exception('Could not find the mac address for %s' % interface) raise Exception('Could not find the mac address for %s' % interface)

View File

@@ -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)

View File

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from .dependency import Dependency from .dependency import Dependency
from ..tools.ifconfig import Ifconfig from ..tools.ip import Ip
from ..util.color import Color from ..util.color import Color
class Macchanger(Dependency): class Macchanger(Dependency):
@@ -20,7 +20,7 @@ class Macchanger(Dependency):
Color.clear_entire_line() Color.clear_entire_line()
Color.p('\r{+} {C}macchanger{W}: taking interface {C}%s{W} down...' % iface) Color.p('\r{+} {C}macchanger{W}: taking interface {C}%s{W} down...' % iface)
Ifconfig.down(iface) Ip.down(iface)
Color.clear_entire_line() Color.clear_entire_line()
Color.p('\r{+} {C}macchanger{W}: changing mac address of interface {C}%s{W}...' % iface) 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.clear_entire_line()
Color.p('\r{+} {C}macchanger{W}: bringing interface {C}%s{W} up...' % iface) Color.p('\r{+} {C}macchanger{W}: bringing interface {C}%s{W} up...' % iface)
Ifconfig.up(iface) Ip.up(iface)
return True return True
@@ -56,7 +56,7 @@ class Macchanger(Dependency):
Color.pl('\r{+} {C}macchanger{W}: resetting mac address on %s...' % iface) Color.pl('\r{+} {C}macchanger{W}: resetting mac address on %s...' % iface)
# -p to reset to permanent MAC address # -p to reset to permanent MAC address
if cls.down_macch_up(iface, ['-p']): if cls.down_macch_up(iface, ['-p']):
new_mac = Ifconfig.get_mac(iface) new_mac = Ip.get_mac(iface)
Color.clear_entire_line() 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)) 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 # -e to keep vendor bytes the same
if cls.down_macch_up(iface, ['-e']): if cls.down_macch_up(iface, ['-e']):
cls.is_changed = True cls.is_changed = True
new_mac = Ifconfig.get_mac(iface) new_mac = Ip.get_mac(iface)
Color.clear_entire_line() Color.clear_entire_line()
Color.pl('\r{+} {C}macchanger{W}: changed mac address to {C}%s{W} on {C}%s{W}' % (new_mac, iface)) Color.pl('\r{+} {C}macchanger{W}: changed mac address to {C}%s{W} on {C}%s{W}' % (new_mac, iface))