Friday, October 23, 2009

Sunday, October 18, 2009

Help needed

I decided to release a new version of dedexer but I am not satisfied. The Holy Grail I am chasing is the high-quality disassembly of ODEX files and I intended to use the hint received from Nenik. I extended the dedexer tool with data flow analysis so it now has knowledge about the types in Dalvik registers at any point of the execution of Android bytecode. If you ask nicely the new version of the tool (-r switch), it will even share this information with you. Now a decompiled method looks like this if this switch is used:

.method public (Ljava/lang/String;)V
.limit registers 4
; this: v2 (LLineReader;)
; parameter[0] : v3 (Ljava/lang/String;)
.catch java/io/IOException from lbba to lbda using lbdc
.line 18
invoke-direct {v2},java/lang/Object/ ; ()V
; v2 : LLineReader;
lbba:
.line 20
new-instance v0,java/io/FileInputStream
; v0 : Ljava/io/FileInputStream;
invoke-direct {v0,v3},java/io/FileInputStream/ ; (Ljava/lang/String;)V
; v0 : Ljava/io/FileInputStream; , v3 : Ljava/lang/String;
iput-object v0,v2,LineReader.fis Ljava/io/FileInputStream;
; v0 : Ljava/io/FileInputStream; , v2 : LLineReader;
.line 21
new-instance v0,java/io/BufferedInputStream
; v0 : Ljava/io/BufferedInputStream;
iget-object v1,v2,LineReader.fis Ljava/io/FileInputStream;
; v1 : Ljava/io/FileInputStream; , v2 : LLineReader;
invoke-direct {v0,v1},java/io/BufferedInputStream/ ; (Ljava/io/InputStream;)V
; v0 : Ljava/io/BufferedInputStream; , v1 : Ljava/io/FileInputStream;
iput-object v0,v2,LineReader.bis Ljava/io/BufferedInputStream;
; v0 : Ljava/io/BufferedInputStream; , v2 : LLineReader;
lbda:
.line 28
return-void
lbdc:
.line 23
move-exception v0
; v0 : Ljava/io/IOException;
goto lbda
.end method

Great then, but where is the invoke-quick disassembly? Well, erm, I ran into problems. First of all, I could not figure out the data structures that store the names of other ODEX files that this ODEX file depends on. They seem to be in some sort of data structure at the end of the ODEX file that stores the name of these files but its exact layout remains a mistery for me.

Second, in order to decode invoke-quick statements, iget-object-quick statements also need to be decoded because the type values they put into Dalvik registers are needed for the data flow analyser. The source of this instruction is known as an offset and the mapping of these offsets back to Java types.

I will try to progress with these problems, any help is appreciated.

And now some PR after the boring technical details.

I will make a short presentation about dedexer during the coming Android meetup in London. If you are interested about the tool and central London is accessible for you, let's see each other there.

Sunday, August 23, 2009

Dedexer in Softpedia

Wow, I got an e-mail that dedexer 1.5 got included into Softpedia. The funny thing is that it got included into the Mac development tool section. I have already got a number of questions from Android developers working on Mac. Is it so that Mac is a favourite platform for Android developers or is it just my fortune? Any opinions?

Monday, August 17, 2009

Fancy graphs

It seems that a sure sign of the maturity of an application platform when graph libraries start to appear. Android definitely got to this stage with aiCharts.

I didn't discover it myself. I got a mail from the authors. Even though aiCharts is a commercial product, the Android component market is still nascent enough so that they deserve advertising (even if it is only my lame advertising).

aiCharts comes with flashy demonstrations and a number of demo programs.


There was only one limitation I was able to discover: the demo programs require the latest API version and according to the authors, aiChart will not run with lower than Android 1.1. Another limitation is that ArtfulBits obviously wants to make money out of the product so the thing is protected by license key.

I also received this chart from them that I now share with you. If you need a chart library, at least you know what options to choose from.

Feature name aiCharts, Artfulbits v1.0.0 Rchart, java4less, v1.0.0 chart4j, Google, v1.2 jFreeChart, Jfree, v1.0.13 AChartEngine, 4viewsoft, v0.3.0
Chart types




Area + + - + +
Bar + + + + +
Bubble + + + + -
Box and Whiskers - - - + -
Candle stick + + - + +
Column + + + + -
Doughnut - - - + -
Fast line + - - + -
Funnel + - - - -
Gantt - - - + -
HiLo Open Close + + - + -
HiLo + + - + -
Histogram - - - + -
Kagi - - - - -
Line + + + + +
Pie + + + + +
Point + + + + -
Polar + + + + -
Point and Figure - - - - -
Pyramid + - - - -
Renko - - - - -
Spline Area + - - + -
Spline + + + + -
100% Stacked Area + - - + -
Stacked Area + - - + -
Stacked Bar + + - + +
100% Stacked Column + - - + -
Stacked Column + - - + -
Step Line + - - + -
Step Area - - - + -
Three line break - - - - -
Tornado
- - - -
3D Charts - + pseoudo + -
Annotations + + + + -
Multiple series + + + + +
Multiple areas + - - - -
Legend + + + + -
Multiple legends + - - - -
Legend dock + + + + -
Legend alignment + + - - -
Custom legend items + - - + -
Axis




Logarithmic axes - + - + -
Multiple axes - + - + -
Axis label position + - - + -
Axis label alignment + - - + -
Labels mode + - + + -
Date values + + + + -
Axis scale + + + + -
Custom labels format + - + - -
Nice range calculation + + + + -
Zoom/Scroll + + + + -
Striplines + + + + -
Series




SQL data source + - - - -
Series drawables + - - - -
Per point style + - - - -
XML data source + - - - -
Visual customization




Themes - - - + -
Chart background + + - + -
Axes customization




Series customization




Annotations customization + + + + -
Saving chart to image/stream + + + + -
XML inflation + - - - -
Multiple titles + - - - -
Events on chart objects clicks + - - - -
Specially writtern for Android + - - - -
APIs Documentation + + - + -
Intuitive architecture + - - - -
Summary for features 61 38 25 53 9

Friday, August 7, 2009

Dedexer annotation support

Just a short post for those few who do Dalvik bytecode analysis: dedexer has now full annotation support! For example it now decompiles "throws" and inner class annotation, along with custom annotations. Go for 1.5 release to get it.

Thursday, July 30, 2009

It's that simple

Like many, I also thought that this project was a joke. Somebody obviously created something like the Visual Basic and made it work on Android. Then from this blog post, it became clear that Simple is dead serious.

Simple tries to replicate the 20 year old Microsoft idea about high-performance components and a script language binding them into applications. There is one thing, however, that caught my attention. Why not Python or any other "real" script language? Why this Basic afterthought?

The intriguing fact is that Android's virtual machine, Dalvik just got another language beside Java. The Simple compiler takes the Simple code and compiles directly into Dalvik bytecode, without going through Java. For example there is this Simple subroutine (remember the term "subroutine" ages ago? :-)).

Sub PreviewBrick(brick As Brick, orientation As Integer)

The Simple compiler turns it into a proper Dalvik method (Simple compiler's DEX output decompiled by Dedexer):

.method public PreviewBrick(Lcom/google/devtools/simple/samples/tetris/Brick;I)V

There is a runtime for Simple programs but it is not really an interpreter, it is just a glue between the standard Android classes and the Simple event system. That may explain, why the scripting language is not Python; a real scripting language may be too dynamic to compile.

There have been similar attempts for Java proper but the JVM was never designed to run anything other than Java. When .Net appeared, Microsoft claimed that the .Net Common Language Runtime is much more suitable running certain languages than the Java bytecode. This may or may not be true, the fact remains that CLR runs mostly C# and Visual Basic.NET programs.

From this demonstration with Simple, it is clear that Dalvik can also run a script language (Simple) and a component language (Java). Whether developers will find attractive enough to work in a script language that needs time-consuming compilation and deployment before running it (one huge advantage of scripting languages is that the program can be executed immediately after modification) or whether experimenting software experts want to use a rather obsolete language (like this BASIC clone) for binding their components is yet to be seen.

Wednesday, July 1, 2009

New DEX assembler/disassembler pair

Dedexer got competition! Not one but immediately two - smali and baksmali is a DEX assembler/disassembler pair. The programs are brand new and - like Dedexer - they are also based on a Jasmin-like format. I tried them very shortly, the disassembler - baksmali - worked correctly and indeed produced an output similar to dedexer but I could not compile the output of baksmali back to DEX format with the assembler - smali. The disassembler does not handle ODEX files either.

The initiative is indeed valuable, however, and I encourage every reverse engineer out there give the new tools a try.