-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (18 loc) · 687 Bytes
/
index.js
File metadata and controls
24 lines (18 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/node
// Requirements
var pcap = require('pcap'),
tcp_tracker = new pcap.TCPTracker(),
pcap_session = pcap.createSession('wlp4s0', ''),
geoip = require('geoip-lite');
// TCP capture
tcp_tracker.on('session', function (session) {
console.log("Start of session between " + session.src_name + " and " + session.dst_name);
session.on('end', function (session) {
console.log("End of TCP session between " + session.src_name + " and " + session.dst_name);
});
});
// Packet capture is evenement based
pcap_session.on('packet', function (raw_packet) {
// do some stuff with a raw packet
var packet = pcap.decode.packet(raw_packet);
});