From 049cec75a948dd98b527c66ec6076c505dc8a7fe Mon Sep 17 00:00:00 2001 From: mint Date: Fri, 28 Nov 2025 16:01:14 +0800 Subject: [PATCH] pr: flooding possible if error is caused during binwalk (Denial of service) --- aperisolve/analyzers/binwalk.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aperisolve/analyzers/binwalk.py b/aperisolve/analyzers/binwalk.py index e8dafba..908f713 100644 --- a/aperisolve/analyzers/binwalk.py +++ b/aperisolve/analyzers/binwalk.py @@ -40,6 +40,10 @@ def analyze_binwalk(input_img: Path, output_dir: Path) -> None: zip_exist = True stderr += zip_data.stderr + # Remove the extracted directory + if extracted_dir.exists(): + shutil.rmtree(extracted_dir) + if len(stderr) > 0: err = { "binwalk": { @@ -50,10 +54,6 @@ def analyze_binwalk(input_img: Path, output_dir: Path) -> None: update_data(output_dir, err) return None - # Remove the extracted directory - if extracted_dir.exists(): - shutil.rmtree(extracted_dir) - output_data = { "binwalk": { "status": "ok",