Git Product home page Git Product logo

drawflowdiagramofsmalimethods's Introduction

DrawFlowDiagramOfSmaliMethods

when analysing an APK in reverse process, we usually use apktool(http://ibotpeaches.github.io/Apktool/) to decompile the APK and then get smali codes. Although some tools,such as dex-to-jar, can convert smali codes to java codes which is more readable, those tools may not work if the method is complicate enough or confused. In this case, you can use this project to draw the basic flow diagram of method to understand the execution flow quickly.

The flow diagram is based on unconditional jump(goto) and conditional jump(if) instructions.

##Dependency

  1. python2.7

##Platform

  • You can run this program on Linux.
  • As for windows, you can change the variable DOT_PATH in drawFlowDiagramOfSmaliMethods.py.
    Since output file name is named by method's name correspondingly, if method's name contains illegal characters of file name, the flow diagram of this method will not be generated.

##Usage (Make sure you install python2.7 and Graphviz before running this program)

  • type "python drawFlowDiagramOfSmaliMethods.py -h" in cmdline will show help message.
  1. -s smali_file_path is indispensable, it specifies which smali file you want to parse.
  2. -f {png,jpg,svg} specifies the format of output picture file containing flow diagram generated
  3. -m methods_to_draw specifies the methods which you want to draw flow diagrams of. Different methods split with #, such as func#func1\(I\)Z. If you doesn't specify this parameter,it will draw all methods' flow diagrams.
  4. -o output_dir specifies the directory of output flow diagrams. Defult is current directory.

Example:

  • python drawFlowDiagramOfSmaliMethods.py -s Check.smali //generate flow diagrams of all methods in Check.smali
  • python drawFlowDiagramOfSmaliMethods.py -s Check.smali -f png -m check -o /home/cpf/output

##Output Flow Diagrams 1.example 1

2.example 2

Note:

  • The numbers in the diagram increasing from top to bottom are the line numbers of instructions.
    Figure legends:
    1.Yellow rectangle indicates return instruction.
    2.Orange edge indicates unconditional jump
    3.Red edge indicates conditional jump if condition is false. That means it will execute all instructions between from node and end node
    4.Green edge indicates conditional jump if condition is true

drawflowdiagramofsmalimethods's People

Contributors

manyface 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

Watchers

 avatar  avatar

drawflowdiagramofsmalimethods's Issues

question

Hello,I want to ask weather your smali file is just a class or java file?And you know an apk may have many smali file,do you have some ideas to get the CFG graph from the whole apk.Thanks!

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.