Пример #1
0
    def initialize(self):
        """
        Set up scanning based on configuration
        FixedRange -> Reads from range_fixed field in configuration
        otherwise, takes a range from every IP address the current host has.
        :return:
        """
        # get local ip addresses
        self._ip_addresses = local_ips()

        if not self._ip_addresses:
            raise Exception("Cannot find local IP address for the machine")

        LOG.info("Found local IP addresses of the machine: %r",
                 self._ip_addresses)
        # for fixed range, only scan once.
        if WormConfiguration.range_class is FixedRange:
            self._ranges = [
                WormConfiguration.range_class(
                    fixed_addresses=WormConfiguration.range_fixed)
            ]
        else:
            self._ranges = [
                WormConfiguration.range_class(ip_address)
                for ip_address in self._ip_addresses
            ]
        if WormConfiguration.local_network_scan:
            self._ranges += [
                FixedRange(
                    [ip_address for ip_address in get_ips_from_interfaces()])
            ]
        LOG.info("Base local networks to scan are: %r", self._ranges)
Пример #2
0
    def initialize(self):
        # get local ip addresses
        self._ip_addresses = local_ips()

        if not self._ip_addresses:
            raise Exception("Cannot find local IP address for the machine")

        LOG.info("Found local IP addresses of the machine: %r", self._ip_addresses)
        # for fixed range, only scan once.
        if WormConfiguration.range_class is FixedRange:
            self._ranges = [WormConfiguration.range_class(None)]
        else:
            self._ranges = [WormConfiguration.range_class(ip_address)
                            for ip_address in self._ip_addresses]
        if WormConfiguration.local_network_scan:
            self._ranges += [FixedRange([ip_address for ip_address in get_ips_from_interfaces()])]
        LOG.info("Base local networks to scan are: %r", self._ranges)