Post-Exploitation: Token Impersonation Lab Report
Author: Basit Hassan
Date: 2025-10-13
Environment: The same AD environment i have been simulating from the begining of this journey.
Scope:Scope: Demonstration in a lab environment of token impersonation using Meterpreter incognito.
Overview
I used the credential of a user I obtained in an earlier post and launched Metasploit’s psexec module against a target in my simulated AD lab. From the psexec exploit I obtained a Meterpreter session on the host. Inside Meterpreter I loaded the incognito extension and ran list_tokens -u to enumerate available user tokens. I identified a privileged token corresponding to an Administrator account and used impersonate_token to assume that context. I then spawned a shell under the impersonated token and verified privileges with whoami, which confirmed LABDOMAIN\\Administrator (sanitized).
Walkthrough
Launched msfconsole on the attacker VM.
Used psexec (via Metasploit) with valid credentials to get a Meterpreter session on the target VM.
In the Meterpreter session: load incognito and list_tokens to enumerate tokens.
Found an Administrator token and used impersonate_token to assume the admin context.
Spawned a shell under the impersonated token and verified privileges with whoami.
Launched msfconsole on the attacker VM.
Used psexec (via Metasploit) with valid credentials to get a Meterpreter session on the target VM.
In the Meterpreter session: load incognito and list_tokens to enumerate tokens.
Found an Administrator token and used impersonate_token to assume the admin context.
Spawned a shell under the impersonated token and verified privileges with whoami.

i was able to get administration shell the highest priviledge i will ever get this is the domain contoller admin
Important: This impersonation succeeded because the Administrator account already had an active session token on the target (the admin had previously logged in). If the machine had been restarted — clearing session tokens — the impersonation would not have worked until an Administrator session existed again.
Mitigation & Hardening Recommendations
Least privilege: Remove unnecessary privileges like
SeImpersonatePrivilegefrom non-privileged service accounts.LSA Protection & Credential Guard: Enable LSA protection and Microsoft Defender Credential Guard where possible.
Rotate local admin credentials: Use LAPS (Local Administrator Password Solution) to manage/rotate local admin passwords.
EDR & Monitoring: Deploy EDR that detects LSASS memory reads, token duplication, and common post-exploitation tools (Meterpreter, Mimikatz).
Network segmentation & MFA: Limit lateral movement opportunities and require multi-factor authentication for privileged accounts.
Harden service accounts: Ensure service accounts do not hold interactive or excessive privileges and rotate their credentials regularly.


Comments
Post a Comment