Skip to content

Commit

Permalink
Merge branch 'master' into yarapy
Browse files Browse the repository at this point in the history
  • Loading branch information
phutelmyer authored Mar 11, 2024
2 parents b06ff63 + 7f71bcb commit 0936a49
Show file tree
Hide file tree
Showing 16 changed files with 1,270 additions and 76 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/psf/black
rev: "22.6.0"
rev: "24.2.0"
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -17,16 +17,16 @@ repos:
args:
- -b main
- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
rev: "7.0.0"
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
rev: "5.11.5"
rev: "5.13.2"
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.961
# rev: "1.9.0"
# hooks:
# - id: mypy
# additional_dependencies:
Expand Down
5 changes: 5 additions & 0 deletions configs/python/backend/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ scanners:
priority: 5
options:
limit: 1000
limit_metadata: True
size_limit: 250000000
crack_pws: False
log_pws: True
password_file: '/etc/strelka/passwords.dat'
'ScanRpm':
- positive:
flavors:
Expand Down
6 changes: 3 additions & 3 deletions docs/README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pyxlsb2 = "0.0.9"
pyyaml = "6.0.1"
pyzbar = "0.1.9"
pyzipper = "0.3.6"
rarfile = "4.0"
rarfile = "4.1"
redis = "4.5.4"
requests = "2.31.0"
rpmfile = "1.1.1"
Expand Down
300 changes: 247 additions & 53 deletions src/python/strelka/scanners/scan_rar.py

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions src/python/strelka/scanners/scan_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class ScanZip(strelka.Scanner):
Defaults to /etc/strelka/passwords.dat.
"""

def init(self):
self.passwords = []

def scan(self, data, file, options, expire_at):
file_limit = options.get("limit", 100)
size_limit = options.get("size_limit", 250000000)
Expand All @@ -28,8 +31,6 @@ def scan(self, data, file, options, expire_at):
log_pws = options.get("log_pws", True)
password_file = options.get("password_file", "/etc/strelka/passwords.dat")

passwords = [None]

# Gather count and list of files to be extracted
self.event["total"] = {"files": 0, "extracted": 0}
self.event["files"] = []
Expand All @@ -38,10 +39,23 @@ def scan(self, data, file, options, expire_at):
compress_size_total = 0
file_size_total = 0

if crack_pws and os.path.isfile(password_file):
with open(password_file, "rb") as f:
for line in f:
passwords.append(line.strip())
if crack_pws:
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())

if (
len(self.passwords) == 0
and "no_passwords_loaded" not in self.flags
):
self.flags.append("no_passwords_loaded")
else:
if "password_file_missing" not in self.flags:
self.flags.append("password_file_missing")

self.passwords.insert(0, None)

with io.BytesIO(data) as zip_io:
try:
Expand Down Expand Up @@ -96,17 +110,17 @@ def scan(self, data, file, options, expire_at):
if "encrypted" not in self.flags:
self.flags.append("encrypted")

for password in passwords:
for password in self.passwords:
try:
if extract:
extract_data = zip_obj.read(
compressed_file.filename, password
)
if extract_data:
passwords.insert(
self.passwords.insert(
0,
passwords.pop(
passwords.index(password)
self.passwords.pop(
self.passwords.index(password)
),
)
if password and crack_pws and log_pws:
Expand Down
2 changes: 1 addition & 1 deletion src/python/strelka/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run_test_scan(

scanner.scan_wrapper(
data=data,
file=File(name="test"),
file=File(name=fixture_path if fixture_path else "test"),
options=options,
expire_at=datetime.date.today(),
)
Expand Down
Binary file added src/python/strelka/tests/fixtures/test_big.rar
Binary file not shown.
Binary file not shown.
Binary file added src/python/strelka/tests/fixtures/test_mixed.rar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/python/strelka/tests/helpers/test_passwords_alternate.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Spring2024!
hunter2
Loading

0 comments on commit 0936a49

Please sign in to comment.