Merge pull request #171 from Zeecka/worker/file
Fix #158 - Add FileAnalyzer, remove old image_resize artefacts, update foremost …
This commit is contained in:
@@ -45,6 +45,7 @@ Aperi'Solve is an open-source steganalysis web platform that performs automated
|
|||||||
- [steghide](https://steghide.sourceforge.net/) (extraction with password)
|
- [steghide](https://steghide.sourceforge.net/) (extraction with password)
|
||||||
- [strings](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/strings.html)
|
- [strings](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/strings.html)
|
||||||
- [zsteg](https://github.com/zed-0xff/zsteg) (LSB text/data extraction)
|
- [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).
|
- Worker queue architecture for offloading heavy/slow analyzers (Redis + background workers).
|
||||||
- Results stored for later browsing and download.
|
- Results stored for later browsing and download.
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -22,7 +22,7 @@ class ForemostAnalyzer(SubprocessAnalyzer):
|
|||||||
def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]:
|
def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]:
|
||||||
"""Process the stdout/stderr."""
|
"""Process the stdout/stderr."""
|
||||||
if "Processing" in stderr and "|*|" in stderr:
|
if "Processing" in stderr and "|*|" in stderr:
|
||||||
return stderr.strip().split("\n")
|
return stderr.strip().replace("\n", "")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from os import getenv
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp", ".tiff"]
|
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"
|
RESULT_FOLDER = Path(__file__).parent.resolve() / "results"
|
||||||
REMOVED_IMAGES_FOLDER = Path(__file__).parent.resolve() / "removed_images"
|
REMOVED_IMAGES_FOLDER = Path(__file__).parent.resolve() / "removed_images"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const TOOL_ORDER = [
|
const TOOL_ORDER = [
|
||||||
"decomposer",
|
"decomposer",
|
||||||
|
"file",
|
||||||
"exiftool",
|
"exiftool",
|
||||||
"binwalk",
|
"binwalk",
|
||||||
"foremost",
|
"foremost",
|
||||||
@@ -9,7 +10,7 @@ const TOOL_ORDER = [
|
|||||||
"steghide",
|
"steghide",
|
||||||
"openstego",
|
"openstego",
|
||||||
"zsteg",
|
"zsteg",
|
||||||
"strings",
|
"strings"
|
||||||
];
|
];
|
||||||
|
|
||||||
function escapeHtml(text) {
|
function escapeHtml(text) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ initialize_sentry()
|
|||||||
from .analyzers.binwalk import analyze_binwalk # pylint: disable=C0413
|
from .analyzers.binwalk import analyze_binwalk # pylint: disable=C0413
|
||||||
from .analyzers.decomposer import analyze_decomposer
|
from .analyzers.decomposer import analyze_decomposer
|
||||||
from .analyzers.exiftool import analyze_exiftool
|
from .analyzers.exiftool import analyze_exiftool
|
||||||
|
from .analyzers.file import analyze_file
|
||||||
from .analyzers.foremost import analyze_foremost
|
from .analyzers.foremost import analyze_foremost
|
||||||
from .analyzers.openstego import analyze_openstego
|
from .analyzers.openstego import analyze_openstego
|
||||||
from .analyzers.outguess import analyze_outguess
|
from .analyzers.outguess import analyze_outguess
|
||||||
@@ -103,6 +104,7 @@ def analyze_image(submission_hash: str) -> None:
|
|||||||
(analyze_binwalk, img_path, result_path),
|
(analyze_binwalk, img_path, result_path),
|
||||||
(analyze_decomposer, img_path, result_path),
|
(analyze_decomposer, img_path, result_path),
|
||||||
(analyze_exiftool, img_path, result_path),
|
(analyze_exiftool, img_path, result_path),
|
||||||
|
(analyze_file, img_path, result_path),
|
||||||
(analyze_foremost, img_path, result_path),
|
(analyze_foremost, img_path, result_path),
|
||||||
(analyze_openstego, img_path, result_path, submission.password),
|
(analyze_openstego, img_path, result_path, submission.password),
|
||||||
(analyze_pngcheck, img_path, result_path),
|
(analyze_pngcheck, img_path, result_path),
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ And also in `aperisolve.js` in the `TOOL_ORDER` constant:
|
|||||||
```js
|
```js
|
||||||
const TOOL_ORDER = [
|
const TOOL_ORDER = [
|
||||||
"decomposer",
|
"decomposer",
|
||||||
|
"file",
|
||||||
"exiftool",
|
"exiftool",
|
||||||
"binwalk",
|
"binwalk",
|
||||||
"mytool" // My new tool
|
"mytool" // My new tool
|
||||||
@@ -157,7 +158,6 @@ const TOOL_ORDER = [
|
|||||||
"openstego",
|
"openstego",
|
||||||
"zsteg",
|
"zsteg",
|
||||||
"strings",
|
"strings",
|
||||||
"image_resize",
|
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user