Exemple #1
0
def analysis(targets, check_ranges, check_subdomains, subs_temp, range_temp,
             log_in_file, time_sleep, language, verbose_level, show_version,
             check_update, proxies, retries, socks_proxy, enumerate_flag):
    tmp = open(range_temp, 'a')
    tmp.write('')
    tmp.close()
    tmp = open(subs_temp, 'a')
    tmp.write('')
    tmp.close()

    for target in targets:
        if target_type(target) == 'SINGLE_IPv4':
            if check_ranges is True:
                if not enumerate_flag:
                    info(messages(language, 51).format(target))
                IPs = IPRange(getIPRange(target), range_temp, language)
                if type(IPs) == netaddr.ip.IPNetwork:
                    for IPm in IPs:
                        yield IPm
                elif type(IPs) == list:
                    for IPm in IPs:
                        for IP in IPm:
                            yield IP
            else:
                if not enumerate_flag:
                    info(messages(language, 81).format(target))
                yield target

        elif target_type(target) == 'RANGE_IPv4' or target_type(
                target) == 'CIDR_IPv4':
            IPs = IPRange(target, range_temp, language)
            if not enumerate_flag: info(messages(language, 52).format(target))
            if type(IPs) == netaddr.ip.IPNetwork:
                for IPm in IPs:
                    yield IPm
            elif type(IPs) == list:
                for IPm in IPs:
                    for IP in IPm:
                        yield IP

        elif target_type(target) == 'DOMAIN':
            if check_subdomains is True:
                if check_ranges is True:
                    if enumerate_flag:
                        info(messages(language, 52).format(target))
                    sub_domains = json.loads(open(subs_temp).read()) if len(open(subs_temp).read()) > 0 else \
                        __get_subs(target, 3, '', 0, language, 0, socks_proxy, 3, 0, 0)
                    if len(open(subs_temp).read()) is 0:
                        f = open(subs_temp, 'a')
                        f.write(json.dumps(sub_domains))
                        f.close()
                    if target not in sub_domains:
                        sub_domains.append(target)
                    for target in sub_domains:
                        if not enumerate_flag:
                            info(messages(language, 81).format(target))
                        yield target
                        n = 0
                        err = 0
                        IPs = []
                        while True:
                            try:
                                IPs.append(socket.gethostbyname(target))
                                err = 0
                                n += 1
                                if n is 12:
                                    break
                            except:
                                err += 1
                                if err is 3 or n is 12:
                                    break
                        IPz = list(set(IPs))
                        for IP in IPz:
                            if not enumerate_flag:
                                info(messages(language, 51).format(IP))
                            IPs = IPRange(getIPRange(IP), range_temp, language)
                            if type(IPs) == netaddr.ip.IPNetwork:
                                for IPm in IPs:
                                    yield IPm
                            elif type(IPs) == list:
                                for IPm in IPs:
                                    for IPn in IPm:
                                        yield IPn
                else:
                    if enumerate_flag:
                        info(messages(language, 52).format(target))
                    sub_domains = json.loads(open(subs_temp).read()) if len(open(subs_temp).read()) > 0 else \
                        __get_subs(target, 3, '', 0, language, 0, socks_proxy, 3, 0, 0)
                    if len(open(subs_temp).read()) is 0:
                        f = open(subs_temp, 'a')
                        f.write(json.dumps(sub_domains))
                        f.close()
                    if target not in sub_domains:
                        sub_domains.append(target)
                    for target in sub_domains:
                        if not enumerate_flag:
                            info(messages(language, 81).format(target))
                        yield target
            else:
                if check_ranges is True:
                    if not enumerate_flag:
                        info(messages(language, 52).format(target))
                    yield target
                    n = 0
                    err = 0
                    IPs = []
                    while True:
                        try:
                            IPs.append(socket.gethostbyname(target))
                            err = 0
                            n += 1
                            if n is 12:
                                break
                        except:
                            err += 1
                            if err is 3 or n is 12:
                                break
                    IPz = list(set(IPs))
                    for IP in IPz:
                        if not enumerate_flag:
                            info(messages(language, 51).format(IP))
                        IPs = IPRange(getIPRange(IP), range_temp, language)
                        if type(IPs) == netaddr.ip.IPNetwork:
                            for IPm in IPs:
                                yield IPm
                        elif type(IPs) == list:
                            for IPm in IPs:
                                for IPn in IPm:
                                    yield IPn
                else:
                    if not enumerate_flag:
                        info(messages(language, 81).format(target))
                    yield target

        elif target_type(target) == 'HTTP':
            if not enumerate_flag: info(messages(language, 52).format(target))
            yield target
            if check_ranges is True:
                if 'http://' == target[:7].lower():
                    target = target[7:].rsplit('/')[0]
                if 'https://' == target[:8].lower():
                    target = target[8:].rsplit('/')[0]
                yield target
                IPs = []
                while True:
                    try:
                        IPs.append(socket.gethostbyname(target))
                        err = 0
                        n += 1
                        if n is 12:
                            break
                    except:
                        err += 1
                        if err is 3 or n is 12:
                            break
                IPz = list(set(IPs))
                for IP in IPz:
                    if not enumerate_flag:
                        info(messages(language, 51).format(IP))
                    IPs = IPRange(getIPRange(IP), range_temp, language)
                    if type(IPs) == netaddr.ip.IPNetwork:
                        for IPm in IPs:
                            yield IPm
                    elif type(IPs) == list:
                        for IPm in IPs:
                            for IPn in IPm:
                                yield IPn

        else:
            sys.exit(error(messages(language, 50).format(target)))
