资源简介
用FlowDroid的静态分析方法来分析android应用程序,描绘出android应用程序的函数调用图
代码片段和文件信息
package flowdroidcg;
import it.uniroma1.dis.wsngroup.gexf4j.core.EdgeType;
import it.uniroma1.dis.wsngroup.gexf4j.core.Gexf;
import it.uniroma1.dis.wsngroup.gexf4j.core.Graph;
import it.uniroma1.dis.wsngroup.gexf4j.core.Mode;
import it.uniroma1.dis.wsngroup.gexf4j.core.Node;
import it.uniroma1.dis.wsngroup.gexf4j.core.data.Attribute;
import it.uniroma1.dis.wsngroup.gexf4j.core.data.AttributeClass;
import it.uniroma1.dis.wsngroup.gexf4j.core.data.AttributeList;
import it.uniroma1.dis.wsngroup.gexf4j.core.data.AttributeType;
import it.uniroma1.dis.wsngroup.gexf4j.core.impl.GexfImpl;
import it.uniroma1.dis.wsngroup.gexf4j.core.impl.StaxGraphWriter;
import it.uniroma1.dis.wsngroup.gexf4j.core.impl.data.AttributeListImpl;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
public class CGExporter {
private Gexf gexf;
private Graph graph;
private Attribute codeArray;
private AttributeList attrList;
public CGExporter() {
this.gexf = new GexfImpl();
this.graph = this.gexf.getGraph();
this.gexf.getmetadata().setCreator(“liu3237“).setDescription(“App method invoke graph“);
this.gexf.setVisualization(true);
this.graph.setDefaultEdgeType(EdgeType.DIRECTED).setMode(Mode.STATIC);
this.attrList = new AttributeListImpl(AttributeClass.NODE);
this.graph.getAttributeLists().add(attrList);
//可以给每个节点设置一些属性,这里设置的属性名是 codeArray,实际上后面没用到
this.codeArray = this.attrList.createAttribute(“0“ AttributeType.STRING“codeArray“);
}
public void exportMIG(String graphName String storeDir) {
String outPath = storeDir + “/“ + graphName + “.gexf“;
StaxGraphWriter graphWriter = new StaxGraphWriter();
File f = new File(outPath);
Writer out;
try {
out = new FileWriter(f false);
graphWriter.writeToStream(this.gexf out “UTF-8“);
} catch (IOException e) {
e.printStackTrace();
}
}
public Node getNodeByID(String Id) {
List nodes = this.graph.getNodes();
Node nodeFinded = null;
for (Node node : nodes) {
String nodeID = node.getId();
if (nodeID.equals(Id)) {
nodeFinded = node;
break;
}
}
return nodeFinded;
}
public void linkNodeByID(String sourceID String targetID) {
Node sourceNode = this.getNodeByID(sourceID);
Node targetNode = this.getNodeByID(targetID);
if (sourceNode.equals(targetNode)) {
return;
}
if (!sourceNode.hasEdgeTo(targetID)) {
String edgeID = sourceID + “-->“ + targetID;
sourceNode.connectTo(edgeID ““ EdgeType.DIRECTED targetNode);
}
}
public void createNode(String m) {
String id = m;
String c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-12-14 14:06 flowdroidcg\
文件 1004 2015-12-14 13:57 flowdroidcg\.classpath
文件 387 2015-12-14 13:49 flowdroidcg\.project
目录 0 2015-12-14 13:49 flowdroidcg\.settings\
文件 598 2015-12-14 13:51 flowdroidcg\.settings\org.eclipse.jdt.core.prefs
目录 0 2015-12-14 13:58 flowdroidcg\bin\
目录 0 2015-12-14 13:59 flowdroidcg\bin\flowdroidcg\
文件 5795 2015-12-14 13:59 flowdroidcg\bin\flowdroidcg\CGExporter.class
文件 4326 2015-12-14 14:06 flowdroidcg\bin\flowdroidcg\CGGenerator.class
文件 941963 2015-12-14 14:06 flowdroidcg\flowdroidCFG.gexf.gexf
目录 0 2015-12-14 13:56 flowdroidcg\Refrenced Libraries\
文件 28108 2015-12-14 13:56 flowdroidcg\Refrenced Libraries\Axm
文件 72232 2015-12-14 13:56 flowdroidcg\Refrenced Libraries\gexf4j-0.4.4-BETA.jar
文件 182112 2015-12-14 13:56 flowdroidcg\Refrenced Libraries\stax2-api-3.1.1.jar
文件 482465 2015-12-14 13:56 flowdroidcg\Refrenced Libraries\woodstox-core-asl-4.0.6.jar
目录 0 2015-12-14 14:04 flowdroidcg\sootOutput\
文件 0 2015-12-14 14:02 flowdroidcg\sourcesAndSinks.txt
目录 0 2015-12-14 13:58 flowdroidcg\src\
目录 0 2015-12-14 13:59 flowdroidcg\src\flowdroidcg\
文件 3280 2015-12-14 13:59 flowdroidcg\src\flowdroidcg\CGExporter.java
文件 3911 2015-12-14 14:06 flowdroidcg\src\flowdroidcg\CGGenerator.java
- 上一篇:Android通用搜索页的分析与封装配套资源
- 下一篇:java数据结构课程设计
评论
共有 条评论