问题描述
美好的一天,
我是 Soot 的新手,一直在尝试让 Soot 分析外部库/应用程序的调用图。具体来说,我想在 Tomcat jar 文件“catalina.jar”中获取类“DefaultServlet”的调用图。首先,我遵循了使用 main 方法分析简单类/文件的教程(例如 O2Lab)。但是,我要分析的类通常没有 main 方法。因此,我找到并遵循了利用入口点的示例(例如 Heros),但 Soot 仍然无法找到该类。请,我会很感激一些帮助。 这是我尝试过的最新主要代码段。
public class IFDSDataFlowTransformer extends SceneTransformer {
static LinkedList<String> excludeList;
static String mainclass = "DefaultServlet";
static String mainmethod = "doGet"; // "doPut";
public static void main(String[] args) {
// Set Soot's internal classpath
String javapath = System.getProperty("java.class.path");
String jredir = System.getProperty("java.home")+"/lib/rt.jar";
String path = javapath+File.pathSeparator+jredir;
Options.v().set_soot_classpath(path);
// Enable whole-program mode
Options.v().set_whole_program(true);
Options.v().set_app(true);
// Call-graph options
Options.v().setPhaSEOption("cg","safe-newinstance:true");
Options.v().setPhaSEOption("cg.cha","enabled:false");
// Enable SPARK call-graph construction
Options.v().setPhaSEOption("cg.spark","enabled:true");
Options.v().setPhaSEOption("cg.spark","verbose:true");
Options.v().setPhaSEOption("cg.spark","on-fly-cg:true");
Options.v().set_allow_phantom_refs(true);
// Set the main class of the application to be analysed
Options.v().set_main_class(mainclass);
// Load the main class
SootClass c = Scene.v().loadClass(mainclass,SootClass.BODIES);
c.setApplicationClass();
// Load the "main" method of the main class and set it as a Soot entry point
// SootMethod entryPoint = c.getmethodByName("main");
SootMethod entryPoint = c.getmethodByName(mainmethod);
List<SootMethod> entryPoints = new ArrayList<SootMethod>();
entryPoints.add(entryPoint);
Scene.v().setEntryPoints(entryPoints);
PackManager.v().getPack("wjtp").add(new Transform("wjtp.herosifds",new IFDSDataFlowTransformer()));
// soot.Main.main();
//start working
PackManager.v().runPacks();
}
我使用的是 Soot 3.3.1、Java 1.8,下面有一张我的 Eclipse 项目结构的照片。文件 IFDSDataFlowTransformer 和 TestSootCallGraph 开始两个单独的试验。 我是否必须创建一个带有 main 的新类来启动对 Tomcat 应用程序的请求(例如 http 或 curl 请求)?如果是这样,则需要在项目中包含更多 Tomcat jar/文件。但是,我认为 Soot 不需要应用程序中的特定输入或所有文件来静态分析代码。
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)