|
1
|
|
|
'use strict'; |
|
2
|
|
|
|
|
3
|
|
|
const driver = options => { |
|
4
|
|
|
const Wappalyzer = require('./wappalyzer'); |
|
5
|
|
|
const request = require('request'); |
|
|
|
|
|
|
6
|
|
|
const fs = require('fs'); |
|
7
|
|
|
const Browser = require('zombie', { |
|
8
|
|
|
userAgent: options.userAgent |
|
9
|
|
|
}); |
|
10
|
|
|
|
|
11
|
|
|
const json = JSON.parse(fs.readFileSync(__dirname + '/apps.json')); |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
return { |
|
14
|
|
|
quiet: true, |
|
15
|
|
|
|
|
16
|
|
|
analyze: url => { |
|
17
|
|
|
const wappalyzer = new Wappalyzer(); |
|
18
|
|
|
|
|
19
|
|
|
wappalyzer.apps = json.apps; |
|
20
|
|
|
wappalyzer.categories = json.categories; |
|
21
|
|
|
|
|
22
|
|
|
return new Promise((resolve, reject) => { |
|
23
|
|
|
wappalyzer.driver.log = (message, source, type) => { |
|
24
|
|
|
if ( type === 'error' ) { |
|
25
|
|
|
return reject(message); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
if ( !driver.quiet ) { |
|
|
|
|
|
|
29
|
|
|
console.log('[wappalyzer ' + type + ']', '[' + source + ']', message); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
}; |
|
32
|
|
|
|
|
33
|
|
|
wappalyzer.driver.displayApps = detected => { |
|
34
|
|
|
var apps = []; |
|
35
|
|
|
|
|
36
|
|
|
Object.keys(detected).forEach(appName => { |
|
37
|
|
|
const app = detected[appName]; |
|
38
|
|
|
|
|
39
|
|
|
var categories = []; |
|
40
|
|
|
|
|
41
|
|
|
app.props.cats.forEach(id => { |
|
42
|
|
|
var category = {}; |
|
43
|
|
|
|
|
44
|
|
|
category[id] = wappalyzer.categories[id].name; |
|
45
|
|
|
|
|
46
|
|
|
categories.push(category) |
|
47
|
|
|
}); |
|
48
|
|
|
|
|
49
|
|
|
apps.push({ |
|
50
|
|
|
name: app.name, |
|
51
|
|
|
confidence: app.confidenceTotal.toString(), |
|
52
|
|
|
version: app.version, |
|
53
|
|
|
icon: app.props.icon || 'default.svg', |
|
54
|
|
|
website: app.props.website, |
|
55
|
|
|
categories |
|
56
|
|
|
}); |
|
57
|
|
|
}); |
|
58
|
|
|
|
|
59
|
|
|
resolve(apps); |
|
60
|
|
|
}; |
|
61
|
|
|
|
|
62
|
|
|
const browser = new Browser(); |
|
63
|
|
|
|
|
64
|
|
|
browser.visit(url, error => { |
|
|
|
|
|
|
65
|
|
|
if ( !browser.resources['0'].response ) { |
|
66
|
|
|
return reject('No response from server'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
browser.wait(options.maxWait) |
|
70
|
|
|
.then(() => { |
|
71
|
|
|
wappalyzer.driver.document = browser.document; |
|
72
|
|
|
|
|
73
|
|
|
const headers = {}; |
|
74
|
|
|
|
|
75
|
|
|
browser.resources['0'].response.headers._headers.forEach(header => { |
|
76
|
|
|
headers[header[0]] = header[1]; |
|
77
|
|
|
}); |
|
78
|
|
|
|
|
79
|
|
|
const vars = Object.getOwnPropertyNames(browser.window); |
|
80
|
|
|
const html = browser.html(); |
|
81
|
|
|
|
|
82
|
|
|
const hostname = wappalyzer.parseUrl(url).hostname; |
|
83
|
|
|
|
|
84
|
|
|
wappalyzer.analyze(hostname, url, { |
|
85
|
|
|
headers, |
|
86
|
|
|
html, |
|
87
|
|
|
env: vars |
|
88
|
|
|
}); |
|
89
|
|
|
}) |
|
90
|
|
|
.catch(error => reject(error)); |
|
|
|
|
|
|
91
|
|
|
}); |
|
92
|
|
|
}); |
|
93
|
|
|
} |
|
94
|
|
|
}; |
|
95
|
|
|
}; |
|
96
|
|
|
|
|
97
|
|
|
module.exports = driver; |
|
98
|
|
|
|