diff --git a/README.md b/README.md index ae871d71..45ede866 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,9 @@ Miscellaneous Android-Specific Implicit Flows -------------- * **ImplicitFlow1-4**: Test cases for implicit flows. +* **ImplicitFlow_Exception_prone_instruction**: IMEI value and its digits are written to Log through division by zero exception. +* **ImplicitFlow_Polymorphism**: IMEI value is written to Log through a polymorphic method. +* **ImplicitFlow_Throw**: IMEI value is written to Log through Throw instruction. Reflection ---------- diff --git a/apk/ImplicitFlows/ImplicitFlow_Exception_prone_instruction.apk b/apk/ImplicitFlows/ImplicitFlow_Exception_prone_instruction.apk new file mode 100644 index 00000000..afaf5a2d Binary files /dev/null and b/apk/ImplicitFlows/ImplicitFlow_Exception_prone_instruction.apk differ diff --git a/apk/ImplicitFlows/ImplicitFlow_Polymorphism.apk b/apk/ImplicitFlows/ImplicitFlow_Polymorphism.apk new file mode 100644 index 00000000..fecee205 Binary files /dev/null and b/apk/ImplicitFlows/ImplicitFlow_Polymorphism.apk differ diff --git a/apk/ImplicitFlows/ImplicitFlow_Throw.apk b/apk/ImplicitFlows/ImplicitFlow_Throw.apk new file mode 100644 index 00000000..66fd15d6 Binary files /dev/null and b/apk/ImplicitFlows/ImplicitFlow_Throw.apk differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.classpath b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.classpath new file mode 100644 index 00000000..7bc01d9a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.project b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.project new file mode 100644 index 00000000..5c8fd63e --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.project @@ -0,0 +1,33 @@ + + + ImplicitFlow_Exception_prone_instruction + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.settings/org.eclipse.jdt.core.prefs b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/AndroidManifest.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/AndroidManifest.xml new file mode 100644 index 00000000..79239827 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/ic_launcher-web.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/ic_launcher-web.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/libs/android-support-v4.jar b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/libs/android-support-v4.jar new file mode 100644 index 00000000..c31cede4 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/libs/android-support-v4.jar differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/proguard-project.txt b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/project.properties b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/project.properties new file mode 100644 index 00000000..3409f081 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-20 diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-hdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-hdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-mdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-mdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-xhdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-xhdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-xxhdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/layout/activity_main.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/layout/activity_main.xml new file mode 100644 index 00000000..50fe8d03 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values-v11/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values-v11/styles.xml new file mode 100644 index 00000000..3c02242a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values-v14/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values-v14/styles.xml new file mode 100644 index 00000000..a91fd037 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values/strings.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values/strings.xml new file mode 100644 index 00000000..78054628 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + ImplicitFlow_Exception_prone_instruction + Hello world! + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/src/aut/atlas/MainActivity.java b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/src/aut/atlas/MainActivity.java new file mode 100644 index 00000000..9c4534ac --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Exception_prone_instruction/src/aut/atlas/MainActivity.java @@ -0,0 +1,41 @@ +package aut.atlas; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.util.Log; +/** + * @testcase_name ImplicitFlow_ExceptionProneInstruction + * @version 0.1 + * @author_mail z.bohluli@aut.ac.ir + * @description IMEI value and its digits are written to Log through division by zero exception + * @dataflow source -> Exception-prone instruction -> sink + * @number_of_leaks 2 + * @challenges the analysis must be able to handle implicit flows induced by exception-prone instructions + */ + +public class MainActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + String imei = telephonyManager.getDeviceId(); + String lowIMEI = new String(); + for (char c : imei.toCharArray()){ + int high = ((int)c) - 48 ; + for (int low=0; low<=9; low++){ + try { + int tmp = 1 / (high - low); + } catch (Exception e){ + lowIMEI += (char) (low + 48); + Log.i("info", "An IMEI digit found " + low); + } + } + } + Log.i("info", "IMEI found = " + lowIMEI); + } + +} diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.classpath b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.classpath new file mode 100644 index 00000000..7bc01d9a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.project b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.project new file mode 100644 index 00000000..810c1c85 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.project @@ -0,0 +1,33 @@ + + + ImplicitFlow_Polymorphism + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.settings/org.eclipse.jdt.core.prefs b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/AndroidManifest.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/AndroidManifest.xml new file mode 100644 index 00000000..f7d88af7 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/AndroidManifest.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/ic_launcher-web.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/ic_launcher-web.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/libs/android-support-v4.jar b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/libs/android-support-v4.jar new file mode 100644 index 00000000..c31cede4 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/libs/android-support-v4.jar differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/proguard-project.txt b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/project.properties b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/project.properties new file mode 100644 index 00000000..3409f081 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-20 diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-hdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-hdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-mdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-mdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-xhdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-xhdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-xxhdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/layout/activity_main.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/layout/activity_main.xml new file mode 100644 index 00000000..50fe8d03 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values-v11/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values-v11/styles.xml new file mode 100644 index 00000000..3c02242a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values-v14/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values-v14/styles.xml new file mode 100644 index 00000000..a91fd037 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values/strings.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values/strings.xml new file mode 100644 index 00000000..01c0adfc --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + ImplicitFlow_Polymorphism + Hello world! + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/src/aut/atlas/MainActivity.java b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/src/aut/atlas/MainActivity.java new file mode 100644 index 00000000..fd27423a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Polymorphism/src/aut/atlas/MainActivity.java @@ -0,0 +1,104 @@ +package aut.atlas; + +import android.app.Activity; +import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.content.Context; +import android.util.Log; + +/** + * @testcase_name ImplicitFlow_Polymorphism + * @version 0.1 + * @author_mail z.bohluli@aut.ac.ir + * @description IMEI is written to Log through a polymorphic method + * @dataflow source -> polymorphic method -> sink + * @number_of_leaks 1 + * @challenges the analysis must be able to handle implicit flows induced by polymorphism + */ + + +public class MainActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + String imei = telephonyManager.getDeviceId(); + String lowIMEI = new String(); + Poly[] polys = {new Poly_0(), new Poly_1(), new Poly_2(), new Poly_3(), + new Poly_4(), new Poly_5(), new Poly_6(), new Poly_7(), new Poly_8(), new Poly_9()} ; + + for (char c: imei.toCharArray()){ + int high = ((int)c) - 48 ; + Poly poly = polys [high - 0]; + lowIMEI += poly.f(); + } + + Log.i("Info", "IMEI found = " + lowIMEI); + } +} + +class Poly { Poly() {} + char f() { return 'c'; } +} + +class Poly_0 extends Poly +{ + Poly_0() { super(); } + char f() { return '0'; } +} + +class Poly_1 extends Poly +{ + Poly_1() { super(); } + char f() { return '1'; } +} + +class Poly_2 extends Poly +{ + Poly_2() { super(); } + char f() { return '2'; } +} + +class Poly_3 extends Poly +{ + Poly_3() { super(); } + char f() { return '3'; } +} + +class Poly_4 extends Poly{ + Poly_4() { super(); } + char f() { return '4'; } +} + +class Poly_5 extends Poly +{ Poly_5() { super(); } + char f() { return '5'; } +} + +class Poly_6 extends Poly +{ Poly_6() { super(); } + char f() { return '6'; } +} + +class Poly_7 extends Poly +{ + Poly_7() { super(); } + char f() { return '7'; } +} + +class Poly_8 extends Poly +{ + Poly_8() { super(); } + char f() { return '8'; } +} + +class Poly_9 extends Poly +{ + Poly_9() { super(); } + char f() { return '9'; } +} + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.classpath b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.classpath new file mode 100644 index 00000000..7bc01d9a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.project b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.project new file mode 100644 index 00000000..9aaa553a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.project @@ -0,0 +1,33 @@ + + + ImplicitFlow_Throw + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.settings/org.eclipse.jdt.core.prefs b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/AndroidManifest.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/AndroidManifest.xml new file mode 100644 index 00000000..8e16bc1c --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/ic_launcher-web.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/ic_launcher-web.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/libs/android-support-v4.jar b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/libs/android-support-v4.jar new file mode 100644 index 00000000..c31cede4 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/libs/android-support-v4.jar differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/proguard-project.txt b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/project.properties b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/project.properties new file mode 100644 index 00000000..3409f081 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-20 diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-hdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-hdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-mdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-mdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-xhdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-xhdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-xxhdpi/ic_launcher.png b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/layout/activity_main.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/layout/activity_main.xml new file mode 100644 index 00000000..50fe8d03 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values-v11/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values-v11/styles.xml new file mode 100644 index 00000000..3c02242a --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values-v14/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values-v14/styles.xml new file mode 100644 index 00000000..a91fd037 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values/strings.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values/strings.xml new file mode 100644 index 00000000..0aea8246 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + ImplicitFlow_Throw + Hello world! + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values/styles.xml b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/src/aut/atlas/MainActivity.java b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/src/aut/atlas/MainActivity.java new file mode 100644 index 00000000..71db9747 --- /dev/null +++ b/eclipse-project/ImplicitFlows/ImplicitFlow_Throw/src/aut/atlas/MainActivity.java @@ -0,0 +1,84 @@ +package aut.atlas; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.util.Log; + +/** + * @testcase_name ImplicitFlow_Throw + * @version 0.1 + * @author_mail z.bohluli@aut.ac.ir + * @description IMEI is written to Log through Throw instruction + * @dataflow source -> Throw instruction -> sink + * @number_of_leaks 1 + * @challenges the analysis must be able to handle implicit flows induced by Throw instruction + */ + +public class MainActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + String imei = telephonyManager.getDeviceId(); + String lowIMEI = new String(); + Exception[] excepts = {new Exception_0(), new Exception_1(),new Exception_2(), + new Exception_3(), new Exception_4(), new Exception_5(), new Exception_6(), + new Exception_7(), new Exception_8(), new Exception_9()}; + for (char c : imei.toCharArray()){ + int high = ((int)c ) - 48 ; + Exception except = excepts[high-0]; + + try { + throw except ; + }catch (Exception_0 e){ + lowIMEI += '0' ; + } + catch (Exception_1 e){ + lowIMEI += '1' ; + } + catch (Exception_2 e){ + lowIMEI += '2' ; + } + catch (Exception_3 e){ + lowIMEI += '3' ; + } + catch (Exception_4 e){ + lowIMEI += '4' ; + } + catch (Exception_5 e){ + lowIMEI += '5' ; + } + catch (Exception_6 e){ + lowIMEI += '6' ; + } + catch (Exception_7 e){ + lowIMEI += '7' ; + } + catch (Exception_8 e){ + lowIMEI += '8' ; + } + catch (Exception_9 e){ + lowIMEI += '9' ; + } + catch (Exception e){ + e.printStackTrace(); + } + } + Log.i("Info", "IMEI found " + lowIMEI) ; + } + +} +class Exception_0 extends Exception{} +class Exception_1 extends Exception{} +class Exception_2 extends Exception{} +class Exception_3 extends Exception{} +class Exception_4 extends Exception{} +class Exception_5 extends Exception{} +class Exception_6 extends Exception{} +class Exception_7 extends Exception{} +class Exception_8 extends Exception{} +class Exception_9 extends Exception{}