Amandroid - Argus static analysis framework
Argus is
a static analysis framework designed to help through a security vetting for Android applications. Previously also known as Amandroid,
its core functionality is to catch data flow of inter-component communication and represent it with inter-procedural control graphs (ICFG)
and inter-component data flow graphs (IDFG).
Argus builds upon Jawa language,
it serves as an intermediate representation for Java-like byte code (eg., Java, Dalvik byte code). Jawa is a subset of Pilar language
which is highly flexible, annotation based intermediate representation language. Android is an event and component-based system. The control flow is driven by events from an application’s environment that can trigger various method calls and component can
send an intent to another component. Android is very reactive environment and this framework helps catch control flow paths.
Argus provides an range of abilities from parsing Jawa codes, loading information from jar and class files, resolving virtual method invocation to creating call graphs, ICFG, IDFG, Data dependence analysis and taint analysis. Argus is available as a library and as a tool. As a tool it comes as a ".jar" file with few features such as decompilation of apk files, detector of API misuse and taint analysis of apks. Argus can also be used as library for Scala and Java projects which will require to load jawa-core library, to access API for analyzing Jawa language, and amandroid-core library to access API and tools related to Android decompiling and analysis. Its important to note that Argus - Amandroid does not analyze native code.
Lets look for an example a simple Android application and analyze it with Argus in Scala.
public class MainActivity extends AppCompActivity {First thing to do is load and decompile apk files. To do that only few properties needs to be configured in the settings object and call loader with apk-s URI:
public void say(String msg1, String msg2) {
TextView textView = (TextView) findViewById(R.id.textView)
textView.setText(msg1+msg2)
}
@Override
protected void onCreate(Bundle savedInstance) {
String a = "Hello";
String b = " world!";
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
say(a,b);
}
}
val apk = yard.loadApk(fileUri, settings)After that control flow graphs and ICFG and IDFG are easily created by defining entry points and passing the apk. For instance to get control flow graph of the MainActivity it can be called by name and then method should be picked which is wished to be analyzed.
var clazz = apk.getClazz(new JawaType("package.name.MainActivity")).getThis code produces the following output:
var method: JawaMethod = clazz.getDeclaredMethodByName("onCreate").get
var cfg = JawaAlirInfoProvider.getCfg(method) println(cfg)
L169418 -> L16941cThe notation here prescribed is that every statement in frameworks intermediate representation is denoted by Ln, n being the number of the statement also entry and exit nodes are marked. There are 2 set of facts associated with each statement, the entry set and the exit set. If reaching definition analysis is conducted over this control flow graph it can be concluded where are these facts defined.
L16941c -> L169420
L169420 -> L169426
L169426 -> L16942c
L16942c -> L169432
L169432 -> L169438
L169438 -> Exit
Entry -> L169418
For the code:
var rda = JawaAlirInfoProvider.getRda(method,cfg)It results in the following output:
println(rda)
L169418=Set((MainActivity_v3,*),(int_v2,?),(String_v0,?),(String_v1,?),(Bundle_v4,*))For each statement it is given a set of tuples which represent a fact and a statement of its definition, if it cannot be concluded where the fact is pointed to, it is marked with "*" or if its still undefined with "?". First 2 statements represents definition of variable a,b following super.onCreate(savedInstanceState) command and call for R.layout.activity_main. After each call the appropriate fields are pointed to the statement which defines them. If IDFG is created it can be seen how "say" method is called in the statement L169432. To do that all what is needed is to call an appropriate function with loaded apk and map of entry points:
L16941c=Set((MainActivity_v3,*),(int_v2,?),(String_v0,L169418),(String_v1,?),(Bundle_v4,*))
L169420=Set((MainActivity_v3,*),(int_v2,?),(String_v0,L169418),(String_v1,L16941c),(Bundle_v4,*))
L169426=Set((MainActivity_v3,*),(int_v2,?),(String_v0,L169418),(String_v1,L16941c),(Bundle_v4,*))
L16942c=Set((MainActivity_v3,*),(String_v0,L169418),(int_v2,L169426),(String_v1,L16941c),(Bundle_v4,*))
L169432=Set((MainActivity_v3,*),(String_v0,L169418),(int_v2,L169426),(String_v1,L16941c),(Bundle_v4,*))
L169438=Set((MainActivity_v3,*),(String_v0,L169418),(int_v2,L169426),(String_v1,L16941c),(Bundle_v4,*)
Exit=Set((MainActivity_v3,*),(String_v0,L169418),(int_v2,L169426),(String_v1,L16941c),(Bundle_v4,*))
Entry=Set((MainActivity_v3,*),(int_v2,?),(String_v0,?),(String_v1,?),(Bundle_v4,*))
val iss = InterproceduralSuperSpark(apk,Jumping to node L169432:
clazz.getDeclaredMethods.map(_.getSignature))
println(iss)
Call@(apk-name.apk:onCreate,L169432) ->The new entry point is function say() with 2 string arguments which were defined on the start of the onCreate() method as it can be seen by querying appropriate node in ICFG.
Entry@Lpackage/name/MainActivity;.say: (Ljava/lang/String;Ljava/lang/String;)V
invNode:Call@(apk-name.apk:onCreate,L169432)Argus is a useful tool which enables to build control and data flow graphs so one could follow how objects and variables are changed, and most importantly it follows the data through components which would otherwise be very restrictive. The key idea here is to query the usage of known crytographic APIs through the graphs to check for misuses which is demonstrated by authors. Since most CryptoLint rules mentioned before rely on checking the properties of arguments these type of analyzes seems appropriate to handle such tasks.
args:List(MainActivity_v3, String_v0, String_v1)
Source: https://sgros-students.blogspot.com/2017/06/amandroid-argus-static-analysis.html
相關文章
- Slither: A Static Analysis Framework For SmartFramework
- [論文解讀]A Quantitative Analysis Framework for Recurrent Neural NetworkFramework
- RISK ANALYSIS
- Flutter Analysis OptionsFlutter
- HanLP Analysis for ElasticsearchHanLPElasticsearch
- Oracle Hang AnalysisOracle
- static
- A Security Analysis Of Browser Extensions
- 生存分析(survival analysis)
- Profitability Analysis – General tables
- Statistics and Data Analysis for BioinformaticsORM
- java static 與 static靜態程式碼塊Java
- Elasticsearch Analysis 分析器Elasticsearch
- UEFI BIOS Rootkit AnalysisiOS
- Regression Analysis Using ExcelExcel
- An Analysis of Sequential Recommendation Datasets
- Web Scraping & Data AnalysisWebAPI
- C語言中的 static變數、static函式C語言變數函式
- php static dynamicPHP
- C#staticC#
- Java之StaticJava
- static變數變數
- 解析static!(轉)
- 理解static(轉)
- Interface中加Static
- Java中static、final、static final的區別Java
- Exercise 5: Field data acquisition and analysisUI
- Analysis of Set Union Algorithms 題解Go
- MSE 609 Quantitative Data Analysis
- java中的Static、final、Static final各種用法Java
- PHP中的staticPHP
- 理解C++ staticC++
- oop_promax_staticOOP
- static關鍵字
- PHP類的靜態(static)方法和靜態(static)變數PHP變數
- what-i-learned-from-analysis-vuepressVue
- Oracle Respones-Time Analysis ReportsOracle
- R語言-Survival analysis(生存分析)R語言