<div dir="ltr">Hi Steven,<div><br></div><div>Can we work with Android native apps using SOOT, i.e can we construct call graph from Native Android app&#39;s apk ? I couldn&#39;t find any tutorial on this topic.</div><div><br></div><div>Thank you.</div><div>Regards,</div><div>Monika</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 8, 2015 at 7:04 PM, Monika Mashalkar <span dir="ltr">&lt;<a href="mailto:monikamashalkar@gmail.com" target="_blank">monikamashalkar@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Got it !! Thank you Steven :)<span class=""><br><br>On Friday, 6 March 2015 17:12:38 UTC+5:30, Steven Arzt  wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">    <div><span class=""><p><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hi Monika,</span></p><p><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">You get these warnings because your APK file references classes which are not included in your Android JAR file. This is usually not a problem as long as you do not wish to analyze the code of the Android operating system itself.</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Best regards,</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">  Steven</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p></span><p><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Von:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a rel="nofollow">soot-lis...@CS.McGill.CA</a> [mailto:<a rel="nofollow">soot-lis...@CS.<u></u>McGill.CA</a>] <b>Im Auftrag von </b>Monika Mashalkar<span class=""><br><b>Gesendet:</b> Mittwoch, 25. Februar 2015 13:51<br><b>An:</b> Steven Arzt<br></span><b>Cc:</b> <a rel="nofollow">soot...@CS.McGill.CA</a>; <a rel="nofollow">soot...@sable.mcgill.ca</a>; <a rel="nofollow">soot...@googlegroups.com</a><span class=""><br><b>Betreff:</b> Re: [Soot-list] Generating Android APK CallFlowGraph</span></span></p><p> </p><div><p>Hi Steven,</p><div><div class="h5"><div><p> </p></div><div><p>Thanks for your quick reply. I am able to run the code now. But I am getting the warnings as follow :</p></div><div><p> </p></div><div><div><p>Warning: java.lang.ref.Finalizer is a phantom class!</p></div><div><p>Warning: android.graphics.pdf.<u></u>PdfDocument$Page is a phantom class!</p></div><div><p>Warning: android.graphics.pdf.<u></u>PdfDocument$PageInfo is a phantom class!</p></div><div><p>Warning: android.graphics.pdf.<u></u>PdfDocument is a phantom class!</p></div><div><p>Warning: android.media.<u></u>RemoteControlClient$<u></u>OnGetPlaybackPositionListener is a phantom class!</p></div><div><p>Warning: android.media.<u></u>RemoteControlClient$<u></u>OnPlaybackPositionUpdateListen<u></u>er is a phantom class!</p></div><div><p>Warning: android.print.PageRange is a phantom class!</p></div><div><p>Warning: android.print.PrintAttributes$<u></u>Builder is a phantom class!</p></div><div><p>Warning: android.print.PrintAttributes$<u></u>MediaSize is a phantom class!</p></div><div><p>Warning: android.print.PrintAttributes is a phantom class!</p></div><div><p>Warning: android.print.<u></u>PrintDocumentAdapter$<u></u>LayoutResultCallback is a phantom class!</p></div><div><p>Warning: android.print.<u></u>PrintDocumentAdapter$<u></u>WriteResultCallback is a phantom class!</p></div><div><p>Warning: android.print.<u></u>PrintDocumentAdapter is a phantom class!</p></div><div><p>Warning: android.print.<u></u>PrintDocumentInfo$Builder is a phantom class!</p></div><div><p>Warning: android.print.<u></u>PrintDocumentInfo is a phantom class!</p></div><div><p>Warning: android.print.PrintJob is a phantom class!</p></div><div><p>Warning: android.print.PrintManager is a phantom class!</p></div><div><p>Warning: android.print.pdf.<u></u>PrintedPdfDocument is a phantom class!</p></div><div><p>Warning: android.view.ViewTreeObserver$<u></u>OnWindowAttachListener is a phantom class!</p></div><div><p>Warning: android.view.ViewTreeObserver$<u></u>OnWindowFocusChangeListener is a phantom class!</p></div></div><div><p> </p></div><div><p>May I know the reason, why I am getting these warnings ?</p></div><div><p> </p></div><div><p>The command that I am using to run the program is :</p></div><div><p> </p></div><div><p>monika@monika-OptiPlex-990:~$ java -cp .:soot-trunk.jar:soot-<u></u>infoflow.jar:soot-infoflow-<u></u>android.jar:slf4j-api-1.7.5.<u></u>jar:slf4j-simple-1.7.5.jar:<u></u>axml-2.0.jar:/usr/lib/jvm/<u></u>java-7-openjdk-i386/jre/lib/<u></u>rt.jar CFG</p></div><div><p> </p></div><div><p>I am attaching the output file with this mail. Please, tell me I am getting it correct or not.</p></div><div><p> </p></div><div><p>Thanks and regards,</p></div><div><p>Monika</p></div></div></div></div><div><p> </p><div><span class=""><p>On Wed, Feb 25, 2015 at 3:51 PM, Steven Arzt &lt;<a rel="nofollow">Steve...@cased.de</a>&gt; wrote:</p></span><div><div><span class=""><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hi Monika,</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">The CFG class is not part of Soot. It was just written as an example. You need to compile it on your own.</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Best regards,</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">  Steven</span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:13.5pt;font-family:&quot;Courier New&quot;;color:black">M.Sc. M.Sc. Steven Arzt</span></p><p><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">Secure Software Engineering Group (SSE)</span></p><p><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">European Center for Security and Privacy by Design (EC SPRIDE) </span></p><p><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">Rheinstraße 75</span></p><p><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">D-64293 Darmstadt</span></p><p><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">Phone: +49 61 51 869-336</span></p><p><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">Fax: +49 61 51 16-72118</span></p><p><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">eMail: </span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><a rel="nofollow"><span lang="EN-US">steven.arzt@ec-spride.de</span></a></span></p><p><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">Web: <a href="http://sse.ec-spride.de/" rel="nofollow" target="_blank">http://sse.ec-spride.de</a></span></p><p><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p></span><p><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Von:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Monika Mashalkar [mailto:<a rel="nofollow">monikam...@gmail.<u></u>com</a>] <br><span class=""><b>Gesendet:</b> Mittwoch, 25. Februar 2015 05:30<br></span><b>An:</b> <a rel="nofollow">soot...@googlegroups.com</a><br><b>Cc:</b> <a rel="nofollow">soot...@sable.mcgill.ca</a>; <a rel="nofollow">soot...@cs.mcgill.ca</a>; <a rel="nofollow">Steve...@cased.de</a></span></p><div><div class="h5"><br><b>Betreff:</b> Re: [Soot-list] Generating Android APK CallFlowGraph</div></div><p></p><div><div class="h5"><p> </p><div><p>Hi Lokesh,</p><div><p> </p></div><div><p>I am very new to the SOOT Framework and Flow-droid. I want to find the flow graph from android apk in my project and I am trying to run the code posted in this thread to do the same. I am trying to run the following command on Ubuntu <br><br>Command : java -cp soot-trunk.jar:soot-infoflow.<u></u>jar:soot-infoflow-android.jar:<u></u>slf4j-api-1.7.5.jar:slf4j-<u></u>simple-1.7.5.jar:axml-2.0.jar -cp .:/usr/lib/jvm/java-7-openjdk-<u></u>i386/jre/lib/rt.jar CFG</p></div><div><p> </p></div><div><p>but I am getting Error as : Error: Could not find or load main class CFG</p></div><div><p> </p></div><div><p>Could you please tell me the command to execute the CFG program.</p></div><div><p> </p></div><div><p>Thank you,</p></div><div><p>Monika</p></div><div><p><br>On Monday, 21 July 2014 13:46:37 UTC+5:30, LOKESH JAIN wrote:</p><div><p>Hi all,</p><div><p> </p></div><div><p>I resolved the issue and finally i am getting the call graph. Thank you all of you for your time and help. :)</p></div><div><p> </p></div><div><p>1. But Stevan I am still curious to know how to work with QueueReader Object for generating dot format.</p></div><div><p>2. And why the size of call graph for RV2013.apk is 54. And is there any way to remove unnecessary size.</p></div><div><p> </p></div><div><p>Thanks&amp;Regards</p></div><div><p>Lokesh</p></div></div><div><p style="margin-bottom:12.0pt"> </p><div><p>On Mon, Jul 21, 2014 at 11:38 AM, LOKESH JAIN &lt;<a>lokesh...@gmail.com</a>&gt; wrote:</p><div><div><div><div><p>Hi all,</p></div><div><p>Steven I still couldn&#39;t figure it out how to work with queuereader object for generating dot format.</p></div><div><p> </p></div><div><p>I have used dot graph class manually as suggested to me by Stefan but,</p></div><div><div><div><p>I am getting NullPointerException. I don&#39;t know why. I have pasted the complete code.</p></div><div><p>Please help me out.</p></div><div><p> </p></div><div><p>Exception in thread &quot;main&quot; java.lang.NullPointerException</p></div><div><p>at DotGraph.getNode(DotGraph.<u></u>java:53)</p></div><div><p>at DotGraph.drawNode(DotGraph.<u></u>java:61)</p></div><div><p>at CFG.visit(CFG.java:114)</p></div><div><p>at CFG.main(CFG.java:94)</p></div><div><p> </p></div><div><p> </p></div><div><p>CFG.java</p></div><div><p> </p></div><div><p>import java.io.BufferedOutputStream;</p></div><div><p>import java.io.FileOutputStream;</p></div><div><div><p>import java.io.IOException;</p></div><div><p>import java.io.OutputStream;</p></div><div><p>import java.util.Collections;</p></div></div><div><p>import java.util.HashMap;</p></div><div><p>import java.util.HashSet;</p></div><div><p>import java.util.Iterator;</p></div><div><div><p>import java.util.LinkedList;</p></div><div><p>import java.util.List;</p></div><div><p> </p></div><div><p>import org.xmlpull.v1.<u></u>XmlPullParserException;</p></div><div><p> </p></div></div><div><p>import soot.MethodOrMethodContext;</p></div><div><div><p>import soot.PackManager;</p></div><div><p>import soot.Scene;</p></div><div><p>import soot.SootMethod;</p></div><div><p>import soot.jimple.infoflow.android.<u></u>SetupApplication;</p></div></div><div><p>import soot.jimple.toolkits.<u></u>callgraph.CallGraph;</p></div><div><p>import soot.jimple.toolkits.<u></u>callgraph.Targets;</p></div><div><div><p>import soot.options.Options;</p></div><div><p>import soot.util.dot.DotGraphUtility;</p></div><div><p>import soot.util.dot.Renderable;</p></div><div><p>public class CFG {</p></div></div><div><p>private static DotGraph dot = new DotGraph(&quot;callgraph&quot;);</p></div></div></div><div><p>private static HashMap &lt;String,Boolean&gt; visited = new HashMap&lt;String,Boolean&gt;(); </p></div><div><div><div><p>public CFG() {</p></div><div><div><div><p> </p></div><div><p> </p></div><div><p>}</p></div><div><p> </p></div><div><p>public static void main(String[] args) {</p></div><div><p> </p></div><div><p>// TODO Auto-generated method stub</p></div><div><p> </p></div><div><p>SetupApplication app = new SetupApplication(&quot;/home/<u></u>lokesh/Desktop/android-sdk-<u></u>linux/platforms/android-19/<u></u>android.jar&quot;,&quot;/home/lokesh/<u></u>Desktop/android-<u></u>instrumentation-tutorial-<u></u>master/app-example/RV2013/bin/<u></u>RV2013.apk&quot;);</p></div><div><p>try {</p></div><div><p> </p></div><div><p>app.<u></u>calculateSourcesSinksEntrypoin<u></u>ts(&quot;/home/lokesh/Downloads/<u></u>soot-infoflow-android-develop/<u></u>SourcesAndSinks.txt&quot;);</p></div><div><p> </p></div><div><p> </p></div><div><p>} catch (IOException e) {</p></div><div><p> </p></div><div><p>// TODO Auto-generated catch block</p></div><div><p> </p></div><div><p>e.printStackTrace();</p></div><div><p> </p></div><div><p>} catch (XmlPullParserException e) {</p></div><div><p> </p></div><div><p>// TODO Auto-generated catch block</p></div><div><p> </p></div><div><p>e.printStackTrace();</p></div><div><p> </p></div><div><p>}</p></div><div><p> </p></div><div><p>soot.G.reset();</p></div><div><p> </p></div><div><p>Options.v().set_src_prec(<u></u>Options.src_prec_apk);</p></div><div><p> </p></div><div><p>Options.v().set_process_dir(<u></u>Collections.singletonList(&quot;/<u></u>home/lokesh/Desktop/android-<u></u>instrumentation-tutorial-<u></u>master/app-example/RV2013/bin/<u></u>RV2013.apk&quot;));</p></div><div><p> </p></div><div><p>Options.v().set_force_android_<u></u>jar(&quot;/home/lokesh/Desktop/<u></u>android-sdk-linux/platforms/<u></u>android-19/android.jar&quot;);</p></div><div><p> </p></div><div><p>Options.v().set_whole_program(<u></u>true);</p></div><div><p> </p></div><div><p>Options.v().set_allow_phantom_<u></u>refs(true);</p></div><div><p> </p></div><div><p>Options.v().set_output_format(<u></u>Options.output_format_none);</p></div><div><p> </p></div><div><p>Options.v().setPhaseOption(&quot;<u></u>cg.spark verbose:true&quot;, &quot;on&quot;);</p></div><div><p> </p></div><div><p>Scene.v().<u></u>loadNecessaryClasses();</p></div><div><p> </p></div><div><p>SootMethod entryPoint = app.getEntryPointCreator().<u></u>createDummyMain();</p></div><div><p> </p></div><div><p>Options.v().set_main_class(<u></u>entryPoint.getSignature());</p></div><div><p> </p></div><div><p>Scene.v().setEntryPoints(<u></u>Collections.singletonList(<u></u>entryPoint));</p></div><div><p> </p></div><div><p>System.out.println(&quot;..........<u></u>..&quot;+entryPoint.getActiveBody()<u></u>);</p></div><div><p> </p></div><div><p>PackManager.v().runPacks();</p></div><div><p> </p></div><div><p>System.out.println(Scene.v().<u></u>getCallGraph().size());</p></div></div></div><div><div><p>CallGraph cg = Scene.v().getCallGraph();</p></div><div><p> </p></div><div><p>visit(cg, entryPoint);</p></div></div><div><p>dot.plot(&quot;/home/lokesh/<u></u>Desktop/soot1&quot;+ dot.DOT_EXTENSION);</p></div><div><div><p> </p></div><div><p>}</p></div><div><p>private static void visit(CallGraph cg, SootMethod k)</p></div><div><p>{</p></div><div><p>String identifier = k.getName();</p></div></div><div><p> </p></div></div></div><div><div><div><p>visited.put(k.getSignature(),<u></u>true);</p></div><div><div><p> </p></div><div><p> </p></div><div><p>dot.drawNode(identifier);</p></div><div><p> </p></div><div><p> </p></div><div><p>//iterate over unvisited parents</p></div><div><p>Iterator&lt;<u></u>MethodOrMethodContext&gt; ptargets = new Targets(cg.edgesInto(k));</p></div><div><p> </p></div><div><p> </p></div><div><p>if(ptargets != null){</p></div><div><p>while(ptargets.hasNext())</p></div><div><p>{</p></div><div><p>SootMethod p = (SootMethod) ptargets.next();</p></div><div><p> </p></div><div><p> </p></div><div><p>if(p == null) System.out.println(&quot;p is null&quot;);</p></div><div><p> </p></div><div><p> </p></div><div><p>if(!visited.containsKey(p.<u></u>getSignature()))</p></div><div><p>visit(cg,p);</p></div><div><p>}</p></div><div><p>}</p></div><div><p> </p></div><div><p> </p></div><div><p>//iterate over unvisited children</p></div><div><p>Iterator&lt;<u></u>MethodOrMethodContext&gt; ctargets = new Targets(cg.edgesOutOf(k));</p></div><div><p> </p></div><div><p> </p></div><div><p>if(ctargets != null){</p></div><div><p>while(ctargets.hasNext())</p></div><div><p>{</p></div><div><p>SootMethod c = (SootMethod) ctargets.next();</p></div><div><p>if(c == null) System.out.println(&quot;c is null&quot;);</p></div><div><p>dot.drawEdge(identifier, c.getName());</p></div><div><p> </p></div><div><p> </p></div><div><p>if(!visited.containsKey(c.<u></u>getSignature()))</p></div><div><p>visit(cg,c);</p></div><div><p>}</p></div><div><p>}</p></div><div><p>}</p></div><div><p>}</p></div><div><p> </p></div><div><p> </p></div><div><p> </p></div><div><p> </p></div></div><div><p>DotGraph.java</p></div><div><p> </p></div><div><p>import java.io.BufferedOutputStream;</p></div><div><p>import java.io.FileOutputStream;</p></div><div><p>import java.io.IOException;</p></div><div><p>import java.io.OutputStream;</p></div><div><p>import java.util.HashMap;</p></div><div><p>import java.util.LinkedList;</p></div><div><p>import java.util.List;</p></div><div><p> </p></div><div><p>import soot.util.dot.DotGraphEdge;</p></div><div><p>import soot.util.dot.DotGraphNode;</p></div><div><div><p>import soot.util.dot.DotGraphUtility;</p></div><div><p>import soot.util.dot.Renderable;</p></div><div><p> </p></div><div><p>public class DotGraph implements Renderable</p></div><div><p>{</p></div></div><div><p>public final static String DOT_EXTENSION = &quot;.dot&quot;;</p></div><div><p>private HashMap&lt;String, DotGraphNode&gt; nodes;</p></div><div><div><p>private boolean isSubGraph;</p></div><div><p>private List&lt;Renderable&gt; drawElements;</p></div><div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>  ...</blockquote></div></blockquote></div><br></div>