Chapter 06: Exploiting and Pivoting Flashcards
Choosing a Target
Always consider the primary goals of your pentest as it relates to the SOW and RoE
In most cases, you’ll target the most vulnerable systems for yout initial exploitation to gain a foothold and pivot
AD
Active Directory
A central directory service that allows our information to be stored, classified, and retrieved easily
* From here, we can begin looking upwards at the users, groups, OUs, the domain, trees, or even the forests
* Doing this shows us what this host can see and what they can communicate with
* Shows what information might be out there on the network for us to grab
To Do This
PowerShell
* Get-NetDomain: Get the current user’s domain
* Get-NetLoggedon: Get users that are logged on to a given computer
Linux
* cat/etc/passwd: Lists all users on the system
* uname-a: Displays the OS name, version, and other details
* env: Outputs a list of all the environmental variables
Enumeration of Users
This takes many forms:
* Brute force enumeration by attempting logins via a login page or system login
* Use of forgotten password tools to identify legitimate userIDs
* Checking for users by reviewing /etc/passwd
* Gathering user info via AD queries
* Listing users by looking for user directories and other fileystem artifacts
* Querying directory services for an org
* Gathering email addresses from OSINT
* Discovering if user is admin, belongs to certain groups, has roles, etc
Enumeration of Groups
Helps pentesters find other targets who may have similar access rights or who may otherwise make sense to compromise
Groups can also help identify admin users and accounts
/etc/groups on Linux
AD or PowerShell on Windows using local Users and Groups GUI
Enumeration of Forests
In MS AD environments, a forest is the topmost container for the AD environment
Enumerating the forest means enumerating all the objects inside
This can provide a massive amount of data about the computers, users, and other AD contents
In some cases where domains have trust relationships with other domains, it can be possible to enumerate forests that aren’t part of your own domain
Enumeration of Sensitive Data
Challenging because the data may not be in predictable places
Likely to require multiple pieces of information like:
* The org’s or individual’s practices and habits
* Security policies or procedures like encryption or other sensitive data storage techniques
* Compliance requirements that may impact how the data is stored and protected
* Other influences on the data’s storage and format
Enumeration of Unencrypted Files
Can be as simple as using a tool like strings to search for text that isn’t encrypted
More complext techniques take advantage of file entropy (randomness) to programmatically determine whether files are likely encrypted, although it can result in false positives
Many pentests will use cat to quickly view discovered files and filesystems
Metasploit
Full walkthrough of a Metasploit example
Page 206 to 212
PowerSploit
A set of Windows PowerShell scripts designed to provide capabilities like AV bypass, code execution, exfiltration, presistence, reverse engineering, and recon
It will be picked up by Windows Defender and other AV AM tools as soon as you download it
Kali includes PowerSploit by default
One of the most popular tools to use with PowerSploit is Mimikatz, which injects it into memory and then allows you to dump credentials without having Mimikatz on disk where it can be discovered by AV
Empire
A PowerShell and Python based post-exploitation tool
It uses encrypted comms to allow PowerShell agents to run without powershell.exe and it has many modules designed to help with post-exploitation activities on Windows
Similar functionality and interface to Metasploit
BloodHound
A tool used to visualize AD objects and permissions
It can’t be used by itself—you have to acquire AD information and then feed it into BloodHound in order to analyze the data more easily
SharpHound will enumerate the AD domain if you run it as a domain member
RPC/DCOM
Remote Procedure Call / Distributed Component Object Model
Historically, a common way to attack Windows NT, 2000, XP, and 2003 server systems
More modern exploits tend to focus on other elements like the .NET interoperability layers for DCOM
Although RPC/DCOM continuer to appear, the exploits are far less common today
PsExec
The Sysinternals Windows toolkit includes PsExec, a tool designed to allow admins to run programs on remote systems via SMB port 445
If available during a pentest, incredibly useful because you can execute arbitrary commands, up to and including running an interactive shell
Most AV AM tools will flag PsExec the second it lands on a system though
PS Remoting/WinRM
Windows systems running 7 or later use Windows Remote Management (WinRM) to support remote PowerShell command execution
For pentesters, being able to run PowerShell commands on a remote system is awesome, but this feature needs to be turned on first
Remote PowerShell command execution can be turned on using the “enable-PSRemoting -force” command while running PowerShell as admin
If the systems aren’t part of the same domain, you’ll need to set up trust between them using the TrustedHosts settings:
Set-Item wsman:\localhost\client\trustedhosts [ipaddress or hostname]
After doing that, restart WinRM and you can run remote PowerShell commands at will
WMI
Windows Management Instrumentation
Allows for remote management and data gathering installed on all Windows systems, making it an attractive target for pentesters and attackers
Provides access to a huge variety of information from Windows Defender and SNMP to Application Inventory listings
WMI can allow remote execution of commands, file transfers, and data gathering from files and the Registry (and much more)
Multiple PowerShell tools have been written to exploit WMI including WMImplant and WmiSploit
Fileless Malware and Living Off the Land
Fileless Malware
* Used to avoid leaving IoC
* Memory-resident tools insert themselves into legitimate processes to hide from AV AM while allowing attackers to take action like those processes would
Common fileless malware targets for Windows include:
* PowerShell
* WMI
* .NET framework
* Dozens of other options
Living Off the Land
* Once pentesters have successfully used fileless malware to gain access to a system, the next step is living off the land
* Only use existing tools that are on the system
* That includes built-in Linux utilities, Windows commands and PowerShell features, or other accessible tools or programs on the system
Tools like CrackMapExec can be helpful when using LotL techniques—it uses native tools for AD-enabled systems to conduct attacks and supprots pass-the-hash, null session, and more in a single unified shell
Scheduled Tasks and Cron Jobs
Using these to perform actions on a compromised host is tried-and-true method for retaining access
Unlike memory-resident exploits, scheduled tasks and cron jobs can survive system rebootsl