+8
-5
@@ -26,17 +26,20 @@ RUN wget https://github.com/syvaidya/openstego/releases/download/openstego-0.8.6
|
|||||||
dpkg -i /tmp/openstego.deb && \
|
dpkg -i /tmp/openstego.deb && \
|
||||||
rm /tmp/openstego.deb
|
rm /tmp/openstego.deb
|
||||||
|
|
||||||
# Clean up apt cache and remove useless packages
|
# Copy application
|
||||||
RUN apt-get remove -y wget && \
|
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY aperisolve/ /aperisolve/
|
COPY aperisolve/ /aperisolve/
|
||||||
|
|
||||||
RUN mkdir -p /data
|
RUN mkdir -p /data
|
||||||
|
|
||||||
|
# Install Python dependencies
|
||||||
RUN pip install --no-cache-dir -r /aperisolve/requirements.txt
|
RUN pip install --no-cache-dir -r /aperisolve/requirements.txt
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Auto clean after build
|
||||||
|
RUN apt-get remove -y wget && \
|
||||||
|
apt-get autoremove -y && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info", "--capture-output", "aperisolve.wsgi:application"]
|
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info", "--capture-output", "aperisolve.wsgi:application"]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from .utils import MAX_PENDING_TIME, update_data
|
from .utils import MAX_PENDING_TIME, update_data
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ def analyze_binwalk(input_img: Path, output_dir: Path) -> None:
|
|||||||
stderr = ""
|
stderr = ""
|
||||||
# Run binwalk
|
# Run binwalk
|
||||||
data = subprocess.run(
|
data = subprocess.run(
|
||||||
["binwalk", "-e", "../" + str(image_name), "--run-as=root"],
|
["binwalk", "--matryoshka", "-e", "../" + str(image_name), "--run-as=root"],
|
||||||
cwd=output_dir,
|
cwd=output_dir,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
@@ -47,16 +48,17 @@ def analyze_binwalk(input_img: Path, output_dir: Path) -> None:
|
|||||||
# Only report error if stderr exists AND extraction failed.
|
# Only report error if stderr exists AND extraction failed.
|
||||||
# If zip_exist is True, binwalk worked (despite warnings), so we proceed.
|
# If zip_exist is True, binwalk worked (despite warnings), so we proceed.
|
||||||
if len(stderr) > 0 and not zip_exist:
|
if len(stderr) > 0 and not zip_exist:
|
||||||
err = {
|
err: dict[str, dict[str, Any]] = {
|
||||||
"binwalk": {
|
"binwalk": {
|
||||||
"status": "error",
|
"status": "error",
|
||||||
|
"output": data.stdout.split("\n") if data else [],
|
||||||
"error": stderr,
|
"error": stderr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_data(output_dir, err)
|
update_data(output_dir, err)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
output_data = {
|
output_data: dict[str, dict[str, Any]] = {
|
||||||
"binwalk": {
|
"binwalk": {
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
"output": data.stdout.split("\n") if data else [],
|
"output": data.stdout.split("\n") if data else [],
|
||||||
|
|||||||
@@ -252,6 +252,38 @@ function parseResult(result) {
|
|||||||
|
|
||||||
analyzer.innerHTML += `<h2>${capitalize(tool.replace("_"," "))}</h2>`;
|
analyzer.innerHTML += `<h2>${capitalize(tool.replace("_"," "))}</h2>`;
|
||||||
|
|
||||||
|
// Parse text output
|
||||||
|
if (typeof result[tool]["output"] === "string") {
|
||||||
|
analyzer.innerHTML += `<pre>${escapeHtml(
|
||||||
|
result[tool]["output"]
|
||||||
|
)}</pre>`;
|
||||||
|
} else if (Array.isArray(result[tool]["output"])) {
|
||||||
|
if (result[tool]["output"].length > 0) {
|
||||||
|
var texarea_content = `<div class="textarea-container">`;
|
||||||
|
texarea_content += `<textarea class="form-control w-100 mb-2" rows="8" readonly>`;
|
||||||
|
for (const line of result[tool]["output"]) {
|
||||||
|
texarea_content += escapeHtml(`${line}\n`);
|
||||||
|
}
|
||||||
|
texarea_content += `</textarea>`;
|
||||||
|
texarea_content += `<i class="fas fa-copy copy-icon"></i>`;
|
||||||
|
texarea_content += `</div>`;
|
||||||
|
analyzer.innerHTML += texarea_content;
|
||||||
|
}
|
||||||
|
} else if (typeof result[tool]["output"] === "object") {
|
||||||
|
var table_content = `<div class="table-container">`;
|
||||||
|
table_content += `<table>`;
|
||||||
|
for (const key in result[tool]["output"]) {
|
||||||
|
table_content += `<tr><td>${escapeHtml(key)}</td>`;
|
||||||
|
table_content += `<td>${escapeHtml(
|
||||||
|
result[tool]["output"][key]
|
||||||
|
)}</td></tr>`;
|
||||||
|
}
|
||||||
|
table_content += `</table>`;
|
||||||
|
table_content += `</table>`;
|
||||||
|
analyzer.innerHTML += table_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse images, downloads, ...
|
||||||
if (result[tool]["status"] === "ok") {
|
if (result[tool]["status"] === "ok") {
|
||||||
if ("images" in result[tool]) {
|
if ("images" in result[tool]) {
|
||||||
// Parse image output
|
// Parse image output
|
||||||
@@ -286,41 +318,6 @@ function parseResult(result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse text output
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof result[tool]["output"] === "string") {
|
|
||||||
analyzer.innerHTML += `<pre>${escapeHtml(
|
|
||||||
result[tool]["output"]
|
|
||||||
)}</pre>`;
|
|
||||||
} else if (Array.isArray(result[tool]["output"])) {
|
|
||||||
if (result[tool]["output"].length > 0) {
|
|
||||||
var texarea_content = `<div class="textarea-container">`;
|
|
||||||
texarea_content += `<textarea class="form-control w-100 mb-2" rows="8" readonly>`;
|
|
||||||
for (const line of result[tool]["output"]) {
|
|
||||||
texarea_content += escapeHtml(`${line}\n`);
|
|
||||||
}
|
|
||||||
texarea_content += `</textarea>`;
|
|
||||||
texarea_content += `<i class="fas fa-copy copy-icon"></i>`;
|
|
||||||
texarea_content += `</div>`;
|
|
||||||
analyzer.innerHTML += texarea_content;
|
|
||||||
}
|
|
||||||
} else if (typeof result[tool]["output"] === "object") {
|
|
||||||
var table_content = `<div class="table-container">`;
|
|
||||||
table_content += `<table>`;
|
|
||||||
for (const key in result[tool]["output"]) {
|
|
||||||
table_content += `<tr><td>${escapeHtml(key)}</td>`;
|
|
||||||
table_content += `<td>${escapeHtml(
|
|
||||||
result[tool]["output"][key]
|
|
||||||
)}</td></tr>`;
|
|
||||||
}
|
|
||||||
table_content += `</table>`;
|
|
||||||
table_content += `</table>`;
|
|
||||||
analyzer.innerHTML += table_content;
|
|
||||||
} else {
|
|
||||||
// analyzer.innerHTML += `<pre>${result[tool]["output"]}</pre>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("download" in result[tool]) {
|
if ("download" in result[tool]) {
|
||||||
// Parse download link
|
// Parse download link
|
||||||
analyzer.innerHTML += `<br/><a href="${escapeHtml(
|
analyzer.innerHTML += `<br/><a href="${escapeHtml(
|
||||||
|
|||||||
Reference in New Issue
Block a user