Add header option to CLI

main
Elbert Alias 2 years ago
parent b66242de29
commit 8ec975cc99

@ -15,6 +15,7 @@ const aliases = {
d: 'debug', d: 'debug',
t: 'delay', t: 'delay',
h: 'help', h: 'help',
H: 'header',
D: 'maxDepth', D: 'maxDepth',
m: 'maxUrls', m: 'maxUrls',
p: 'probe', p: 'probe',
@ -47,7 +48,15 @@ while (true) {
? args.shift() ? args.shift()
: true : true
if (options[key]) {
if (!Array.isArray(options[key])) {
options[key] = [options[key]]
}
options[key].push(value)
} else {
options[key] = value options[key] = value
}
} else { } else {
url = arg url = arg
} }
@ -59,7 +68,7 @@ if (!url || options.help) {
Examples: Examples:
wappalyzer https://www.example.com wappalyzer https://www.example.com
node cli.js https://www.example.com -r -D 3 -m 50 node cli.js https://www.example.com -r -D 3 -m 50 -H "Cookie: username=admin"
docker wappalyzer/cli https://www.example.com --pretty docker wappalyzer/cli https://www.example.com --pretty
Options: Options:
@ -67,6 +76,7 @@ Options:
-d, --debug Output debug messages -d, --debug Output debug messages
-t, --delay=ms Wait for ms milliseconds between requests -t, --delay=ms Wait for ms milliseconds between requests
-h, --help This text -h, --help This text
-H, --header Extra header to send with requests
--html-max-cols=... Limit the number of HTML characters per line processed --html-max-cols=... Limit the number of HTML characters per line processed
--html-max-rows=... Limit the number of HTML lines processed --html-max-rows=... Limit the number of HTML lines processed
-D, --max-depth=... Don't analyse pages more than num levels deep -D, --max-depth=... Don't analyse pages more than num levels deep
@ -85,13 +95,25 @@ Options:
process.exit(1) process.exit(1)
} }
const headers = {}
if (options.header) {
;(Array.isArray(options.header) ? options.header : [options.header]).forEach(
(header) => {
const [key, value] = header.split(':')
headers[key.trim()] = (value || '').trim()
}
)
}
;(async function () { ;(async function () {
const wappalyzer = new Wappalyzer(options) const wappalyzer = new Wappalyzer(options)
try { try {
await wappalyzer.init() await wappalyzer.init()
const site = await wappalyzer.open(url) const site = await wappalyzer.open(url, headers)
const results = await site.analyze() const results = await site.analyze()

@ -13,6 +13,7 @@ const { setTechnologies, setCategories, analyze, analyzeManyToMany, resolve } =
const { CHROMIUM_BIN, CHROMIUM_DATA_DIR, CHROMIUM_WEBSOCKET } = process.env const { CHROMIUM_BIN, CHROMIUM_DATA_DIR, CHROMIUM_WEBSOCKET } = process.env
const chromiumArgs = [ const chromiumArgs = [
'--single-process',
'--no-sandbox', '--no-sandbox',
'--no-zygote', '--no-zygote',
'--disable-gpu', '--disable-gpu',

@ -13,7 +13,7 @@
"software" "software"
], ],
"homepage": "https://www.wappalyzer.com/", "homepage": "https://www.wappalyzer.com/",
"version": "6.10.36", "version": "6.10.37",
"author": "Wappalyzer", "author": "Wappalyzer",
"license": "MIT", "license": "MIT",
"repository": { "repository": {

@ -13,7 +13,7 @@
"software" "software"
], ],
"homepage": "https://www.wappalyzer.com/", "homepage": "https://www.wappalyzer.com/",
"version": "6.10.36", "version": "6.10.37",
"author": "Wappalyzer", "author": "Wappalyzer",
"license": "MIT", "license": "MIT",
"repository": { "repository": {