Exemple #2
0
def analysis(
    targets,
    check_ranges,
    check_subdomains,
    subs_temp,
    range_temp,
    log_in_file,
    time_sleep,
    language,
    verbose_level,
    retries,
    socks_proxy,
    enumerate_flag,
):
    """
    analysis and calulcate targets.

    Args:
        targets: targets
        check_ranges: check IP range flag
        check_subdomains: check subdomain flag
        subs_temp: subdomain temp filename
        range_temp: IP range tmp filename
        log_in_file: output filename
        time_sleep: time to sleep
        language: language
        verbose_level: verbose level number
        retries: retries number
        socks_proxy: socks proxy
        enumerate_flag: enumerate flag

    Returns:
        a generator
    """
    __log_into_file(range_temp, "a", "", language)
    __log_into_file(subs_temp, "a", "", language)

    for target in targets:
        if target_type(target) == "SINGLE_IPv4":
            if check_ranges:
                if not enumerate_flag:
                    info(messages(language, "checking_range").format(target))
                IPs = IPRange(getIPRange(target), range_temp, language)
                if type(IPs) == netaddr.ip.IPNetwork:
                    for IPm in IPs:
                        yield IPm
                elif type(IPs) == list:
                    for IPm in IPs:
                        for IP in IPm:
                            yield IP
            else:
                if not enumerate_flag:
                    info(messages(language, "target_submitted").format(target))
                yield target
        elif target_type(target) == "SINGLE_IPv6":
            yield target

        elif (target_type(target) == "RANGE_IPv4"
              or target_type(target) == "CIDR_IPv4"):
            IPs = IPRange(target, range_temp, language)
            if not enumerate_flag:
                info(messages(language, "checking").format(target))
            if type(IPs) == netaddr.ip.IPNetwork:
                for IPm in IPs:
                    yield IPm
            elif type(IPs) == list:
                for IPm in IPs:
                    for IP in IPm:
                        yield IP

        elif target_type(target) == "DOMAIN":
            if check_subdomains:
                if check_ranges:
                    if enumerate_flag:
                        info(messages(language, "checking").format(target))
                    sub_domains = (json.loads(open(subs_temp).read())
                                   if len(open(subs_temp).read()) > 2 else
                                   __get_subs(target, 3, "", 0, language, 0,
                                              socks_proxy, 3, 0, 0))
                    if len(open(subs_temp).read()) == 0:
                        __log_into_file(subs_temp, "a",
                                        json.dumps(sub_domains), language)
                    if target not in sub_domains:
                        sub_domains.append(target)
                    for target in sub_domains:
                        if not enumerate_flag:
                            info(
                                messages(language,
                                         "target_submitted").format(target))
                        yield target
                        n = 0
                        err = 0
                        IPs = []
                        while True:
                            try:
                                IPs.append(socket.gethostbyname(target))
                                err = 0
                                n += 1
                                if n == 12:
                                    break
                            except Exception:
                                err += 1
                                if err == 3 or n == 12:
                                    break
                        IPz = list(set(IPs))
                        for IP in IPz:
                            if not enumerate_flag:
                                info(
                                    messages(language,
                                             "checking_range").format(IP))
                            IPs = IPRange(getIPRange(IP), range_temp, language)
                            if type(IPs) == netaddr.ip.IPNetwork:
                                for IPm in IPs:
                                    yield IPm
                            elif type(IPs) == list:
                                for IPm in IPs:
                                    for IPn in IPm:
                                        yield IPn
                else:
                    if enumerate_flag:
                        info(messages(language, "checking").format(target))
                    sub_domains = (json.loads(open(subs_temp).read())
                                   if len(open(subs_temp).read()) > 2 else
                                   __get_subs(target, 3, "", 0, language, 0,
                                              socks_proxy, 3, 0, 0))
                    if len(open(subs_temp).read()) == 0:
                        __log_into_file(subs_temp, "a",
                                        json.dumps(sub_domains), language)
                    if target not in sub_domains:
                        sub_domains.append(target)
                    for target in sub_domains:
                        if not enumerate_flag:
                            info(
                                messages(language,
                                         "target_submitted").format(target))
                        yield target
            else:
                if check_ranges:
                    if not enumerate_flag:
                        info(messages(language, "checking").format(target))
                    yield target
                    n = 0
                    err = 0
                    IPs = []
                    while True:
                        try:
                            IPs.append(socket.gethostbyname(target))
                            err = 0
                            n += 1
                            if n == 12:
                                break
                        except Exception:
                            err += 1
                            if err == 3 or n == 12:
                                break
                    IPz = list(set(IPs))
                    for IP in IPz:
                        if not enumerate_flag:
                            info(
                                messages(language,
                                         "checking_range").format(IP))
                        IPs = IPRange(getIPRange(IP), range_temp, language)
                        if type(IPs) == netaddr.ip.IPNetwork:
                            for IPm in IPs:
                                yield IPm
                        elif type(IPs) == list:
                            for IPm in IPs:
                                for IPn in IPm:
                                    yield IPn
                else:
                    if not enumerate_flag:
                        info(
                            messages(language,
                                     "target_submitted").format(target))
                    yield target

        elif target_type(target) == "HTTP":
            if not enumerate_flag:
                info(messages(language, "checking").format(target))
            yield target
            if check_ranges:
                if "http://" == target[:7].lower():
                    target = target[7:].rsplit("/")[0]
                if "https://" == target[:8].lower():
                    target = target[8:].rsplit("/")[0]
                yield target
                IPs = []
                while True:
                    try:
                        IPs.append(socket.gethostbyname(target))
                        err = 0
                        n += 1
                        if n == 12:
                            break
                    except Exception:
                        err += 1
                        if err == 3 or n == 12:
                            break
                IPz = list(set(IPs))
                for IP in IPz:
                    if not enumerate_flag:
                        info(messages(language, "checking_range").format(IP))
                    IPs = IPRange(getIPRange(IP), range_temp, language)
                    if type(IPs) == netaddr.ip.IPNetwork:
                        for IPm in IPs:
                            yield IPm
                    elif type(IPs) == list:
                        for IPm in IPs:
                            for IPn in IPm:
                                yield IPn

        else:
            __die_failure(messages(language, "unknown_target").format(target))
