def print_targets(self): ''' Prints targets to console ''' if len(self.targets) == 0: Color.p('\r') return if self.previous_target_count > 0: # We need to "overwrite" the previous list of targets. if self.previous_target_count > len(self.targets) or \ Scanner.get_terminal_height() < self.previous_target_count + 3: # Either: # 1) We have less targets than before, so we can't overwrite the previous list # 2) The terminal can't display the targets without scrolling. # Clear the screen. from Process import Process Process.call('clear') else: # We can fit the targets in the terminal without scrolling # "Move" cursor up so we will print over the previous list Color.pl(Scanner.UP_CHAR * (3 + self.previous_target_count)) self.previous_target_count = len(self.targets) # Overwrite the current line Color.p('\r') Target.print_header() for (index, target) in enumerate(self.targets): index += 1 Color.pl(' {G}%s %s' % (str(index).rjust(3), target))
def print_targets(self): ''' Prints targets to console ''' if len(self.targets) == 0: Color.p('\r') return if self.previous_target_count > 0: # We need to "overwrite" the previous list of targets. if Configuration.verbose <= 1: # Don't clear screen buffer in verbose mode. if self.previous_target_count > len(self.targets) or \ Scanner.get_terminal_height() < self.previous_target_count + 3: # Either: # 1) We have less targets than before, so we can't overwrite the previous list # 2) The terminal can't display the targets without scrolling. # Clear the screen. from Process import Process Process.call('clear') else: # We can fit the targets in the terminal without scrolling # "Move" cursor up so we will print over the previous list Color.pl(Scanner.UP_CHAR * (3 + self.previous_target_count)) self.previous_target_count = len(self.targets) # Overwrite the current line Color.p('\r') Target.print_header() for (index, target) in enumerate(self.targets): index += 1 Color.clear_entire_line() Color.pl(' {G}%s %s' % (str(index).rjust(3), target))
def stop(iface): Color.p("{!} {R}disabling {O}monitor mode{O} on {R}%s{O}... " % iface) (out,err) = Process.call('nexutil -m0') (out,err) = Process.call('nexutil -m') nexutil_monitor_mode = out.split()[1] # Assert that there is an interface in monitor mode if nexutil_monitor_mode != 0: Color.pl('{R}disabled %s{W}' % iface) else: Color.pl('{O}could not disable on {R}%s{W}' % iface)
def print_targets(self): ''' Prints targets to console ''' if len(self.targets) == 0: Color.p('\r') return if self.previous_target_count > 0: # We need to "overwrite" the previous list of targets. if Configuration.verbose <= 1: # Don't clear screen buffer in verbose mode. if self.previous_target_count > len(self.targets) or \ Scanner.get_terminal_height() < self.previous_target_count + 3: # Either: # 1) We have less targets than before, so we can't overwrite the previous list # 2) The terminal can't display the targets without scrolling. # Clear the screen. from Process import Process Process.call('clear') else: # We can fit the targets in the terminal without scrolling # "Move" cursor up so we will print over the previous list Color.pl(Scanner.UP_CHAR * (3 + self.previous_target_count)) self.previous_target_count = len(self.targets) # Overwrite the current line Color.p('\r') # First row: columns Color.p(' NUM') Color.p(' ESSID') if Configuration.show_bssids: Color.p(' BSSID') Color.pl(' CH ENCR POWER WPS? CLIENT') # Second row: separator Color.p(' ---') Color.p(' -------------------------') if Configuration.show_bssids: Color.p(' -----------------') Color.pl(' --- ---- ----- ---- ------') # Remaining rows: targets for idx, target in enumerate(self.targets, start=1): Color.clear_entire_line() Color.p(' {G}%s ' % str(idx).rjust(3)) Color.pl(target.to_str(Configuration.show_bssids))
def forge_packet(xor_file, bssid, station_mac): ''' Forges packet from .xor file ''' forged_file = 'forged.cap' cmd = [ 'packetforge-ng', '-0', '-a', bssid, # Target MAC '-h', station_mac, # Client MAC '-k', '192.168.1.2', # Dest IP '-l', '192.168.1.100', # Source IP '-y', xor_file, # Read PRNG from .xor file '-w', forged_file, # Write to Configuration.interface ] cmd = '"%s"' % '" "'.join(cmd) (out, err) = Process.call(cmd, cwd=Configuration.temp(), shell=True) if out.strip() == 'Wrote packet to: %s' % forged_file: return forged_file else: from Color import Color Color.pl('{!} {R}failed to forge packet from .xor file{W}') Color.pl('output:\n"%s"' % out) return None
def aircrack_handshakes(self): if not self.bssid: return [] (stdout, stderr) = Process.call(self.aircrack_command()) if 'passphrase not in dictionary' in stdout.lower(): return [(self.bssid, None)] else: return []
def start(iface): ''' Starts an interface (iface) in monitor mode Args: iface - The interface to start in monitor mode Either an instance of Interface 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) == Interface: iface = iface.name Airmon.base_interface = iface # Call airmon-ng Color.p("{+} enabling {G}monitor mode{W} on {C}%s{W}... " % iface) (out, err) = Process.call('airmon-ng start %s' % iface) # Find the interface put into monitor mode (if any) mon_iface = None for line in out.split('\n'): if 'monitor mode' in line and 'enabled' in line and ' on ' in line: mon_iface = line.split(' on ')[1] if ']' in mon_iface: mon_iface = mon_iface.split(']')[1] if ')' in mon_iface: mon_iface = mon_iface.split(')')[0] break if mon_iface == None: # Airmon did not enable monitor mode on an interface Color.pl("{R}failed{W}") mon_ifaces = Airmon.get_interfaces_in_monitor_mode() # Assert that there is an interface in monitor mode if len(mon_ifaces) == 0: Color.pl("{R}failed{W}") raise Exception( "iwconfig does not see any interfaces in Mode:Monitor") # Assert that the interface enabled by airmon-ng is in monitor mode if mon_iface not in mon_ifaces: Color.pl("{R}failed{W}") raise Exception("iwconfig does not see %s in Mode:Monitor" % mon_iface) # No errors found; the device 'mon_iface' was put into MM. Color.pl("{G}enabled {C}%s{W}" % mon_iface) Configuration.interface = mon_iface return mon_iface
def start(iface): ''' Starts an interface (iface) in monitor mode Args: iface - The interface to start in monitor mode Either an instance of Interface 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) == Interface: iface = iface.name Airmon.base_interface = iface # Call airmon-ng Color.p("{+} enabling {G}monitor mode{W} on {C}%s{W}... " % iface) (out,err) = Process.call('airmon-ng start %s' % iface) # Find the interface put into monitor mode (if any) mon_iface = None for line in out.split('\n'): if 'monitor mode' in line and 'enabled' in line and ' on ' in line: mon_iface = line.split(' on ')[1] if ']' in mon_iface: mon_iface = mon_iface.split(']')[1] if ')' in mon_iface: mon_iface = mon_iface.split(')')[0] break if mon_iface == None: # Airmon did not enable monitor mode on an interface Color.pl("{R}failed{W}") mon_ifaces = Airmon.get_interfaces_in_monitor_mode() # Assert that there is an interface in monitor mode if len(mon_ifaces) == 0: Color.pl("{R}failed{W}") raise Exception("iwconfig does not see any interfaces in Mode:Monitor") # Assert that the interface enabled by airmon-ng is in monitor mode if mon_iface not in mon_ifaces: Color.pl("{R}failed{W}") raise Exception("iwconfig does not see %s in Mode:Monitor" % mon_iface) # No errors found; the device 'mon_iface' was put into MM. Color.pl("{G}enabled {C}%s{W}" % mon_iface) Configuration.interface = mon_iface return mon_iface
def start(iface): ''' Starts an interface (iface) in monitor mode Args: iface - The interface to start in monitor mode Either an instance of Interface 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) == Interface: iface = iface.name Airmon.base_interface = iface # Call airmon-ng Color.p("{+} enabling {G}monitor mode{W} on {C}%s{W}... " % iface) (out,err) = Process.call('nexutil -m2') (out,err) = Process.call('nexutil -m') nexutil_monitor_mode = out.split()[1] # Assert that there is an interface in monitor mode if nexutil_monitor_mode == 0: Color.pl("{R}failed{W}") raise Exception("nexutil does not see any interfaces in Mode:Monitor") # No errors found; the device 'mon_iface' was put into MM. Color.pl("{G}enabled {C}%s{W}" % iface) Configuration.interface = iface return iface
def get_interfaces_in_monitor_mode(): ''' Uses 'iwconfig' to find all interfaces in monitor mode Returns: List of interface names that are in monitor mode ''' interfaces = [] (out, err) = Process.call("iwconfig") for line in out.split("\n"): if len(line) == 0: continue if line[0] != ' ': iface = line.split(' ')[0] if '\t' in iface: iface = iface.split('\t')[0] if 'Mode:Monitor' in line and iface not in interfaces: interfaces.append(iface) return interfaces
def get_interfaces_in_monitor_mode(): ''' Uses 'iwconfig' to find all interfaces in monitor mode Returns: List of interface names that are in monitor mode ''' interfaces = [] (out, err) = Process.call("iwconfig") for line in out.split("\n"): if len(line) == 0: continue if line[0] != ' ': iface = line.split(' ')[0] if '\t' in iface: iface = iface.split('\t')[0] if 'Mode:Monitor' in line and iface not in interfaces: interfaces.append(iface) return interfaces
def get_interfaces_in_monitor_mode(): ''' Uses 'iwconfig' to find all interfaces in monitor mode Returns: List of interface names that are in monitor mode ''' interfaces = [] Color.p("{+} leer {G}" % interfaces) (out, err) = Process.call("iwconfig") for line in out.split("\n"): if len(line) == 0: continue if line[0] != ' ': iface = line.split(' ')[0] if '\t' in iface: iface = iface.split('\t')[0] iface = "wlan1mon" if iface not in interfaces: Color.p("{+} leer2 {G}" % iface) interfaces.append(iface) return interfaces
def stop(iface): Color.p("{+} {R}disabling {O}monitor mode{R} on {O}%s{W}... " % iface) (out,err) = Process.call('airmon-ng stop %s' % iface) mon_iface = None for line in out.split('\n'): # aircrack-ng 1.2 rc2 if 'monitor mode' in line and 'disabled' in line and ' for ' in line: mon_iface = line.split(' for ')[1] if ']' in mon_iface: mon_iface = mon_iface.split(']')[1] if ')' in mon_iface: mon_iface = mon_iface.split(')')[0] break # aircrack-ng 1.2 rc1 match = re.search('([a-zA-Z0-9]+).*\(removed\)', line) if match: mon_iface = match.groups()[0] break if mon_iface: Color.pl('{R}disabled {O}%s{W}' % mon_iface) else: Color.pl('{O}could not disable on {R}%s{W}' % iface)
def stop(iface): Color.p("{!} {R}disabling {O}monitor mode{O} on {R}%s{O}... " % iface) (out, err) = Process.call('airmon-ng stop %s' % iface) mon_iface = None for line in out.split('\n'): # aircrack-ng 1.2 rc2 if 'monitor mode' in line and 'disabled' in line and ' for ' in line: mon_iface = line.split(' for ')[1] if ']' in mon_iface: mon_iface = mon_iface.split(']')[1] if ')' in mon_iface: mon_iface = mon_iface.split(')')[0] break # aircrack-ng 1.2 rc1 match = re.search('([a-zA-Z0-9]+).*\(removed\)', line) if match: mon_iface = match.groups()[0] break if mon_iface: Color.pl('{R}disabled %s{W}' % mon_iface) else: Color.pl('{O}could not disable on {R}%s{W}' % iface)
def forge_packet(xor_file, bssid, station_mac): ''' Forges packet from .xor file ''' forged_file = 'forged.cap' cmd = [ 'packetforge-ng', '-0', '-a', bssid, # Target MAC '-h', station_mac, # Client MAC '-k', '192.168.1.2', # Dest IP '-l', '192.168.1.100', # Source IP '-y', xor_file, # Read PRNG from .xor file '-w', forged_file, # Write to Configuration.interface ] cmd = '"%s"' % '" "'.join(cmd) (out, err) = Process.call(cmd, cwd=Configuration.temp(), shell=True) if out.strip() == 'Wrote packet to: %s' % forged_file: return forged_file else: from Color import Color Color.pl('{!} {R}failed to forge packet from .xor file{W}') Color.pl('output:\n"%s"' % out) return None
def put_interfaces_up(): Color.pl("{+} {O}Putting interfaces up...") for interface in Airmon.get_interfaces(): Color.pl("{+} {B}up into {O}%s" %(interface.name)) (out,err) = Process.call('ifconfig %s up' %(interface.name))
def start_network_manager(): Color.p("{!} {O}restarting {R}NetworkManager{O}...") (out, err) = Process.call('systemctl start NetworkManager') Color.pl(" {R}restarted{W}")
def put_interface_up(iface): Color.p("{!} {O}putting interface {R}%s up{O}..." % (iface)) (out, err) = Process.call('ifconfig %s up' % (iface)) Color.pl(" {R}done{W}")
def put_interface_up(iface): Color.p("{!} {O}putting interface {R}%s up{O}..." % (iface)) (out,err) = Process.call('ifconfig %s up' % (iface)) Color.pl(" {R}done{W}")
def start_network_manager(): Color.p("{!} {O}restarting {R}NetworkManager{O}...") (out,err) = Process.call('systemctl start NetworkManager') Color.pl(" {R}restarted{W}")
def start_network_manager(): Color.pl("{+} {O}Starting NetworkManager") (out,err) = Process.call('systemctl start NetworkManager')