Add FileAnalyzer, remove old image_resize artefacts, update foremost output

This commit is contained in:
Zeecka
2026-01-10 23:29:40 +01:00
parent 0ceb174688
commit 24dbdb99c6
7 changed files with 29 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
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()
+1 -1
View File
@@ -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 []
+1 -1
View File
@@ -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"
+2 -1
View File
@@ -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) {
+2
View File
@@ -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),