SlideShare a Scribd company logo
Windows 4 pentesters
Internals 101
# whoami
Krzysztof ‘0kami’ Marciniak
Twitter: @__0kami
medium.com/_0kami
Security Consultant @ F-Secure
Poznan Security Meetup co-founder
Binexp, CTFs, OS (mostly Windows)
internals
Windows infrastructure intro a.k.a. why?
● IT-managed desktops/notebooks with Windows
(usually 7/10)
● Servers with Windows Server (i.e. file servers)
● Organized into a “domain”
● Domain controller (Windows server)
● Users, policies etc. stored in Active Directory
Lookin’ under the hood
Authentication - Local Security Authority (LSA)
The LSA handles user logon and authentication on the local computer, and if the authentication package processing the
logon request supports pass-through authentication, the LSA can also log users on to other computers on the network. The
LSA provides access to authentication packages for Security Support Providers (SSPs). One of the two following types of
authentication is performed:
● Interactive Authentication
● Noninteractive Authentication
https://docs.microsoft.com/en-us/windows/desktop/secauthn/lsa-user-logon-authentication
Authentication - LSASS memory
The Local Security Authority Subsystem Service (LSASS) stores credentials in memory on behalf of users with active
Windows sessions. This allows users to seamlessly access network resources, such as file shares, Exchange Server
mailboxes, and SharePoint sites, without re-entering their credentials for each remote service.
LSASS can store credentials in multiple forms, including:
● Reversibly encrypted plaintext
● Kerberos tickets (TGTs, service tickets)
● NT hash
● LM hash
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994565(v%3Dws.11)
Authentication - LSASS memory
The Local Security Authority Subsystem Service (LSASS) stores credentials in memory on behalf of users with active
Windows sessions. This allows users to seamlessly access network resources, such as file shares, Exchange Server
mailboxes, and SharePoint sites, without re-entering their credentials for each remote service.
LSASS can store credentials in multiple forms, including:
● Reversibly encrypted plaintext
● Kerberos tickets (TGTs, service tickets)
● NT hash
● LM hash
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994565(v%3Dws.11)
Authentication - NTLM
● Besides the regular user+pass pair, NTLM hash can be used
for auth.
● NTLM auth (Net-NTLMv2) is a challenge-response auth.
process
● By default, Windows tries to auth with the hash even to
unknown shares
Authentication - recap
● Local authentication is handled by LSA
● LSA Subsystem Service (LSASS) caches those credentials*
● Credentials can either be user+pass, hashes, Kerberos
tickets
Processes, threads, fibers… oh my!
● When you run an application, a process is created
● A process (or multiple processes) can be grouped into a
job
● A process consists of 0+ threads*
● In Windows threads are the basic unit of scheduling
● Fibers (similar to threads in *NIX), however, are
scheduled manually by the user
Process/thread in-mem shenanigans
● All processes are injected with several interesting dlls
○ ntdll.dll
○ kernel32.dll
○ kernelbase.dll
● We can use this for our advantage
○ No touching disk/invoking LoadLibrary()
○ Utilizing existing pieces of code
○ ...
Process/thread in-mem shenanigans
mov ebx, fs:0x30 ; Get pointer to PEB
mov ebx, [ebx + 0x0C] ; Get pointer to PEB_LDR_DATA
mov ebx, [ebx + 0x14] ; Get pointer to first entry in
InMemoryOrderModuleList
mov ebx, [ebx] ; Get pointer to second (ntdll.dll)
entry in InMemoryOrderModuleList
mov ebx, [ebx] ; Get pointer to third (kernel32.dll)
entry in InMemoryOrderModuleList
mov ebx, [ebx + 0x10] ; Get kernel32.dll base address
https://idafchev.github.io/exploit/2017/09/26/writing_windows_shellcode.html#find_dll
Privileges
Privileges determine the type of system operations that a user account can perform. An administrator assigns privileges to
user and group accounts. Each user's privileges include those granted to the user and to the groups to which the user
belongs.
The functions that get and adjust the privileges in an access token use the locally unique identifier (LUID) type to identify
privileges.
Privileges
Privileges determine the type of system operations that a user account can perform. An administrator assigns privileges to
user and group accounts. Each user's privileges include those granted to the user and to the groups to which the user
belongs.
The functions that get and adjust the privileges in an access token use the locally unique identifier (LUID) type to identify
privileges.
Windows 4 pentesters - internals 101
Handles
● In Windows, resources are usually ref. with a handle
● A handle is a pointer to some actual resource
● The type is usually HANDLE
● Example: acquire process handle
HANDLE OpenProcess(
DWORD dwDesiredAccess,
BOOL bInheritHandle,
DWORD dwProcessId
);
Memory management
● Memory is virtual, paged
● To manage memory, one needs to:
○ Acquire process handle
○ Allocate a page, i.e. with LPVOID VirtualAlloc( LPVOID lpAddress,
SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
○ Adjust protection (VirtualProtect) [optional]
○ Read/Write/… memory (ReadMemory, WriteMemory, …)
○ Free with VirtualFree()
○ Close handle with CloseHandle()
Memory management
Hint 1: One does not need to allocate memory in self (only
have a handle to where the memory will be allocated)
Hint 2: The same goes for pages with PAGE_EXECUTE*
Memory management: consequences
● Read memory of privileged process requires local admin
● Cached passwords from LSASS can thus easily dumped
● One can spawn a thread from another process’s memory
region (without touching the disk)
Memory management: consequences
● Read memory of privileged process requires local admin
● Cached passwords from LSASS can thus easily dumped
● One can spawn a thread from another process’s memory
region (without touching the disk)
Dumping LSASS: plan
● Acquire debug privileges
● Attach to the lsass process
● ReadMemory()
● Save to file
● ...
● Profit!
Code injection
● We can access any* process’s memory
● CreateRemoteThread
● DLL/PE injection
● Hollowing
● Hooking (i.e. SetWindowsHookEx)
● AtomBombing
● ...
https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process
Memory management: consequences
● Read memory of privileged process requires local admin
● Cached passwords from LSASS can thus easily dumped
● One can spawn a thread from another process’s memory
region (without touching the disk)
Process creation
1. Open EXE, create selection object
2. Create executive process object
a. Set up EPROCESS
b. Set up initial proc. address space
c. Create kernel process block
d. Conclude setup of process address space
e. Set up PEB
f. Complete the setup
3. Create initial thread (stack, context, executive thread object)
4. Notify the Win32 subsystem of the new process
5. Start initial thread execution (unless CREATE_SUSPENDED)
6. Complete initialization (i.e. load DLLs), begin execution
Process creation
1. Open EXE, create selection object
2. Create executive process object
a. Set up EPROCESS
b. Set up initial proc. address space
c. Create kernel process block
d. Conclude setup of process address space
e. Set up PEB
f. Complete the setup
3. Create initial thread (stack, context, executive thread object)
4. Notify the Win32 subsystem of the new process
5. Start initial thread execution (unless CREATE_SUSPENDED)
6. Complete initialization (i.e. load DLLs), begin execution
DKOM rootkit - process hiding: plan
● Windows stores info about processes in EPROCESS (kernel)
● EPROCESS has two pointers: Flink, Blink (double-linked list)
● Drivers can modify kernel objects (DKOM)
● Change pointers to make the process “disappear”
DKOM rootkit - process hiding: plan
● Create a driver
○ Find the EPROCESS struct for the given process
○ Point front to back, back to front
● Create a loader
● Load the driver
● ...
● Profit!
(or, rather, watch the proc disappear and wait for BSOD :D)
Process creation
1. Open EXE, create selection object
2. Create executive process object
a. Set up EPROCESS
b. Set up initial proc. address space
c. Create kernel process block
d. Conclude setup of process address space
e. Set up PEB
f. Complete the setup
3. Create initial thread (stack, context, executive thread object)
4. Notify the Win32 subsystem of the new process
5. Start initial thread execution (unless CREATE_SUSPENDED)
6. Complete initialization (i.e. load DLLs), begin execution
Process creation
1. Open EXE, create selection object
2. Create executive process object
a. Set up EPROCESS
b. Set up initial proc. address space
c. Create kernel process block
d. Conclude setup of process address space
e. Set up PEB
f. Complete the setup
3. Create initial thread (stack, context, executive thread object)
4. Notify the Win32 subsystem of the new process
5. Start initial thread execution (unless CREATE_SUSPENDED)
6. Complete initialization (i.e. load DLLs), begin execution
PEB shenanigans: argument spoofing - idea
● PEB stores arguments for the process (runtime)
● PEB is stored in an RW region
● Windows logs process information at creation time
● Taskmgr, for example, gets proc info based on this
● Binary utilizes PEB args
PEB shenanigans: argument spoofing - plan
● Create process as suspended
● NtQueryInformationProcess(..., ProcessBasicInformation, ...) ->
PEB address
● Update pPEB->ProcessParameters
● Resume process
Hint: the easy way is long args -> short args
(verified with a ton of pain and misery, tears not included)
Bonus: parent spoofing - idea
● CreateProcess can spawn processes, buuuut…
To set extended attributes, use a STARTUPINFOEX structure and specify EXTENDED_STARTUPINFO_PRESENT in the
dwCreationFlags parameter.
[...]
InitializeProcThreadAttributeList ->
UpdateProcThreadAttribute(lpList, dwFlags,
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, ...)
Bonus: parent spoofing - code/demo
[insert obligatory sacrifice for RNG gods]
Bonus: getsystem via parent spoofing - code/demo
[insert obligatory sacrifice for RNG gods]
Bonus: parent spoofing -> SYSTEM
Fact: child process inherits parent’s token
Consequence: if we spawn a child under a privileged process
(SYSTEM), we get a privileged child
Questions!
Thank you! / Dziękuję za uwagę!
ありがとうございます

More Related Content

PDF
Hernan Ochoa - WCE Internals [RootedCON 2011]
PDF
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
PDF
1 04 rao
PPTX
Горизонтальные перемещения в инфраструктуре Windows
PPT
Linux
PDF
Jaime Peñalba - Kernel exploitation. ¿El octavo arte? [rooted2019]
PPTX
Unix operating system architecture with file structure
Hernan Ochoa - WCE Internals [RootedCON 2011]
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
1 04 rao
Горизонтальные перемещения в инфраструктуре Windows
Linux
Jaime Peñalba - Kernel exploitation. ¿El octavo arte? [rooted2019]
Unix operating system architecture with file structure

What's hot (20)

PDF
Forensics of a Windows System
DOCX
PDF
Wtf is happening_inside_my_android_phone_public
PPTX
Chapter 1: Introduction to Unix / Linux Kernel
PPTX
Kheirkhabarov24052017_phdays7
PPTX
Unix
PPTX
Unix Administration
PPTX
PDF
Trust boundaries - Confidence 2015
PPTX
How to drive a malware analyst crazy
PDF
Unix - An Introduction
PPTX
Introduction to Unix
DOCX
Code red SUM
PPTX
Passwords#14 - mimikatz
PDF
Basics of Linux Commands, Git and Github
PDF
Puppetconf2016 Puppet on Windows
PPTX
Malware Analysis and Defeating using Virtual Machines
DOCX
Introduction to unix
PPTX
Unix Operating System
Forensics of a Windows System
Wtf is happening_inside_my_android_phone_public
Chapter 1: Introduction to Unix / Linux Kernel
Kheirkhabarov24052017_phdays7
Unix
Unix Administration
Trust boundaries - Confidence 2015
How to drive a malware analyst crazy
Unix - An Introduction
Introduction to Unix
Code red SUM
Passwords#14 - mimikatz
Basics of Linux Commands, Git and Github
Puppetconf2016 Puppet on Windows
Malware Analysis and Defeating using Virtual Machines
Introduction to unix
Unix Operating System
Ad

Similar to Windows 4 pentesters - internals 101 (20)

PDF
CNIT 152 12. Investigating Windows Systems (Part 3)
PDF
CNIT 121: 12 Investigating Windows Systems (Part 3)
PDF
Process injection - Malware style
PDF
Windows internals Essentials
PDF
CNIT 126 12: Covert Malware Launching
PPT
Windows Kernel-
PDF
Practical Malware Analysis Ch12
PPT
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
PDF
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
PDF
CNIT 126 7: Analyzing Malicious Windows Programs
PDF
Bh Usa 07 Butler And Kendall
PPTX
OS Internals and Portable Executable File Format
PPT
Windows internals
PDF
Wce internals rooted_con2011_ampliasecurity
PPTX
Power of linked list
PDF
Windows Internals: fuzzing, hijacking and weaponizing kernel objects
PPTX
Windows Internal - Ch9 memory management
PDF
Process Doppelgänging
PPTX
Hypervisor-Based Active Data Protection for Integrity and Confidentiality of ...
PDF
An Analysis And Solution For The Problem Of Hidden Orphan Processes On Window...
CNIT 152 12. Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)
Process injection - Malware style
Windows internals Essentials
CNIT 126 12: Covert Malware Launching
Windows Kernel-
Practical Malware Analysis Ch12
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows Programs
Bh Usa 07 Butler And Kendall
OS Internals and Portable Executable File Format
Windows internals
Wce internals rooted_con2011_ampliasecurity
Power of linked list
Windows Internals: fuzzing, hijacking and weaponizing kernel objects
Windows Internal - Ch9 memory management
Process Doppelgänging
Hypervisor-Based Active Data Protection for Integrity and Confidentiality of ...
An Analysis And Solution For The Problem Of Hidden Orphan Processes On Window...
Ad

