Skip to content

Commit

Permalink
Fix a minor (tab/space) etc
Browse files Browse the repository at this point in the history
  • Loading branch information
kimocoder committed Jan 11, 2020
1 parent 267c2b3 commit e607189
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 110 deletions.
95 changes: 0 additions & 95 deletions wifite/tools/airmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,98 +120,6 @@ def get_iface_info(interface_name):

return None

@staticmethod
def start_bad_driver(iface):
'''
Manually put interface into monitor mode (no airmon-ng or vif).
Fix for bad drivers like the rtl8812AU.
'''
Ip.down(iface)
Iw.mode(iface, 'monitor')
Ip.up(iface)

# /sys/class/net/wlan0/type
iface_type_path = os.path.join('/sys/class/net', iface, 'type')
if os.path.exists(iface_type_path):
with open(iface_type_path, 'r') as f:
if (int(f.read()) == Airmon.ARPHRD_IEEE80211_RADIOTAP):
return iface

return None

@staticmethod
def stop_bad_driver(iface):
'''
Manually put interface into managed mode (no airmon-ng or vif).
Fix for bad drivers like the rtl8812AU.
'''
Ip.down(iface)
Iw.mode(iface, 'managed')
Ip.up(iface)

# /sys/class/net/wlan0/type
iface_type_path = os.path.join('/sys/class/net', iface, 'type')
if os.path.exists(iface_type_path):
with open(iface_type_path, 'r') as f:
if (int(f.read()) == Airmon.ARPHRD_ETHER):
return iface

return None

@staticmethod
def start(iface):
'''
Starts an interface (iface) in monitor mode
Args:
iface - The interface to start in monitor mode
Either an instance of AirmonIface object,
or the name of the interface (string).
Returns:
Name of the interface put into monitor mode.
Throws:
Exception - If an interface can't be put into monitor mode
'''
# Get interface name from input
if type(iface) == AirmonIface:
iface_name = iface.interface
driver = iface.driver
else:
iface_name = iface
driver = None

# Remember this as the 'base' interface.
Airmon.base_interface = iface_name

Color.p('{+} enabling {G}monitor mode{W} on {C}%s{W}... ' % iface_name)

airmon_output = Process(['airmon-ng', 'start', iface_name]).stdout()

enabled_iface = Airmon._parse_airmon_start(airmon_output)

if enabled_iface is None and driver in Airmon.BAD_DRIVERS:
Color.p('{O}"bad driver" detected{W} ')
enabled_iface = Airmon.start_bad_driver(iface_name)

if enabled_iface is None:
Color.pl('{R}failed{W}')

monitor_interfaces = Iw.get_interfaces(mode='monitor')

# Assert that there is an interface in monitor mode
if len(monitor_interfaces) == 0:
Color.pl('{R}failed{W}')
raise Exception('Cannot find any interfaces in monitor mode')

# Assert that the interface enabled by airmon-ng is in monitor mode
if enabled_iface not in monitor_interfaces:
Color.pl('{R}failed{W}')
raise Exception('Cannot find %s with type:monitor' % enabled_iface)

# No errors found; the device 'enabled_iface' was put into Mode:Monitor.
Color.pl('{G}enabled {C}%s{W}' % enabled_iface)

return enabled_iface

@staticmethod
def _parse_airmon_start(airmon_output):
'''Find the interface put into monitor mode (if any)'''
Expand All @@ -226,7 +134,6 @@ def _parse_airmon_start(airmon_output):

return None


@staticmethod
def stop(iface):
Color.p('{!}{W} Disabling {O}monitor{W} mode on {R}%s{W}...\n' % iface)
Expand All @@ -246,7 +153,6 @@ def stop(iface):

return (disabled_iface, enabled_iface)


@staticmethod
def _parse_airmon_stop(airmon_output):
'''Find the interface taken out of into monitor mode (if any)'''
Expand Down Expand Up @@ -277,7 +183,6 @@ def _parse_airmon_stop(airmon_output):

return (disabled_iface, enabled_iface)


@staticmethod
def ask():
'''
Expand Down
2 changes: 1 addition & 1 deletion wifite/tools/airodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __enter__(self):
'--write-interval', '1' # Write every second
]
if self.channel: command.extend(['-c', str(self.channel)])
elif self.all_bands: command.extend(['--band', 'abg'])
elif self.all_bands: command.extend(['--band', 'abg'])
elif self.five_ghz: command.extend(['--band', 'a'])

if self.encryption: command.extend(['--enc', self.encryption])
Expand Down
12 changes: 0 additions & 12 deletions wifite/tools/bully.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ def _run(self, airodump):
self.stop()
return


time.sleep(0.5)


def pattack(self, message, newline=False):
# Print message with attack information.
if self.pixie_dust:
Expand Down Expand Up @@ -171,11 +169,9 @@ def pattack(self, message, newline=False):
if newline:
Color.pl('')


def running_time(self):
return int(time.time() - self.start_time)


def get_status(self):
main_status = self.state

Expand All @@ -194,7 +190,6 @@ def get_status(self):

return main_status


def parse_line_thread(self):
for line in iter(self.bully_proc.pid.stdout.readline, b''):
if line == '': continue
Expand All @@ -211,7 +206,6 @@ def parse_line_thread(self):
if self.crack_result:
break


def parse_crack_result(self, line):
# Check for line containing PIN and PSK
# [*] Pin is '80246213', key is 'password'
Expand Down Expand Up @@ -258,7 +252,6 @@ def parse_crack_result(self, line):

return self.crack_result


def parse_state(self, line):
state = self.state

Expand Down Expand Up @@ -346,19 +339,15 @@ def parse_state(self, line):
re_running_pixiewps = re.search(r".*Running pixiewps with the information", line)
if re_running_pixiewps:
state = '{G}Running pixiewps...{W}'

return state


def stop(self):
if hasattr(self, 'pid') and self.pid and self.pid.poll() is None:
self.pid.interrupt()


def __del__(self):
self.stop()


@staticmethod
def get_psk_from_pin(target, pin):
# Fetches PSK from a Target assuming 'pin' is the correct PIN
Expand Down Expand Up @@ -389,7 +378,6 @@ def get_psk_from_pin(target, pin):

return None


if __name__ == '__main__':
Configuration.initialize()
Configuration.interface = 'wlan0mon'
Expand Down
2 changes: 0 additions & 2 deletions wifite/tools/cowpatty.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import os
import re


class Cowpatty(Dependency):
''' Wrapper for Cowpatty program. '''
dependency_required = False
dependency_name = 'cowpatty'
dependency_url = 'https://tools.kali.org/wireless-attacks/cowpatty'


@staticmethod
def crack_handshake(handshake, show_command=False):
# Crack john file
Expand Down

0 comments on commit e607189

Please sign in to comment.