Skip to content

Instantly share code, notes, and snippets.

@AlD
Last active August 30, 2016 22:38
Show Gist options
  • Save AlD/651b5ec4fc1873e10bec90b8bcffda47 to your computer and use it in GitHub Desktop.
Save AlD/651b5ec4fc1873e10bec90b8bcffda47 to your computer and use it in GitHub Desktop.
Just as a hint; this is how many "secure" Android apps check for a rooted phone
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
final class zx
{
private static boolean a()
{
String s;
ArrayList arraylist = xe.a(new String[] {
"/system/bin/getprop", "ro.secure"
});
if(arraylist.isEmpty())
return false;
s = (String)arraylist.get(0);
int j = Integer.parseInt(s);
int i = j;
_L1:
NumberFormatException numberformatexception;
return i == 0;
numberformatexception;
i = 0;
goto _L1
}
public static boolean a(Context context)
{
label0:
{
String s = Build.TAGS;
boolean flag;
if(s != null && s.contains("test-keys"))
flag = true;
else
flag = false;
if(!flag && !(new File("/system/app/Superuser.apk")).exists())
{
boolean flag1;
boolean flag2;
if((new File("/system/xbin/which")).exists())
{
if(!xe.a(new String[] {
"/system/xbin/which", "su"
}).isEmpty())
flag2 = true;
else
flag2 = false;
} else
{
flag2 = false;
}
if(!flag2 && !b(context) && !a())
{
boolean flag3 = b();
flag1 = false;
if(!flag3)
break label0;
}
}
flag1 = true;
}
return flag1;
}
private static boolean a(Context context, String s)
{
try
{
context.getPackageManager().getPackageInfo(s, 8192);
}
catch(android.content.pm.PackageManager.NameNotFoundException namenotfoundexception)
{
return false;
}
return true;
}
private static boolean b()
{
ArrayList arraylist = xe.a(new String[] {
"/system/bin/ps", ""
});
if(arraylist.isEmpty())
return false;
arraylist.remove(0);
for(Iterator iterator = arraylist.iterator(); iterator.hasNext();)
{
String s = (String)iterator.next();
if(s.contains("/sbin/adbd"))
return s.contains("root");
}
return false;
}
private static boolean b(Context context)
{
if(context != null)
{
String as[] = {
"com.noshufou.android.su", "com.thirdparty.superuser", "eu.chainfire.supersu", "com.koushikdutta.superuser", "com.zachspong.temprootremovejb", "com.ramdroid.appquarantine"
};
for(int i = 0; i < 6; i++)
if(a(context, as[i]))
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment