def post_scanning_configurations(self): # Escrever num ficheiro depois ler se for chamado no airhost card = NetworkCard(self.ap_interface) max_supported_access_points = card.get_number_of_supported_aps() print "Max aps: ", max_supported_access_points if self.max_access_points > max_supported_access_points: print "[-] max_access_points is higher than what card supports. Setting to {}".format( max_supported_access_points) self.max_access_points = max_supported_access_points self.aplauncher = APLauncher(self.hostapd_conf) self.dnsmasqhandler = DNSMasqHandler(self.dnsmasq_conf) rand_mac = "52:54:00:%02x:%02x:%02x" % (randint(0, 255), randint( 0, 255), randint(0, 255)) final_list = [] if len(self.lonely_probes) < self.max_access_points: print "[+] Adding all requested ssids to hostapd configuration." for probe in self.lonely_probes: print "[+] Adding '{}' with hit_count '{}' to hostapd configuration".format( probe, self.hit_count[probe]) final_list = list(self.lonely_probes) SessionManager().log_event( NeutralEvent("Added all found probes to Karma list.")) else: inverted_popular_ssids = { hit_count: ssid for ssid, hit_count in self.hit_count.iteritems() } ordered_popularity = sorted(inverted_popular_ssids.keys())[::-1] for i in ordered_popularity: popular_ssid = inverted_popular_ssids[i] final_list.append(popular_ssid) print "[+] Adding '{}' with hit_count '{}' to hostapd configuration".format( popular_ssid, self.hit_count[popular_ssid]) SessionManager().log_event( NeutralEvent( "Added '{}' to Karma list.".format(popular_ssid))) if len(final_list) == self.max_access_points: break self.number_of_configured_nets = len(final_list) NetworkManager().set_mac_and_unmanage(self.ap_interface, rand_mac, True, self.number_of_configured_nets) self.dnsmasqhandler.set_captive_portal_mode(self.captive_portal) self.dnsmasqhandler.write_dnsmasq_configurations( self.ap_interface, card.get_ip(), [ ".".join(card.get_ip().split(".")[:3] + ["2"]), ".".join(card.get_ip().split(".")[:3] + ["254"]) ], ["8.8.8.8", "8.8.4.4"], len(final_list)) self.aplauncher.write_hostapd_configurations(self.ap_interface, final_list, rand_mac)
def post_scanning_configurations(self): # Escrever num ficheiro depois ler se for chamado no airhost card = NetworkCard(self.ap_interface) max_supported_access_points = card.get_number_of_supported_aps() print "Max aps: ", max_supported_access_points if self.max_access_points > max_supported_access_points: print "[-] max_access_points is higher than what card supports. Setting to {}".format(max_supported_access_points) self.max_access_points = max_supported_access_points self.aplauncher = APLauncher(self.hostapd_conf) self.dnsmasqhandler = DNSMasqHandler(self.dnsmasq_conf) rand_mac = "52:54:00:%02x:%02x:%02x" % (randint(0, 255), randint(0, 255), randint(0, 255)) final_list = [] if len(self.lonely_probes) < self.max_access_points: print "[+] Adding all requested ssids to hostapd configuration." for probe in self.lonely_probes: print "[+] Adding '{}' with hit_count '{}' to hostapd configuration".format(probe, self.hit_count[probe]) final_list = list(self.lonely_probes) SessionManager().log_event(NeutralEvent("Added all found probes to Karma list.")) else: inverted_popular_ssids = { hit_count : ssid for ssid, hit_count in self.hit_count.iteritems() } ordered_popularity = sorted(inverted_popular_ssids.keys())[::-1] for i in ordered_popularity: popular_ssid = inverted_popular_ssids[i] final_list.append(popular_ssid) print "[+] Adding '{}' with hit_count '{}' to hostapd configuration".format(popular_ssid, self.hit_count[popular_ssid]) SessionManager().log_event(NeutralEvent("Added '{}' to Karma list.".format(popular_ssid))) if len(final_list) == self.max_access_points: break self.number_of_configured_nets = len(final_list) NetworkManager().set_mac_and_unmanage( self.ap_interface, rand_mac, True, self.number_of_configured_nets) self.dnsmasqhandler.set_captive_portal_mode(self.captive_portal) self.dnsmasqhandler.write_dnsmasq_configurations(self.ap_interface, card.get_ip(), [ ".".join(card.get_ip().split(".")[:3] + ["2"]), ".".join(card.get_ip().split(".")[:3] + ["254"]) ], ["8.8.8.8", "8.8.4.4"], len(final_list)) self.aplauncher.write_hostapd_configurations( self.ap_interface, final_list, rand_mac)
def post_start(self): # Wait for hostapd to setup all the access points sleep(1) card = NetworkCard(self.ap_interface) if card is not None: gateway = card.get_ip() for i in range(self.number_of_configured_nets - 1): interface_name = "{}_{}".format(self.ap_interface, i) if interface_name in pyw.winterfaces(): gateway = ".".join(gateway.split(".")[0:2] + [str(int(gateway.split(".")[2]) + 1)] + [gateway.split(".")[3]]) NetUtils().interface_config(interface_name, card.get_ip()) NetUtils().set_interface_mtu(interface_name, 1800) NetUtils().accept_forwarding(interface_name) self.dnsmasqhandler.start_dnsmasq()
def post_start(self): # Wait for hostapd to setup all the access points sleep(1) card = NetworkCard(self.ap_interface) if card is not None: gateway = card.get_ip() for i in range(self.number_of_configured_nets - 1): interface_name = "{}_{}".format(self.ap_interface, i) if interface_name in pyw.winterfaces(): gateway = ".".join( gateway.split(".")[0:2] + [str(int(gateway.split(".")[2]) + 1)] + [gateway.split(".")[3]]) NetUtils().interface_config(interface_name, card.get_ip()) NetUtils().set_interface_mtu(interface_name, 1800) NetUtils().accept_forwarding(interface_name) self.dnsmasqhandler.start_dnsmasq()