Merge branch 'master' of logicalhacking.com:BrowserSecurity/ExtensionCrawler

This commit is contained in:
Michael Herzberg 2017-08-16 21:32:16 +01:00
commit 534ed5d581
1 changed files with 16 additions and 3 deletions

View File

@ -41,6 +41,16 @@ def helpmsg():
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):
"""Main function of the extension crawler."""
basedir = "archive"
@ -48,8 +58,9 @@ def main(argv):
date = None
extid = ""
output = ""
winfs = False
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:
helpmsg()
sys.exit(2)
@ -63,13 +74,15 @@ def main(argv):
date = arg
elif opt in ("-o", "--output"):
output = arg
elif opt in ("-w", "--winfs"):
winfs = True
elif opt == '-s':
verbose = False
if len(args) > 0:
extid = args[0]
else:
help()
helpmsg()
sys.exit()
if date is not None:
@ -87,7 +100,7 @@ def main(argv):
if verbose:
print("Extracting "+os.path.join(output, last))
with tarfile.open(tar, 'r') as archive:
archive.extract(last, output)
archive.extractall(path=output, members=get_tarinfo(archive, last, winfs))
if __name__ == "__main__":
main(sys.argv[1:])