Code Monkey home page Code Monkey logo

rootbeer's Introduction

RootBeer app icon

RootBeer

A tasty root checker library and sample app. We've scoured the internets for different methods of answering that age old question... Has this device got root?

Root checks

These are the current checks/tricks we are using to give an indication of root.

Java checks

  • checkRootManagementApps
  • checkPotentiallyDangerousApps
  • checkRootCloakingApps
  • checkTestKeys
  • checkForDangerousProps
  • checkForBusyBoxBinary
  • checkForSuBinary
  • checkSuExists
  • checkForRWSystem

Native checks

We call through to our native root checker to run some of its own checks. Native checks are typically harder to cloak, so some root cloak apps just block the loading of native libraries that contain certain keywords.

  • checkForSuBinary

Disclaimer and limitations!

We love root! both Scott and Mat (the creators) own and use rooted devices (albeit not as daily driver). However we appreciate it can be useful to have an indication your app is running on a rooted device. Plus as hackday style project we wanted to see if we could beat the root cloakers at the time in 2015.

Remember root==god, so there's no 100% guaranteed way to check for root! treat this as an indication of root.

Root cloakers

In 2015 we successfully tested Rootbeer and it flagged an indication of root when testing with the following root cloak apps. However Rootbeer was defeated when using a combination of the root cloakers activated at the same time.

Tested cloakers:

Usage

RootBeer rootBeer = new RootBeer(context);
if (rootBeer.isRooted()) {
    //we found indication of root
} else {
    //we didn't find indication of root
}

You can also call each of the checks individually as the sample app does. It is advisable to call isRooted() from a background thread as it involves disk I/O.

False positives

Manufacturers often leave the busybox binary in production builds and this doesn't always mean that a device is root. We have removed the busybox check we used to include as standard in the isRooted() method to avoid these false positives.

If you want to detect the busybox binary in your app you can use checkForBinary(BINARY_BUSYBOX) to detect it alone, or as part of the complete root detection method:

rootBeer.isRootedWithBusyBoxCheck();

The following devices are known the have the busybox binary present on the stock rom:

  • All OnePlus Devices
  • Moto E
  • OPPO R9m (ColorOS 3.0,Android 5.1,Android security patch January 5, 2018 )

Dependency

Available on maven central, to include using Gradle just add the following:

dependencies {
    implementation 'com.scottyab:rootbeer-lib:0.1.0'
}

Or use this Jitpack.io link

Building

The native library in this application will now be built via Gradle and the latest Android Studio without having to resort to the command line. However the .so files are also distributed in this repository for those who cannot compile using the NDK for some reason.

Sample app

The sample app is published on Google play to allow you to quickly and easier test the library. Enjoy! And please do feedback to us if your tests produce different results.

Get it on Google Play

screenshot

Contributing

There must be more root checks to make this more complete. If you have one please do send us a pull request.

Thanks

Other libraries

If you dig this, you might like:

Licence

Apache License, Version 2.0

Copyright (C) 2015, Scott Alexander-Bown, Mat Rollings

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

rootbeer's People

Contributors

altvnv avatar andyb129 avatar awaseem avatar biddster avatar blizzedru avatar cre8ivejp avatar danielkutik avatar deepakpk009 avatar fi5t avatar friederbluemle avatar harsh2098 avatar leocadiotine avatar leonkarabchevsky avatar litrik avatar namouchislim avatar prattpratt avatar prempalsingh avatar scottyab avatar shanmugasanthosh7 avatar slawert avatar stealthcopter avatar stefma avatar toteto avatar vyas-n avatar zhqcqupt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rootbeer's Issues

UnsatisfiedLinkError

Hi,
thank you for the great lib,

I have an app that has compiled libs only for armeabi and x86, whne I run it it works well and all my .so are found when needed, when I add rootbeer-lib, to my dependencies, it adds other libs (including arm64) which i don't have .so for, my app starts runing in arm64 and fails to fails to find my lib and therefore craches.

