Giter Site home page Giter Site logo

gantman / jail-monkey Goto Github PK

View Code? Open in Web Editor NEW
548.0 9.0 141.0 1.39 MB

A React Native library for identifying if a phone is rooted or mocking locations

License: MIT License

Objective-C 32.73% JavaScript 4.72% Java 42.31% Ruby 6.16% TypeScript 6.51% Kotlin 5.77% Objective-C++ 1.81%
react react-native android trust mock-locations jailbreak

jail-monkey's Introduction

WARNING: I don't have the devices to test anymore, so testing is done by those submitting PRs bona fide.

Jail Monkey

Version Downloads

Can you ever really trust a phone?

Why?

Are users claiming they are crossing the globe in seconds and collecting all the Pokeballs? Some apps need to protect themselves in order to protect data integrity. JailMonkey allows you to:

  • Identify if a phone has been jail-broken or rooted for iOS/Android.
  • Detect mocked locations for phones set in "developer mode".
  • (ANDROID ONLY) Detect if the application is running on external storage such as an SD card.

Use

import JailMonkey from 'jail-monkey'

if (JailMonkey.isJailBroken()) {
  // Alternative behaviour for jail-broken/rooted devices.
}

Circle of Trust

API

Method Returns Description
isJailBroken boolean is this device jail-broken/rooted.
canMockLocation boolean Can this device fake its GPS location.
trustFall boolean Checks if the device violates either isJailBroken or canMockLocation.
isDebuggedMode Promise<boolean> Is the application is running in debug mode. Note that this method returns a Promise.

iOS Only APIs

Method Returns Description
jailBrokenMessage string Returns the reason for jailbroken detection. Will return an empty string on Android.

Android Only APIs

Method Returns Description
hookDetected boolean Detects if there is any suspicious installed applications.
isOnExternalStorage boolean Is the application running on external storage (ie. SD Card)
AdbEnabled boolean Is Android Debug Bridge enabled.
isDevelopmentSettingsMode Promise<boolean> Whether user has enabled development settings on their device. Note that this method returns a Promise.
androidRootedDetectionMethods RootedDetectionMethods Returns an object with the results of all the Android rooted detection methods for more granular detection, this can be helpful if some devices are giving false positives.
type RootedDetectionMethods = {
  rootBeer: {
    detectRootManagementApps: boolean;
    detectPotentiallyDangerousApps: boolean;
    checkForSuBinary: boolean;
    checkForDangerousProps: boolean;
    checkForRWPaths: boolean;
    detectTestKeys: boolean;
    checkSuExists: boolean;
    checkForRootNative: boolean;
    checkForMagiskBinary: boolean;
  },
  jailMonkey: boolean;
}

On iOS all of the Android only methods will return false or Promise<false> where appropriate.

❗ Since emulators are usually rooted, you might want to bypass these checks during development. Unless you're keen on constant false alarms ⏰

Install

npm i jail-monkey --save
react-native link # Not required as of React Native 0.60.0

for iOS:

cd ios && pod install

If you use rnpm, you may have trouble as rnpm does not link Android properly after 0.29.0!

Note: On Android you should include location.isFromMockProvider() from your location provider to compliment JailMonkey.canMockLocation(). Most react-native location libraries already have this check built in

Additional Info

This has been made public to help keep it up to date. As detection measures get better or out-dated, please send updates to this project so it can be the best method of detection.

Special thanks to this fantastic blog article: http://blog.geomoby.com/2015/01/25/how-to-avoid-getting-your-location-based-app-spoofed/

jail-monkey's People

Contributors

adamivancza avatar alarm109 avatar almouro avatar andreicalazans avatar aprct avatar brockdub avatar buschco avatar crafterm avatar danthonypabon avatar dependabot[bot] avatar droidking18 avatar el173 avatar ermankuruoglu avatar fauzzi avatar gabimoncha avatar gantman avatar geraintwhite avatar gustavjf avatar kelokchan avatar lefloh avatar levibuzolic avatar mateosilguero avatar modevby avatar nicholaszankichsmarkets avatar nityanantan23 avatar sankar4n avatar serdargun avatar sonicdoe avatar tangten avatar tommeier 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

jail-monkey's Issues

Support React Native 0.64

Hey

React native has dropped support for droid 16 - 20
Do you think we can also drop support for lower versions too, our build is failing because of this.

app:mergeExtDexReleaseAndroidTest/Users/runner/work/1/s/node_modules/jail-monkey/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger8223413790448825511.xml:5:5-74 Error:
	uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.64.0] /Users/runner/.gradle/caches/transforms-2/files-2.1/21044a2fdd820610eefdcb25ac985803/jetified-react-native-0.64.0/AndroidManifest.xml as the library might be using APIs not available in 19
	Suggestion: use a compatible library with a minSdk of at most 19,
		or increase this project's minSdk version to at least 21,
		or use tools:overrideLibrary="com.facebook.react" to force usage (may lead to runtime failures)

https://reactnative.dev/blog/2021/03/12/version-0.64

Dropped Android API levels 16-20. 

The Facebook app consistently drops support for Android versions with sufficiently low usage. As the Facebook app no longer supports these versions and is React Native’s main testing surface, React Native is dropping support as well.

Jail-Monkey returns true all the time in android- after expo eject

I am running my jailmonkey, jailbroken check. It always returns true. But works fine in ios...issue only on android. kindly suggest me some fix.
const jail =JailMonkey.isJailBroken();

NOTE:- I have converted my expo app into react-native-cli... did expo eject

jail == true /// always..

Android false positive caused by checking for presence of `test-keys` build tag

I've come across another false positive related to the root detection method that checks for the presence of 'test-keys' here.

I've tested this on a fresh out-of-the-box Vernee Thor running Android 7.0 by logging the boolean results of each of the three methods. Only method 1 returned true. The rest returned false. I checked the result of android.os.Build.TAGS and it returns 'test-keys'. Running cat /system/build.prop | grep ro.build.tags via adb shell returns the same.

I tried running su via adb shell but the binary is not installed so my assumption is this device is not rooted.

Apparently in this case, the 'test-keys' build tag doesn't necessarily mean the device is rooted but rather the OS image was not appropriately signed. Here and here is some more info on that.

@GantMan Should this root detection method be used if it doesn't necessarily indicate a rooted device? I'm unsure, since this library also uses the test-keys method.

False alarm on brand new Samsung Galaxy Note10+

Hi

We have gotten a bug report from one of our customers. He has just bought a brand new phone straight from the electronics store (he peeled plastic of himself). When he installed our app that uses this package, he got the error that his phone is rooted, even though it's not.

I have these images of software versions on the phone (sorry about the glare):
image
image

How do I use JailMonkey.canMockLocation() ?

How do I use JailMonkey.canMockLocation() ?
Does it support RN 0.30 ?

I got undefined is not an object (evaluating 'this.props.navigator') error

Here's my code

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import JailMonkey from 'jail-monkey';

class RNmonkey extends Component {

  componentWillMount(){
   JailMonkey.canMockLocation();
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.android.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

module.exports = RNmonkey;

TypeError: null is not an object (evaluating 'JailMonkey.isDevelopmentSettingsMode')] on ANDROID

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'JailMonkey.isDevelopmentSettingsMode')]
at node_modules/jail-monkey/jailmonkey.js:16:8 in isDevelopmentSettingsMode
at src/screens/Home/HomeScreen.js:66:26 in
at src/screens/Home/HomeScreen.js:65:9 in
at src/screens/Home/HomeScreen.js:65:8 in useEffect$argument_0
at node_modules/@react-navigation/core/src/useSyncState.tsx:39:22 in React.useCallback$argument_0
at node_modules/@react-navigation/core/src/useNavigationBuilder.tsx:309:21 in React.useCallback$argument_0
at node_modules/@react-navigation/core/src/useOnAction.tsx:105:20 in React.useCallback$argument_0
at node_modules/@react-navigation/core/src/useNavigationHelpers.tsx:43:30 in dispatch
at node_modules/@react-navigation/core/src/useNavigationCache.tsx:91:10 in dispatch
at node_modules/@react-navigation/core/src/useNavigationCache.tsx:122:22 in withStack$argument_0
at node_modules/@react-navigation/core/src/useNavigationCache.tsx:109:18 in withStack
at node_modules/@react-navigation/core/src/useNavigationCache.tsx:120:21 in acc.name
at src/screens/Preload/PreloadScreen.js:21:19 in checkLogin

I already did manual link, import, add the package, but nothing works

False alarm on Samsung S8 and A7

I get a false alarm that the device has been rooted when it has not been rooted..

