Git Product home page Git Product logo

privsympoke's Introduction

PrivSymPoke, a library and tool to mess around with private symbols in Mach-O files.

Created by Arpad Goretity "H2CO3" on 08/10/2014.

The code heavily relies on a modified version of the Mac OS X 'nm' tool, from Apple's cctools. See APPLE_LICENSE for annoying legal stuff I didn't want to pollute this readme with.

The API

High-level private symbol searching

Declared in PrivSymPoke.h.

typedef struct PrivSymFile PrivSymFile;

A structure that represents a Mach-O file being raped.

PrivSymFile *privsym_OpenFile(const char *fname);

Open a Mach-O file, read private symbols. Returns NULL pointer on failure.

void privsym_CloseFile(PrivSymFile *file);

Close and free an open file structure.

void *privsym_GetSymbol(PrivSymFile *file, const char *symname);

Retrieve a pointer to a symbol, private or public, with the name 'symname'. The symbol name must be specified with the leading underscore (if any). Returns NULL pointer on failure.

Lower-level Mach-O symbol table API

Declared in nm.h.

struct nm_symbol_entry {
    char *name;
    unsigned char type;
    intptr_t address;
};

Describes one individual symbol in a Mach-O file. 'type' is the type as reported by 'nm': 't' for "TEXT", 'd' for DATA segments, etc. A lowercase type means a private (static) symbol, whereas caps denote an exported symbol.

struct nm_symbol_list {
    uint32_t entry_count;
    struct nm_symbol_entry *entries;
};

A simple dynamic array of symbol descriptors.

struct nm_symbol_list *nm_read_symbols_from_file(const char *fname);

Returns an array of symbol descriptors from 'file'.

void nm_free_symbol_list(struct nm_symbol_list *symlist);

Frees resources associated with symlist.

The tool

Usage, or this is how you pretty-print a hard-wired 1024-bit RSA-key:

dumpsym /path/to/file.dylib '_MySecretRSAKeyThatYouWontEverFindOhWait' u8 128

u8 denotes unsigned integer, 8 bits long (uint8_t). Other valid type specifiers:

u16
u32
u64
i8  // i* specifiers mean 'signed'
i16
i32
i64
float
double

The last number is an integer specified using either decimal, hexadecimal or octal notation (as required by strtoul()). It is the number of blocks to print. Each block will be interpreted according to the type specified above, and will also be formatted relevantly.

Enjoy! -- H2CO3

privsympoke's People

Contributors

h2co3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.