From f8b2fb7ff853fca70384d9de620619cfa642c2ce Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 2 Oct 2017 16:56:31 -0600 Subject: [PATCH] fix false positive on 0x20 failure --- bin/dig.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/dig.js b/bin/dig.js index 3113955..925dbc5 100755 --- a/bin/dig.js +++ b/bin/dig.js @@ -186,6 +186,7 @@ cli.main(function (args, cli) { cli.onMessage = function (nb) { var packet = dnsjs.DNSPacket.parse(nb.buffer.slice(nb.byteOffset, nb.byteOffset + nb.byteLength)); + var fail0x20; if (packet.id !== query.id) { console.log('ignoring packet for ', packet.question[0].name); @@ -197,6 +198,13 @@ cli.main(function (args, cli) { console.log(packet); } + packet.question.forEach(function (q) { + // if (-1 === q.name.indexOf(cli.casedQuery)) + if (q.name !== cli.casedQuery) { + fail0x20 = q.name; + } + }); + if (!cli.norecase && !cli.recase) { [ 'question', 'answer', 'authority', 'additional' ].forEach(function (group) { (packet[group]||[]).forEach(function (a) { @@ -225,14 +233,12 @@ cli.main(function (args, cli) { }); } - packet.question.forEach(function (q) { - // if (-1 === q.name.indexOf(cli.casedQuery)) - if (q.name !== cli.casedQuery) { - console.warn(""); - console.warn(";; Warning: DNS 0x20 security not implemented (or packet spoofed). Queried '" + cli.casedQuery + "' but got response for '" + q.name + "'."); - console.warn(""); - } - }); + if (fail0x20) { + console.warn(""); + console.warn(";; Warning: DNS 0x20 security not implemented (or packet spoofed). Queried '" + cli.casedQuery + "' but got response for '" + fail0x20 + "'."); + console.warn(""); + } + console.log(';; Got answer:'); dig.logQuestion(packet);