Skip to content

Instantly share code, notes, and snippets.

@maxvonhippel
Created April 27, 2018 02:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maxvonhippel/9df5d30beca2dea0a92ddac30b59e436 to your computer and use it in GitHub Desktop.
Save maxvonhippel/9df5d30beca2dea0a92ddac30b59e436 to your computer and use it in GitHub Desktop.
Getting started with MaMaDroid on Mac OS
# Clone MamaDroid
git clone https://bitbucket.org/gianluca_students/mamadroid_code.git mamadroid
# Get some malware to look at
git clone https://github.com/ashishb/android-malware.git malware
# Export variables
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/
export JRE_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/bin
export PATH=$JAVA_HOME:$JRE_HOME:$PATH
# Base dir variable for convenience
basedir=$(echo $(pwd)/mamadroid)
cd mamadroid
mv soot_jars soot
cd soot
# axml-2.0.jar
wget https://github.com/secure-software-engineering/soot-infoflow-android/raw/develop/lib/axml-2.0.jar
# slf4j-api-1.7.5.jar
wget https://github.com/secure-software-engineering/soot-infoflow-android/raw/b436c512431d875a0bb3c53ea55bbdb137c0aab0/lib/slf4j-api-1.7.5.jar
# slf4j-simple-1.7.5.jar
wget https://github.com/secure-software-engineering/soot-infoflow-android/raw/b436c512431d875a0bb3c53ea55bbdb137c0aab0/lib/slf4j-simple-1.7.5.jar
# soot-infoflow-android.jar should already be in there
# soot-infoflow.jar should already be in there
# soot-trunk.jar should already be in there
# SourcesAndSinks.txt
wget https://raw.githubusercontent.com/secure-software-engineering/soot-infoflow-android/develop/SourcesAndSinks.txt
# AndroidCallbacks.txt
wget https://raw.githubusercontent.com/0-14N/soot-infoflow-android/master/AndroidCallbacks.txt
# EasyTaintWrapperSource.txt
wget https://raw.githubusercontent.com/secure-software-engineering/soot-infoflow/develop/EasyTaintWrapperSource.txt
# Export classpath for java
export CLASSPATH="$basedir/.:$basedir/soot/soot-trunk.jar:$basedir/soot/soot-infoflow.jar:$basedir/soot/soot-infoflow-android.jar:$basedir/soot/slf4j-simple-1.7.5.jar:$basedir/soot/slf4j-api-1.7.5.jar:$basedir/soot/axml-2.0.jar:$basedir/soot/sootclasses-trunk-jar-with-dependencies.jar"
cd ..
# Compile Appgraph
javac -cp $CLASSPATH Appgraph.java
export ANDORID_JARS=$HOME/Library/Android/sdk/platforms
# Get DroidBench
cd ..
git clone https://github.com/secure-software-engineering/DroidBench.git
cd mamadroid
# Add DroidBench path
export DROIDBENCH=$HOME/DroidBench
# Now we try it on an app
badapp=../android-malware/Android.Malware.at_plapk.a/com.fdhgkjhrtjkjbx.model.apk
python2 mamadroid.py -f $badapp -d $ANDORID_JARS
# A ton of stuff gets output
less com.fdhgkjhrtjkjbx.model.txt
# ^^ Presumably this file is what I will be able to do something interesting with using MaMaDroid once I learn how it works
@Dhani92
Copy link

Dhani92 commented Apr 27, 2018

Thanks for sharing this!!

@maxvonhippel
Copy link
Author

Sure! Hope it helps!

@maxvonhippel
Copy link
Author

maxvonhippel commented Apr 28, 2018

I made another gist for making a figure from MAMADROID's output, you can check it out here

@OxfordNJ
Copy link

Hi, do you have any idea on optimizing the MaMaDroid?

@JunTomyang
Copy link

Hi maxvonhippel,
Thanks for your time and attention. I am setting up MaMadroid project. The formal steps are all executable. When I run the 'line 43' command, there appears an error as:
Exception in thread "main" java.lang.RuntimeException: file '/home/nsclab/Library/Android/sdk/platforms' does not exist!
at soot.Scene.getAndroidAPIVersion(Scene.java:338)
at soot.Scene.getAndroidJarPath(Scene.java:320)
at soot.jimple.infoflow.android.SetupApplication.getClasspath(SetupApplication.java:644)
at soot.jimple.infoflow.android.SetupApplication.initializeSoot(SetupApplication.java:660)
at soot.jimple.infoflow.android.SetupApplication.calculateCallbackMethods(SetupApplication.java:470)
at soot.jimple.infoflow.android.SetupApplication.calculateSourcesSinksEntrypoints(SetupApplication.java:401)
at soot.jimple.infoflow.android.SetupApplication.calculateSourcesSinksEntrypoints(SetupApplication.java:359)
at Appgraph.main(Appgraph.java:40)
Can you give me some advice? How can I install the SDK platforms? Look forward to your reply.

@PegX
Copy link

PegX commented Jun 19, 2020

Hello Max. Would you mind give me some hints about the database:database:database as the input of MaMaStat.py? I am a little bit confused about the description of the usage.

@maxvonhippel
Copy link
Author

Hey guys, I haven't tried to run this code in ~ 2 years ... I suggest you contact the project's authors. Sorry!

(I had nothing to do with developing MaMaDroid, I only figured out how to run the code in order to use it for comparison to some code I wrote in a senior thesis as an undergrad ...)

@maxvonhippel
Copy link
Author

If any of you find the solutions to these problems feel free to share them here.

@maxvonhippel
Copy link
Author

@PegX I am sure I never used any database in MaMaDroid, I probably only ever ran the code I wrote in this gist, ie., python2 mamadroid.py -f $badapp -d $ANDORID_JARS ... sorry!

@PegX
Copy link

PegX commented Jun 22, 2020

@PegX I am sure I never used any database in MaMaDroid, I probably only ever ran the code I wrote in this gist, ie., python2 mamadroid.py -f $badapp -d $ANDORID_JARS ... sorry!

Hi Max. No worries. Thanks for your reply. Actually I checked the code and find out some tips. Thanks again.

@maxvonhippel
Copy link
Author

Sure! Glad this helped!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment