forked from Lissy93/wapalyzer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
92 lines (75 loc) · 2.63 KB
/
cli.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env node
const Wappalyzer = require('./driver');
const args = process.argv.slice(2);
const options = {};
let url;
let arg;
const aliases = {
a: 'userAgent',
b: 'browser',
c: 'chunkSize',
d: 'debug',
t: 'delay',
h: 'help',
D: 'maxDepth',
m: 'maxUrls',
p: 'password',
P: 'pretty',
r: 'recursive',
u: 'username',
w: 'maxWait',
};
while (true) { // eslint-disable-line no-constant-condition
arg = args.shift();
if (!arg) {
break;
}
const matches = /^-?-([^=]+)(?:=(.+)?)?/.exec(arg);
if (matches) {
const key = aliases[matches[1]] || matches[1].replace(/-\w/g, _matches => _matches[1].toUpperCase());
// eslint-disable-next-line no-nested-ternary
const value = matches[2] ? matches[2] : args[0] && !args[0].match(/^-/) ? args.shift() : true;
options[key] = value;
} else {
url = arg;
}
}
if (!url || options.help) {
process.stdout.write(`Usage:
wappalyzer <url> [options]
Examples:
wappalyzer https://www.example.com
node cli.js https://www.example.com -b puppeteer -r -D 3 -m 50
docker wappalyzer/cli https://www.example.com --pretty
Options:
-b, --browser=... Specify which headless browser to use (zombie or puppeteer)
-c, --chunk-size=... Process links in chunks
-d, --debug Output debug messages
-t, --delay=ms Wait for ms milliseconds between requests
-h, --help This text
--html-max-cols=... Limit the number of HTML characters per line processed
--html-max-rows=... Limit the number of HTML lines processed
-D, --max-depth=... Don't analyse pages more than num levels deep
-m, --max-urls=... Exit when num URLs have been analysed
-w, --max-wait=... Wait no more than ms milliseconds for page resources to load
-p, --password=... Password to be used for basic HTTP authentication (zombie only)
-P, --pretty Pretty-print JSON output
--proxy=... Proxy URL, e.g. 'http://user:pass@proxy:8080' (zombie only)
-r, --recursive Follow links on pages (crawler)
-a, --user-agent=... Set the user agent string
-u, --username=... Username to be used for basic HTTP authentication (zombie only)
`);
process.exit(1);
}
// eslint-disable-next-line import/no-dynamic-require
const Browser = require(`./browsers/${options.browser || 'zombie'}`);
const wappalyzer = new Wappalyzer(Browser, url, options);
wappalyzer.analyze()
.then((json) => {
process.stdout.write(`${JSON.stringify(json, null, options.pretty ? 2 : null)}\n`);
process.exit(0);
})
.catch((error) => {
process.stderr.write(`${error}\n`);
process.exit(1);
});