File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,11 +46,15 @@ def response(self, resolution):
4646 retVal = ""
4747
4848 if self ._query :
49- retVal += self ._raw [:2 ] + "\x81 \x80 "
49+ retVal += self ._raw [:2 ] # Transaction ID
50+ retVal += "\x84 \x00 " # Flags (Standard query response, No error)
5051 retVal += self ._raw [4 :6 ] + self ._raw [4 :6 ] + "\x00 \x00 \x00 \x00 " # Questions and Answers Counts
51- retVal += self ._raw [12 :] # Original Domain Name Question
52+ retVal += self ._raw [12 :( 12 + self . _raw [ 12 :]. find ( " \x00 " ) + 5 )] # Original Domain Name Query
5253 retVal += "\xc0 \x0c " # Pointer to domain name
53- retVal += "\x00 \x01 \x00 \x01 \x00 \x00 \x00 \x3c \x00 \x04 " # Response type, ttl and resource data length -> 4 bytes
54+ retVal += "\x00 \x01 " # Type A
55+ retVal += "\x00 \x01 " # Class IN
56+ retVal += "\x00 \x00 \x01 \x2c " # TTL
57+ retVal += "\x00 \x04 " # Data length
5458 retVal += "" .join (chr (int (_ )) for _ in resolution .split ('.' )) # 4 bytes of IP
5559
5660 return retVal
You can’t perform that action at this time.
0 commit comments