forked from lair-framework/browser-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnikto_Host_List.js
69 lines (65 loc) · 2.2 KB
/
nikto_Host_List.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
61
62
63
64
65
66
67
68
69
niktoHostList = function (service, 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 DOMAIN = domain;
var SERVICES = service;
var HostTargets = {};
var PROJECT_ID = Session.get('projectId');
function getHosts(lpid, port) {
var host = Hosts.findOne({
'project_id': PROJECT_ID,
'_id': lpid
});
if (!(host.string_addr + ':' + port in HostTargets)) {
HostTargets[host.string_addr + ':' + 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 ports = [];
if (typeof service == 'object') {
ports = Ports.find({
'project_id': PROJECT_ID,
'service': {
'$regex': service
}
}).fetch();
ports.forEach(function (port) {
getHosts(port.host_id, port.port);
})
} else if (typeof service == 'string') {
var list = service.split('-');
for (var i = parseInt(list[0], 10); i <= parseInt(list[1], 10); i++) {
ports = Ports.find({
'project_id': PROJECT_ID,
'port': i
}).fetch();
ports.forEach(function (port) {
getHosts(port.host_id, port.port);
})
}
} else {
var port = Ports.findOne({
'project_id': PROJECT_ID,
'port': service
});
getHosts(port.host_id, port.port);
}
});
for (var key in HostTargets) {
console.log(key)
}
};