Skip to content

Network & remote access

Windows Firewall Logs

Windows Firewall cheat sheet: pfirewall.log format and defaults, rule change events 2004-2006, WFP audit 5156/5157, rules in the registry and netsh abuse.

Location
C:\Windows\System32\LogFiles\Firewall\pfirewall.log
Proves
Allowed or dropped connections (if logging is on) and when firewall rules or profiles were changed
Timestamps
pfirewall.log date/time columns in local time; event logs in UTC (FILETIME precision)
Retention
pfirewall.log 4 MB by default, rolled once to pfirewall.log.old; event logs are circular
Access
Administrator; pfirewall.log is held open by the firewall service, raw copy may be needed
Type
File / file system
Windows
XPVista / 78 / 8.11011
KAPE target
WindowsFirewallEventLogs
Velociraptor
Windows.Triage.Targets:WindowsFirewallEventLogs

What it is

Windows Defender Firewall (formerly Windows Firewall) leaves three kinds of evidence: a text packet log (pfirewall.log), event logs that record configuration changes, and Windows Filtering Platform (WFP) audit events in the Security log. The rule set itself is stored in the registry. Together they answer two questions: did this host talk to that address, and did someone open a hole in the firewall.

Location

EvidenceLocationDefault state
Packet log (XP SP2)C:\Windows\pfirewall.logOff
Packet log (Vista and later)%SystemRoot%\System32\LogFiles\Firewall\pfirewall.logOff (per profile)
Firewall event log (Vista and later)Microsoft-Windows-Windows Firewall With Advanced Security%4Firewall.evtxOn
WFP auditSecurity.evtxOff (needs audit policy)
Local rulesHKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRulesPresent
GPO rulesHKLM\SOFTWARE\Policies\Microsoft\WindowsFirewall\FirewallRulesIf a policy applies
Profile and logging settings...\FirewallPolicy\DomainProfile, StandardProfile, PublicProfile (and \Logging subkeys)Present

The log path can be changed per profile, so read LogFilePath before assuming the default.

What it proves

  • pfirewall.log: a connection attempt was allowed (ALLOW) or dropped (DROP), with IPs, ports and protocol. The path column is the direction (SEND, RECEIVE), not a process path; some recent Windows 11 builds add a pid column, but do not count on it.
  • Firewall event log: a rule was added, modified or deleted, or a profile setting (for example firewall on/off) changed, and which application made the change.
  • 5156/5157: the process (Application) behind each permitted or blocked connection, which pfirewall.log generally lacks.

It does not prove data volume transferred (see SRUM) or anything about traffic when logging was disabled, which is the default.

Key fields

SourceField / IDMeaning
pfirewall.logdate time action protocol src-ip dst-ip src-port dst-port size tcpflags tcpsyn tcpack tcpwin icmptype icmpcode info pathW3C-style header (#Fields:), space separated
Firewall evtx2004 / 2005 / 2006Rule added / modified / deleted (rule name, application path, ports, modifying application)
Firewall evtx2033All rules deleted
Firewall evtx2003Profile setting changed (for example Enable Windows Defender Firewall)
Security5156 / 5157WFP permitted / blocked a connection (process, direction, IPs, ports)
Security5152WFP dropped a packet
Security4946 / 4947 / 4948 / 4950Rule added / modified / deleted, setting changed (MPSSVC rule-level audit)
Registry rule valuev2.xx|Action=Allow|Active=TRUE|Dir=In|Protocol=6|LPort=3389|App=...|Name=...|One value per rule, keyed by rule GUID or name

Recent Windows 11 builds log rule changes under newer IDs (2097 added, 2099 modified, 2052 deleted are commonly reported). Filter on both sets.

Timestamps

TimestampFormatPitfalls
pfirewall.log date + timeYYYY-MM-DD HH:MM:SS, local timeNo time zone in the file; convert using the host's TimeZoneInformation (UTC and local time)
Event TimeCreatedUTCRule change time, not rule creation in the registry
Registry key last writeUTCFirewallRules key time only shows the latest change to any rule

Retention and clearing

  • pfirewall.log defaults to 4,096 KB. When full, it is renamed to pfirewall.log.old (overwriting the previous one) and a new file starts, so only about 8 MB of history ever exists.
  • The firewall event log and Security log are circular; Security volume explodes if 5156 is enabled.
  • Attackers commonly disable the firewall or add allow rules: netsh advfirewall set allprofiles state off, netsh advfirewall firewall add rule name="x" dir=in action=allow protocol=TCP localport=3389, Set-NetFirewallProfile -Enabled False, or the legacy netsh firewall context.

Collection

robocopy C:\Windows\System32\LogFiles\Firewall E:\case\Firewall /COPY:DAT
wevtutil epl "Microsoft-Windows-Windows Firewall With Advanced Security/Firewall" E:\case\Firewall.evtx
reg export "HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy" E:\case\FirewallPolicy.reg
netsh advfirewall show allprofiles
auditpol /get /subcategory:"Filtering Platform Connection"

KAPE WindowsFirewall collects the text logs; EventLogs covers the EVTX files. If the copy fails because the file is in use, use a raw copy (KAPE, Velociraptor or an image).

Parsing tools

  • EvtxECmd, Get-WinEvent, Chainsaw: firewall and Security events.
  • Log Parser or any CSV tool: pfirewall.log is plain text; skip the # header lines.
  • Registry Explorer / RECmd: decode FirewallRules values and key times.
  • Velociraptor: live queries of rules and log files across hosts.

Investigation tips

  • Hunt rule events where the modifying application is netsh.exe, powershell.exe or an unknown binary, and rules opening RDP (3389), SMB (445), WinRM (5985/5986) or allowing a program in a user-writable path.
  • Compare FirewallRules against a clean build: rules with odd names, Active=TRUE inbound allows and App= in \AppData\ or \ProgramData\ stand out.
  • A 2003 event turning the firewall off shortly before lateral movement is a strong anchor for the timeline.
  • Correlate pfirewall.log DROP bursts with 4625 logons to spot scanning and brute force.
  • Pair 5156 process names with Sysmon event 3 if both exist.

Related artifacts

Glossary terms

Guides

All artifacts on one page: cheat sheet