3 ms·
Ah yes, right up my alley. Sort of. I spent many months reverse engineering a SC8 executable for fun, yep purely for fun. 10 years ago now. I have more experie
by farmdve 3y ago
Ah yes, right up my alley. Sort of. I spent many months reverse engineering a SC8 executable for fun, yep purely for fun. 10 years ago now.
I have more experience with SecuROM 8. Did you guys know there is a hidden flag that is parsed on executable running that initializes a separate application which generates a file you can send to the authors of SecuROM that holds the version of SecuROM and quite a lot of other details?
Opaque predicates, VM, simple code integrity checks(int 3), xchg used as control flow obfuscation? It was all there. It took me a while to get the program running under a debugger. Once I did there were a bunch of threads running which would detect tampering or pausing of the threads and kill the process. After suspending those I could do whatever I want.
The DRM used a lot of control flow methods, especially hardware breakpoints and UD2 instruction.
At the time of Unicorn engine's popularity I made a custom plugin to emulate the zlib code embedded inside to search for hidden API calls, unfortunately due to the way QEMU emitted some instructions for the helpers some instructon hooks were called a few times more e.g those with a rep prefix severely skewing instruction counting.
Anyway, VM hunting was difficult. The VM had quite a few single-threaded VM contexts so it could run a lot of programs. From then on it was a matter of reverse engineering the opcodes. at the time I used Olly to trace and log the instruction handlers and opcodes and then using Notepad++ magic I could clean it up from the control flow in a single coherent picture.
Honestly I've forgotten most of it now.
But a few years ago I did write my own Control flow graph generator in Java just to find the 20 or 30 thousand code integrity checks and trace them statically and then was going to use it on the VM.
The most unusual thing is, I often communicated with one of the devs of SecuROM on IRC, of course I did not ask him anything nor did he reveal anything, that is of course illegal. I remember asking him about the little "Cut my life into pieces" tidbit he left just after VMEnter.
Needless to say it is thanks to SecuROM that I gained an interest in RE. Yes I was a novice and dived deep down into a commercial DRM. Thanks to it I learned a lot and is helping me even today, yep as I type this I am working on a SH2 architecture firmware.
But back in the day SecuROM inspired me to write this little ugly thing https://github.com/farmdve/TextVM https://github.com/farmdve/TextVM
- markus_zhang 3y agoThanks for sharing. I'm not a student of the RE art so just curious about what you just said -- by saying VM did you mean the whole SC8 is running some core code inside a VM (of course within the same executable)? I assume that the intermediate code is definitely not public so people like you have to RE all those stuffs too?
- farmdve 3y agoIt's called an Obfuscation Virtual Machine running custom opcodes. These opcodes were decoded in a special way and a single x86 instruction like mov imm, reg would get translated in 20-30 instructions most of them junk, but they were not laid out contiguously, you would execute one junk instruction and then return to the dispatcher to get to the next one, if I remember correctly. This made the VM and tracing dog slow. Additionally it used a small 256 or 1024 byte scratch buffer for the virtual registers that held data. I've forgotten now how it was exactly. The entire VM used only jmp instructions which was how you would spot it.
- markus_zhang 3y agoThanks. I got the idea. Looks like they really wanted to slow you guys down :D I wonder if modern AI could solve that for you. "Oh look, that huge block essentially just set some variable to 127".