1 Copyright 2015 Trend Micro Inc.

60
Copyright 2015 Trend Micro Inc. 1

Transcript of 1 Copyright 2015 Trend Micro Inc.

Page 1: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 1

Page 2: 1 Copyright 2015 Trend Micro Inc.

Shifting Paradigms from Windows to Mac Nicholas Ramos and Michelle Morales

Page 3: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 3

Introduction to MAC OS X

Page 4: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 4

Review

Page 5: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 5

MAC OS X Timeline

2016

2015

2014

2013

2012

2011

2009 10.6 – Snow Leopard

10.7 - Lion

10.8 – Mountain Lion

10.9 - Mavericks

10.10 - Yosemite

10.11 – El Capitan

10.12 – macOS Sierra

Page 6: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 6

Getting to Know More

Page 7: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 7

*Market share data is only between Mac and Windows, other operating systems are excluded *Reference: http://www.statista.com/statistics/218089/global-market-share-of-windows-7/

Page 8: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 8

Myths about MAC

• Yes!! There are incidents and there will more to come.

MAC can’t get viruses

• “Mac OS X software has more high-risk vulnerabilities than all versions of Windows put together,” -Bogdan Botezatu

MAC are safer to use compared to windows

• MAC applications crash more than often than in Windows 7 (Network World)

MAC don’t crash

Page 9: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 9

OS X Safety Features

• Built-in anti-malware software

XProtect

• Halts unauthorized binary execution

GateKeeper

• Prevents user apps from accessing Kernel/core level components

Sandboxing

• Only signed kext (drivers) can be loaded

Code Signing

Page 10: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 10

OS X Boot-up Process

Page 11: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 11

Power ON

MAC Boot-Up

Page 12: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 12

MAC Boot-Up

Boot ROM firmware activated

Power-On Self Test (POST)

Page 13: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 13

MAC Boot-Up

EFI selects OS to use

control is passed on to

boot.efi loader

Boot loader loads kernel environment

kernel cache mkext cache

/System/Library/Extensions

Page 14: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 14

MAC Boot-Up

boot loader starts kernel's initialization

initialize MAC and BSD

data structures

initialize I/O kit

kernel looks for root device and

roots BSD off of it

Page 15: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 15

MAC Boot-Up

launchd process spawns important

WindowServer processes

launchd starts loginwindow.app

Page 16: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 16

MAC Boot-Up

Page 17: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 17

Auto-Start Mechanism TRICKS AND WAYS FOR MALWARE PERSISTENCE

Page 18: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 18

Pre-Login Persistence

EFI XNU

(kernel) Kernel Cache

Page 19: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 19

Launched as Daemon or Agent

lau

nch

d Daemon

/System/Library/LaunchDaemons

/Library/LaunchDaemons

Agent

/System/Library/LaunchAgents

/Library/LaunchAgents

~/Library/LaunchAgents

Page 20: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 20

Type of Launched Daemons and Agents Type Location Run on behalf of Purpose

User Agents ~/Library/LaunchAgents Currently logged in user

Third-Party App for Specific user

Global Agents /Library/LaunchAgents Currently logged in user

Third-Party App for all users

Global Daemons /Library/LaunchDaemons root Third-Party App for all users

System Agents /System/Library/LaunchAgents Currently logged in user

Crucial for the OS

System Daemons /System/Library/LaunchDaemons

root

Crucial for the OS

Page 21: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 21

Tools to check for Daemon and Agents

• launchctl

• LaunchControl.app

• Lingon X.app

• lunchy

Page 22: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 22

Login Items

• Associated with a specific user

• SYSTEM PREFERENCES -> USERS & GROUPS -> LOGIN ITEMS

• ~/Library/Preferences/com.apple.loginitems.plist – Path is base64 encoding

Page 23: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 23

Re-opening App after Reboot

• On login, any opened windows or apps will be restored – Malware could use this as auto-start mechanism

– ~/Library/Preferences/ByHost/com.apple.loginwindow.<hardware UUID>.plist

Page 24: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 24

Start-up Items

• Automatically executes a script at each reboot

• Place a malicious script and StartUpParameters.plist to: – /System/Library/StartupItems

– /Library/StartupItems

Page 25: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 25

Application Base

• By targeting specific applications logic/framework – Plugins and extensions can be used

• /Users/<user>/Library/Safari/Extensions

• /Library/Internet Plug-Ins

Page 26: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 26

FileSystem

Page 27: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 27

MAC OS X Filesystem

Scripts

• Perl

• Python

• Bash

Containers

• DMG

