Coder Social home page Coder Social logo

bb010g / binaryninja-chained-fixups Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xpcmdshell/bn-chained-fixups

0.0 1.0 0.0 1.05 MB

This plugin will apply the rebasing and binding information present in LC_DYLD_CHAINED_FIXUPS for ARM Mach-O files.

Python 100.00%

binaryninja-chained-fixups's Introduction

bn-chained-fixups

This Binary Ninja plugin adds a command to apply the fixup information present in LC_DYLD_CHAINED_FIXUPS for eligible ARM Mach-O files (such as M1 Kernel extensions). This plugin was written against the dev branch of Binary Ninja API, and tested against M1 kernel extensions and M1 Kernel images.

As of macOS 12/iOS 15, a new load command (LC_DYLD_CHAINED_FIXUPS) is used to store the linker data that dyld uses at process startup. For more information, there's a blog post by Emerge Tools here that explains it at a high level.

In short, there is a list of start locations of pointer chains for each segment. Each chain entry contains information about whether it needs to be rebased or bound, the information to do so (target or ordinal number), as well as the location of the next entry in the chain. DYLD will traverse each of these chains and apply the necessary fixups.

Usage

To apply fixups for eligible projects, use the plugin action under Tools -> Plugins -> Apply LC_DYLD_CHAINED_FIXUPS.

Sample Output

Information about where fixups were applied is available in the Log console:

[*] Fixup header at = 0x20000 
[*] DYLD_CHAINED_STARTS_IN_IMAGE at = 0x20020, with 0x5 segments
[*] Imports table at 0x2006c 
[*] Symbols table at 0x2090c
[*] Chain start at 0x180b4
[*] Rebasing pointer at 0x180b4
[*] Rebasing pointer at 0x180bc
[*] Rebasing pointer at 0x180c8
[*] Rebasing pointer at 0x180d0
[*] Chain start at 0x1c000
[*] Rebasing pointer at 0x1c000
[*] Chain start at 0x1d000
[*] Binding __ZN9IOService20getDeviceMemoryCountEv at 0x1d000
[*] Binding __ZN9IOService24getDeviceMemoryWithIndexEj at 0x1d008

...

[ SNIP ]

Before

Before Fixups

After

After Fixups

Programmatic Usage

To call this plugin action from your own plugin or another script, you can use the following snippet:

ctx = plugin.PluginCommandContext(bv)
plugin_list = plugin.PluginCommand.get_valid_list(ctx)
plugin_list['Apply LC_DYLD_CHAINED_FIXUPS'].execute(ctx)

binaryninja-chained-fixups's People

Contributors

bb010g avatar xpcmdshell 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.