Sysmon Event ID 3
Sysmon Event ID 3: Network Connection
Network connection detected
- Log source
- Microsoft-Windows-Sysmon/Operational
- How to enable it
- Sysmon installed, with a NetworkConnect section. Off by default
- Category
- Lateral Movement
- Priority
- High
- Typical volume
- High
- MITRE ATT&CK
What Sysmon Event ID 3 means
Sysmon event 3 records TCP and UDP connections with the program that made them, the user and both ends. It is disabled by default and is meant to be enabled with rules, so that only the interesting share of traffic is kept.
Perimeter devices see an address. This event sees who was behind it. The same destination visited by a browser and by regsvr32.exe has two very different meanings, and no firewall log can tell them apart.
It logs the connection and neither bytes nor duration, and DNS names are only a reverse lookup of the address, which is often wrong for cloud services. Join with event 22 on ProcessGuid for the name that was really requested.
Key fields to inspect
| Field | Meaning | Suspicious when |
|---|---|---|
Image | Program that made or accepted the connection. | rundll32.exe, regsvr32.exe, mshta.exe, msbuild.exe, notepad.exe, or a file in a user folder. |
DestinationIp | Destination address. | Recently registered hosting, or internal hosts outside the program's role. |
DestinationPort | Destination port. | 4444, 8443, 50050, or 88 and 389 from a program other than lsass.exe. |
Initiated | true if this host started the connection. | false on a workstation, for an unexpected program. |
User | Account of the process. | SYSTEM or a service account going to the internet. |
DestinationHostname | Reverse lookup of the address. | Treat it as a hint only. |
ProcessGuid | Unique identifier of the process. | Join it with events 1 and 22. |
Detection queries
Measure the regularity of outbound connections by unusual programs to find beacons. Adjust names and thresholds to your environment. About these queries.
Splunk SPL
index=windows source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=3
Initiated=true
| regex Image="(?i)\\\\(rundll32|regsvr32|mshta|msbuild|installutil|dllhost|notepad|powershell|pwsh|wscript|cscript)\.exe$"
| where NOT (cidrmatch("10.0.0.0/8", DestinationIp) OR cidrmatch("172.16.0.0/12", DestinationIp) OR cidrmatch("192.168.0.0/16", DestinationIp) OR cidrmatch("127.0.0.0/8", DestinationIp))
| sort 0 Computer Image DestinationIp _time
| streamstats current=f last(_time) AS previous BY Computer Image DestinationIp
| eval gap=_time-previous
| stats count avg(gap) AS average stdev(gap) AS deviation BY Computer Image DestinationIp
| eval jitter=round(deviation/average, 2)
| where count>=10 AND jitter<0.3 Microsoft Sentinel KQL
Event
| where EventLog == "Microsoft-Windows-Sysmon/Operational" and EventID == 3
| extend Image = extract(@'Name="Image">([^<]*)<', 1, EventData)
| extend DestinationIp = extract(@'Name="DestinationIp">([^<]*)<', 1, EventData)
| extend DestinationPort = extract(@'Name="DestinationPort">([^<]*)<', 1, EventData)
| extend Initiated = extract(@'Name="Initiated">([^<]*)<', 1, EventData)
| where Initiated == "true" and Image matches regex @"(?i)\\(rundll32|regsvr32|mshta|msbuild|installutil|dllhost|notepad|powershell|pwsh|wscript|cscript)\.exe$"
| where ipv4_is_private(DestinationIp) == false
| sort by Computer asc, Image asc, DestinationIp asc, TimeGenerated asc
| extend Gap = iff(prev(DestinationIp) == DestinationIp and prev(Image) == Image and prev(Computer) == Computer, datetime_diff("second", TimeGenerated, prev(TimeGenerated)), long(null))
| summarize Connections = count(), Average = avg(Gap), Deviation = stdev(Gap) by Computer, Image, DestinationIp, DestinationPort
| where Connections >= 10 and Deviation / Average < 0.3 PowerShell
Get-WinEvent -FilterHashtable @{ LogName = 'Microsoft-Windows-Sysmon/Operational'; Id = 3; StartTime = (Get-Date).AddDays(-1) } |
ForEach-Object { $d = @{ Time = $_.TimeCreated }; ([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }; [pscustomobject]$d } |
Where-Object { $_.Initiated -eq 'true' -and $_.Image -match 'rundll32|regsvr32|mshta|msbuild|powershell' } |
Select-Object Time, Image, User, DestinationIp, DestinationPort, DestinationHostname | Format-Table -AutoSize Attack scenarios
Beaconing implant
Injected code in a system program contacts one address at steady intervals with small variation. Regularity over hours is hard to hide, even if the traffic itself is encrypted and the address belongs to a large cloud provider.
Script-based download
mshta.exe, certutil.exe or powershell.exe opens a single connection and event 11 shows a new file seconds later. The three events share a ProcessGuid.
WinRM and WMI lateral movement
powershell.exe or wsmprovhost.exe connects to port 5985 on several hosts, or wmic.exe to port 135 followed by high ports.
Investigation checklist
- Join with event 1 on ProcessGuid for the command line and parent.
- Join with event 22 for the DNS name that was requested.
- Calculate the interval between connections and look for regularity.
- Search all hosts for the same destination.
- Contain the host before you block the address, if you want to observe the operator.
Common benign causes
- PowerShell and management tools that reach cloud services.
- Monitoring agents, which are as regular as beacons and need exclusion by path.
- Developer tools such as msbuild.exe that restore packages.
Sysmon Event ID 3 FAQ
Why is Sysmon event 3 disabled by default?
Because of volume. Every connection of every program would be logged. Enable it with rules that include suspicious programs and ports, or that exclude browsers and known agents.
How do I detect beaconing with Sysmon?
Group connections by host, program and destination, measure the gaps between them, and look for a low ratio of standard deviation to average over many connections. Exclude known agents first.
Is DestinationHostname reliable?
No. It is a reverse lookup of the address and often shows a hosting provider instead of the site. Use Sysmon event 22 to see the name that the program asked for.