Merge branch 'master' of logicalhacking.com:BrowserSecurity/ExtensionCrawler
This commit is contained in:
commit
534ed5d581
19
extract-crx
19
extract-crx
|
@ -41,6 +41,16 @@ def helpmsg():
|
||||||
print(" -a=<DIR> archive directory")
|
print(" -a=<DIR> archive directory")
|
||||||
|
|
||||||
|
|
||||||
|
def get_tarinfo(members, name, winfs = False):
|
||||||
|
"""Select tarinfo object with a specified path/name."""
|
||||||
|
for tarinfo in members:
|
||||||
|
if tarinfo.name == name:
|
||||||
|
if winfs:
|
||||||
|
tarinfo.name = name.replace(":","-")
|
||||||
|
yield tarinfo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
"""Main function of the extension crawler."""
|
"""Main function of the extension crawler."""
|
||||||
basedir = "archive"
|
basedir = "archive"
|
||||||
|
@ -48,8 +58,9 @@ def main(argv):
|
||||||
date = None
|
date = None
|
||||||
extid = ""
|
extid = ""
|
||||||
output = ""
|
output = ""
|
||||||
|
winfs = False
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, "hsd:a:o:", ["date=", "archive=", "output="])
|
opts, args = getopt.getopt(argv, "hsd:a:o:w", ["date=", "archive=", "output="])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
helpmsg()
|
helpmsg()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
@ -63,13 +74,15 @@ def main(argv):
|
||||||
date = arg
|
date = arg
|
||||||
elif opt in ("-o", "--output"):
|
elif opt in ("-o", "--output"):
|
||||||
output = arg
|
output = arg
|
||||||
|
elif opt in ("-w", "--winfs"):
|
||||||
|
winfs = True
|
||||||
elif opt == '-s':
|
elif opt == '-s':
|
||||||
verbose = False
|
verbose = False
|
||||||
|
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
extid = args[0]
|
extid = args[0]
|
||||||
else:
|
else:
|
||||||
help()
|
helpmsg()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if date is not None:
|
if date is not None:
|
||||||
|
@ -87,7 +100,7 @@ def main(argv):
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Extracting "+os.path.join(output, last))
|
print("Extracting "+os.path.join(output, last))
|
||||||
with tarfile.open(tar, 'r') as archive:
|
with tarfile.open(tar, 'r') as archive:
|
||||||
archive.extract(last, output)
|
archive.extractall(path=output, members=get_tarinfo(archive, last, winfs))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|
Loading…
Reference in New Issue