PowerShell Empire A Comprehensive Guide
PowerShell Empire A Comprehensive Guide
This guide will teach you how to use PowerShell Empire to perform privilege
escalation, install persistence mechanisms, and dump credentials. Along the
way, you will discover why this C2 framework is so popular in the security
community, its main components, and how to use them.
So put on your hacker hat, and let’s get started emulating adversaries in this
comprehensive guide to the PowerShell Empire framework!
You can run the Empire Server and Empire Client on the same machine as a
local process or run the Empire Server on a separate machine. In this guide,
both components are run on the same machine for simplicity.
You can find a detailed breakdown and comparison of all the popular C2
frameworks in the C2 Matrix Project. This project aims to point you to the
best C2 framework to suit your testing needs.
Penetration testers and red teamers will often use a C2 framework over a
penetration testing framework, such as Metasploit, for several reasons:
Modern security solutions that gather PowerShell logs (or block it entirely)
severely impact PowerShell Empire’s capabilities.
The framework has a learning curve for new users who need to understand
PowerShell scripting and how the framework functions.
Installation
Now you know what PowerShell Empire is and what it is used for, let’s see
how to use it. To start with PowerShell Empire, you first need to install it on
your machine. You can do this on Kali Linux by running:
PowerShell Empire Stagers connect to the Empire Server. They then create
an Agent which you interact with and use to control compromised systems.
To allow Stagers to connect to the server, you need to create a Listener for
them to connect back to. These Listeners will “listen” for a connection from
an Empire Stager and generate an Agent when a Stager connects.
This will create a Listener on port number 80 of the Empire Server (your local
PC) and show you the all the options options being used. You can customize
this Listener by adjusting these options. For example, to change the name of
the Listener, run set Name MyListener and to change the network port
the Listener is listening on set Port 80. To save these options and start
the Listener, run the execute command.
You can then re-inspect the Listener’s options by running the
command options.
Execute the command back to return from the Listener’s interface. You can
then view all active Listeners on the Empire Server with the
command listeners.
Stagers
Now that your Listener is up and running, you need to create a Stager.
A Stager is a piece of code that executes a payload on the target machine,
which connects back to your Listener. This payload contains the functionality
needed to generate an Agent that lets you remotely control the
compromised system while initiating the Encrypted Key Exchange
protocol to protect the C2 communication.
Executables (.exe)
Shellcode
Your Listener and Stager are now created. The final step is to execute
the Stager you created on the target system. This will generate a
new Agent once it connects back to the Empire Server, which allows you to
control the target machine remotely.
First, transfer the Stager you created to the target machine. PowerShell
Empire will tell you where this Stager was written to when you ran
the execute command.
When you have transferred this Stager to your target machine, run it.
Back in PowerShell Empire, type agents to see a list of active Agents.
Here you see a new Agent has been created after your Stager connected
back. However, it has a complicated name (H97R1ZN8). To change
the Agent name, run the command rename H97R1ZN8 MyAgent and interact
with the Agent by running interact MyAgent.
Modules
To perform actions against the target machine, you need to use PowerShell
Empire’s Modules. Each Module performs a specific function, such as
collecting browser data, dumping passwords, exploiting local vulnerabilities,
establishing persistence, performing reconnaissance, and moving laterally.
PowerShell Empire has over 400 modules for you to use, written in
PowerShell, Python, and C#. Let’s take a look at some popular ones.
Privilege Escalation
Persistence
Here you can see the module ran successfully. You can adjust the name of
the scheduled task, what time it is executed, and where it is hidden on the
system by editing the Module’s configuration options. This lets you better
obfuscate your persistence mechanism and evade network detection.
Dumping Credentials
This module extracts the NTLM hashes of local user accounts stored in the
target system’s registry. You can crack these extracted password hashes to
reveal the plaintext passwords with a password cracking tools like Hydra, or
use them to perform lateral movement through the pass-the-hash attack.
To see if the module was successful, try interacting with the Agent again.
The module was successful and shows the NTLM hashes of several users. You
can also see several Empire Agents that have disconnected and stopped
connecting back to the Listener. Disconnected Agents are shown in red.
You can dump other credentials, such as Kerberos tickets, access tokens,
browser data, and more, using PowerShell Empire Modules. Here are a few of
the other Modules you can take advantage of.
Module
Module Description Example Module
Category
You have learned about the three components that make up the PowerShell
Empire framework; the Empire Server, the Empire Client, and the Starkiller
GUI tool. You then saw how to use the framework by starting a Listener,
creating and executing a Stager, and performing post-exploitation activities
on a target machine through an Agent and PowerShell Empire’s Modules.