gpt4 book ai didi

java - 使用 Soot 分析 Android 应用程序

转载 作者:行者123 更新时间:2023-11-30 09:12:29 25 4
gpt4 key购买 nike

我正在编写一些分析 android 源代码的代码,基本上是为了跟踪局部变量的定义,我想在我的代码中使用 Soot 从 Android 源代码中提取一些信息并构建类的高级调用图, 我所有的工作都是使用应用程序的 java 源代码..

我不确定我是否需要在 http://www.bodden.de/2013/01/08/soot-android-instrumentation/ 中提到的 android jar因为这项工作不涉及阅读或编写 Dalvik 字节码 - 我无论如何都无法下载 jars!!-

我想知道是否有人可以就此给我一些指导,我阅读了 soot 的邮件列表并尝试了提供的解决方案但没有运气-由于导入的库和 R 类出现问题-!![我正在测试它一个基本的 hello world 源代码]

我们将不胜感激任何帮助,包括任何其他用于 android 静态分析的工具的引用。

非常感谢,,

用于 soot.Main 调用的参数是:

List<String> argsList = new ArrayList<String>(Arrays.asList(args));
argsList.addAll(Arrays.asList(new String[]{
"-allow-phantom-refs",
"-w",
"-soot-class-path",
"C:/Users/workspace_A/sootTest/src/com/example/soottest",
"-output-format",
"jimple",
"MainActivity"}

部分结果:

Warning: java.lang.NoClassDefFoundError is a phantom class!
Warning: java.lang.StringBuffer is a phantom class!
Warning: java.lang.Boolean is a phantom class!
Warning: java.lang.Long is a phantom class!
Warning: java.lang.Integer is a phantom class!
Warning: java.lang.Short is a phantom class!
Warning: java.lang.Float is a phantom class!
Warning: java.lang.Double is a phantom class!
Warning: java.lang.Throwable is a phantom class!
Warning: java.lang.Class is a phantom class!
Warning: java.lang.Character is a phantom class!
Warning: java.lang.AssertionError is a phantom class!
Warning: java.lang.Byte is a phantom class!
Warning: java.lang.Void is a phantom class!
Warning: java.lang.ClassFormatError is a phantom class!
Warning: java.lang.InstantiationError is a phantom class!
Warning: java.lang.Runnable is a phantom class!
Warning: java.lang.ref.Finalizer is a phantom class!
Warning: java.lang.IncompatibleClassChangeError is a phantom class!
Warning: java.lang.NoSuchFieldError is a phantom class!
Warning: java.lang.StackOverflowError is a phantom class!
Warning: java.lang.Thread is a phantom class!
Warning: java.lang.IllegalAccessError is a phantom class!
Warning: java.lang.ArrayStoreException is a phantom class!
Warning: java.dyn.InvokeDynamic is a phantom class!
Warning: java.lang.NoSuchMethodError is a phantom class!
Warning: java.lang.LinkageError is a phantom class!
Warning: java.lang.ExceptionInInitializerError is a phantom class!
Warning: java.lang.InternalError is a phantom class!
Warning: java.lang.VerifyError is a phantom class!
Warning: java.io.Serializable is a phantom class!
Warning: java.lang.ArrayIndexOutOfBoundsException is a phantom class!
Warning: java.lang.ClassCastException is a phantom class!
Warning: java.lang.ArithmeticException is a phantom class!
Warning: java.lang.IndexOutOfBoundsException is a phantom class!
Warning: java.lang.AbstractMethodError is a phantom class!
Warning: java.lang.Object is a phantom class!
Warning: java.lang.ThreadDeath is a phantom class!
Warning: java.lang.String is a phantom class!
Warning: java.lang.UnknownError is a phantom class!
Warning: java.lang.ClassCircularityError is a phantom class!
Warning: java.lang.Cloneable is a phantom class!
Warning: java.lang.NegativeArraySizeException is a phantom class!
Warning: java.lang.UnsatisfiedLinkError is a phantom class!
Warning: java.lang.Error is a phantom class!
Warning: java.lang.OutOfMemoryError is a phantom class!
Warning: java.lang.IllegalMonitorStateException is a phantom class!
Warning: java.lang.RuntimeException is a phantom class!
Warning: java.lang.NullPointerException is a phantom class!
Warning: java.lang.ClassNotFoundException is a phantom class!
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:3,8:
Semantic Error: no visible type named android.os.Bundle
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:4,8:
Semantic Error: no visible type named android.app.Activity
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:5,8:
Semantic Error: no visible type named android.view.Menu
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:7,35:
Semantic Error: no visible type named Activity
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:9:
Semantic Error: method does not override a method from its superclass
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:10,26:
Semantic Error: no visible type named Bundle
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:12:
Semantic Error: no method named setContentView(Unknown) in com.example.soottest.MainActivity matches.
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:12,18:
Semantic Error: R.layout not found
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:12,27:
Semantic Error: no field named activity_main
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:15:
Semantic Error: method does not override a method from its superclass
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:16,37:
Semantic Error: no visible type named Menu
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:18:
Semantic Error: no method named getMenuInflater() in com.example.soottest.MainActivity matches.
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:18,29:
Semantic Error: R.menu not found
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:18,36:
Semantic Error: no field named main
Exception in thread "main" soot.CompilationDeathException: there were errors during parsing and/or type checking (JastAdd frontend)
at soot.JastAddInitialResolver.formAst(JastAddInitialResolver.java:63)
at soot.JavaClassSource.resolve(JavaClassSource.java:54)
at soot.SootResolver.bringToHierarchy(SootResolver.java:215)
at soot.SootResolver.bringToSignatures(SootResolver.java:239)
at soot.SootResolver.bringToBodies(SootResolver.java:280)
at soot.SootResolver.processResolveWorklist(SootResolver.java:150)
at soot.SootResolver.resolveClass(SootResolver.java:124)
at soot.Scene.loadClass(Scene.java:448)
at soot.Scene.loadClassAndSupport(Scene.java:433)
at soot.Scene.loadNecessaryClass(Scene.java:1053)
at soot.Scene.loadNecessaryClasses(Scene.java:1067)
at soot.Main.run(Main.java:167)
at soot.Main.main(Main.java:141)
at sootCFG.CallGraphExample.main(CallGraphExample.java:60)

最佳答案

您需要在 Soot 的类路径上从您的 Java SDK 中为 Soot 提供 android.jar 或 rt.jar。然后它应该一切正常。

关于java - 使用 Soot 分析 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21505026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com