Skip to content

Commit

Permalink
removing natively zip cracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Derekt2 committed Aug 17, 2021
1 parent a1b3201 commit 7e0c2c1
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/python/strelka/scanners/scan_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,18 @@ class ScanZip(strelka.Scanner):
password_file: Location of passwords file for zip archives.
Defaults to /etc/strelka/passwords.dat.
"""
def init(self):
self.passwords = []

def scan(self, data, file, options, expire_at):
file_limit = options.get('limit', 1000)
password_file = options.get('password_file', '/etc/strelka/passwords.dat')

self.event['total'] = {'files': 0, 'extracted': 0}

if not self.passwords:
if os.path.isfile(password_file):
with open(password_file, 'rb') as f:
for line in f:
self.passwords.append(line.strip())

with io.BytesIO(data) as zip_io:
try:
with zipfile.ZipFile(zip_io) as zip_obj:
name_list = zip_obj.namelist()
self.event['total']['files'] = len(name_list)

password = b''
for i, name in enumerate(name_list):
if not name.endswith('/'):
if self.event['total']['extracted'] >= file_limit:
Expand All @@ -53,19 +43,6 @@ def scan(self, data, file, options, expire_at):
if i == 0:
self.flags.append('encrypted')

if not password:
for pw in self.passwords:
try:
extract_data = zip_obj.read(name, pw)
if extract_data:
password = pw
break

except (RuntimeError, zipfile.BadZipFile, zlib.error):
pass
else:
extract_data = zip_obj.read(name, password)

else:
extract_data = zip_obj.read(name)

Expand Down

0 comments on commit 7e0c2c1

Please sign in to comment.