@leejungkiin/awkit 1.0.1 → 1.0.3
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/README.md +3 -3
- package/VERSION +1 -1
- package/bin/awk.js +1 -1
- package/core/GEMINI.md +54 -25
- package/package.json +2 -2
- package/skills/beads-manager/SKILL.md +298 -181
- package/skills/smali-to-kotlin/SKILL.md +521 -0
- package/skills/smali-to-kotlin/library-patterns.md +189 -0
- package/skills/smali-to-kotlin/smali-reading-guide.md +310 -0
- package/skills/smali-to-swift/SKILL.md +749 -0
- package/skills/smali-to-swift/framework-patterns.md +189 -0
- package/skills/smali-to-swift/objc-reading-guide.md +388 -0
- package/workflows/expert/codeExpert.md +25 -10
- package/workflows/expert/planExpert.md +37 -14
- package/workflows/lifecycle/plan.md +13 -9
- package/workflows/mobile/reverse-android-build.md +232 -0
- package/workflows/mobile/reverse-android-scan.md +158 -0
- package/workflows/mobile/reverse-android.md +106 -0
- package/workflows/mobile/reverse-ios-build.md +248 -0
- package/workflows/mobile/reverse-ios-scan.md +155 -0
- package/workflows/mobile/reverse-ios.md +114 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: smali-to-kotlin
|
|
3
|
+
description: >-
|
|
4
|
+
Android Reverse Engineering specialist. Reads Apktool output (Smali, resources, manifest)
|
|
5
|
+
and rebuilds the app from scratch using modern Kotlin + Jetpack Compose + Clean Architecture.
|
|
6
|
+
Includes library detection to reuse existing dependencies.
|
|
7
|
+
author: Antigravity Team
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
trigger: conditional
|
|
10
|
+
activation_keywords:
|
|
11
|
+
- "/reverse-android"
|
|
12
|
+
- "smali"
|
|
13
|
+
- "apktool"
|
|
14
|
+
- "reverse engineer"
|
|
15
|
+
- "dịch ngược"
|
|
16
|
+
- "tái tạo apk"
|
|
17
|
+
- "rebuild apk"
|
|
18
|
+
- "smali to kotlin"
|
|
19
|
+
priority: high
|
|
20
|
+
platform: android
|
|
21
|
+
extensible_to:
|
|
22
|
+
- ios (separate skill: smali-to-swift — planned)
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# 🔧 Smali-to-Kotlin Skill
|
|
26
|
+
|
|
27
|
+
> **Purpose:** Transform decompiled Android APK (Apktool output) into a modern Kotlin app with Jetpack Compose, Clean Architecture, and MVVM.
|
|
28
|
+
> **Philosophy:** "Read Smali to understand WHAT and WHY → Write Kotlin for HOW."
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ⚠️ SCOPE CLARITY
|
|
33
|
+
|
|
34
|
+
| This skill DOES | This skill DOES NOT |
|
|
35
|
+
|-----------------|---------------------|
|
|
36
|
+
| Read & analyze Smali/Java decompiled code | Write Smali code |
|
|
37
|
+
| Rebuild logic in modern Kotlin | Modify original APK |
|
|
38
|
+
| Detect & reuse third-party libraries | Crack/bypass security |
|
|
39
|
+
| Extract only needed resources (on-demand) | Mass-copy resources blindly |
|
|
40
|
+
| Set up Clean Architecture project structure | Handle iOS reverse engineering |
|
|
41
|
+
| Scan APK libraries for package reuse | Deploy to Play Store |
|
|
42
|
+
|
|
43
|
+
→ For iOS reverse engineering → future skill: `smali-to-swift`
|
|
44
|
+
→ After rebuild complete → use `/test` or `/deploy` workflows
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🎯 ROLE DEFINITION
|
|
49
|
+
|
|
50
|
+
When this skill is active, the agent becomes:
|
|
51
|
+
|
|
52
|
+
> **Expert Android Reverse Engineer & Kotlin Architect**
|
|
53
|
+
> - Master at reading Smali bytecode and obfuscated Java
|
|
54
|
+
> - Fluent in Clean Architecture + MVVM + Jetpack Compose
|
|
55
|
+
> - Knows when to reuse vs rewrite third-party dependencies
|
|
56
|
+
> - Enforces resource-on-demand principle (zero bloat)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🏗️ MODERN TECH STACK (Mandatory)
|
|
61
|
+
|
|
62
|
+
### Core
|
|
63
|
+
| Layer | Technology | Replaces |
|
|
64
|
+
|-------|-----------|----------|
|
|
65
|
+
| **UI** | Jetpack Compose + Material 3 | XML Layouts + findViewById |
|
|
66
|
+
| **State** | StateFlow + ViewModel | LiveData / AsyncTask |
|
|
67
|
+
| **Navigation** | Navigation Compose | Intent-based navigation |
|
|
68
|
+
| **DI** | Hilt (Dagger) | Manual DI / ServiceLocator |
|
|
69
|
+
|
|
70
|
+
### Data Layer
|
|
71
|
+
| Purpose | Technology | Replaces |
|
|
72
|
+
|---------|-----------|----------|
|
|
73
|
+
| **Network** | Retrofit + OkHttp + Kotlin Serialization | Volley / HttpURLConnection |
|
|
74
|
+
| **Local DB** | Room Database | Raw SQLite / SQLiteOpenHelper |
|
|
75
|
+
| **Preferences** | DataStore (Proto/Preferences) | SharedPreferences |
|
|
76
|
+
| **Image Loading** | Coil | Picasso / Glide (evaluate) |
|
|
77
|
+
| **Async** | Kotlin Coroutines + Flow | AsyncTask / Handler / Thread |
|
|
78
|
+
|
|
79
|
+
### Observability
|
|
80
|
+
| Purpose | Technology |
|
|
81
|
+
|---------|-----------|
|
|
82
|
+
| **Crash** | Firebase Crashlytics |
|
|
83
|
+
| **Analytics** | Firebase Analytics |
|
|
84
|
+
| **Logging** | Timber |
|
|
85
|
+
|
|
86
|
+
### Replacements Table (Legacy → Modern)
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
always_replace:
|
|
90
|
+
AsyncTask: "Coroutines (suspend fun / Flow)"
|
|
91
|
+
Volley: "Retrofit + OkHttp"
|
|
92
|
+
HttpURLConnection: "Retrofit + OkHttp"
|
|
93
|
+
Handler/Looper: "Coroutines (Dispatchers.Main)"
|
|
94
|
+
BroadcastReceiver (local): "Flow / EventBus → SharedFlow"
|
|
95
|
+
SharedPreferences: "DataStore"
|
|
96
|
+
SQLiteOpenHelper: "Room"
|
|
97
|
+
ListView/GridView: "LazyColumn/LazyGrid (Compose)"
|
|
98
|
+
findViewById: "Compose state"
|
|
99
|
+
Gson: "Kotlin Serialization (kotlinx.serialization)"
|
|
100
|
+
|
|
101
|
+
evaluate_before_replacing:
|
|
102
|
+
Glide: "Keep if deeply integrated, otherwise → Coil"
|
|
103
|
+
RxJava: "Migrate to Coroutines + Flow (gradual)"
|
|
104
|
+
EventBus: "Replace with SharedFlow"
|
|
105
|
+
Butter Knife: "Not needed in Compose"
|
|
106
|
+
Dagger 2: "Upgrade to Hilt"
|
|
107
|
+
|
|
108
|
+
keep_as_is:
|
|
109
|
+
- "OkHttp (still current)"
|
|
110
|
+
- "Retrofit (still current)"
|
|
111
|
+
- "Firebase SDKs (use latest version)"
|
|
112
|
+
- "Google Play Services"
|
|
113
|
+
- "Native .so libraries (JNI)"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 📋 EXECUTION PIPELINE (6 Steps)
|
|
119
|
+
|
|
120
|
+
> **Rule:** Always complete one step fully before moving to the next.
|
|
121
|
+
> **Rule:** After each step, create a checkpoint summary for the user.
|
|
122
|
+
|
|
123
|
+
### Step 0: Library Scanner (PRE-STEP — Always First) 🔍
|
|
124
|
+
|
|
125
|
+
**Purpose:** Scan the APK structure to identify all third-party libraries before any coding.
|
|
126
|
+
|
|
127
|
+
**Process:**
|
|
128
|
+
1. **Scan `smali/` directories** for package patterns:
|
|
129
|
+
```
|
|
130
|
+
smali/com/google/ → Google SDKs
|
|
131
|
+
smali/com/facebook/ → Facebook SDK
|
|
132
|
+
smali/com/squareup/ → OkHttp, Retrofit, Picasso
|
|
133
|
+
smali/io/reactivex/ → RxJava
|
|
134
|
+
smali/org/greenrobot/ → EventBus
|
|
135
|
+
smali/com/bumptech/ → Glide
|
|
136
|
+
smali/com/airbnb/ → Lottie
|
|
137
|
+
smali/androidx/ → AndroidX (baseline)
|
|
138
|
+
smali/com/jakewharton/ → Butterknife, Timber
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
2. **Check `lib/` for native libraries (.so)**:
|
|
142
|
+
```
|
|
143
|
+
lib/arm64-v8a/*.so → 64-bit native libs
|
|
144
|
+
lib/armeabi-v7a/*.so → 32-bit native libs
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
3. **Check `assets/` for embedded resources:**
|
|
148
|
+
- ML models (.tflite, .onnx)
|
|
149
|
+
- WebView HTML/JS bundles
|
|
150
|
+
- Config files (JSON, XML)
|
|
151
|
+
|
|
152
|
+
4. **Output: Library Report**
|
|
153
|
+
```markdown
|
|
154
|
+
## 📦 Library Detection Report
|
|
155
|
+
|
|
156
|
+
### ✅ Can Reuse (add to build.gradle)
|
|
157
|
+
| Library | Detected Package | Latest Version | Action |
|
|
158
|
+
|---------|-----------------|----------------|--------|
|
|
159
|
+
| Retrofit | com.squareup.retrofit2 | 2.9.0 | Add dependency |
|
|
160
|
+
| OkHttp | com.squareup.okhttp3 | 4.12.0 | Add dependency |
|
|
161
|
+
| Glide | com.bumptech.glide | 4.16.0 | Evaluate → Coil? |
|
|
162
|
+
|
|
163
|
+
### 🔄 Must Replace (legacy)
|
|
164
|
+
| Old Library | Detected Package | Replacement |
|
|
165
|
+
|-------------|-----------------|-------------|
|
|
166
|
+
| Volley | com.android.volley | Retrofit |
|
|
167
|
+
| AsyncTask | android.os.AsyncTask | Coroutines |
|
|
168
|
+
|
|
169
|
+
### 📱 Native (.so) — Keep As-Is
|
|
170
|
+
| File | Architecture | Notes |
|
|
171
|
+
|------|-------------|-------|
|
|
172
|
+
| libfoo.so | arm64-v8a | Need JNI bridge |
|
|
173
|
+
|
|
174
|
+
### ❓ Unknown (investigate)
|
|
175
|
+
| Package | Path | Possible Library |
|
|
176
|
+
|---------|------|-----------------|
|
|
177
|
+
| com.xyz.abc | smali/com/xyz/abc | Custom? |
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### Step 1: AndroidManifest Analysis & Project Bootstrap 📄
|
|
183
|
+
|
|
184
|
+
**Input:** User provides `AndroidManifest.xml` from Apktool output.
|
|
185
|
+
|
|
186
|
+
**Tasks:**
|
|
187
|
+
1. Extract Application ID and original package name
|
|
188
|
+
2. List all required permissions (group by category: network, storage, camera, etc.)
|
|
189
|
+
3. Identify entry points:
|
|
190
|
+
- `Application` class (custom init logic?)
|
|
191
|
+
- `SplashActivity` / Launcher Activity
|
|
192
|
+
- `MainActivity`
|
|
193
|
+
4. Map all components:
|
|
194
|
+
- Activities → future Compose screens
|
|
195
|
+
- Services → WorkManager candidates?
|
|
196
|
+
- BroadcastReceivers → keep or replace with Flow?
|
|
197
|
+
- ContentProviders → keep or replace with Room?
|
|
198
|
+
5. Detect intent-filters for deep links
|
|
199
|
+
6. **Output:** Propose Clean Architecture project structure
|
|
200
|
+
|
|
201
|
+
**Project Structure Template:**
|
|
202
|
+
```
|
|
203
|
+
app/
|
|
204
|
+
├── src/main/
|
|
205
|
+
│ ├── java/com/package/app/
|
|
206
|
+
│ │ ├── App.kt # Application class
|
|
207
|
+
│ │ ├── di/ # Hilt modules
|
|
208
|
+
│ │ │ ├── AppModule.kt
|
|
209
|
+
│ │ │ ├── NetworkModule.kt
|
|
210
|
+
│ │ │ └── DatabaseModule.kt
|
|
211
|
+
│ │ ├── data/ # Data Layer
|
|
212
|
+
│ │ │ ├── remote/
|
|
213
|
+
│ │ │ │ ├── api/ # Retrofit interfaces
|
|
214
|
+
│ │ │ │ ├── dto/ # Data Transfer Objects
|
|
215
|
+
│ │ │ │ └── interceptor/ # OkHttp interceptors
|
|
216
|
+
│ │ │ ├── local/
|
|
217
|
+
│ │ │ │ ├── db/ # Room database
|
|
218
|
+
│ │ │ │ ├── dao/ # Room DAOs
|
|
219
|
+
│ │ │ │ ├── entity/ # Room entities
|
|
220
|
+
│ │ │ │ └── datastore/ # DataStore preferences
|
|
221
|
+
│ │ │ └── repository/ # Repository implementations
|
|
222
|
+
│ │ ├── domain/ # Domain Layer
|
|
223
|
+
│ │ │ ├── model/ # Business models
|
|
224
|
+
│ │ │ ├── repository/ # Repository interfaces
|
|
225
|
+
│ │ │ └── usecase/ # Use cases
|
|
226
|
+
│ │ ├── presentation/ # Presentation Layer
|
|
227
|
+
│ │ │ ├── navigation/ # NavGraph + Routes
|
|
228
|
+
│ │ │ ├── theme/ # Material 3 Theme
|
|
229
|
+
│ │ │ ├── components/ # Reusable Compose components
|
|
230
|
+
│ │ │ └── screens/ # Feature screens
|
|
231
|
+
│ │ │ ├── splash/
|
|
232
|
+
│ │ │ │ ├── SplashScreen.kt
|
|
233
|
+
│ │ │ │ └── SplashViewModel.kt
|
|
234
|
+
│ │ │ ├── home/
|
|
235
|
+
│ │ │ │ ├── HomeScreen.kt
|
|
236
|
+
│ │ │ │ └── HomeViewModel.kt
|
|
237
|
+
│ │ │ └── ...
|
|
238
|
+
│ │ └── util/ # Extensions, helpers
|
|
239
|
+
│ ├── res/ # Only needed resources
|
|
240
|
+
│ └── AndroidManifest.xml # Clean manifest
|
|
241
|
+
├── build.gradle.kts
|
|
242
|
+
└── proguard-rules.pro
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
### Step 2: Data Layer Reconstruction 💾
|
|
248
|
+
|
|
249
|
+
**Input:** User provides Smali/Java code for API endpoints, JSON models, database queries.
|
|
250
|
+
|
|
251
|
+
**Tasks:**
|
|
252
|
+
1. **Models:** Convert POJO/Model Smali → Kotlin `data class`
|
|
253
|
+
- Use `@Serializable` (kotlinx.serialization) or `@JsonClass` (Moshi)
|
|
254
|
+
- Preserve JSON field names with `@SerialName`
|
|
255
|
+
2. **API Layer:**
|
|
256
|
+
- Extract base URL, endpoints, headers from Smali
|
|
257
|
+
- Create Retrofit `@GET/@POST` interfaces
|
|
258
|
+
- Identify auth patterns (token, API key, custom headers)
|
|
259
|
+
3. **Local Storage:**
|
|
260
|
+
- SQLite queries → Room entities + DAOs
|
|
261
|
+
- SharedPreferences keys → DataStore schema
|
|
262
|
+
4. **Repository:**
|
|
263
|
+
- Create interface in `domain/repository/`
|
|
264
|
+
- Implement in `data/repository/`
|
|
265
|
+
- Use Flow for reactive data streams
|
|
266
|
+
|
|
267
|
+
**Smali Reading Tips:**
|
|
268
|
+
```
|
|
269
|
+
# Finding API base URL:
|
|
270
|
+
Look for: const-string → "https://" or "http://"
|
|
271
|
+
Look for: .field → BASE_URL or API_URL
|
|
272
|
+
|
|
273
|
+
# Finding endpoints:
|
|
274
|
+
Look for: StringBuilder + append patterns
|
|
275
|
+
Look for: Annotation patterns (@GET, @POST in obfuscated form)
|
|
276
|
+
|
|
277
|
+
# Finding JSON parsing:
|
|
278
|
+
Look for: JSONObject, JSONArray usage
|
|
279
|
+
Look for: Gson.fromJson / TypeToken patterns
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Step 3: Core Logic & Utils Reconstruction 🧮
|
|
285
|
+
|
|
286
|
+
**Input:** User provides Smali for encryption, hashing, time formatting, custom utils.
|
|
287
|
+
|
|
288
|
+
**Tasks:**
|
|
289
|
+
1. Translate mathematical/encryption logic from Smali → Kotlin
|
|
290
|
+
- Preserve exact input/output signatures (critical for server compatibility)
|
|
291
|
+
- Use `object` for stateless utils, extension functions for type-specific
|
|
292
|
+
2. Map special encoding patterns:
|
|
293
|
+
- MD5/SHA hashing → `MessageDigest`
|
|
294
|
+
- AES/DES encryption → `javax.crypto.Cipher`
|
|
295
|
+
- Base64 → `android.util.Base64` or `java.util.Base64`
|
|
296
|
+
- Custom obfuscation → reverse engineer step-by-step
|
|
297
|
+
3. **Verification:** Create unit tests that compare output with original app
|
|
298
|
+
|
|
299
|
+
**Critical Rule:**
|
|
300
|
+
> ⚠️ Encryption and hashing functions MUST produce identical output to the original app.
|
|
301
|
+
> Any mismatch will break server communication. Always unit test with known input/output pairs.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
### Step 4: UI & ViewModel Reconstruction (Per Screen) 🎨
|
|
306
|
+
|
|
307
|
+
**Input:** User provides `layout_xxx.xml` + corresponding Smali for Activity/Fragment.
|
|
308
|
+
|
|
309
|
+
**Tasks:**
|
|
310
|
+
1. **Resource Extraction (On-Demand):**
|
|
311
|
+
- List ONLY the drawables, strings, colors, dimens used in this specific screen
|
|
312
|
+
- User copies only those resources to the new project
|
|
313
|
+
- Clean up namespace references in resources
|
|
314
|
+
|
|
315
|
+
2. **Compose Migration:**
|
|
316
|
+
- Convert XML layout → Jetpack Compose composables
|
|
317
|
+
- Map View attributes → Compose modifiers
|
|
318
|
+
- Common mappings:
|
|
319
|
+
```
|
|
320
|
+
LinearLayout (vertical) → Column
|
|
321
|
+
LinearLayout (horizontal) → Row
|
|
322
|
+
FrameLayout → Box
|
|
323
|
+
RelativeLayout → Box with alignment / ConstraintLayout
|
|
324
|
+
RecyclerView → LazyColumn / LazyGrid
|
|
325
|
+
ScrollView → verticalScroll modifier
|
|
326
|
+
ImageView → Image / AsyncImage (Coil)
|
|
327
|
+
TextView → Text
|
|
328
|
+
EditText → TextField / OutlinedTextField
|
|
329
|
+
Button → Button / TextButton / OutlinedButton
|
|
330
|
+
ProgressBar → CircularProgressIndicator / LinearProgressIndicator
|
|
331
|
+
CardView → Card (Material 3)
|
|
332
|
+
Toolbar/ActionBar → TopAppBar (Material 3)
|
|
333
|
+
BottomNavigationView → NavigationBar (Material 3)
|
|
334
|
+
TabLayout + ViewPager → TabRow + HorizontalPager
|
|
335
|
+
SwipeRefreshLayout → pullRefresh modifier
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
3. **ViewModel Creation:**
|
|
339
|
+
- Read Smali logic flow: when API calls happen, loading states, form validation
|
|
340
|
+
- Create sealed class for UI state:
|
|
341
|
+
```kotlin
|
|
342
|
+
sealed interface ScreenUiState {
|
|
343
|
+
data object Loading : ScreenUiState
|
|
344
|
+
data class Success(val data: ScreenData) : ScreenUiState
|
|
345
|
+
data class Error(val message: String) : ScreenUiState
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
- Expose via `StateFlow` from ViewModel
|
|
349
|
+
- Handle one-time events via `SharedFlow` (navigation, snackbar, toast)
|
|
350
|
+
|
|
351
|
+
4. **Screen Composable:**
|
|
352
|
+
- Collect state from ViewModel
|
|
353
|
+
- Implement Material 3 theming
|
|
354
|
+
- Handle navigation via Navigation Compose
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### Step 5: Third-party SDK & Native Library Integration 📦
|
|
359
|
+
|
|
360
|
+
**Input:** User provides JNI libs list and SDK detection from Step 0.
|
|
361
|
+
|
|
362
|
+
**Tasks:**
|
|
363
|
+
1. **Native Libraries (.so):**
|
|
364
|
+
- Keep .so files in `jniLibs/` directory
|
|
365
|
+
- Declare `external fun` in Kotlin matching C/C++ signatures
|
|
366
|
+
- Use `System.loadLibrary("name")` in companion object or init block
|
|
367
|
+
- Document JNI method signatures
|
|
368
|
+
|
|
369
|
+
2. **SDKs (from Library Report):**
|
|
370
|
+
- Add latest stable versions to `build.gradle.kts`
|
|
371
|
+
- Initialize in `Application` class using modern patterns:
|
|
372
|
+
```kotlin
|
|
373
|
+
@HiltAndroidApp
|
|
374
|
+
class App : Application() {
|
|
375
|
+
override fun onCreate() {
|
|
376
|
+
super.onCreate()
|
|
377
|
+
// Firebase (auto-init via manifest, or manual)
|
|
378
|
+
// Timber
|
|
379
|
+
if (BuildConfig.DEBUG) {
|
|
380
|
+
Timber.plant(Timber.DebugTree())
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
- Replace deprecated SDK API calls with current documentation
|
|
386
|
+
|
|
387
|
+
3. **build.gradle.kts Setup:**
|
|
388
|
+
- Use Version Catalogs (`libs.versions.toml`) for dependency management
|
|
389
|
+
- Configure Compose compiler, Hilt plugin, KSP
|
|
390
|
+
- Set up proper minSdk, targetSdk, compileSdk
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### Step 6: Parity Check & Quality Gate ✅
|
|
395
|
+
|
|
396
|
+
**Per-module checklist:**
|
|
397
|
+
1. **Branch Coverage:** Review all `if-else`, `switch/when`, `try-catch` paths from Smali
|
|
398
|
+
- List discovered branches as test cases
|
|
399
|
+
- Ask user to test each edge case
|
|
400
|
+
|
|
401
|
+
2. **API Parity:** Verify all API endpoints produce same request/response
|
|
402
|
+
- Compare headers, body format, encoding
|
|
403
|
+
- Test auth flow end-to-end
|
|
404
|
+
|
|
405
|
+
3. **Data Parity:** Verify local storage read/write matches original
|
|
406
|
+
- Migration path from old DB schema if user needs it
|
|
407
|
+
|
|
408
|
+
4. **UI Parity:** Compare screen-by-screen
|
|
409
|
+
- Layout matches (spacing, colors, interactions)
|
|
410
|
+
- Navigation flow matches
|
|
411
|
+
- Error states handled
|
|
412
|
+
|
|
413
|
+
5. **Performance Check:**
|
|
414
|
+
- ProGuard/R8 rules for release build
|
|
415
|
+
- No unnecessary allocations in Compose (stable/immutable)
|
|
416
|
+
- Proper coroutine scope management
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 🔄 WORKFLOW INTEGRATION
|
|
421
|
+
|
|
422
|
+
### With Other Skills/Workflows:
|
|
423
|
+
|
|
424
|
+
```yaml
|
|
425
|
+
triggers_from:
|
|
426
|
+
- "/reverse-android" workflow command
|
|
427
|
+
- Keywords: "smali", "apktool", "dịch ngược", "rebuild"
|
|
428
|
+
|
|
429
|
+
delegates_to:
|
|
430
|
+
- "/test" — after parity check
|
|
431
|
+
- "/deploy" — when rebuild is complete
|
|
432
|
+
- beads-manager — auto-track progress per step
|
|
433
|
+
|
|
434
|
+
works_with:
|
|
435
|
+
- memory-sync — saves decisions, patterns, solutions
|
|
436
|
+
- orchestrator — routes to this skill based on intent
|
|
437
|
+
|
|
438
|
+
independent_from:
|
|
439
|
+
- brainstorm-agent
|
|
440
|
+
- ios-engineer (but shares design philosophy)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Session State Tracking:
|
|
444
|
+
|
|
445
|
+
```yaml
|
|
446
|
+
session_state:
|
|
447
|
+
current_step: 0-6
|
|
448
|
+
current_screen: "HomeScreen" (for step 4 iterations)
|
|
449
|
+
library_report: generated | pending
|
|
450
|
+
completed_screens: ["SplashScreen", "LoginScreen"]
|
|
451
|
+
pending_screens: ["HomeScreen", "SettingsScreen"]
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## 🚫 ANTI-PATTERNS
|
|
457
|
+
|
|
458
|
+
```yaml
|
|
459
|
+
never_do:
|
|
460
|
+
- Copy all resources blindly from APK → only on-demand
|
|
461
|
+
- Use deprecated libraries (AsyncTask, Volley) → always use modern replacements
|
|
462
|
+
- Skip library scanning step → always detect reusable packages first
|
|
463
|
+
- Modify encryption output → must match original exactly
|
|
464
|
+
- Create massive God Activity → split into Compose screens + ViewModels
|
|
465
|
+
- Hardcode API keys/secrets → use BuildConfig or encrypted storage
|
|
466
|
+
- Skip parity check → always verify against original behavior
|
|
467
|
+
|
|
468
|
+
always_do:
|
|
469
|
+
- Run Library Scanner (Step 0) before any coding
|
|
470
|
+
- Present library report to user for approval
|
|
471
|
+
- Ask user to confirm each step's output before proceeding
|
|
472
|
+
- Create checkpoint summary after each step
|
|
473
|
+
- Unit test all encryption/hashing utils
|
|
474
|
+
- Use sealed classes for UI state
|
|
475
|
+
- Follow Clean Architecture layer separation strictly
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## 📊 CHECKPOINT TEMPLATE
|
|
481
|
+
|
|
482
|
+
After each step, output:
|
|
483
|
+
|
|
484
|
+
```markdown
|
|
485
|
+
## ✅ Step [N] Complete: [Step Name]
|
|
486
|
+
|
|
487
|
+
### What was done:
|
|
488
|
+
- [Summary of actions]
|
|
489
|
+
|
|
490
|
+
### Files created:
|
|
491
|
+
- [List of new files]
|
|
492
|
+
|
|
493
|
+
### Resources extracted:
|
|
494
|
+
- [List of resources moved to new project]
|
|
495
|
+
|
|
496
|
+
### Decisions made:
|
|
497
|
+
- [Key decisions documented]
|
|
498
|
+
|
|
499
|
+
### ⏭️ Next: Step [N+1] — [Step Name]
|
|
500
|
+
- [What user needs to provide]
|
|
501
|
+
- [What will be done]
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
## 🧩 EXTENSIBILITY NOTE
|
|
507
|
+
|
|
508
|
+
This skill follows the **Platform RE Template Pattern**:
|
|
509
|
+
- Core workflow (6 steps) is transferable to other platforms
|
|
510
|
+
- Technology mappings are platform-specific (this file: Android)
|
|
511
|
+
- Future `smali-to-swift` skill will follow same structure with iOS tech stack:
|
|
512
|
+
- Smali → Swift
|
|
513
|
+
- Jetpack Compose → SwiftUI
|
|
514
|
+
- Room → Core Data / SwiftData
|
|
515
|
+
- Retrofit → URLSession / Alamofire
|
|
516
|
+
- Hilt → Swift DI patterns
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
*smali-to-kotlin v1.0.0 — Android Reverse Engineering Skill for AWF*
|
|
521
|
+
*Created by Antigravity Team*
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# 📦 Library Detection Patterns
|
|
2
|
+
|
|
3
|
+
> Reference database for Step 0 (Library Scanner).
|
|
4
|
+
> Agent uses these patterns to identify third-party libraries from Smali package structure.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🟢 Network & API
|
|
9
|
+
|
|
10
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
11
|
+
|----------------|---------|-------------------|--------|
|
|
12
|
+
| `com/squareup/retrofit2` | Retrofit 2 | Keep (current) | Add to build.gradle |
|
|
13
|
+
| `com/squareup/okhttp3` | OkHttp 3 | Keep (current) | Add to build.gradle |
|
|
14
|
+
| `com/android/volley` | Volley | Retrofit + OkHttp | Replace |
|
|
15
|
+
| `com/squareup/okhttp` | OkHttp 2 | OkHttp 4 | Upgrade |
|
|
16
|
+
| `com/loopj/android` | AsyncHttpClient | Retrofit | Replace |
|
|
17
|
+
| `org/apache/http` | Apache HTTP | OkHttp | Replace |
|
|
18
|
+
| `com/squareup/moshi` | Moshi | Keep (current) | Add to build.gradle |
|
|
19
|
+
| `com/google/gson` | Gson | kotlinx.serialization | Evaluate |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🟡 Image Loading
|
|
24
|
+
|
|
25
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
26
|
+
|----------------|---------|-------------------|--------|
|
|
27
|
+
| `com/bumptech/glide` | Glide | Coil (Compose-native) | Evaluate |
|
|
28
|
+
| `com/squareup/picasso` | Picasso | Coil | Replace |
|
|
29
|
+
| `com/facebook/fresco` | Fresco | Coil | Replace |
|
|
30
|
+
| `com/nostra13/universalimageloader` | UIL | Coil | Replace |
|
|
31
|
+
| `io/coil` | Coil | Keep (current) | Add to build.gradle |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔵 Reactive Programming
|
|
36
|
+
|
|
37
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
38
|
+
|----------------|---------|-------------------|--------|
|
|
39
|
+
| `io/reactivex/rxjava3` | RxJava 3 | Coroutines + Flow | Gradual migrate |
|
|
40
|
+
| `io/reactivex/rxjava2` | RxJava 2 | Coroutines + Flow | Replace |
|
|
41
|
+
| `io/reactivex` | RxJava 1 | Coroutines + Flow | Replace |
|
|
42
|
+
| `io/reactivex/rxandroid` | RxAndroid | Dispatchers.Main | Replace |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 🟠 Dependency Injection
|
|
47
|
+
|
|
48
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
49
|
+
|----------------|---------|-------------------|--------|
|
|
50
|
+
| `dagger/hilt` | Hilt | Keep (current) | Add to build.gradle |
|
|
51
|
+
| `com/google/dagger` | Dagger 2 | Hilt | Upgrade |
|
|
52
|
+
| `org/koin` | Koin | Keep or Hilt | Evaluate |
|
|
53
|
+
| `toothpick` | Toothpick | Hilt | Replace |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🟣 Firebase & Google
|
|
58
|
+
|
|
59
|
+
| Package Pattern | Library | Action |
|
|
60
|
+
|----------------|---------|--------|
|
|
61
|
+
| `com/google/firebase/analytics` | Firebase Analytics | Add latest |
|
|
62
|
+
| `com/google/firebase/crashlytics` | Crashlytics | Add latest |
|
|
63
|
+
| `com/google/firebase/messaging` | FCM | Add latest |
|
|
64
|
+
| `com/google/firebase/auth` | Firebase Auth | Add latest |
|
|
65
|
+
| `com/google/firebase/firestore` | Firestore | Add latest |
|
|
66
|
+
| `com/google/firebase/database` | Realtime DB | Add latest |
|
|
67
|
+
| `com/google/firebase/storage` | Cloud Storage | Add latest |
|
|
68
|
+
| `com/google/firebase/config` | Remote Config | Add latest |
|
|
69
|
+
| `com/google/android/gms/ads` | AdMob | Add latest |
|
|
70
|
+
| `com/google/android/gms/auth` | Google Sign-In | Add latest |
|
|
71
|
+
| `com/google/android/gms/maps` | Google Maps | Add latest |
|
|
72
|
+
| `com/google/android/gms/location` | Location Services | Add latest |
|
|
73
|
+
| `com/google/android/play` | Play Core | Add latest |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 🔴 Social SDKs
|
|
78
|
+
|
|
79
|
+
| Package Pattern | Library | Action |
|
|
80
|
+
|----------------|---------|--------|
|
|
81
|
+
| `com/facebook/login` | Facebook Login | Add latest |
|
|
82
|
+
| `com/facebook/share` | Facebook Share | Add latest |
|
|
83
|
+
| `com/facebook/appevents` | Facebook Analytics | Add latest |
|
|
84
|
+
| `com/twitter` | Twitter SDK | Evaluate (deprecated?) |
|
|
85
|
+
| `com/kakao` | Kakao SDK | Add latest |
|
|
86
|
+
| `com/linecorp` | LINE SDK | Add latest |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 🟤 UI & Animation
|
|
91
|
+
|
|
92
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
93
|
+
|----------------|---------|-------------------|--------|
|
|
94
|
+
| `com/airbnb/lottie` | Lottie | Keep (has Compose support) | Add to build.gradle |
|
|
95
|
+
| `com/github/bumptech/glide` | Glide Transformations | Compose modifiers | Evaluate |
|
|
96
|
+
| `com/makeramen/roundedimageview` | RoundedImageView | Compose `clip(CircleShape)` | Replace |
|
|
97
|
+
| `de/hdodenhof/circleimageview` | CircleImageView | Compose `clip(CircleShape)` | Replace |
|
|
98
|
+
| `com/github/chrisbanes` | PhotoView | Compose zoomable | Replace |
|
|
99
|
+
| `com/google/android/material` | Material Components | Material 3 (Compose) | Upgrade |
|
|
100
|
+
| `com/jakewharton/butterknife` | Butterknife | Not needed (Compose) | Remove |
|
|
101
|
+
| `androidx/viewpager2` | ViewPager2 | HorizontalPager (Compose) | Replace |
|
|
102
|
+
| `androidx/cardview` | CardView | Card (Material 3 Compose) | Replace |
|
|
103
|
+
| `androidx/recyclerview` | RecyclerView | LazyColumn/LazyGrid | Replace |
|
|
104
|
+
| `androidx/swiperefreshlayout` | SwipeRefresh | pullRefresh modifier | Replace |
|
|
105
|
+
| `com/github/PhilJay/MPAndroidChart` | MPAndroidChart | Vico / Compose Charts | Evaluate |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## ⚪ Database & Storage
|
|
110
|
+
|
|
111
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
112
|
+
|----------------|---------|-------------------|--------|
|
|
113
|
+
| `androidx/room` | Room | Keep (current) | Add to build.gradle |
|
|
114
|
+
| `io/realm` | Realm | Room | Evaluate |
|
|
115
|
+
| `net/sqlcipher` | SQLCipher | Room + encrypted | Keep |
|
|
116
|
+
| `com/google/protobuf` | Protocol Buffers | Keep | Add to build.gradle |
|
|
117
|
+
| `com/tencent/mmkv` | MMKV | DataStore | Evaluate |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## ⚫ Utility
|
|
122
|
+
|
|
123
|
+
| Package Pattern | Library | Latest Replacement | Action |
|
|
124
|
+
|----------------|---------|-------------------|--------|
|
|
125
|
+
| `com/jakewharton/timber` | Timber | Keep (current) | Add to build.gradle |
|
|
126
|
+
| `org/greenrobot/eventbus` | EventBus | SharedFlow | Replace |
|
|
127
|
+
| `com/google/zxing` | ZXing (QR/Barcode) | ML Kit Barcode | Evaluate |
|
|
128
|
+
| `com/journeyapps/barcodescanner` | ZXing Android | ML Kit Barcode | Evaluate |
|
|
129
|
+
| `com/github/permissions` | Various permission libs | Accompanist Permissions | Replace |
|
|
130
|
+
| `pub/devrel/easypermissions` | EasyPermissions | Accompanist Permissions | Replace |
|
|
131
|
+
| `org/jsoup` | Jsoup | Keep (HTML parsing) | Add to build.gradle |
|
|
132
|
+
| `com/google/android/exoplayer2` | ExoPlayer | Media3 ExoPlayer | Upgrade |
|
|
133
|
+
| `androidx/media3` | Media3 | Keep (current) | Add to build.gradle |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 🔐 Security & Encryption
|
|
138
|
+
|
|
139
|
+
| Package Pattern | Library | Action |
|
|
140
|
+
|----------------|---------|--------|
|
|
141
|
+
| `com/scottyab/rootbeer` | RootBeer | Evaluate |
|
|
142
|
+
| `io/jsonwebtoken` | JJWT | Keep |
|
|
143
|
+
| `org/bouncycastle` | BouncyCastle | Keep |
|
|
144
|
+
| `net/sqlcipher` | SQLCipher | Keep |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 🔍 Detection Strategy
|
|
149
|
+
|
|
150
|
+
### Step 1: Directory Scan
|
|
151
|
+
```bash
|
|
152
|
+
# List all top-level smali packages
|
|
153
|
+
ls -d smali/*/
|
|
154
|
+
ls -d smali_classes*/*/ # multi-dex apps
|
|
155
|
+
|
|
156
|
+
# Find specific library patterns
|
|
157
|
+
find smali/ -maxdepth 3 -type d | sort
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Step 2: Classify Each Package
|
|
161
|
+
```
|
|
162
|
+
For each detected package:
|
|
163
|
+
1. Match against patterns above
|
|
164
|
+
2. If MATCH → categorize (Keep / Replace / Upgrade / Evaluate)
|
|
165
|
+
3. If NO MATCH → mark as "Unknown — investigate"
|
|
166
|
+
4. If app's own package → mark as "App Code — rebuild in Kotlin"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Step 3: Check Native Libraries
|
|
170
|
+
```bash
|
|
171
|
+
# List native libraries
|
|
172
|
+
ls lib/*/
|
|
173
|
+
file lib/arm64-v8a/*.so # identify library type
|
|
174
|
+
|
|
175
|
+
# Common native libs:
|
|
176
|
+
libfb*.so → Facebook SDK
|
|
177
|
+
libreact*.so → React Native
|
|
178
|
+
libflutter*.so → Flutter engine
|
|
179
|
+
libhermes*.so → Hermes JS engine (React Native)
|
|
180
|
+
libsqlcipher*.so → SQLCipher encrypted DB
|
|
181
|
+
libmmkv*.so → MMKV storage
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Step 4: Generate Report
|
|
185
|
+
Use the template from SKILL.md Step 0 output format.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
*library-patterns v1.0.0 — Reference database for APK library detection*
|