6 def __init__(self
, data
):
10 tipo
= (ord(data
[2]) >> 3) & 15
15 self
.dominio
+=data
[ini
+1:ini
+lon
+1]+'.'
19 def respuesta(self
, ip
):
22 packet
+=self
.data
[:2] + "\x81\x80"
23 packet
+=self
.data
[4:6] + self
.data
[4:6] + '\x00\x00\x00\x00'
24 packet
+=self
.data
[12:]
26 packet
+='\x00\x01\x00\x01\x00\x00\x00\x3c\x00\x04'
27 packet
+=str.join('',map(lambda x
: chr(int(x
)), ip
.split('.')))
30 if __name__
== '__main__':
32 print 'pyminifakeDNS:: dom.query. 60 IN A %s' % ip
34 udps
= socket
.socket(socket
.AF_INET
, socket
.SOCK_DGRAM
)
39 data
, addr
= udps
.recvfrom(1024)
41 udps
.sendto(p
.respuesta(ip
), addr
)
42 print 'Response: %s -> %s' % (p
.dominio
, ip
)
43 except KeyboardInterrupt:
44 print 'Finalizing ...'