From a8f24d3bd36926a537997c0b1faad5d506ab2a4e Mon Sep 17 00:00:00 2001 From: Quentin Kaiser Date: Fri, 12 Jan 2024 13:20:34 +0100 Subject: [PATCH] fix(handler): extend valid states to 0, 1, and 2. --- .../filesystem/extfs/__input__/ext2.1024.nullstate.img | 3 +++ .../filesystem/extfs/__input__/ext3.1024.nullstate.img | 3 +++ .../filesystem/extfs/__input__/ext4.1024.nullstate.img | 3 +++ .../__output__/ext2.1024.nullstate.img_extract/0-524288.extfs | 3 +++ .../0-524288.extfs_extract/apple.txt | 3 +++ .../0-524288.extfs_extract/banana.txt | 3 +++ .../0-524288.extfs_extract/cherry.txt | 3 +++ .../0-524288.extfs_extract/lost+found/.gitkeep | 0 .../ext2.1024.nullstate.img_extract/524288-524289.padding | 3 +++ .../__output__/ext3.1024.nullstate.img_extract/0-524288.extfs | 3 +++ .../0-524288.extfs_extract/apple.txt | 3 +++ .../0-524288.extfs_extract/banana.txt | 3 +++ .../0-524288.extfs_extract/cherry.txt | 3 +++ .../0-524288.extfs_extract/lost+found/.gitkeep | 0 .../ext3.1024.nullstate.img_extract/524288-524289.padding | 3 +++ .../__output__/ext4.1024.nullstate.img_extract/0-524288.extfs | 3 +++ .../0-524288.extfs_extract/apple.txt | 3 +++ .../0-524288.extfs_extract/banana.txt | 3 +++ .../0-524288.extfs_extract/cherry.txt | 3 +++ .../0-524288.extfs_extract/lost+found/.gitkeep | 0 .../ext4.1024.nullstate.img_extract/524288-524289.padding | 3 +++ unblob/handlers/filesystem/extfs.py | 4 ++-- 22 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/integration/filesystem/extfs/__input__/ext2.1024.nullstate.img create mode 100644 tests/integration/filesystem/extfs/__input__/ext3.1024.nullstate.img create mode 100644 tests/integration/filesystem/extfs/__input__/ext4.1024.nullstate.img create mode 100644 tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs create mode 100644 tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep create mode 100644 tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/524288-524289.padding create mode 100644 tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs create mode 100644 tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep create mode 100644 tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/524288-524289.padding create mode 100644 tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs create mode 100644 tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt create mode 100644 tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep create mode 100644 tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/524288-524289.padding diff --git a/tests/integration/filesystem/extfs/__input__/ext2.1024.nullstate.img b/tests/integration/filesystem/extfs/__input__/ext2.1024.nullstate.img new file mode 100644 index 0000000000..33b50655d1 --- /dev/null +++ b/tests/integration/filesystem/extfs/__input__/ext2.1024.nullstate.img @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13a3e5482e5e95df1cb59109052d20b4fb3b75501b52acedbbb8454b7e1ca922 +size 524289 diff --git a/tests/integration/filesystem/extfs/__input__/ext3.1024.nullstate.img b/tests/integration/filesystem/extfs/__input__/ext3.1024.nullstate.img new file mode 100644 index 0000000000..ff7793a7a9 --- /dev/null +++ b/tests/integration/filesystem/extfs/__input__/ext3.1024.nullstate.img @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbab8888991165b4b2baee41b620ec526b2013cfc9f97d4cfc8b0e3eb81595af +size 524289 diff --git a/tests/integration/filesystem/extfs/__input__/ext4.1024.nullstate.img b/tests/integration/filesystem/extfs/__input__/ext4.1024.nullstate.img new file mode 100644 index 0000000000..0f06a31e44 --- /dev/null +++ b/tests/integration/filesystem/extfs/__input__/ext4.1024.nullstate.img @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f11fa59981143916c137aefc193107174a8e84847d43a71c4532a2c344adea8 +size 524289 diff --git a/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs new file mode 100644 index 0000000000..52691d4cdd --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9730dc5e199b942d41e5afa089f91bc2193ee5fcddd4add44e237bfbba615a32 +size 524288 diff --git a/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt new file mode 100644 index 0000000000..fb25b54492 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:303980bcb9e9e6cdec515230791af8b0ab1aaa244b58a8d99152673aa22197d0 +size 6 diff --git a/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt new file mode 100644 index 0000000000..f822df33ed --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a81483d96b0bc15ad19af7f5a662e14b275729fbc05579b18513e7f550016b1 +size 7 diff --git a/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt new file mode 100644 index 0000000000..3193bfe1b1 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86baf3529da550a44b0681ffa031b6b676e620e9e06dc5ac1119d0cd21cbcf55 +size 7 diff --git a/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/524288-524289.padding b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/524288-524289.padding new file mode 100644 index 0000000000..fd481aab72 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext2.1024.nullstate.img_extract/524288-524289.padding @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b +size 1 diff --git a/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs new file mode 100644 index 0000000000..dfa8e14264 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47bcf9652ef9ff9e5493636dabe9e3bda4dfbb2a9ab7b96d3936c2c12374aa47 +size 524288 diff --git a/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt new file mode 100644 index 0000000000..fb25b54492 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:303980bcb9e9e6cdec515230791af8b0ab1aaa244b58a8d99152673aa22197d0 +size 6 diff --git a/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt new file mode 100644 index 0000000000..f822df33ed --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a81483d96b0bc15ad19af7f5a662e14b275729fbc05579b18513e7f550016b1 +size 7 diff --git a/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt new file mode 100644 index 0000000000..3193bfe1b1 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86baf3529da550a44b0681ffa031b6b676e620e9e06dc5ac1119d0cd21cbcf55 +size 7 diff --git a/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/524288-524289.padding b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/524288-524289.padding new file mode 100644 index 0000000000..fd481aab72 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext3.1024.nullstate.img_extract/524288-524289.padding @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b +size 1 diff --git a/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs new file mode 100644 index 0000000000..5706276ec4 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:714921b8850fc6b6f77e72ae049c5fed9b8880798a3f8bfdb3be228c3bd6dba6 +size 524288 diff --git a/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt new file mode 100644 index 0000000000..fb25b54492 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/apple.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:303980bcb9e9e6cdec515230791af8b0ab1aaa244b58a8d99152673aa22197d0 +size 6 diff --git a/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt new file mode 100644 index 0000000000..f822df33ed --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/banana.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a81483d96b0bc15ad19af7f5a662e14b275729fbc05579b18513e7f550016b1 +size 7 diff --git a/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt new file mode 100644 index 0000000000..3193bfe1b1 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/cherry.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86baf3529da550a44b0681ffa031b6b676e620e9e06dc5ac1119d0cd21cbcf55 +size 7 diff --git a/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/0-524288.extfs_extract/lost+found/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/524288-524289.padding b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/524288-524289.padding new file mode 100644 index 0000000000..fd481aab72 --- /dev/null +++ b/tests/integration/filesystem/extfs/__output__/ext4.1024.nullstate.img_extract/524288-524289.padding @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b +size 1 diff --git a/unblob/handlers/filesystem/extfs.py b/unblob/handlers/filesystem/extfs.py index f3c524f101..1fa8298c48 100644 --- a/unblob/handlers/filesystem/extfs.py +++ b/unblob/handlers/filesystem/extfs.py @@ -28,7 +28,7 @@ class EXTHandler(StructHandler): NAME = "extfs" - PATTERNS = [HexString("53 ef ( 01 | 02 ) 00 ( 00 | 01 | 02 | 03 | 04 ) 00")] + PATTERNS = [HexString("53 ef ( 00 | 01 | 02 ) 00 ( 00 | 01 | 02 | 03 | 04 ) 00")] C_DEFINITIONS = r""" typedef struct ext4_superblock { @@ -67,7 +67,7 @@ class EXTHandler(StructHandler): EXTRACTOR = Command("debugfs", "-R", 'rdump / "{outdir}"', "{inpath}") def valid_header(self, header) -> bool: - if header.s_state not in [0x1, 0x2]: + if header.s_state not in [0x0, 0x1, 0x2]: logger.debug("ExtFS header state not valid", state=header.s_state) return False if header.s_errors not in [0x0, 0x1, 0x2, 0x3]: