예제 #1
0
    def _clear_iptable_rules(self):
        if self.set_rules:
            NetUtils().set_port_redirection_rule("tcp", "80", self.listen_port, add = False)
            if self.ssl:
                NetUtils().set_port_redirection_rule("tcp", "443", self.listen_port, add = False)

            self.set_rules = False
예제 #2
0
    def _prepare_iptable_rules(self):
        if not self.set_rules:
            NetUtils().set_port_redirection_rule("tcp", "80", self.listen_port)
            if self.ssl:
                NetUtils().set_port_redirection_rule("tcp", "443", self.listen_port)

            self.set_rules = True
예제 #3
0
 def restore_process(self):
     if not self.is_set_up:
         NetUtils().set_port_redirection_rule(
             "tcp", "80", self.config["tcp_redirection_port"],
             False)  # Deletes the iptable rule
         NetUtils().set_port_redirection_rule(
             "tcp", "443", self.config["tcp_redirection_port"],
             False)  # Deletes the iptable rule
     super(SSLStripSpawner, self).restore_process()
예제 #4
0
 def setup_process(self):
     if not self.is_set_up:
         NetUtils().set_port_redirection_rule(
             "tcp", "80", self.config["tcp_redirection_port"],
             True)  # Adds the iptable rule
         NetUtils().set_port_redirection_rule(
             "tcp", "443", self.config["tcp_redirection_port"],
             True)  # Adds the iptable rule
     super(SSLStripSpawner, self).setup_process()
예제 #5
0
    def restore_process(self):
        airhost_configs = ConfigurationManager(
        ).config["etf"]["aircommunicator"]["airhost"]
        ap_interface = airhost_configs["ap_interface"]
        internet_interface = airhost_configs["internet_interface"]

        NetUtils().flush_iptables()
        NetUtils().accept_forwarding(ap_interface)
        NetUtils().set_postrouting_interface(internet_interface)
예제 #6
0
    def _parse_connected_clients(self, interface):
        try:
            if not pyw.modeget(pyw.getcard(interface)) == 'AP':
                print "[-] '{}' is not on AP mode".format(interface)
                return False
        except Exception:
            return False

        client_dump = check_output("iw dev {} station dump".format(
            interface).split()).split('Station')
        client_dump = [
            map(str.strip, client.split("\n")) for client in client_dump
            if interface in client
        ]
        ssid = NetUtils().get_ssid_from_interface(interface)
        temp_clients = []
        # At this point a client is a list of arguments to be parsed
        for client in client_dump:
            client_mac = client[0].split()[0].strip()
            client_name, client_ip = NetUtils().get_ip_from_mac(
                interface, client_mac)
            inactivity_time = client[1].split(":")[1].strip()
            rx_packets = client[3].split(":")[1].strip()
            tx_packets = client[5].split(":")[1].strip()
            signal = client[8].split(":")[1].strip()
            tx_bitrate = client[10].split(":")[1].strip()
            rx_bitrate = client[11].split(":")[1].strip()
            id = len(temp_clients)

            client = Client(id, client_name, client_mac, client_ip, ssid,
                            inactivity_time, rx_packets, tx_packets,
                            rx_bitrate, tx_bitrate, signal)

            try:
                if client not in self.connected_clients[interface]:
                    connected_client_str = "New connected client on '{ssid}'-> ip: {ip}, mac: {mac} ({vendor})"\
                                           .format(ssid=ssid, ip=client_ip, mac=client_mac, vendor=client.vendor)
                    SessionManager().log_event(
                        SuccessfulEvent(connected_client_str))
                    print "[+]", connected_client_str
            except:
                pass

            temp_clients.append(client)

        self.connected_clients[interface] = temp_clients
        return True
예제 #7
0
 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()
예제 #8
0
    def setup_process(self):
        try:
            self.redirection_port = ConfigurationManager(
            ).config["etf"]["spawner"]["tcp_redirection_port"]
        except KeyError:
            pass

        NetUtils().set_port_redirection_rule("tcp", "80",
                                             self.redirection_port,
                                             True)  # Adds the iptable rule
예제 #9
0
 def _get_ssid_from_mac(self, mac_address):
     for iface in pyw.winterfaces():
         if pyw.macget(pyw.getcard(iface)) == mac_address:
             return NetUtils().get_ssid_from_interface(iface)