Skip to content

Commit

Permalink
feat: add ADB detection (#49)
Browse files Browse the repository at this point in the history
* feat(Android): add ADB detection

* feat(ts): add ADB detection

* feat(example): add ADB detection

* release: freeRASP 7.1.0
  • Loading branch information
tompsota authored Nov 20, 2024
1 parent 01a861d commit 8621a60
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 8 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.1.0] - 2024-11-19

### Cordova

#### Added

- Added `adbEnabled` callback, which allows you to detect USB debugging option enabled in the developer settings on the device

### Android

#### Added

- ADB detection feature

## [7.0.1] - 2024-11-18

- Android SDK version: 12.0.0
Expand Down
2 changes: 1 addition & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions example/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export class AppComponent implements OnInit {

config = {
androidConfig: {
packageName: 'com.cordova.example',
packageName: 'io.ionic.starter',
certificateHashes: ['AKoRuyLMM91E7lX/Zqp3u4jMmd0A7hH/Iqozu0TMVd0='],
malwareConfig: {
blacklistedHashes: ['FgvSehLMM91E7lX/Zqp3u4jMmd0A7hH/Iqozu0TMVd0u'],
blacklistedPackageNames: ['com.wultra.app.screenlogger'],
blacklistedPackageNames: ['io.ionic.starter'],
suspiciousPermissions: [
[
'android.permission.INTERNET',
Expand All @@ -36,7 +36,7 @@ export class AppComponent implements OnInit {
},
},
iosConfig: {
appBundleIds: 'com.cordova.example',
appBundleIds: 'io.ionic.starter',
appTeamId: 'your_team_ID',
},
watcherMail: 'your_email_address@example.com',
Expand Down Expand Up @@ -89,6 +89,7 @@ export class AppComponent implements OnInit {
this.updateMalware(detectedApps);
this.updateAppChecks('Malware');
},
adbEnabled: () => this.updateAppChecks('ADB Enabled'),
};

async addItemsToMalwareWhitelist() {
Expand Down
1 change: 1 addition & 0 deletions example/src/app/utils/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const androidChecks = [
{ name: 'Obfuscation Issues', isSecure: true },
{ name: 'Developer Mode', isSecure: true },
{ name: 'Malware', isSecure: true },
{ name: 'ADB Enabled', isSecure: true },
];
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-talsec-plugin-freerasp",
"version": "7.0.1",
"version": "7.1.0",
"description": "Cordova plugin for improving app security and threat monitoring on Android and iOS mobile devices.",
"cordova": {
"id": "cordova-talsec-plugin-freerasp",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-talsec-plugin-freerasp"
version="7.0.1">
version="7.1.0">

<name>freerasp</name>
<author>Talsec (info@talsec.app)</author>
Expand Down
4 changes: 4 additions & 0 deletions src/android/TalsecThreatHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ internal object TalsecThreatHandler : ThreatListener.ThreatDetected, ThreatListe
listener?.threatDetected(Threat.DevMode)
}

override fun onADBEnabledDetected() {
listener?.threatDetected(Threat.ADBEnabled)
}

override fun onSystemVPNDetected() {
listener?.threatDetected(Threat.SystemVPN)
}
Expand Down
4 changes: 3 additions & 1 deletion src/android/Threat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal sealed class Threat(val value: Int) {
object SystemVPN : Threat((10000..999999999).random())
object DevMode : Threat((10000..999999999).random())
object Malware : Threat((10000..999999999).random())
object ADBEnabled : Threat((10000..999999999).random())

companion object {
internal fun getThreatValues(): JSONArray {
Expand All @@ -40,7 +41,8 @@ internal sealed class Threat(val value: Int) {
UnofficialStore.value,
ObfuscationIssues.value,
DevMode.value,
Malware.value
Malware.value,
ADBEnabled.value
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/android/talsec.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repositories {
}

dependencies {
implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-Cordova:12.0.0"
implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-Cordova:13.0.0"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
}

Expand Down
1 change: 1 addition & 0 deletions www/talsec.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type NativeEventEmitterActions = {
devMode?: () => any;
systemVPN?: () => any;
malware?: (suspiciousApps: SuspiciousAppInfo[]) => any;
adbEnabled?: () => any;
};
export type TalsecConfig = {
androidConfig?: TalsecAndroidConfig;
Expand Down
5 changes: 5 additions & 0 deletions www/talsec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Threat {
static ObfuscationIssues = new Threat(0);
static DevMode = new Threat(0);
static Malware = new Threat(0);
static ADBEnabled = new Threat(0);
constructor(value) {
this.value = value;
}
Expand All @@ -34,6 +35,7 @@ class Threat {
this.ObfuscationIssues,
this.DevMode,
this.Malware,
this.ADBEnabled,
]
: [
this.AppIntegrity,
Expand Down Expand Up @@ -169,6 +171,9 @@ const start = async (config, eventListenerConfig) => {
case Threat.Malware.value:
eventListenerConfig.malware?.(parseMalwareData(event[malwareKey]));
break;
case Threat.ADBEnabled.value:
eventListenerConfig.adbEnabled?.();
break;
default:
onInvalidCallback();
break;
Expand Down
6 changes: 6 additions & 0 deletions www/talsec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type NativeEventEmitterActions = {
devMode?: () => any;
systemVPN?: () => any;
malware?: (suspiciousApps: SuspiciousAppInfo[]) => any;
adbEnabled?: () => any;
};

export type TalsecConfig = {
Expand Down Expand Up @@ -82,6 +83,7 @@ class Threat {
static ObfuscationIssues = new Threat(0);
static DevMode = new Threat(0);
static Malware = new Threat(0);
static ADBEnabled = new Threat(0);

constructor(value: number) {
this.value = value;
Expand All @@ -103,6 +105,7 @@ class Threat {
this.ObfuscationIssues,
this.DevMode,
this.Malware,
this.ADBEnabled,
]
: [
this.AppIntegrity,
Expand Down Expand Up @@ -251,6 +254,9 @@ const start = async (
case Threat.Malware.value:
eventListenerConfig.malware?.(parseMalwareData(event[malwareKey]));
break;
case Threat.ADBEnabled.value:
eventListenerConfig.adbEnabled?.();
break;
default:
onInvalidCallback();
break;
Expand Down

0 comments on commit 8621a60

Please sign in to comment.