Token Manipulation: উইন্ডোজের অ্যাক্সেস টোকেন ম্যানিপুলেট করে সাধারণ ব্যবহারকারী থেকে সিস্টেম অ্যাডমিন হওয়ার সাইবার কৌশল!
Windows access token theft, token impersonation, SeImpersonatePrivilege abuse এবং privilege escalation technique-এর বিস্তারিত red team গাইড।
Windows operating system-এ প্রতিটি process এবং thread-এর সাথে একটি access token যুক্ত থাকে, যা সেই process-এর identity, group membership, privilege এবং security context define করে। যখন একজন user log in করেন, Windows তার জন্য একটি primary token তৈরি করে; যখন কোনো process অন্য কোনো user-এর behalf-এ কাজ করতে চায়, তখন impersonation token ব্যবহার করে। এই token-গুলো Windows access control-এর হৃদয়। আক্রমণকারী যদি কোনোভাবে একটি high-privilege token (যেমন SYSTEM বা domain admin-এর token) চুরি করে নিজের process-এ ব্যবহার করতে পারে, তাহলে তাদের privilege নাটকীয়ভাবে বেড়ে যায় — সাধারণ user থেকে সিস্টেম administrator। এই family-র technique-কে Token Manipulation বলা হয়, এবং MITRE ATT&CK framework-এ এটি T1134-এর অধীনে document করা। এই article-এ আমরা Windows token architecture, manipulation technique, real-world tool এবং defense বিস্তারিতভাবে আলোচনা করব।
Windows Access Token Architecture
Windows-এ প্রতিটি securable object-এর সাথে একটি Security Descriptor যুক্ত, যা ACL (Access Control List)-এর মাধ্যমে কে কী access পাবে তা define করে। প্রতিটি running process-এর সাথে যুক্ত access token কয়েকটি field বহন করে-
- User SID: ব্যবহারকারীর Security Identifier।
- Group SIDs: ব্যবহারকারী যেসব group-এর সদস্য।
- Privileges: SeDebugPrivilege, SeImpersonatePrivilege, SeBackupPrivilege ইত্যাদি।
- Logon Session: কোন logon session-এ created।
- Integrity Level: Low, Medium, High, System (UAC-এর সাথে সম্পর্কিত)।
- Token Source: কোন subsystem-এর তৈরি।
দুই ধরনের token-
- Primary Token: process-এর প্রধান identity define করে। সাধারণত process creation-এর সময় assign।
- Impersonation Token: একটি thread temporarily অন্য user-এর identity ধারণ করতে পারে। ৪টি impersonation level — Anonymous, Identification, Impersonation, Delegation।
Win32 API-এ token-এর সাথে interact করার জন্য OpenProcessToken, OpenThreadToken, DuplicateToken, DuplicateTokenEx, ImpersonateLoggedOnUser, CreateProcessWithTokenW, SetThreadToken, LogonUser — এসব function ব্যবহৃত হয়।
কেন Token Manipulation কার্যকর
Token Manipulation-এর সবচেয়ে বড় সুবিধা — কোনো credential চুরি করতে হয় না, কোনো password crack করতে হয় না। যদি একটি high-privilege user-এর token attacker-এর reach-এ থাকে (যেমন target machine-এ admin recently logged in ছিলেন), সেই token duplicate এবং impersonate করেই attacker সেই user-এর সম্পূর্ণ privilege ধার নিতে পারেন।
এছাড়াও token-based attack stealthy। Authentication event (Event ID 4624) generate হয় না নতুন logon-এর মতো, কারণ token already existing logon session থেকে derived। SOC analyst-এর জন্য detection comparatively কঠিন।
Common Token Manipulation Technique
Token Impersonation
Attacker একটি existing process-এর token duplicate করে নিজের thread বা process-এ ব্যবহার করেন।
Workflow:
OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)— high-privilege process handle।OpenProcessToken(hProc, TOKEN_DUPLICATE | TOKEN_QUERY, &hToken)— token handle।DuplicateTokenEx(hToken, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &hNewToken)।CreateProcessWithTokenW(hNewToken, ..., "cmd.exe", ...)— new process under stolen identity।
এই workflow Cobalt Strike-এর steal_token command, Meterpreter-এর steal_token module-এ implemented।
SeImpersonatePrivilege Abuse
SeImpersonatePrivilege Windows-এর একটি sensitive privilege যা service account (LocalService, NetworkService, IIS application pool identity, SQL Server service account) সাধারণত ধারণ করে। এই privilege যে process হোল্ড করে, সে অন্য user-এর token impersonate করতে পারে।
Famous exploit family — "Potato attack" — এই privilege-এর misuse exploit করে।
- Hot Potato (2016): Windows update mechanism এবং NBNS spoofing-এর combination।
- Rotten Potato (2016): DCOM এবং NTLM relay।
- Juicy Potato (2018): DCOM activator with arbitrary CLSID।
- PrintSpoofer (2020): Print Spooler service-এর named pipe abuse।
- RoguePotato, JuicyPotatoNG, GodPotato (2022-2023): Print Spooler patch-এর পরে newer technique।
- EfsPotato, SharpEfsPotato: EFSRPC-এর abuse।
এই tool-গুলো IIS app pool বা SQL service-এ initial code execution থেকে SYSTEM privilege escalate করে। Penetration test report-এ এদের ক্রমাগত উপস্থিতি দেখা যায়।
Make Token
LogonUser API দিয়ে credential-base নতুন token তৈরি। যদি attacker-এর কাছে valid username/password থাকে, তাঁরা সেই credential-এ একটি new logon token তৈরি করতে পারেন।
LogonUser("domain\\user", NULL, "password", LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, &hToken)
LOGON32_LOGON_NEW_CREDENTIALS flag বিশেষভাবে useful — এটি কেবল outbound authentication-এ token ব্যবহার করে, local validation skip করে। Cobalt Strike-এর make_token command এটি ব্যবহার করে।
Pass-the-Hash with Token
Mimikatz-এর sekurlsa::pth — যেখানে NTLM hash দিয়ে impersonation token তৈরি করা হয়। LSASS process-এ injected logon session-এ hash inject করে।
Pass-the-Ticket
Kerberos ticket (TGT বা service ticket) extract করে অন্য session-এ inject। Rubeus-এর Rubeus.exe ptt /ticket:...। Token impersonation-এর Kerberos variant।
Real-World Tool
Mimikatz
Benjamin Delpy-এর iconic tool। Token-related command-
token::list— current process-এ accessible token list।token::elevate— SYSTEM token impersonate।token::run /user:DOMAIN\Administrator /process:cmd.exe— specific user-এর token দিয়ে process।privilege::debug— SeDebugPrivilege enable।
Cobalt Strike
Commercial red team C2। Token-related command-
getsystem— multiple technique try করে SYSTEM token অর্জন।steal_token <pid>— specified process থেকে token steal।make_token <user> <pass>— credential থেকে token তৈরি।rev2self— original token restore।
Meterpreter (Metasploit)
getsystem— SYSTEM escalation।steal_token <pid>।impersonate_token <user>।rev2self।
Incognito
Built into Metasploit। Token enumeration এবং impersonation-এর dedicated tool।
PrintSpoofer, GodPotato, JuicyPotatoNG
Specific privilege escalation tool যা SeImpersonatePrivilege exploit করে।
Token Theft Walkthrough Example
ধরা যাক একটি penetration test scenario-
- Attacker phishing-এর মাধ্যমে regular user
[email protected]-এর workstation-এ Meterpreter session পেয়েছেন। pscommand-এ run করে দেখা গেছে administrator[email protected]-ও সেই machine-এ logged in আছেন (remote support context-এ) — তাঁরexplorer.exePID 4528-এ চলছে।getuid— current identityalice।use incognito→list_tokens -u— available token check।impersonate_token "CORP\\bob"— token impersonation।getuid— এখনbob।- Bob domain admin হলে এখন domain-wide action সম্ভব।
এই scenario-তে কোনো password crack হয়নি, কোনো hash extract হয়নি — কেবল existing logon session-এর token reuse।
Linux এবং Cross-Platform Analogue
Linux-এ exact token concept নেই, কিন্তু similar concept — setuid/setgid bit, capability, user namespace।
- setuid/setgid binary abuse: vulnerable suid binary থেকে privilege escalation।
- sudo misconfiguration: NOPASSWD entries।
- Capability abuse:
cap_dac_override,cap_sys_adminদিয়ে privilege bypass। - Linux PEAS: enumeration tool।
macOS-এ — XPC service abuse, sandbox escape, TCC bypass — different mechanism কিন্তু similar end goal।
UAC Bypass এবং Token Manipulation
User Account Control (UAC) admin user-কে দুটি token দেয় — filtered (medium integrity) এবং elevated (high integrity)। UAC bypass technique attacker-কে user consent ছাড়াই elevated token-এ পৌঁছাতে দেয়। Common technique-
- Fodhelper, EventVwr, ComputerDefaults registry hijack।
- DLL hijacking in auto-elevate binary।
- CMSTPLUA COM hijack।
UACMe (GitHub-এর hfiref0x/UACME) এই technique-গুলোর comprehensive collection।
Detection: Defender-এর Perspective
Token manipulation detect করা challenging কিন্তু impossible নয়। Detection technique-
Sysmon Event ID 1 + 10
Process creation (Event 1) এবং ProcessAccess (Event 10) event-এর সমন্বিত analysis। যদি একটি unprivileged process অন্য privileged process-এ 0x1000 (PROCESS_QUERY_LIMITED_INFORMATION) বা 0x40 (PROCESS_DUP_HANDLE) access নেয়, সেটি suspicious।
Token-Related Event
- Event ID 4672: special privileges assigned to new logon।
- Event ID 4673: privileged service called।
- Event ID 4624: logon success, particularly type 9 (NewCredentials)।
Behavioral Anomaly
Service account-এর under unusual child process — IIS Application Pool থেকে cmd.exe spawn, SQL service থেকে PowerShell — strong indicator।
EDR Telemetry
CrowdStrike, Microsoft Defender for Endpoint, SentinelOne — সবাই token manipulation pattern detection-এ specific rule include করে। Especially Potato-family exploitation।
Memory Forensics
LSASS access pattern (mimikatz-style), process token integrity check।
Sigma Rule
SigmaHQ-তে দ্বারা SeImpersonatePrivilege abuse, Potato exploit, Mimikatz token theft-এর জন্য rule available।
Defense Strategy
Principle of Least Privilege
Service account-এর SeImpersonatePrivilege strictly necessary basis-এ। যেকোনো service অযথা LocalSystem-এ run না করানো।
Credential Guard
Windows 10/11 Enterprise-এর Credential Guard — LSASS-কে virtualization-based security-এর মাধ্যমে protect করে। Token theft কিছুটা কঠিন হয়, যদিও PrintSpoofer-typed attack বাঁধা পায় না।
Protected Process Light (PPL)
Anti-malware service, LSASS — selected critical process PPL hierarchy-এ। Standard user থেকে memory injection বা token theft কঠিন।
Restricted Admin Mode
RDP-এর Restricted Admin Mode credential server-এ leave না করে, lateral movement risk কমায়।
LAPS (Local Administrator Password Solution)
Local administrator password randomization — lateral movement-এর সুযোগ কমায়।
JEA (Just Enough Administration)
PowerShell-এর JEA framework limited delegation — full admin token-এর প্রয়োজন কমায়।
EDR Deployment
Behavior-based EDR + kernel callback enable। Token manipulation pattern detect করে।
Patch Management
Print Spooler-related vulnerability, EFSRPC, DCOM-related fix timely apply।
Tiered Administration Model
Microsoft-এর Privileged Access Workstation (PAW) model — Tier 0 (domain admin), Tier 1 (server admin), Tier 2 (workstation admin) — strict separation।
Service Hardening
Service account isolation, virtual account (NT SERVICE\xxx), managed service account (MSA), group managed service account (gMSA)।
Monitoring এবং SOC
Sysmon comprehensive config, SIEM rule, Sigma rule deploy।
Real-World Incident: Token Manipulation in APT Campaign
Nobellium/APT29-এর SolarWinds Sunburst campaign-এ extensive token manipulation observed। Compromised SolarWinds Orion-এর মাধ্যমে initial access-এর পর attacker-রা Service Principal Name (SPN) manipulation, Golden SAML attack, এবং token theft দিয়ে cloud environment-এ persist করেছিলেন।
LAPSUS$ group ২০২২-এ Microsoft, Okta, Nvidia, Samsung breach-এ session token-stealing infostealer (Raccoon, RedLine) + helpdesk social engineering combine করেছিল। Stolen session token দিয়ে MFA bypass।
Scattered Spider (UNC3944) MGM এবং Caesars hack-এ similar pattern — social engineering + token abuse।
Token Manipulation Windows offensive security-এর সবচেয়ে elegant এবং কার্যকর technique-এর একটি। এটি প্রমাণ করে যে identity-based access control-এর শক্তি যেমন বিশাল, তেমনই সেটি abuse-এর সুযোগও বিশাল। SeImpersonatePrivilege থেকে Potato exploit, Mimikatz token::elevate থেকে Pass-the-Hash — প্রতিটি technique attacker-দের দিয়েছে process boundary cross করার এবং privilege climb করার নিরবিচ্ছিন্ন path। Defender-দের জন্য এই reality জানা মানে কেবল detection rule তুলে রাখা নয় — বরং architectural choice — least privilege, credential guard, PPL, tiered administration, কঠোর service hardening — এগুলোকে নিরাপত্তা strategy-র কেন্দ্রে রাখা। যত পরিশীলিতভাবে আপনি token-এর lifecycle understand করবেন, তত ভালোভাবে আপনি adversary-র manipulation detect এবং prevent করতে পারবেন। Windows security-এর গভীরে যেতে হলে token-এর গল্প পড়া অপরিহার্য।
আপনার জ্ঞান যাচাই করতে প্রস্তুত? আজই HackCert-এ Token Manipulation MCQ Quiz-টি দিন!
Related articles
AMSI Patching: Deconstructing the Art of Disabling Antivirus via Memory Manipulation
8 min
Constrained Delegation: Security Risks and Solutions in Active Directory
12 min
LSASS Dumping: Advanced Cyber Techniques for Extracting Usernames and Passwords from Memory
11 min
Syscalls Execution: Direct Kernel Communication Tactics for Bypassing Security Software
11 min

