Crowd Security Intelligence. syn.ac/virusb2014. @patrickwardle. (download slides)



Similar documents
Malware Persistence on OS X Yosemite

Practical Mac OS X Insecurity. Security Concepts, Problems and Exploits on your Mac

Everything is Terrible

Practical Mac OS X Insecurity

Installation of PHP, MariaDB, and Apache

Senomix Timesheets for Mac OS X

End User Devices Security Guidance: Apple OS X 10.10

Using a login script for deployment of Kaspersky Network Agent to Mac OS X clients

Certificates and Application Resigning

"EZHACK" POPULAR SMART TV DONGLE REMOTE CODE EXECUTION

WebView addjavascriptinterface Remote Code Execution 23/09/2013

About This Document 3. Integration and Automation Capabilities 4. Command-Line Interface (CLI) 8. API RPC Protocol 9.

Sophos Anti-Virus for Linux configuration guide. Product version: 9

Installing F-Secure Anti-Virus (FSAV) Table of Contents. FSAV 8.x and FSLS 7.x End of Life. FSAV 9.x and FSLS 9.x End of Life

NaviCell Data Visualization Python API

Software Fingerprinting for Automated Malicious Code Analysis

Witango Application Server 6. Installation Guide for OS X

Grandstream Networks, Inc.

Citrix : Remediation - MAC

AdwareMedic. About AdwareMedic How to use AdwareMedic Frequently Asked Questions Version History... 9 License Agreement...

Spyware Analysis. Security Event - April 28, 2004 Page 1

Using TS-ACCESS for Remote Desktop Access

Secure Shell Demon setup under Windows XP / Windows Server 2003

Turning your managed Anti-Virus

How To Harden Ancient Mac Xp On Mac Moonlight (Mac) On A Macbook V.Xo (Apple) With A Hardening Mode On A Windows Xp On A

Windows Installation 1. On a Windows PC (For MAC, skip to next section), at the file download prompt click Run.

Reverse Engineering and Computer Security

Installing a Symantec Backup Exec Agent on a SnapScale Cluster X2 Node or SnapServer DX1 or DX2. Summary

Wireless Presentation Gateway. User Guide

Automating Linux Malware Analysis Using Limon Sandbox Monnappa K A monnappa22@gmail.com

SEAGATE BUSINESS NAS ACCESSING THE SHELL. February 1, 2014 by Jeroen Diel IT Nerdbox

Pentesting Mobile Applications

Getting Started with the iscan Online Data Breach Risk Intelligence Platform

Firewalls and Software Updates

Guidance End User Devices Security Guidance: Apple OS X 10.9

Honeypots & Honeynets Overview. Adli Wahid Security Specialist, APNIC.net adli@apnic.net

Sophos Anti-Virus for Linux configuration guide. Product version: 9

Persist It Using and Abusing Microsoft s Fix It Patches

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

Legal notices. Legal notices. For legal notices, see

Chapter 4. System Software. What You Will Learn... Computers Are Your Future. System Software. What You Will Learn... Starting the Computer

Tutorial: Assigning Prelogin Criteria to Policies

CUNY TUMBLEWEED (SECURE TRANSPORT) USER GUIDE

How To Package In Composer (Amd64)

Sophos Anti-Virus for Linux user manual

Client Management - MCX

Future Technology Devices International Ltd. Mac OS-X Installation Guide

Application Whitelisting - Extend your Security Arsenal? Mike Baldi Cyber Security Architect Honeywell Process Solutions

FortiClient SSL VPN Client User s Guide

Backing Up TestTrack Native Project Databases

Casper Suite Administrator s Guide. Version 9.0

Portal Instructions for Mac

Comprehensive Malware Detection with SecurityCenter Continuous View and Nessus. February 3, 2015 (Revision 4)

Remote Configuration for FileBrowser

The current case DNSChanger what computer users can do now

Intelligent Power Protector User manual extension for Microsoft Virtual architectures: Hyper-V 6.0 Manager Hyper-V Server (R1&R2)

ABSTRACT' INTRODUCTION' COMMON'SECURITY'MISTAKES'' Reverse Engineering ios Applications

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Using Microsoft Visual Studio API Reference

Incremental Backup Script. Jason Healy, Director of Networks and Systems

Storm Worm & Botnet Analysis

Abysssec Research. 1) Advisory information. 2) Vulnerable version

Silk Test Testing Mobile Applications

Content Management System

Aqua Connect Load Balancer User Manual (Linux)

Author A.Kishore/Sachin VNC Background

Securing ios Applications. Dr. Bruce Sams, OPTIMAbit GmbH

APPLICATION SECURITY: FROM WEB TO MOBILE. DIFFERENT VECTORS AND NEW ATTACK

Mass Deploying Bomgar Software to Macs

Source Code Review Using Static Analysis Tools

Healthstone Monitoring System

Virtualization for Security

User's Manual. Intego VirusBarrier Server 2 / VirusBarrier Mail Gateway 2 User's Manual Page 1

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

QuickStart Guide for Client Management. Version 8.7

Detecting Malware With Memory Forensics. Hal Pomeranz SANS Institute

Streamlined Malware Incident Response with EnCase

SAIP 2012 Performance Engineering

Windows and MAC User Handbook Remote and Secure Connection Version /19/2013. User Handbook

Kaseya 2. User Guide. Version 7.0. English

What Do You Mean My Cloud Data Isn t Secure?

Complete Patch Management

egambit Forensic egambit, your defensive cyber-weapon system. You have the players. We have the game.

The BackTrack Successor

Background on Elastic Compute Cloud (EC2) AMI s to choose from including servers hosted on different Linux distros

Shellshock. Oz Elisyan & Maxim Zavodchik

Citrix XenApp 6.5 User Guide. For Windows and OS X


Click Start > Control Panel > System icon to open System Properties dialog box. Click Advanced > Environment Variables.

Sophos Computer Security Scan startup guide

Kaseya 2. User Guide. Version R8. English

BYOD AND NEXT- GENERATION MOBILE SECURITY

Host Hardening. OS Vulnerability test. CERT Report on systems vulnerabilities. (March 21, 2011)

Hadoop Basics with InfoSphere BigInsights

Virtually Secure. a journey from analysis to remote root 0day on an industry leading SSL-VPN appliance

Casper Suite Administrator s Guide. Version 9.2

Transcription:

Crowd Security Intelligence (download slides) syn.ac/virusb2014 @patrickwardle

METHODS of MALWARE PERSISTENCE on os x mavericks

ABOUT [synack] sources a global contingent of vetted security experts worldwide and pays them on an incentivized basis to discover security vulnerabilities in our customers web apps, mobile apps, and infrastructure endpoints. patrick wardle /NASA /NSA /VRL /SYNACK

AN OUTLINE background, persistence, malware, & detection background os x malware methods of persistence autoruns for os x

BACKGROUND why you should care

THE RISE OF MACS macs are everywhere (home & enterprise) doesn t include idevices apple is now the #3 vendor in usa pc shipments percentage 14 10.5 7 3.5 0 '09 '10 '11 '12 year macs as % of total usa pc sales '13

MALWARE ON OS X? but macs don t get malware right? It doesn t get PC viruses. A Mac isn t susceptible to the thousands of viruses plaguing Windows-based computers. -apple.com (2012) first virus (elk cloner) infected apple II s last year, 33 new os x malware families

APPLE S RESPONSE OS X now contains many anti-malware features so we re all safe now, right?!? xprotect gatekeeper }nope! < wins os x sandbox code-signing

THE CURRENT SITUATION the apple juice is sour + lots of macs + feeble anti-malware protections + os x malware limited os x malware analysis tools by identifying persistence mechanisms in os x and studying malware that abuses these, we can (better) protect ourselves.and a new analysis tool can help as well

METHODS OF PERSISTENCE where malware may live

