Sometimes you have to hide stuff that your code does from a reverse engineer’s eye or static analysis tools. To achieve that, I came up with a few helper macros and functions to search for functions at runtime and call them without leaving a trace in the executable’s import table.
TL;DR
Hiding function imports
Let’s take this simple program as an example:
|
|
If you compile it and dump the imports using dumpbin.exe
you will see that the VirtualAlloc
function from kernel32.dll
is imported by our program:
dumpbin.exe /IMPORTS .\RTFNTemplate.exe
|
|
Run dumpbin.exe
again and voila, the import is gone:
Hiding *.dll imports
This is a simple program that downloads a file using the URLDownloadToFileA
which is located in the urlmon.dll
.
|
|
You have to load the DLL file if it’s not already loaded like “kernel32.dll” (maybe use manual DLL mapping to load it to hide LoadLibrary calls).
|
|
The import should be gone now. But keep in mind that the string urlmon.dll
is going to be in you binary. To hide this, use some kind of compile-time string encryption like this: https://github.com/JustasMasiulis/xorstr
strings64.exe .\RTFNTemplate.exe
How it works
…