Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lanwin
Created February 9, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanwin/46110a6510230e900e7d to your computer and use it in GitHub Desktop.
Save lanwin/46110a6510230e900e7d to your computer and use it in GitHub Desktop.
Parse tshark (Wireshark) data field capture file
var fs = require("fs");
var content = fs.readFileSync("outfile.raw",{encoding:'ascii'}).toString().trim().split(/\r?\n/g);
var text = Buffer.concat(content.map(function(line){return new Buffer(line.trim(),'hex');})).toString('ascii').trim();
text.split(/\r\n\r\n/g).forEach(function(line){
var obj = JSON.parse(line);
console.log( ' ' );
console.log( JSON.stringify(obj,null,line.length>200?2:0) );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment