9 Hunting Empire
9 Hunting Empire
You will need to extend the techniques mentioned in the course to detect Empire’s presence
on an endpoint.
The objective of this lab is to combine different detection techniques to detect Empire’s
presence on an endpoint. Specifically, you will learn to use EIF, Get-InjectedThread and
NorkNork, in conjunction, to detect Empire on an endpoint.
EIF
EIF Parser
Get-InjectedThread
NorkNork
You:
o IP: 172.16.82.0/24
child-dc01 (the server from where you will start your hunt):
o IP: 10.100.10.253
o VNC Credentials: vnc@3L$-CHILDL0c@l
o Domain Credentials: ELS-CHILD\Administrator | Admin@3L$-CHILDL0c@l*****
UATSERVER [Optional if you want to take a closer look]
o IP: 10.100.11.150
o VNC Credentials: vnc@3L$-CHILDL0c@l
o Domain Credentials: ELS-CHILD\appsvc | la@3L$-CHILDL0c@l
1. Identify the most common technique being used by Empire for process injection.
You can use the internet for that or dive into the Empire Project’s source code.
HINTS: EIF, EIF Parser and Get-InjectedThread.ps1 are detection tools that can assist
you in detecting Empire’s most common process injection technique.
2. In the case of an attack that evaded your first line of defense, you can always catch an
attacker during post-exploitation activities. Identify the most common persistence
techniques employed by Empire. Once again, you can use the internet for that or dive
into the Empire Project’s source code.
HINTS: NorkNork is a detection tool that can assist you in detecting Empire’s most
common persistence mechanisms.
Detecting reflective DLL injection, however, is not an easy task. Malicious code
injected into a process using reflective DLL injection will not touch disk. Process
memory introspection is therefore required to detect this kind of injection.
EIF, EIF Parser and Get-InjectedThread.ps1 will assist you in looking for any PSInject-
like operations on an endpoint. They will actually detect most reflective DLL injection
cases, so, don’t jump into quick conclusions.
2. Empire features multiple persistence mechanisms. Diving into the source code of
Empire, we can see that the registry, WMI, schtasks, debuggers and more are being
abused for persistence.
Any overly large base64 encoded strings stored in the registry or any suspicious-
looking WMI subscriptions can be an indication of Empire’s presence on an endpoint.
*Reflective DLL injection refers to loading a DLL from memory rather than from disk.
This is done through custom functions. Windows does not feature native functionality
to perform reflective DLL loading.
We will start by using the EIF tool to detect if reflective DLL injection has occurred on any of
the running processes of the machine. [EIF will scan the memory of processes that are not
protected]
Use a Linux or Windows VNC client to connect to child-dc01 (10.100.10.253) from where
you will start your hunt, using the provided VNC and Domain credentials above. (Shift +
Ctrl + Alt + Del)
EIF Parser actually deploys EvilInjectFinder.exe into the remote machine and parses the
results. The results are saved into C:\users\Administrator\Desktop\Hunting
Empire\Detection Method 1\EIF_Parser-master\EIF_Results.
For example, we can see that the PowerShell core library System.Management.Automation
is loaded into the explorer.exe process. A word of caution: Many legitimate applications
load PowerShell. You should therefore combine this kind of detection with process
network activity analysis for optimum results.
Additional Indicator: It won’t be surprising to find a full .NET module (PE header present)
while examining the memory of a process against which PSInject was executed.
From inside your VNC session with child-dc01, perform the following.
You should now be confident that some kind of fileless malware is on that endpoint. We are
not yet sure that this malware is Empire. Many Remote Access Tools used by attackers
have the ability to reflectively inject malicious DLLs. Let’s continue our investigation….
Chances are that the malware has also implemented some kind of persistence into
UATSERVER. Let’s use a persistence detection tool called NorkNork to find out.
From inside your VNC session with child-dc01, perform the following.
Inside the “Hunting Empire” folder, which is located on the child-dc01 machine’s
desktop, open the “Detection Method 3” folder and navigate to NorkNork-
master\bin.
Copy NorkNork.exe, open File Explorer and navigate to \\uatserver.els-
child.els.local\c$
Paste NorkNork.exe somewhere into the uatserver.els-child.els.local machine (for
example in C:\ )
Now, from inside child-dc01, open a new PowerShell terminal as Administrator and
execute the following. [Connecting to UATSERVER using PSRemoting]
If you carefully analyze Empire’s source code, you will be able to conclude that the above
script is Empire-derived. The C2 URL format (login/process.php), the XOR routine and the K
variable (that almost certainly contains Empire’s staging key] all resemble the way the
Empire tool operates.
To conclude, in this lab four (3) ways were documented that, when combined, could assist
you in detecting Empire on an endpoint, under your supervision.