示例#1
0
def dotransform(request, response):
    ip = request.value
    ans = nslookup("www.google.ca", nameserver=ip)
    if ans is not None:
        for site in config['dnscachesnoop/wordlist']:
            debug('Resolving %s' % site)
            ans = nslookup(site, nameserver=ip, rd=0)
            if not ans[DNS].ancount:
                ans = nslookup('www.%s' % site, nameserver=ip, rd=0)
            if ans[DNS].ancount:
                e = DNSName(site)
                t = Table(['Name', 'Query Class', 'Query Type', 'Data', 'TTL'], 'Cached Answers')
                for i in range(0, ans[DNS].ancount):
                    rr = ans[DNS].an[i]
                    t.addrow([
                            rr.rrname.rstrip('.'),
                            rr.sprintf('%rclass%'),
                            rr.sprintf('%type%'),
                            rr.rdata.rstrip('.'),
                            rr.sprintf('%ttl%')
                        ])
                e += Label('Cached Answers', t, type='text/html')
                response += e
    else:
        response += UIMessage('DNS server did not respond to initial DNS request.')
    return response
示例#2
0
def dotransform(request, response):
    ip = request.value
    ans = nslookup("www.google.ca", nameserver=ip)
    if ans is not None:
        for site in config['dnscachesnoop/wordlist']:
            debug('Resolving %s' % site)
            ans = nslookup(site, nameserver=ip, rd=0)
            if not ans[DNS].ancount:
                ans = nslookup('www.%s' % site, nameserver=ip, rd=0)
            if ans[DNS].ancount:
                e = DNSName(site)
                t = Table(['Name', 'Query Class', 'Query Type', 'Data', 'TTL'],
                          'Cached Answers')
                for i in range(0, ans[DNS].ancount):
                    rr = ans[DNS].an[i]
                    t.addrow([
                        rr.rrname.rstrip('.'),
                        rr.sprintf('%rclass%'),
                        rr.sprintf('%type%'),
                        rr.rdata.rstrip('.'),
                        rr.sprintf('%ttl%')
                    ])
                e += Label('Cached Answers', t, type='text/html')
                response += e
    else:
        response += UIMessage(
            'DNS server did not respond to initial DNS request.')
    return response
示例#3
0
def dotransform(request, response):
    ans = nslookup(request.value, 'AXFR')
    if not isinstance(ans, list) and not ans[DNS].ancount:
        ans = nslookup(request.value, 'IXFR')
    if isinstance(ans, list):
        for a in ans:
            addrecord(a.an, response)
    elif ans[DNS].ancount:
        for i in range(0, ans[DNS].ancount):
            addrecord(ans[DNS].an[i], response)
    else:
        response += UIMessage('AXFR/IXFR was unsuccessful.')
    return response
示例#4
0
def dotransform(request, response):
    ans = nslookup(request.value, 'AXFR')
    if not isinstance(ans, list) and not ans[DNS].ancount:
        ans = nslookup(request.value, 'IXFR')
    if isinstance(ans, list):
        for a in ans:
            addrecord(a.an, response)
    elif ans[DNS].ancount:
        for i in range(0, ans[DNS].ancount):
            addrecord(ans[DNS].an[i], response)
    else:
        response += UIMessage('AXFR/IXFR was unsuccessful.')
    return response
示例#5
0
def dotransform(request, response):
    ans = nslookup(request.value)
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 1:
                response += IPv4Address(ans[DNS].an[i].rdata)
    return response
示例#6
0
def dotransform(request, response):
    ans = nslookup(request.value, 'NS')
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 2:
                response += NSRecord(ans[DNS].an[i].rdata.rstrip('.'))
    return response
示例#7
0
def dotransform(request, response):
    ans = nslookup(request.value)
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 1:
                response += IPv4Address(ans[DNS].an[i].rdata)
    return response
示例#8
0
def dotransform(request, response):
    ans = nslookup(request.value, 'NS')
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 2:
                response += NSRecord(ans[DNS].an[i].rdata.rstrip('.'))
    return response
示例#9
0
def dotransform(request, response):
    ans = nslookup(IPAddress(request.value).arpa, 'PTR')
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 12:
                e = DNSName(ans[DNS].an[i].rdata.rstrip('.'))
                response += e
    return response
