From 7a5a91294fb9d90fd398eb3ebbd721169c448b04 Mon Sep 17 00:00:00 2001 From: 653o Date: Tue, 31 Mar 2026 04:03:39 +0900 Subject: [PATCH 1/4] update binwalk v3 and FirmAE --- docker/scout-emulation/Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/scout-emulation/Dockerfile b/docker/scout-emulation/Dockerfile index c10a4ef..5a0b2f1 100644 --- a/docker/scout-emulation/Dockerfile +++ b/docker/scout-emulation/Dockerfile @@ -31,22 +31,22 @@ RUN apt-get update && apt-get install -y \ RUN python3 -m pip install --no-cache-dir psycopg2-binary coloredlogs python-magic -# Install binwalk (required by FirmAE extractor) -RUN wget -q https://github.com/ReFirmLabs/binwalk/archive/refs/tags/v2.3.4.tar.gz \ - && tar -xf v2.3.4.tar.gz \ - && cd binwalk-2.3.4 \ - && python3 setup.py install \ - && cd / && rm -rf /v2.3.4.tar.gz /binwalk-2.3.4 +# Install binwalk (required by FirmAE extractor) v3 need to edit where to place .cargo +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +RUN . /root/.cargo/env && cargo install binwalk # Clone FirmAE pinned to a specific commit for reproducibility. # To update: pass --build-arg FIRMAE_COMMIT= and rebuild. -RUN git clone --recursive https://github.com/pr0v3rbs/FirmAE.git /opt/FirmAE \ +RUN git clone https://github.com/pr0v3rbs/FirmAE.git /opt/FirmAE \ && cd /opt/FirmAE \ - && git checkout "${FIRMAE_COMMIT}" \ && git submodule update --init --recursive \ && cp /opt/FirmAE/core/unstuff /usr/local/bin/ 2>/dev/null || true \ + && ./download.sh \ + && printf "y\n" | ./install.sh \ && chmod +x /opt/FirmAE/run.sh \ - && ./download.sh + && ln -s /opt/FirmAE/run.sh /usr/local/bin/firmae + + # Initialize PostgreSQL for FirmAE RUN service postgresql start \ From a062072794461d4623a4877ecc46a217d0733f08 Mon Sep 17 00:00:00 2001 From: 653o Date: Tue, 31 Mar 2026 04:11:08 +0900 Subject: [PATCH 2/4] update binwalk to v3 and end firmae installation --- docker/scout-emulation/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/scout-emulation/Dockerfile b/docker/scout-emulation/Dockerfile index c10a4ef..2667a37 100644 --- a/docker/scout-emulation/Dockerfile +++ b/docker/scout-emulation/Dockerfile @@ -42,11 +42,13 @@ RUN wget -q https://github.com/ReFirmLabs/binwalk/archive/refs/tags/v2.3.4.tar.g # To update: pass --build-arg FIRMAE_COMMIT= and rebuild. RUN git clone --recursive https://github.com/pr0v3rbs/FirmAE.git /opt/FirmAE \ && cd /opt/FirmAE \ - && git checkout "${FIRMAE_COMMIT}" \ && git submodule update --init --recursive \ && cp /opt/FirmAE/core/unstuff /usr/local/bin/ 2>/dev/null || true \ && chmod +x /opt/FirmAE/run.sh \ - && ./download.sh + && ./download.sh \ + && printf "y\n" | ./install.sh \ + # through symbolic link 'firmae' to execute from anywhere + ln -s /opt/FirmAE/run.sh /usr/local/bin/firmae # Initialize PostgreSQL for FirmAE RUN service postgresql start \ From d6c5a70dfeda55acd8206c343c560a41855eb611 Mon Sep 17 00:00:00 2001 From: 653o Date: Wed, 1 Apr 2026 02:56:22 +0900 Subject: [PATCH 3/4] Fix Dockerfile: upgrade binwalk to v3 and fix syntax errors --- docker/scout-emulation/Dockerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/scout-emulation/Dockerfile b/docker/scout-emulation/Dockerfile index 2667a37..75a1198 100644 --- a/docker/scout-emulation/Dockerfile +++ b/docker/scout-emulation/Dockerfile @@ -25,30 +25,30 @@ RUN apt-get update && apt-get install -y \ libmagic1 mtd-utils gzip bzip2 cpio lzop lzma squashfs-tools \ unzip p7zip p7zip-full arj lhasa cabextract sleuthkit \ srecord zlib1g-dev liblzma-dev liblzo2-dev \ + # Build & Development for Binwalk v3 + build-essential pkg-config libsodium-dev libfontconfig1-dev libgraphite2-dev \ # Network tools net-tools iproute2 iputils-ping iptables bridge-utils \ && rm -rf /var/lib/apt/lists/* RUN python3 -m pip install --no-cache-dir psycopg2-binary coloredlogs python-magic -# Install binwalk (required by FirmAE extractor) -RUN wget -q https://github.com/ReFirmLabs/binwalk/archive/refs/tags/v2.3.4.tar.gz \ - && tar -xf v2.3.4.tar.gz \ - && cd binwalk-2.3.4 \ - && python3 setup.py install \ - && cd / && rm -rf /v2.3.4.tar.gz /binwalk-2.3.4 +# Install Rust and Binwalk v3 (Rust version) +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN cargo install binwalk # Clone FirmAE pinned to a specific commit for reproducibility. # To update: pass --build-arg FIRMAE_COMMIT= and rebuild. RUN git clone --recursive https://github.com/pr0v3rbs/FirmAE.git /opt/FirmAE \ && cd /opt/FirmAE \ + && git checkout "${FIRMAE_COMMIT}" \ && git submodule update --init --recursive \ && cp /opt/FirmAE/core/unstuff /usr/local/bin/ 2>/dev/null || true \ && chmod +x /opt/FirmAE/run.sh \ && ./download.sh \ && printf "y\n" | ./install.sh \ - # through symbolic link 'firmae' to execute from anywhere - ln -s /opt/FirmAE/run.sh /usr/local/bin/firmae + && ln -s /opt/FirmAE/run.sh /usr/local/bin/firmae # Initialize PostgreSQL for FirmAE RUN service postgresql start \ From 63d7b08a349077be409f8f5e9c63c99d5006c772 Mon Sep 17 00:00:00 2001 From: 653o Date: Wed, 1 Apr 2026 03:36:51 +0900 Subject: [PATCH 4/4] Fix PR review items: pin binwalk v3.1.0, fix extraction.py compatibility, and resolve install.sh duplication --- docker/scout-emulation/Dockerfile | 12 +++--------- src/aiedge/extraction.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/docker/scout-emulation/Dockerfile b/docker/scout-emulation/Dockerfile index 75a1198..650b2e6 100644 --- a/docker/scout-emulation/Dockerfile +++ b/docker/scout-emulation/Dockerfile @@ -33,10 +33,10 @@ RUN apt-get update && apt-get install -y \ RUN python3 -m pip install --no-cache-dir psycopg2-binary coloredlogs python-magic -# Install Rust and Binwalk v3 (Rust version) +# Install Rust and Binwalk v3 (Rust version) - Pin to v3.1.0 RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" -RUN cargo install binwalk +RUN cargo install binwalk@3.1.0 # Clone FirmAE pinned to a specific commit for reproducibility. # To update: pass --build-arg FIRMAE_COMMIT= and rebuild. @@ -47,16 +47,10 @@ RUN git clone --recursive https://github.com/pr0v3rbs/FirmAE.git /opt/FirmAE \ && cp /opt/FirmAE/core/unstuff /usr/local/bin/ 2>/dev/null || true \ && chmod +x /opt/FirmAE/run.sh \ && ./download.sh \ + # FirmAE's install.sh handles PostgreSQL initialization (firmadyne user/db) && printf "y\n" | ./install.sh \ && ln -s /opt/FirmAE/run.sh /usr/local/bin/firmae -# Initialize PostgreSQL for FirmAE -RUN service postgresql start \ - && su - postgres -c "psql -c \"CREATE USER firmadyne WITH PASSWORD 'firmadyne';\"" \ - && su - postgres -c "createdb -O firmadyne firmware" \ - && su - postgres -c "psql -d firmware < /opt/FirmAE/database/schema" \ - && service postgresql stop - COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh diff --git a/src/aiedge/extraction.py b/src/aiedge/extraction.py index f401c6d..1db4fe2 100644 --- a/src/aiedge/extraction.py +++ b/src/aiedge/extraction.py @@ -1036,8 +1036,8 @@ def run(self, ctx: StageContext) -> StageOutcome: argv: list[str] = [binwalk] if self.matryoshka: + # Binwalk v3 removed -d (depth) flag. It handles recursion without depth limits. argv.append("-M") - argv.extend(["-d", str(int(self.matryoshka_depth))]) argv.append("-e") argv.append(str(fw)) try: