Skip to content

lzma: also anchor on props 0x6D (OpenWrt lc1/lp2/pb2 kernels) - #56

Closed
fengqiaoqu wants to merge 1 commit into
nmatt0:masterfrom
fengqiaoqu:lzma-props-6d
Closed

fengqiaoqu wants to merge 1 commit into
nmatt0:masterfrom
fengqiaoqu:lzma-props-6d

Conversation

@fengqiaoqu

@fengqiaoqu fengqiaoqu commented Oct 17, 2026 •

Copy link
Copy Markdown

Fixes #45.

The standalone LZMA signature only anchored on 5d0000, so streams with any other props byte were never offered to the validator. OpenWrt builds its kernels with lzma e -lc1 -lp2 -pb2 (props 0x6D), which is why the kernel at 0x200 of the Archer C7 factory image from the issue was missed.

This adds a second [[magic]] anchor for 6d0000 and updates the comments that described 5D 00 00 as the only anchor. The validator is unchanged: it already accepts any props up to 224 and trial-decodes to the end marker, so a stray 6d 00 00 in unrelated data is rejected the same way a stray 5d 00 00 is.

I kept it to the one value seen in the wild rather than enumerating more props bytes. The wildcard-anchor idea from the issue would be the general fix, but it needs schema support and seemed like a separate change.

Testing:

  • tests/test_lzma.py gets a new case: a props-0x6D stream (Python's lzma with lc=1, lp=2, pb=2) embedded at 0x200, checked for a single verified finding at that offset and a byte-exact -e extraction. It fails on master and passes with this change.
  • On openwrt-23.05.5-ath79-generic-tplink_archer-c7-v2-squashfs-factory.bin, moria -A now reports lzma at 0x200 (7837801 bytes, dict 8 MiB, verified) alongside the squashfs at 0x23af40. Scan time on that image went from 0.88 s to 0.97 s, which is the trial decode of the kernel itself.
  • moria_unit, test_samples.py, test_extract.py, test_rae_rfp.py, test_vbf.py, plus the lzma/jzlzma/upx/carve/partition tests all pass on a -Wall -Wextra Release build (gcc, Debian 13).

The .lzma-alone header has no magic, and the signature only matched
props 0x5D. OpenWrt compresses its kernels with lc1/lp2/pb2 (props
0x6D), so the kernel at 0x200 in its factory images went unreported.
Add a 6d0000 anchor; the validator's trial decode still filters stray
matches. Extend test_lzma.py with an embedded 0x6D stream.

Fixes nmatt0#45
@nmatt0

nmatt0 commented Oct 17, 2026

Copy link
Copy Markdown
Owner

already fixed in #57

@nmatt0 nmatt0 closed this Oct 17, 2026
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.

LZMA magic anchor only matches props 0x5D — misses OpenWrt kernel at 0x200 (props 0x6D)

2 participants