Fun with Constrained Programming (2012)
The author built an assembler and toolchain for the obscure, x86-like virtual machine hidden inside WinRAR archives, enabling custom executable code during decompression.
read it Offers a fascinating technical walkthrough of building an assembler and toolchain for the obscure virtual machine built into WinRAR archives.
summary
WinRAR allows custom user-defined bytecode filters executed inside a virtual machine during decompression. Because archives require matching CRCs, arbitrary dynamic output is normally blocked by header checks. The author built an assembler, linker, and ported a dynamic CRC compensation algorithm to make self-modifying, executable RAR files possible.
key points
- WinRAR supports custom filters executed by an x86-like VM with 8 registers and up to 250 million execution cycles.
- The author created rarvmtools, an assembler and toolchain to write and compile custom programs for this hidden VM.
- A port of a dynamic CRC compensation algorithm allows the VM to alter its output at runtime while satisfying archive CRC checks.
who should read it
Systems programmers, reverse engineers, and developers interested in binary formats and quirky virtual machines.
discussion warm
consensus
Commenters are largely surprised and amused by the discovery of a VM inside WinRAR, discussing potential security implications and sharing similar personal filter projects.
Neat! I've messed with something similar for ZPAQ, didn't realize RAR had it as well. And for a long time, this might need (2012)
In my case I wanted to compress CD subcodes, most of the unpredictability for these is from a CRC16 on every frame, so I made a filter to xor that out and then back in. If anyone finds that amusing: https://gist.github.com/hcs64/84d981f42cc9f3cfb0f4fc8b37d447...
Shares a parallel anecdote about writing custom compression filters and handling CRCs for ZPAQ.
Generated by an LLM from the article and thread. Check the sources before relying on it.