# Wait before sniff request packet from target Base.print_info("Wait 10 sec. before sniff packets from target: " + mac_address) sleep(10) # Add 5 packets to number of WiFi deauth packets deauth_packets_number += 5 # endregion # region Main function if __name__ == "__main__": # region Variables Scanner = Scanner() ArpScan = ArpScan() ICMPv6Scan = ICMPv6Scan() DnsServer = DnsServer() TM = ThreadManager(5) ip_pattern = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") target_mac_address = None target_ip_address = None new_target_ip_address = None target_apple_device = None first_suffix = 2 last_suffix = 255
class ScannerTest(unittest.TestCase): # region Properties path.append(dirname(dirname(dirname(dirname(dirname(abspath(__file__))))))) from raw_packet.Scanners.scanner import Scanner from raw_packet.Tests.Unit_tests.variables import Variables scanner: Scanner = Scanner() # endregion def test01_apple_device_selection(self): apple_devices = [['192.168.0.1', '12:34:56:78:90:ab', 'Apple, Inc.'], ['192.168.0.2', '12:34:56:78:90:ac', 'Apple, Inc.']] bad_apple_devices = [['192.168.0.1', '12:34:56:78:90:ab', 'Apple, Inc.'], ['192.168.0.2', '12:34:56:78:90:ac']] bad_apple_devices1 = [['192.168.0.1', '12:34:56:78:90:ab', 'Apple, Inc.'], ['192.168.0.1234', '12:34:56:78:90:ac', 'Apple, Inc.']] bad_apple_devices2 = [['192.168.0.1', '12:34:56:78:90:ab', 'Apple, Inc.'], ['192.168.0.2', '12:34:56:78:90:abc', 'Apple, Inc.']] self.assertIsNone(self.scanner.apple_device_selection(bad_apple_devices)) self.assertIsNone(self.scanner.apple_device_selection(bad_apple_devices1)) self.assertIsNone(self.scanner.apple_device_selection(bad_apple_devices2)) self.assertIsNone(self.scanner.apple_device_selection(None)) self.assertIsNone(self.scanner.apple_device_selection([])) selection_result = self.scanner.apple_device_selection([apple_devices[0]]) self.assertEqual(apple_devices[0], selection_result) with patch('builtins.input', return_value='yes'): self.assertIsNone(self.scanner.apple_device_selection(apple_devices)) with patch('builtins.input', return_value='3'): self.assertIsNone(self.scanner.apple_device_selection(apple_devices)) with patch('builtins.input', return_value='1'): selection_result = self.scanner.apple_device_selection(apple_devices) self.assertEqual(apple_devices[0], selection_result) with patch('builtins.input', return_value='2'): selection_result = self.scanner.apple_device_selection(apple_devices) self.assertEqual(apple_devices[1], selection_result) def test02_ipv6_device_selection(self): ipv6_devices = [{'ip-address': 'fd00::1', 'mac-address': '12:34:56:78:90:ab', 'vendor': 'Apple Inc.'}, {'ip-address': 'fd00::2', 'mac-address': '12:34:56:78:90:ac', 'vendor': 'Apple Inc.'}] bad_ipv6_devices1 = [{'ip-address': 'fd00::1', 'mac-address': '12:34:56:78:90:ab', 'vendor': 'Apple Inc.'}, {'ip-address': 'fd00::2', 'mac-address': '12:34:56:78:90:ac'}] bad_ipv6_devices2 = [{'ip-address': 'fd00::1', 'mac-address': '12:34:56:78:90:ab', 'vendor': 'Apple Inc.'}, {'ip-address': 'fd00::2', 'mac-address': '12:34:56:78:90:ac', 'test': 'Apple Inc.'}] bad_ipv6_devices3 = [{'ip-address': 'fd00::1', 'mac-address': '12:34:56:78:90:ab', 'vendor': 'Apple Inc.'}, {'ip-address': 'fd00:::2', 'mac-address': '12:34:56:78:90:ac', 'vendor': 'Apple Inc.'}] bad_ipv6_devices4 = [{'ip-address': 'fd00::1', 'mac-address': '12:34:56:78:90:ab', 'vendor': 'Apple Inc.'}, {'ip-address': 'fd00::2', 'mac-address': '12:34:56:78:90:abc', 'vendor': 'Apple Inc.'}] self.assertIsNone(self.scanner.ipv6_device_selection(bad_ipv6_devices1)) self.assertIsNone(self.scanner.ipv6_device_selection(bad_ipv6_devices2)) self.assertIsNone(self.scanner.ipv6_device_selection(bad_ipv6_devices3)) self.assertIsNone(self.scanner.ipv6_device_selection(bad_ipv6_devices4)) self.assertIsNone(self.scanner.ipv6_device_selection(None)) self.assertIsNone(self.scanner.ipv6_device_selection([])) selection_result = self.scanner.ipv6_device_selection([ipv6_devices[0]]) self.assertEqual(ipv6_devices[0], selection_result) with patch('builtins.input', return_value='yes'): self.assertIsNone(self.scanner.ipv6_device_selection(ipv6_devices)) with patch('builtins.input', return_value='3'): self.assertIsNone(self.scanner.ipv6_device_selection(ipv6_devices)) with patch('builtins.input', return_value='1'): self.assertEqual(self.scanner.ipv6_device_selection(ipv6_devices), ipv6_devices[0]) with patch('builtins.input', return_value='2'): self.assertEqual(self.scanner.ipv6_device_selection(ipv6_devices), ipv6_devices[1]) def test03_find_ip_in_local_network(self): scan_result = \ self.scanner.find_ip_in_local_network(network_interface=ScannerTest.Variables.test_network_interface) self.assertIsNotNone(scan_result) self.assertIn(ScannerTest.Variables.router_ipv4_address, scan_result) def test04_find_apple_devices_by_mac(self): scan_results = \ self.scanner.find_apple_devices_by_mac(network_interface=ScannerTest.Variables.test_network_interface) self.assertIsNotNone(scan_results) find_apple_device: bool = False for scan_result in scan_results: if ScannerTest.Variables.apple_device_mac_address in scan_result: find_apple_device = True break self.assertTrue(find_apple_device) def test05_find_apple_devices_by_mac_ipv6(self): scan_results = \ self.scanner.find_apple_devices_by_mac_ipv6(network_interface=ScannerTest.Variables.test_network_interface) self.assertIsNotNone(scan_results) find_apple_device: bool = False for scan_result in scan_results: if ScannerTest.Variables.apple_device_mac_address in scan_result: find_apple_device = True break self.assertTrue(find_apple_device) def test06_find_ipv6_devices(self): scan_results = \ self.scanner.find_ipv6_devices(network_interface=ScannerTest.Variables.test_network_interface) self.assertIsNotNone(scan_results) find_apple_device: bool = False for scan_result in scan_results: if ScannerTest.Variables.apple_device_mac_address == scan_result['mac-address']: find_apple_device = True break self.assertTrue(find_apple_device) def test07_find_apple_devices_with_nmap(self): scan_results = \ self.scanner.find_apple_devices_with_nmap(network_interface=ScannerTest.Variables.test_network_interface) self.assertIsNotNone(scan_results) find_apple_device: bool = False for scan_result in scan_results: if ScannerTest.Variables.apple_device_mac_address in scan_result: find_apple_device = True break self.assertTrue(find_apple_device)
# region Main function if __name__ == '__main__': # region Import Raw-packet classes path.append(dirname(dirname(dirname(abspath(__file__))))) from raw_packet.Utils.base import Base from raw_packet.Scanners.scanner import Scanner from raw_packet.Scanners.icmpv6_scanner import ICMPv6Scan from raw_packet.Utils.network import RawICMPv6 base: Base = Base() icmpv6: RawICMPv6 = RawICMPv6() icmpv6_scan: ICMPv6Scan = ICMPv6Scan() scanner: Scanner = Scanner() raw_socket: socket = socket(AF_PACKET, SOCK_RAW) # endregion # region Check user, platform and create threads base.check_user() base.check_platform() # endregion try: # region Parse script arguments parser = ArgumentParser(description='ICMPv6 spoofing', formatter_class=RawTextHelpFormatter) parser.add_argument('-T', '--technique',
__copyright__ = 'Copyright 2019, Raw-packet Project' __credits__ = [''] __license__ = 'MIT' __version__ = '0.1.1' __maintainer__ = 'Vladimir Ivanov' __email__ = '*****@*****.**' __status__ = 'Development' # endregion # region Check user, platform and create threads Base = Base() Base.check_user() Base.check_platform() icmpv6 = ICMPv6_raw() icmpv6_scan = ICMPv6Scan() scanner = Scanner() # endregion # region Parse script arguments parser = ArgumentParser(description='NA (Neighbor Advertisement) spoofing') parser.add_argument('-i', '--interface', help='Set interface name for send ARP packets') parser.add_argument('-t', '--target_ip', help='Set target IPv6 link local address', default=None) parser.add_argument('-m', '--target_mac', help='Set target MAC address',
# endregion # region Authorship information __author__ = 'Vladimir Ivanov' __copyright__ = 'Copyright 2019, Raw-packet Project' __credits__ = [''] __license__ = 'MIT' __version__ = '0.1.1' __maintainer__ = 'Vladimir Ivanov' __email__ = '*****@*****.**' __status__ = 'Development' # endregion # region Check user, platform and print banner Base = Base() Scanner = Scanner() ArpScan = ArpScan() eth = Ethernet_raw() arp = ARP_raw() ip = IP_raw() udp = UDP_raw() dhcp = DHCP_raw() Base.check_user() Base.check_platform() Base.print_banner() # endregion # region Parse script arguments parser = ArgumentParser(