分享

Streams:安全警告与解除锁定

 沿阶草_2 2013-10-14

  我们从网上下载一些文件,在打开他们的时候,会有如下的提示:

 

Streams:安全警告与解除锁定-Zone.Identifier

 

  如果单击“取消”,该文件或程序会被打开而运行。

  如果单击“运行”,该文件或程序会被打开或运行。

 

  以后在每次打开时,都会有这个对话框出现。如果确认该文件为安全,可以在单击“运行”之前,取消“打开此文件前总是询问”的勾选。

 

  当然,也可以右键单击“属性”,在“常规”选项卡下,会多出一个“安全”的条目,如下图:

 

Streams:安全警告与解除锁定-Zone.Identifier

 

  在这里,单击“解除锁定”,变化如下图:

 

Streams:安全警告与解除锁定-Zone.Identifier

 

  这样也可以使该文件在下次打开时,不出现安全警告。再此右键单击“属性”,在“常规”选项卡下,就看不到“安全”的条目了,如下图:

 

Streams:安全警告与解除锁定-Zone.Identifier

 

  好了,现在我就开始废话了,讲一下相关的知识。 

㈠、Zone Identifier Object

1,原理:

  Microsoft Internet Explorer 是一款流行的WEB浏览器。 
  Windows XP SP2 增加了新的 Windows Internet Explorer 相关的域识别对象(Zone Identifier Object)。在 XP SP2 中,使用 Internet Explorer 或者 Outlook Express 从不可信区域下载文件域识别对象标记为“3”,存储在 ADS( Additional Data Stream 交换数据流)中,如下图:

 

Streams:安全警告与解除锁定-Zone.Identifier

 

  如果本地用户尝试执行文件,用户会被如下的提示:

 

Streams:安全警告与解除锁定-Zone.Identifier

 

  Zone.Identifier 内容如下的数据流:

 

[ZoneTransfer]
ZoneId=3

 

2,说明:


  由于该数据流属于 NTFS 数据流的一部分,所以必须有以下先决条件:

  • 操作系统至少是 Windows XP SP2 ;
  • 浏览器至少是 Microsoft Internet Explorer 6.0 或以上;
  • 文件系统必须是 NTFS ;
  • 必须是使用 Internet Explorer 下载的,使用其他下载软件,例如迅雷等,不会追加此数据流。

 

3,漏洞:

 

  但是 Windows Explorer 缓存文件的域 ID,不能识别文件的域 ID 的更改。如果使用指示不可信域的区域 ID 文件覆盖可信任域 ID 文件,那么覆盖的文件在被 Windows Explorer 打开时,就不会提示警告信息,而导致不信任文件盲目的被执行。

㈡、使用 Streams

1,语法:

 

Usage: streams [-s] [-d] <file or directory>

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

-s 包含子目录.
-d 删除数据流.
支持通配符 e.g. 'streams *.txt'.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

 

2,下载: 

 

下载地址:Streams v1.56

 

3,使用:

 

  将 streams.zip 解压缩得到 streams.exe ,并将 streams.exe 复制到 %SystemRoot%\system32\ 目录下。然后在 CMD 下运行 streams /? ,显示其帮助语法,如下:

 

C:\WINDOWS\system32\CMD.exe本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

Microsoft Windows XP [版本 5.1 2600]
<C> 版权所有 1985-2001 Microsoft Corp.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>streams /?

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals -
www.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

usage: streams [-s] [-d] <file or directory>
-s     Recurse subdirectories
-d     Delete streams

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>

 

  CMD 下运行 streams -s D:\ ,在 D 盘及其所有子目录下查找含有交换数据流的文件,其输出的:

D:\寒夜孤星.exe:
   :Zone.Identifier:$DATA 26

为枚举出所有含有交换数据流的文件。如下:

 

C:\WINDOWS\system32\CMD.exe本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

Microsoft Windows XP [版本 5.1 2600]
<C> 版权所有 1985-2001 Microsoft Corp.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>streams -s D:\

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals -
www.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

