SlideShare a Scribd company logo
1 of 18
Download to read offline
Center of vulnerability research
Yurii Drozdov Liudmila Drozdova
DCG#7812
Saint-Petersburg
2016
WINDOWS 10 ANNIVERSARY UPDATE:
GDI HANDLE MANAGEMENT AND
VULNERABILITY EXPLOITATION
GDI HANDLE MANAGEMENT BEFORE WINDOWS
10 ANNIVERSARY UPDATE
• Win32k.sys contains gdi handle manager (win32kbase.sys for Windows 10),
functions with Hmg* prefix are responsible for handle management.
• HmgInsertObject inserts every gdi object (Bitmap, Brush, Font, Pen ….) into handle
table after allocation in kernel mode.
• Handle table is mapping to address space of every gui process. Pointer to mapped
table is located in the PEB.GdiSharedHandleTable field.
GDI HANDLE MANAGEMENT BEFORE WINDOWS
10 ANNIVERSARY UPDATE
Every object in handle table described by following structure
typedef struct {
PVOID64 pKernelAddress;
USHORT wProcessId;
USHORT wCount;
USHORT wUpper;
USHORT wType;
PVOID64 pUserAddress;
} GDICELL64;
So, we can get kernel address of gdi object from usermode.
OLD HMGINSERTOBJECT
Every object must be added to handle table after creation. Handle table pointer saved in win32k variable gpentHmgr (its pointer is
located in PEB.GdiSharedHandleTable in usermode).
HmgInsertObject function inserts object into handle table and contains following code
HmgInsertObject(_BASEOBJECT *ObjectKernelAddress,
unsigned __int16 flags,
unsigned __int8 objtype) {
...
Handle = hGetFreeHandle(objtype);
ENTRYOBJ::vSetup(
(gpentHmgr + 24i64 * LOWORD(Handle)),
ObjectKernelAddress,
objtype,
flags,
LOWORD(Handle));
...
}
ENTRYOBJ::vSetup function is filling GDICELL64 structure with given parameters.
WHY DO WE NEED GDI KERNEL OBJECT
ADDRESS DURING EXPLOITATION?
• To make exploit more stable:
• 1) we can check if object was allocated on the right place after spray.
• 2) we can change memory layout as we want.
• Sometimes it is important part of exploitation.
• 1) We can change Bitmap (SURFOBJ) fields and gain arbitrary read and write when we
know its address.
• We can use gdi objects for exploitation even if we have vulnerability in different (not
win32k) system component.
• SURFOBJ is one of the popular ways to achieve privilege escalation, which is working
from Vista to 10.
WINDOWS 10 ANNIVERSARY UPDATE
• Gdi handle management was changed a lot after update of Windows 10.
• PEB.GdiSharedHandleTable doesn’t contain kernel addresses anymore.
• New handle management classes and functions were added in win32kbase.sys.
• This update was introduced for Windows 10 only, but other systems can be affected soon.
WIN32KBASE.SYS CHANGES
• New Hmg* functions were added. The most interesting – HmgPentryFromPobj, because it
references new class GdiHandleManager.
• New handle management classes were added – GdiHandleManager,
GdiHandleEntryDirectory, GdiHandleEntryTable, EntryDataLookupTable.
• HmgCreate creates and initializes handle table (like in old version).
• We can easily track all changes via HmgInserObject function.
OLD GDI.GDISHAREDHANDLETABLE CONTENT
NEW PEB.GDISHAREDHANDLETABLE CONTENT
GDI HANDLE MANAGEMENT IN WINDOWS 10
ANNIVERSARY UPDATE
STRUCTURES OF NEW GDI HANDLE MANAGER
struct GdiHandleManager {
DWORD64 unknown;
DWORD max_handle_count;
DWORD unknown;
GdiHandleEntryDirectory * Dir;
}
struct GdiHandleEntryDirectory {
BYTE busy_flag ;
BYTE unknown;
WORD TableCount ;
DWORD unknown1 ;
GdiHandleEntryTable * Tables[0x100] ;
DWORD MaxHandleCount ;
} ;
struct GdiHandleEntryTable {
GDICELL64 * SharedMem_or_CellData ;
DWORD MaxHandleCount ;
DWORD unknown1 ;
DWORD unknown2 ;
DWORD unknown3 ;
EntryDataLookupTable * GdiLookupTable ;
} ;
struct EntryDataLookupTable {
LookupEntryAddress *LookupTableData ;
DWORD MaxHandleCount ;
DWORD unknown1 ;
} ;
struct LookupEntryAddress {
LOOKUP_ENTRY *leaddress ;
} ;
struct LOOKUP_ENTRY {
DWORD64 unknown;
PVOID64 GdiObjectAddress;
}
WHAT PEB.GDISHAREDHANDLETABLE
CONTAINS?
• Handle entry size wasn’t changed, it is like old GDICELL64 size – 0x18
typedef struct {
PVOID64 pKernelAddress;
USHORT wProcessId;
USHORT wCount;
USHORT wUpper;
USHORT wType;
PVOID64 pUserAddress;
} GDICELL64;
• The main change – pKernelAddress contains value 0xffffffffff000000 | dword_index, where dword_index =
[zero_byte][unused_table_index][lookup_entry_address_index]|[lookup_entry_index]
• no kernel addresses anymore.
HOW TO GET GDI OBJECT ADDRESS BY HANDLE
(X64) ?
Before updates Windbg command looked like this (handle in this case - 0x3c05096a)
• dq poi(poi(win32kbase!gpentHmgr) + 0x18*(0x3c05096a & 0xffff))
After changes (handle in this case - 0x1f0509e)
• dq poi(poi(poi(poi(poi((poi(poi(win32kbase!gpHandleManager)+0x10) + 8 + 0*8)) +
0x18)) + ((0x1f0509ea & 0xffff) / 0x100) * 8) + (0x1f0509ea & 0xff)*0x10 + 8)
RESULT OF EXECUTION OF WINDBG COMMAND
ON UPDATED WINDOWS 10 SYSTEM
CHANGES SUMMARY
• Object metadata (pid, object type …) and object address were saved
together in GDICELL structure before update and both were mapped to
userspace.
• Now, only object metadata is mapping, kernel addresses are located in
kernel pool inaccessible from usermode.
LPE VULNERABILITIES EXPLOITATION AFTER
UPDATES
• All this changes made exploitation more difficult. But there are few possible solutions. Gdi
is good, but not only exploitation approach.
• We still have user objects (window, cursor, menu etc) and we can still get their addresses!
i.e. we can use user objects in some exploits instead of gdi objects.
• Theoretically we can still use gdi objects (SURFOBJ): we can try to predict location of
object via spray.
• We can find additional vulnerability which will allow us to get gdi object address (we have
few ideas, but need some time to check them).
LINKS
• https://www.blackhat.com/docs/us-16/materials/us-16-Weston-Windows-10-Mitigation-
Improvements.pdf
• http://cvr-data.blogspot.ru/
Дроздов Юрий и Дроздова Людмила - Windows 10: Последние изменения в управлении хендлами gdi объектов и их влияние на процесс эксплуатации уязвимостей

