Giter VIP home page Giter VIP logo

retools's Introduction

retools: a reverse engineering toolkit for normies

Collection of tools (disassembler, emulator, binary parser) aimed at reverse enginering tasks, more specifically, bug finding related. Currently we target ARMv7 and Mach-O though in the future more architectures and formats are planned.

retools is somewhat unique in that most of the semantics for relevant instructions are parsed out of the specification PDFs as opposed to being generated by hand. Currently the disassembler, emulator, and binary parsers are partially done, with a symbolic execution engine and instrumentation/hooking framework to come as I get more time.

Build Status

About the framework

retools has been designed to be modular, that is, we have divided each major subsystem in a separate library that can be used in most of the cases independently of other parts of the framework.

libdisassembly

Multi architecture decoding/disassembling library. It supports, for now, the ARMv7 (and below) architecture. The decoding/disasembling procedures for the ARMv7 architecture are generated automatically from the architecture manual.

libemulation

Emulation library that allows its clients to emulate instructions. The emulation code has been automatically generated in the same fashion as libdisassembly.

libbinary

Library that allows its clients to read/write/parse binary executables in a generic way that is independent of the underliying file format of the binary. As of now we only support mach-o binaries, both fat and slim binaries.

Example

In this example we will use the binary_info tool to inspect some generic details about a macho binary. binary_info is meant to be an example of how to use libbinary.

$ ./build/src/tools/binary_info/binary_info /bin/ps

Current binary:
  Linker: /usr/lib/dyld

  Version: 168.0.0.0.0

  UID: 55137f9f2fd933e6b9f39d4c7c65681c

  Entry points:
    entry: 0x51ac
    ...

  Libraries:
    lib: /usr/lib/libSystem.B.dylib

  Strings:
    val: no valid keywords; valid keywords:
    val:        ps [-L]
    ...

  Symbols:
    sym: __mh_execute_header @ 0x100000000
    ...
  Segment:
    address : 0x0
    size    : 0x100000000
    perm    : ---
  Segment:
    address : 0x100000000
    size    : 0x6000
    perm    : r-x
  Segment:
    address : 0x100006000
    size    : 0x3000
    perm    : rw-
  Segment:
    address : 0x100009000
    size    : 0x4000
    perm    : r--

libsymbolic

The main idea of libsymbolic is to have an accurate and complete representation of the working architecture (say, ARM, x86, etc.) in a way that can be queried and used in the construction of reverse engineering tools.

As of now, libsymbolic is a placeholder for the automaticaly generated formal specification of the architecture.

libinstrumentation

Placeholder for an instrumentation library.

Installation

There are two recommended ways you can install this framework, we recommend using vagrant if you are just curious about testing the tools and having a look at the code. Otherwise compiling the code should not be difficult on a semi-modern linux system.

Requirements

retools is supported and has been tested on macOS and Linux. A Windows build may be possible if you don't mind not building the libdebug part of the framework because as of now, it depends on lldb being present.

Software dependencies:

  • pyparsing
  • capstone
  • unicorn
  • darm
  • cmake
  • Boost.Python
  • lldb

All the dependencies should be handled by the bootstrap.sh script.

Vagrant

Use vagrant with the provided Vagrant file. It will automatically create an Ubuntu VM and will run bootstrap.sh to install all the required files for compilation. Once the VM is created, you will find retools code at $HOME/retools. Move to that directory and then follow the compilation instructions that follow.

Compilation

# Clone the repository.
$ git clone https://github.com/agustingianni/retools.git

# Move to the cloned directory.
$ cd retools/

# Bootstrap installation (skip if using vagrant).
$ bash bootstrap.sh

# Compile sources.
$ mkdir build
$ cd build/
$ cmake ..
$ make -j8

Documentation / Presentations

  • ARM Disassembling with a twist / Ekoparty 2016 PDF
  • ARM Disassembling with a twist / Ekoparty 2016 VID
  • ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition PDF

Licensing

See LICENSE

Contact

Feel free to contact via e-mail to [email protected] or twitter @agustingianni.

retools's People

Contributors

agustingianni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

retools's Issues

Test emulator

  • Test against unicorn.
  • Test against a real device.

Improve bootstraping

  • Handle installation of dependencies for macOS and linux automatically.
  • Improve the current scripts.
  • Update the documentation accordingly.

Handle integer operations on big integers

Use boost multiprecision to handle the usage of non standard integers (128, 256 bit integers, etc.).

  • Save more specific type information from the parsing stage.
  • Improve the generation of code to include boost.mutiprecision integers.
  • Decide what to do when the size of an integer depends on the encoding of an instruction. That is, if the size of the integer variable is N, where N depends on the opcode.

Add usage examples

  • Command line disassembly.
  • Command line emulation.
  • Instruction fuzzer.

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.