Reusing binary code from malware is one of my favorite topics. Binary re-engineering and being able to bend compiled code to your will is really just an amazing skill. There is also something poetic about taking malware decryption routines and making them serve you.
Over the years this topic has come up again and again. Previous articles have included emit based rips , exe to dll conversion , emulator based approaches , and even converting malware into an IPC based decoder service .
The above are all native code manipulations which makes them something you can work with directly. Easy to disassemble, easy to debug, easy to patch. (Easy being a relative term of course :))
Lately I have been working on VB6 P-Code, and developing a P-Code debugger. One goal I had was to find a way to call a P-Code function, ripped from a malware, with my own arguments. It is very powerful to be able to harness existing code without having to recreate it (including all of its nuances.)
Is this even possible with P-Code? As it turns out, it is possible, and I am going to show you how.
The distilled knowledge below is small slice