forked from lair-framework/browser-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iis_os_profiler.js
52 lines (51 loc) · 1.74 KB
/
iis_os_profiler.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
var iisOsProfiler = function () {
// Loops over every port who's product matches IIS X.X and performs a
// best guess at the operating system, inserting the guess into the
// port's host's os array.
//
// Usage: iisOsProfiler()
// Created by: Tom Steele
// Requires client-side updates: false
var PROJECT_ID = Session.get('projectId');
var WEIGHT = 90;
var TOOL = 'IIS OS Profiler';
var ports = Ports.find({
'project_id': PROJECT_ID,
'product': {
'$regex': /IIS\s(httpd\s)?\d+\.\d+/,
'$options': 'i'
}
}).fetch();
ports.forEach(function (port) {
var product = port.product;
var res = product.match(/\d+\.\d+/);
if (res === null) {
return;
}
var version = parseFloat(res[0]);
if (isNaN(version)) {
return;
}
var os = models.os();
os.tool = TOOL;
os.weight = WEIGHT;
if (version < 6) {
os.fingerprint = 'Microsoft Windows Server 2000';
} else if (version < 7) {
os.fingerprint = 'Microsoft Windows Server 2003';
} else if (version < 8) {
os.fingerprint = 'Microsoft Windows Server 2008';
} else if (version < 9) {
os.fingerprint = 'Microsoft Windows Server 2012';
}
if (os.fingerprint !== '') {
Meteor.call('addHostOs', PROJECT_ID, port.host_id, os.tool, os.fingerprint, os.weight, function (err) {
if (err) {
console.log('Error generating OS for', port.host_id, err);
} else {
console.log('Created new OS', os.fingerprint, 'for', port.host_id);
}
});
}
});
};