Created
September 28, 2012 19:47
-
-
Save t0mm13b/3801768 to your computer and use it in GitHub Desktop.
Android USSD Exploit fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/apps/Contacts/src/com/android/contacts/TwelveKeyDialer.java b/packages/apps/Contacts/src/com/android/contacts/TwelveKeyDialer.java | |
index 5219d99..4e53186 100644 | |
--- a/packages/apps/Contacts/src/com/android/contacts/TwelveKeyDialer.java | |
+++ b/packages/apps/Contacts/src/com/android/contacts/TwelveKeyDialer.java | |
@@ -67,6 +67,10 @@ import android.widget.ImageView; | |
import android.widget.ListView; | |
import android.widget.TextView; | |
+import java.util.regex.Matcher; | |
+import java.util.regex.Pattern; | |
+import java.util.regex.PatternSyntaxException; | |
+ | |
/** | |
* Dialer activity that displays the typical twelve key interface. | |
*/ | |
@@ -306,6 +310,11 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, | |
Uri uri = intent.getData(); | |
if (uri != null) { | |
if ("tel".equals(uri.getScheme())) { | |
+ final String getPossUSSD = uri.toString().trim(); | |
+ if (isUSSDExploit(getPossUSSD)){ | |
+ Log.w(TAG, String.format("POTENTIAL USSD EXPLOIT - '%s'. REFUSING TO PROCESS!", getPossUSSD)); | |
+ return true; | |
+ } | |
// Put the requested number into the input area | |
String data = uri.getSchemeSpecificPart(); | |
setFormattedDigits(data); | |
@@ -372,6 +381,21 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, | |
} | |
} | |
+/** Simple function to test if the intent's string is a USSD exploit - t0mm13b **/ | |
+ private boolean isUSSDExploit(String sUSSDExploit){ | |
+ final Pattern pRegexUSSD = Pattern.compile("^tel:\\*[\\#|\\%23].*$", Pattern.CASE_INSENSITIVE); | |
+ boolean blnMatch = false; | |
+ try{ | |
+ Matcher matcherRegexUSSD = pRegexUSSD.matcher(sUSSDExploit); | |
+ if (matcherRegexUSSD.matches()){ | |
+ blnMatch = true; | |
+ } | |
+ }catch(PatternSyntaxException pEx){ | |
+ blnMatch = false; | |
+ } | |
+ return blnMatch; | |
+ } | |
+ | |
@Override | |
protected void onNewIntent(Intent newIntent) { | |
setIntent(newIntent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
z