rg663
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # How to Install SootUp ## Installing SootUp Open the command prompt in your computer and in the directory of your choice (Desktop, Downloads.. etc) run`git clone https://github.com/secure-software-engineering/Shttps://hackmd.io/ootUp.git` (paste this command in your terminal). You should see the below output. ![](https://hackmd.io/_uploads/B1QcShIfp.png) ###### Figure 1: Screenshot of the successful clone of SootUP We then change directories using the command `cd SootUp` in your terminal. After this run `mvn install` in the terminal (`mvn` stands for Maven). You should see the below output. ![](https://hackmd.io/_uploads/HyOvH3UfT.png) ##### Figure 2: Screenshot of the successful build of SootUP ## IDE After building SootUp in your directory of choice, you should install IntelliJ IDEA (Ultimate Edition) (https://www.jetbrains.com/idea/). As a student, you can avail the free version from the JetBrains website. We will be using this IDE for the duration of this course. Open IntelliJ and click on New Project, choose the required options for the project as shown below. ![](https://hackmd.io/_uploads/r1nMDnUG6.png) ##### Figure 3: Screenshot of the New Project specifications for the Hello World project ## Maven When you open your Project, you should be able to see something similar as shown below. In the below screenshot, you can see the pom.xml file. ![](https://hackmd.io/_uploads/By46PhLMp.png) Open your project's pom.xml file. Below `</properties>` and before `</project>` in your pom.xml file, paste the below code. Once IntelliJ renders your pom.xml file, you will see a small blue M icon show up next to your code. Click this to import the Maven projects, and your Output window should not show any errors. ``` <repositories> <repository> <id>SootUp-repo</id> <url>https://github.com/soot-oss/SootUp</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.core</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.java.core</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.java.sourcecode</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.java.bytecode</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.jimple.parser</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.callgraph</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.soot-oss</groupId> <artifactId>sootup.analysis</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>2.0.0-alpha0</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>2.0.0-alpha0</version> <scope>runtime</scope> </dependency> </dependencies> ``` Save the pom.xml file. ## Adding Jar files Next, click on `Files>>Project Structure>> Modules>>Dependencies>>click on the plus button then click on Jars and Directories`. For every folder that starts with `sootup` in your directory, go to the target folder, click the `.jar` file in that directory, and add it. Ensure that you do this for every subfolder. If you have an error asking what kind of file this is, click `Jar Directory.` ![](https://hackmd.io/_uploads/HJGikRUfT.png) ##### Figure 4: Screenshot of adding the jar files for the Hello World project # Running HelloWorld.java Paste the below code into a new file in your SootUp directory called HelloWorld.java in src>main>java>org>example. ``` public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } ``` In your Terminal, cd into the directory where you just created your HelloWorld.java file. Run `javac HelloWorld.java`, this will create a class file called HelloWorld.class in your project directory. Run `java HelloWorld.java` After this go to your project in IntelliJ and create another file called HelloWorldAnalysis.java, in the same directory as your HelloWorld.java and HelloWorld.class files. Copy and paste the following code into the HelloWorldAnalysis.java file: ``` import sootup.core.Project; import sootup.core.inputlocation.AnalysisInputLocation; import sootup.core.jimple.common.stmt.Stmt; import sootup.core.model.SootClass; import sootup.core.model.SootMethod; import sootup.core.signatures.MethodSignature; import sootup.core.types.ClassType; import sootup.core.views.View; import sootup.java.bytecode.inputlocation.JavaClassPathAnalysisInputLocation; import sootup.java.core.JavaProject; import sootup.java.core.JavaSootClass; import sootup.java.core.JavaSootClassSource; import sootup.java.core.language.JavaLanguage; import sootup.java.core.views.JavaView; import java.util.Collections; public class HelloWorldAnalysis { public static void main(String[] args) { AnalysisInputLocation<JavaSootClass> inputLocation = new JavaClassPathAnalysisInputLocation("src/main/java/org/example"); JavaLanguage language = new JavaLanguage(8); Project<JavaSootClass, JavaView> project = JavaProject.builder(language) .addInputLocation(inputLocation).build(); ClassType classType = project.getIdentifierFactory().getClassType("HelloWorld"); MethodSignature methodSignature = project.getIdentifierFactory().getMethodSignature( "main", String.valueOf(classType), "void", Collections.singletonList("java.lang.String[]")); View<JavaSootClass> view = project.createView(); SootClass<JavaSootClassSource> sootClass = view.getClass(classType).get(); SootMethod sootMethod = sootClass.getMethod(methodSignature.getSubSignature()).get(); System.out.println(sootMethod.getBody().getStmts()); } } } ``` Once you run the HelloWorldAnalysis.java file, you will be able to see the Jimple representation of your HelloWorld.java code as shown below. ![](https://hackmd.io/_uploads/ry4xG0IMp.png) # Testing for sources and sinks To be able to test if the given programs let in or let out sensitive information, run the test cases in the `sources/main/java/org/example/SourcesSinksTests.java` file in the `sources-and-sinks-implementation` branch by clicking on the green Play button in IntelliJ. Feel free to create your own by inputting methods into the code as follows: Example folder name containing .class Java file to compile: `"helloworld"` (the exact path is `sources/main/java/org/example/helloworld/HelloWorld.class`) Example method signature to verify source/ sink analysis on: `<java.io.PrintStream: void println(java.lang.String)>` ``` @Test @DisplayName("Println is indeed a sink") public void testHelloWorld() { String printOutput = SourcesAndSinksAnalysis.SourcesSinks("helloworld").get("<java.io.PrintStream: void println(java.lang.String)>"); assert Objects.equals(printOutput, "SINK"); } ``` # Running these tests automatically To automatically run all tests, input the following into your command to compile the automated testing file: `javac TestRunner.java` Then, run the green Play button in IntelliJ to run the tests. # The WorkList Algorithm To run a version of the WorkList algorithm on SootUp, go to ```url://url```. This is an implementation of the algorithm in SootUp specifically using SootUp's ```Stmt``` class. This algorithm runs on a pre-defined ```Node``` class. It has the attrbutes ```stmt```, which is of the ```Stmt``` type, as well as successors and predecessors, which are a ```Hashset``` constaining ```Node``` types. This algorithm uses the [test for sources and sinks](https://hackmd.io/2mMA1-8USkCbXSVYEngi1Q#Testing-for-sources-and-sinks) to determine whether a node is a source or sink. If it is neither, the algorithm uses the various methods in the ```Stmt``` to determine whether the ```Node``` holds an ```AssignStmt```, ```InvokeStmt``` or any other type of ```Stmt``` supported by SootUp. After this, the algorithm performs a union operation with the predeccesors of this node and the ```Stmt``` contained within the node in question. This provides a detailed ```Hashset``` of all the data from this ```Node``` and its predeccesors that could potentially be leaked. # FAQ 1. How to install Maven? If you get the `command not found` error you need to install maven, you can do that by going to https://maven.apache.org/download.cgi and then downloading the 3.9.5 bin.tar.gz if you are using Mac and bin.zip file if you are using Windows. Additional help can be found here for installing maven for Mac https://www.digitalocean.com/community/tutorials/install-maven-mac-os, installing maven for Windows https://phoenixnap.com/kb/install-maven-windows. 2. Java version Make sure when you run `javac -version` and `java -version`, the outputs in the terminal should match. This usually means you have two Java versions installed on your computer. For this project, we will be using either Java 8 or Java 18.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully