blechschmidt / massdns

A high-performance DNS stub resolver for bulk lookups and reconnaissance (subdomain enumeration)
GNU General Public License v3.0
3.1k stars 459 forks source link

JSON output contains invalid escape sequences #43

Closed honoki closed 4 years ago

honoki commented 5 years ago

When running massdns in bruteforce mode, the output in JSON will sometimes contain invalid escape sequences (e.g. when using the wordlist on https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056):

~/massdns/scripts/subbrute.py ~/wordlists/all.txt google.com | massdns -r ~/resolvers.txt -t A -o J | grep '\\'

Output:

{"query_name":"\x03\x00\x05\x08\x02\x00\x05\x0d.google.com.","query_type":"A","resp_name":"google.com.","resp_type":"SOA","data":"ns1.google.com. dns-admin.google.com. 241673399 900 900 1800 60"}

This is considered invalid JSON:

echo '{"query_name":"\x03\x00\x05\x08\x02\x00\x05\x0d.google.com.","query_type":"A","resp_name":"google.com.","resp_type":"SOA","data":"ns1.google.com. dns-admin.google.com. 241673399 900 900 1800 60"}' | jq '.'
parse error: Invalid escape at line 1, column 60

A solution could be to encoding as Unicode instead, i.e.


{"query_name":"\u0003\u0000\u0005\u0008\u0002\u0000\u0005\u000d.google.com.","query_type":"A","resp_name":"google.com.","resp_type":"SOA","data":"ns1.google.com. dns-admin.google.com. 241673399 900 900 1800 60"}
blechschmidt commented 4 years ago

This should have been fixed by https://github.com/blechschmidt/massdns/commit/6b74007bae6ebeb3025b288dd091120a0f2d109a.