From a4d4d55f3478e7af504586997c389f867c336ae1 Mon Sep 17 00:00:00 2001 From: Daplie Date: Fri, 13 Jan 2017 20:04:21 -0700 Subject: [PATCH] fixed how to --- howto.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/howto.md b/howto.md index 733cfa2..c13622e 100644 --- a/howto.md +++ b/howto.md @@ -9,6 +9,50 @@ npm init how to duplicate DNS crash: +``` +cd ~/dns_test +``` -How to print out hex and binary values of the message? +``` +node listen.js +``` +``` +dig @224.0.0.251 -p 5353 -t PTR _cloud._tcp.local +``` + +The output is then: + +``` +START DNS PACKET +/home/daplie/dns_test/node_modules/dns-js/lib/bufferconsumer.js:52 + throw new Error('Buffer overflow') + ^ + +Error: Buffer overflow + at BufferConsumer.slice (/home/daplie/dns_test/node_modules/dns-js/lib/bufferconsumer.js:52:13) + s at Function.DNSRecord.parse (/home/daplie/dns_test/node_modules/dns-js/lib/dnsrecord.js:237:46) + at /home/daplie/dns_test/node_modules/dns-js/lib/dnspacket.js:164:30 + at Array.forEach (native) + at Function.DNSPacket.parse (/home/daplie/dns_test/node_modules/dns-js/lib/dnspacket.js:159:17) + at /home/daplie/dns_test/cloud-respond.js:86:31 + at Array.forEach (native) + at /home/daplie/dns_test/cloud-respond.js:11:21 + at Array.forEach (native) + at Object.module.exports.respond (/home/daplie/dns_test/cloud-respond.js:10:11) + +``` + + + + +How to print out hex values of the DNS message? + +```javascript +socket.on('message', function (message, rinfo) { + console.log('Received %d bytes from %s:%d\n', + message.length, rinfo.address, rinfo.port); + //console.log(msg.toString('utf8')); + + console.log(message.toString('hex')); +``` \ No newline at end of file