Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing with the current wappalyser source #29

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ tags.*
src/out.json

keys.json
src_gppongmhjkpfnbhagpmjfkannfbllamg/
101 changes: 101 additions & 0 deletions bin/import_rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Original Wappalyser Chrome extension https://chrome.google.com/webstore/detail/gppongmhjkpfnbhagpmjfkannfbllamg
const https = require('https')
const fs = require('fs')
const { exec } = require('child_process')

const extensionId = 'gppongmhjkpfnbhagpmjfkannfbllamg'
const url = `https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D${extensionId}%26uc&acceptformat=crx3`
const zipFileName = `${extensionId}.zip`
const tempDir = `src_${extensionId}`

// Download Chrome extension
const downloadExtension = (url, dest) => {
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(dest)
const request = https.get(url, (response) => {
if (
response.statusCode >= 300 &&
response.statusCode < 400 &&
response.headers.location
) {
console.log('Redirecting to', response.headers.location)
downloadExtension(response.headers.location, dest)
.then(resolve)
.catch(reject)
} else if (response.statusCode === 200) {
response.pipe(file)
file.on('finish', () => {
console.log('Download completed')
file.close(resolve)
})
} else {
file.close()
fs.unlink(dest, () => {
reject(new Error(`Failed to download: HTTP ${response.statusCode}`))
})
}
})
request.on('error', (error) => {
fs.unlink(dest, () => reject(error))
})
})
}

const unzipExtension = (zipFile, dest) => {
return new Promise((resolve, reject) => {
try {
exec(`unzip -o ${zipFile} -d ${dest}`, (error) => {
if (error) {
resolve()
} else {
resolve()
}
})
} catch (error) {
console.log(error)
}
})
}

const removeZipFile = (file) => {
return new Promise((resolve, reject) => {
fs.unlink(file, (error) => {
if (error) {
reject(error)
} else {
resolve()
}
})
})
}

const copyFiles = () => {
return Promise.all([
exec(`cp -f ${tempDir}/technologies/* src/technologies/`),
exec(`cp -f ${tempDir}/categories.json src/categories.json`),
exec(`cp -f ${tempDir}/groups.json src/groups.json`),
])
}

// Main function
const main = async () => {
try {
await downloadExtension(url, zipFileName)
console.log('Unzipping Chrome extension...')

await unzipExtension(zipFileName, tempDir)

console.log('Removing downloaded zip file...')
await removeZipFile(zipFileName)

await copyFiles()
console.log('Chrome extension downloaded and files copied successfully.')
} catch (error) {
console.error('An error occurred:', error)
process.exit(1)
}

process.exit(0)
}

main()
Loading