Adversaries may establish persistence by executing malicious content triggered by hijacked references to Component Object Model (COM) objects. COM is a system within Windows to enable interaction between software components through the operating system. References to various COM objects are stored in the Registry.
Adversaries can use the COM system to insert malicious code that can be executed in place of legitimate software through hijacking the COM references and relationships as a means for persistence. Hijacking a COM object requires a change in the Registry to replace a reference to a legitimate system component which may cause that component to not work when executed. When that system component is executed through normal system operations the adversary's code will be executed instead. An adversary is likely to hijack objects that are used frequently enough to maintain a consistent level of persistence, but are unlikely to break noticeable functionality within the system as to avoid system instability that could lead to detection.
For this example I will search for instances of applications trying to load objects that don't exist.
Process Monitor is a great tool to search for these objects it's part of the Sysinternals Suite and it shows everything in real time. When running procmon we will apply a filter since it gets bloated with a ton of information that in this case won't be necessary, so what we are looking for here is:
· Result is NAME NOT FOUND
· Operations is RegOpenKey
· Path ends with InprocServer32
In a few minutes I get a ton of results, since this is a Clean VM almost everything is from Explorer and Firefox mainly:
One of the things I noticed is probably the times it is being called, In my testing I went for Explorer since it is being called plenty of times in a matter of seconds but It usually failed, I have no idea why, (Please do explain if you know @dmcxblue).
From here create a Simple DLL Project from Visual Studio and have it open a MessageBox, I wrote "Hello hacker", it will need 3 arguments so just use NULL on the other 2 and your last being Hello hacker message.
Once we have our DLL built we will transfer it to the host machine and register it to the proper CLSID but we are assuming here that we have a terminal and not a GUI Desktop so for this simple demo we will.
We will locate the CLSID that we are currently aiming to Hijack and we will change the location of the DLL that it is currently trying to load:
Once we find ti and replace this, we will wait for a while (10 min in my occasion) and we will get greeted with a message (we are trying to gain persistence as an Administrator, but in this Demo I reached for a user level persistence)