Ask Your Question

How does a web browser parse the raw bytes of each part of a DNS name to a human readable form?

asked 2020-06-27 15:34:54 +0000

Junior gravatar image

My focus is to parse the structure of a DNS packet programmatically using python. Consider the snap where my browser send a large domain name through the pipe without even complaining.

image description

Let's take a close look at the byte string: b'\x03www99dksjfhkdfgh534534534dkfghkldfhglksdfhg435634634dkfghlkd\x03com\x00'

image description

I can programmatically write my codes in python with a logic like this image description

So my question is: How does a web browser parse the raw bytes of each part of a DNS name to a human readable form? Any form of advice/help is welcomed.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-27 17:25:39 +0000

Chuckc gravatar image

(Looks like the red text is for a different query - "www" vs "www2" in the screen shot)
When all else fails, read the instructions: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION

3.1. Name space definitions

Domain names in messages are expressed in terms of a sequence of labels.
Each label is represented as a one octet length field followed by that
number of octets.  Since every domain name ends with the null label of
the root, a domain name is terminated by a length byte of zero.  The
high order two bits of every length octet must be zero, and the
remaining six bits of the length field limit the label to 63 octets or

Wireshark displays [Label Count: 3] for www2, <the long text>, com

The red text should start with \x04www2 to match the screen shot.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-06-27 15:34:54 +0000

Seen: 35 times

Last updated: Jun 27