Skip to content

Instantly share code, notes, and snippets.

@sooshie
Created April 10, 2020 19:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sooshie/5ff946bc99b0e5b44858ae2a2d3dd185 to your computer and use it in GitHub Desktop.
Save sooshie/5ff946bc99b0e5b44858ae2a2d3dd185 to your computer and use it in GitHub Desktop.
Download multiple versions of Chrome extension source from crxcavator.io and run a string search on the files.
# Python 3
# Sometimes hunting for strings in a bunch of different browser extensions and their many versions can be a pain.
# This will call out to crxcavator.io, pull the versions and sources. Then just run a simple string match on it.
# Surprisingly, it works.
#
# sooshie@gmail.com
import requests
import json
import sys
import io
import zipfile
def parse_zip(r, extname, version, search_string):
raw_data = b''
for chunk in r.iter_content(chunk_size=128):
raw_data += chunk
zipfile_ob = zipfile.ZipFile(io.BytesIO(raw_data))
for zipinfo in zipfile_ob.infolist():
with zipfile_ob.open(zipinfo) as thefile:
filecontent = thefile.read()
offset = filecontent.find(search_string)
if offset != -1:
print('{} - {}'.format(version, zipinfo.filename))
print('https://crxcavator.io/source/{}/{}?file={}'.format(extname, version, zipinfo.filename))
print(str(filecontent[offset - 20: offset + len(search_string) + 20]))
def main():
extension = ''
versions = []
report_url = 'https://api.crxcavator.io/v1/report/'
search_string = None
try:
extension = sys.argv[1]
except:
print('Please provide an extension ID on the commandline')
sys.exit(1)
try:
search_string = sys.argv[2].encode()
except:
print('Please provide a search string on the commandline')
sys.exit(1)
r = requests.get(report_url + extension)
data = json.loads(r.text)
for ext in data:
versions.append(ext['version'])
for version in versions:
r = requests.get('https://extensions.crxcavator.io/{}_{}.zip'.format(extension, version))
parse_zip(r, extension, version, search_string)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment