This tool can, under some conditions, calculate the exact time of a dns query made by someone, using TTL information cached on his ISP's nameservers.
397ca55e70fd272383102f3bb1e3eef0aecaffde8efee6c48e40cffcb5463c13
#!/usr/bin/python
# -*- coding: ISO-8859-15 -*
# TTLeak v0.1 - GPL License - Copyright (C) 2004 by nono2357
# (published in Hackademy Manuel #12, dec-jan 2005)
import re, string, datetime, time, sys, DNS # pydns library
l_dns_fai = {
'free' : ['212.27.32.5','212.27.32.6','212.27.32.176','212.27.39.134','212.27.39.135'],
'wanadoo' : ['193.252.19.10','193.252.19.11','80.12.255.23','80.12.255.152'],
'noos' : ['212.198.2.51', '212.198.0.91'],
'aol' : ['DNS-01.NS.AOL.COM','DNS-02.NS.AOL.COM','DNS-06.NS.AOL.COM','DNS-07.NS.AOL.COM']
}
DNS.ParseResolvConf()
def Error(mesg):
print "ERROR:", mesg
sys.exit(1)
class HostSearch:
def __init__(self, host, zone):
# hostname (no IP)
self.host = host
self.ldns = l_dns_fai[zone]
print "Recherche de %s dans la zone '%s'..." % (host,zone)
def getAuthorityServers(self, domain):
r = DNS.Request(domain,qtype='SOA').req()
if r.header['status'] != 'NOERROR':
Error("Erreur de réponse DNS")
primary,email,serial,refresh,retry,expire,minimum = r.answers[0]['data']
return primary
def getTTLs(self):
lr = []
for dns in self.ldns:
print "Interrogation de %s..." % dns
r = DNS.Request(name=self.host, server=dns, qtype='A')
a = r.req()
for reponse in a.answers:
lr.append((dns,int(reponse['ttl']),int(time.time())))
return lr
def getOriginalTTL(self):
domain = string.join(self.host.split('.')[-2:],".")
aserver = self.getAuthorityServers(domain)
a = DNS.Request(name=self.host, server=aserver, qtype='A').req()
return int(a.answers[0]['ttl'])
def showResults(self):
lr, ot = self.getTTLs(), self.getOriginalTTL()
print "Requêtes dans les dernières %d secondes :" % ot
print "DNS","\t\t","Dernière requête disponible"
print '-'*43
for r in lr:
if r[1]!=ot:
print r[0],"\t",datetime.datetime.fromtimestamp(r[2]-ot+r[1])
if len(sys.argv) != 3:
Error("\nUsage: %s FAI hostname" % sys.argv[0])
else:
HostSearch(sys.argv[2],sys.argv[1]).showResults()