• PKG

• Universal Binaries

Binaries

• Mach-O (EXE)

• Dylib (DLL)

• Kext (SYS)

Page 28: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 28

Property List

• *.plist

• Settings and configuration

• XML Format

• Like a decentralized registry (windows)

Page 29: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 29

Binary PLIST (complied PLIST)

• One of the several format used by Apple for PLIST

• Signature @ offset 0 – bplist00

– bplist01

Page 30: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 30

Plist Tools

• Prefs Editor.app

• PlistEdit Pro.app – pledit (using command line)

• Pref Setter.app (slow)

Page 31: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 31

.db files

• Uses SQLite database format

• Signature @ offset 0 – SQLite

Page 32: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 32

.db Tools

• DB Browser for SQLite – http://sqlitebrowser.org/

Page 33: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 33

Universal Binaries/Fat Binaries

• Essentially a wrapper – a simple archiver that concatenates Mach-O Files for multiple architectures

• Supports multiple architecture – PowerPC

– Intel 32-bit

– Intel 64-bit

Page 34: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 34

Fat Binaries

struct at_header {

uint32_t magic; “CAFEBABE”

uint32_t nfat_arch;

};

struct fat_arch {

cpu_type_t cputype;

cpu_subtype_t cpusubtype;

uint32_t offset;

uint32_t size;

uint32_t align;

};

Page 35: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 35

Mach-O File Header struct mach_header {

uint32_t magic;

cpu_type_t cputype;

cpu_subtype_t cpusubtype;

uint32_t filetype;

uint32_t ncmds;

uint32_t sizeofcmds;

uint32_t flags;

uint32_t reserved; /*available for 64-bit*/

};

/* Constant for the magic field of the mach_header (32-bit architectures) */

#define MH_MAGIC 0xfeedface /*POWERPC*/

#define MH_CIGAM 0xcefaedfe /*Intel*/

/* Constant for the magic field of the mach_header_64 (64-bit

architectures) */

#define MH_MAGIC_64 0xfeedfacf /* POWERPC*/

#define MH_CIGAM_64 0xcffaedfe /*Intel*/

Page 36: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 36

MAC Malware Trends

Page 37: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 37

Virus Worm

Backdoor FakeAV

OSX/Leap-A

2006

Renepo a.k.a.

1998

Opener

Lamzev a.k.a.

OSX/Malez

2008

MAC Defender

2011

OSX/Leap-A a.k.a.

Oompa Loompa

• disguised as simple

image file

• infects Cocoa

applications

• spread via iChat instant messaging

a.k.a. Oompa Loompa

First MAC Malwares

Page 38: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 38

Virus Worm

Backdoor FakeAV

OSX/Leap-A

2006

Renepo a.k.a.

1998

Opener

Lamzev a.k.a.

OSX/Malez

2008

MAC Defender

2011

a.k.a. Oompa Loompa

Renepo a.k.a.

Opener

• self-propagating

worm by gaining

root access

• propagates via

networks and

drives

• turns off OS X firewall

First MAC Malwares

Page 39: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 39

Virus Worm

Backdoor FakeAV

OSX/Leap-A

2006

Thunderstrike 2

1998

Opener

Lamzev a.k.a.

OSX/Malez

2008

MAC Defender

2011

a.k.a. Oompa Loompa

Lamzev a.k.a.

OSX/Malez

• hacker tool to

install backdoor

• needs physical

access to the

system

First MAC Malwares

Page 40: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 40

Virus Worm

Backdoor FakeAV

OSX/Leap-A

2006

Renepo a.k.a.

1998

Opener

Lamzev a.k.a.

OSX/Malez

2008

MAC Defender

2011

a.k.a. Oompa Loompa MAC Defender

• attack similar to

ones on Windows

• took the name of

legitimate

MacDefender

program

• poisoned popular

search terms

First MAC Malwares

Page 41: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 41

Virus Worm

Backdoor FakeAV

2013

Clapzok.A

More Recent MAC Malwares

Clapzok.A

• proof-of-concept

virus by JPanic,

updated version

of a Windows

virus

• only infects x86

versions

• multi-platform

infection

Thunderstrike 2 2015

Eleanor 2016

MacKeeper

2014

Page 42: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 42

Virus Worm

Backdoor FakeAV

Thunderstrike 2

• proof-of-concept

worm by security

researchers

• stealth firmware

worm

• can spread once

option ROM on

peripheral devices is infected

More Recent MAC Malwares

2013

Clapzok.A

Thunderstrike 2 2015

Eleanor 2016

MacKeeper

2014

Page 43: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 43

Virus Worm

Backdoor FakeAV

Eleanor

• distributed as

Easydoc

Converter

• connects infected

PC to TOR network

and generates

.onion domain to

access user’s

system using only

the browser

More Recent MAC Malwares

2013

Clapzok.A

Thunderstrike 2 2015

Eleanor 2016

MacKeeper

2014

Page 44: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 44

Virus Worm

Backdoor FakeAV

MacKeeper

• utility software for

“MAC OS X

security and

optimization”

More Recent MAC Malwares

2013

Clapzok.A

Thunderstrike 2 2015

Eleanor 2016

MacKeeper

2014

Page 45: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 45

MAC Ransomware: KeRanger

Transmission v2.90

dmg installer

General.rtf

UPX-packed

Mach-O

Executable

kernel_pid;

kernel_time;

kernel_complete

encrypts users’ files

and hold these for

ransom

Page 46: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 46

Tools For Static Analysis

Page 47: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 47

HexDumpers

• Display a hexdump of a binary file – hexdump –C <filename>

– OxED.app (GUI)

– Hex Fiend (GUI)

Page 48: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 48

File String Extraction

• Search for a pattern – grep ‘regex pattern’ <filename>

• Search for strings – strings <filename>

• String extractor – TExtractor.app (GUI)

Page 49: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 49

Mach-O File Analysis Tools

• Displays and parse the whole Mach-O file – MachOView.app (GUI)

– Otool

– machoviz.anrc-services.com

Page 50: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 50

Tools For Dynamic Analysis

Page 51: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 51

Process Monitoring

• Display running processes – Activity Monitor.app (GUI)

– Task Explorer.app (GUI)

– top | grep ‘process name’

– ps -ef | grep ‘process name’

Page 52: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 52

Persistence Monitoring

• Display lauch daemons or agents – lauchctl list

– KnockKnock

Page 53: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 53

FileSystem Monitoring

• Watch filesystem in realtime in console – fs_usage

• Graphical view of filesystem events – fseventer.app (GUI)

• Track file system activity – AbTriv FS Spy.app (GUI)

• List open files – lsof

Page 54: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 54

Network Monitoring

• Network Traffic Analysis – Wireshark.app (GUI)

• HTTP Parser – Fetcher.app (GUI)

• List active network connections – PortsMonitor.app (GUI)

– netstat –a

Page 55: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 55

Other Tools

• Text and Source Code Editors – TextWrangler.app

– Tincta.app

• API Documentation Browser – Dash.app

Page 56: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 56

Conclusion

Page 57: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 57

Learn MAC Malware Analysis NOW!

Page 58: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 58

References:

• Jonathan Levin: MAC OS X and iOS Internals

• http://electronics.howstuffworks.com/tech-myths/5-myths-about-apple10.htm

• https://www.rsaconference.com/writable/presentations/file_upload/ht-r03-malware-persistence-on-os-x-yosemite_final.pdf

• https://objective-see.com/products/knockknock.html

Page 59: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 59

References: • http://www.toptenreviews.com/software/articles/history-of-macintosh-viruses/

• https://nakedsecurity.sophos.com/2011/10/03/mac-malware-history/

VIRUS

• http://www.macworld.com/article/1049459/leapafaq.html

• http://reverse.put.as/2013/05/31/clapzok-a-reversing-the-os-x-part-of-a-multiplatform-poc-infector/

WORM

• https://www.macobserver.com/tmo/article/Renepo_Worm_Targets_Mac_OS_X

• https://www.wired.com/2015/08/researchers-create-first-firmware-worm-attacks-macs/

BACKDOOR

• http://www.zdnet.com/article/mac-os-x-targeted-by-trojan-and-backdoor-tool/

• http://news.softpedia.com/news/new-malware-uses-tor-to-open-backdoor-on-mac-os-x-systems-506000.shtml

FAKEAV

• http://www.eweek.com/c/a/Security/Fake-AV-Targets-Mac-OS-X-Through-Poisoned-Search-Links-644121

• http://www.thesafemac.com/ongoing-mackeeper-fraud/

• https://discussions.apple.com/docs/DOC-3036

RANSOMWARE

• http://researchcenter.paloaltonetworks.com/2016/03/new-os-x-ransomware-keranger-infected-transmission-bittorrent-client-installer/

macOS Sierra

• http://www.macrumors.com/roundup/macos-sierra/

Page 60: 1 Copyright 2015 Trend Micro Inc.

Copyright 2015 Trend Micro Inc. 60

Thank you!!!