Skip to content

[AUTOMATED] List embedded images and archives, and name them in decompiled code - #1682

Merged
mahaloz merged 6 commits into
Noelo-Lab:mainfrom
coleleavitt:fix/blobs-inventory
Nov 19, 2026
Merged

mahaloz merged 6 commits into
Noelo-Lab:mainfrom
coleleavitt:fix/blobs-inventory

Conversation

@coleleavitt

Copy link
Copy Markdown
Contributor

[AUTOMATED]

A PNG, JPEG, GIF, zip or gzip stored whole in a data section showed only as string fragments of its header, and the code that returns it printed a bare address.

/* blob.c: a 1x1 PNG */
static const unsigned char logo[] = {
  0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
  0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde, 0x00, 0x00, 0x00,
  0x0c, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0xf8, 0xcf, 0xc0, 0x00,
  0x00, 0x03, 0x01, 0x01, 0x00, 0xc9, 0xfe, 0x92, 0xef, 0x00, 0x00, 0x00,
  0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
const unsigned char *get_logo(unsigned *n) { *n = sizeof logo; return logo; }
clang -O2 -c blob.c -o blob.o && ld.lld -shared -o blob.so blob.o && llvm-strip blob.so
kuna strings blob.so; kuna decompile blob.so get_logo
0x2d1	ascii	5	.rodata	0	-	PNG\r\n
0x2db	ascii	5	.rodata	0	-	\rIHDR

unsigned long get_logo(unsigned int *a0)
{
  *a0 = 0x45;
  return 0x2d0;
}

With this change kuna blobs blob.so prints 0x2d0 png 69 .rodata 1 get_logo, and the function is unsigned char * get_logo(...) returning png_2d0.

The change

  • kuna blobs <binary> [--json] [--extract DIR] [--kind LIST] [--section NAME] [--no-xrefs] lists each embedded PNG, JPEG, GIF, BMP, ICO, zip, gzip, xz and zstd file with its address, exact length, section and the functions that reference it. --extract writes the files out.
  • The scanner (kuna-analysis/src/analyzers/blobs) treats a magic number as a candidate only. A file is reported when its container walks to its end: PNG chunks to IEND with every CRC-32, JPEG markers to EOI, GIF blocks to the trailer, the BMP size against its pixel array, an ICO directory of PNG or DIB images, the zip end record and central directory, a gzip stream inflated to its trailer CRC-32, the xz footer and index CRC-32s, zstd frame and block headers. No pixels are decoded, and a truncated PNG is not reported.
  • New option blobs on|off, default on: the same scan runs at load and each file becomes a <kind>_<addr> symbol typed unsigned char[length] where no symbol already covers the address. String fragments inside a file are no longer planted.
  • A constant equal to a file's first address is weighed as a pointer even below the pointer lower bound, unless the function also uses that value as a number. A shared object's read-only data starts in the first page, so without this the repro still printed 0x2d0, with or without a symbol on the array.
  • The input is untrusted: every read is bounds-checked and one scan's work is capped at sixteen times the section size.

Tests

  • tests/stages/kuna-blobs.xml, two passes over a stripped shared object holding a PNG, GIF, JPEG, zip, gzip and a PNG cut before IEND: off prints return 0x3c0;, the default return png_3c0;, and the cut PNG stays 0x720 in both.
  • kuna-cli/tests/blobs_cli.rs (listing, owners, --extract byte for byte, --json, filters) and scanner unit tests for all nine kinds, truncation, damaged checksums, nesting and the work cap.
  • On Qt WebEngine, Telegram Desktop, ClickHouse and Grafana the scan reports 1,694 files; gzip -t, zstd -t, unzip -t and Pillow accept every one.
  • The scan adds about 0.3 s of load on a 170 MB libLLVM.so (the string scan there takes 1.2 s) and under 10 ms on bash. No existing datatest or stage expectation moved.

Fixes #1649

coleleavitt and others added 4 commits November 18, 2026 16:54
…piled code

A PNG, JPEG, GIF, BMP, ICO, zip, gzip, xz or zstd file stored whole in a mapped
section showed only as string fragments of its header, and the code returning
it printed a bare address.

`kuna blobs <binary> [--json] [--extract DIR] [--kind LIST] [--section NAME]
[--no-xrefs]` lists each file with its address, exact length, section and the
functions that reference it. The scanner (kuna-analysis `blobs`) keeps a
magic-number candidate only when its container structure walks to its end
(PNG chunk CRC-32s to IEND, JPEG markers to EOI, the GIF trailer, the BMP size
against its pixel array, an ICO directory of PNG or DIB images, the zip end
record and central directory, a gzip stream inflated to its trailer CRC-32,
the xz footer and index CRC-32s, zstd frame and block headers). No pixels are
decoded, a truncated file is not reported, and one scan's work is capped.

New option `blobs on|off`, default on: the same scan runs at load and each
file becomes a `<kind>_<addr>` symbol typed `unsigned char[length]` where no
symbol covers the address; string fragments inside a file are not planted. A
constant equal to a file's first address is weighed as a pointer even below
the pointer lower bound, unless the function also reads the value as a number,
so a shared object whose read-only data starts in the first page returns
`png_2d0` instead of `0x2d0`.

Fixes Noelo-Lab#1649
Resolves the corpus-count, catalog-count, kuna-cli mod-list and stages-baseline
conflicts with main 3059b7f.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
… state the pointer escape's cost

- kuna blobs lib.a:member works like the other image subcommands (added to
  the archive-member command list, with a CLI test).
- The fixture recipe needs -fcf-protection=full to rebuild byte-for-byte.
- Spec 05 and the option's use_when say that a plain number equal to a
  first-page file's address prints as the file too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
@mahaloz

mahaloz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Pushed three commits on top of d9ae254:

  • fed88d2 merges main 3059b7f. It resolves the corpus-count, catalog-count, kuna-cli mod list and stages-baseline conflicts.
  • b41069f:
    • kuna blobs lib.a:member.o now works. blobs is added to the archive-member command list from [AUTOMATED] Load and decompile members of ar archives (.a) #1675, with a CLI test.
    • The fixture recipe gains -fcf-protection=full. With it, clang/LLD 21 rebuild embedded_blobs_x86_64.so byte-for-byte (SHA-256 1765fc8f…). Without it the .text differs.
    • Spec 05 and the option's use_when now state the cost of the first-page pointer escape. In an lld shared object with a PNG at 0x370, an unrelated unsigned long get_size(void) { return 0x370; } prints return png_370; with an unsigned char * return type. consume(0x370) and p->sz = 0x370 change the same way.
  • 7430c47 re-derives the counts (219 settables, KUNA-CATALOG Analysis-tier: ARM Thumb decode end-to-end (linked fixture) #15 = 227) and regenerates docs/options.md and phase_catalog.json.

The scanner had no false positives on 4,156 binaries (system libraries and tools, Go and Rust toolchains, node, decbench x86-64/ARM/MIPS/PPC, PE). All 1,326 files found pass gzip -t, unzip -t, ImageMagick and a full PNG chunk and IDAT check.

@mahaloz
mahaloz merged commit c6e8190 into Noelo-Lab:main Nov 19, 2026
2 checks passed
@coleleavitt
coleleavitt deleted the fix/blobs-inventory branch November 21, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AUTOMATED] List embedded images and archives in a binary, with exact offsets and lengths

2 participants