[Soot-list] Questions about soot:how to use soot to analysis java project

Linghui Luo linghui.luo at uni-paderborn.de
Fri Dec 22 05:15:06 EST 2017


Hi Jing,

I would suggest you to look after the line “ SootClass c = Scene.v().forceResolve("HelloWorld", SootClass.BODIES);” if you really got the HelloWorld class. If it is the case, you can use “c.getMethods()” to get all methods in c. Simply iterate it and look if the method test is in it. I think it is not hard to debug where the problem was.

Best regards,
Linghui Luo



Von: 张婧 [mailto:m201672947 at hust.edu.cn]
Gesendet: Freitag, 22. Dezember 2017 10:59
An: Linghui Luo <linghui.luo at uni-paderborn.de>
Betreff: Re: AW: [Soot-list] Questions about soot:how to use soot to analysis java project


Hello Linghui,

Thank you for your help.

there is another question:

I want to set the main method as entry point by myself.

such as:

package temp;//current package
import util.Unit;

public class HelloWorld {

public static void main(String[] args) {
// TODO Auto-generated method stub
}

 public void test(int in) {
  Unit unit = new Unit();
unit.A();
}
}

Unit is a class in other package "util".

I want set the "test()" as the entry point.

so:

 Options.v().parse("-cp D:\\eclipseProject\\HelloWorld\\bin -pp");
SootClass c = Scene.v().forceResolve("HelloWorld", SootClass.BODIES);
c.setApplicationClass();
Scene.v().loadNecessaryClasses();
SootMethod method = c.getMethodByName("test");
List entryPoints = new ArrayList();
entryPoints.add(method);
Scene.v().setEntryPoints(entryPoints);
PackManager.v().runPacks();



.class files are in folder "bin".

I get the following error:



Exception in thread "main" java.lang.RuntimeException: couldn't find method test(*) in HelloWorld
at soot.SootClass.getMethodByName(SootClass.java:494)
at s1test.Test.main(Test.java:27)

Can you help me?



Thank you very much.

Hope to receive your reply soon.

Best Regards,



Jing




-----原始邮件-----
发件人:"Linghui Luo" <linghui.luo at uni-paderborn.de<mailto:linghui.luo at uni-paderborn.de>>
发送时间:2017-12-21 22:01:47 (星期四)
收件人: "张婧" <m201672947 at hust.edu.cn<mailto:m201672947 at hust.edu.cn>>
抄送:
主题: AW: [Soot-list] Questions about soot:how to use soot to analysis java project
Hello Jing,

You need to compile your java source code (.java files) to java bytecode (.class files) at first. You can use soot to analyze the bytecode, namely .class files.
You can set soot class path with “Options.v().set_soot_classpath(targetDir)” or use the soot command line options “-cp targetDir -pp” (in your screenshot Options.v().parse(“-cp targetDir -pp”)),   “targetDir” should be the path of folder which includes the packages of the .class files you want to analyze.

Best,
Linghui Luo

Von: Soot-list [mailto:soot-list-bounces at CS.McGill.CA<mailto:soot-list-bounces at CS.McGill.CA>] Im Auftrag von ??
Gesendet: Donnerstag, 21. Dezember 2017 03:43
An: soot-list at cs.mcgill.ca<mailto:soot-list at cs.mcgill.ca>
Betreff: [Soot-list] Questions about soot:how to use soot to analysis java project


Hi,

My name is Jing. I'm new to use soot, so I meet some challenges.

Followings are my questions:

I want to use soot to analyse java projects or 3rd-party libraries, not apk.

For example:

project like

[cid:image001.png at 01D37B16.211493D0]

there many different packages,I want to analyse this project.(or a jar provides function interfaces)

What‘s more,I’'d like to set the entry point by myself.

I found some helps from tutorials in github,:

1. using "-process-dir"

[X]

2. analyse project without main method:

[cid:image002.png at 01D37B16.211493D0]



But I cann't run it successfully.

When java files in different packages,there are errors about “cann't find class:***”

I also failed in setting the main method

So, Does Soot can analyse the java project having  without main method?

If yes, someone can provide me a example in detail?



Thank you very much.

Hope to receive reply soon.

Best Regards.



Jing




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20171222/6568e185/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 32982 bytes
Desc: image001.png
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20171222/6568e185/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 131638 bytes
Desc: image002.png
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20171222/6568e185/attachment-0003.png>


More information about the Soot-list mailing list