Android 루팅(Rooting) 여부 체크

RootBeer의 간단한 버전으로 루팅여부를 체크해보자.

class RootChecker(private val context: Context) { private val rootFiles = arrayOf( "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/system/usr/we-need-root/", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su", "/su/bin/su", "/su/bin", "/system/xbin/daemonsu" ) private val rootPackages = arrayOf( "com.devadvance.rootcloak", "com.devadvance.rootcloakplus", "com.koushikdutta.superuser", "com.thirdparty.superuser", "eu.chainfire.supersu", "de.robv.android.xposed.installer", "com.saurik.substrate", "com.zachspong.temprootremovejb", "com.amphoras.hidemyroot", "com.amphoras.hidemyrootadfree", "com.formyhm.hiderootPremium", "com.formyhm.hideroot", "com.noshufou.android.su", "com.noshufou.android.su.elite", "com.yellowes.su", "com.topjohnwu.magisk", "com.kingroot.kinguser", "com.kingo.root", "com.smedialink.oneclickroot", "com.zhiqupk.root.global", "com.alephzain.framaroot" ) private val runtime by lazy { Runtime.getRuntime() } fun isDeviceRooted(): Boolean { return checkRootFiles() || checkSUExist() || checkRootPackages() } private fun checkRootFiles(): Boolean { for (path in rootFiles) { try { if (File(path).exists()) { return true } } catch (e: RuntimeException) { } } return false } private fun checkSUExist(): Boolean { var process: Process? = null val su = arrayOf("/system/xbin/which", "su") try { process = runtime.exec(su) BufferedReader( InputStreamReader( process.inputStream, Charset.forName("UTF-8") ) ).use { reader -> return reader.readLine() != null } } catch (e: IOException) { } catch (e: Exception) { } finally { process?.destroy() } return false } private fun checkRootPackages(): Boolean { val pm = context.packageManager if (pm != null) { for (pkg in rootPackages) { try { pm.getPackageInfo(pkg, 0) return true } catch (ignored: PackageManager.NameNotFoundException) { // fine, package doesn't exist. } } } return false } }


댓글 없음:

댓글 쓰기

Android Compose Animation

나타남 /  사라짐 애니메이션 AnimatedVisibility 의 enter 및 exit 매개변수를 사용하면 컴포저블이 표시되고 사라질 때의 동작을 구성할 수 있습니다. 자세한 내용은  전체 문서 를 참고하세요. 컴포저블의 가시성을 애니메이션화하는 ...