-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathnikto_Host_List.js
More file actions
70 lines (65 loc) · 1.91 KB
/
nikto_Host_List.js
File metadata and controls
70 lines (65 loc) · 1.91 KB
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
61
62
63
64
65
66
67
68
69
70
/* eslint-disable no-unused-vars */
/* globals Session Hosts Meteor Services */
function niktoHostList (services, domain) {
// Creates a list of hosts and/or hostnames for automated Nikto scan
//
// Created by: Matt Burch
// Usage: niktoHostList([/http/,80,'8000-8015'])
// Optional Usage: niktoHostList([/http/,80,'8000-8015'],/domain\.com/)
//
if (domain && typeof domain !== 'object') {
return console.log('Domain regex can not be a string, must be an object')
}
var HostTargets = {}
var projectId = Session.get('projectId')
function getHosts (lpid, port) {
var host = Hosts.findOne({
'projectId': projectId,
'_id': lpid
})
if (!(host.ipv4 + ':' + port in HostTargets)) {
HostTargets[host.ipv4 + ':' + port] = true
}
if (domain) {
host.hostnames.forEach(function (hostname) {
if (domain.test(hostname) && !(hostname + ':' + port in HostTargets)) {
HostTargets[hostname + ':' + port] = true
}
})
}
}
services.forEach(function (service) {
var foundServices = []
if (typeof service === 'object') {
foundServices = Services.find({
'projectId': projectId,
'service': {
'$regex': service
}
}).fetch()
foundServices.forEach(function (s) {
getHosts(s.hostId, s.port)
})
} else if (typeof service === 'string') {
var list = service.split('-')
for (var i = parseInt(list[0], 10); i <= parseInt(list[1], 10); i++) {
foundServices = Services.find({
'projectId': projectId,
'service': i
}).fetch()
foundServices.forEach(function (s) {
getHosts(s.hostId, s.port)
})
}
} else {
var s = Services.findOne({
'projectId': projectId,
'service': service
})
getHosts(s.hostId, service.port)
}
})
for (var key in HostTargets) {
console.log(key)
}
}