githubEdit

Windows Enum

Enumeration

circle-check
circle-info

Be aware sometimes these commands require elevated privileges to be run, or may be blocked by GPO or other means (JEAarrow-up-right for example).

Most commands that run in cmd.exe will also run in PowerShell! This gives many more options and provides flexibility at times. Some commands may not work directly though, and will need to be run through cmd.exe by prefixing the commands with cmd /c

https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEASarrow-up-right = My favorite Windows enumeration script, automates most common enumeration methods.

User Enumeration

Get user information

$env:username Displays the current user's display name

Get-LocalUser | Select * Display usernames, password and account expiration, SID, Description, enabled status

Groups

[Security.Principal.WindowsIdentity]::GetCurrent() Not very good output by default, need to manipulate the object a bit to get the desired information

The below example is better. Will display group name and SIDs. Still not the same as whoami /all though.

List users' home folders

Using WMI

Use either Get-WmiObject or Get-CimInstance to pull information about all local accounts. This can also be used remotely, and to query information about AD accounts.

Get-WmiObject has been deprecated. Only use it if Get-CimInstance is not available due to outdated PowerShell version or problems with Windows Remoting. In most cases the two command names should be replaceable with no issues.

Using ADSI

Can be run on remote machines by substituting $env:computername with the computer name of the remote machine. This returns a large amount of useful information on all users.

circle-info

There is a property called Password, though this did not return anything on my Microsoft Account-enabled machine. Will have to try this on a domain or local account.

Get list of users

Get list of local users

Inferring from user's home folders

Using WMI

Gets display name, description, lockout status, password requirements, login name and domain, and SID.

If run on a domain connected machine dumps all accounts on the whole domain! On a non-domain joined machine lists all local users. Includes Service Accounts.

Groups

Get list of local groups

List group members

PrincipleSource will tell you whether the account is a local, domain, or Microsoft account.

Check for AutoLogon accounts

Active Directory

Enumeration without Active Directory module installed

Using WMI Query Language (WQL)

WQL is an entire subject on its own. If you want to know the full extent of the capabilities of this powerful query language, type Get-Help WQL in a PowerShell prompt. Below are a few examples of queries to pull lists of users from both local machines and from the domain.

circle-info

WQL uses the backslash (\) as its escape character. This is different from Windows PowerShell, which uses the backtick character (`).

LAPS

LAPS allows you to manage the local Administrator password (which is randomized, unique, and changed regularly) on domain-joined computers. These passwords are centrally stored in Active Directory and restricted to authorized users using ACLs. Passwords are protected in transit from the client to the server using Kerberos v5 and AES.

When using LAPS, two new attributes appear in the computer objects of the domain: ms-msc-AdmPwd and ms-mcs-AdmPwdExpirationTime. These attributes contains the plain-text admin password and the expiration time. In a domain environment, it could be interesting to check which users can read these attributes.

Find Administrator Accounts

TODO: Add more examples

Many administrators set their account passwords to never expire, so searching for these can be valuable. Also, this means the password may have been set a long time ago.

Search for passwords

Search for keyword in registry

The /f flag specifies the keyword to search for. In this case the word "password".

Search in Credential Manager

Check SAM and SYSTEM registry hives

If you can access these files and copy them, you can dump credentials for the system.

ntdsutil

The NTDSUtil "Install from media" (IFM) feature can be used to backup NTDS.dit with the one-liner below.

vssown.vbs

  1. Check the status of the Volume Shadow Copy Service (VSS)

2. Start the volume shadow backup service if it is not currently running.

3. Create a backup of the drive

4. Extract any files that were in use that are of interest (ntds.dit/SAM hive, etc.)

File Permissions

Find files/folders where the "Everyone" group has permissions.

This will recursively search the "Program Files" folders, ignoring (most) errors.

More good groups to search for would be the "BUILTIN\Users" or "Domain Users" groups.

Using accesschk.exe (SysInternals)

You can also use accesschk.exe from Sysinternals to check for writeable folders and files.

OS Information

Get OS Version information

Get basic Windows information

Get-ComputerInfo Gives a ton of information about the current hardware and Windows configuration

Get installed patches

Use the -description "Security update" attribute of Get-Hotfix to list only security updates

Drivers

Get a list of installed drivers

Requires an elevated PowerShell prompt:

Specifies that the action is to be taken on the operating system that is currently running on the local computer.

Default log path

$env:windir\Logs\Dism\dism.log

Make back up of all installed drivers

List Environment Variables

Show all current environment variables: Get-ChildItem Env:

Also aliased to: dir env: or ls env: or gci env:

Check Audit (logging) Settings

These settings show what is being logged, this can be useful information for evasion and persistence

Add the -Name $KeyName property to get the value of a specific key.

Windows Event Forwarding

Check where the logs are sent:

Add the -Name $KeyName property to get the value of a specific key.

Antivirus

Check if there is any antivirus installed:

Windows Firewall

Check the status of the Windows Firewall

Use the -Name Public property (instead of -All) to select a specific firewall profile. Pipe the results to | Get-NetFirewallRule to see the currently configured rules.

Clipboard

Get the contents of the clipboard

Get-Clipboard

Software, Services, and Processes

Software

List the installed software

The below PowerShell script will return a more complete list of all software installed by querying SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall on a list of computer names. It displays the following information:

  • Computer Name,

  • Software Name,

  • Version,

  • Publisher

Uninstall Software

If Get-CimInstance is not able to find your software, you can try this instead:

To get PowerShell to display all the programs in the Control Panel, use an asterisk in place of the Name parameter.

circle-info

This command only uninstalls the latest version of a program. If you’ve installed multiple versions use the -RequiredVersion 2.0 property of Get-Package to specify the version to uninstall.

Services

Get a list of services:

Get-Service

Get detailed information for a specific service

sc qc $service_name

circle-check

Enable a disabled service

If you are having this error (for example with SSDPSRV):

System error 1058 has occurred. The service cannot be started, either because it is disabled or because it has no enabled devices associated with it. You can enable it using:

Note: In Windows XP SP1, the service upnphost depends on SSDPSRV to work

Unquoted service paths

Unquoted service paths are paths to services that contain a space in them, that are not surrounded by quotes. These paths can be hijacked to run arbitrary code if the break in the path is a writeable location.

Get running processes

Get-Process

With usernames of process owner

*Admin rights needed to pull owner information

Without usernames

Last updated