Exemple #3
0
def analysis(targets, check_ranges, check_subdomains, subs_temp, range_temp,
             log_in_file, time_sleep, language, verbose_level, retries,
             socks_proxy, enumerate_flag):
    """
    analysis and calulcate targets.

    Args:
        targets: targets
        check_ranges: check IP range flag
        check_subdomains: check subdomain flag
        subs_temp: subdomain temp filename
        range_temp: IP range tmp filename
        log_in_file: output filename
        time_sleep: time to sleep
        language: language
        verbose_level: verbose level number
        retries: retries number
        socks_proxy: socks proxy
        enumerate_flag: enumerate flag

    Returns:
        a generator
    """
    __log_into_file(range_temp, 'a', '', language)
    __log_into_file(subs_temp, 'a', '', language)

    for target in targets:
        if target_type(target) == 'SINGLE_IPv4':
            if check_ranges:
                if not enumerate_flag:
                    info(messages(language, 51).format(target))
                IPs = IPRange(getIPRange(target), range_temp, language)
                if type(IPs) == netaddr.ip.IPNetwork:
                    for IPm in IPs:
                        yield IPm
                elif type(IPs) == list:
                    for IPm in IPs:
                        for IP in IPm:
                            yield IP
            else:
                if not enumerate_flag:
                    info(messages(language, 81).format(target))
                yield target
        elif target_type(target) == 'SINGLE_IPv6':
            yield target

        elif target_type(target) == 'RANGE_IPv4' or target_type(
                target) == 'CIDR_IPv4':
            IPs = IPRange(target, range_temp, language)
            if not enumerate_flag: info(messages(language, 52).format(target))
            if type(IPs) == netaddr.ip.IPNetwork:
                for IPm in IPs:
                    yield IPm
            elif type(IPs) == list:
                for IPm in IPs:
                    for IP in IPm:
                        yield IP

        elif target_type(target) == 'DOMAIN':
            if check_subdomains:
                if check_ranges:
                    if enumerate_flag:
                        info(messages(language, 52).format(target))
                    sub_domains = json.loads(open(subs_temp).read()) if len(open(subs_temp).read()) > 2 else \
                        __get_subs(target, 3, '', 0, language, 0, socks_proxy, 3, 0, 0)
                    if len(open(subs_temp).read()) is 0:
                        __log_into_file(subs_temp, 'a',
                                        json.dumps(sub_domains), language)
                    if target not in sub_domains:
                        sub_domains.append(target)
                    for target in sub_domains:
                        if not enumerate_flag:
                            info(messages(language, 81).format(target))
                        yield target
                        n = 0
                        err = 0
                        IPs = []
                        while True:
                            try:
                                IPs.append(socket.gethostbyname(target))
                                err = 0
                                n += 1
                                if n is 12:
                                    break
                            except:
                                err += 1
                                if err is 3 or n is 12:
                                    break
                        IPz = list(set(IPs))
                        for IP in IPz:
                            if not enumerate_flag:
                                info(messages(language, 51).format(IP))
                            IPs = IPRange(getIPRange(IP), range_temp, language)
                            if type(IPs) == netaddr.ip.IPNetwork:
                                for IPm in IPs:
                                    yield IPm
                            elif type(IPs) == list:
                                for IPm in IPs:
                                    for IPn in IPm:
                                        yield IPn
                else:
                    if enumerate_flag:
                        info(messages(language, 52).format(target))
                    sub_domains = json.loads(open(subs_temp).read()) if len(open(subs_temp).read()) > 2 else \
                        __get_subs(target, 3, '', 0, language, 0, socks_proxy, 3, 0, 0)
                    if len(open(subs_temp).read()) is 0:
                        __log_into_file(subs_temp, 'a',
                                        json.dumps(sub_domains), language)
                    if target not in sub_domains:
                        sub_domains.append(target)
                    for target in sub_domains:
                        if not enumerate_flag:
                            info(messages(language, 81).format(target))
                        yield target
            else:
                if check_ranges:
                    if not enumerate_flag:
                        info(messages(language, 52).format(target))
                    yield target
                    n = 0
                    err = 0
                    IPs = []
                    while True:
                        try:
                            IPs.append(socket.gethostbyname(target))
                            err = 0
                            n += 1
                            if n is 12:
                                break
                        except:
                            err += 1
                            if err is 3 or n is 12:
                                break
                    IPz = list(set(IPs))
                    for IP in IPz:
                        if not enumerate_flag:
                            info(messages(language, 51).format(IP))
                        IPs = IPRange(getIPRange(IP), range_temp, language)
                        if type(IPs) == netaddr.ip.IPNetwork:
                            for IPm in IPs:
                                yield IPm
                        elif type(IPs) == list:
                            for IPm in IPs:
                                for IPn in IPm:
                                    yield IPn
                else:
                    if not enumerate_flag:
                        info(messages(language, 81).format(target))
                    yield target

        elif target_type(target) == 'HTTP':
            if not enumerate_flag: info(messages(language, 52).format(target))
            yield target
            if check_ranges:
                if 'http://' == target[:7].lower():
                    target = target[7:].rsplit('/')[0]
                if 'https://' == target[:8].lower():
                    target = target[8:].rsplit('/')[0]
                yield target
                IPs = []
                while True:
                    try:
                        IPs.append(socket.gethostbyname(target))
                        err = 0
                        n += 1
                        if n is 12:
                            break
                    except:
                        err += 1
                        if err is 3 or n is 12:
                            break
                IPz = list(set(IPs))
                for IP in IPz:
                    if not enumerate_flag:
                        info(messages(language, 51).format(IP))
                    IPs = IPRange(getIPRange(IP), range_temp, language)
                    if type(IPs) == netaddr.ip.IPNetwork:
                        for IPm in IPs:
                            yield IPm
                    elif type(IPs) == list:
                        for IPm in IPs:
                            for IPn in IPm:
                                yield IPn

        else:
            __die_failure(messages(language, 50).format(target))