-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathController.java
More file actions
164 lines (132 loc) · 4.55 KB
/
Controller.java
File metadata and controls
164 lines (132 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package com.talsec.free.rasp;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.widget.Toast;
import android.os.Handler;
import android.os.Looper;
import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo;
import com.aheaditec.talsec_security.security.api.Talsec;
import com.aheaditec.talsec_security.security.api.TalsecConfig;
import com.aheaditec.talsec_security.security.api.TalsecMode;
import com.aheaditec.talsec_security.security.api.ThreatListener;
import java.util.List;
public class Controller implements ThreatListener.ThreatDetected, ThreatListener.DeviceState {
private static final String TAG = Controller.class.getSimpleName();
// Native method declaration - implemented in C++
// this is used for threat detection
private static native void threatDetected(String message);
// Native method declaration - implemented in C++
// this is used for notifying the native code that the RASP execution has finished
private static native void raspExecutionFinished();
public static class AppRaspExecutionState extends ThreatListener.RaspExecutionState {
@Override
public void onAllChecksFinished() {
raspExecutionFinished();
}
}
private boolean talSecInitialized;
private AppRaspExecutionState appRaspExecutionState;
public Controller() {
talSecInitialized = false;
appRaspExecutionState = new AppRaspExecutionState();
}
public void initializeTalsec(Context context, String packageName,
String [] signingCertificateBase64Hash,
String [] supportedAlternativeStores,
String watcherEmailAddress, boolean isProd) {
if(!talSecInitialized) {
TalsecConfig config = new TalsecConfig.Builder(packageName,
signingCertificateBase64Hash)
.supportedAlternativeStores(supportedAlternativeStores)
.watcherMail(watcherEmailAddress)
.prod(isProd)
.build();
ThreatListener threatListener = new ThreatListener(this, this, appRaspExecutionState);
threatListener.registerListener(context);
Talsec.start(context, config, TalsecMode.BACKGROUND);
talSecInitialized = true;
}
}
@Override
public void onRootDetected() {
threatDetected("onPrivilegedAccess");
}
@Override
public void onTamperDetected() {
threatDetected("onAppIntegrity");
}
@Override
public void onMalwareDetected(List<SuspiciousAppInfo> list) {
// not implemented yet
}
@Override
public void onDebuggerDetected() {
threatDetected("onDebug");
}
@Override
public void onEmulatorDetected() {
threatDetected("onSimulator");
}
@Override
public void onUntrustedInstallationSourceDetected() {
threatDetected("onUnofficialStore");
}
@Override
public void onHookDetected() {
threatDetected("onHooks");
}
@Override
public void onDeviceBindingDetected() {
threatDetected("onDeviceBinding");
}
@Override
public void onObfuscationIssuesDetected() {
threatDetected("onObfuscationIssues");
}
@Override
public void onScreenshotDetected() {
threatDetected("onScreenshot");
}
@Override
public void onScreenRecordingDetected() {
threatDetected("onScreenRecording");
}
@Override
public void onUnlockedDeviceDetected() {
threatDetected("onPasscode");
}
@Override
public void onHardwareBackedKeystoreNotAvailableDetected() {
threatDetected("onSecureHardwareNotAvailable");
}
@Override
public void onDeveloperModeDetected() {
threatDetected("onDevMode");
}
@Override
public void onADBEnabledDetected() {
threatDetected("onADBEnabled");
}
@Override
public void onSystemVPNDetected() {
threatDetected("onSystemVPN");
}
@Override
public void onMultiInstanceDetected() {
threatDetected("onMultiInstance");
}
@Override
public void onUnsecureWifiDetected() {
threatDetected("onUnsecureWifi");
}
@Override
public void onTimeSpoofingDetected() {
threatDetected("onTimeSpoofing");
}
@Override
public void onLocationSpoofingDetected() {
threatDetected("onLocationSpoofing");
}
}