More Related Content

Viewers also liked

Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
DefconRussia
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Peter Hlavaty
 

Viewers also liked (17)

nosymbols - defcon russia 20
nosymbols - defcon russia 20nosymbols - defcon russia 20
nosymbols - defcon russia 20
 
Weakpass - defcon russia 23
Weakpass - defcon russia 23Weakpass - defcon russia 23
Weakpass - defcon russia 23
 
Attacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринAttacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей Тюрин
 
static - defcon russia 20
static  - defcon russia 20static  - defcon russia 20
static - defcon russia 20
 
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Nedospasov defcon russia 23
Nedospasov defcon russia 23Nedospasov defcon russia 23
Nedospasov defcon russia 23
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
HTTP HOST header attacks
HTTP HOST header attacksHTTP HOST header attacks
HTTP HOST header attacks
 
Miasm defcon russia 23
Miasm defcon russia 23Miasm defcon russia 23
Miasm defcon russia 23
 
Tyurin Alexey - NTLM. Part 1. Pass-the-Hash
Tyurin Alexey - NTLM. Part 1. Pass-the-HashTyurin Alexey - NTLM. Part 1. Pass-the-Hash
Tyurin Alexey - NTLM. Part 1. Pass-the-Hash
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implement
 
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
 
Automating Post Exploitation with PowerShell
Automating Post Exploitation with PowerShellAutomating Post Exploitation with PowerShell
Automating Post Exploitation with PowerShell
 
Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000
Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000
Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000
 

