Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update && \
build-essential \
bzip2 \
cabextract \
clang \
cpio \
cramfsswap \
curl \
Expand All @@ -26,8 +27,12 @@ RUN apt-get update && \
gzip \
lhasa \
libarchive-dev \
libfontconfig1-dev \
liblzma-dev \
liblzo2-dev \
liblz4-dev \
libbz2-dev \
libssl-dev \
libmagic1 \
locales \
lz4 \
Expand All @@ -44,9 +49,11 @@ RUN apt-get update && \
squashfs-tools \
srecord \
tar \
unar \
unrar \
unrar-free \
unyaffs\
unzip \
wget \
xz-utils \
zlib1g-dev \
zstd
Expand Down Expand Up @@ -77,6 +84,15 @@ RUN pip install --upgrade pip && \
python3 -m pip install python-lzo==1.14 && \
poetry config virtualenvs.create false

RUN curl -L -o sasquatch_1.0.deb "https://github.com/onekey-sec/sasquatch/releases/download/sasquatch-v4.5.1-4/sasquatch_1.0_$(dpkg --print-architecture).deb" && \
dpkg -i sasquatch_1.0.deb && \
rm sasquatch_1.0.deb

# Binwalk v3 dependencies
RUN git clone --depth=1 https://github.com/ReFirmLabs/binwalk /binwalk && \
cd /binwalk/dependencies && \
sh -c ./ubuntu.sh

# CramFS no longer in apt - needed by binwalk
RUN git clone --depth=1 https://github.com/davidribyrne/cramfs.git /cramfs && \
cd /cramfs && make && make install
Expand All @@ -85,6 +101,15 @@ RUN git clone --depth=1 https://github.com/davidribyrne/cramfs.git /cramfs && \
RUN git clone --depth=1 https://github.com/rehosting/unblob.git /unblob
RUN cd /unblob && poetry install --only main

# Install Rust
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y

# Add .cargo/bin to PATH
ENV PATH="/root/.cargo/bin:${PATH}"

# Install binwalk v3
RUN cargo install binwalk

# Explicitly install unblob deps - mostly captured above, but some of the .debs get updated and installed via curl
RUN sh -c /unblob/unblob/install-deps.sh

Expand Down
11 changes: 10 additions & 1 deletion src/fw2tar
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import multiprocessing

multiprocessing.set_start_method("fork")

EXTRACTORS=["unblob", "binwalk"]
EXTRACTORS=["unblob", "binwalk", "binwalkv3"]

BAD_SUFFIXES = ['_extract', '.uncompressed', '.unknown', # Filename suffixes that show up as extraction artifacts
'cpio-root', 'squashfs-root', '0.tar'] # squashfs-root-* is special cased below
Expand Down Expand Up @@ -239,6 +239,15 @@ def _extract(extractor, infile, extract_dir, log_file):

signature=True
)
elif extractor == "binwalkv3":
subprocess.run([
"binwalk",
"-eM",
"--log", log_file,
"-q",
infile,
"-C", str(extract_dir)
])
else:
raise ValueError(f"Unknown extractor: {extractor}")

Expand Down