D:\寒夜孤星.exe:
   :Zone.Identifier:$DATA 26

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>

 

  CMD 下运行 streams D:\寒夜孤星.exe ,这里的 D:\寒夜孤星.exe 就是我们要检查的文件,其输出的:

D:\寒夜孤星.exe:
   :Zone.Identifier:$DATA 26

表明此文件存在 NTFS 数据流。如下:

 

C:\WINDOWS\system32\CMD.exe本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

Microsoft Windows XP [版本 5.1 2600]
<C> 版权所有 1985-2001 Microsoft Corp.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>streams D:\寒夜孤星.exe

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals -
www.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

D:\寒夜孤星.exe:
   :Zone.Identifier:$DATA 26

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>

 

  CMD 下运行 streams -d D:\寒夜孤星.exe ,这里的 D:\寒夜孤星.exe 就是我们要操作的文件,其中:

D:\寒夜孤星.exe:
   Deleted :Zone.Identifier:$DATA

表示删除交换数据流并成功完成操作。如下: 

 

C:\WINDOWS\system32\CMD.exe本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

Microsoft Windows XP [版本 5.1 2600]
<C> 版权所有 1985-2001 Microsoft Corp.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>streams -d D:\寒夜孤星.exe

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals -
www.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

D:\寒夜孤星.exe:
   Deleted :Zone.Identifier:$DATA

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>

 

  CMD 下运行 streams D:\寒夜孤星.exe ,这里的 D:\寒夜孤星.exe 就是我们要检查的文件,其输出的为空,表明此文件不存在 NTFS 数据流(因为刚才删除了交换数据流)。如下: 

 

C:\WINDOWS\system32\CMD.exe本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

Microsoft Windows XP [版本 5.1 2600]
<C> 版权所有 1985-2001 Microsoft Corp.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>streams D:\寒夜孤星.exe

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals -
www.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>

 

  CMD 下运行 streams -s D:\ ,在 D 盘极其所有子目录下查找含有交换数据流的文件,其输出的:

No files with streams found.

表明 D 盘及其所有子目录下不存在含有交换数据流的文件(因为刚才删除了交换数据流)。如下:

 

C:\WINDOWS\system32\CMD.exe本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

Microsoft Windows XP [版本 5.1 2600]
<C> 版权所有 1985-2001 Microsoft Corp.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>streams -s D:\

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals -
www.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

No files with streams found.

本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

C:\Documents and Settings\寒夜孤星>

 

㈢、其他源代码

1,原理:

 

  项目需要引用Trinet.Core.IO.Ntfs.dll  C# code。

 

2,代码:

 

示例本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Trinet.Core.IO.Ntfs;
using System.IO;

.html
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            FileInfo file=new FileInfo(@"c:\Hanye.chm");
            AlternateDataStreamInfo adsi= file.GetAlternateDataStream("Zone.Identifier", System.IO.FileMode.Create);//创建流

            StreamWriter sw = new StreamWriter(adsi.OpenWrite());
            sw.WriteLine("[ZoneTransfer]" Environment.NewLine "ZoneId=3");//InternetZone
            sw.Close();
            Console.ReadLine();//等待按下回车键,这里右键点击Hanye.chm文件,可以看到解除锁定按钮,说明已成功创建流
            foreach (AlternateDataStreamInfo s in file.ListAlternateDataStreams())
            {
                Console.WriteLine(adsi.Name);
                s.Delete();//删除流
            };
            Console.ReadLine();//等待按下回车键,这里右键点击Hanye.chm文件已看不到锁定按钮,说明已成功删除流


    }
}本文转自http://blog.sina.com.cn/s/blog_51a4af870100biha.html

 

说明:在C盘根文件夹下放置一个名为Hanye.chm的文件,在程序运行后会停在第一个ReadLine处,这时流已创建,右键点击文件可见解除锁定按钮,双击运行会弹出安全警告对话框  按下回车后,程序会显示文件关联的所有流名称,同时删除所有关联流,并停在第二个ReadLine处,这时流已删除,文件属性对话框中已没有解除锁定按钮,但可能是操作系统缓存的原因,第一次运行时仍为弹出安全警告对话框,第二次就正常了。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多