In our continued research on Operation Pawn Storm, we found one interesting poisoned pawn—spyware specifically designed for espionage on iOS devices. While spyware targeting Apple users is highly notable by itself, this particular spyware is also involved in a targeted attack. **_Background of Operation Pawn Storm_** [Operation Pawn Storm is an active economic and political cyber-espionage operation that targets a wide](http://www.trendmicro.com/vinfo/us/security/news/cyber-attacks/pawn-storm-espionage-attacks-use-decoys-deliver-sednit) range of entities, like the military, governments, defense industries, and the media. The actors of Pawn Storm tend to first move a lot of pawns in the hopes they come close to their actual, high profile targets. When they finally successfully infect a high profile target, they might decide to move their next pawn forward: advanced espionage malware. The iOS malware we found is among those advanced malware. We believe the iOS malware gets installed on already compromised systems, and it is very similar to next stage SEDNIT malware we have found for Microsoft Windows’ systems. We found two malicious iOS applications in Operation Pawn Storm. One is called XAgent (detected as IOS_XAGENT.A) and the other one uses the name of a legitimate iOS game, MadCap (detected as IOS_ XAGENT.B). After analysis, we concluded that both are applications related to SEDNIT. The obvious goal of the SEDNIT-related spyware is to steal personal data, record audio, make screenshots, and send them to a remote command-and-control (C&C) server. As of this publishing, the C&C server contacted by the iOS malware is live. **_Analysis of XAgent_** The XAgent app is fully functional malware. After being installed on iOS 7, the app’s icon is hidden and it runs in the background immediately. When we try to terminate it by killing the process, it will restart almost immediately. Installing the malware into an iOS 8 device yields different results. The icon is not hidden and it also cannot restart automatically. This suggests that the malware was designed prior to the release of iOS 8 last September 2014. **_Data Theft Capabilities_** The app is designed to collect all kind of information on an iOS device. It is able to perform the following routines: ----- Get contact lists Get pictures Collect geo-location data Start voice recording Get a list of installed apps Get a list of processes Get the Wi-Fi status **_C&C Communication_** _Figure 1. XAgent code structure_ Besides collecting information from the iOS device, the app sends the information out via HTTP. It uses POST request to send messages, and GET request to receive commands. **_Formatted Log Messages_** The malware’s log messages are written in HTML and color coded, making it easier for human operators to read. Error messages tend to be in red, while others are in green as shown in the figure below. ----- _Figure 2. Color-coded HTML log messages_ **_A Well-Designed Code Structure_** We can see that the code structure of the malware is very organized. The malware looks carefully maintained and consistently updated. _Figure 3. XAgent code structure_ The app uses the commands watch, search, find, results, _open, and close._ _Figure 4. List of base URIs_ **_Randomly Generated URI_** ----- template agreed upon with the C&C server. The base URI can be seen in Figure 4, and parameters are chosen from the list below and appended to the base URI. _Figure 5. List of parameters used with URIs_ Here are corresponding implementations we got during our reversing: _Figures 6 and 7. Code for URI generation_ **_Token Format and Encoding_** The malware uses a token to identify which module is communicating. The token is Base64 encoded data, but padded with a 5-byte random prefix so that it looks like valid Base64 data. See the first line “ai=” part in the figure below. ----- _Figure 8. Client (XAgent) request_ Reverse engineering also revealed additional communication functions. _Figure 9. HTTP communication functions_ _Figure 10. C2 server_ **_FTP Communication_** ----- _Figure 11. FTP communication functions_ **_Analysis of “MadCap”_** “Madcap” is similar to the XAgent malware, but the former is focused on recording audio. “Madcap” can only be installed on jailbroken devices. _Figure 12. Code structure of Madcap_ **_Possible Infection Methods_** ----- doesn t have to be jailbroken per se. We have seen one instance wherein a lure involving XAgent simply says “Tap Here to Install the Application.” The app uses Apple’s ad hoc provisioning, which is a standard distribution method of Apple for iOS App developers. Through ad hoc provisioning, the malware can be installed simply by clicking on a link, such as in the picture below. The link will lead to https://www. _{BLOCKED}/adhoc/XAgent.plist, a service that installs applications wirelessly._ _Figure 13. Site used in downloading XAgent_ There may be other methods of infection that are used to install this particular malware. One possible [scenario is infecting an iPhone after connecting it to a compromised or infected Windows laptop via a USB](http://blog.trendmicro.com/trendlabs-security-intelligence/the-other-side-of-masque-attacks-data-encryption-not-found-in-ios-apps/) cable. _To learn more about this campaign, you may refer to our report, Operation Pawn Storm Using Decoys_ _to Evade Detection._ The hashes of the related files are: 05298a48e4ca6d9778b32259c8ae74527be33815 176e92e7cfc0e57be83e901c36ba17b255ba0b1b 30e4decd68808cb607c2aba4aa69fb5fdb598c64 **_Special thanks to Loucif Kharouni and Fernando Merces for additional insights._** -----