Skip to content

Commit 91dfc36

Browse files
committed
rce bug fix
1 parent 2c86140 commit 91dfc36

File tree

1 file changed

+11
-4
lines changed
  • src/main/java/org/joychou/controller

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,31 @@ public class Rce {
2525
public String CommandExec(HttpServletRequest request){
2626
String cmd = request.getParameter("cmd").toString();
2727
Runtime run = Runtime.getRuntime();
28+
String lineStr = "";
29+
2830
try {
2931
Process p = run.exec(cmd);
3032
BufferedInputStream in = new BufferedInputStream(p.getInputStream());
3133
BufferedReader inBr = new BufferedReader(new InputStreamReader(in));
32-
String lineStr;
33-
while ((lineStr = inBr.readLine()) != null)
34-
return lineStr;
34+
String tmpStr;
35+
36+
while ((tmpStr = inBr.readLine()) != null) {
37+
lineStr += tmpStr + "\n";
38+
System.out.println(tmpStr);
39+
}
40+
3541
if (p.waitFor() != 0) {
3642
if (p.exitValue() == 1)
3743
return "command exec failed";
3844
}
45+
3946
inBr.close();
4047
in.close();
4148
} catch (Exception e) {
4249
e.printStackTrace();
4350
return "Except";
4451
}
45-
return "Cmd exec success.";
52+
return lineStr;
4653
}
4754
}
4855

0 commit comments

Comments
 (0)