Game 25
We have another Android APK to reverse engineer. Extract and decompile it:
❯ file Suninatas25Suninatas25: Zip archive data, ...
❯ unar Suninatas25❯ mv Suninatas25 Suninatas25.apk❯ # Open with jadxThe decompiled code reveals the app’s logic:
public class Suninatas25 extends Activity { public void onCreate(Bundle savedInstanceState) { // Reads contact with name "SuNiNaTaS" String conId = Suninatas25.this.getContacts("id"); String conNum = Suninatas25.this.getTel(conId);
// Constructs URL with contact name and number Uri uri = Uri.parse("http://www.suninatas.com/challenge/web25/chk_key.asp?id=" + id.toString() + "&pw=" + pw.toString() + "&Name=" + conName.toString() + "&Number=" + conNum.toString()); Intent it = new Intent("android.intent.action.VIEW", uri); Suninatas25.this.startActivity(it); }
public String getTel(String Idno) { // Retrieves phone number for contact ID StringBuffer tnum = new StringBuffer(); Cursor phones = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, "contact_id=" + Idno, null, null);16 collapsed lines
while (phones.moveToNext()) { String phoneNumber = phones.getString(phones.getColumnIndex("data1")); tnum.append(phoneNumber); } return tnum.toString(); }
public String getContacts(String Sel) { // Searches for contact named "SuNiNaTaS" StringBuffer sb = new StringBuffer(); Cursor contacts = getContentResolver().query( ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (contacts.moveToNext()) { String displayName = contacts.getString(contacts.getColumnIndex("display_name")); String contactId = contacts.getString(contacts.getColumnIndex("_id")); if (displayName.equals("SuNiNaTaS")) { if (Sel.equals("id")) { sb.append(contactId); } } } return sb.toString(); }}The vulnerability: the app reads the device’s contacts and looks for a contact named exactly SuNiNaTaS. To exploit it:
- Create a test account
- Add a contact to the phone with display name
SuNiNaTaSand any phone number - Run the app to extract the contact’s phone number
- Submit the request with the contact info:
Or directly enter the URL:
http://www.suninatas.com/challenge/web25/chk_key.asp?id=testuser&pw=testpass&Name=SuNiNaTaS&Number=1234567890The server verifies the contact information and returns the auth key.
FanTast1c aNdr0id w0r1d!