I feel like this might be a Samsung related issue since the is another issue related to this that has not been solved.
#58

Any help would be appreciated, I will give you an electronic 🍫 .. (Which you can copy paste to make as many as you would like.. hehe)

❤️

Xcode build error

I already linked the library. When I build in xcode got this error

ld: warning: directory not found for option '-L/Users/user/Library/Developer/Xcode/DerivedData/project-name/Build/Products/Debug-iphonesimulator/React'

duplicate symbol OBJC_CLASS$_JailMonkey in:
/Users/user/Library/Developer/Xcode/DerivedData/project-name/Build/Products/Debug-iphonesimulator/jail-monkey/libjail-monkey.a(JailMonkey.o)
/Users/user/Library/Developer/Xcode/DerivedData/project-name/Build/Products/Debug-iphonesimulator/libJailMonkey.a(JailMonkey.o)

duplicate symbol OBJC_METACLASS$_JailMonkey in:
/Users/user/Library/Developer/Xcode/DerivedData/project-name/Build/Products/Debug-iphonesimulator/jail-monkey/libjail-monkey.a(JailMonkey.o)
/Users/user/Library/Developer/Xcode/DerivedData/project-name/Build/Products/Debug-iphonesimulator/libJailMonkey.a(JailMonkey.o)

ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Lint error

After use

./gradlew build

Error display

> Lint found errors in the project; aborting build.
  
  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...
  Errors found:
  
***/node_modules/jail-monkey/android/src/main/java/com/gantix/JailMonkey/MockLocation/MockLocationCheck.java:47: Error: The logging tag can be at most 23 characters, was 26 (Mock location check error ) [LongLogTag]
                          Log.e("Mock location check error ", e.getMessage());

Error: Exception in HostObject::get(propName:JailMonkey): java.lang.NullPointerException

jail-monkey version: 2.3.2
RN: 0.61.5

Setup:
android/app/build.gradle:

dependencies {
   ....
   ....
   ....
    implementation project(':jail-monkey')
    implementation project(':react-native-branch')
   ....

settings.build.gradle

include ':jail-monkey'
project(':jail-monkey').projectDir = new File(rootProject.projectDir, '../node_modules/jail-monkey/android')

I am getting this error in some of the android devices (Samsung note 20 Ultra):

com.facebook.react.common.JavascriptException: Error: Exception in HostObject::get(propName:JailMonkey): java.lang.NullPointerException, stack:
<unknown>@1788:122
v@2:1474
<unknown>@1785:349
v@2:1474
<unknown>@386:200
v@2:1474
<unknown>@6:58
v@2:1474
d@2:876
global code@3823:4

at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java
  at java.lang.reflect.Method.invoke (Method.java)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:371)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:150)
  at com.facebook.react.bridge.queue.NativeRunnable.run (NativeRunnable.java)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:26)
  at android.os.Looper.loop (Looper.java:246)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:225)
  at java.lang.Thread.run (Thread.java:923)

Can you please help on what might be wrong here?

Jail Monkey

React Native 0.60.3 JailMonkey.isJailBroken() returns null and not working.

Add an open source license?

Thanks for sharing this project! We'd love to use it as part of the Mattermost open source project (https://www.mattermost.org/) in our React Native mobile app (which users an Apache 2.0 license).

Would you consider adding either an MIT or an Apache 2.0 license?

To do so, in GitHub you can hit "Create new file" and name a file LICENSE.txt

image

This will prompt GitHub to offer a license template:

image

If you use either an MIT license or an Apache 2.0 license it would make it easy to add your work to other open source projects, and we'd love to include your work in ours.

Thanks kindly for your consideration.

Not working in iOS simulator

Hi,

I am using react-native 0.59. I have installed as per the documentation. But when i tried to run this i am getting the following error : Cannot read property 'canMockLocation' of undefined.

Where as when I print JailMonkey i got following.:
{isJailBroken: ƒ, hookDetected: ƒ, canMockLocation: ƒ, trustFall: ƒ, isOnExternalStorage: ƒ, …}
AdbEnabled: ƒ AdbEnabled()
canMockLocation: ƒ canMockLocation()
hookDetected: ƒ hookDetected()
isDebuggedMode: ƒ isDebuggedMode()
isDevelopmentSettingsMode: ƒ isDevelopmentSettingsMode()
isJailBroken: ƒ isJailBroken()
isOnExternalStorage: ƒ isOnExternalStorage()
trustFall: ƒ trustFall()
proto: Object

