blechschmidt / massdns

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

Invalid JSON output produced (but, grabage-in / garbage-out) #60

Closed mzpqnxow closed 4 years ago

mzpqnxow commented 4 years ago

Hi @blechschmidt

I was recently performing some testing and didn't realize that my input list had some illegal DNS names in it. Specifically, one of the domains to be queried contained a double quote.

As expected, there was no A record for this name. However, the SOA record was logged and the double quote was not escaped inside the JSON line, causes JSON parsers to choke.

I realize that this was an illegal query, but there should probably be a better way of handling this, either at input time or output time

  1. Reject the name before even querying it and throw a warning to stderr
  2. Escape the name in the JSON output

If you prefer one of these (or none) I am happy to provide a simple PR, please let me know! Thanks

blechschmidt commented 4 years ago

Hi,

I would prefer massdns to escape the name in the JSON output properly in order to allow illegal queries and responses. This could come in handy for research purposes. At the moment, other types of illegal payloads are not encoded properly either (see https://github.com/blechschmidt/massdns/issues/43). If you want to provide a PR, I am happy to merge it.

blechschmidt commented 4 years ago

I overhauled the NDJSON output. The issue should have been fixed by https://github.com/blechschmidt/massdns/commit/6b74007bae6ebeb3025b288dd091120a0f2d109a.

mzpqnxow commented 4 years ago

Thanks! I will give it a shot on one of my datasets, I believe the other issue was with a \ which by the looks of the commit I believe is handled properly now (by escaping it)

Will let you know if any issues persist