此工具允许您验证一个简单的 Java Web 应用程序是否对 CVE-2021-44228 存在漏洞,基于用户提供的 Java 和 Log4J 版本。
您还可以(可选地)应用几种预定义的缓解措施之一。
由 log4shell_validator.py 启动的模拟实验室使用 docker-compose 来模拟利用 log4j 漏洞并在易受攻击的机器上获得 RCE。
首先,需要构建一些 Docker 镜像。./build_images.sh 脚本会处理这些。
攻击模拟按以下方式进行:
/2021-44228-via-message 的 GET 调用时,它始终记录 User-Agent 头字段。此应用程序的代码位于 ./poc_template。./exploit.sh 脚本,该脚本向易受攻击的应用程序发送负载。cd marshalsec/ ;mvn clean package -DskipTests ;cd -./build-images.shpython log4shell_validator.py --java-version 8 --log4j-version 2.12.1~/workspace/CVE-2021-44228-playground$ python log4shell_validator.py --help
usage: log4shell_validator.py [-h] [--java-version JAVA_VERSION] --log4j-version LOG4J_VERSION [--no-cleanup] [--disable-trust-url] [--remove-jndi-lookup-class] [--disable-message-lookup] [--debug]
[--exploit-via-thread-context]
log4j-vulnerability-tester
optional arguments:
-h, --help show this help message and exit
--java-version JAVA_VERSION
version of java to be used
--log4j-version LOG4J_VERSION
version of log4j to be used
--no-cleanup Don't delete used containers.
--disable-trust-url Disable the LDAP trustURLCodebase setting on the victim app
--remove-jndi-lookup-class
Remove the JNDI Lookup class from the log4j jar file
--disable-message-lookup
Disable the JNDI message lookup in the victim app's JVM
--debug Display all container's logs
--exploit-via-thread-context
By sending the payload to an HTTP handler which makes use of Custom logging with ThreadContext, attempt to bypass the no-message-lookup mitigation
此验证器已使用 Java7/8 的几种组合以及不同版本的 Log4J2 进行了测试,更多示例请参见 github actions 选项卡中的扩展测试管道。
目前,已实现以下缓解措施:
com.sun.jndi.ldap.object.trustURLCodebase 设置为 False 来禁用 LDAP 的 trustURLCodebase。-Dlog4j2.formatMsgNoLookups=True此外,添加了一个新标志,用于测试一种可以绕过禁用消息查找的利用向量:--exploit-via-thread-context
本软件纯粹为研究和开发有效缓解技术而创建,除非得到明确授权,否则不得用于攻击系统。项目维护者对软件的滥用不承担任何责任。请负责任地使用。