Recently uploaded (20)

PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
"Secure File Sharing Solutions on AWS".pptx
PDF
Website Design Services for Small Businesses.pdf
PDF
Visual explanation of Dijkstra's Algorithm using Python
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
assetexplorer- product-overview - presentation
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
PPTX
Computer Software - Technology and Livelihood Education
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Cybersecurity: Protecting the Digital World
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PPTX
CNN LeNet5 Architecture: Neural Networks
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
"Secure File Sharing Solutions on AWS".pptx
Website Design Services for Small Businesses.pdf
Visual explanation of Dijkstra's Algorithm using Python
Weekly report ppt - harsh dattuprasad patel.pptx
Tech Workshop Escape Room Tech Workshop
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Computer Software and OS of computer science of grade 11.pptx
DNT Brochure 2025 – ISV Solutions @ D365
assetexplorer- product-overview - presentation
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
Computer Software - Technology and Livelihood Education
GSA Content Generator Crack (2025 Latest)
Advanced SystemCare Ultimate Crack + Portable (2025)
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Cybersecurity: Protecting the Digital World
How to Use SharePoint as an ISO-Compliant Document Management System
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
CNN LeNet5 Architecture: Neural Networks

Windows 4 pentesters - internals 101

  • 2. # whoami Krzysztof ‘0kami’ Marciniak Twitter: @__0kami medium.com/_0kami Security Consultant @ F-Secure Poznan Security Meetup co-founder Binexp, CTFs, OS (mostly Windows) internals
  • 3. Windows infrastructure intro a.k.a. why? ● IT-managed desktops/notebooks with Windows (usually 7/10) ● Servers with Windows Server (i.e. file servers) ● Organized into a “domain” ● Domain controller (Windows server) ● Users, policies etc. stored in Active Directory
  • 5. Authentication - Local Security Authority (LSA) The LSA handles user logon and authentication on the local computer, and if the authentication package processing the logon request supports pass-through authentication, the LSA can also log users on to other computers on the network. The LSA provides access to authentication packages for Security Support Providers (SSPs). One of the two following types of authentication is performed: ● Interactive Authentication ● Noninteractive Authentication https://docs.microsoft.com/en-us/windows/desktop/secauthn/lsa-user-logon-authentication
  • 6. Authentication - LSASS memory The Local Security Authority Subsystem Service (LSASS) stores credentials in memory on behalf of users with active Windows sessions. This allows users to seamlessly access network resources, such as file shares, Exchange Server mailboxes, and SharePoint sites, without re-entering their credentials for each remote service. LSASS can store credentials in multiple forms, including: ● Reversibly encrypted plaintext ● Kerberos tickets (TGTs, service tickets) ● NT hash ● LM hash https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994565(v%3Dws.11)
  • 7. Authentication - LSASS memory The Local Security Authority Subsystem Service (LSASS) stores credentials in memory on behalf of users with active Windows sessions. This allows users to seamlessly access network resources, such as file shares, Exchange Server mailboxes, and SharePoint sites, without re-entering their credentials for each remote service. LSASS can store credentials in multiple forms, including: ● Reversibly encrypted plaintext ● Kerberos tickets (TGTs, service tickets) ● NT hash ● LM hash https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994565(v%3Dws.11)
  • 8. Authentication - NTLM ● Besides the regular user+pass pair, NTLM hash can be used for auth. ● NTLM auth (Net-NTLMv2) is a challenge-response auth. process ● By default, Windows tries to auth with the hash even to unknown shares
  • 9. Authentication - recap ● Local authentication is handled by LSA ● LSA Subsystem Service (LSASS) caches those credentials* ● Credentials can either be user+pass, hashes, Kerberos tickets
  • 10. Processes, threads, fibers… oh my! ● When you run an application, a process is created ● A process (or multiple processes) can be grouped into a job ● A process consists of 0+ threads* ● In Windows threads are the basic unit of scheduling ● Fibers (similar to threads in *NIX), however, are scheduled manually by the user
  • 11. Process/thread in-mem shenanigans ● All processes are injected with several interesting dlls ○ ntdll.dll ○ kernel32.dll ○ kernelbase.dll ● We can use this for our advantage ○ No touching disk/invoking LoadLibrary() ○ Utilizing existing pieces of code ○ ...
  • 12. Process/thread in-mem shenanigans mov ebx, fs:0x30 ; Get pointer to PEB mov ebx, [ebx + 0x0C] ; Get pointer to PEB_LDR_DATA mov ebx, [ebx + 0x14] ; Get pointer to first entry in InMemoryOrderModuleList mov ebx, [ebx] ; Get pointer to second (ntdll.dll) entry in InMemoryOrderModuleList mov ebx, [ebx] ; Get pointer to third (kernel32.dll) entry in InMemoryOrderModuleList mov ebx, [ebx + 0x10] ; Get kernel32.dll base address https://idafchev.github.io/exploit/2017/09/26/writing_windows_shellcode.html#find_dll
  • 13. Privileges Privileges determine the type of system operations that a user account can perform. An administrator assigns privileges to user and group accounts. Each user's privileges include those granted to the user and to the groups to which the user belongs. The functions that get and adjust the privileges in an access token use the locally unique identifier (LUID) type to identify privileges.
  • 14. Privileges Privileges determine the type of system operations that a user account can perform. An administrator assigns privileges to user and group accounts. Each user's privileges include those granted to the user and to the groups to which the user belongs. The functions that get and adjust the privileges in an access token use the locally unique identifier (LUID) type to identify privileges.
  • 16. Handles ● In Windows, resources are usually ref. with a handle ● A handle is a pointer to some actual resource ● The type is usually HANDLE ● Example: acquire process handle HANDLE OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId );
  • 17. Memory management ● Memory is virtual, paged ● To manage memory, one needs to: ○ Acquire process handle ○ Allocate a page, i.e. with LPVOID VirtualAlloc( LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect); ○ Adjust protection (VirtualProtect) [optional] ○ Read/Write/… memory (ReadMemory, WriteMemory, …) ○ Free with VirtualFree() ○ Close handle with CloseHandle()
  • 18. Memory management Hint 1: One does not need to allocate memory in self (only have a handle to where the memory will be allocated) Hint 2: The same goes for pages with PAGE_EXECUTE*
  • 19. Memory management: consequences ● Read memory of privileged process requires local admin ● Cached passwords from LSASS can thus easily dumped ● One can spawn a thread from another process’s memory region (without touching the disk)
  • 20. Memory management: consequences ● Read memory of privileged process requires local admin ● Cached passwords from LSASS can thus easily dumped ● One can spawn a thread from another process’s memory region (without touching the disk)
  • 21. Dumping LSASS: plan ● Acquire debug privileges ● Attach to the lsass process ● ReadMemory() ● Save to file ● ... ● Profit!
  • 22. Code injection ● We can access any* process’s memory ● CreateRemoteThread ● DLL/PE injection ● Hollowing ● Hooking (i.e. SetWindowsHookEx) ● AtomBombing ● ... https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process
  • 23. Memory management: consequences ● Read memory of privileged process requires local admin ● Cached passwords from LSASS can thus easily dumped ● One can spawn a thread from another process’s memory region (without touching the disk)
  • 24. Process creation 1. Open EXE, create selection object 2. Create executive process object a. Set up EPROCESS b. Set up initial proc. address space c. Create kernel process block d. Conclude setup of process address space e. Set up PEB f. Complete the setup 3. Create initial thread (stack, context, executive thread object) 4. Notify the Win32 subsystem of the new process 5. Start initial thread execution (unless CREATE_SUSPENDED) 6. Complete initialization (i.e. load DLLs), begin execution
  • 25. Process creation 1. Open EXE, create selection object 2. Create executive process object a. Set up EPROCESS b. Set up initial proc. address space c. Create kernel process block d. Conclude setup of process address space e. Set up PEB f. Complete the setup 3. Create initial thread (stack, context, executive thread object) 4. Notify the Win32 subsystem of the new process 5. Start initial thread execution (unless CREATE_SUSPENDED) 6. Complete initialization (i.e. load DLLs), begin execution
  • 26. DKOM rootkit - process hiding: plan ● Windows stores info about processes in EPROCESS (kernel) ● EPROCESS has two pointers: Flink, Blink (double-linked list) ● Drivers can modify kernel objects (DKOM) ● Change pointers to make the process “disappear”
  • 27. DKOM rootkit - process hiding: plan ● Create a driver ○ Find the EPROCESS struct for the given process ○ Point front to back, back to front ● Create a loader ● Load the driver ● ... ● Profit! (or, rather, watch the proc disappear and wait for BSOD :D)
  • 28. Process creation 1. Open EXE, create selection object 2. Create executive process object a. Set up EPROCESS b. Set up initial proc. address space c. Create kernel process block d. Conclude setup of process address space e. Set up PEB f. Complete the setup 3. Create initial thread (stack, context, executive thread object) 4. Notify the Win32 subsystem of the new process 5. Start initial thread execution (unless CREATE_SUSPENDED) 6. Complete initialization (i.e. load DLLs), begin execution
  • 29. Process creation 1. Open EXE, create selection object 2. Create executive process object a. Set up EPROCESS b. Set up initial proc. address space c. Create kernel process block d. Conclude setup of process address space e. Set up PEB f. Complete the setup 3. Create initial thread (stack, context, executive thread object) 4. Notify the Win32 subsystem of the new process 5. Start initial thread execution (unless CREATE_SUSPENDED) 6. Complete initialization (i.e. load DLLs), begin execution
  • 30. PEB shenanigans: argument spoofing - idea ● PEB stores arguments for the process (runtime) ● PEB is stored in an RW region ● Windows logs process information at creation time ● Taskmgr, for example, gets proc info based on this ● Binary utilizes PEB args
  • 31. PEB shenanigans: argument spoofing - plan ● Create process as suspended ● NtQueryInformationProcess(..., ProcessBasicInformation, ...) -> PEB address ● Update pPEB->ProcessParameters ● Resume process Hint: the easy way is long args -> short args (verified with a ton of pain and misery, tears not included)
  • 32. Bonus: parent spoofing - idea ● CreateProcess can spawn processes, buuuut… To set extended attributes, use a STARTUPINFOEX structure and specify EXTENDED_STARTUPINFO_PRESENT in the dwCreationFlags parameter. [...] InitializeProcThreadAttributeList -> UpdateProcThreadAttribute(lpList, dwFlags, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, ...)
  • 33. Bonus: parent spoofing - code/demo [insert obligatory sacrifice for RNG gods]
  • 34. Bonus: getsystem via parent spoofing - code/demo [insert obligatory sacrifice for RNG gods]
  • 35. Bonus: parent spoofing -> SYSTEM Fact: child process inherits parent’s token Consequence: if we spawn a child under a privileged process (SYSTEM), we get a privileged child
  • 37. Thank you! / Dziękuję za uwagę! ありがとうございます