Skip to content

Commit

Permalink
change private functions to internal. annotate publishedApi. inline e…
Browse files Browse the repository at this point in the history
…vade function. (#11)
  • Loading branch information
evilthreads669966 authored Oct 8, 2020
1 parent fad9587 commit f0d1cc1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ allprojects {
2. Add the dependency to your app's build.gradle file
```gradle
dependencies {
implementation 'com.github.evilthreads669966:evademe:1.0'
implementation 'com.github.evilthreads669966:evademe:1.1'
}
```
3. Use the evade ktx function inside of any android context.
Expand Down
23 changes: 15 additions & 8 deletions evade/src/main/java/com/evilthreads/evade/Evade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ check multiple conditions regarding whether it is safe in regards to cyber secur
your payload please pass false as the argument as true is the default value. This will also return a callback for onEscape meaning it was not executed.
Which immediately after you can register for a callback named onSuccess.*/
//If we wanted to make this better we could check the state of the sim card(s) allowing us to evade device's without a sim card. However this will cause us to use a dangerous permission called READ_PHONE_STATE
fun Context.evade(requiresNetwork: Boolean = true, payload: () -> Unit): OnEvade.Escape{
inline fun Context.evade(requiresNetwork: Boolean = true, payload: () -> Unit): OnEvade.Escape{
if(!isEmulator && !isRooted() && !hasAdbOverWifi() && !isConnected()){
if(hasUsbDevices())
return OnEvade.Escape(false)
Expand All @@ -93,10 +93,12 @@ fun Context.evade(requiresNetwork: Boolean = true, payload: () -> Unit): OnEvade

/*Checks whether this phone is connected to a usb device such as a computer. I do not know whether this works but I believe it won't hurt to check*/
@RequiresApi(Build.VERSION_CODES.HONEYCOMB_MR1)
private fun Context.hasUsbDevices() = (this.getSystemService(Context.USB_SERVICE) as UsbManager).deviceList.isNotEmpty()
@PublishedApi
internal fun Context.hasUsbDevices() = (this.getSystemService(Context.USB_SERVICE) as UsbManager).deviceList.isNotEmpty()

/*Checks whether the app is running on a fake device*/
private val isEmulator = (Build.DEVICE.contains("generic")
@PublishedApi
internal val isEmulator = (Build.DEVICE.contains("generic")
|| Build.FINGERPRINT.contains("generic")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
Expand All @@ -117,7 +119,8 @@ private val isEmulator = (Build.DEVICE.contains("generic")
|| Build.PRODUCT.contains("simulator"))

/*checks whether the device has a firewall or networking utilities app installed.*/
private fun Context.hasFirewall(): Boolean {
@PublishedApi
internal fun Context.hasFirewall(): Boolean {
lateinit var packages: List<PackageInfo>
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
packages = this.packageManager.getInstalledPackages(PackageManager.MATCH_UNINSTALLED_PACKAGES)
Expand All @@ -135,7 +138,8 @@ private fun Context.hasFirewall(): Boolean {
}

/*Checks whether the device is listening to port 5555. This port is used to connect to a computer through wifi on a local network for ADB debugging*/
private fun Context.hasAdbOverWifi(): Boolean{
@PublishedApi
internal fun Context.hasAdbOverWifi(): Boolean{
var isOpen = false
val mgr = this.getSystemService(Context.WIFI_SERVICE) as WifiManager
if(!mgr.isWifiEnabled)
Expand All @@ -160,7 +164,8 @@ private fun Context.hasAdbOverWifi(): Boolean{

/*checks whether the network is running through a VPN*/
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private fun Context.hasVPN(): Boolean{
@PublishedApi
internal fun Context.hasVPN(): Boolean{
val mgr = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
mgr.allNetworks.forEach {network ->
val capabilities = mgr.getNetworkCapabilities(network)
Expand All @@ -171,10 +176,12 @@ private fun Context.hasVPN(): Boolean{
}

/*checks whether the device has super user powers SU*/
private fun Context.isRooted() = RootBeer(this).apply { setLogging(false) }.isRooted
@PublishedApi
internal fun Context.isRooted() = RootBeer(this).apply { setLogging(false) }.isRooted

/*checks whether there is a usb cord plugged into the phone*/
private fun Context.isConnected(): Boolean {
@PublishedApi
internal fun Context.isConnected(): Boolean {
val intent = this.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
val plugged = intent!!.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
Expand Down

0 comments on commit f0d1cc1

Please sign in to comment.