Windows

Get Help

# List available commands
help

# Help for a specified command
help <command>
<command> /?

Networking

All the below commands work with both CMD and Powershell.

General networking information, such as interfaces, IP addresses, and DNS:

ipconfig /all
Test-NetConnection -ComputerName 192.168.210.12 -Port 5985

System

General enumeration:

# General system information
systeminfo

# Name of the host
hostname

# Operating system version
[environment]::OSVersion.Version

# Environment variables
dir env:

# Named pipes
gci \\.\pipe\

# Clipboard
Get-Clipboard

Applications:

# Installed applications
> Get-WmiObject -Class Win32_Product |  select Name, Version

# installed applications (registry key queries)
# 32-bit apps
> Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
> GCI 'c:\program files (x86)'

# 64-bit apps
> Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
> GCI 'c:\program files'

Processes:

# List running processes
> tasklist
> Get-Process
# Information about a specific process
> Get-Process -Id <PID>
> tasklist /FI "PID eq <PID>"
> Get-Process -Name <process-name> | Format-list *

Services:

# Services hosted in each process
tasklist /svc

Users & Groups

# Domain/username (domain-joined) or NetBIOS/username (non domain-joined)
whoami # can be used to infer the purpose and type of the machine

# List current user's privileges
whoami /priv

# List current user's information
whoami /all

# List local users (net.exe only lists user objects, not group objects, so it can miss nested group memberships)
net user /domain
Get-LocalUser

# Query about the specified user
net user robert /domain

# List active (logged-on) users (works only on Windows Servers)
query user

Shared Resources

All the below commands work with both CMD and Powershell.

# List resources
net share

Protections

Check WD's status with PS:

Get-MpComputerStatus

Check WD's status with CMD:

sc query windefend

Files

# List all (including) hidden files
Get-ChildItem -Force
# All dirs and files
GCI C:\Users\User -Force 
# Only hidden files
GCI C:\Users\User\ -Hidden

# Search for a specific file
Get-ChildItem -Path C:\ -Filter local.txt -Recurse -ErrorAction SilentlyContinue -Force

# Config files, temp saves
GCI C:\Users\User\AppData

# Check PS's host type
$Host.Name
# PS history of the current user
(Get-PSReadlineOption).HistorySavePath

# PS history file of another user
Get-Content C:\Users\<user>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

# KeePass database files
Get-ChildItem -Path C:\ -Include *.kdbx -File -Recurse -ErrorAction SilentlyContinue

# XAMPP configuration files
Get-ChildItem -Path C:\xampp -Include *.txt,*.ini -File -Recurse -ErrorAction SilentlyContinue

# Documents in the user's home directory
Get-ChildItem -Path C:\Users\dave\ -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx -File -Recurse -ErrorAction SilentlyContinue

Writable Directories

C:\Windows\System32\spool\drivers\color
C:\Windows\Tasks
C:\Users\Public # similar to \Temp but more stealthy
C:\Windows\Temp # all users have rwx
C:\Users\<user>\AppData\Local\Temp # similar to above, but user-only
C:\windows\tracing
C:\Windows\Registration\CRMLog
C:\Windows\System32\FxsTmp
C:\Windows\System32\com\dmp
C:\Windows\System32\Microsoft\Crypto\RSA\MachineKeys
C:\Windows\System32\spool\PRINTERS
C:\Windows\System32\spool\SERVERS
C:\Windows\System32\Tasks\Microsoft\Windows\SyncCenter
C:\Windows\System32\Tasks_Migrated
C:\Windows\SysWOW64\FxsTmp
C:\Windows\SysWOW64\com\dmp
C:\Windows\SysWOW64\Tasks\Microsoft\Windows\SyncCenter
C:\Windows\SysWOW64\Tasks\Microsoft\Windows\PLA\System

Test access:

# Move into the target directory
cd C:\Windows\Temp
# Create a file
echo "test" > test
# List the file's contents
type test

Use another user's credentials

# Create a PSCredential object
$pass = ConvertTo-SecureString '<password>' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential('<domain\user', $pass)

# Add the target user to the group with PowerView
Add-DomainGroupMember -Identity '<group>' -Members '<user>' -Credential $creds

# Confirm
Get-DomainUser <user> -Credential $cred

# Execute remote commands on another host
Invoke-Command -Computer DC -Credential $cred -ScriptBlock { whoami; hostname }

Binaries

We can transfer the binary in a Unix-based attacking host and run strings on it:

# strings with 16-bit encoding for Windows binaries
strings -eb <FILE> | grep pass

Last updated

Was this helpful?