示例#10
0
def dotransform(request, response):
    ans = nslookup(IPAddress(request.value).arpa, "PTR")
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 12:
                e = DNSName(ans[DNS].an[i].rdata.rstrip("."))
                response += e
    return response
示例#11
0
def dotransform(request, response):
    ans = nslookup(request.value, 'MX')
    if ans is not None and DNS in ans:
        for i in range(0, ans[DNS].ancount):
            if ans[DNS].an[i].type == 15:
                e = MXRecord(ans[DNS].an[i].rdata.rstrip('.'))
                e += Field('mxrecord.priority', ans[DNS].an[i].mxpriority)
                response += e
    return response
示例#12
0
 def run(self):
     while True:
         subdomain = q.get()
         if subdomain is None:
             break
         ans = nslookup('%s.%s' % (subdomain, self.domain))
         if ans is not None and DNS in ans and ans[DNS].ancount:
             qret.put(ans[DNS])
         sleep(1/self.lookup_rate)
     qret.put(None)
示例#13
0
 def run(self):
     while True:
         subdomain = q.get()
         if subdomain is None:
             break
         ans = nslookup('%s.%s' % (subdomain, self.domain))
         if ans is not None and DNS in ans and ans[DNS].ancount:
             qret.put(ans[DNS])
         sleep(1 / self.lookup_rate)
     qret.put(None)
示例#14
0
def dotransform(request, response):

    domain = request.value

    global q
    global qret
    q = Queue()
    qret = Queue()

    ans = nslookup('%s.%s' % (str(uuid4()), domain))
    wcip = getips(ans)
    foundsds = {}
    if wcip:
        response += UIMessage(
            'Warning: wildcard domain is defined... results may not be accurate'
        )

    ncount = 0
    nthreads = config['dnsdiscovery/numthreads']
    subdomains = config['dnsdiscovery/wordlist']

    threads = []
    for i in range(0, nthreads):
        t = DNSResolver(request.value)
        t.start()
        threads.append(t)

    for sd in subdomains:
        q.put(sd)

    for i in range(0, nthreads):
        q.put(None)

    while True:
        r = qret.get()
        if r is None:
            ncount += 1
            if ncount == nthreads:
                break
        else:
            names = getnames(domain, r)
            ips = getips(r)
            if wcip and wcip.issuperset(ips):
                continue
            for name in names:
                if name in foundsds:
                    continue
                else:
                    foundsds[name] = 1
                    response += DNSName(name)

    for t in threads:
        t.join()
    return response
示例#15
0
def dotransform(request, response):

    domain = request.value

    global q
    global qret
    q = Queue()
    qret = Queue()

    ans = nslookup('%s.%s' % (str(uuid4()), domain))
    wcip = getips(ans)
    foundsds = {}
    if wcip:
        response += UIMessage('Warning: wildcard domain is defined... results may not be accurate')

    ncount = 0
    nthreads = config['dnsdiscovery/numthreads']
    subdomains = config['dnsdiscovery/wordlist']

    threads = []
    for i in range(0, nthreads):
        t = DNSResolver(request.value)
        t.start()
        threads.append(t)

    for sd in subdomains:
        q.put(sd)

    for i in range(0, nthreads):
        q.put(None)

    while True:
        r = qret.get()
        if r is None:
            ncount += 1
            if ncount == nthreads:
                break
        else:
            names = getnames(domain, r)
            ips = getips(r)
            if wcip and wcip.issuperset(ips):
                continue
            for name in names:
                if name in foundsds:
                    continue
                else:
                    foundsds[name] = 1
                    response += DNSName(name)

    for t in threads:
        t.join()
    return response
示例#16
0
def dotransform(request, response):

    for r in config['dnscachelookup/resolvers']:
        debug('fetching from %s' % r)
        ans = nslookup(request.value, 255, r, rd=0)
        if ans is None:
            continue
        elif isinstance(ans, list):
            for a in ans:
                addrecord(a.an, response)
        elif ans[DNS].ancount:
            for i in range(0, ans[DNS].ancount):
                addrecord(ans[DNS].an[i], response)
    return response