diff --git a/README.md b/README.md index 4dd9263..8db4425 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Aperi'Solve is an open-source steganalysis web platform that performs automated - [steghide](https://steghide.sourceforge.net/) (extraction with password) - [strings](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/strings.html) - [zsteg](https://github.com/zed-0xff/zsteg) (LSB text/data extraction) + - [file](https://www.darwinsys.com/file/) (MIME type and format detection) - Worker queue architecture for offloading heavy/slow analyzers (Redis + background workers). - Results stored for later browsing and download. diff --git a/aperisolve/analyzers/file.py b/aperisolve/analyzers/file.py new file mode 100644 index 0000000..bb194c0 --- /dev/null +++ b/aperisolve/analyzers/file.py @@ -0,0 +1,25 @@ +# flake8: noqa: E203,E501,W503 +# pylint: disable=C0413,W0718,R0903,R0801 +# mypy: disable-error-code=unused-awaitable +"""File Analyzer for Image Submissions.""" +from pathlib import Path + +from .base_analyzer import SubprocessAnalyzer + + +class FileAnalyzer(SubprocessAnalyzer): + """Analyzer for the `file` command.""" + + def __init__(self, input_img: Path, output_dir: Path) -> None: + super().__init__("file", input_img, output_dir) + self.cmd = ["file", "-b", self.img] + + def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]: + """Process the stdout into a list of lines.""" + return stdout + + +def analyze_file(input_img: Path, output_dir: Path) -> None: + """Analyze an image submission using `file`.""" + analyzer = FileAnalyzer(input_img, output_dir) + analyzer.analyze() diff --git a/aperisolve/analyzers/foremost.py b/aperisolve/analyzers/foremost.py index 85a667b..2c71322 100644 --- a/aperisolve/analyzers/foremost.py +++ b/aperisolve/analyzers/foremost.py @@ -22,7 +22,7 @@ class ForemostAnalyzer(SubprocessAnalyzer): def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]: """Process the stdout/stderr.""" if "Processing" in stderr and "|*|" in stderr: - return stderr.strip().split("\n") + return stderr.strip().replace("\n", "") return [] diff --git a/aperisolve/config.py b/aperisolve/config.py index 340ac24..11c8ce1 100644 --- a/aperisolve/config.py +++ b/aperisolve/config.py @@ -7,7 +7,7 @@ from os import getenv from pathlib import Path IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp", ".tiff"] -WORKER_FILES = ["binwalk", "foremost", "steghide", "zsteg", "image_resize", "openstego", "pcrt"] +WORKER_FILES = ["binwalk", "foremost", "steghide", "zsteg", "openstego", "pcrt"] RESULT_FOLDER = Path(__file__).parent.resolve() / "results" REMOVED_IMAGES_FOLDER = Path(__file__).parent.resolve() / "removed_images" diff --git a/aperisolve/static/js/aperisolve.js b/aperisolve/static/js/aperisolve.js index af973c7..ac22bed 100644 --- a/aperisolve/static/js/aperisolve.js +++ b/aperisolve/static/js/aperisolve.js @@ -1,5 +1,6 @@ const TOOL_ORDER = [ "decomposer", + "file", "exiftool", "binwalk", "foremost", @@ -9,7 +10,7 @@ const TOOL_ORDER = [ "steghide", "openstego", "zsteg", - "strings", + "strings" ]; function escapeHtml(text) { diff --git a/aperisolve/workers.py b/aperisolve/workers.py index cb6e467..8da3463 100644 --- a/aperisolve/workers.py +++ b/aperisolve/workers.py @@ -16,6 +16,7 @@ initialize_sentry() from .analyzers.binwalk import analyze_binwalk # pylint: disable=C0413 from .analyzers.decomposer import analyze_decomposer from .analyzers.exiftool import analyze_exiftool +from .analyzers.file import analyze_file from .analyzers.foremost import analyze_foremost from .analyzers.openstego import analyze_openstego from .analyzers.outguess import analyze_outguess @@ -103,6 +104,7 @@ def analyze_image(submission_hash: str) -> None: (analyze_binwalk, img_path, result_path), (analyze_decomposer, img_path, result_path), (analyze_exiftool, img_path, result_path), + (analyze_file, img_path, result_path), (analyze_foremost, img_path, result_path), (analyze_openstego, img_path, result_path, submission.password), (analyze_pngcheck, img_path, result_path), diff --git a/docs/adding-analyzer.md b/docs/adding-analyzer.md index 24069a9..4be6466 100644 --- a/docs/adding-analyzer.md +++ b/docs/adding-analyzer.md @@ -146,6 +146,7 @@ And also in `aperisolve.js` in the `TOOL_ORDER` constant: ```js const TOOL_ORDER = [ "decomposer", + "file", "exiftool", "binwalk", "mytool" // My new tool @@ -157,7 +158,6 @@ const TOOL_ORDER = [ "openstego", "zsteg", "strings", - "image_resize", ]; ```