LOW LEVEL the boot process affords several opportunities for persistence often highly complex, though very insidious and difficult to detect replace/patch the boot.efi? install malicious EFI components? re-flash the bootrom? infecting the boot process mac efi rootkits by loukas k (snare)

KERNEL EXTENSIONS loaded automatically into ring-0 write a KEXT copy to KEXT directory set ownership to root rebuild kernel cache also: /System/Library/Extensions # cp - R persist.kext /Library/Extensions! # chown - R root:wheel /Library/Extensions/persist.kext! # kextcache - system- prelinked- kernel # kextcache - system- caches installing a kext

LAUNCH DAEMONS & AGENTS similar to windows services daemons and agents are started by launchd daemons agents non interactive, launched pre-login /System/Library/LaunchDaemons /Library/LaunchDaemons interactive, launched post-login /System/Library/LaunchAgents /Library/LaunchAgents ~/Library/LaunchAgents

LAUNCH DAEMONS & AGENTS registered ( installed ) via a property list label/identifier auto launch plist instructs launchd how/when to load the item <?xml version="1.0" encoding="utf- 8"?> <!DOCTYPE plist PUBLIC...> <plist version="1.0"> <dict> <key>label</key> <string>com.example.persist</string> <key>programarguments</key> <array> <string>/path/to/persist</string> <string>args?</string> </array> <key>runatload</key> <true/> </dict> </plist> daemon/agent plist binary image

CRON JOBS used to automatically run scrips/commands popular with malware writers coming from *nix based backgrounds can use @reboot, @daily, etc. $ echo "* * * * * echo \"I'm persisting\"" > /tmp/persistjob! $ crontab /tmp/persistjob create! $ crontab - l * * * * * echo "I'm persisting" creating & installing a cron job

LOGIN & LOGOUT HOOKS allow a script to be automatically executed at login and/or logout # defaults write com.apple.loginwindow LoginHook /usr/bin/hook.sh # ~/Library/Preferences/com.apple.loginwindow.plist <?xml version="1.0" encoding="utf- 8"?> <!DOCTYPE plist...> <plist version="1.0"> <dict> <key>loginhook</key> <string>/usr/bin/hook.sh</string> </dict> </plist> login hook script

LOGIN ITEMS legitimate method to ensure apps are executed at login ~/Library/Preferences/com.apple.loginitems.plist System Preferences -> Users & Groups -> Login Items base64 data (path, etc.) <dict> <key>com.apple.lssharedfilelist.binding</key> <data> ZG5pYgAAAAACAAAAAAAAAAAAAAAAAAAAAAAA... </data> <key>com.apple.lssharedfilelist.itemishidden</key> <true/> <key>com.apple.loginitem.hideonlaunch</key> <true/> <key>name</key> <string>ituneshelper</string> </dict> login item

LOGIN ITEMS (SANDBOXED) ensure sandboxed apps are executed at each login, legitimately does not show up in (any) GUI copy persistent app to <main>.app/ Contents/Library/LoginItems/ invoke SMLoginItemSetEnableD() in the main app, with the persistent app s id /private/var/db/launchd.db/ - >com.apple.launchd.peruser.501/overrides.plist //enable auto launch SMLoginItemSetEnabled(( bridge CFStringRef) @"com.company.persistme", YES); sandboxed login item

STARTUP ITEMS allow a script to be automatically executed at each reboot #!/bin/sh. /etc/rc.common StartService() { #anything here } match script's name { Description = "anything"; Provides = ("<name>"); } StartupParameters.plist RunService "$1" persistent script /System/Library/StartupItems /Library/StartupItems

RC.COMMON allows scripts or commands to automatically execute another linux y-based technique how easy is this? # vim /etc/rc.common!... add any commands (at end) modifying rc.common

LAUNCHD.CONF allows launchctl commands to be automatically executed file does not exist by default # echo bsexec 1 /bin/bash <anything.script> > /etc/launchd.conf launchd.conf 'bsexec' is a launchctl command that executes other commands perfect! can also set environment variables via the setenv command (e.g. DYLD_INSERT_LIBRARIES)

