Why Lateral Movement Is So Hard to Detect
Inside a corporate network, SSH, RDP, SMB and WinRM connections happen tens of thousands of times a day; administrators move between these ports as a matter of routine. Any single connection looks exactly like an attacker's hop: TCP handshake, protocol negotiation, authentication, session established.
The real difference lives in the pattern. An administrator connects to server A today and server B tomorrow, while an attacker typically starts from one host and probes a set of targets in a short window until one allows deeper access. "Short window, many targets, one admin protocol" is the decidable shape.
That is why lateral movement detection must treat the whole capture as the observation window rather than judging packet by packet. PcapDecoder's detector maintains per-source target sets and only emits a finding once the threshold is reached within the window.
Three Detection Rules
Rule 1: Lateral sweep
A source in RFC1918 → RFC1918 direction sends SYNs (no ACK, i.e. initial connections) to ≥3 distinct targets on ports belonging to the admin service set: 22 (SSH), 445 (SMB), 3389 (RDP), 5900 (VNC), 5985/5986 (WinRM).
All three qualifiers matter:
- Internal to internal: RDP from the internet is more likely an exposure problem, a different detection class;
- SYN without ACK: only the initiator counts, so responses are not mistaken for attacks;
- Admin port set: high-frequency connections to random ports are more likely application behavior, not admin channel abuse.
Rule 2: Admin share access
SMB admin shares are the classic lateral technique — write a file to C$ or ADMIN$ then execute remotely. The criterion sits on the SMB2 Tree Connect message: Command field equals 3, StructureSize equals 9, and the path (UTF-16LE) contains \C$ or \ADMIN$.
One easy mistake to avoid: SMB2's Command sits at header offset 12 and StructureSize at offset 64, with path offset and length at 68 and 70. Checking both fields prevents misreading response frames (StructureSize 16) as requests.
Note that accessing C$ is common in legitimate operations — backup software, patch distribution and asset inventory all use it. A single admin share access is not enough to conclude anything; it becomes meaningful only combined with sweeps, timeline anomalies or other findings.
Rule 3: Tool delivery
A source transfers an executable or script to an internal target over SMB / HTTP / FTP, immediately followed by a remote execution connection. This rule requires cross-protocol correlation; the current implementation attaches a path-extension check to admin share behavior, while full delivery-then-execute correlation is still evolving.
Role Reversal: The Most Valuable Signal
The first two rules catch "acting outward"; role reversal catches "being compromised".
The criterion: a host first appears as the server side of port 445 (others connect to its SMB), and then it starts initiating SYN connections to port 445 on other hosts. That ordering means it changed from a service endpoint into a client — normal servers keep a stable role, and a file server does not suddenly start enumerating other shares.
Why is this signal so valuable? Because it points directly at a pivot host. After gaining the first machine, attackers habitually use it as a foothold to push deeper, and on the wire that is exactly this role switch. Overlay role-reversal hosts with sweep paths and you can reconstruct the full hop chain.
How-to: Locate the Hop Path in Three Steps
Step 1: Check the lateral movement group. Findings list the source, the target count and ports, and evidence packet numbers. Start with the one touching the most targets — that is most likely the sweep origin.
Step 2: Read the host communication graph. PcapDecoder's graphical attack traceback draws internal host connections as a directed graph with lateral movement edges highlighted. Far more intuitive than a list, especially when explaining "this machine touched those five" to non-technical colleagues.
Step 3: Walk back the timeline. Compare the lateral finding with what happened in the ten minutes before it. A typical chain: cleartext credentials (T1040) or brute force (T1110) → successful logon → lateral sweep (T1021) → admin share write → new outbound traffic from the target. Every segment has corresponding packet numbers in the capture.
Hardening Directions
- Tighten admin protocol reachability inside the network: adopt the Privileged Access Workstation model so only designated jump hosts can reach RDP/WinRM;
- Restrict daily admin share access: open
C$andADMIN$only to required accounts and monitor access through SMB audit logs; - Disable NTLM, require Kerberos: lateral movement depends heavily on NTLM relay and pass-the-hash; removing NTLM cuts a large share of paths;
- Segmentation: enforce east-west control between server, office and OT zones so the first hop is blocked;
- Monitor abnormal SMB writes: writing an exe or ps1 to
C$is a strong signal, detectable in coordination with file server or EDR telemetry.
Traffic-side detection is positioned as "retrospectively visible plus audit evidence" — it does not replace segmentation or least privilege. But it has an advantage endpoint detection lacks: cross-host, cross-segment behavior is continuous on the wire while endpoint logs are scattered.
Related reading: Identifying Kerberos Attacks, Detecting ARP Spoofing in a Packet Capture.
