Add SSL/TLS CA detection

main
Elbert Alias 4 years ago
parent d7712f9272
commit 8540730ba6

2
.gitignore vendored

@ -1,5 +1,5 @@
/build/* /build/*
/src/drivers/**/apps.json /src/drivers/**/technologies.json
/src/drivers/**/wappalyzer.js /src/drivers/**/wappalyzer.js
/src/drivers/webextension/images/icons/converted/* /src/drivers/webextension/images/icons/converted/*

@ -1,6 +1,6 @@
'use strict' 'use strict'
/* eslint-env browser */ /* eslint-env browser */
/* globals chrome, Wappalyzer, Utils */ /* globals chrome, browser, Wappalyzer, Utils */
const { const {
setTechnologies, setTechnologies,
@ -57,12 +57,18 @@ const Driver = {
chrome.browserAction.setBadgeBackgroundColor({ color: '#6B39BD' }, () => {}) chrome.browserAction.setBadgeBackgroundColor({ color: '#6B39BD' }, () => {})
chrome.webRequest.onCompleted.addListener( chrome.webRequest.onHeadersReceived.addListener(
Driver.onWebRequestComplete, Driver.onHeadersReceived,
{ urls: ['http://*/*', 'https://*/*'], types: ['main_frame'] }, { urls: ['http://*/*', 'https://*/*'], types: ['main_frame'] },
['responseHeaders'] ['responseHeaders', 'blocking']
) )
// chrome.webRequest.onCompleted.addListener(
// Driver.onWebRequestComplete,
// { urls: ['http://*/*', 'https://*/*'], types: ['main_frame'] },
// ['responseHeaders']
// )
chrome.tabs.onRemoved.addListener((id) => (Driver.cache.tabs[id] = null)) chrome.tabs.onRemoved.addListener((id) => (Driver.cache.tabs[id] = null))
// Enable messaging between scripts // Enable messaging between scripts
@ -184,7 +190,7 @@ const Driver = {
* Analyse response headers * Analyse response headers
* @param {Object} request * @param {Object} request
*/ */
async onWebRequestComplete(request) { async onHeadersReceived(request) {
if (await Driver.isDisabledDomain(request.url)) { if (await Driver.isDisabledDomain(request.url)) {
return return
} }
@ -208,11 +214,32 @@ const Driver = {
) )
}) })
let certIssuer = ''
if (browser) {
// Currently only works in Firefox
// See https://stackoverflow.com/a/50484642
const { certificates } = await browser.webRequest.getSecurityInfo(
request.requestId,
{
certificateChain: true,
rawDER: false,
}
)
if (certificates && certificates.length) {
certIssuer = certificates[0].issuer.replace(
/^.*CN=([^,]+).*$/,
'$1'
)
}
}
if ( if (
headers['content-type'] && headers['content-type'] &&
/\/x?html/.test(headers['content-type'][0]) /\/x?html/.test(headers['content-type'][0])
) { ) {
await Driver.onDetect(request.url, analyze({ headers })) await Driver.onDetect(request.url, analyze({ headers, certIssuer }))
} }
} }
} catch (error) { } catch (error) {

@ -64,6 +64,7 @@
"tabs", "tabs",
"webRequest", "webRequest",
"webNavigation", "webNavigation",
"webRequestBlocking",
"http://*/*", "http://*/*",
"https://*/*" "https://*/*"
], ],