Skip to content

Commit

Permalink
Update CAPE.py
Browse files Browse the repository at this point in the history
Fix that prevents extracted files from being ignored for detection.
  • Loading branch information
ClaudioWayne authored Jan 9, 2025
1 parent e21766f commit 70a7781
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions modules/processing/CAPE.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,23 @@ def process_file(self, file_path, append_file, metadata: dict, *, category: str,
# Process CAPE Yara hits
# Prefilter extracted data + beauty is better than oneliner:
all_files = []
for extracted_file in file_info.get("extracted_files", []):
if not extracted_file["cape_yara"]:
continue
if extracted_file.get("data", b""):
extracted_file_data = make_bytes(extracted_file["data"])
else:
extracted_file_data = Path(extracted_file["path"]).read_bytes()
for yara in extracted_file["cape_yara"]:
all_files.append(
(
f"[{extracted_file.get('sha256', '')}]{file_info['path']}",
extracted_file_data,
yara,
for key, value in file_info.get("selfextract", {}).items():
extracted_files = value.get("extracted_files")
for file in extracted_files:
if not file.get("cape_yara", []):
continue
if file.get("data", b""):
extracted_file_data = make_bytes(extracted_file["data"])
else:
extracted_file_data = Path(file["path"]).read_bytes()
for yara in file["cape_yara"]:
all_files.append(
(
f"[{file.get('sha256', '')}]{file_info['path']}",
extracted_file_data,
yara,
)
)
)

# Get the file data
file_data = None
Expand Down

0 comments on commit 70a7781

Please sign in to comment.