Information to steal
Local machine
Users and groups
Operating System
Processes and software
IMPORTANT: The installed software may save sensitive data in logs, configuration files or the Windows registry. Look closely. Password managers, SSH clients (e.g. Putty), FTP clients, RDP clients often store credentials somewhere.
Services
PowerShell history
Most Administrators use the Clear-History
to clear the PowerShell history. But this cmdlet is only clearing PowerShell's own history, which can be retrieved with Get-History. Starting with PowerShell v5, a module named PSReadline
is included, which is used for line-editing and command history functionality. Interestingly, Clear-History does not clear the command history recorded by PSReadline. PSReadline history can be retrieved.
Another interesting command is Start-Transcript
which starts a PowerShell Transcription and basically dumps everything executed in a PowerShell session to a file. This command contains the path where the transcript file is stored. This transcription file can be also read but there's no easy way to get its path.
There's also a feature called Script Block Logging
. If enabled, it generates events with PowerShell commands of ID 4104.
Files to loot
Searching for interesting files
Password managers
One interesting type of file is password manager databases. Probably the most popular is KeePass with .kdbx
extension. From such a file you can then extract the hash (keepass2john
) and crack it offline.
Automated scanning
There are plenty of tools to automate enumeration and security scanning:
Active Directory
Users and groups
Built-in options:
It's also possible to execute raw LDAP query using LDAPSearch
but it might be difficult.
Raw LDAP queries can be difficult to understand. Here's a source on how to create your own: SpecterOps.io, An Introduction to Manual Active Directory Querying.
Extensions:
Advanced PowerShell cmdlets like Get-ADUser
are only installed by default on domain controllers as part of the Remote Server Administration Tools (RSAT). RSAT is very rarely present on clients in a domain and we must have administrative privileges to install them. If the RSAT is present, execute import-module ActiveDirectory
to load the AD module to PS session.
However, we can download Active Directory module files from GitHub (link) and load them into the current session without administrator privileges.
Another popular option is the PowerView
(link) PowerShell script, which includes many useful functions to execute AD enumeration.
User sessions
Obtain information which user is logged in to which computer using NetSessionEnum
WinAPI function. Most probably regular domain users are not able to execute this function anymore on Windows 11.
PowerShell (PowerView):
Another option is to use PsLoggedOn executable from SysInternals Suite
. It works calling Remote Registry
service (via RPC named pipes) on a target machine. The Remote Registry service has not been enabled by default since Windows 8, but system administrators may enable it for administrative tasks. It is enabled by default on later Windows Servers such as Server 2012, 2016, 2019, 2022.
Machines
PowerShell (PowerView):
Service accounts and Service Principal Name (SPN)
Information about SPNs is stored in AD, it is present on the domain controller. Since service accounts are used to run services, we can assume that they have more privileges than regular domain user accounts. To enumerate SPNs in the domain, we have multiple options. One of them is usage of built-in Windows tool:
PowerShell (PowerView):
Domain shares
PowerShell (PowerView):