I am writing an Android app that will report to the user (among other SafetyNet data) if there is any PHA (Potentially Harmful Application) installed on his/her device.
For that I am using the SafetyNet Verify Apps API. My call to isVerifyAppsEnabled()
is working properly, but making calls to listHarmfulApps()
yields nothing.
Both are syntatically identical, so I believe my code is ok, but here it is, anyway:
SafetyNetClient safetyNetClient = SafetyNet.getClient(this.getContext());
safetyNetClient.listHarmfulApps()
.addOnCompleteListener(new OnCompleteListener<SafetyNetApi.HarmfulAppsResponse>() {
@Override
public void onComplete(@NonNull Task<SafetyNetApi.HarmfulAppsResponse> task) {
Log.d("FragmentSafetyNet", "Received listHarmfulApps() result");
if (task.isSuccessful()) {
SafetyNetApi.HarmfulAppsResponse result = task.getResult();
List<HarmfulAppsData> appList = result.getHarmfulAppsList();
if (appList.isEmpty()) {
Log.d("FragmentSafetyNet", "There are no known potentially harmful apps installed.");
} else {
Log.e("FragmentSafetyNet", "Potentially harmful apps are installed!");
for (HarmfulAppsData harmfulApp : appList) {
Log.e("FragmentSafetyNet", "Information about a harmful app:");
Log.e("FragmentSafetyNet", " APK: " + harmfulApp.apkPackageName);
Log.e("FragmentSafetyNet", " SHA-256: " + harmfulApp.apkSha256);
Log.e("FragmentSafetyNet", " Category: " + harmfulApp.apkCategory);
}
}
} else {
Log.d("FragmentSafetyNet", "An error occurred. " +
"Call isVerifyAppsEnabled() to ensure " +
"that the user has consented.");
}
}
})
.addOnSuccessListener(new OnSuccessListener<SafetyNetApi.HarmfulAppsResponse>() {
@Override
public void onSuccess(SafetyNetApi.HarmfulAppsResponse harmfulAppsResponse) {
Log.d("listHarmfulApps()", "Sucess! Received listHarmfulApps() result");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e("listHarmfulApps()", "Error: " + e.getMessage());
}
});
There really isn't much to the code: it is basically the code on Google's page adapted to use the new API calls in GMS 11.0.2 (the examples on the forementioned page all use deprecated calls), but it isn't working at all. None of the listeners are being triggered.
Either I messed something or there simply isn't any PHA on the device I am testing.
Thus my 3 questions:
1) Is my code correct?
2) Is there any sort of PHA that I can install that will be blacklisted, show up on the list, but isn't actually harmful? (like the EICAR virus used to test anti-virus software).
3) Finally, if (1) and (2) aren't possible, is there any PHA I can install? In this case I'll be using a controlled, disposible environment, like a rooted emulator that I'll just wipe afterwards.
Thank you in advance.