• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    C
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interprocess dlsym() for OS X & iOS
โ•ฆ  โ”Œโ”€โ”โ”ฌโ”€โ”โ”Œโ”€โ”โ”Œโ”โ”Œโ”Œโ”€โ”โ”Œโ”ฌโ”โ”Œโ”ฌโ”โ”Œโ”€โ”   โ”Œโ”ฌโ”โ”ฌ โ”ฌโ”Œโ”€โ”    โ”ฌ  โ”ฌโ”Œโ” 
โ•‘  โ”‚ โ”‚โ”œโ”ฌโ”˜โ”‚ โ”ฌโ”‚โ”‚โ”‚โ”œโ”ค  โ”‚  โ”‚ โ”œโ”ค     โ”‚ โ”œโ”€โ”คโ”œโ”ค     โ”‚  โ”‚โ”œโ”ดโ”
โ•ฉโ•โ•โ””โ”€โ”˜โ”ดโ””โ”€โ””โ”€โ”˜โ”˜โ””โ”˜โ””โ”€โ”˜ โ”ด  โ”ด โ””โ”€โ”˜    โ”ด โ”ด โ”ดโ””โ”€โ”˜    โ”ดโ”€โ”˜โ”ดโ””โ”€โ”˜

Build Status

Lorgnette enables you to lookup symbols on OS X and iOS (jailbreak is required, though). It works for both local and remote symbols (i.e. symbols within an alien process address space). So you may think about it as dlsym() without ยซthe current process symbols onlyยป and ยซwon't find unexported symbolsยป limitations.

OS X contains a private framework called CoreSymbolication that can be used to locate symbols in any running task on the system and even more. I believe that it has something to do with dtrace.
So if you need something production-ready (heh), you should use the Apple thing instead of liblorgnette.
See CoreSymbolication section of this file.

Usage

If the target is a mach_task_self() then lorgnette_lookup() will act like dlsym(). But unlike dlsym() it can be used to locate unexported symbols.

#include "lorgnette.h"
mach_vm_address_t main_addr = lorgnette_lookup(mach_task_self(), "main");
assert(dlsym(RTLD_DEFAULT, "main") == main_addr);

mach_vm_address_t dlopen_addr = lorgnette_lookup_image(mach_task_self(), "dlopen", "libdyld.dylib");
assert(dlsym(RTLD_DEFAULT, "dlopen") == dlopen_addr);

Or it will inspect any alien task you have rights to control (task_for_pid isn't for everyone, you know):

pid_t proc = 20131;

task_t target;
task_for_pid(mach_task_self(), proc, &target);

mach_vm_address_t remote_addr = lorgnette_lookup(target, "_private_function");

Interface

mach_vm_address_t lorgnette_lookup(task_t target, const char *symbol_name);

Locate a symbol inside an arbitrary process' address space.

This function iterates local symbols first and only then it looks for symbols in linked libraries.

Parameter Type (in/out) Description
target in (required) The target process to inspect
symbol_name in (required) The name of the symbol to find. This parameter must not be NULL
Return value
An address of the given symbol within the given process, or 0 (zero) if this symbol could not be found


mach_vm_address_t lorgnette_lookup_image(task_t target, const char *symbol_name, const char *image_name);

Locate a symbol within a particular image inside an alien process.

Parameter Type (in/out) Description
target in (required) The target process to inspect
symbol_name in (required) The name of the symbol to find. This parameter must not be NULL
image_name in (optional) The name of the host image of the given symbol. The image name should be either a full file path or just a file base name
Return value
An address of the given symbol within the given process, or 0 (zero) if this symbol could not be found [within the given image, if image_name is not NULL]

CoreSymbolication

Here're some reverse engineered headers for the framework along with functionality tests: mountainstorm/CoreSymbolication.
Also see this StackOverflow question by Johannes WeiรŸ.


If you found any bug(s) or something, please open an issue or a pull request โ€” I'd appreciate your help! (^,,^)

Dmitry Rodionov, 2014
[email protected]

More Repositories

1

SWRoute

PoC of function hooking in Swift
Swift
586
star
2

rd_route

Function hooking for macOS
C
184
star
3

shortcuts

A CLI manager for your text replacements on macOS
Objective-C
66
star
4

cuckoo-osx-analyzer

An OS X analyzer for Cuckoo Sandbox project
Python
57
star
5

task_vaccine

Yet another code injection library for macOS
C
52
star
6

RDInjectionWizard

[Deprecated] Painless code injection
Objective-C
52
star
7

RDProcess

Re-implementation of NSProcessInfo+NSRunningApplication with all missed stuff (incl. Sandbox information and other things)
Objective-C
37
star
8

machobot

A Python toolbox for Mach-O files analysis.
Python
22
star
9

Locatr

OS X app for faking your location
Objective-C
17
star
10

selfieo

Dump the current process image to a file (OS X)
C
14
star
11

NeverGonnaGiveYouUp

An OS X kernel module that protects a userland process from being terminated in any way
C
13
star
12

rd_get_symbols

A modern replacement for nlist() that works for both i386 and x86_64 processes
C
11
star
13

ABetterPlaceForTweetbot

A positivity filter for Tweetbot in the morning.
Objective-C
9
star
14

Cegta

A tiny DSL for TDD/BDD written in C
C++
7
star
15

dotfiles

My dotfiles
Shell
6
star
16

Daruma

A Mac app for browsing japanese emoticons
Objective-C
5
star
17

dns-monitor

A simple DNS monitor/locker for macOS based on SystemConfiguration framework
Objective-C
4
star
18

Meetings

OS X Notifications showcase: schedule meetings and receive reminders about upcoming events
Swift
4
star
19

homebrew-taps

My very own Homebrew tap repository
Ruby
3
star
20

DropboxStatusFetcher

Query a local file sync status on OS X
Objective-C
2
star
21

YetAnotherAStar

A* path finder in Swift
Swift
1
star
22

rodionovd.github.io

my tiny corner of the web
HTML
1
star
23

HSCore.framework

HoneySound Core framework
1
star