Skip to content

Instantly share code, notes, and snippets.

@sam0737
Created March 17, 2018 19:43
Show Gist options
  • Save sam0737/2f15ddc7bb17c67b0e1192ca7eb4495c to your computer and use it in GitHub Desktop.
Save sam0737/2f15ddc7bb17c67b0e1192ca7eb4495c to your computer and use it in GitHub Desktop.
HSBC Payme Root Detection
package com.cherrypicks.hsbcpayme.Manager;
import android.content.Context;
import android.os.Build;
import com.cherrypicks.hsbcpayme.model.util.C1764b;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
public class by {
public static Context f4158a;
public static void m7156a(Context context) {
f4158a = context;
}
public static boolean m7157a() {
return m7159b() || m7160c() || m7161d() || m7162e() || m7163f();
}
private static boolean m7158a(String str) {
try {
f4158a.getPackageManager().getPackageInfo(str, 1);
return true;
} catch (Exception e) {
return false;
}
}
private static boolean m7159b() {
String str = Build.TAGS;
boolean z = str != null && str.contains("test-keys");
C1764b.m8373a("RootPermissionManager", "#1:" + (z ? "FAIL" : "PASS"));
return z;
}
private static boolean m7160c() {
boolean z = new File("/system/app/Superuser.apk").exists() || new File("/system/app/supersu.apk").exists() || new File("/system/app/su.apk").exists() || !new File("/etc/security/otacerts.zip").exists();
C1764b.m8373a("RootPermissionManager", "#2:" + (z ? "FAIL" : "PASS"));
return z;
}
private static boolean m7161d() {
boolean z = false;
for (String file : new String[]{"/system/bin/su", "/system/xbin/su", "/sbin/su", "/system/su", "/system/bin/.ext/.su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su", "/data/local/xbin/su", "/data/local/bin/su"}) {
if (new File(file).exists()) {
z = true;
}
}
C1764b.m8373a("RootPermissionManager", "#3:" + (z ? "FAIL" : "PASS"));
return z;
}
private static boolean m7162e() {
boolean z = false;
Process process = null;
try {
process = Runtime.getRuntime().exec(new String[]{"/system/xbin/which", "su"});
if (new BufferedReader(new InputStreamReader(process.getInputStream())).readLine() != null) {
z = true;
}
if (process != null) {
process.destroy();
}
} catch (Throwable th) {
if (process != null) {
process.destroy();
}
}
C1764b.m8373a("RootPermissionManager", "#4:" + (z ? "FAIL" : "PASS"));
return z;
}
private static boolean m7163f() {
boolean z = m7158a("com.noshufou.android.su") || m7158a("com.thirdparty.superuser") || m7158a("eu.chainfire.supersu") || m7158a("com.koushikdutta.superuser");
C1764b.m8373a("RootPermissionManager", "#5:" + (z ? "FAIL" : "PASS"));
return z;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment