开发者

webapp in python

I have got a very开发者_高级运维 simple idea in mind that i want to try out. Say i have a browser, chrome for instance, and i want to search for the ip of the domain name, say www.google.com. I use windows 7 and i have set the dns lookup properties to manual and have given the address 127.0.0.1 where my server (written in Python is running). I started my server and i could see the dns query but it was very weird as in it is showing faces like this:

WAITING FOR CONNECTION.........

.........recieved from :  ('127.0.0.1', 59339)

╟╝☺  ☺      ♥www♠google♥com  ☺ ☺

The waiting for connection and the received from is from my server. How do i get a human readable dns query?

This is my server code(quiet elementary but still):

Here is the code:

from time import sleep 
import socket 
host='' 
port=53 
addr_list=(host,port) 
buf_siz=1024 
udp=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) 
udp.bind(addr_list) 
while True: 
    print 'WAITING FOR CONNECTION.........' 
    data,addr = udp.recvfrom(buf_siz) print '.........recieved from : ',addr 
    sleep(3) 
    print data


DNS uses a compression algorithm and uses [length]string to represent parts of the domain name (as far as I remember). e.g. [3]www[6]google[3]com.

Have a look at the DNS RFCs, e.g. http://www.zoneedit.com/doc/rfc/rfc1035.txt

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