Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
Advanced Mac Os x Rootkits

Advanced Mac Os x Rootkits

Ratings: (0)|Views: 92 |Likes:
Published by vijaya_vangapalli

More info:

Published by: vijaya_vangapalli on Jan 19, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/28/2010

pdf

text

original

 
ADVANCED MAC OS X ROOTKITS
DINO A. DAI ZOVIDDZ@THETA44.ORG
Abstract.
The Mac OS X kernel (xnu) is a hybrid BSD and Machkernel. While Unix-oriented rootkit techniques are pretty well known,Mach-based rootkit techniques have not been as thoroughly publiclyexplored. This paper covers a variety of rootkit techniques for bothuser-space and kernel-space rootkits using unique and poorly under-stood or documented Mac OS X and Mach features.1.
Introduction
Rootkit techniques affecting FreeBSD are well known and docu-mented ([4]). Many of these techniques also apply directly to MacOS X since it shares a good deal of code with FreeBSD. This research,however, focuses on rootkit techniques that use or abuse unique fea-tures of the Mach functionality in the Mac OS X kernel.This paper is organized as follows. First, some background is givenon Mach abstractions, IPC, and RPC. The body of the paper proceedsin describing injecting code into running processes, injecting new in-kernel RPC subsystems, transparent remote control of a compromisedsystem via Mach IPC, and detecting hidden kernel rootkits. Finally,the paper concludes with some commentary on future directions andgives the reader instructions on how to obtain the proof-of-concepttools described in this paper.2.
Background
The Mac OS X kernel (xnu) is an operating system kernel of mixedlineage, combining the older research-oriented Mach microkernel withthe more traditional and modern FreeBSD monolithic kernel. TheMach microkernel combines a powerful abstraction, Mach message-based interprocess communication (IPC) with a number of cooperatingservers to form the core of an operating system. The Mach microkernelis responsible for managing separate tasks, each in their own separateaddress spaces and consisting of multiple threads. A number of default
Date
: July 24, 2009.
 
2 DINO A. DAI ZOVI DDZ@THETA44.ORG
servers also provide virtual memory paging, a system clock, and othermiscellaneous low-level services.The Mach microkernel alone, however, is not enough to implementa modern operating system. In particular, it has no notion of users,groups, or even files. In order to provide this functionality, the Mac OSX kernel includes a graft of the FreeBSD kernel. The top-half of theFreeBSD kernel (system call handlers, file systems, networking, etc)was ported to run on top of the Mach microkernel. In order to addressthe performance concerns with excessive IPC messaging between kernelcomponents, both kernels exist in the same privileged address space.However, in most respects, the Mach API visible from kernel code isthe same as the Mach API visible from user processes.The Mach kernel deals with a number of core abstractions: the host,task, thread, and ports that represent them. The Mach
host 
representsa computer system that is capable of running
tasks
. Each task encapsu-lates a number of resources, including a virtual memory address space,one or more
threads
of execution control, and an IPC space. The Machkernel, tasks, and threads all communicate with each other through
ports
. A port is a unidirectional, sequenced, and structured data chan-nel that is capable of transmitting
messages
. Each port in a task’s IPCspace is referred to by a task-specific
name
. Different tasks may referto the same port via different names. Access to a port is governed bya task possessing defined
rights
on it. Multiple tasks may have rightsto send messages on a port, however only one task may have rights toreceive messages on it. In addition to sending data, tasks may transmitport rights through messages to other tasks. This system of ports andport rights forms Mach’s capability-based security model.Unidirectional IPC is only of limited use. In order to provide a moreflexible system, Mach provides a Remote Procedure Call (RPC) systemon top of Mach IPC. Tasks may use RPC to interact with other tasks onthe same host. Tasks that primarily perform actions on behalf of othertasks are referred to as
servers
. Mach-based systems commonly provideMiG, the Mach Interface Generator to aid in constructing RPC clientsand servers. MiG takes a definition file specifying the RPC interface(referred to as a
subsystem 
) and creates both client and server stubfunctions to automatically handle the marshalling of data into andfrom Mach messages. MiG-generated client stubs are actually usedin most of the Mach API to communicate with MiG-generated serverstubs executing within the kernel.
 
ADVANCED MAC OS X ROOTKITS 3
3.
Mach Injection
The Mach API supports a high-level of control over other tasks andthreads. With access to another task’s control port, a controlling taskmay allocate, deallocate, read, and write memory within the task. Itmay also create, suspend, and kill threads within the controlled task.These operations are sufficient to map new code into the remote taskand create a new thread to execute that code. There are, however,some complications with this.First, the injected code will not be able to call many system APIs.The code will be executing within a ”naked” Mach thread and manysystem functions assume that all threads are POSIX threads. Second,the injected code may need to be linked in order to call system libraries.Purely injected code is essentially limited to the level of functionalityof common exploit payloads used in memory corruption exploits.In order to address these shortcomings, direct Mach thread injectionis simply used to call functions loaded in the remote processes addressspace. A small bit of trampoline code is injected in order to promotethe ”naked” Mach thread into a full POSIX thread so that the fullrange of standard library functions may be called. In addition, we usea unique feature of Mach in order to obtain the return value of thefunction call in the remote address space. In addition to setting upthe thread, the injected trampoline sets a bogus stack return addressintended to make the thread crash in a deterministic way. Prior tostarting the thread, the controlling task registers itself as an exceptionhandler for that thread. By doing so, it is notified about exceptions inthe thread before the owning task is. This allows the controlling taskto handle the exception and terminate the thread without disturbingthe rest of the task. When the injected thread crashes at the bogusreturn address, the return value from the function is obtained fromthe appropriate CPU register in the thread state. By combining thesesteps, the controlling task is able to call arbitrary functions in thetarget task with chosen arguments and obtain the returned value of the called function.Using this technique,
dlopen()
is called in the remote process in orderto properly load and link a bundle from disk. After loading,
dlsym()
is called to resolve the address of the
run()
symbol exported from thebundle. Finally, this function is called in order to run the injectedbundle in the remote task.For more complete details on this technique, see the author’s
inject-bundle
tool (available as described in Section 7) and Chapter 11 of 
TheMac Hacker’s Handbook 
[5].

Activity (4)

You've already reviewed this. Edit your review.
1 hundred reads
z0rt liked this
plutoaa36 liked this
annunaki-1974 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->