Ejemplo n.º 1
0
    def domains_to_ips(self):
        ar = AsyncResolver([domain_data["domain"] for domain_data in self.repo.get_domain_data()])
        resolved = ar.resolve()

        for host, ips in resolved.items():
            if ips is None:
                logging.debug("%s could not be resolved." % host)
            else:
                self.repo.add_domain_ips(host, ips)
Ejemplo n.º 2
0
def doAsyncDNSResolution(DomainList):
    '''
	Resolves the domains in the DomainList argument very quickly, asynchronously. 
	Returns a dictionary of {'host': 'ip'}

	@DomainList = A list of domains to be resolved. 

	IMPORTANT: The DomainList cannot contain duplicate domain names 
	or else this function will NEVER return!
	'''
    ar = AsyncResolver(DomainList, intensity=100)
    resolved = ar.resolve()
    return resolved
def doAsyncDNSResolution(DomainList):
	'''
	Resolves the domains in the DomainList argument very quickly, asynchronously. 
	Returns a dictionary of {'host': 'ip'}

	@DomainList = A list of domains to be resolved. 

	IMPORTANT: The DomainList cannot contain duplicate domain names 
	or else this function will NEVER return!
	'''
	ar = AsyncResolver(DomainList,intensity=100)
	resolved = ar.resolve()
	return resolved
Ejemplo n.º 4
0
from async_dns import AsyncResolver
import sys
from time import time
hosts=list(sys.argv)
hosts.pop(0)
ar = AsyncResolver(
           hosts
    )
start = time()
resolved = ar.resolve()
end = time()

print "-------------------------------------------"
for host, ip in resolved.items():
  if ip is None:
        	print "%s could not be resolved." % host
      	else:
        	print "%s resolved to %s" % (host, ip)
print "-------------------------------------------"
print "It took %.2f seconds to resolve %d hosts." % (end-start, len(sys.argv)-1)
print "-------------------------------------------"
Ejemplo n.º 5
0
                        host=DBHOST,
                        password=DBPASS,
                        port=DBPORT)
cur = conn.cursor()
resolver = dns.resolver.Resolver()
resolver.timeout = 1  # timoutes
resolver.lifetime = 1

#Adding addresses for domains not yet in the a table
cur.execute("select * from ns;")
nsList = cur.fetchall()
nsdList = []
acount = 0
dcount = 0

ar = AsyncResolver(["www.google.com", "www.reddit.com", "www.nonexistz.net"])
resolved = ar.resolve()

for host, ip in resolved.items():
    if ip is None:
        print "%s could not be resolved." % host
    else:
        print "%s resolved to %s" % (host, ip)

print "Filling in A records and addresses for domains not in the a table"
for ns in nsList:
    (idnum, zone, ttl, host, nsdname) = ns
    conn.commit()
    cur.execute("select * from public.a where host='{0}';".format(nsdname))
    aList = cur.fetchall()
    if len(