We need to deal with the tcpdump headers as well :eyeroll:

This commit is contained in:
John Shaver 2017-09-25 11:06:36 -07:00
parent 7616ab95f3
commit e59a0b2943
2 changed files with 34 additions and 2 deletions

View File

@ -5,10 +5,17 @@ if(typeof(atob) === 'undefined') {
'use strict';
var encodedPacket = "1MOyoQIABAAAAAAAAAAAAAAABAABAAAAKPfFWWMZCwBRAAAAUQAAAExg3kp+6eSzGAoxpggARQAAQ66CQABAEXgXCgAAEAoAAAG90gA1AC+qDJSEAQAAAQAAAAAAAAphc3NldHMtY2RuBmdpdGh1YgNjb20AAAEAAQ=="
//convert to binary string to create ArrayBuffer
var packet = atob(encodedPacket);
console.log(packet.length);
console.log("tcpdump length:", packet.length);
//The first 40 bytes are the tcpdump header
packet = packet.slice(40);
console.log("UDP length:", packet.length);
//We now have the raw UDP packet!
var buffer = new ArrayBuffer(packet.length);
var view = new DataView(buffer)
@ -18,7 +25,31 @@ if(typeof(atob) === 'undefined') {
}
for(i = 0; i < packet.length; ++i) {
console.log(view.getUint8(i).toString(16));
}
console.log("Result:", parseDNSHeader(view));
//Parse DNS Header (given the UDP payload)
function parseDNSHeader(view) {
return {
MessageID: getHId(view)
};
}
function getHId(view) {
return view.getUint16(0, false)
}
function getQR(view) {
}
function getOPCode(view) {
}
function getAA(view) {
}
function getTC(view) {
}
})();

View File

@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {