# Path: theHarvester/discovery/dnssearch.py
# class DnsForce:
#     def __init__(self, domain, dnsserver, verbose=False):
#     async def run(self):
# def serialize_ip_range(
#         ip: str,
#         netmask: str = '24') -> str:
# def list_ips_in_network_range(iprange: str) -> List[str]:
# async def reverse_single_ip(ip: str, resolver: DNSResolver) -> str:
# async def reverse_all_ips_in_range(iprange: str, callback: Callable, nameservers: Optional[List[str]] = None) -> None:
# def log_query(ip: str) -> None:
# def log_result(host: str) -> None:
# def generate_postprocessing_callback(target: str, **allhosts: List[str]) -> Callable:
#     def append_matching_hosts(host: str) -> None:
# IP_REGEX = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
# PORT_REGEX = r'\d{1,5}'
# NETMASK_REGEX = r'\d{1,2}|' + IP_REGEX
# NETWORK_REGEX = r'\b({})(?:\:({}))?(?:\/({}))?\b'.format(
#     IP_REGEX,
#     PORT_REGEX,
#     NETMASK_REGEX)
# 
# Path: theHarvester/discovery/takeover.py
# class TakeOver:
#     def __init__(self, hosts):
#     async def check(self, url, resp):
#     async def do_take(self):
#     async def process(self, proxy=False):
# 
# Path: theHarvester/discovery/shodansearch.py
# class SearchShodan:
#     def __init__(self):
#     async def search_ip(self, ip):
# 
# Path: theHarvester/lib/hostchecker.py
# class Checker:
#     def __init__(self, hosts: list, nameserver=False):
#     async def query(host, resolver) -> Tuple[str, Any]:
#     async def query_all(self, resolver) -> list:
#     async def check(self):
# 
# Path: theHarvester/lib/stash.py
# class StashManager:
#     def __init__(self):
#     async def do_init(self):
#     async def store(self, domain, resource, res_type, source):
#     async def store_all(self, domain, all, res_type, source):
#     async def generatedashboardcode(self, domain):
#     async def getlatestscanresults(self, domain, previousday=False):
#     async def getscanboarddata(self):
#     async def getscanhistorydomain(self, domain):
#     async def getpluginscanstatistics(self):
#     async def latestscanchartdata(self, domain):


from typing import Dict, List
from theHarvester.discovery import *
from theHarvester.discovery import dnssearch, takeover, shodansearch
from theHarvester.discovery.constants import *
from theHarvester.lib import hostchecker
from theHarvester.lib import stash
from theHarvester.lib.core import *
                    from theHarvester.discovery import anubis
                    from theHarvester.discovery import baidusearch
                    from theHarvester.discovery import binaryedgesearch
                    from theHarvester.discovery import bingsearch
                    from theHarvester.discovery import bufferoverun
                    from theHarvester.discovery import censysearch
                    from theHarvester.discovery import certspottersearch
                        from theHarvester.discovery import crtsh
                        from theHarvester.discovery import dnsdumpster
                    from theHarvester.discovery import duckduckgosearch
                    from theHarvester.discovery import fullhuntsearch
                        from theHarvester.discovery import githubcode
                    from theHarvester.discovery import googlesearch
                    from theHarvester.discovery import hackertarget
                    from theHarvester.discovery import huntersearch
                    from theHarvester.discovery import intelxsearch
                    from theHarvester.discovery import linkedinsearch
                    from theHarvester.discovery import linkedinsearch
                    from theHarvester.discovery import n45htsearch
                    from theHarvester.discovery import omnisint
                    from theHarvester.discovery import otxsearch
                    from theHarvester.discovery import pentesttools
                    from theHarvester.discovery import projectdiscovery
                    from theHarvester.discovery import qwantsearch
                    from theHarvester.discovery import rapiddns
                    from theHarvester.discovery import rocketreach
                    from theHarvester.discovery import securitytrailssearch
                    from theHarvester.discovery import sublist3r
                    from theHarvester.discovery import spyse
                    from theHarvester.discovery import threatcrowd
                    from theHarvester.discovery import threatminer
                    from theHarvester.discovery import trello
                    from theHarvester.discovery import twittersearch
                    from theHarvester.discovery import urlscan
                    from theHarvester.discovery import virustotal
                    from theHarvester.discovery import yahoosearch
                        from theHarvester.discovery import zoomeyesearch
        from theHarvester.discovery.dnssearch import (
            generate_postprocessing_callback,
            reverse_all_ips_in_range,
            serialize_ip_range)
        from aiomultiprocess import Pool
        from theHarvester.screenshot.screenshot import ScreenShotter
import argparse
import asyncio
import ujson
import netaddr
import re
import sys
import string
import secrets
    import os
        import time
        import json
        print('\n[*] Starting active queries.')
        # load the reverse dns tools

        # reverse each iprange in a separate task
        __reverse_dns_tasks = {}
        for entry in host_ip:
            __ip_range = serialize_ip_range(ip=entry, netmask='24')
            if __ip_range and __ip_range not in set(__reverse_dns_tasks.keys()):
                print('\n[*] Performing reverse lookup on ' + __ip_range)
                __reverse_dns_tasks[__ip_range] = asyncio.create_task(reverse_all_ips_in_range(
                    iprange=__ip_range,
                    callback=generate_postprocessing_callback(
                        target=word,
                        local_results=dnsrev,
                        overall_results=full),
                    nameservers=list(map(str, dnsserver.split(','))) if dnsserver else None))

        # run all the reversing tasks concurrently
        await asyncio.gather(*__reverse_dns_tasks.values())

        # Display the newly found hosts
        print('\n[*] Hosts found after reverse lookup (in target domain):')
        print('--------------------------------------------------------')
        for xh in dnsrev:
            print(xh)

    # DNS TLD expansion
    dnstldres = []
    if dnstld is True:
        print('[*] Starting DNS TLD expansion.')

# Path: theHarvester/discovery/dnssearch.py
# class DnsForce:
#     def __init__(self, domain, dnsserver, verbose=False):
#     async def run(self):
# def serialize_ip_range(
#         ip: str,
#         netmask: str = '24') -> str:
# def list_ips_in_network_range(iprange: str) -> List[str]:
# async def reverse_single_ip(ip: str, resolver: DNSResolver) -> str:
# async def reverse_all_ips_in_range(iprange: str, callback: Callable, nameservers: Optional[List[str]] = None) -> None:
# def log_query(ip: str) -> None:
# def log_result(host: str) -> None:
# def generate_postprocessing_callback(target: str, **allhosts: List[str]) -> Callable:
#     def append_matching_hosts(host: str) -> None:
# IP_REGEX = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
# PORT_REGEX = r'\d{1,5}'
# NETMASK_REGEX = r'\d{1,2}|' + IP_REGEX
# NETWORK_REGEX = r'\b({})(?:\:({}))?(?:\/({}))?\b'.format(
#     IP_REGEX,
#     PORT_REGEX,
#     NETMASK_REGEX)
# 
# Path: theHarvester/discovery/takeover.py
# class TakeOver:
#     def __init__(self, hosts):
#     async def check(self, url, resp):
#     async def do_take(self):
#     async def process(self, proxy=False):
# 
# Path: theHarvester/discovery/shodansearch.py
# class SearchShodan:
#     def __init__(self):
#     async def search_ip(self, ip):
# 
# Path: theHarvester/lib/hostchecker.py
# class Checker:
#     def __init__(self, hosts: list, nameserver=False):
#     async def query(host, resolver) -> Tuple[str, Any]:
#     async def query_all(self, resolver) -> list:
#     async def check(self):
# 
# Path: theHarvester/lib/stash.py
# class StashManager:
#     def __init__(self):
#     async def do_init(self):
#     async def store(self, domain, resource, res_type, source):
#     async def store_all(self, domain, all, res_type, source):
#     async def generatedashboardcode(self, domain):
#     async def getlatestscanresults(self, domain, previousday=False):
#     async def getscanboarddata(self):
#     async def getscanhistorydomain(self, domain):
#     async def getpluginscanstatistics(self):
#     async def latestscanchartdata(self, domain):


# Path: theHarvester/__main__.py
from typing import Dict, List
from theHarvester.discovery import *
from theHarvester.discovery import dnssearch, takeover, shodansearch
from theHarvester.discovery.constants import *
from theHarvester.lib import hostchecker
from theHarvester.lib import stash
from theHarvester.lib.core import *
                    from theHarvester.discovery import anubis
                    from theHarvester.discovery import baidusearch
                    from theHarvester.discovery import binaryedgesearch
                    from theHarvester.discovery import bingsearch
                    from theHarvester.discovery import bufferoverun
                    from theHarvester.discovery import censysearch
                    from theHarvester.discovery import certspottersearch
                        from theHarvester.discovery import crtsh
                        from theHarvester.discovery import dnsdumpster
                    from theHarvester.discovery import duckduckgosearch
                    from theHarvester.discovery import fullhuntsearch
                        from theHarvester.discovery import githubcode
                    from theHarvester.discovery import googlesearch
                    from theHarvester.discovery import hackertarget
                    from theHarvester.discovery import huntersearch
                    from theHarvester.discovery import intelxsearch
                    from theHarvester.discovery import linkedinsearch
                    from theHarvester.discovery import linkedinsearch
                    from theHarvester.discovery import n45htsearch
                    from theHarvester.discovery import omnisint
                    from theHarvester.discovery import otxsearch
                    from theHarvester.discovery import pentesttools
                    from theHarvester.discovery import projectdiscovery
                    from theHarvester.discovery import qwantsearch
                    from theHarvester.discovery import rapiddns
                    from theHarvester.discovery import rocketreach
                    from theHarvester.discovery import securitytrailssearch
                    from theHarvester.discovery import sublist3r
                    from theHarvester.discovery import spyse
                    from theHarvester.discovery import threatcrowd
                    from theHarvester.discovery import threatminer
                    from theHarvester.discovery import trello
                    from theHarvester.discovery import twittersearch
                    from theHarvester.discovery import urlscan
                    from theHarvester.discovery import virustotal
                    from theHarvester.discovery import yahoosearch
                        from theHarvester.discovery import zoomeyesearch
        from theHarvester.discovery.dnssearch import (
            generate_postprocessing_callback,
            reverse_all_ips_in_range,
            serialize_ip_range)
        from aiomultiprocess import Pool
        from theHarvester.screenshot.screenshot import ScreenShotter
import argparse
import asyncio
import ujson
import netaddr
import re
import sys
import string
import secrets
    import os
        import time
        import json

        print('\n[*] Starting active queries.')
        # load the reverse dns tools

        # reverse each iprange in a separate task
        __reverse_dns_tasks = {}
        for entry in host_ip:
            __ip_range = serialize_ip_range(ip=entry, netmask='24')
            if __ip_range and __ip_range not in set(__reverse_dns_tasks.keys()):
                print('\n[*] Performing reverse lookup on ' + __ip_range)
                __reverse_dns_tasks[__ip_range] = asyncio.create_task(reverse_all_ips_in_range(
                    iprange=__ip_range,
                    callback=generate_postprocessing_callback(
                        target=word,
                        local_results=dnsrev,
                        overall_results=full),
                    nameservers=list(map(str, dnsserver.split(','))) if dnsserver else None))

        # run all the reversing tasks concurrently
        await asyncio.gather(*__reverse_dns_tasks.values())

        # Display the newly found hosts
        print('\n[*] Hosts found after reverse lookup (in target domain):')
        print('--------------------------------------------------------')
        for xh in dnsrev:
            print(xh)

    # DNS TLD expansion
    dnstldres = []
    if dnstld is True:
        print('[*] Starting DNS TLD expansion.')

        a = dnssearch.DnsTld(word, dnsserver, verbose=True)