DYLD_INSERT_LIBRARIES allows a library to be automatically loaded/executed application $ less /Applications/Safari.app/Contents/Info.plist... <key>lsenvironment</key> <dict> <key>dyld_insert_libraries</key> <string>/usr/bin/evil.dylib</string> </dict> launch item unsign the target binary $ less /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist... <key>environmentvariables</key> <dict> <key>dyld_insert_libraries</key> <string>/usr/bin/evil.dylib</string> </dict> dyld_insert_libraries (app & launch item)

MACH-O INFECTION ensures (injected) code is executed when host is run read, infecting mach-o files (roy g biv) entry point mach-o structure

APPLICATION SPECIFIC plugins or extensions can provide automatic code execution safari firefox chrome browser (chrome) extensions evil plugin (fg!) itunes

PERSISTENCE OS X MALWARE how the bad guys do it

OSX/CALLME (LAUNCH DAEMON) allows for infil/exfil & remote execution of commands fs_usage is like filemon # fs_usage - w - filesystem grep OSX_CallMe open /library/launchdaemons/.dat035f.000 WrData[A] /library/launchdaemons/.dat035f.000 rename /library/launchdaemons/.dat035f.000 - > /library/launchdaemons/realplayerupdate.plist $ ls /Library/LaunchDaemons/real* realplayerupdate.plist the malware $ ps aux grep - i real root 0:00.06 /Library/Application Support/.realPlayerUpdate launch daemon persistence

OSX/FLASHBACK (LAUNCHAGENT) injects ads into users http/https streams persist $ less ~/Library/LaunchAgents/com.java.update.plist <?xml version="1.0" encoding="utf- 8"?> <dict> <key>label</key> <string>com.java.update.plist</string> <key>programarguments</key> <array> <string> /Users/user/.jupdate </string> </array> <key>runatload</key> <true/> (user) launch agent persistence malware s binary

OSX/CRISIS (LAUCHAGENT) collects audio, images, screenshots and method name IDA (pseudo) disassembly ;build path for malware s launch agent plist - [RCSMUtils createlaunchagentplist:forbinary:] call NSHomeDirectory mov [esp+0ch], eax lea edx, @"Library/LaunchAgents/com.apple.mdworker.plist" mov [esp+10h], edx lea edx, "%@/%@" mov [esp+8], edx mov [esp+4], stringwithformat_message_refs mov [esp], NSString_clsRef call _objc_msgsend [NSString stringwithformat:@"%@%@", (user) launch agent persistence NSHomeDirectory(), @"Library/LaunchAgents/com.apple.mdworker.plist"];

OSX/XSLCMD (LAUNCH AGENT) provides reverse shell, infil/exfil, installation of other tools persistence cstring:0000e910 clipboardd db 'clipboardd',0 com_apple_serv db 'com.apple.service.clipboardd.plist',0 $ less ~/Library/LaunchAgents/com.apple.service.clipboardd.plist librarylaunch db '/Library/LaunchAgents',0 <?xml version="1.0" encoding= UTF- 8"?> db '<?xml version="1.0" encoding="utf- 8"?>',0Ah <plist version="1.0"> db '<plist version="1.0">',0ah <dict> db '<dict>',0ah <key>runatload</key> db '<key>runatload</key>',0ah <false/> db '<false/>',0ah <key>keepalive</key> db '<key>keepalive</key>',0ah <true/> db '<true/>',0ah <key>label</key> db '<key>label</key>',0ah <string>com.apple.service.clipboardd</string> db '<string>com.apple.service.clipboardd</string>',0ah <key>program</key> db '<key>program</key>',0ah <string>~/library/launchagents/clipboardd</string> </dict> db '<string>%s</string>',0ah </plist> db '</dict>',0ah db '</plist>',0ah,0 launch daemon persistence

