iface before PHY in output.

Remove "Interface" model, rely on ifconfig
This commit is contained in:
derv82
2018-04-18 15:01:25 -04:00
parent ec49c0336e
commit 6f71957753
4 changed files with 8 additions and 90 deletions

View File

@@ -5,8 +5,8 @@ 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 ..config import Configuration from ..config import Configuration
from ..model.interface import Interface
from ..util.color import Color from ..util.color import Color
from ..util.input import raw_input from ..util.input import raw_input
from ..model.wep_result import CrackResultWEP from ..model.wep_result import CrackResultWEP
@@ -57,7 +57,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 = Interface.get_mac() client_mac = Ifconfig.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:

View File

@@ -1,81 +0,0 @@
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
from ..tools.ifconfig import Ifconfig
from ..util.color import Color
import re
class Interface(object):
'''
Represents an 'interface' known by airmon-ng
'''
def __init__(self, fields):
'''
Initializes & stores info about an interface.
Args:
Fields - list of fields
0: PHY
1: INTERFACE
2: DRIVER
3: CHIPSET
'''
if len(fields) == 3:
phy = 'phyX'
match = re.search(' - \[(phy\d+)\]', fields[2])
if match:
phy = match.groups()[0]
fields[2] = fields[2][:fields[2].rfind(' - [')]
fields.insert(0, phy)
if len(fields) != 4:
raise Exception("Expected 4, got %d in %s" % (len(fields), fields))
self.phy = fields[0].strip()
self.interface = fields[1].strip()
self.driver = fields[2].strip()
self.chipset = fields[3].strip()
# Max length of fields.
# Used for printing a table of interfaces.
PHY_LEN = 6
INTERFACE_LEN = 12
DRIVER_LEN = 20
CHIPSET_LEN = 30
def __str__(self):
''' Colored string representation of interface '''
s = Color.s('{W}%s' % self.phy.ljust(self.PHY_LEN))
s += Color.s('{G}%s' % self.interface.ljust(self.INTERFACE_LEN))
s += Color.s('{C}%s' % self.driver.ljust(self.DRIVER_LEN))
s += Color.s('{W}%s' % self.chipset.ljust(self.CHIPSET_LEN))
return s
@staticmethod
def menu_header():
''' Colored header row for interfaces '''
s = ' '
s += 'PHY'.ljust(Interface.PHY_LEN)
s += 'Interface'.ljust(Interface.INTERFACE_LEN)
s += 'Driver'.ljust(Interface.DRIVER_LEN)
s += 'Chipset'.ljust(Interface.CHIPSET_LEN)
s += '\n'
s += '-' * (Interface.PHY_LEN + Interface.INTERFACE_LEN + Interface.DRIVER_LEN + Interface.CHIPSET_LEN + 3)
return s
@staticmethod
def get_mac(iface=None):
from ..config import Configuration
from ..util.process import Process
if iface is None:
Configuration.initialize()
iface = Configuration.interface
if iface is None:
raise Exception('Interface must be defined (-i)')
Ifconfig.get_mac(iface)
if __name__ == '__main__':
mac = Interface.get_mac()
print('wlan0mon mac address:', mac)

View File

@@ -1,7 +1,6 @@
#!/usr/bin/python2.7 #!/usr/bin/python2.7
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from ..model.interface import Interface
from ..tools.ifconfig import Ifconfig from ..tools.ifconfig import Ifconfig
from ..tools.iwconfig import Iwconfig from ..tools.iwconfig import Iwconfig
from ..util.process import Process from ..util.process import Process
@@ -23,15 +22,16 @@ class AirmonIface(object):
# Max length of fields. # Max length of fields.
# Used for printing a table of interfaces. # Used for printing a table of interfaces.
PHY_LEN = 6
INTERFACE_LEN = 12 INTERFACE_LEN = 12
PHY_LEN = 6
DRIVER_LEN = 20 DRIVER_LEN = 20
CHIPSET_LEN = 30 CHIPSET_LEN = 30
def __str__(self): def __str__(self):
''' Colored string representation of interface ''' ''' Colored string representation of interface '''
s = Color.s('{W}%s' % self.phy.ljust(self.PHY_LEN)) s = ''
s += Color.s('{G}%s' % self.interface.ljust(self.INTERFACE_LEN)) s += Color.s('{G}%s' % self.interface.ljust(self.INTERFACE_LEN))
s += Color.s('{W}%s' % self.phy.ljust(self.PHY_LEN))
s += Color.s('{C}%s' % self.driver.ljust(self.DRIVER_LEN)) s += Color.s('{C}%s' % self.driver.ljust(self.DRIVER_LEN))
s += Color.s('{W}%s' % self.chipset.ljust(self.CHIPSET_LEN)) s += Color.s('{W}%s' % self.chipset.ljust(self.CHIPSET_LEN))
return s return s
@@ -39,13 +39,13 @@ class AirmonIface(object):
@staticmethod @staticmethod
def menu_header(): def menu_header():
''' Colored header row for interfaces ''' ''' Colored header row for interfaces '''
s = ' ' s = ' ' # Space for index #
s += 'PHY'.ljust(AirmonIface.PHY_LEN)
s += 'Interface'.ljust(AirmonIface.INTERFACE_LEN) s += 'Interface'.ljust(AirmonIface.INTERFACE_LEN)
s += 'PHY'.ljust(AirmonIface.PHY_LEN)
s += 'Driver'.ljust(AirmonIface.DRIVER_LEN) s += 'Driver'.ljust(AirmonIface.DRIVER_LEN)
s += 'Chipset'.ljust(AirmonIface.CHIPSET_LEN) s += 'Chipset'.ljust(AirmonIface.CHIPSET_LEN)
s += '\n' s += '\n'
s += '-' * (Interface.PHY_LEN + Interface.INTERFACE_LEN + Interface.DRIVER_LEN + Interface.CHIPSET_LEN + 3) s += '-' * (AirmonIface.INTERFACE_LEN + AirmonIface.PHY_LEN + AirmonIface.DRIVER_LEN + AirmonIface.CHIPSET_LEN + 3)
return s return s

View File

@@ -1,7 +1,6 @@
#!/usr/bin/python2.7 #!/usr/bin/python2.7
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from ..model.interface import Interface
from ..tools.ifconfig import Ifconfig from ..tools.ifconfig import Ifconfig
from ..util.color import Color from ..util.color import Color