Getting the Lay of the Land
Last updated
Last updated
When we land on a Windows or Linux system intending to escalate privileges next, there are several things we should always look for to plan out our next moves. We may find other hosts that we can access directly, protections in place that will need to be bypassed, or find that certain tools will not work against the system in question.
We should always look at to view information about the local network and networks around it. We can also gather information about the local domain (if the host is part of an Active Directory environment), including the IP addresses of domain controllers. It is also important to use the command to view the ARP cache for each interface and view other hosts the host has recently communicated with. This could help us with lateral movement after obtaining credentials. It could be a good indication of which hosts administrators are connecting to via RDP or WinRM from this host.
Interface(s), IP Address(es), DNS Information
ARP Table
Routing Table
Most modern environments have some sort of anti-virus or Endpoint Detection and Response (EDR) service running to monitor, alert on, and block threats proactively. These tools may interfere with the enumeration process. They will very likely present some sort of challenge during the privilege escalation process, especially if we are using some kind of public PoC exploit or tool. Enumerating protections in place will help us ensure that we are using methods that are not being blocked or detected and will help us if we have to craft custom payloads or modify tools before compiling them.
This may be used to attempt to block non-admin users from running cmd.exe
or powershell.exe
or other binaries and file types not needed for their day-to-day work. A popular solution offered by Microsoft is . We can use the cmdlet to enumerate the local, effective (enforced), and domain AppLocker policies.
Some EDR tools detect on or even block usage of common binaries such as net.exe
, tasklist
, etc. Organizations may restrict what binaries a user can run or immediately flag suspicious activities, such as an accountant's machine showing specific binaries being run via cmd.exe.
Early enumeration and a deep understanding of the client's environment and workarounds against common AV and EDR solutions can save us time during a non-evasive engagement and make or break an evasive engagement.
Check Windows Defender Status
List AppLocker Rules
Test AppLocker Policy
During an assessment, we may gain a low-privileged shell on a Windows host (domain-joined or not) and need to perform privilege escalation to further our access. Fully compromising the host may gain us access to sensitive files/file shares, grant us the ability to capture traffic to obtain more credentials, or obtain credentials that can help further our access or even escalate directly to Domain Admin in an Active Directory environment. We can escalate privileges to one of the following depending on the system configuration and what type of data we encounter:
The built-in local administrator
account. Some organizations disable this account, but many do not. It is not uncommon to see this account reused across multiple systems in a client environment.
Another local account that is a member of the local Administrators
group. Any account in this group will have the same privileges as the built-in administrator
account.
A standard (non-privileged) domain user who is part of the local Administrators
group.
A domain admin (highly privileged in the Active Directory environment) that is part of the local Administrators
group.
Enumeration is the key to privilege escalation.
OS name
: Knowing the type of Windows OS (workstation or server) and level (Windows 7 or 10, Server 2008, 2012, 2016, 2019, etc.) will give us an idea of the types of tools that may be available (such as the PowerShell
version), or lack thereof on legacy systems. This would also identify the operating system version for which there may be public exploits available.
Running Services
: Knowing what services are running on the host is important, especially those running as NT AUTHORITY\SYSTEM
or an administrator-level account. A misconfigured or vulnerable service running in the context of a privileged account can be an easy win for privilege escalation.
Let's take a more in-depth look.
Other processes such as MsMpEng.exe
, Windows Defender, are interesting because they can help us map out what protections are in place on the target host that we may have to evade/bypass.
The environment variables explain a lot about the host configuration. To get a printout of them, Windows provides the set
command. One of the most overlooked variables is PATH
. In the output below, nothing is out of the ordinary. However, it is not uncommon to find administrators (or applications) modify the PATH
.
The systeminfo
command will show if the box has been patched recently and if it is a VM. If the box has not been patched recently, getting administrator-level access may be as simple as running a known exploit.
Additionally, many guides will say the Network Information is important as it could indicate a dual-homed machine (connected to multiple networks). Generally speaking, when it comes to enterprises, devices will just be granted access to other networks via a firewall rule and not have a physical cable run to them.
WMI can also be used to display installed software. This information can often guide us towards hard-to-find exploits. Is FileZilla
/Putty
/etc installed? Run LaZagne
to check if stored credentials for those applications are installed. Also, some programs may be installed and running as a service that is vulnerable.
Netstat
Users are often the weakest link in an organization, especially when systems are configured and patched well. We may find the system to be well patched, but a member of the local administrators group's user directory is browsable and contains a password file such as logins.xlsx
, resulting in a very easy win.
It is always important to determine what users are logged into a system. Are they idle or active? Can we determine what they are working on?
Knowing what other users are on the system is important as well. If we gained RDP access to a host using credentials we captured for a user bob
, and see a bob_adm
user in the local administrators group, it is worth checking for credential re-use.
One of the best places to look for privilege escalation is the processes that are running on the system. Even if a process is not running as an administrator, it may lead to additional privileges.
The most common example is discovering a web server like IIS or XAMPP running on the box, placing an aspx/php
shell on the box, and gaining a shell as the user running the web server. Generally, this is not an administrator but will often have the SeImpersonate
token, allowing for Rogue/Juicy/Lonely Potato
to provide SYSTEM permissions.
Display Active Network Connections
The main thing to look for with Active Network Connections are entries listening on loopback addresses (127.0.0.1
and ::1
) that are not listening on the IP Address (10.129.43.8
) or broadcast (0.0.0.0
, ::/0
).
The reason for this is network sockets on localhost are often insecure due to the thought that "they aren't accessible to the network."
Beacon starts a named pipe of \.\pipe\msagent_12
Beacon starts a new process and injects command into that process directing output to \.\pipe\msagent_12
Server displays what was written into \.\pipe\msagent_12
Windows systems use a client-server implementation for pipe communication. In this type of implementation, the process that creates a named pipe is the server, and the process communicating with the named pipe is the client. Named pipes can communicate using half-duplex
, or a one-way channel with the client only being able to write data to the server, or duplex
, which is a two-way communication channel that allows the client to write data over the pipe, and the server to respond back with data over that pipe.
Listing Named Pipes with Pipelist
Additionally, we can use PowerShell to list named pipes using gci
(Get-ChildItem
).
From the output above, we can see that only administrators have full access to the LSASS process, as expected.
Using accesschk
we can search for all named pipes that allow write access with a command such as accesschk.exe -w \pipe\* -v
and notice that the WindscribeService
named pipe allows READ
and WRITE
access to the Everyone
group, meaning all authenticated users.
From here, we could leverage these lax permissions to escalate privileges on the host to SYSTEM.
The highly privileged NT AUTHORITY\SYSTEM
account, or account which is a highly privileged account with more privileges than a local administrator account and is used to run most Windows services.
This is very handy for performing manual enumeration tasks.
Version
: As with the OS , there may be public exploits that target a vulnerability in a specific version of Windows. Windows system exploits can cause system instability or even a complete crash. Be careful running these against any production system, and make sure you fully understand the exploit and possible ramifications before running one.
It is essential to become familiar with standard Windows processes such as , , , , and , among others and the services associated with them.
In addition to the PATH, set
can also give up other helpful information such as the HOME DRIVE. In enterprises, this will often be a file share. Navigating to the file share itself may reveal other directories that can be accessed. It is not unheard of to be able to access an "IT Directory," which contains an inventory spreadsheet that includes passwords. Additionally, shares are utilized for home directories so the user can log on to other computers and have the same experience/files/desktop/etc. (). This may also mean the user takes malicious items with them. If a file is placed in USERPROFILE\AppData\Microsoft\Windows\Start Menu\Programs\Startup
, when the user logs into a different machine, this file will execute.
Google the KBs installed under to get an idea of when the box has been patched. This information isn't always present, as it is possible to hide hotfixes software from non-administrators. The System Boot Time
and OS Version
can also be checked to get an idea of the patch level. If the box has not been restarted in over six months, chances are it is also not being patched.
If systeminfo
doesn't display hotfixes, they may be queriable with using the WMI-Command binary with to display patches.
We can do this with PowerShell as well using the cmdlet.
We can, of course, do this with PowerShell as well using the cmdlet.
The command will display active TCP and UDP connections which will give us a better idea of what services are listening on which port(s) both locally and accessible to the outside. We may find a vulnerable service only accessible to the local host (when logged on to the host) that we can exploit to escalate privileges.
Many cheat sheets are available to help us, such as
In Windows, are used to describe the security context (security attributes or rules) of a process or thread. The token includes information about the user account's identity and privileges related to a specific process or thread. When a user authenticates to a system, their password is verified against a security database, and if properly authenticated, they will be assigned an access token. Every time a user interacts with a process, a copy of this token will be presented to determine their privilege level.
One of the best examples of this type of privilege escalation is the Splunk Universal Forwarder
, installed on endpoints to send logs into Splunk. The default configuration of Splunk did not have any authentication on the software and allowed anyone to deploy applications, which could lead to code execution. Again, the default configuration of Splunk was to run it as SYSTEM$ and not a low privilege user. For more information, check out and .
Another overlooked but common local privilege escalation vector is the Erlang Port
(25672). Erlang is a programming language designed around distributed computing and will have a network port that allows other Erlang nodes to join the cluster. The secret to join this cluster is called a cookie. Many applications that utilize Erlang will either use a weak cookie (RabbitMQ uses rabbit
by default) or place the cookie in a configuration file that is not well protected. Some example Erlang applications are SolarWinds, RabbitMQ, and CouchDB. For more information check out the
The other way processes communicate with each other is through Named Pipes. Pipes are essentially files stored in memory that get cleared out after being read. Cobalt Strike uses Named Pipes for every command (excluding ). Essentially the workflow looks like this:
Pipes are used for communication between two applications or processes using shared memory. There are two types of pipes, and anonymous pipes. An example of a named pipe is \\.\PipeName\\ExampleNamedPipeServer
We can use the tool from the Sysinternals Suite to enumerate instances of named pipes.
After obtaining a listing of named pipes, we can use to enumerate the permissions assigned to a specific named pipe by reviewing the Discretionary Access List (DACL), which shows us who has the permissions to modify, write, read, or execute a resource. Let's take a look at the LSASS
process. We can also review the DACLs of all named pipes using the command .\accesschk.exe /accepteula \pipe\
.
Let's walk through an example of taking advantage of an exposed named pipe to escalate privileges. This is a great example.