False alarm on samsung s10 and iphone 6s

Hello,
I get a false alarm that the device has been rooted when it has not been rooted or jail-broken, using isJailBroken only.
Any help would be appreciated,
Thanks.

Jump to version 0.2.1

Hello,
After the PR that you merged yesterday #23 , could you kindly jump to a new version and publish it into NPM environment?

Thanks

Bypass Jailbreak using Liberty Lite

Hi,

I want to ask, can this lib be bypassed using Liberty Lite?
I want to make sure that jail-monkey prevents bypass from any tools, including Liberty Lite.

Thank you.

app crashed on onePlus A3010

Fatal Exception: com.facebook.react.common.JavascriptException: Java exception in 'NativeModules'

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference, stack:
com.gantix.JailMonkey.JailMonkeyModule.isMockLocationOn@127
com.gantix.JailMonkey.JailMonkeyModule.getConstants@36
com.facebook.react.bridge.JavaModuleWrapper.getConstants@138
android.os.Handler.handleCallback@789
android.os.Handler.dispatchMessage@98
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage@29

Not accurate

Hi,
My users say that their device are not rooted but they still got blocked on app because jail-monkey see them as rooted. Is there a bug?

Behaviour on Android emulator

Hi, I just found ur lib, great use case scenario btw!
Just a quick check since I think it's better to ask the maker than trying to find jailbroken/rooted phones lol
I got this when running on Android emulator:

jailbreak: true
mock: false
both: false

Is this actual false alarm from the lib or is it expected to behave that way since emulator is considered a rooted device?
Also, does canMockLocation() module refer to the potential of having mock location or does it mean apps like fakeGPS is CURRENTLY active on the phone?

Thanks in advance! 😄

Repo is out of sync with npm

Can you please increase the version and publish this to npm, as the current package i am getting is 9 month old.

[iOS] Build Failed

Hey,

I'm getting a "Build Failed" when trying to run this on a simulator after I link the libJailMonkey.a library to the build target in XCode.

It doesn't give me an error message or anything. It just tells me that the build has failed. Any ideas?

Cannot read property 'isJailBroken' of null in Android

JailMonkey works fine in IOS but when I run it with an android emulator I always get this error.

Also when I use other API such as isDebuggedMode(), trustFall(), etc... I always get the same error:

Cannot read property 'isDebuggedMode' of null etc.

Screen Shot 2021-02-05 at 11 18 23 AM

iOS mock location detection not accurate

After reading the part in source for iOS I realized the mock location detection is equal to jailbreak detection:

JMCanMockLocationKey: @(self.isJailBroken)

However it's possible for an user to mock location while stays jailed, I found a discussion here about possible detection mechanisms for those who are interested.

Android build fails

Integrated jail-monkey for react native application but getting following error while running the app

`Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:jail-monkey] C:\newApp\node_modules\jail-monkey\android\build\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="com.gantix.JailMonkey" to force usage (may lead to runtime failures)`

package.json
"dependencies": { "jail-monkey": "^2.2.0", "react-native": "0.62.2", }

android/build.gradle
ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 }

Android False Positives

I've just installed and linked the library and called JailMonkey.isJailBroken() in componentDidMount() of my top-level component. I got three false positives on separate physical devices:

  • Android 6.0.1 (rooted once, now no longer rooted)
  • Android 7.0 (never rooted)
  • Android O (never rooted)

Does this library not yet support 6.X and above?

Create and publish a release

I noticed the last release was made a while ago (05/04). And since then, many fixes were merged, in particular, #46 and #49 which solve some building problems for Android.

Would it be possible to create and publish a new release? Is there a procedure or a schedule this project follows?

Android mock location detection

I've tested on 2 devices. Samsung Galaxy S9(Android 9), Xiaomi MI-4c (Android 6), canMockLocation always returns false

 "react-native": "0.55.4",
 "jail-monkey": "^2.2.0",

Execution failed for task ':jail-monkey:verifyReleaseResources'.

Hi,
I have this problem when i try to create one apk release with the jaik-monkey library.
After using:

cd android && ./gradlew assembleRelease

This exceptions appear:

* What went wrong:
Execution failed for task ':jail-monkey:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

package.json

 "jail-monkey": "^1.0.0",
"react-native": "0.57.1"

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.