Code Monkey home page Code Monkey logo

abx's Introduction

Android Binary XML toolbox

Dependencies

  • Erlang R16 or newer (R15 lacks at least binary_to_integer)

Installing and building

$ git clone https://github.com/dnet/abx.git
...
$ cd abx
$ erlc *.erl

Usage

abx.sh can be invoked from the shell and can be used to transform XMLs, an example can be seen below that enables on-device debugging.

$ unzip foo.apk AndroidManifest.xml
Archive:  foo.apk
  inflating: AndroidManifest.xml
$ ./abx.sh AndroidManifest.xml
Self-test succeeded, proceed with injection
$ ./abx.sh AndroidManifest.xml out.xml application.debuggable=true

The resulting XML can be repackaged into the APK, but then you'll need to sign the package again, here's a blogpost telling you how. If you need more flexibility and know some Erlang, the following modules can be used.

  • abx_parser transforms the binary XML to simple Erlang terms
    • parse_file parses a file specified by name
    • parse_binary does the same, but directly on an Erlang binary
  • abx_serializer serializes the Erlang terms to binary XML format
    • serialize_to_file writes the output to a file
    • serialize_to_binary returns the output as an Erlang binary
  • abx_transform compiles and applies transformations on Erlang terms

The Erlang term structure is a list, in which each item matches a chunk in the Android Binary XML format. The list items are tuples, the first element is always an atom that tags the contents. Currently, three such tags are supported.

  • {string_pool, [String1, String2, ...]} represents a string pool, the second member is a list of binaries; the order matches the original chunk
  • {element, LineNum, Comment, Namespace, Name, [{Ns, Name, Value}, ...]} represents the start of an XML element with zero or more attributes as tuples of three elements. Namespaces and names are represented as binaries, values are represented as the following.
    • booleans follow Erlang convention by using true and false atoms
    • decimal numbers are Erlang integers
    • hexadecimal numbers are tagged tuples {hex, Number}
    • references are tagged tuples {ref, Number}
  • {unknown, Type, HeaderSize, Payload} represents every other chunk

License

The whole project is available under MIT license, see LICENSE.txt.

abx's People

Contributors

dnet avatar

Watchers

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