Git Product home page Git Product logo

machobfuscator's Introduction

MachObfuscator ๐Ÿ”

MachObfuscator is a programming-language-agnostic Mach-O apps obfuscator (for Apple platforms).

Current status ๐Ÿƒโ€โ™‚๏ธ

โœ… โ€“ means feature is completed, โŒ โ€“ means feature is todo/in-progress.

  • โœ… Mach-O iOS
  • โœ… Mach-O macOS
  • โœ… iOS NIBs (including storyboards)
  • โš ๏ธ macOS NIBs (including storyboards) โ€“ does not support bindings yet
  • โŒ MOMs (CoreData)
  • โŒ Mach-O watchOS
  • โŒ Mach-O tvOS
  • โŒ Bitcode
  • โŒ automatic code re-signing (need to re-sign all images manually, see resign.sh)

Overview ๐ŸŒ

MachObfuscator is a binary symbolic obfuscator. What does it mean? There are a few important terms:

  • Obfuscator โ€“ a tool which makes software hard to be reverse engineered.
  • Binary obfuscator โ€“ a type of obfuscator that operates on machine code, not on a source code.
  • Symbolic obfuscator โ€“ a type of obfuscator that obfuscates only symbol names, does not change program control-flow.

MachObfuscator transforms symbols in Mach-O files directly. Mach-O format is used mainly on Apple platforms as a machine code container for executables and libraries. MachObfuscator doesn't need access to the app source code in order to obfuscate it.

Demo ๐Ÿš€

Let's see MachObfuscator obfuscating SampleApp.app application:

readme_resource/machobfuscator_demo.gif

Results can be seen by opening app's main executable in MachOView. MachOView shows obfuscated ObjC selectors:

and obfuscated ObjC class names:

Only sample changes are shown above. MachObfuscator changes more Mach-O sections.

Usage details ๐ŸŽฎ

$ ./MachObfuscator
usage: ./MachObfuscator [-qvhtD] [-m mangler_key] APP_BUNDLE

  Obfuscates application APP_BUNDLE in-place.

Options:
  -h              help screen (this screen)
  -q              quiet mode, no output to stdout
  -v              verbose mode, output verbose info to stdout
  -t              obfuscate methType section (objc/runtime.h methods may work incorrectly)
  -D              MachOViewDoom, MachOView crashes after trying to open your binary (doesn't work with caesarMangler)
  -m mangler_key  select mangler to generate obfuscated symbols

Available manglers by mangler_key:
  caesar - ROT13 all objc symbols and dyld info
  realWords - replace objc symbols with random words (dyld info obfuscation supported)

Under the hood ๐Ÿ”ง

In a great simplification, MachObfuscator:

  1. looks for all executables in the app bundle,
  2. searches recursively for all dependent libraries, dependencies of those libraries and so on,
  3. searches for all NIB files in the app bundle,
  4. discriminates obfuscable files (files in the app bundle) and unobfuscable files (files outside the app bundle),
  5. collects Obj-C symbols, export tries and import lists from the whole dependency graph,
  6. creates symbols whitelist and symbol blacklist (symbols used in unobfuscable files),
  7. mangles whitelist symbols, export tries and import lists using selected mangler,
  8. replaces symbols in obfuscable files,
  9. clears sections which are optional,
  10. saves all the files at once.

MachObfuscator changes following Mach-O sections:

  • __TEXT, __objc_classname โ€“ mangles symbol names
  • __TEXT, __objc_methname โ€“ mangles symbol names
  • __TEXT, __objc_methtype โ€“ (optional, enabled with -t parameter) fills whole section with 0s
  • __TEXT, __swift3_typeref, __TEXT, __swift4_typeref โ€“ fills whole section with 0s
  • __TEXT, __swift3_reflstr โ€“ fills whole section with 0s
  • LC_DYLD_INFO_ONLY โ€“ mangles export tries and binding lists
  • LC_SYMTAB โ€“ fills whole section with 0s

__TEXT, __swift* are sections used by Swift's reflection mechanism (Mirror). Mirror works even after clearing those sections, just returns less detailed data. LC_SYMTAB is used by lldb.

MachObfuscator does not affect crash symbolication because dSYMs are generated during compilation โ€“ that is before obfuscation.

Contributing ๐ŸŽ

If you have any idea for improving MachObfuscator, let's chat on Twitter (@kam800).

If you want to write some code, but don't feel confortable with Mach-O, I suggest doing some preparations first:

  1. Play with MachOView, open some binaries and try to feel Mach-O layout.
  2. Read /usr/include/mach-o/loader.h from any macOS.
  3. Read Mach+Loading.swift from MachObfuscator repo.

License ๐Ÿ‘

This project is licensed under the MIT License - see the LICENSE file for details.

machobfuscator's People

Contributors

kam800 avatar kkosowski-bt avatar

Watchers

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