Path: blob/master/documentation/modules/exploit/multi/http/apache_commons_text4shell.md
25706 views
Vulnerable Application
This exploit takes advantage of the StringSubstitutor interpolator class, which is included in the Commons Text library. A default interpolator allows for string lookups that can lead to Remote Code Execution. This is due to a logic flaw that makes the “script”, “dns” and “url” lookup keys interpolated by default, as opposed to what it should be, according to the documentation of the StringLookupFactory class. Those keys allow an attacker to execute arbitrary code via lookups primarily using the "script" key.
In order to exploit the vulnerabilities, the following requirements must be met:
Setup
git clone https://github.com/karthikuj/cve-2022-42889-text4shell-dockercd cve-2022-42889-text4shell-dockermvn clean installdocker build --tag=text4shell .docker run -p 80:8080 text4shellVulnerable application now running at port 8080 on docker image's ip address
Verification Steps
Setup the application
Start msfconsole
Do:
use apache_commons_text4shellDo:
set RHOST <docker ip>Do:
set RPORT 8080Do:
set TARGETURI /text4shell/attackDo:
set PARAM searchDo:
set LHOST docker0Do:
run
Options
PARAM
The parameter vulnerable to the exploit.
METHOD
The HTTP method to use. Default: GET
TARGETURI
The URI to target. Default: /
Scenarios
Apache Commons Text 1.8 on Alpine Linux v3.9 JDK 8
Check:
Target: java
Target: Linux Command
Target: Linux Dropper
Apache Commons Text 1.8 on Windows 11 home JDK 14.0.2
Target: Windows EXE Dropper
Target: Windows Command