-
Notifications
You must be signed in to change notification settings - Fork 107
/
scan.js
54 lines (44 loc) · 1.09 KB
/
scan.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
var ip = require("ip");
const net = require('net');
const Evilscan = require('evilscan');
var localNetwork = ip.address().split('.');
var network = localNetwork[0] + '.' + localNetwork[1] + '.' + localNetwork[2];
var range = network + ".1-" + network + ".254"
var networkDevices = []
const options = {
target: range,
port: '23',
status: 'TROU', // Timeout, Refused, Open, Unreachable
banner: true
};
new Evilscan(options, (err, scan) => {
if (err) {
//console.log(err);
return;
}
scan.on('result', data => {
// fired when item is matching options
//console.log(data);
if (data.status == "open") {
var type = false
if (data.banner.indexOf("GrblHAL") != -1) {
type = "grblHAL"
} else if (data.banner.indexOf("Grbl") != -1) {
type = "grbl"
}
networkDevices.push({
ip: data.ip,
type: type,
banner: data.banner
})
}
});
scan.on('error', err => {
//throw new Error(data.toString());
});
scan.on('done', () => {
// finished !
console.log(networkDevices);
});
scan.run();
});