The mapi32.dll is a stub DLL that acts as a proxy for MAPI API calls. Pretty much all its exported functions start with a GetProxyDllEx routine that tries very hard to find a target email client library that will deliver the requested functionality offered by a standardized MAPI interface.
The GetProxyDllEx routine is pretty complicated as it attempts to handle many cases – many of which are catering for various architectural choices Microsoft made around MAPI over last 3 decades. Okay, I lied, it’s actually more boring than complicated, and since I am always triggerhappy when it comes to quick wins, I will just describe one below.
As a side note, from a forensic perspective, the following registry entry may be of interest:
HKLM\SOFTWARE\Clients\Mail\AlwaysUseLegacyMapiRegistration
It determines how the MAPI provider DLL is being searched for. If it doesn’t exist, or the value is not 1, the search will focus primarily on the modern RoGetActivationFactory function; otherwise, it will search the MAPI providers the old-fashioned way (via Registry enumeration of HKLM\Software\Clients\Mail key).
Anyway, back to the quick win…
If we put the file mapisvc.inf in a PATH location, and attempt to load any MAPI API via rundll32.exe f.ex.:
rundll32 mapi32.dll, LaunchWizard
the mapi32.dll will try to load:
C:\Windows\System32\mapi32x.dll
This DLL may or not may be present on the OS, depending on the OS version. So it’s a bit of a Schrödinger phantom DLL. If you are lucky, and it doesn’t exist, it can be used to host a payload…
Note: the mapi32x.dll file name is hard coded and used in situations when a better MAPI DLL file cannot be found. In many cases there may be Email clients present on the system that will configure email client entries that will take precedence over mapi32x.dll, so YMMV and you simply need to test it for your specific scenario. Remember it’s a quick win, and these are usually low quality 🙂