Example #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)
Example #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)
Example #3
0
    def initialize(self):
        """
        Set up scanning.
        based on configuration: scans local network and/or scans fixed list of IPs/subnets.
        :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.
        self._ranges = [NetworkRange.get_range_obj(address_str=x) for x in WormConfiguration.subnet_scan_list]
        if WormConfiguration.local_network_scan:
            self._ranges += get_interfaces_ranges()
        LOG.info("Base local networks to scan are: %r", self._ranges)
Example #4
0
    def initialize(self):
        """
        Set up scanning.
        based on configuration: scans local network and/or scans fixed list of IPs/subnets.
        :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.
        self._ranges = [
            NetworkRange.get_range_obj(address_str=x)
            for x in WormConfiguration.subnet_scan_list
        ]
        if WormConfiguration.local_network_scan:
            self._ranges += get_interfaces_ranges()
        LOG.info("Base local networks to scan are: %r", self._ranges)