OSX/JANICAB (CRONJOB) collects audio and screenshots janicab s installer.py """ add to crontab """ #add the script to crontab subprocess.call("echo \"* * * * * python ~/.t/runner.pyc \" >>/tmp/dump",shell=true)! #import the new crontab subprocess.call("crontab /tmp/dump",shell=true) subprocess.call("rm - f /tmp/dump",shell=true) $ crontab - l * * * * * python ~/.t/runner.pyc cron job persistence

OSX/KITMOS (LOGIN ITEM) uploads screen shots to a remote c&c server ;build path for malware s launch agent plist - [FileBackupAppDelegate checkautorun] mov dword ptr [esp+18h], 0 mov dword ptr [esp+14h], 0 mov [esp+10h], ebx mov dword ptr [esp+0ch], 0 mov dword ptr [esp+8], 0 mov [esp+4], eax ; _klssharedfilelistitemlast_ptr mov [esp], edi ; _LSSharedFileListCreate call LSSharedFileListInsertItemURL persistence api login item persistence user s login items

OSX/MACPROTECTOR (LOGIN ITEM) fake (rogue) anti-virus product that coerces user into paying up ~/Library/Preferences/com.apple.loginitems.plist base64 encoded path, etc <dict> <key>alias</key> <data> ZG5pYgAAAAACAAAAAAAAAAAAAAAAAAAAAAAA... </data> <key>name</key> <string>macprotector</string> </dict> login item persistence

OSX/YONTOO (BROWSER EXTENSION) injects adds into users browser sessions extracted from IDA disassembly ;create paths for malicious plugins lea edi, cfstr_installingexte ; "Installing extensions" lea ebx, cfstr_ok ; "Ok"... +[ExtensionsInstaller installsafariextension:] "~/Library/Safari/Extensions/Extensions.plist" +[ExtensionsInstaller installfirefoxextension:] "~/Library/Application Support/Mozilla/Extensions" +[ExtensionsInstaller installchromeextension:] "~/Library/Application Support/Google/Chrome/External Extensions" browser extension persistence

OSX/CLAPZOK (VIRAL INFECTION) researcher released proof-of-concept image src: http://reverse.put.as/ (fg!) entry point load command binary infection persistence

KNOCK KNOCK autoruns for OS X

KNOCK KNOCK S DESIGN & GOALS finds stuff that will automatically execute during startup open-source, plugin-oriented, design aims to encourage collaboration & evolution scan core engine malware plugins auto run binaries & commands github.com/synack/knockknock

KNOCKKNOCK S PLUGINS one for each particular persistence technique #launch daemon directories LAUNCH_DAEMON_DIRS = ['/System/Library/LaunchDaemons/', '/Library/LaunchDaemons/'] #init results results['launchagents'] = [] #get all files in launch daemon directories for directory in LAUNCH_DAEMON_DIRS: launchitems.extend(glob.glob(directory + '*')) #iterate over launch daemon files (plists) # - >find/save ones that are set to auto run for item in launchitems: plistdata = utils.loadplist(item) if plistdata[ RunAtLoad'] or plistdata['keepalive']: results.append(file.file(plistdata['programarguments'][0])) persistence? (simplified) launch daemon plugin

KNOCKKNOCK OUTPUT (currently) command-line $ python knockknock.py - p launchdanda WHO'S THERE: [Launch Agents]! clipboardd path: /Users/user/Library/LaunchAgents/clipboardd plist: /Users/user/Library/LaunchAgents/com.apple.service.clipboardd.plist hash: 60242ad3e1b6c4d417d4dfeb8fb464a1! TOTAL ITEMS FOUND: 1 OSX/XSLCmd detection

SOME CONCLUSIONS with tonnes of persistence methods + insecure macs = os x malware but knowledge is power & knockknock can help!

QUESTIONS & ANSWERS feel free to contact me any time! patrick@synack.com @patrickwardle syn.ac/virusb2014 try it out! github.com/synack/knockknock

credits thezooom.com deviantart.com (FreshFarhan) iconmonstr.com flaticon.com