Persistence identification
We'll begin our script by making the assumption that you have received an alert within your EDR (Endpoint detection and response) platform of choice and are aware of a malicious binary that has been executed on an endpoint. From here, as we've learned in past chapters, it will be key to identifying persistence mechanisms (methodologies that malware utilizes to run on the system each time the system reboots, or a user logs in) that have been established by the malware, meaning it may continue to run regardless of user action.
Let's now move on to a few code examples that will help to triage the most common persistence methodologies.
Registry keys
As previously discussed in the preceding section, there are four primary Run Keys within the Windows operating system. Other methods of persistence within the Windows registry exist as well, but for now, we'll focus on the four primary ones:
HKEY_LOCAL_MACHINE\Software\Microsoft...