Coder Social home page Coder Social logo

banjo's Introduction

Banjo

logo

Android Dex disassembler and Binary Ninja plugin

Description

Banjo parses Dex files and disassembles them into a smali syntax that is close to baksmali's.

There are three parts to this project:

For more documentation, see the doc/ directory.

There are still some rough edges. See GitHub issues for more details.

This project was released at a ShmooCon 2020 talk.

screenshot

Installation Instructions

Make sure Binary Ninja is using Python 3.8 or higher and copy banjo to BN_USER_DIRECTORY/plugins/. On Linux:

cd ~/.binaryninja/plugins/ && git clone https://github.com/carvesystems/banjo.git

banjo's People

Contributors

austin-ralls-cs 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

banjo's Issues

Lift to LLIL

This is currently not a priority because

  1. I don't see a big use case. Smali is already pretty high-level.
  2. It would be a lot of work, and I'm not positive it would be possible to lift every instruction due to Dalvik being a VM.

I've never done anything with lifting before though, so please leave a comment if you think otherwise.

Files load in hex view

When you open up a Dex file, the default view is the hex view. For ELF files, the default is graph view (or maybe that's from my settings. Point is, it's not hex).

Check licensing

  • Did I do MIT license correctly? Should get someone else to double-check.
  • Are there any complications because this is a plugin? Does this repo need to acknowledge Binary Ninja's license in any way?

Package/class black/whitelisting

Dissassembling every method in a large Dex file can take a long time. Request by @drosseau-carve:

The ability to say "I don't care about disassembling package X" (ie android.arch.core.internal)

Control flow wrong for switch statements

packed-switch and sparse-switch instructions do not have branches set. Methods with these instructions will not have the full control flow graph, and will probably not disassemble completely.


More than two branches can't be added to an InstructionInfo object in get_instruction_info: https://github.com/CarveSystems/banjo/blob/bd07db6c3a8de9b4eff56d381c581909b0ea2b05/architecture.py#L99-L108

According to rss, the right way to do this is to use LLIL_JUMP_TO in LLIL. I couldn't figure out how to do this. My best attempt (does not work):

https://github.com/CarveSystems/banjo/blob/bd07db6c3a8de9b4eff56d381c581909b0ea2b05/architecture.py#L170-L174

ImportError: DLL load failed while importing binaryninjaui: The specified module could not be found. Python plugin 'banjo' could not be loaded

Traceback (most recent call last):
  File "C:\Users\Myself\AppData\Roaming\Binary Ninja\plugins\banjo\__init__.py", line 10, in <module>
    from binaryninjaui import UIContextNotification, UIContext  # type: ignore
  File "E:\binaryNinja2.1\BinaryNinja-personal-2.0.2097-dev\plugins\..\python3\binaryninjaui\__init__.py", line 5, in <module>
    from .binaryninjaui import *
ImportError: DLL load failed while importing binaryninjaui: The specified module could not be found.
Python plugin 'banjo' could not be loaded

Python 3.8 is installed

How to fix this?

docstrings

I have a bunch uncommitted. I should finish and push them.

Test more against baksmali

I've tested this against a relatively small corpus of dex files that I have lying around. It needs to be tested against way more.

  • Find collection of publicly-licensed Dex files
  • Run disas_to_files.py on them and share results

Locally I've been using

#!/bin/sh

fn=$1
[ -z $fn ] && exit 1
bn=$(basename -s .dex -s .cdex "$fn")

set -e

time java -jar baksmali.jar d --parameter-registers false -o "$bn"_baksmali "$fn"
time disas_to_files.py -o "$bn"_banjo "$fn"
diff -r "$bn"_*

Add support for other containers like APK, ODEX, etc.

This plugin only supports disassembling Dex files.

It could unzip APKs and pull out any Dex files, but that's easy to do manually, and would require code to check for and alert the user if multiple dexs are found, no dexes are found, or other dex container files are found. This doesn't seem like the right tool to do that.

Adding support for odex, cdex, vdex, or whatever else there is would require writing a whole new parser for each container type. There are other tools that can convert these types into Dex files. Again, this doesn't seem like the right tool to have this functionality in.

If you feel differently, leave a comment.

Tests are broken

There are some Python unittest classes for low-level tests. Somewhere along the line in code reorganization they stopped working.

ImportError: Failed to import test module: dex
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/home/.../.binaryninja/plugins/banjo/android/dex.py", line 9, in <module>
    from .smali import (
ImportError: attempted relative import with no known parent package

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.