SOA record can be parsed if there are no compression pointers present in the rdata

This commit is contained in:
Daplie 2017-03-15 17:55:59 -06:00
parent 12cb2887fa
commit 50b134f33b
1 changed files with 25 additions and 11 deletions

View File

@ -20,15 +20,18 @@ exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) {
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 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 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++){ for(var i = 0; i < dv.byteLength;i++){
console.log(parseInt(dv.getUint8(i), 10).toString(16)); console.log(parseInt(dv.getUint8(i), 10).toString(16));
} }
// Primary NS // 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; // 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. // 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 // ie: ns1.example.com, where ns1 is 3 bytes, example.com represented by 2 bytes (c0 0c - compression pointer) and then
@ -36,19 +39,30 @@ exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) {
// 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 // 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 // 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 // Serial Number
record.sn = dv.getUint32(dv.byteLength - 20); record.sn = dv.getUint32(dv.byteLength - 20, false);
// Refresh Interval // Refresh Interval
record.ref = dv.getUint32(dv.byteLength - 16); record.ref = dv.getUint32(dv.byteLength - 16, false);
// Retry Interval // Retry Interval
record.ret = dv.getUint32(dv.byteLength - 12); record.ret = dv.getUint32(dv.byteLength - 12, false);
// Expiration Limit // Expiration Limit
record.ex = dv.getUint32(dv.byteLength - 8); record.ex = dv.getUint32(dv.byteLength - 8, false);
// Minimum TTL // Minimum TTL
record.nx = dv.getUint32(dv.byteLength - 4); record.nx = dv.getUint32(dv.byteLength - 4, false);
return record; return record;