From 571e4959cfff207e8192587071beb099e169eca8 Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 4 Mar 2017 17:10:25 -0700 Subject: [PATCH 01/15] soa packer and parser --- packer/type.soa.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packer/type.soa.js diff --git a/packer/type.soa.js b/packer/type.soa.js new file mode 100644 index 0000000..7099853 --- /dev/null +++ b/packer/type.soa.js @@ -0,0 +1,10 @@ +(function (exports) { +'use strict'; + + +exports.DNS_PACKER_TYPE_SOA = function (ab, dv, total, record) { + + return total; +}; + +}('undefined' !== typeof window ? window : exports)); From 0ba8871c3a9f847c1a9353c93b59283b7bf74efc Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 4 Mar 2017 17:11:33 -0700 Subject: [PATCH 02/15] parser soa type --- parser/type.soa.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/parser/type.soa.js b/parser/type.soa.js index b468e8a..762a67a 100644 --- a/parser/type.soa.js +++ b/parser/type.soa.js @@ -9,13 +9,28 @@ // Serial Number Unsigned 32-bit integer // Refresh Interval Unsigned 32-bit integer // Retry Interval Unsigned 32-bit integer -// Retry Interval Unsigned 32-bit integer // Expiration Limit Unsigned 32-bit integer // Minimum TTL Unsigned 32-bit integer exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) { + var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength); + var dv = new DataView(rdataAb) + // Serial Number + record.sn = dv.getUint32(dv.byteLength - 20); + // Refresh Interval + record.ref = dv.getUint32(dv.byteLength - 16); + // Retry Interval + record.ret = dv.getUint32(dv.byteLength - 12); + // Expiration Limit + record.ex = dv.getUint32(dv.byteLength - 8); + // Minimum TTL + record.nx = dv.getUint32(dv.byteLength - 4); + + + return record; + }; }('undefined' !== typeof window ? window : exports)); From 8129863dc61f9ff77b0bc4bd63f0bd831ba0a52f Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 4 Mar 2017 17:20:33 -0700 Subject: [PATCH 03/15] captured soa record type for sample data --- test/soa/soa0.google.com.soa.0.bin | Bin 0 -> 210 bytes test/soa/soa0.google.com.soa.0.json | 203 ++++++++++++++++++++++++ test/soa/soa0.google.com.soa.query.bin | Bin 0 -> 28 bytes test/soa/soa0.google.com.soa.query.json | 19 +++ 4 files changed, 222 insertions(+) create mode 100644 test/soa/soa0.google.com.soa.0.bin create mode 100644 test/soa/soa0.google.com.soa.0.json create mode 100644 test/soa/soa0.google.com.soa.query.bin create mode 100644 test/soa/soa0.google.com.soa.query.json diff --git a/test/soa/soa0.google.com.soa.0.bin b/test/soa/soa0.google.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..03f7864735e8ad01e56a6354550b06a69ff04754 GIT binary patch literal 210 zcmazoX>4F%1VR=D7Pj>K{Pdhu=H&cb1_m|;#sfScl7WH2hCz)vuh`@O4`)hVv2J2Y zZf4#A9*!q_ix?P~TOgR71Edb9g9)VL;dcf$pbn!0JV+u;2Q-j)AbCR+d60-PP^1d% n9)^d%7+7w+SKvAj1?9g7@s+p^^g#HJSV4Rht^*p#>eaXa3%xX< literal 0 HcmV?d00001 diff --git a/test/soa/soa0.google.com.soa.0.json b/test/soa/soa0.google.com.soa.0.json new file mode 100644 index 0000000..4ba4b2f --- /dev/null +++ b/test/soa/soa0.google.com.soa.0.json @@ -0,0 +1,203 @@ +{ + "header": { + "id": 23924, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 4, + "arcount": 4, + "question": [ + { + "name": "google.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "google", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "google.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 50, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 40, + "rdlength": 38, + "ttl": 60, + "sn": 149208434, + "ref": 900, + "ret": 900, + "ex": 1800, + "nx": 60 + } + ], + "authority": [ + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 90, + "rdlength": 6, + "ttl": 57847, + "data": "ns2.google.com" + }, + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 14, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 108, + "rdlength": 2, + "ttl": 57847, + "data": "ns4.google.com" + }, + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 122, + "rdlength": 6, + "ttl": 57847, + "data": "ns1.google.com" + }, + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 140, + "rdlength": 6, + "ttl": 57847, + "data": "ns3.google.com" + } + ], + "edns_options": [], + "additional": [ + { + "name": "ns1.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns1", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 158, + "rdlength": 4, + "ttl": 57850, + "address": "216.239.32.10" + }, + { + "name": "ns2.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns2", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 174, + "rdlength": 4, + "ttl": 57839, + "address": "216.239.34.10" + }, + { + "name": "ns3.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns3", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 190, + "rdlength": 4, + "ttl": 57861, + "address": "216.239.36.10" + }, + { + "name": "ns4.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns4", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 206, + "rdlength": 4, + "ttl": 57850, + "address": "216.239.38.10" + } + ], + "byteLength": 210 +} diff --git a/test/soa/soa0.google.com.soa.query.bin b/test/soa/soa0.google.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..d33b6611fd4e91d6ee414df7a16c628127a0a52b GIT binary patch literal 28 dcmazoVPs$cA`oCp&(BZKNo7vX&joTA7y&;T1fT!_ literal 0 HcmV?d00001 diff --git a/test/soa/soa0.google.com.soa.query.json b/test/soa/soa0.google.com.soa.query.json new file mode 100644 index 0000000..1122b4d --- /dev/null +++ b/test/soa/soa0.google.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 23924, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "google.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file From 4df82c456ed8d0433f4f4fb2d1049c95de753eff Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 8 Mar 2017 17:51:41 -0700 Subject: [PATCH 04/15] added NS record packer --- packer/type.ns.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packer/type.ns.js diff --git a/packer/type.ns.js b/packer/type.ns.js new file mode 100644 index 0000000..6c68dcf --- /dev/null +++ b/packer/type.ns.js @@ -0,0 +1,39 @@ +(function (exports) { +'use strict'; + + +// NS name for the supplied domain. May be label, pointer or any combination + +exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) { + if(!record.data){ + throw new Error("no data on NS record"); + } + + + var nsLen = 0; + var rdLenIndex = total; + total +=2; + + // RDATA + // a sequence of labels + + record.data.split('.').forEach(function(label) { + nsLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; + + label.split('').forEach(function (ch){ + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; + }); + }); + + // RDLENGTH + dv.setUint16(rdLenIndex, record.data.length + 1, false); + + + return total; +}; + +}('undefined' !== typeof window ? window : exports)); From 43360a75da933a9a2e105c10a128b781945316a2 Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 8 Mar 2017 17:53:15 -0700 Subject: [PATCH 05/15] added NS record packer. --- packer/type.ns.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packer/type.ns.js diff --git a/packer/type.ns.js b/packer/type.ns.js new file mode 100644 index 0000000..6c68dcf --- /dev/null +++ b/packer/type.ns.js @@ -0,0 +1,39 @@ +(function (exports) { +'use strict'; + + +// NS name for the supplied domain. May be label, pointer or any combination + +exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) { + if(!record.data){ + throw new Error("no data on NS record"); + } + + + var nsLen = 0; + var rdLenIndex = total; + total +=2; + + // RDATA + // a sequence of labels + + record.data.split('.').forEach(function(label) { + nsLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; + + label.split('').forEach(function (ch){ + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; + }); + }); + + // RDLENGTH + dv.setUint16(rdLenIndex, record.data.length + 1, false); + + + return total; +}; + +}('undefined' !== typeof window ? window : exports)); From 05beaa480b3c4121afc8a0bef15a70c40d8718be Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 8 Mar 2017 18:59:33 -0700 Subject: [PATCH 06/15] added PTR record packer --- packer/type.ns.js | 1 - packer/type.ptr.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 packer/type.ptr.js diff --git a/packer/type.ns.js b/packer/type.ns.js index 6c68dcf..20a0ee1 100644 --- a/packer/type.ns.js +++ b/packer/type.ns.js @@ -16,7 +16,6 @@ exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) { // RDATA // a sequence of labels - record.data.split('.').forEach(function(label) { nsLen += 1 + label.length; diff --git a/packer/type.ptr.js b/packer/type.ptr.js new file mode 100644 index 0000000..51db54c --- /dev/null +++ b/packer/type.ptr.js @@ -0,0 +1,37 @@ +(function (exports) { +'use strict'; + +// The host name that represents the supplied UP address +// May be a label, pointer or any combination + +exports.DNS_PACKER_TYPE_PTR = function (ab, dv, total, record) { + if (!record.data) { + throw new Error("no data for PTR record"); + } + + var ptrLen = 0; + var rdLenIndex = total; + total += 2; + + // RDATA + // a sequence of labels + record.data.split('.').forEach(function (label){ + console.log("the labels are: " + label); + ptrLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; + + label.split('').forEach(function (ch){ + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; + }); + }); + + // RDLENGTH + dv.setUint16(rdLenIndex, record.data.length + 1, false); + + return total; +}; + +}('undefined' !== typeof window ? window : exports)); From 792bea258d394dc90f2940899a3eea2253f1636c Mon Sep 17 00:00:00 2001 From: Daplie Date: Thu, 9 Mar 2017 15:12:26 -0700 Subject: [PATCH 07/15] finished SRV record data packer. Still need to test exhaustively. Left in debugging code. --- packer/type.srv.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 packer/type.srv.js diff --git a/packer/type.srv.js b/packer/type.srv.js new file mode 100644 index 0000000..63b8440 --- /dev/null +++ b/packer/type.srv.js @@ -0,0 +1,73 @@ +(function (exports) { +'use strict'; + +// SRV RDATA contains: +// Priority: The relative priority of this service. 16-bit (range 0-65535) +// Weight: Used when more than one serivice has the same priority. 16-bit +// (range 0-65535) +// Port: Port number assigned to the symbolic service. 16-bit (range 0-65535) +// Target: The name of the host that will provide service. + +exports.DNS_PACKER_TYPE_SRV = function (ab, dv, total, record) { + + // maybe these should be changed to 'hasOwnProperty' for all of these + // TODO: Check that number is in range 1-64k + if (!record.priority){ + throw new Error("no priority for SRV record"); + } + if (!record.hasOwnProperty('weight')){ + throw new Error("no weight for SRV record"); + } + if (!record.port){ + throw new Error("no port for SRV record"); + } + if (!record.target) { + throw new Error("no target for SRV record"); + } + + // console.log("record length, priority, weight, port, then target"); + // console.log("record priority is: " + record.priority); + // console.log("record weight is: " + record.weight); + // console.log("record port is: " + record.port); + // console.log("record target is: " + record.target); + // console.log("total length currently is: " + total); + + + var srvLen = 6; // 16-bit priority, weight and port = 6 Bytes + var rdLenIndex = total; + + total+=2; + + dv.setUint16(total, parseInt(record.priority, 10), false); + total+=2; + + dv.setUint16(total,parseInt(record.weight, 10), false); + total+=2; + + dv.setUint16(total, parseInt(record.port, 10), false); + total+=2; + + record.target.split('.').forEach(function (label){ + srvLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; + + label.split('').forEach(function (ch) { + dv.setUint8(total, ch.charCodeAt(0), false); + total +=1; + }); + }); + + + // RDLENGTH + + dv.setUint16(rdLenIndex, srvLen, false); + + + + + return total; +}; + +}('undefined' !== typeof window ? window : exports)); From 16dd91ace03e60567c54de22996233fb09411249 Mon Sep 17 00:00:00 2001 From: Daplie Date: Thu, 9 Mar 2017 19:22:45 -0700 Subject: [PATCH 08/15] captured some more SOA records. --- test/soa_test/test.america.com.soa.0.bin | Bin 0 -> 97 bytes test/soa_test/test.america.com.soa.0.json | 61 +++++++++++++++++ test/soa_test/test.america.com.soa.query.bin | Bin 0 -> 29 bytes test/soa_test/test.america.com.soa.query.json | 19 ++++++ test/soa_test/test.daplie.com.soa.0.bin | Bin 0 -> 95 bytes test/soa_test/test.daplie.com.soa.0.json | 61 +++++++++++++++++ test/soa_test/test.daplie.com.soa.query.bin | Bin 0 -> 28 bytes test/soa_test/test.daplie.com.soa.query.json | 19 ++++++ .../test.doesntexisit.google.com.soa.0.bin | Bin 0 -> 91 bytes .../test.doesntexisit.google.com.soa.0.json | 62 ++++++++++++++++++ ...test.doesntexisit.google.com.soa.query.bin | Bin 0 -> 41 bytes ...est.doesntexisit.google.com.soa.query.json | 19 ++++++ test/soa_test/test.facebook.com.soa.0.bin | Bin 0 -> 75 bytes test/soa_test/test.facebook.com.soa.0.json | 61 +++++++++++++++++ test/soa_test/test.facebook.com.soa.query.bin | Bin 0 -> 30 bytes .../soa_test/test.facebook.com.soa.query.json | 19 ++++++ test/soa_test/test.gmail.com.soa.0.bin | Bin 0 -> 84 bytes test/soa_test/test.gmail.com.soa.0.json | 61 +++++++++++++++++ test/soa_test/test.gmail.com.soa.query.bin | Bin 0 -> 27 bytes test/soa_test/test.gmail.com.soa.query.json | 19 ++++++ test/soa_test/test.google.com.soa.0.bin | Bin 0 -> 78 bytes test/soa_test/test.google.com.soa.0.json | 61 +++++++++++++++++ test/soa_test/test.google.com.soa.query.bin | Bin 0 -> 28 bytes test/soa_test/test.google.com.soa.query.json | 19 ++++++ test/soa_test/test.khanacademy.com.soa.0.bin | Bin 0 -> 117 bytes test/soa_test/test.khanacademy.com.soa.0.json | 61 +++++++++++++++++ .../test.khanacademy.com.soa.query.bin | Bin 0 -> 33 bytes .../test.khanacademy.com.soa.query.json | 19 ++++++ test/soa_test/test.pinterest.com.soa.0.bin | Bin 0 -> 75 bytes test/soa_test/test.pinterest.com.soa.0.json | 61 +++++++++++++++++ .../soa_test/test.pinterest.com.soa.query.bin | Bin 0 -> 31 bytes .../test.pinterest.com.soa.query.json | 19 ++++++ test/soa_test/test.tinder.com.soa.0.bin | Bin 0 -> 110 bytes test/soa_test/test.tinder.com.soa.0.json | 61 +++++++++++++++++ test/soa_test/test.tinder.com.soa.query.bin | Bin 0 -> 28 bytes test/soa_test/test.tinder.com.soa.query.json | 19 ++++++ 36 files changed, 721 insertions(+) create mode 100644 test/soa_test/test.america.com.soa.0.bin create mode 100644 test/soa_test/test.america.com.soa.0.json create mode 100644 test/soa_test/test.america.com.soa.query.bin create mode 100644 test/soa_test/test.america.com.soa.query.json create mode 100644 test/soa_test/test.daplie.com.soa.0.bin create mode 100644 test/soa_test/test.daplie.com.soa.0.json create mode 100644 test/soa_test/test.daplie.com.soa.query.bin create mode 100644 test/soa_test/test.daplie.com.soa.query.json create mode 100644 test/soa_test/test.doesntexisit.google.com.soa.0.bin create mode 100644 test/soa_test/test.doesntexisit.google.com.soa.0.json create mode 100644 test/soa_test/test.doesntexisit.google.com.soa.query.bin create mode 100644 test/soa_test/test.doesntexisit.google.com.soa.query.json create mode 100644 test/soa_test/test.facebook.com.soa.0.bin create mode 100644 test/soa_test/test.facebook.com.soa.0.json create mode 100644 test/soa_test/test.facebook.com.soa.query.bin create mode 100644 test/soa_test/test.facebook.com.soa.query.json create mode 100644 test/soa_test/test.gmail.com.soa.0.bin create mode 100644 test/soa_test/test.gmail.com.soa.0.json create mode 100644 test/soa_test/test.gmail.com.soa.query.bin create mode 100644 test/soa_test/test.gmail.com.soa.query.json create mode 100644 test/soa_test/test.google.com.soa.0.bin create mode 100644 test/soa_test/test.google.com.soa.0.json create mode 100644 test/soa_test/test.google.com.soa.query.bin create mode 100644 test/soa_test/test.google.com.soa.query.json create mode 100644 test/soa_test/test.khanacademy.com.soa.0.bin create mode 100644 test/soa_test/test.khanacademy.com.soa.0.json create mode 100644 test/soa_test/test.khanacademy.com.soa.query.bin create mode 100644 test/soa_test/test.khanacademy.com.soa.query.json create mode 100644 test/soa_test/test.pinterest.com.soa.0.bin create mode 100644 test/soa_test/test.pinterest.com.soa.0.json create mode 100644 test/soa_test/test.pinterest.com.soa.query.bin create mode 100644 test/soa_test/test.pinterest.com.soa.query.json create mode 100644 test/soa_test/test.tinder.com.soa.0.bin create mode 100644 test/soa_test/test.tinder.com.soa.0.json create mode 100644 test/soa_test/test.tinder.com.soa.query.bin create mode 100644 test/soa_test/test.tinder.com.soa.query.json diff --git a/test/soa_test/test.america.com.soa.0.bin b/test/soa_test/test.america.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..484d202358aa7e8cf1f90a10fd1f2fb1d908fed6 GIT binary patch literal 97 zcmaDmp|OF15eR{RJux@6C^I>cIXORks?P07zq%*;#9 s&nqd)&p9B%oRU|}ngtZAV9rY|VW`lmkzimbXkcKFQDES-0@8c}0Eej;YybcN literal 0 HcmV?d00001 diff --git a/test/soa_test/test.america.com.soa.0.json b/test/soa_test/test.america.com.soa.0.json new file mode 100644 index 0000000..16062f9 --- /dev/null +++ b/test/soa_test/test.america.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 60816, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "america.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 17, + "labels": [ + "america", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "america.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 68, + "labels": [ + "america", + "com" + ], + "cpcount": 1, + "rdstart": 41, + "rdlength": 56, + "ttl": 3599, + "sn": 2016050200, + "ref": 28800, + "ret": 7200, + "ex": 604800, + "nx": 3600 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 97 +} \ No newline at end of file diff --git a/test/soa_test/test.america.com.soa.query.bin b/test/soa_test/test.america.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..a4e7bfcae61ceb831afa860de9431b85fe838732 GIT binary patch literal 29 gcmaDmfsug$h(LfnF*mg+GdYntIX{X;r1Q>)$fx6f^06gy&YXATM literal 0 HcmV?d00001 diff --git a/test/soa_test/test.daplie.com.soa.0.json b/test/soa_test/test.daplie.com.soa.0.json new file mode 100644 index 0000000..910c526 --- /dev/null +++ b/test/soa_test/test.daplie.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 60281, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "daplie.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "daplie", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "daplie.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 67, + "labels": [ + "daplie", + "com" + ], + "cpcount": 1, + "rdstart": 40, + "rdlength": 55, + "ttl": 0, + "sn": 2017020100, + "ref": 10800, + "ret": 3600, + "ex": 1209600, + "nx": 1800 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 95 +} \ No newline at end of file diff --git a/test/soa_test/test.daplie.com.soa.query.bin b/test/soa_test/test.daplie.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..6ae4d8f0c7c6753424a83ee49a7d7c17e0753ebc GIT binary patch literal 28 ecmaD|$;iL}L?FPHl30+FnaZ4;p9|zLFaiKhUgBo*Q jvEczp&Xl}j-NcmK%)A4V9B)!{7#NsaAefy4sLloeFlQC5 literal 0 HcmV?d00001 diff --git a/test/soa_test/test.doesntexisit.google.com.soa.0.json b/test/soa_test/test.doesntexisit.google.com.soa.0.json new file mode 100644 index 0000000..4225714 --- /dev/null +++ b/test/soa_test/test.doesntexisit.google.com.soa.0.json @@ -0,0 +1,62 @@ +{ + "header": { + "id": 14537, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 3 + }, + "qdcount": 1, + "ancount": 0, + "nscount": 1, + "arcount": 0, + "question": [ + { + "name": "doesntexisit.google.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 29, + "labels": [ + "doesntexisit", + "google", + "com" + ], + "cpcount": 0 + } + ], + "answer": [], + "authority": [ + { + "name": "google.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 50, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 53, + "rdlength": 38, + "ttl": 59, + "sn": 149710188, + "ref": 900, + "ret": 900, + "ex": 1800, + "nx": 60 + } + ], + "edns_options": [], + "additional": [], + "byteLength": 91 +} \ No newline at end of file diff --git a/test/soa_test/test.doesntexisit.google.com.soa.query.bin b/test/soa_test/test.doesntexisit.google.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..06efffc9a6c4d41e1c9315dae624b6da99fc0a17 GIT binary patch literal 41 scmcCG$;iL}L?FPElAl_fSCU$hS)5tImY$!Vo|DR)oS)0Uz{bD`0L9D+{{R30 literal 0 HcmV?d00001 diff --git a/test/soa_test/test.doesntexisit.google.com.soa.query.json b/test/soa_test/test.doesntexisit.google.com.soa.query.json new file mode 100644 index 0000000..b1f950d --- /dev/null +++ b/test/soa_test/test.doesntexisit.google.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 14537, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "doesntexisit.google.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file diff --git a/test/soa_test/test.facebook.com.soa.0.bin b/test/soa_test/test.facebook.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..10a5b34de5e2f82f28b12ada7a95c32e9cca115f GIT binary patch literal 75 zcmd=6*Vw?o2!ueuk(QX8nv|cP&77Q{%fP_Kz<7WML;|JC859{4nevJc@Gz%<$cRIX UpBWfr6c`xTIT$#t8h}bF0BqC`z5oCK literal 0 HcmV?d00001 diff --git a/test/soa_test/test.facebook.com.soa.0.json b/test/soa_test/test.facebook.com.soa.0.json new file mode 100644 index 0000000..d6aeab2 --- /dev/null +++ b/test/soa_test/test.facebook.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 3582, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "facebook.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "facebook", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "facebook.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 45, + "labels": [ + "facebook", + "com" + ], + "cpcount": 1, + "rdstart": 42, + "rdlength": 33, + "ttl": 119, + "sn": 1489109491, + "ref": 7200, + "ret": 1800, + "ex": 604800, + "nx": 120 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 75 +} \ No newline at end of file diff --git a/test/soa_test/test.facebook.com.soa.query.bin b/test/soa_test/test.facebook.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..23e09c475c8996ccc9d8d63a998d530bbf5bf361 GIT binary patch literal 30 hcmd=6$H>3{L?FPCmYAHHl%Jo?oSdJ_z`(}92mn)71(^T< literal 0 HcmV?d00001 diff --git a/test/soa_test/test.facebook.com.soa.query.json b/test/soa_test/test.facebook.com.soa.query.json new file mode 100644 index 0000000..884a7b4 --- /dev/null +++ b/test/soa_test/test.facebook.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 3582, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "facebook.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file diff --git a/test/soa_test/test.gmail.com.soa.0.bin b/test/soa_test/test.gmail.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..dddc1f632f5e51241223c9f53a52a3cfbe9ed24e GIT binary patch literal 84 zcmbQbwXuPL5eR{RH9a>mGlw}jKbL`lje+q14~PVcTQle~=M@{VrRV3T=cFDG;!Mda c)=f;w&CENX&GGur6b1(776@kN04lcu05)h{RE`| literal 0 HcmV?d00001 diff --git a/test/soa_test/test.gmail.com.soa.query.json b/test/soa_test/test.gmail.com.soa.query.json new file mode 100644 index 0000000..c52d2f2 --- /dev/null +++ b/test/soa_test/test.gmail.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 38325, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "gmail.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file diff --git a/test/soa_test/test.google.com.soa.0.bin b/test/soa_test/test.google.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..e7e8d96fba55293e4242eb88960b3d33b59eb490 GIT binary patch literal 78 zcmb<7Y;0g)1VSKSOV7_w&q-xY&d&vM7#I)mfJmT(HG>*+Ua|239?q1!V%@})+|0ZK UJRGn8OkrSPZh>HS4xl<40F7x7!vFvP literal 0 HcmV?d00001 diff --git a/test/soa_test/test.google.com.soa.0.json b/test/soa_test/test.google.com.soa.0.json new file mode 100644 index 0000000..00ed0c9 --- /dev/null +++ b/test/soa_test/test.google.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 32561, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "google.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "google", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "google.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 50, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 40, + "rdlength": 38, + "ttl": 59, + "sn": 149683348, + "ref": 900, + "ret": 900, + "ex": 1800, + "nx": 60 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 78 +} \ No newline at end of file diff --git a/test/soa_test/test.google.com.soa.query.bin b/test/soa_test/test.google.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..3002d00b2608eb0894806048840ea5ae282f658c GIT binary patch literal 28 dcmb<7WMp6fA`oCp&(BZKNo7vX&joTA7y&!M1b+Yk literal 0 HcmV?d00001 diff --git a/test/soa_test/test.google.com.soa.query.json b/test/soa_test/test.google.com.soa.query.json new file mode 100644 index 0000000..0b77bf4 --- /dev/null +++ b/test/soa_test/test.google.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 32561, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "google.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file diff --git a/test/soa_test/test.khanacademy.com.soa.0.bin b/test/soa_test/test.khanacademy.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..15572858fac9a06dd5cbcde9b4b138e8fc30dd3b GIT binary patch literal 117 zcmb2S+StIr2!ueuot=@GmzbQGlA2q|oSdJ_z`(}9cz_2)GB7YVGkCD)73&%q7#njY zmKUc0*=9ye$@xsB*$jeEfsFj(lHA1NlGGx$#N5QH{JaAaKy!h*WfXuWv@i&j0(pTA E0GE>-x&QzG literal 0 HcmV?d00001 diff --git a/test/soa_test/test.khanacademy.com.soa.0.json b/test/soa_test/test.khanacademy.com.soa.0.json new file mode 100644 index 0000000..42b9feb --- /dev/null +++ b/test/soa_test/test.khanacademy.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 7381, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "khanacademy.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 21, + "labels": [ + "khanacademy", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "khanacademy.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 84, + "labels": [ + "khanacademy", + "com" + ], + "cpcount": 1, + "rdstart": 45, + "rdlength": 72, + "ttl": 899, + "sn": 1, + "ref": 7200, + "ret": 900, + "ex": 1209600, + "nx": 86400 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 117 +} \ No newline at end of file diff --git a/test/soa_test/test.khanacademy.com.soa.query.bin b/test/soa_test/test.khanacademy.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..bc9651548b680bf61020a029d3960c0aea1ff4c8 GIT binary patch literal 33 kcmb2S%E-U~L?FPOospQAn4FlBnp?@7oS)0Uz{bD`0BZCGz5oCK literal 0 HcmV?d00001 diff --git a/test/soa_test/test.khanacademy.com.soa.query.json b/test/soa_test/test.khanacademy.com.soa.query.json new file mode 100644 index 0000000..926a1e6 --- /dev/null +++ b/test/soa_test/test.khanacademy.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 7381, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "khanacademy.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file diff --git a/test/soa_test/test.pinterest.com.soa.0.bin b/test/soa_test/test.pinterest.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..3e720bdaf33b6fa95f154ce272dbceb4c3511a8c GIT binary patch literal 75 zcmdO$)!4wm2!ueuS&*4ml3J8nT*923pUc3&#=v-h2ShS3FlsX>Fy|E;9^he4$twnm YGBCbnVBiyAU|@=1;IwLBU|{C}09AJmM*si- literal 0 HcmV?d00001 diff --git a/test/soa_test/test.pinterest.com.soa.0.json b/test/soa_test/test.pinterest.com.soa.0.json new file mode 100644 index 0000000..1c15262 --- /dev/null +++ b/test/soa_test/test.pinterest.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 11674, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "pinterest.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 19, + "labels": [ + "pinterest", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "pinterest.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 44, + "labels": [ + "pinterest", + "com" + ], + "cpcount": 1, + "rdstart": 43, + "rdlength": 32, + "ttl": 299, + "sn": 493, + "ref": 3600, + "ret": 600, + "ex": 604800, + "nx": 1800 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 75 +} \ No newline at end of file diff --git a/test/soa_test/test.pinterest.com.soa.query.bin b/test/soa_test/test.pinterest.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..107bea3c27a42b9cb324eac1c21a14b0c3c1eb9f GIT binary patch literal 31 icmdO$#mK+_L?FOfkeOGKT9jH`!knC+%fP_Kzz6_WX9fBI literal 0 HcmV?d00001 diff --git a/test/soa_test/test.pinterest.com.soa.query.json b/test/soa_test/test.pinterest.com.soa.query.json new file mode 100644 index 0000000..bad0db7 --- /dev/null +++ b/test/soa_test/test.pinterest.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 11674, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "pinterest.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file diff --git a/test/soa_test/test.tinder.com.soa.0.bin b/test/soa_test/test.tinder.com.soa.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..80f4f7324a51d97f325eb11187989ac4625656d0 GIT binary patch literal 110 zcmWHJZERp*1VSKSE6L1DNiAYd&d&vM7#I)mfJg=g=6nV>_PkEw woH@TJok0-F&B!k<$xSRSNiAYa%uTGy&pRLtG!Up)Mgge5g+Ztk$O~)$0Cyc43IG5A literal 0 HcmV?d00001 diff --git a/test/soa_test/test.tinder.com.soa.0.json b/test/soa_test/test.tinder.com.soa.0.json new file mode 100644 index 0000000..3ff3101 --- /dev/null +++ b/test/soa_test/test.tinder.com.soa.0.json @@ -0,0 +1,61 @@ +{ + "header": { + "id": 21341, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 0, + "arcount": 0, + "question": [ + { + "name": "tinder.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "tinder", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "tinder.com", + "type": 6, + "typeName": "SOA", + "class": 1, + "className": "IN", + "byteLength": 82, + "labels": [ + "tinder", + "com" + ], + "cpcount": 1, + "rdstart": 40, + "rdlength": 70, + "ttl": 879, + "sn": 1, + "ref": 7200, + "ret": 900, + "ex": 1209600, + "nx": 86400 + } + ], + "authority": [], + "edns_options": [], + "additional": [], + "byteLength": 110 +} \ No newline at end of file diff --git a/test/soa_test/test.tinder.com.soa.query.bin b/test/soa_test/test.tinder.com.soa.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..fd01e4c6d056d26aae562d4513f17d3eb5c937b2 GIT binary patch literal 28 dcmWHJWn^FgA`oCJ$;?YhEn-g2&joTA7yQc(3t literal 0 HcmV?d00001 diff --git a/test/soa_test/test.tinder.com.soa.query.json b/test/soa_test/test.tinder.com.soa.query.json new file mode 100644 index 0000000..3e08596 --- /dev/null +++ b/test/soa_test/test.tinder.com.soa.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 21341, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "tinder.com", + "typeName": "SOA", + "className": "IN" + } + ] +} \ No newline at end of file From 12cb2887fa47e5a8c86ed69f629c07f0fd193967 Mon Sep 17 00:00:00 2001 From: Daplie Date: Thu, 9 Mar 2017 19:34:27 -0700 Subject: [PATCH 09/15] still working on it --- packer/type.cname.js | 14 +- packer/type.soa.js | 20 +++ packer/type.txt.js | 38 +++++ parser/type.soa.js | 28 +++- test/soa/soa0.google.com.soa.0.bin | Bin 210 -> 0 bytes test/soa/soa0.google.com.soa.0.json | 203 ------------------------ test/soa/soa0.google.com.soa.query.bin | Bin 28 -> 0 bytes test/soa/soa0.google.com.soa.query.json | 19 --- 8 files changed, 90 insertions(+), 232 deletions(-) create mode 100644 packer/type.txt.js delete mode 100644 test/soa/soa0.google.com.soa.0.bin delete mode 100644 test/soa/soa0.google.com.soa.0.json delete mode 100644 test/soa/soa0.google.com.soa.query.bin delete mode 100644 test/soa/soa0.google.com.soa.query.json diff --git a/packer/type.cname.js b/packer/type.cname.js index 3ca92fe..afa823e 100644 --- a/packer/type.cname.js +++ b/packer/type.cname.js @@ -15,14 +15,14 @@ exports.DNS_PACKER_TYPE_CNAME = function (ab, dv, total, record) { // RDATA // a sequence of labels record.data.split('.').forEach(function (label) { - cnameLen += 1 + label.length; - - dv.setUint8(total, label.length, false); - total += 1; + cnameLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; - label.split('').forEach(function (ch) { - dv.setUint8(total, ch.charCodeAt(0), false); - total += 1; + label.split('').forEach(function (ch) { + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; }); }); diff --git a/packer/type.soa.js b/packer/type.soa.js index 7099853..f80ba99 100644 --- a/packer/type.soa.js +++ b/packer/type.soa.js @@ -2,7 +2,27 @@ 'use strict'; + + exports.DNS_PACKER_TYPE_SOA = function (ab, dv, total, record) { + if(!record.sn){ + throw new Error("no serial number for SOA record"); + } + if(!record.ref){ + throw new Error("no serial number for SOA record"); + } + if(!record.ret){ + throw new Error("no serial number for SOA record"); + } + if(!record.ex){ + throw new Error("no serial number for SOA record"); + } + if(!record.nx){ + throw new Error("no serial number for SOA record"); + } + + + return total; }; diff --git a/packer/type.txt.js b/packer/type.txt.js new file mode 100644 index 0000000..ee7e0ee --- /dev/null +++ b/packer/type.txt.js @@ -0,0 +1,38 @@ +(function (exports) { +'use strict'; + +// Record type is just any text. + +exports.DNS_PACKER_TYPE_TXT = function (ab, dv, total, record) { + // if (!record.data){ + // throw new Error("no data for TXT record"); + // } + + + // console.log("record data is: " + record.data); + + // var txtLen = 0; + // var rdLenIndex = total; + // total += 2; + + // //RDATA + // // a sequence of labels + // record.data.split('.').forEach(function (label) { + // txtLen += 1 + label.length; + + // dv.setUint8(total, label.length, false); + // total += 1; + + // label.split('').forEach(function (ch) { + // dv.setUint8(total, ch.charCodeAt(0), false); + // total += 1; + // }); + // }); + + // // RDLENGTH + // dv.setUint16(rdLenIndex, record.data.length + 1, false); + + // return total; +}; + +}('undefined' !== typeof window ? window : exports)); diff --git a/parser/type.soa.js b/parser/type.soa.js index 762a67a..6550f8f 100644 --- a/parser/type.soa.js +++ b/parser/type.soa.js @@ -1,7 +1,7 @@ (function (exports) { 'use strict'; -// TODO. Not yet implemented +// TODO. Not yet implemented. Do we need to include the name server and email address record properties??? // Value Meaning/Use // Primary NS Variable length. The name of the Primary Master for the domain. May be a label, pointer, or any combination @@ -12,11 +12,33 @@ // Expiration Limit Unsigned 32-bit integer // Minimum TTL Unsigned 32-bit integer +var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS; exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) { var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength); - var dv = new DataView(rdataAb) + var dv = new DataView(rdataAb); + var cpcount = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).cpcount; + var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength; + + + for(var i = 0; i < dv.byteLength;i++){ + + console.log(parseInt(dv.getUint8(i), 10).toString(16)); + } + + // Primary NS + //record.name_server = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + // var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength; + // Admin MB. This email address is always preceeded by 6 Bytes of the name_server data and email_addr length. + // ie: ns1.example.com, where ns1 is 3 bytes, example.com represented by 2 bytes (c0 0c - compression pointer) and then + // 1 more byte representing the email_addr length. + // TODO: email_addr probably shouldn't be parsed this way. The email_addr length byte is probably there to parse this in a more robust way + // we just have to figure that out + + //record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart+offset, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + + // Serial Number record.sn = dv.getUint32(dv.byteLength - 20); // Refresh Interval @@ -27,7 +49,7 @@ exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) { record.ex = dv.getUint32(dv.byteLength - 8); // Minimum TTL record.nx = dv.getUint32(dv.byteLength - 4); - + return record; diff --git a/test/soa/soa0.google.com.soa.0.bin b/test/soa/soa0.google.com.soa.0.bin deleted file mode 100644 index 03f7864735e8ad01e56a6354550b06a69ff04754..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 210 zcmazoX>4F%1VR=D7Pj>K{Pdhu=H&cb1_m|;#sfScl7WH2hCz)vuh`@O4`)hVv2J2Y zZf4#A9*!q_ix?P~TOgR71Edb9g9)VL;dcf$pbn!0JV+u;2Q-j)AbCR+d60-PP^1d% n9)^d%7+7w+SKvAj1?9g7@s+p^^g#HJSV4Rht^*p#>eaXa3%xX< diff --git a/test/soa/soa0.google.com.soa.0.json b/test/soa/soa0.google.com.soa.0.json deleted file mode 100644 index 4ba4b2f..0000000 --- a/test/soa/soa0.google.com.soa.0.json +++ /dev/null @@ -1,203 +0,0 @@ -{ - "header": { - "id": 23924, - "qr": 1, - "opcode": 0, - "aa": 0, - "tc": 0, - "rd": 1, - "ra": 1, - "res1": 0, - "res2": 0, - "res3": 0, - "rcode": 0 - }, - "qdcount": 1, - "ancount": 1, - "nscount": 4, - "arcount": 4, - "question": [ - { - "name": "google.com", - "type": 6, - "typeName": "SOA", - "class": 1, - "className": "IN", - "byteLength": 16, - "labels": [ - "google", - "com" - ], - "cpcount": 0 - } - ], - "answer": [ - { - "name": "google.com", - "type": 6, - "typeName": "SOA", - "class": 1, - "className": "IN", - "byteLength": 50, - "labels": [ - "google", - "com" - ], - "cpcount": 1, - "rdstart": 40, - "rdlength": 38, - "ttl": 60, - "sn": 149208434, - "ref": 900, - "ret": 900, - "ex": 1800, - "nx": 60 - } - ], - "authority": [ - { - "name": "google.com", - "type": 2, - "typeName": "NS", - "class": 1, - "className": "IN", - "byteLength": 18, - "labels": [ - "google", - "com" - ], - "cpcount": 1, - "rdstart": 90, - "rdlength": 6, - "ttl": 57847, - "data": "ns2.google.com" - }, - { - "name": "google.com", - "type": 2, - "typeName": "NS", - "class": 1, - "className": "IN", - "byteLength": 14, - "labels": [ - "google", - "com" - ], - "cpcount": 1, - "rdstart": 108, - "rdlength": 2, - "ttl": 57847, - "data": "ns4.google.com" - }, - { - "name": "google.com", - "type": 2, - "typeName": "NS", - "class": 1, - "className": "IN", - "byteLength": 18, - "labels": [ - "google", - "com" - ], - "cpcount": 1, - "rdstart": 122, - "rdlength": 6, - "ttl": 57847, - "data": "ns1.google.com" - }, - { - "name": "google.com", - "type": 2, - "typeName": "NS", - "class": 1, - "className": "IN", - "byteLength": 18, - "labels": [ - "google", - "com" - ], - "cpcount": 1, - "rdstart": 140, - "rdlength": 6, - "ttl": 57847, - "data": "ns3.google.com" - } - ], - "edns_options": [], - "additional": [ - { - "name": "ns1.google.com", - "type": 1, - "typeName": "A", - "class": 1, - "className": "IN", - "byteLength": 16, - "labels": [ - "ns1", - "google", - "com" - ], - "cpcount": 2, - "rdstart": 158, - "rdlength": 4, - "ttl": 57850, - "address": "216.239.32.10" - }, - { - "name": "ns2.google.com", - "type": 1, - "typeName": "A", - "class": 1, - "className": "IN", - "byteLength": 16, - "labels": [ - "ns2", - "google", - "com" - ], - "cpcount": 2, - "rdstart": 174, - "rdlength": 4, - "ttl": 57839, - "address": "216.239.34.10" - }, - { - "name": "ns3.google.com", - "type": 1, - "typeName": "A", - "class": 1, - "className": "IN", - "byteLength": 16, - "labels": [ - "ns3", - "google", - "com" - ], - "cpcount": 2, - "rdstart": 190, - "rdlength": 4, - "ttl": 57861, - "address": "216.239.36.10" - }, - { - "name": "ns4.google.com", - "type": 1, - "typeName": "A", - "class": 1, - "className": "IN", - "byteLength": 16, - "labels": [ - "ns4", - "google", - "com" - ], - "cpcount": 2, - "rdstart": 206, - "rdlength": 4, - "ttl": 57850, - "address": "216.239.38.10" - } - ], - "byteLength": 210 -} diff --git a/test/soa/soa0.google.com.soa.query.bin b/test/soa/soa0.google.com.soa.query.bin deleted file mode 100644 index d33b6611fd4e91d6ee414df7a16c628127a0a52b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28 dcmazoVPs$cA`oCp&(BZKNo7vX&joTA7y&;T1fT!_ diff --git a/test/soa/soa0.google.com.soa.query.json b/test/soa/soa0.google.com.soa.query.json deleted file mode 100644 index 1122b4d..0000000 --- a/test/soa/soa0.google.com.soa.query.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "header": { - "id": 23924, - "qr": 0, - "opcode": 0, - "aa": 0, - "tc": 0, - "rd": 1, - "ra": 0, - "rcode": 0 - }, - "question": [ - { - "name": "google.com", - "typeName": "SOA", - "className": "IN" - } - ] -} \ No newline at end of file From 50b134f33b7c18a72eafd379f0bd3bc542069aa8 Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 15 Mar 2017 17:55:59 -0600 Subject: [PATCH 10/15] SOA record can be parsed if there are no compression pointers present in the rdata --- parser/type.soa.js | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/parser/type.soa.js b/parser/type.soa.js index 6550f8f..175047b 100644 --- a/parser/type.soa.js +++ b/parser/type.soa.js @@ -20,35 +20,49 @@ exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) { var dv = new DataView(rdataAb); var cpcount = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).cpcount; var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength; - - + var labels = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels; + console.log("offset is: " + offset); + console.log("cpcount is: " + cpcount); + console.log("the labels are : " + labels); + console.log("rdstart is: " + record.rdstart); for(var i = 0; i < dv.byteLength;i++){ console.log(parseInt(dv.getUint8(i), 10).toString(16)); } // Primary NS - //record.name_server = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + record.name_server = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; // var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength; // Admin MB. This email address is always preceeded by 6 Bytes of the name_server data and email_addr length. // ie: ns1.example.com, where ns1 is 3 bytes, example.com represented by 2 bytes (c0 0c - compression pointer) and then // 1 more byte representing the email_addr length. // TODO: email_addr probably shouldn't be parsed this way. The email_addr length byte is probably there to parse this in a more robust way // we just have to figure that out - - //record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart+offset, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; - + + if (cpcount > 0){ + // do something awesome with compression pointers to get the email address + + console.log("name server length is: " + record.name_server.length); + var email_len = parseInt(dv.getUint8(0), 10) + ;dv.getUint16(0) + console.log("email_start is: " + email_len); + record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart , { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + + } + else { + + record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart + offset, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + } // Serial Number - record.sn = dv.getUint32(dv.byteLength - 20); + record.sn = dv.getUint32(dv.byteLength - 20, false); // Refresh Interval - record.ref = dv.getUint32(dv.byteLength - 16); + record.ref = dv.getUint32(dv.byteLength - 16, false); // Retry Interval - record.ret = dv.getUint32(dv.byteLength - 12); + record.ret = dv.getUint32(dv.byteLength - 12, false); // Expiration Limit - record.ex = dv.getUint32(dv.byteLength - 8); + record.ex = dv.getUint32(dv.byteLength - 8, false); // Minimum TTL - record.nx = dv.getUint32(dv.byteLength - 4); + record.nx = dv.getUint32(dv.byteLength - 4, false); return record; From 2388b46c748f239359e5bf1695f91f83415b1baf Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 15 Mar 2017 20:24:03 -0600 Subject: [PATCH 11/15] sort of round about way to get the email property of SOA RDATA. Let me know if theirs a better way --- parser/type.soa.js | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/parser/type.soa.js b/parser/type.soa.js index 175047b..1a3f834 100644 --- a/parser/type.soa.js +++ b/parser/type.soa.js @@ -18,41 +18,38 @@ exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) { var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength); var dv = new DataView(rdataAb); + + // we need this information for this parser var cpcount = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).cpcount; var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength; var labels = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels; - console.log("offset is: " + offset); - console.log("cpcount is: " + cpcount); - console.log("the labels are : " + labels); - console.log("rdstart is: " + record.rdstart); - for(var i = 0; i < dv.byteLength;i++){ - - console.log(parseInt(dv.getUint8(i), 10).toString(16)); - } // Primary NS record.name_server = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; - // var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength; - // Admin MB. This email address is always preceeded by 6 Bytes of the name_server data and email_addr length. - // ie: ns1.example.com, where ns1 is 3 bytes, example.com represented by 2 bytes (c0 0c - compression pointer) and then - // 1 more byte representing the email_addr length. - // TODO: email_addr probably shouldn't be parsed this way. The email_addr length byte is probably there to parse this in a more robust way - // we just have to figure that out - - + + // if there exists compression pointers in the rdata if (cpcount > 0){ // do something awesome with compression pointers to get the email address + // I need the length of all the data before the email address starts. + // if there are compression pointers then there will be a byte to indicate the length of each label, the label, + // then there will be a compression pointer to grab the longest label. - console.log("name server length is: " + record.name_server.length); - var email_len = parseInt(dv.getUint8(0), 10) + ;dv.getUint16(0) - console.log("email_start is: " + email_len); - record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart , { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + var start = 2; // start or email_addr. take into account compression pointer and address length + for(var i = 0; i < labels.length; i++){ - } + // increase start by the label length. the +1 is to take into account the next label size byte + start = start + labels[i].length + 1; + // check for cpcount. 2 counts behind + if(parseInt(dv.getUint8(start - 2), 10) === 192){ + record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart + start ,{ byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + } + } + } // if there are no compression pointers, we can get the email address directly from the offset else { record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart + offset, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; } + // Serial Number record.sn = dv.getUint32(dv.byteLength - 20, false); // Refresh Interval From cfae86e5f17cdcdc5de259e0628d09d3d0c8e598 Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 18 Mar 2017 11:38:43 -0600 Subject: [PATCH 12/15] tested soa packer. It works, but doesn't utilize compression pointers to full capabilities --- packer/type.soa.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packer/type.soa.js b/packer/type.soa.js index c716c72..d79a9f5 100644 --- a/packer/type.soa.js +++ b/packer/type.soa.js @@ -27,7 +27,7 @@ exports.DNS_PACKER_TYPE_SOA = function (ab, dv, total, record) { } if(!record.ret){ throw new Error("no serial number for SOA record"); - } + } if(!record.ex){ throw new Error("no serial number for SOA record"); } @@ -35,7 +35,7 @@ exports.DNS_PACKER_TYPE_SOA = function (ab, dv, total, record) { throw new Error("no serial number for SOA record"); } - var soaLen = 20; // take into account sn, ref, ret, ex, and nx + var soaLen = 20; // take into account sn, ref, ret, ex, and nx // (32-bits each. 4Bytes * 5 = 20) var rdLenIndex = total; total += 2; // Save space for RDLENGTH @@ -72,7 +72,7 @@ exports.DNS_PACKER_TYPE_SOA = function (ab, dv, total, record) { dv.setUint32(total, parseInt(record.ref, 10), false); total+=4; dv.setUint32(total, parseInt(record.ret, 10), false); - total+=4; + total+=4; dv.setUint32(total, parseInt(record.ex, 10), false); total+=4; dv.setUint32(total, parseInt(record.nx, 10), false); From 28fbc448246617165e350e81949c1a051d247a78 Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 18 Mar 2017 11:40:14 -0600 Subject: [PATCH 13/15] wrote the code but dns.rdat.pack.js is having trouble finding the packer for some reason. --- packer/type.txt.js | 49 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/packer/type.txt.js b/packer/type.txt.js index ee7e0ee..93cfb4f 100644 --- a/packer/type.txt.js +++ b/packer/type.txt.js @@ -4,35 +4,32 @@ // Record type is just any text. exports.DNS_PACKER_TYPE_TXT = function (ab, dv, total, record) { - // if (!record.data){ - // throw new Error("no data for TXT record"); - // } + if (!record.data){ + throw new Error("no data for TXT record"); + } + + var txtLen = 0; + var rdLenIndex = total; + total += 2; + + // RDATA + + record.data.split('.').forEach(funtion(label){ + txtLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; + + label.split('').forEach(function (ch) { + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; + }); + }); - // console.log("record data is: " + record.data); + dv.setUint16(rdLenIndex, record.data.length + 1, flase);s - // var txtLen = 0; - // var rdLenIndex = total; - // total += 2; - - // //RDATA - // // a sequence of labels - // record.data.split('.').forEach(function (label) { - // txtLen += 1 + label.length; - - // dv.setUint8(total, label.length, false); - // total += 1; - - // label.split('').forEach(function (ch) { - // dv.setUint8(total, ch.charCodeAt(0), false); - // total += 1; - // }); - // }); - - // // RDLENGTH - // dv.setUint16(rdLenIndex, record.data.length + 1, false); - - // return total; + return total; }; }('undefined' !== typeof window ? window : exports)); From 937e93d1df3137f6d149cfe071e2430487a6d996 Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 18 Mar 2017 11:40:38 -0600 Subject: [PATCH 14/15] captured some txt records with dig.js --- test/txt_test/google.com.txt.0.bin | Bin 0 -> 212 bytes test/txt_test/google.com.txt.0.json | 201 ++++++++++++++++++++++++ test/txt_test/google.com.txt.query.bin | Bin 0 -> 28 bytes test/txt_test/google.com.txt.query.json | 19 +++ 4 files changed, 220 insertions(+) create mode 100644 test/txt_test/google.com.txt.0.bin create mode 100644 test/txt_test/google.com.txt.0.json create mode 100644 test/txt_test/google.com.txt.query.bin create mode 100644 test/txt_test/google.com.txt.query.json diff --git a/test/txt_test/google.com.txt.0.bin b/test/txt_test/google.com.txt.0.bin new file mode 100644 index 0000000000000000000000000000000000000000..f29c4a8c2c6319058bd8894aa85d89ff318fc31e GIT binary patch literal 212 zcmZQv*Vw?o2!t#QENtod`RO^S%*pw=3=9Gcj0bo?Bm)C?5rc|ynQd`FnxR5wUUE)p zN~%>nkf#SxuLo4GP?wmK160ohGRrxQfsHw@*!TbsnurO8h#`iE5m2NC>>}o8DGV$( h-Yak&=!5bjL3|~y0})VuK8UZvbs!7M&j#_;xB$dKGpPUo literal 0 HcmV?d00001 diff --git a/test/txt_test/google.com.txt.0.json b/test/txt_test/google.com.txt.0.json new file mode 100644 index 0000000..e50d47a --- /dev/null +++ b/test/txt_test/google.com.txt.0.json @@ -0,0 +1,201 @@ +{ + "header": { + "id": 430, + "qr": 1, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 1, + "res1": 0, + "res2": 0, + "res3": 0, + "rcode": 0 + }, + "qdcount": 1, + "ancount": 1, + "nscount": 4, + "arcount": 4, + "question": [ + { + "name": "google.com", + "type": 16, + "typeName": "TXT", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "google", + "com" + ], + "cpcount": 0 + } + ], + "answer": [ + { + "name": "google.com", + "type": 16, + "typeName": "TXT", + "class": 1, + "className": "IN", + "byteLength": 48, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 40, + "rdlength": 36, + "ttl": 2930, + "data": [ + "v=spf1 include:_spf.google.com ~all" + ] + } + ], + "authority": [ + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 88, + "rdlength": 6, + "ttl": 82790, + "data": "ns3.google.com" + }, + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 106, + "rdlength": 6, + "ttl": 82790, + "data": "ns4.google.com" + }, + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 124, + "rdlength": 6, + "ttl": 82790, + "data": "ns1.google.com" + }, + { + "name": "google.com", + "type": 2, + "typeName": "NS", + "class": 1, + "className": "IN", + "byteLength": 18, + "labels": [ + "google", + "com" + ], + "cpcount": 1, + "rdstart": 142, + "rdlength": 6, + "ttl": 82790, + "data": "ns2.google.com" + } + ], + "edns_options": [], + "additional": [ + { + "name": "ns1.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns1", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 160, + "rdlength": 4, + "ttl": 255588, + "address": "216.239.32.10" + }, + { + "name": "ns2.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns2", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 176, + "rdlength": 4, + "ttl": 255577, + "address": "216.239.34.10" + }, + { + "name": "ns3.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns3", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 192, + "rdlength": 4, + "ttl": 255599, + "address": "216.239.36.10" + }, + { + "name": "ns4.google.com", + "type": 1, + "typeName": "A", + "class": 1, + "className": "IN", + "byteLength": 16, + "labels": [ + "ns4", + "google", + "com" + ], + "cpcount": 2, + "rdstart": 208, + "rdlength": 4, + "ttl": 255595, + "address": "216.239.38.10" + } + ], + "byteLength": 212 +} \ No newline at end of file diff --git a/test/txt_test/google.com.txt.query.bin b/test/txt_test/google.com.txt.query.bin new file mode 100644 index 0000000000000000000000000000000000000000..393b3302b252400dbc495c75e1301f29ed6b5f86 GIT binary patch literal 28 fcmZQv$H>3{L?FPHo}ZtdlggZ&pUc1?z`zIqJ4OVE literal 0 HcmV?d00001 diff --git a/test/txt_test/google.com.txt.query.json b/test/txt_test/google.com.txt.query.json new file mode 100644 index 0000000..9361cf8 --- /dev/null +++ b/test/txt_test/google.com.txt.query.json @@ -0,0 +1,19 @@ +{ + "header": { + "id": 430, + "qr": 0, + "opcode": 0, + "aa": 0, + "tc": 0, + "rd": 1, + "ra": 0, + "rcode": 0 + }, + "question": [ + { + "name": "google.com", + "typeName": "TXT", + "className": "IN" + } + ] +} \ No newline at end of file From d00f83c625f5c05b7bea42f515d80c8929d1cf9c Mon Sep 17 00:00:00 2001 From: Daplie Date: Thu, 23 Mar 2017 17:33:55 -0600 Subject: [PATCH 15/15] finished TXT record type packer. --- packer/type.txt.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packer/type.txt.js b/packer/type.txt.js index 93cfb4f..dee1b66 100644 --- a/packer/type.txt.js +++ b/packer/type.txt.js @@ -10,24 +10,32 @@ exports.DNS_PACKER_TYPE_TXT = function (ab, dv, total, record) { var txtLen = 0; var rdLenIndex = total; - total += 2; + total += 3; // RDATA + console.log("what is my record data: " + typeof record.data[0]); + console.log("what are my labels? "); + // var res = record.data[0].split(" "); + // console.log("Res: " + res); - record.data.split('.').forEach(funtion(label){ - txtLen += 1 + label.length; + console.log("for each rdata"); + record.data.forEach(function(str){ - dv.setUint8(total, label.length, false); + str.split('').forEach(function(ch){ + + + txtLen += 1; + // console.log(chcim); + dv.setUint8(total, ch.charCodeAt(0), false); total += 1; - - label.split('').forEach(function (ch) { - dv.setUint8(total, ch.charCodeAt(0), false); - total += 1; + }); }); - - dv.setUint16(rdLenIndex, record.data.length + 1, flase);s + console.log("txt rdata length is: " + txtLen); + dv.setUint16(rdLenIndex, txtLen+1, false); + dv.setUint8(rdLenIndex+2, txtLen, false); + // total +=1; return total; };