Exemple #1
0
 def _sniff_packets(self):
     # type: () -> None
     """Sniff packets one at a time until otherwise set."""
     while self._should_continue:
         dot11.sniff(iface=self._interface,
                     prn=self._process_packets,
                     count=1,
                     store=0)
def main(
):  # function that combines sniffing and sending signals to initiate the script
    print(f"Wifi Scanner Initialized")

    while True:  # loops between sniffing signals and sending the signals to the gateway
        sniff(iface="wlan1mon", prn=handle_packet,
              timeout=60)  # start sniffing and stops at the timout
        send_update()
Exemple #3
0
 def _sniff_packets(self):
     # type: () -> None
     """Sniff packets one at a time until otherwise set."""
     while self._should_continue:
         dot11.sniff(
             iface=self._interface,
             prn=self._process_packets,
             count=1,
             store=0)
Exemple #4
0
    def _sniff_packets(self):
        """
        Sniff packets one at a time until otherwise set

        :param self: An AccessPointFinder object
        :type self: AccessPointFinder
        :return: None
        :rtype: None
        """

        # continue to find clients until otherwise told
        while self._should_continue:
            dot11.sniff(iface=self._interface.get_name(), prn=self._process_packets, count=1,
                        store=0)
Exemple #5
0
def main():
    args = arg_parser.parse_args()
    config_file = args.config
    if config_file:
        try:
            with open(config_file) as fp:
                config.update(yaml.safe_load(fp))
        except:
            # Cannot read configuration file
            pass

    register_devices(config)

    if args.log_file:
        handler = RotatingFileHandler(args.log_file)
    else:
        handler = logging.StreamHandler()

    formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')

    handler.setFormatter(formatter)
    logger.addHandler(handler)
    if args.verbose:
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)

    channels = config.get('channels', range(1, 13 + 1))

    plugin_dir = config.get('plugin_dir', None)
    if plugin_dir:
        plugin_manager.load_plugins(plugin_dir)

    hopper = threading.Thread(target=channel_hopper,
                              args=(config['interface'], channels))
    hopper.setDaemon(True)
    hopper.start()

    expire_handler = threading.Thread(target=handle_expire)
    expire_handler.setDaemon(True)
    expire_handler.start()

    bootup()

    scapy.config.conf.iface = config['interface']
    sniff(iface=config['interface'],
          prn=packet_handler,
          lfilter=packet_filter,
          filter='not subtype beacon',
          store=False)
Exemple #6
0
    def _find_clients(self):
        """
        Find all the clients

        :param self: A Deauthentication object.
        :type self: Deauthentication
        :return: None
        :rtype: None
        """

        # continue to find clients until told otherwise
        while self._should_continue:
            dot11.sniff(iface=self._jamming_interface, prn=self._process_packet,
                        count=1, store=0)
Exemple #7
0
    def _sniff_packets(self):
        """
        Sniff packets one at a time until otherwise set

        :param self: An AccessPointFinder object
        :type self: AccessPointFinder
        :return: None
        :rtype: None
        """

        # continue to find clients until otherwise told
        while self._should_continue:
            dot11.sniff(iface=self._interface, prn=self._process_packets, count=1,
                        store=0)
Exemple #8
0
    def _listen(self):
        """
        Listening thread. Listens for packets and forwards them
        to _process_packet.

        :param self: An ExtensionManager object
        :type self: ExtensionManager
        :return: None
        :rtype: None
        """

        # continue to find clients until told otherwise
        dot11.sniff(iface=self._interface,
                    prn=self._process_packet,
                    store=0,
                    stop_filter=self._stopfilter)
Exemple #9
0
def get_new_ap(interface_name):
    # type: (str) -> Tuple[str, int, str, bool]
    """Return a new access point.

    :Example:
        >>> interface = "wlan0"
        >>> get_new_ap()
        AccessPoint("NEW AP", 2, 00:11:22:33:44:55, True)

    .. Note: This function has the possibility of blocking if it can't
        find a valid packet. However in practice this never happens.
    """
    access_point = collections.namedtuple(
        "AccessPoint", "name channel mac_address is_encrypted")
    packet = dot11.sniff(iface=interface_name,
                         count=1,
                         lfilter=is_packet_valid)[0]

    name = packet.info
    channel = ord(packet[dot11.Dot11Elt:3].info)
    mac_address = packet.addr3
    is_encrypted = "privacy" in packet.sprintf(
        "{Dot11Beacon:%Dot11Beacon.cap%}")

    return access_point(name, channel, mac_address, is_encrypted)
Exemple #10
0
    def _listen(self):
        """
        Listening thread. Listens for packets and forwards them
        to _process_packet.

        :param self: An ExtensionManager object
        :type self: ExtensionManager
        :return: None
        :rtype: None
        """

        # continue to find clients until told otherwise
        dot11.sniff(
            iface=self._interface,
            prn=self._process_packet,
            store=0,
            stop_filter=self._stopfilter)
Exemple #11
0
def main():
    args = arg_parser.parse_args()
    config_file = args.config
    if config_file:
        try:
            with open(config_file) as fp:
                config.update(yaml.load(fp.read()))
        except:
            # Cannot read configuration file
            pass

    register_devices(config)

    if args.log_file:
        handler = RotatingFileHandler(args.log_file)
    else:
        handler = logging.StreamHandler()

    formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')

    handler.setFormatter(formatter)
    logger.addHandler(handler)
    if args.verbose:
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)

    channels = config.get('channels', range(1, 13+1))

    hopper = threading.Thread(target=channel_hopper,
                              args=(config['interface'], channels))
    hopper.setDaemon(True)
    hopper.start()

    speak('Starting scanner')
    scapy.config.conf.iface = config['interface']
    sniff(iface=config['interface'], prn=packet_handler,
          lfilter=packet_filter, filter='not subtype beacon', store=False)
Exemple #12
0
    def _listen(self):
        """
        Listening thread. Listens for packets and forwards them
        to _process_packet.

        :param self: An ExtensionManager object
        :type self: ExtensionManager
        :return: None
        :rtype: None
        """

        try:
            # continue to find clients until told otherwise
            while self._should_continue:
                dot11.sniff(iface=self._interface.get_name(),
                            prn=self._process_packet,
                            count=1,
                            store=0,
                            stop_filter=self._stopfilter)
        # Don't display "Network is down" if shutting down
        except OSError:
            if not self._should_continue:
                pass
Exemple #13
0
 def run(self):
     print("Scanning for BSSIDs and non-AP STA MAC addresses")
     sniff(iface=interface, prn=self.get_macs, store=0, filter="wlan type mgt subtype beacon or wlan type mgt subtype probe-req",timeout=self.num_seconds)
Exemple #14
0
 def run(self):
     print("Starting experiment")
     sniff(iface=interface, prn=self.analyze, store=0, filter="wlan type mgt or (wlan type data subtype data and len <= 110)")
Exemple #15
0
    def sniffer(self, timeout=60, interface='wlan1mon'):

        sniff(iface=interface, prn=self.handle_packet, timeout=timeout)