how can I tell rootbeer to only provide .so for architectures I support?

Thank you

Nexus 6p evaluated as rooted

Log as below:

I/OpenGLRenderer: Initialized EGL, version 1.4
I/RootBeer: QLog: <clinit>() [28] - Log class reloaded
V/RootBeer: RootBeer: checkForRWPaths() [289] - /sbin path is mounted with rw permissions!
I/RootBeer: LOOKING FOR BINRARY: /data/local/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /data/local/bin/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /data/local/xbin/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /sbin/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /system/bin/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /system/bin/.ext/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /system/bin/failsafe/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /system/sd/xbin/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /system/usr/we-need-root/su Absent :(
I/RootBeer: LOOKING FOR BINRARY: /system/xbin/su Absent :(
I/Choreographer: Skipped 9851 frames!  The application may be doing too much work on its main thread.
V/RenderScript: 0x7f80a0e000 Launching thread(s), CPUs 8

My Nexus 6p is not rooted.

unable to run the project

I have imported the rootbeer project. But after running this project i am getting below error

Error:error: unable to execute command: program not executable
Error:error: linker command failed with exit code 1 (use -v to see invocation)
Error:org.gradle.internal.UncheckedException: Build command failed.
Error:error: unable to execute command: program not executable
Error:error: linker command failed with exit code 1 (use -v to see invocation)
Error:Build command failed.
Error:error: unable to execute command: program not executable
Error:error: linker command failed with exit code 1 (use -v to see invocation)

can anyone help?

Lock check button once is pressed.

When you press "check" button the test start but that button is still available to be pressed again. If you press again 3 or 4 times, the process is queued and it does the check again and again (the number of times you pressed it).

I suggest to lock check button once is pressed to skip this behavior.

To reproduce the error just open the app and press 5 times the check button, it will perform 5 checks.

Fatal Exception: java.lang.NullPointerException

Fatal Exception: java.lang.NullPointerException
src == null
java.util.Scanner. (Scanner.java:226)
java.util.Scanner. (Scanner.java:210)
com.scottyab.rootbeer.RootBeer.propsReader(RootBeer.java)
com.scottyab.rootbeer.RootBeer.checkForDangerousProps(RootBeer.java)

Error Android NDK: Application targets deprecated ABI(s): armeabi

Hi
I am getting following error after integration of Rootbeer lib in my app
Error:(XX) Android NDK: Application targets deprecated ABI(s): armeabi
Error:(XX) Android NDK: Support for these ABIs will be removed in a future NDK release.

Although app is compiling and running as it is.
What could be the possible solution for this error?

Flavor without native checks

I am using rootbeer in @walleth - there it is not so important that all kinds of root are detected as it is just displayed as a security information to the user (like this: https://twitter.com/wallethapp/status/993808674895343616 ) - it is more important to me that the file is not so big and all devices are able to update (this is now broken with a recent rootbeer update as the amount of included Native platforms was reduced) - unfortunately I just noticed when releasing on play and got the warning. It would be great if there is a flavor in rootbeer that does not contain the native checks - what do you think? The other option I see is to fork the project and remove these checks - but I would prefer to not fork.

ELF built without PIE & Stack Protection

We have a client whose Infosec team have run a vulnerability scanning tool on our app and found that libtool-checker.so from RootBeer is compiled without -pie and -fstack-protector flags.

Is there a reason not to use these flags? If not, could you please add them?

Systemless root detection

When systemless rooted, the su binary location is /su/bin/su. Its path (/su/bin/) should be added to detect the binary using the checkForBinary(...) method.

Nexus 6 evaluated as rooted

I face a problem appearing similar to #13 for a regular Nexus 6 on a non-rooted (and non-tampered-with) Android 6.0.1 system. Specifically, checkForRWPaths() returns true when hitting these variable assignments:

  • line: "none /dev/cpuset cgroup rw,relatime,cpuset,noprefix,release_agent=/sbin/cpuset_release_agent 0 0"
  • pathToCheck: "/sbin"

rootbeercheckforrwpaths

64bit support

Using rootbeer on a 64bit device (Nexus 6P) and I get an exception saying the native library is missing.

I'll look to provide a PR with a fix.

RootBeer is crashed on RIM devices running Android apps.

Used RootBeer library to detect whether an android device was rooted or not. Apparently RIM Blackberry allows android app to run on them and the library crashed on those devices.

Caused by java.lang.NullPointerException
java.util.Scanner. (Scanner.java:226)
java.util.Scanner. (Scanner.java:210)
com.scottyab.rootbeer.RootBeer.mountReader (RootBeer.java:208)
com.scottyab.rootbeer.RootBeer.checkForRWPaths (RootBeer.java:251)
com.scottyab.rootbeer.RootBeer.isRooted (RootBeer.java:41)

Check Ability to mount

Another root check could be to attempt to mount the “/system”
partition with the command mount -o remount,rw /system and check return code.

Crash on root native check

I set rootcloak to hide root things from rootbeer sample app, and then the app crashes at root native check.
Notice: rw paths successfully detected.
OTP Smartbank app (Hungary) uses this root checking library, and it also crashes. Also, if i dont use rootcloak for smartbank, then it will not launch...
I bet the Hungarian OTP team not going to update the library in their app, so can you give me a quick fix how can i bypass the detection in an old version? You know, old versions not supported..
Me and many other users of the app thinks that OTP wants to decide if we want to use root, and it's a bad behavior.

Anyway, here is the log (OTP Smartbank crash when checking for root if rootcloak tries to hide it):
And a video (about the crashing sample app)

Test on the Android P beta

Test root beer on the Android P beta

[] Non-rooted device passed the root test
[] Rooted device fails root test

Proguard rules

Are there any proguard rules? because is not working woth proguard activated
Thanks

Logging cannot be deactivated

I use your library in my Android project. I would like to suggest that there is the possibility to deactivate logging. In QLog the value for Logging Level is hardcoded to "ALL".
Also, the logging message (level INFO) I get is

I/RootBeer: LOOKING FOR BINRARY: /system/bin/su Absent :(

binRary instead of binary.

Encryption support shall be needed for know root packages & su binary paths to avoid cyber security threats

For the below constants, It would be better to keep the encrypted file path strings in the string array
1. knownRootAppsPackages
2. knownDangerousAppsPackages
3. knownRootCloakingPackages
4. suPaths
5. pathsThatShouldNotBeWrtiable

So that we can avoid chances for changing the file path names and breaking the root detection checking by hackers
Use decrypted strings where ever using this file path.

Magisk Hide

I am using rootbeer in my custom application and its not working when Magisk Hide is enabled.

Device is Nexus 6, 6.0, rooted

When Magisk Hide is enabled -> rootBeer.isRooted() and rootBeer.isRootedWithoutBusyBoxCheck() both return false.

When Magisk Hide is disabled --> only then rootbeer detects device is rooted and returns true

False positive: Elephone R9

Just wanted to inform you about another false positive that could be added to the Wiki:

An unrooted Elephone R9 with Android SDK Version 25 (Android 7.1.1) gives the following results

isRooted(): true
isRootedWithoutBusyBoxCheck(): true
canLoadNativeLibrary(): true
checkForNativeLibraryReadAccess(): true
checkForDangerousProps(): true

checkForBusyBoxBinary(): false
checkForMagiskBinary(): false
checkForRootNative(): false
checkForRWPaths(): false
checkForSuBinary(): false
checkSuExists(): false
detectPotentiallyDangerousApps(): false
detectRootCloakingApps(): false
detectRootManagementApps(): false
detectTestKeys(): false

Limit jniLibs to only armeabi-v7a

Hi, I have one app that have compatibility with all devices, but only when there's no native libraries but armeabi-v7a, after adding iroot plugin (that is a wrapper of this one), it creates several other architectures libtool-checker.so files (mips, mips64, x86_64 ...) and this is making my app crash.
Do you know how to limit the plugin so the only generated native library is for armeabi-v7a?
I've been looking through all the code and didn't found where it defines these architectures.
I have already ask the same question here: WuglyakBolgoink/cordova-plugin-iroot#13 (comment)
Thanks.

which binary location

On the 2 phones I tested (running 7.0 and 7.1.1), the which binary was located at /system/bin/which and not /system/xbin/which, which is hardcoded.

Proposed solution: don't hardcode /system/xbin/which

Motorola Moto Z is determined Root wrongly

I have a Moto Z Cell phone for a year. Although it is original but some payment applications which make use of rootbeer indicate my phone as ROOTed and do not let installation on my phone.
One reason is my phone has su command however it is not executable as it is indicated on 'Commands' section of 'Eric Gruber' article .

DexGuard config

Provide some adv DexGuard config to mask the rootcheck method calls and the const.java.

Fatal Exception: java.lang.UnsatisfiedLinkError with proguard

We have theese crashes in our app mobile, with activated proguard

Fatal Exception: java.lang.UnsatisfiedLinkError: No implementation found for int com.scottyab.rootbeer.RootBeerNative.setLogDebugMessages(boolean) (tried Java_com_scottyab_rootbeer_RootBeerNative_setLogDebugMessages and Java_com_scottyab_rootbeer_RootBeerNative_setLogDebugMessages__Z) at com.scottyab.rootbeer.RootBeerNative.setLogDebugMessages(RootBeerNative.java) at com.scottyab.rootbeer.RootBeer.checkForRootNative(RootBeer.java:373) at com.scottyab.rootbeer.RootBeer.isRooted(RootBeer.java:45) at LoginActivity.onCreate(LoginActivity.java:136) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

Xiaomi series evaluated as rooted

I ran the 'RootBeer Sample' app downloaded by google play on some xiaomi devices. and I found a problem that the devices are evaluated as rooted.

Xiaomi Mi max2 - busybox binary
Hongmi(Redmi) Note3 Pro - busybox binary, dangerous props
Xiaomi Mi Note - busybox binary, su binary, root native

Xiaomi Mi A1 - not rooted
Huawei honor 6x - not rooted

I'm not sure whether the devices are actually rooted or not. But as far as I know the devices are not rooted because I got the devices from where some kind of public institutions.

Is that issues for xiaomi devices? Or is that rooted actually?
How can I deal with it?

UnsatisfiedLinkError

Time to time I receive crash reported in Fabric that library crashed.

Fatal Exception: java.lang.UnsatisfiedLinkError: Couldn't load tool-checker from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.myapp.example-2.apk,libraryPath=/data/app-lib/com.myapp.example-2]: findLibrary returned null

   at java.lang.Runtime.loadLibrary(Runtime.java:355)
   at java.lang.System.loadLibrary(System.java:525)
   at com.scottyab.rootbeer.RootBeerNative.(SourceFile)
   at com.scottyab.rootbeer.RootBeer.checkForRootNative(SourceFile:305)
   at com.myapp.example.entity.DeviceConfig.com.scottyab.rootbeer.RootBeer.isRooted(SourceFile:2044)
   at com.myapp.example.entity.DeviceConfig.parseJson(SourceFile:359)
   at com.myapp.example.net.request.Request.prepareRequest(SourceFile:2197)
   at com.myapp.example.net.request.Request.execute(SourceFile:129)
   at com.myapp.example.service.AppStartService.onStartCommand(SourceFile:65)
   at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2833)
   at android.app.ActivityThread.access$2000(ActivityThread.java:159)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1419)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:176)
   at android.app.ActivityThread.main(ActivityThread.java:5419)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:525)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
   at dalvik.system.NativeStart.main(NativeStart.java)

Devices and values provided by Fabric:
ASUS_T00J 4.4.2 No rooted
K6000 Pro 6.0 No rooted
GT-I9300 4.3 No rooted
B1-810 4.4.4 No rooted
P400 4.1.2 Rooted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.