You Don't Need Fancy Tools to Detect Evil


Some Threat Hunters believe you need a big budget and fancy tools to perform effective threat hunting. If that's the case, the tool is the Threat Hunter, not the person.

Here, I will guide you on how to hunt for persistence on Windows hosts using the tools you already have at your disposal.

One of my go-to tools to detect persistence is Microsoft Sysinternals Autoruns. This free utility from Microsoft has the most comprehensive knowledge of the auto-starting locations of any startup monitor. It displays the programs configured to run during system bootup or login and when you start various built-in Windows applications .

Link to Autroruns:

https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns

 

The competent we will use within this zip file is autorunsc64.exe, or if you have a 32-bit version of Windows, autorunsc.exe. This is a command line interface (CLI) for autoruns. We need to get into the detail of autorunsc. However, we will use the -a switch for "autostart entry selection" with the wildcard *. This will look for all autostart entries. 


 

 Sample Output:

 

You may be thinking cool, but that does not scale. Any command can scale if you script it. Before we can script it, we first need to get authorization from the host, and for that, we will read the binary in and covert to base64. Below is the script to do just that. 


Now that we have converted the binary to base64, we can embed it into a PowerShell script, convert it back to a binary, write it to disk, and run it. This technique can be used on any binary file. If you need to check for FromBase64String Powershell commands, you should. Below is a script with the base64 autrorunsc embedded that runs our autorunsc command. Note since the base64 string is so long the gist truncated the preview.  

 

We created a self-contained PowerShell script that will return all autostart entries on Windows. But how do you run it on every Windows host? It depends on your environment. You could use SCCM, GPO, EDR, or a vulnerability scanner. Yes, vulnerability scanner. In my case, Nessus. 


In Nessus, you can upload your audit files, which allow the test assessment powershell_args, which runs a PowerShell command. The only problem is that everything needs to be on a single line. This is an easy fix. We need to do some PowerShell command chaining using a semicolon. 

Comments

Popular posts from this blog

Mapping CIS Critical Controls to Gartner Markets

Malware Can Hide But It Must Run

PCAP Doesn't Lie Part 2