454 points · by strangecasts · 8y ago · 80 comments
So we fired it up and within about 2-3 minutes he managed to shoot PID 1 or something like that as the machine rebooted. Boss was not happy.
The key detail I'll never forget is his "Oh fuck!" face when it happened.
# kill -9 1
Favourite line.
"It gets 2 frames per hour in Branchless DOOM!"
>Q: Why did you make this? A: I thought it would be funny.
Amateur.
And it looks like float and int math is handled with lookup tables. yikes! but impressive!
Another important thing here is that it's an unconditional direct jump. A conditional direct jump can still cause speculative execution (e.g. could be vulnerable to Spectre variant 1).
So, encoding logic in dependent movs does not inherently address the cache side channel issue.
History based branch prediction one difference with with explicit branches of course.
So I was hunting a particular pattern to replace, that I knew probably existed. A simple combination of demovfuscator, regex on the "original" asm and eyeballing it succeeded in the end.
Company I came in as a contractor to... Sort of repair codebases and retrain staff, had a product they were getting paid buckets to support.
Unfortunately, someone had broken the codebase quite severely, and they weren't using version control. All we had was a movfuscated release (yay for paranoid managers who go to tech conferences), but needed to fix a certain feature ASAP.
So I used demovfuscator, someone's memory of what the code once looked like, and some ASM know-how to tear out references to the old and inject the new. Took a couple months of going nowhere fast, but I was pretty far out of my depth.
They don't use movfuscator anymore.
I have also seen a similar obfuscation, although perhaps not using The Movfuscator, many years ago in some shareware. You could probably guess which parts of the code used it; it even looks very distinctive when you open the binary in a text editor for a quick glance.
Malboge is so complicated that nobody can really write a working program.
Brainfuck is so simple that nearly anybody can write it, but reverse-engineering it is a massive time-sink.
I also wonder if it would be at all possible to eventually speed it up (maybe not to actual play speed, but faster) while remaining branchless and free of speculation. It might be interesting to see if research in Doom could provide faster and more secure solutions in the real world.
HN discussion of trapcc: https://news.ycombinator.com/item?id=5261598
hehe
lol
That was until I installed it on my dad's Pentium 200, the speed increased 3x and I realized it was a completely different beast.