Skip to content

Commit

Permalink
20221227a
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierStevens committed Dec 27, 2022
1 parent b9e12fb commit 7c14d03
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions zipdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

__description__ = 'ZIP dump utility'
__author__ = 'Didier Stevens'
__version__ = '0.0.23'
__date__ = '2022/12/14'
__version__ = '0.0.24'
__date__ = '2022/12/19'

"""
Expand Down Expand Up @@ -59,6 +59,7 @@
2022/05/16: 0.0.23 parsing continued
2022/05/17: parsing continued
2022/12/14: added option write
2022/12/19: 0.0.24 added values hash and hashvir for option write
Todo:
"""
Expand Down Expand Up @@ -523,7 +524,7 @@ def PrintManual():
for line in manual.split('\n'):
print(textwrap.fill(line, 78))

validWriteValues = ['vir']
validWriteValues = ['vir', 'hash', 'hashvir']

#Convert 2 Bytes If Python 3
def C2BIP3(string):
Expand Down Expand Up @@ -5180,10 +5181,16 @@ def ZIPDump(zipfilename, options, data=None):
for oZipInfo in oZipfile.infolist():
with oZipfile.open(oZipInfo, 'r', C2BIP3(zippassword)) as file:
if not oZipInfo.is_dir():
memberFilename = os.path.basename(oZipInfo.filename) + '.vir'
data = file.read()
if options.write == 'vir':
memberFilename = os.path.basename(oZipInfo.filename) + '.vir'
else:
memberFilename = hashlib.sha256(data).hexdigest()
if options.write == 'hashvir':
memberFilename += '.vir'
print('Writing: %s' % memberFilename)
with open(memberFilename, 'wb') as fWrite:
fWrite.write(file.read())
fWrite.write(data)
return

if options.yara != None:
Expand Down

0 comments on commit 7c14d03

Please sign in to comment.