I'm using Python2 to implement a server which provides NAPTR DNS answers using dnslib.
The forged answers are in the following format:
0.0.0.0.0.0.0.e164.arpa. 60 IN NAPTR 20 20 "u" "SIP+E2U" "!^.*$!SIP:[email protected]!" .
I use dig in order to perform the queries by using the following syntax:
dig NAPTR 0.0.0.0.0.0.0.e164.arpa @<server_ip>
The issue is that whenever the regexp part of the NAPTR record contains a circumflex (^), dig flags the retrieved packet as malformed:
;; Got bad packet: syntax error
If I remove the circumflex from the string, the query answer gets retrieved properly. So it seems that the circumflex is being somehow misintepreted. I tried to specify regexp.encode('utf-8'), but that didn't solve the issue. Any ideas?