Search Order Hijacking ( Preloading )
Last updated
Last updated
The directory from which the application is loaded
The system directory
The 16-bit system directory
The Windows directory
The current directory (same as 1 unless otherwise specified)
The directories that are listed in the PATH environment variable
When the operating system starts the search for a DLL that the application is importing, unless a full path is specified the directory from which the application was loaded is searched first. If the DLL does not exist there, the system directory is searched next and so on. The abuse occurs when the attackers, having observed the behaviour of an application, place their own DLL earlier in the search order so the application loads that DLL instead of continuing the search.
In this example the target is the google crash handler binary which is signed and trusted. in order to identify the modules that the executable attempts to load and could potentially be hijacked, we use SysInternal's Procmon (same as before) with the following filters:
After applying the filters, we get the following candidate DLLs:
Exploitation
In order to weaponize the GoogleCrashHandler.exe, we created a custom DLL that executes the reverse shell. We named the output DLL wkscli.dll, placed it in the same directory the GoogleCrashHandler executable image exists. We then opened GoogleCrashHandler. The next picture shows the rogue DLL was mapped in the address space of GoogleCrashHandler and a beacon was launched.
And if we check the listener we have a reverse shell from target system.