Add a VMProtect-packed ELF whose version tables are not at their file offsets - #230
Add a VMProtect-packed ELF whose version tables are not at their file offsets#230zardus wants to merge 1 commit into
Conversation
… offsets cle reads DT_VERNEED and DT_VERDEF through pyelftools, which wants a file offset. Every ELF tracked here puts those tables at an RVA that is also a valid file offset, so nothing covers the case where the two differ: over the 940 tracked paths whose content is an ELF at 0166109 there are 578 DT_VERNEED and 40 DT_VERDEF entries, and all 618 have RVA == file offset. tests/x86_64/vmprotect_sample1.vmp.bin is vmp_binaries/binaries/sample1.vmp.bin from JonathanSalwan/VMProtect-devirtualization at 971be45920b504586a9c94fc7df941f8f57261b1, byte-identical to the sample attached to angr/cle#383 in 2023. sha256 b7b577bd569a10cdd1c660c28c8e78e8ae35af8add43f0f57766d899dbd03564 Its DT_VERNEED is 0xCE3808 against an image base of 0x400000, so the RVA is 0x8E3808 in a 0x2E847B-byte file, while the table really begins at file offset 0x2E3808. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head The fileExpected CI: no check. One added path, The source repository, checked anonymously: Why it is neededOver the 940 tracked paths whose content is an ELF at The consumer
A green gate that skipped a suite is green over less than it appears to be: This repository runs no test suite of its own, so nothing here executes against the file. session: sharpen |
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS What this file is for: import cle
ld = cle.Loader("binaries/tests/x86_64/vmprotect_sample1.vmp.bin", auto_load_libs=False)
obj = ld.main_object
print(obj)
print(sorted({s.version for s in obj.symbols if s.version}))
print(len([s for s in obj.symbols if s.version not in (None, "*local*", "*global*")]))
for name in ("printf", "__gxx_personality_v0", "_ZNSs6appendEPKcm"):
print(name, sorted({s.version for s in obj.symbols if s.name == name}))Before — the RVA cle master 0e77ade3After — with the consumer's one-line-each fix to with the consumer's change |
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
Problem
Nothing in this repository is a test input for an ELF whose symbol-version tables sit at a
virtual address that is not also a valid file offset, so cle's ELF loader cannot be tested
against one. Measured over the 940 tracked paths whose content is an ELF at
0166109e: 578DT_VERNEEDentries and 40DT_VERDEFentries, and in every one of the 618 the table's RVA andits file offset are the same number.
Root cause
An RVA is a usable file offset wherever a segment still sits at the image base plus its own file
offset. The count above is the measurement: at
0166109enothing tracked here puts a versiontable anywhere else.
Fix
Add
tests/x86_64/vmprotect_sample1.vmp.bin, a VMProtect-packed x86-64 ELF, 3048571 bytes,sha256
b7b577bd569a10cdd1c660c28c8e78e8ae35af8add43f0f57766d899dbd03564.Its seven
PT_LOADsegments carry five differentp_vaddr - p_offsetdeltas, up to0xA00000.DT_VERNEEDis0xCE3808and the image base is0x400000, so the RVA is0x8E3808—0x5FB38Dbytes past the end of a0x2E847B-byte file — while the table reallybegins at file offset
0x2E3808,0x600000lower.It is a published third-party sample:
vmp_binaries/binaries/sample1.vmp.bininJonathanSalwan/VMProtect-devirtualization
at
971be45920b504586a9c94fc7df941f8f57261b1, the last commit to touch that path, andbyte-identical to the sample the reporter attached to angr/cle#383 in 2023. All three copies
hash to the sha256 above. GitHub reports no licence for that repository (
"license": null) andit has no top-level
LICENSEfile; every licence text in it sits underpin/licensing/andbelongs to the Intel Pin distribution it vendors.
Testing
Loading it under cle master raises
ELFParseError: expected 2, found 0. The consumer is apull request against
angr/cleaddingtests/test_symbol_versions.py, which fixes that andasserts on this file; it references this one, so GitHub cross-links the two. This repository
runs no test suite of its own, so nothing here reads the file.
Expected CI: no check runs and no commit statuses, which is what this repository's three most
recent pull requests each carry.
Validation: #230 (comment)
🤖 Generated with Claude Code
session: sharpen