我最近开始研究隐写,并在网上找到了一个教程,在该教程中,为了在另一个文件中隐藏一个新的文本文件,教程提供者使用了类似于以下命令的内容:
notepad.exe file.ext:textfile.txt我发现命令行中的:相当奇怪:记事本认为这是文件的有效指数化,而原始文件(file.ext)现在在磁盘上有了更大的空间来包含来自新文本文件的数据。由于我所知甚少,而且在我的学术生活中使用cmd非常伤感,我想知道这里发生了什么事。这是什么特征?它的用途是什么?这是windows cmd独有的,还是UNIX上的等效项?
发布于 2019-04-11 07:52:25
TL;DR:
您所看到的是NTFS文件系统(FS)中文件的备用数据流(ADS)。
详细信息:
在旧操作系统(OS)中,文件系统(FS)中的一个条目表示一组数据,这意味着一个文件只是一个文件。较新的OSes具有现代FS,允许一个条目表示一个或多个数据集。在NTFS中,这些被称为流,而在其他OSes中,这些通常被称为叉。对于这种解释,这两个术语是同义的。
在今天的FS中,每个文件至少有一个流。第一个流将没有名称,并将有一个类型的$DATA。第一个流有时被称为主流、默认流或匿名流。第一个广告以外的所有广告都有一个名称和一个类型。默认和最常见的流类型是$DATA。
流的全名为以下形式:
<filename>:<stream name>:<stream type>用法:
在Windows中,广告有很多用途(自从你提到notepad.exe之后,就把焦点放在这里)。人们与之交互的最常见的广告(甚至没有意识到)是Zone.Identifier,它被添加到Internet和其他浏览器下载的文件中。另外,这个额外的数据流被操作系统用作“运行可能不安全”的标志。类似地,MS Office应用程序将在打开可能包含恶意宏的文档时使用相同的流来警告用户。在所有这些情况下,都会警告用户,但不会阻止用户打开危险的文件。
Enum工具(例子,并非详尽无遗):
dir /r来自cmd.exe
Streams.exe来自SysInternals
Get-Item来自powershell.exe
演示:创建、查看、阅读、删除
c:\temp> dir /r ads_test*
File Not Foundc:\temp> echo this is normal text>ads_test.txt
c:\temp> dir /r ads_test*
04/11/2019 01:11 AM 21 ads_test.txtc:\temp> echo this is text for an ADS>ads_test.txt:myHiddenAds
c:\temp> dir /r ads_test*
04/11/2019 01:12 AM 21 ads_test.txt
25 ads_test.txt:myHiddenAds:$DATAc:\temp> dir ads_test*
04/11/2019 01:12 AM 21 ads_test.txtc:\temp> more < ads_test.txt
this is normal textc:\temp> more < ads_test.txt:myHiddenAds
this is text for an ADSc:\temp> type nul 2>ads_test.txt:myHiddenAds
c:\temp> dir /r ads_test*
04/11/2019 01:20 AM 21 ads_test.txt
0 ads_test.txt:myHiddenAds:$DATAc:\temp> echo this is yet another ADS>ads_test.txt:CashMeOutside
c:\temp> dir /r ads_test*
04/11/2019 01:24 AM 21 ads_test.txt
25 ads_test.txt:CashMeOutside:$DATA
0 ads_test.txt:myHiddenAds:$DATAc:\temp> powershell.exe -c "& {get-item -path 'c:\temp\ads_test.txt' -stream * | ft -property FileName,Stream,Length}"
FileName Stream Length
-------- ------ ------
C:\temp\ads_test.txt :$DATA 21
C:\temp\ads_test.txt CashMeOutside 25
C:\temp\ads_test.txt myHiddenAds 0c:\temp> powershell.exe -c "& {remove-item -path 'c:\temp\ads_test.txt' -stream myHiddenAds}"
c:\temp> powershell.exe -c "& {get-item -path 'c:\temp\ads_test.txt' -stream * | ft -property FileName,Stream,Length}"
FileName Stream Length
-------- ------ ------
C:\temp\ads_test.txt :$DATA 21
C:\temp\ads_test.txt CashMeOutside 25其他用途:
虽然它并不常见,目录也可以有广告。对于目录,没有默认数据流,但存在默认目录流。目录是流类型$INDEX_ALLOCATION。类型$INDEX_ALLOCATION (目录流)的默认流名是$I30。虽然目录没有默认数据流,但它们可以有命名数据流。
问题:
近几年来,由于广告被坏角色用来编写隐藏的数据、存储病毒和保持持久性,所以它们的声誉一直很差。即使在今天,与广告相比,许多现代病毒扫描器更能检测出来自原始流的威胁。Microsoft、高级威胁保护和SmartScreen可以有效地检测来自主流的广告威胁。
Demo2 --不良演员如何使用广告的无害例子
C:\temp> echo asdf > \\?\c:\temp\COM1.txt
C:\temp> type c:\windows\system32\calc.exe> \\?\c:\temp\COM1.txt:TotallyNotMalware.exe
C:\temp> wmic process call create "\\?\c:\temp\COM1.txt:TotallyNotMalware.exe"
C:\temp> dir /r
04/11/2019 01:30 AM 21 ads_test.txt
25 ads_test.txt:CashMeOutside:$DATA
04/11/2019 02:45 AM 7 COM1.txt
C:\temp> rem Notice above that the ADS doesn't show - This is because "COM1" is a system reserved name, and many internal and 3rd party programs deal with it wrong.补充读数:
https://stackoverflow.com/questions/55623324
复制相似问题