Code Monkey home page Code Monkey logo

disassembler's Introduction

Disassembler & Differ

This is a refactor of the disassembler and differ used in Decompetition 2020.

The Disassembler

You can use the disassembler via the command line:

python3 disassembler.py -l language path/to/binary.out funcname ...

This will produce plain text output. Add the -y option to get the YAML output used by the differ. This has the following format:

functions:
  (funcname):
    asm: | # disassembly text for this function
      nop
      nop
      nop
    map: # source code line number for each instruction, if available
    - 42
    - null
    - 108

The source map will only be present in YAML mode, and even then only when passed the -s option to enable the it.

The Differ

You can also use the differ via the command line:

python3 differ.py path/to/candidate.yml path/to/target.yml

This will produce YAML output with the following format:

functions:
  (funcname):
    delta:
    - 1 # number of lines appearing only in the candidate
    - 2 # number of lines appearing in both disassemblies
    - 3 # number of lines appearing only in the target
    - 6 # total number of lines in this function
    hunks:
    - - 1 # hunk type (-1 = candidate only; 0 = shared; 1 = target only)
      - | # disassembly text for this hunk
        nop
        nop
      - 2 # total number of lines in this hunk
    - ...
    srcmap: # source code line numbers from the candidate
    - null
    - 69
    - ...

The Binary Class

Most of the work happens in the disassembler, which has been spread over several files for readability. If you're interested in specific functionality, here's where to look:

  • binary/__init__.py contains the Binary class, but not much happens here.
  • binary/mapper.py has functions for mapping assembly instructions to source code lines.
  • binary/reader.py has functions for reading string constants out of the binary.
  • binary/renderer.py takes care of generating the disassembly text.
  • binary/scanner.py finds symbols and names in the binary.

disassembler's People

Contributors

xavierholt avatar

Stargazers

ZiJian avatar TWY avatar  avatar Micah avatar Etum avatar larsw avatar  avatar Jay Bosamiya avatar Suraj K Suresh avatar Fabio Pagani avatar FeDEX avatar Nguyễn Anh Khoa avatar Soumyajit Deb avatar Siddharth M avatar  avatar panda bear avatar Mary Guillemard avatar

Watchers

James Cloos 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.