If you ever have looked at Android applications you know to appreciate the ability of analyzing your target at the most advanced level. Dynamic program analysis will give you a pretty good overview of your applications activities and general behaviour. However sometimes you’ll want to just analyze your application without running it. You’ll want to have a look at its components, analyze how they interact and how data is tainted from one point to another.
This is was the major factor driving the development of smalisca. There are indeed some good reasons for a static code analysis before the dynamic one. Before interacting with the application I like to know how the application has been build, if there is any API and generate all sort of call flow graphs. In fact graphs have been very important to me since they visualize things. Instead of jumping from file to file, from class to class, I just look at the graphs.
While graph building has been an important reason for me to code such a tool, smalisca has some other neat features you should read about.
Changelog v-0.2 :
+ Fixed issue #2
+ Fixed issue #3
+ Fixed issue described in pull #5
+ Added concurrency to the parser
+ You can specify by “-j” the number of jobs/workers
+ Added configuration files
+ Specify configuration file by “-c” parameter
Web API :
+ Added REST API to access the SQLite DB
+ Use http://<host>:<port>/api/<table name> to access JSON data
Based on Flask and Flask Restless
Refer to the installation page. Requirements:
+ Python (2.x / 3.x)
At the moment there are some few major functionalities like:
You can parse a whole directory of Smali files and extract:
— class information
— class properties
— class methods
— calls between methods of different classes
— You can then export the results as JSON or SQLite.
Have a loot at the parsing page for more information.
After exporting the results you’ll get an interactive prompt to take a closer look at your parsed data. You can search for classes, properties, methods and even method calls. You can then apply several filters to your search criterias like:
smalisca> sc -c class_name -p test -r 10 -x path -s class_type
This command will search for 10 (-r 10) classes which contain the pattern test (-p) in their class name (-c). Afterwards the command will exclude the column path (-x path) from the results and sort them by the class type (-s).
Let’s have a look at another example:
smalisca> scl -fc com/android -fm init -r 10
This will search for all method calls whose calling class name contains the pattern com/android (-fc). Additionally we can look for calls originating from methods whose name contain the pattern init (-fm).
You can of course read your commands from a file and analyze your results in a batch- like manner:
$ cat cmd.txt
sc -c class_name -p com/gmail/xlibs -r 10 -x path
$ ./smalisca.py analyzer -i results.sqlite -f sqlite -c cmd.txt
Have a loot at the analysis page for more information.
+ web API
smalisca provides a REST web service in order to easily interact with the results by just using a web client. This way you can access data in your own (fancy) web application and have a clean separation between backend and frontend.
Read more about the available REST API at the web API page.
I think this the most valuable feature of smalisca. The ability to visualize your results in a structured way makes your life more comfortable. Depending on what you’re interested in, this tool has several graph drawing features I’d like to promote.
At first you can draw your packages including their classes, properties and methods:
smalisca> dc -c class_name -p test -f dot -o /tmp/classes.dot
:: INFO Wrote results to /tmp/classes.dot
This will first search classes whose class name contains test and then export the results in the Graphviz DOT language. You can then manually generate a graph using dot, neato, circo etc. Or you do that using the interactive prompt:
smalisca> dc -c class_name -p test -f pdf -o /tmp/classes.pdf –prog neato
:: INFO Wrote results to /tmp/classes.pdf
Have a loot at the drawing page for more information.