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: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ add_executable(moria
src/extract/android_sparse.cpp
src/extract/ext.cpp
src/extract/reiserfs.cpp
src/extract/nilfs2.cpp
src/extract/jffs2.cpp
src/extract/ubifs.cpp
src/extract/tar.cpp
Expand Down Expand Up @@ -256,6 +257,7 @@ if(Python3_Interpreter_FOUND)
test_esp32_nvs
test_legacy_fs
test_reiserfs_extract
test_nilfs2_extract
test_romfs_sizecap
test_luks
test_lzma
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ moria --help

Unpacked in-process, no external tools and no sudo:

- **Filesystems:** SquashFS, ext2/3/4, F2FS, FAT12/16/32, exFAT, NTFS, HFS+/HFSX, XFS, btrfs, JFFS2, UBI/UBIFS, romfs, YAFFS2, cramfs, EROFS, ReiserFS
- **Filesystems:** SquashFS, ext2/3/4, F2FS, FAT12/16/32, exFAT, NTFS, HFS+/HFSX, XFS, btrfs, JFFS2, UBI/UBIFS, romfs, YAFFS2, cramfs, EROFS, ReiserFS, NILFS2
- **Archives and images:** ZIP, tar, cpio, MS-CAB (stored/MSZIP/LZX), CFBF compound files / Windows Installer `.msi`, ISO 9660, Android sparse, Android boot
- **Kernels and wrappers:** U-Boot uImage, U-Boot FIT, Windows CE XIP ROM (nk.bin / .cos), standalone gzip / xz / zstd / lz4 streams, Ingenic jzlzma (hardware LZ77)
- **Firmware packages:** RAE Systems / Honeywell RFP (section table; LZARI-decompresses each section); Artosyn OTRA (AR8030 / VT4 / VR04; SHA-256-verified, LZO1X-decompresses each partition, or exposes the raw flash body on flat images)
Expand Down
2 changes: 1 addition & 1 deletion fuzz/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mapfile -t SRCS < <(find src -name '*.cpp' ! -name 'main.cpp' | sort)
# Xcode clang lacks the libFuzzer runtime; override with a clang that has it
# (e.g. CXX=/opt/homebrew/opt/llvm/bin/clang++ on macOS).
CXX="${CXX:-clang++}"
for target in fuzz_scan fuzz_esp32_part fuzz_esp32_nvs fuzz_lzx fuzz_reiserfs; do
for target in fuzz_scan fuzz_esp32_part fuzz_esp32_nvs fuzz_lzx fuzz_reiserfs fuzz_nilfs2; do
"$CXX" -std=c++20 -O1 -g -fsanitize=fuzzer,address -I src -I third_party \
-DFT_FUZZ_SIGDIR="\"$PWD/signatures\"" \
"${SRCS[@]}" "fuzz/${target}.cpp" -o "$target"
Expand Down
32 changes: 32 additions & 0 deletions fuzz/fuzz_nilfs2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// fuzz_nilfs2.cpp — libFuzzer entry point for the NILFS2 extractor.
// Feeds fuzzer bytes to the parse-only read chain (superblock selection, super
// root, DAT translation, cpfile, ifile, directory walk, block maps) with a
// partition at offset 0, and to the full scan pipeline so the identify/validator
// path also sees adversarial input (issue #64).
//
// Build via fuzz/build.sh. Run: ./fuzz_nilfs2 -max_total_time=60
#include <cstddef>
#include <cstdint>
#include <span>

#include "extract/nilfs2.hpp"
#include "reader.hpp"
#include "scan.hpp"
#include "sigload.hpp"

#ifndef FT_FUZZ_SIGDIR
#define FT_FUZZ_SIGDIR "signatures"
#endif

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
static const ft::LoadResult sigs = ft::load_signatures(FT_FUZZ_SIGDIR);
ft::Reader reader(std::span<const uint8_t>(data, size));

// Direct: the whole read chain with the filesystem at offset 0.
ft::nilfs2_probe(reader, 0);

// Via the pipeline: magic-driven identification on the raw bytes.
auto findings = ft::scan(reader, sigs.signatures);
(void)findings;
return 0;
}
4 changes: 2 additions & 2 deletions moria.1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ embedded formats (filesystems, containers, bootloaders, executables,
compression, media) with byte offsets and confidence tiers. It is
identification-first; with
.B \-\-extract
it also unpacks SquashFS, ext2/3/4, F2FS, JFFS2, UBIFS, romfs, YAFFS2, cramfs, FAT, exFAT, NTFS, HFS+, XFS, btrfs, EROFS, ReiserFS, and ISO9660 filesystems, ZIP/tar/cpio/MS-CAB archives, CFBF compound files (Windows Installer .msi), U-Boot uImage/FIT containers, Windows CE XIP ROM images and registry hives, RAE Systems/Honeywell RFP firmware packages (LZARI-decompressing their sections), and Ingenic jzlzma-compressed kernel/rootfs images (hardware LZ77)
it also unpacks SquashFS, ext2/3/4, F2FS, JFFS2, UBIFS, romfs, YAFFS2, cramfs, FAT, exFAT, NTFS, HFS+, XFS, btrfs, EROFS, ReiserFS, NILFS2, and ISO9660 filesystems, ZIP/tar/cpio/MS-CAB archives, CFBF compound files (Windows Installer .msi), U-Boot uImage/FIT containers, Windows CE XIP ROM images and registry hives, RAE Systems/Honeywell RFP firmware packages (LZARI-decompressing their sections), and Ingenic jzlzma-compressed kernel/rootfs images (hardware LZ77)
internally (no sudo). Every other format is still identified and located by offset, ready for another tool such as binwalk.
.PP
Output is human-readable by default. A single file shows a findings tree
Expand Down Expand Up @@ -55,7 +55,7 @@ List tar/cpio/zip/MS-CAB member names and sizes, or a Windows CE ROM's modules a
.SS Extract
.TP
.BR \-e ", " \-\-extract
Unpack identified SquashFS, ext2/3/4, F2FS, JFFS2, UBIFS (incl. UBI), romfs, YAFFS2, cramfs, FAT, exFAT, NTFS, EROFS, ReiserFS, and ISO9660 filesystems, ZIP/tar/cpio/MS-CAB archives, CFBF compound files such as Windows Installer .msi packages, U-Boot uImage/FIT containers, Android boot/sparse images, Windows CE XIP ROM images, Windows CE registry hives, and RAE Systems/Honeywell RFP firmware packages into
Unpack identified SquashFS, ext2/3/4, F2FS, JFFS2, UBIFS (incl. UBI), romfs, YAFFS2, cramfs, FAT, exFAT, NTFS, EROFS, ReiserFS, NILFS2, and ISO9660 filesystems, ZIP/tar/cpio/MS-CAB archives, CFBF compound files such as Windows Installer .msi packages, U-Boot uImage/FIT containers, Android boot/sparse images, Windows CE XIP ROM images, Windows CE registry hives, and RAE Systems/Honeywell RFP firmware packages into
.IR file .extracted/
(one subdir per region, named
.IR 0x<offset>\-<type> ).
Expand Down
2 changes: 2 additions & 0 deletions src/extract/manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "extract/fat.hpp"
#include "extract/iso9660.hpp"
#include "extract/jffs2.hpp"
#include "extract/nilfs2.hpp"
#include "extract/ntfs.hpp"
#include "extract/otra.hpp"
#include "extract/rae_rfp.hpp"
Expand Down Expand Up @@ -58,6 +59,7 @@ Extractor find_extractor(const std::string& type) {
if (type == "romfs") return extract_romfs;
if (type == "cramfs") return extract_cramfs;
if (type == "reiserfs") return extract_reiserfs;
if (type == "nilfs2") return extract_nilfs2;
if (type == "erofs") return extract_erofs;
if (type == "f2fs") return extract_f2fs;
if (type == "android_sparse") return extract_android_sparse;
Expand Down
Loading
Loading