date: “2016-12-13” draft: false title: “Windows Survey”
Init
- Situational Awareness
-
ipconfig /all# Host Name, IP Address -
wmic process get executablepath, processid, parentprocessid | more# Unusual processes -
wmic process get commandline# Process args and location -
net service# current running services -
date /t# Get system datetime /t# Get system time
-
ver# system versionnet stats server# uptime and statssysteminfo
PowerShell alternative
-
gwmi win32_networkadapterconfiguration | ft description, ipaddress, defaultipgateway -
gwmi win32_process | select processid, parentprocessid, <executablepath | commandline> | ft -autosize -
gwmi win32_service | select processid, <displayname|name>, state, pathname | sort processid | ft -autosize -
get-date
Networking
- Caches
ipconfig /displaydns# dns cachearp -a# arp cache
-
Listening Ports
- Map service to listening port:
sc query <service># find dlltasklist /FI "services eq <service>"# Find dlllistdlls -d <service>.dll# find PIDnetstat -ano# match PID to PORT
- Map listening port to process:
netstat -ano | findstr EST# find Established connections and PIDnetstat -ano# find listening connection port's PIDtasklist /fi "pid eq <pid>"
- Map service to listening port:
-
NetBIOS
nbtstat -n
- Routes
route print
- Share Usage
net use# Current outbound connectionsnet share# Current shared resources
- Firewall
- XP
netsh firewall show config
- Vista+
netsh advfirewall show allprofilesnetsh advfirewall show currentprofilenetsh advfirewall firewall show rule profile=<PROFILE> name=all
- Allowed programs
netsh firewall show allowedprogram
Users and Domains
- Users
net users# Enumerate usersnet session# Enumerate usersreg querey hklm\system\currentcontrolset\control\hivelist# Look for other users logged on SIDspsloggedon# Look for other users logged onpsloglist "Security" -i 528 -s | find /i "Logon Type: 10"
- Local Policies
secedit /export /cfg c:\seccfg.initype c:\seccfg.ini# show policies
- Auditing
auditpol# Look for actions which will be logged
- Domain Membership
reg query hklm\system\currentcontrolset\services\tcpip\parameters# NV Domainsysteminfo# DomainValues Inference NV Domain absent or empty WORKGROUP NV Domain == systemifo Domain DOMAIN NV Domain != systeminfo Domain WORKGROUP
- SIDs
wmic useraccount where name='<username>' get sidwmic useraccount where sid='S-1-3-12-1234525106-3567804255-30012867-1437' get namepsgetsid <sid>
Hardware
- Identify the number of logical processors on the target system:
wmic cpu get numberoflogicalprocessorspslistprocessor count:- Number of threads in the
systemIDLE process equals processors smssElapsed Time / Idle CPU Time aproximately equals
- Number of threads in the
systeminfo /find /I "processor"
Software
- System info via process lists
pslistInterogated Values Inferred Information System PID = 2 Windows NT System PID = 4 Windows XP+ System PID = 8 Windows 2000 winintandlsmWindows Vista+ one csrssWindows XP/2003 or less more than 2 csrssWindows Vista+ dwmWindows Vista+ MsMpEngWindows Defender NlsSrvSecurity Essentials mssecesSecurity Essentials explorerElapsed TimeLogon time smssElapsed TimeSystem Uptime
- System software integrity
dir /tc /od c:\windows\system32# look for most recent changes in system32 (likely suspect)
- System PATH integrity
reg query "hklm\system\currentcontrolset\control\session manager\environment" /v pathreg query "hkcu\environment" /v path
- AppInit (dll) integrity
-
reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Windows" /v appinit_dllsAll the DLLs that are specified in this value are loaded by each Microsoft Windows-based application that is running in the current log on session. (TODO: move to registry.md, link to there)
- Enumerate Persistance Vectors
autorunsc <-b|-l># show boot and logon auto startupsreg query hklm\software\microsoft\windows\currentversion\runreg query hkcu\software\microsoft\windows\currentversion\runreg query hklm\software\microsoft\windows\currentversion\runoncereg query hkcu\software\microsoft\windows\currentversion\runoncereg query hklm\software\microsoft\windows\currentversion\winlogon /v shell
- Evaluate Files (exe, dll, sys, etc)
dir /O:D /T:[A|C|W]
- Evaluate Anti-Virus Protection
wmic /namespace:\\root\securitycenter2 path antivirusproduct get displayname /format:list
or
- make a copy of killav.rb with only the file names, one per line (avlis.txt)
$av = gc avlist.txt$p = gwmi win32_process | sort name -unique | select name$p | ?{$av -contains $_.Name}# display the intersection of processes names and anti-virus names
#EVENT LOGS
Read or get data from an event log:
:WMIC NTEVENT WHERE SourceName=“security” GET Message,EvenTtype /FORMAT:HTABLE > c:\winmgmtevents.htm (htable formats for htlm)
:powershell get-winevent -path C:\Windows\System32\winevt\Logs\Security.evtx
sc
wevtutil eq
Get last 10 entries from a log file: powershell get-eventlog security -newest 10 | format-list psloglist security -n 10 :wevtutil query-events security /count:10 /rd:true /format:xml WMIC NTEVENT WHERE “LogFile=‘application’” :powershell get-winevent -newest 10 -path C:\Windows\System32\winevt\Logs\Security.evtx
Search an event log for an event type:
auditpol security -f “success audit”
psloglist -s -t “\t” -n 20 Security | findstr /n /i “Success Audit”
Find all events with creating a new user:
To find all of the appropriate new user events, you will need to first get the user SID
wmic useraccount where name=‘username’ get sid where ‘username’ would be ‘icarus’
use the psloglist and findstr commands to find the relevant entries in the event logs.
psloglist -s -t “\t” -n 20 Security | findstr /n /i .SID.
0. USERS
Enable a user account:
wmic useraccount where name=“vhalen” set disabled=“False”
Get information on a specific user:
:wmic useraccount where name=“username” get /all /format:list
Get all group and user information:
:wmic path w32_account get /format:list
Find currently logged on user:
reg query “HKCU\Volatile Environment” /v homepath
Reg query “hklm\software\microsoft\windows nt\currentversion\profilelist” Gets you SID
List everything about a user:
wmic useraccount where name=‘rblum’ get /format:list
Find who was the last user to log onto a system:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v defaultusername
Disabling a user account:
wmic useraccount where name=‘john’ set disabled=true
For re-enabling user account:
wmic useraccount where name=‘john’ set disabled=false
Set password to never expire:
wmic useraccount where name=‘tstark’ set PasswordExpiores=false
- DOCUMENTS AND TIMESTAMPS Get version of a file wmic datafile where name=“path_filename” get version Get timestamps dir /t C A W - Create, LastAccess, Last Write gci | select * will show all the options you can select gci | select name, LastWriteTime, LastWriteTimeUTC
#MISC
List the system directory
wmic os get systemdirectory /value