Quickly locate key codes for Android programs
1. Through the Apktool anti-compilation apk file, get the Androidmanifest.xml file, you can get the program used to build, configure, and the main activity
2. Information Feedback method (special string)
3. Feature function method (Toast)
4. A line of code to see
5. Pile Insertion Method
6. View the call stack
7.Method Profiling (log the CPU time of each function, and the call stack)
Smali file format
Main framework
. class < access > [modifier keywords] < class name >
. Super < parent class name >
. Source < code name >
The following is a concrete field, method, annotation (below
Field represents
Static fields:
#static fields.field <访问权限> static [修饰关键字] <字段名>:<字段类型>
Instance fields
#instance fields.field <访问权限> [修饰关键字] <字段名>:<字段类型>
Method represents
.method <访问权限> [修饰关键字] <方法原型>.prologue具体代码.end method
Interface
.implements <接口名>
Annotation class
.annotation [注解属性] <注解类名> [注解字段 = 值].end annotation
Classes in the Android program
Baksmali when you decompile a Dex file, a Smali file is generated for each class
Inner class
As follows
class Outer{ class Inner{}}
Baksmali will generate Outer.smali files and Outer$inner.smali files when they are recompiled. Inside the file name is "[External class]$[inner class].smali".
We open the Outer$inner.smali file and find that there is a this$0 synthetic field (synthetic is synthesized by the compiler), which points to the parent class for other method calls of the inner class (where 0 represents the first layer of the parent class)
Looking at the initialization function of the inner class, we can find that the class is initialized by saving a reference to the outer class, calling the constructor of the parent class, and then initializing it itself
Listener
The anonymous class, which is similar in form to the inner class. The file name is "[External class]$[Digital].smali"
Annotation class
#annotations.annotation system Ldalvik/annotation/Memberclasses; value = { Lcom/droider/crackme/MainActivity#SNChecker; }.end annotation
Memberclasses provides a list of member classes for the parent class. Popular will be a list of internal classes
#annotations.annotation system Ldalvik/annotation/EnclosingMethod; value = { Lcom/droider/crackme/MainActivity;->onCreate()V; }.end annotation
The Enclosingmehtod annotation is used to illustrate its scope, and method means that he works in a single way. Value represents a function in the specific class in which it is acting. The corresponding enclosingclass annotations
#annotations.annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x1 name = "SNChecker".end annotation
The Innerclass annotation indicates that the class is an inner class
Auto-generated class R class
Each resource in the Res directory under each project will have an ID, which is stored in the R class
Read the Smali code Loop statement for disassembly
- Iterators (Hasnext,next)
- Normal cycle (x86 disassembly form almost)
Switch Branch statement
- Packed-switch (Regular)
- Sparse-switch (irregular)
The Smali format is probably as follows:
Xxxxx-switch p0,switch_goto_table
Switch_goto_table points to a jump table.
Where the default Defaults branch is located after the xxxxx-switch p0,switch_goto_table directive
Try-catch statements
In the Smali code, the try statement block is surrounded by try_start_x, try_end_x (where x is a number).
Below the try_end_x is the. catch directive that specifies the type of exception to handle and where to process the code
When processing catch code, an exception is found that calls the perimeter catch
Static Analysis Android Program