Created
January 28, 2019 15:22
-
-
Save mwielgoszewski/0c7ae5172689af494623316edc4f19e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import requests | |
import StringIO | |
import sys | |
import zipfile | |
def download_crx(identifier): | |
sys.stderr.write("Downloading {0}\n".format(identifier)) | |
try: | |
response = requests.get('https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x64&os_arch=x86_64&nacl_arch=x86-64&prod=chromecrx&prodchannel=canary&prodversion=74.0.3686.0&lang=en-US&acceptformat=crx2,crx3&x=id%3D{identifier}%26installsource%3Dondemand%26uc'.format(identifier=identifier)) | |
sio = StringIO.StringIO(response.content) | |
zf = zipfile.ZipFile(sio) | |
return zf | |
except Exception as e: | |
sys.stderr.write("Failed downloading {0}: {1}\n".format(identifier, e)) | |
return None | |
def extract_manifest(crx_file): | |
try: | |
manifest = crx_file.read('manifest.json') | |
manifest = json.loads(manifest) | |
return manifest | |
except Exception: | |
sys.stderr.write("Failed extracting manifest\n") | |
return {} | |
if __name__ == '__main__': | |
import sys | |
chrome_identifiers = open(sys.argv[1], 'rb').read().splitlines() | |
manifests = {} | |
for chrome_identifier in chrome_identifiers: | |
crx = download_crx(chrome_identifier) | |
if crx: | |
manifests[chrome_identifier] = extract_manifest(crx) | |
sys.stdout.write(json.dumps(manifests)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment