Interprocedural distributive environment problem (IDE) & EPICC &SOOT

19
Interprocedural distributive environment problem (IDE) & EPICC &SOOT

description

Interprocedural distributive environment problem (IDE) & EPICC &SOOT. Soot 相关网址. Soot 文档 http:// www.sable.mcgill.ca/soot/tutorial/index.html Soot 命令行示例 http://www.bodden.de/2008/08/21/soot-command-line / Soot eclipse 插件 http://www.bodden.de/2008/08/30/soot-eclipse-plugin-tutorial / - PowerPoint PPT Presentation

Transcript of Interprocedural distributive environment problem (IDE) & EPICC &SOOT

Page 1: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

Interprocedural distributive environment problem (IDE) &

EPICC &SOOT

Page 2: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

Soot 相关网址Soot 文档http://www.sable.mcgill.ca/soot/tutorial/index.htmlSoot 命令行示例http://www.bodden.de/2008/08/21/soot-command-line/Soot eclipse 插件http://www.bodden.de/2008/08/30/soot-eclipse-plugin-tutorial/Soot 中间过程数据流分析http://www.bodden.de/2008/09/22/soot-intra/Soot 自定义分析程序入口点http://www.bodden.de/2012/07/26/soot-custom-entry-points/使用 Soot 分析 Android APPhttp://www.bodden.de/2013/01/08/soot-android-instrumentation/

Page 3: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

Soot

一个开源的、不断扩展的 java 分析工具,可以分析( class ; java ; jimple )

实现了向前、向后、向前分支流分析

Page 4: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

SOOT Android

支持对 Android 中 dex 文件分析 Dex Jimple -android-jar [android platform path]  -process-dir [ apk path] -outputformat […..] 其他参数见 Soot options 类

Page 5: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

Options.v().set_src_prec(Options.src_prec_apk); 预处理加载 apk 中 dex 代码

Soot 需处理 main 函数,构造伪 main 函数( Android )

Page 6: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

设置 soot 参数 加载必要的类 构造伪 main

设置入口点定义 IFDS/IDE

问题难点

解析问题

利用问题结果进行分析(难点)

Page 7: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

实现数据流分析要解决的问题 初始化流 数据流函数问题

DefaultIDETabulationProblem getNormalEdgeFunction getCallEdgeFunction getReturnEdgeFunction getCallToReturnEdgeFunction

Page 8: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

Interprocedural distributive environment problem (IDE)

程序表示点:由一个环境 environment 表示(符号到值的映射)操作 : 有一个环境转换器来表示( distributive environment transfer )Data fact : D L Data fact 属于 Env( D, L)

Page 9: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

G*=(N*, E*)G*: G1,G2,……, Gx 表示函数 x 的有向图,Gmain 表示 main 函数的有向图每个图有唯一 Sp , Ep一个函数调用用两个节点表示 Cs, Er

Page 10: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

一个环境转换器 t : Env(D,L) Env(D,L) ,作用在边上面一个 IDE 数据流问题,需要对有向超图中所有的边都分配一个环境转换器,由环境转换器对边进行解释,以期获得从开始点( source )到目标点( target )的结果

Page 11: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

IDE Problem = (G*,D,L,M) G* 有向超图 D 变量(符号)集合 L 格(值域) E*(Env(D,L) Env(D,L) ) , 对超图中

所有的边分配一个环境转换器

Page 12: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

Epicc

基本参数设置见 options 类

Page 13: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

对 apk 中所有的类都构造一个伪 main 函数

Page 14: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

将所有类都作为入口点加入 soot ,自动构造 CFG

寻找真的有Intent 类选为

入口点

只有有 Intent 对象的类才是要分析的类,

选为入口点

Page 15: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

重新设置入口点类

构造tranformer , IDEProblem ,解析器,问题求

解定义Soot 执行分析

Page 16: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

IDE 问题流函数(环境转换器) getNormalFlowFunction getCallFlowFunction getReturnFlowFunction getCallToReturnFlowFunction

Page 17: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

只做了componentName, Intentfilter , Intent , Boudle

的转换模型

Contentprovide 预留,但未做

Page 18: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

想法可否根据 EPICC 结果,在startactivity , startService 等函数地方进行代码替换,这样可以在一个 main 函数中把 Android 的所有组件都连接起来,可以很直接的获得全局的数据流路径为静态分析提供帮助。如: if () activity1 () else () activity2 ()

Page 19: Interprocedural   distributive  environment  problem (IDE)  & EPICC &SOOT

InvokeExpr invokeExpr = stmt.getInvokeExpr(); if(invokeExpr.getMethod().getName().equals("onDraw")) { Local tmpRef = addTmpRef(b); Local tmpString = addTmpString(b); // insert "tmpRef = java.lang.System.out;" units.insertBefore(Jimple.v().newAssignStmt( tmpRef, Jimple.v().newStaticFieldRef( Scene.v().getField("").makeRef())), u); // insert "tmpLong = 'HELLO';" units.insertBefore(Jimple.v().newAssignStmt(tmpString, StringConstant.v("HELLO")), u); // insert "tmpRef.println(tmpString);" SootMethod toCall = Scene.v().getSootClass("java.io.PrintStream").getMethod("void println(java.lang.String)"); units.insertBefore(Jimple.v().newInvokeStmt( Jimple.v().newVirtualInvokeExpr(tmpRef, toCall.makeRef(), tmpString)), u); //check that we did not mess up the Jimple b.validate(); }