forked from JamesTheHacker/80Scan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
80scan.js
60 lines (49 loc) · 1.44 KB
/
80scan.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
57
58
59
60
let argv = require('yargs').argv
let cidr = new require('cidr-js')()
let fs = require('fs')
let _ = require('lodash')
let request = require('request-promise')
require('events').EventEmitter.prototype._maxListeners = 100;
// Check if the correct arguments have been past
if(!argv.cidr || !argv.needles) {
throw new Error('Usage: node 80scan.js --cidr=192.168.0.0/24 --needles=needles.txt')
}
// Convert the CIDR into a list of IP addresses
ips = cidr.list(argv.cidr)
if(!ips) {
throw new Error('Invalid CIDR!')
}
// Open the needles file and convert to an array
needles = fs.readFileSync(argv.needles).toString().split('\n').filter((n) => {
if(n) return n
})
// Loop through the IP addresses
ips.map((ip) => {
let options = {
url: `http://${ip}`,
timeout: 5000,
transform: (body, response) => {
return {
"ip": ip,
"body": body,
"headers": _.values(response.headers)
}
}
}
request(options)
.then((response) => {
if(argv.headers) {
// Check the headers contain any needles
let headers = _.intersectionWith(needles, response.headers, (needle, header) => {
return header.indexOf(needle) !== -1
})
if(headers.length > 0) console.log(response.ip)
} else {
// Check the body for needles
let inBody = needles.some((needle) => response.body.indexOf(needle) > -1)
if(inBody) console.log(response.ip)
}
}).catch((err) => {
return
})
})