Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/actions/setup-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ runs:
key: venv-${{ hashFiles('poetry.lock') }}-${{ inputs.python-version }}

- name: Poetry install
run: UNBLOB_BUILD_RUST_EXTENSION=1 poetry install
run: UNBLOB_BUILD_RUST_EXTENSION=1 poetry install --with dev
shell: bash
22 changes: 7 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ attrs = "^21.2.0"
structlog = "^21.2.0"
arpy = "^2.2.0"
rarfile = "^4.0"
ubi-reader = { git = "https://github.com/onekey-sec/ubi_reader.git", rev = "8c956d47b28af4085366e2acfee8d3ba016f6e90" }
ubi-reader = "^0.8.5"
python-lzo = "^1.14"
cstruct = "2.1"
jefferson = { git = "https://github.com/onekey-sec/jefferson.git", rev = "51de1f5ba3255ed707bb402bee89e442e11b55c1" }
Expand Down
16 changes: 15 additions & 1 deletion unblob/handlers/filesystem/ubi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import shutil
import statistics
from pathlib import Path
from typing import Optional

from structlog import get_logger
Expand Down Expand Up @@ -95,14 +97,26 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]
)


class UBIExtractor(Command):
Comment thread
qkaiser marked this conversation as resolved.
def extract(self, inpath: Path, outdir: Path):
super().extract(inpath, outdir)
# ubireader_extract_images creates a superfluous directory named
# after the UBI file (inpath here), so we simply move the files up
# and delete the remaining directory.
superfluous_dir_path = outdir.joinpath(inpath.name)
for file_path in superfluous_dir_path.iterdir():
shutil.move(file_path.as_posix(), outdir.as_posix())
shutil.rmtree(superfluous_dir_path.as_posix())


class UBIHandler(Handler):
NAME = "ubi"

_UBI_EC_HEADER = b"UBI#"

PATTERNS = [HexString("55 42 49 23 01 // UBI# and version 1")]

EXTRACTOR = Command("ubireader_extract_images", "{inpath}", "-o", "{outdir}")
EXTRACTOR = UBIExtractor("ubireader_extract_images", "{inpath}", "-o", "{outdir}")

def _guess_peb_size(self, file: File) -> int:
# Since we don't know the PEB size, we need to guess it. At the moment we just find the
Expand Down