breakfixlearn.com

SEC-05Cybersecurity

Windows & PowerShell for defenders

Use this when: you check a Windows PC or server for signs of compromise: logons, new accounts, odd tasks, connections and Defender status.

SEC-05 Windows & PowerShell for defenders cheat sheet. Every table on it is repeated as text below.
Tap the sheet for the full-size image. The text version below is screen-reader friendly.

Text version

Everything on the sheet, as plain HTML: handy for screen readers, copy-paste and search.

Security log events to know

Find them in Event Viewer under Windows Logs, Security. Microsoft rates 4719 and 1102 high: investigate every one.

Event IDWhat happenedWhy care
4624Logon succeededCheck the logon type
4625Logon failedMany in a row = password guessing
4648Logon with explicit credentialsrunas, lateral movement
4672Admin rights given to a new logonWho is acting as admin?
4688New process createdNeeds process auditing turned on
4697Service install attemptedPersistence
4698Scheduled task createdPersistence
4720User account createdWas it expected?
4724Password reset attemptedBy whom?
4732Member added to a local groupAdministrators?
4740Account locked outFind the source
4768Kerberos TGT requestedOn domain controllers
4719System audit policy changedHigh
1102Audit log clearedHigh

Logon types (in 4624 and 4625)

TypeNameMeaning
2InteractiveAt the keyboard
3NetworkFile share, net use
4BatchScheduled task
5ServiceA service started
7UnlockScreen unlocked
10RemoteInteractiveRemote Desktop (RDP)
11CachedInteractiveCached credentials; no domain controller contacted

Hunt with PowerShell (run as admin)

CommandShows
Get-WinEvent -FilterHashtable @{LogName='Security';Id=4625} -MaxEvents 20Last 20 failed logons
Get-LocalGroupMember AdministratorsWho is a local admin
Get-ScheduledTaskTasks: look for odd names and paths
Get-NetTCPConnection -State EstablishedLive connections
Get-Process | Select-Object Name, Id, PathWhere each process runs from
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\RunRun key autostarts (also check HKCU:)

Defender and files

CommandWhat it does
Get-MpComputerStatusIs antivirus on and up to date?
Update-MpSignatureUpdate definitions
Start-MpScan -ScanType QuickScanQuick scan
Get-MpThreatDetectionWhat Defender caught
Get-FileHash .\file.exeSHA-256 hash to look up
Get-AuthenticodeSignature .\file.exeWho signed the file

Turn on visibility first

  • auditpol /get /category:* shows what is being audited.
  • wevtutil epl Security C:\IR\sec.evtx exports the Security log as evidence.
  • Script block logging (event 4104): Group Policy, Administrative Templates, Windows Components, Windows PowerShell, Turn on PowerShell Script Block Logging. Windows PowerShell 5.1 logs to Microsoft-Windows-PowerShell/Operational; PowerShell 7 logs to PowerShellCore/Operational.
  • Event 4688 needs Audit Process Creation turned on, plus the command-line policy to see arguments.

Triage order

  1. Who logged on? (4624, 4625)
  2. New users or admins? (4720, 4732)
  3. What persists? Tasks, services, Run keys
  4. What talks out? Connections
  5. Is Defender healthy?

Danger. Isolate the host. Do not wipe it. Escalate.

Caution. Export logs before a reboot or reimage.

Caution. Never turn off Defender to make an app work.

Remember

  • A burst of 4625 events for one user = password guessing
  • Logon type 10 = RDP
  • 1102 = someone cleared the log

Sources

Go deeper on the blog