Exemplo n.º 1
0
    def _load_target(self, target, service=None):

        # http://localhost
        if "http://" in target or "https://" in target:
            self.put_target(target, service)
        else:

            # 192.168.111.1/24
            if '/' in target and check_ippool(target):
                for each in build(target):
                    self.put_target(each, service)

            # 192.168.111.1-192.168.111.3
            elif '-' in target and check_ippool(target):
                _v = target.split('-')
                for each in build(_v[0], _v[1]):
                    self.put_target(each, service)

            # 192.168.111.1
            else:
                target = target[:-1] if target[-1] == '/' else target
                if ":" in target:
                    _v = target.split(':')
                    host = _v[0]
                    if check_host(host):
                        self.put_target(target, service)
                else:
                    if check_host(target):
                        self.put_target(target, service)
Exemplo n.º 2
0
    def _load_target(self, no, target, service=None):
        targets = []

        # http://localhost
        if target.startswith('http://') or target.startswith('https://'):
            protocol, s1 = urllib.parse.splittype(target)
            host, s2 = urllib.parse.splithost(s1)
            host, port = urllib.parse.splitport(host)
            port = int(
                port
            ) if port != None and port != 0 else 443 if protocol == 'https' else 80
            targets.append(
                self.deal_target(no, ':'.join([host, str(port)]),
                                 SERVICE_PORT_MAP.WEB[0], target))
            if self.limit_port:
                targets += [
                    self.deal_target(no, ':'.join([host, str(x)]), service,
                                     None) for x in self.limit_port
                    if x != port
                ]

        else:

            # 192.168.111.1/24
            if '/' in target and check_ippool(target):
                if self.limit_port:
                    for each in build(target):
                        targets += [
                            self.deal_target(no, ':'.join([each, str(x)]),
                                             service, None)
                            for x in self.limit_port
                        ]
                else:
                    targets += [
                        self.deal_target(no, each, service, None)
                        for each in build(target)
                    ]

            # 192.168.111.1-192.168.111.3
            elif '-' in target and check_ippool(target):
                _v = target.split('-')
                if self.limit_port:
                    for each in build(_v[0], _v[1]):
                        targets += [
                            self.deal_target(no, ':'.join([each, str(x)]),
                                             service, None)
                            for x in self.limit_port
                        ]
                else:
                    targets += [
                        self.deal_target(no, each, service, None)
                        for each in build(_v[0], _v[1])
                    ]

            # 192.168.111.1
            else:
                target = target[:-1] if target[-1] == '/' else target
                if self.limit_port:
                    targets += [
                        self.deal_target(no, ':'.join([target, str(x)]),
                                         service, None)
                        for x in self.limit_port
                    ]
                else:
                    targets.append(self.deal_target(no, target, service, None))

        return targets