More from DefconRussia

Roman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 ScaryRoman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 Scary
DefconRussia
 
Roman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 PracticeRoman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 Practice
DefconRussia
 
Roman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 TheoryRoman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 Theory
DefconRussia
 
Peter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzzPeter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzz
DefconRussia
 
Vadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitationVadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitation
DefconRussia
 

More from DefconRussia (8)

Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхSergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
 
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
 
Anton Alexanenkov - Tor and Botnet C&C
Anton Alexanenkov -  Tor and Botnet C&C Anton Alexanenkov -  Tor and Botnet C&C
Anton Alexanenkov - Tor and Botnet C&C
 
Roman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 ScaryRoman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 Scary
 
Roman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 PracticeRoman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 Practice
 
Roman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 TheoryRoman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 Theory
 
Peter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzzPeter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzz
 
Vadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitationVadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitation
 

Recently uploaded

VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
nirzagarg
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 

Дроздов Юрий и Дроздова Людмила - Windows 10: Последние изменения в управлении хендлами gdi объектов и их влияние на процесс эксплуатации уязвимостей

  • 1. Center of vulnerability research Yurii Drozdov Liudmila Drozdova DCG#7812 Saint-Petersburg 2016 WINDOWS 10 ANNIVERSARY UPDATE: GDI HANDLE MANAGEMENT AND VULNERABILITY EXPLOITATION
  • 2. GDI HANDLE MANAGEMENT BEFORE WINDOWS 10 ANNIVERSARY UPDATE • Win32k.sys contains gdi handle manager (win32kbase.sys for Windows 10), functions with Hmg* prefix are responsible for handle management. • HmgInsertObject inserts every gdi object (Bitmap, Brush, Font, Pen ….) into handle table after allocation in kernel mode. • Handle table is mapping to address space of every gui process. Pointer to mapped table is located in the PEB.GdiSharedHandleTable field.
  • 3. GDI HANDLE MANAGEMENT BEFORE WINDOWS 10 ANNIVERSARY UPDATE Every object in handle table described by following structure typedef struct { PVOID64 pKernelAddress; USHORT wProcessId; USHORT wCount; USHORT wUpper; USHORT wType; PVOID64 pUserAddress; } GDICELL64; So, we can get kernel address of gdi object from usermode.
  • 4. OLD HMGINSERTOBJECT Every object must be added to handle table after creation. Handle table pointer saved in win32k variable gpentHmgr (its pointer is located in PEB.GdiSharedHandleTable in usermode). HmgInsertObject function inserts object into handle table and contains following code HmgInsertObject(_BASEOBJECT *ObjectKernelAddress, unsigned __int16 flags, unsigned __int8 objtype) { ... Handle = hGetFreeHandle(objtype); ENTRYOBJ::vSetup( (gpentHmgr + 24i64 * LOWORD(Handle)), ObjectKernelAddress, objtype, flags, LOWORD(Handle)); ... } ENTRYOBJ::vSetup function is filling GDICELL64 structure with given parameters.
  • 5. WHY DO WE NEED GDI KERNEL OBJECT ADDRESS DURING EXPLOITATION? • To make exploit more stable: • 1) we can check if object was allocated on the right place after spray. • 2) we can change memory layout as we want. • Sometimes it is important part of exploitation. • 1) We can change Bitmap (SURFOBJ) fields and gain arbitrary read and write when we know its address. • We can use gdi objects for exploitation even if we have vulnerability in different (not win32k) system component. • SURFOBJ is one of the popular ways to achieve privilege escalation, which is working from Vista to 10.
  • 6. WINDOWS 10 ANNIVERSARY UPDATE • Gdi handle management was changed a lot after update of Windows 10. • PEB.GdiSharedHandleTable doesn’t contain kernel addresses anymore. • New handle management classes and functions were added in win32kbase.sys. • This update was introduced for Windows 10 only, but other systems can be affected soon.
  • 7. WIN32KBASE.SYS CHANGES • New Hmg* functions were added. The most interesting – HmgPentryFromPobj, because it references new class GdiHandleManager. • New handle management classes were added – GdiHandleManager, GdiHandleEntryDirectory, GdiHandleEntryTable, EntryDataLookupTable. • HmgCreate creates and initializes handle table (like in old version). • We can easily track all changes via HmgInserObject function.
  • 10. GDI HANDLE MANAGEMENT IN WINDOWS 10 ANNIVERSARY UPDATE
  • 11. STRUCTURES OF NEW GDI HANDLE MANAGER struct GdiHandleManager { DWORD64 unknown; DWORD max_handle_count; DWORD unknown; GdiHandleEntryDirectory * Dir; } struct GdiHandleEntryDirectory { BYTE busy_flag ; BYTE unknown; WORD TableCount ; DWORD unknown1 ; GdiHandleEntryTable * Tables[0x100] ; DWORD MaxHandleCount ; } ; struct GdiHandleEntryTable { GDICELL64 * SharedMem_or_CellData ; DWORD MaxHandleCount ; DWORD unknown1 ; DWORD unknown2 ; DWORD unknown3 ; EntryDataLookupTable * GdiLookupTable ; } ; struct EntryDataLookupTable { LookupEntryAddress *LookupTableData ; DWORD MaxHandleCount ; DWORD unknown1 ; } ; struct LookupEntryAddress { LOOKUP_ENTRY *leaddress ; } ; struct LOOKUP_ENTRY { DWORD64 unknown; PVOID64 GdiObjectAddress; }
  • 12. WHAT PEB.GDISHAREDHANDLETABLE CONTAINS? • Handle entry size wasn’t changed, it is like old GDICELL64 size – 0x18 typedef struct { PVOID64 pKernelAddress; USHORT wProcessId; USHORT wCount; USHORT wUpper; USHORT wType; PVOID64 pUserAddress; } GDICELL64; • The main change – pKernelAddress contains value 0xffffffffff000000 | dword_index, where dword_index = [zero_byte][unused_table_index][lookup_entry_address_index]|[lookup_entry_index] • no kernel addresses anymore.
  • 13. HOW TO GET GDI OBJECT ADDRESS BY HANDLE (X64) ? Before updates Windbg command looked like this (handle in this case - 0x3c05096a) • dq poi(poi(win32kbase!gpentHmgr) + 0x18*(0x3c05096a & 0xffff)) After changes (handle in this case - 0x1f0509e) • dq poi(poi(poi(poi(poi((poi(poi(win32kbase!gpHandleManager)+0x10) + 8 + 0*8)) + 0x18)) + ((0x1f0509ea & 0xffff) / 0x100) * 8) + (0x1f0509ea & 0xff)*0x10 + 8)
  • 14. RESULT OF EXECUTION OF WINDBG COMMAND ON UPDATED WINDOWS 10 SYSTEM
  • 15. CHANGES SUMMARY • Object metadata (pid, object type …) and object address were saved together in GDICELL structure before update and both were mapped to userspace. • Now, only object metadata is mapping, kernel addresses are located in kernel pool inaccessible from usermode.
  • 16. LPE VULNERABILITIES EXPLOITATION AFTER UPDATES • All this changes made exploitation more difficult. But there are few possible solutions. Gdi is good, but not only exploitation approach. • We still have user objects (window, cursor, menu etc) and we can still get their addresses! i.e. we can use user objects in some exploits instead of gdi objects. • Theoretically we can still use gdi objects (SURFOBJ): we can try to predict location of object via spray. • We can find additional vulnerability which will allow us to get gdi object address (we have few ideas, but need some time to check them).