Skip to content

Commit a5786c0

Browse files
authored
Merge pull request #2007 from HackTricks-wiki/update_PulseAPK_Core__GUI_workflow_for_APK_decompilation__20260315_124922
PulseAPK Core GUI workflow for APK decompilation, Smali rule...
2 parents 5ed9661 + 3dab1d1 commit a5786c0

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

src/mobile-pentesting/android-app-pentesting/smali-changes.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,49 @@ Notes:
293293
- Make sure the correct ABI variant of the library exists under lib/<abi>/ (e.g., arm64-v8a/armeabi-v7a) to avoid UnsatisfiedLinkError.
294294
- Loading very early (class static initializer) guarantees the native logger can observe subsequent JNI activity.
295295

296-
## References
296+
## Smali Static Analysis / Rule-Based Hunting
297+
298+
After decompiling with `apktool`, you can **scan Smali line-by-line** with regex rules to quickly spot anti-analysis logic (root/emulator checks) and likely hardcoded secrets. This is a **fast triage** technique: treat hits as leads that you must verify in surrounding Smali or reconstructed Java/Kotlin.
299+
300+
Key ideas:
301+
- **Library filtering**: suppress or tag findings under common third-party namespaces so you focus on app-owned code paths.
302+
- **Context hints**: require suspicious strings to appear near the APIs that consume them (within the same method, within N lines).
303+
- **Confidence**: use simple levels (high/medium) to rank leads and reduce false positives.
304+
305+
Example library prefixes to suppress by default:
306+
```text
307+
Landroidx/
308+
Lkotlin/
309+
Lkotlinx/
310+
Lcom/google/
311+
Lcom/squareup/
312+
Lokhttp3/
313+
Lokio/
314+
Lretrofit2/
315+
```
316+
317+
Example detection rules (regex + context heuristics):
318+
```json
319+
{
320+
"category": "root_check",
321+
"regex_patterns": [
322+
"(?i)invoke-static .*Runtime;->getRuntime\\(\\).*->exec\\(.*\\"(su|magisk|busybox)\\"",
323+
"(?i)const-string [vp0-9, ]+\\"(/system/xbin/su|/system/bin/su|/sbin/su)\\""
324+
],
325+
"context_hint": "Only report when the same method also calls File;->exists/canExecute or Runtime;->exec."
326+
}
327+
```
328+
329+
Additional heuristics that work well in practice:
330+
- **Root package/path checks**: require nearby `PackageManager;->getPackageInfo` or `File;->exists` calls for strings like `com.topjohnwu.magisk` or `/data/local/tmp`.
331+
- **Emulator checks**: pair suspicious literals (e.g., `ro.kernel.qemu`, `generic`, `goldfish`) with nearby `Build.*` getters and string comparisons (`->equals`, `->contains`, `->startsWith`).
332+
- **Hardcoded secrets**: flag `const-string` only when a nearby `.field` or `move-result` identifier includes keywords like `password`, `token`, `api_key`. Explicitly ignore UI-only markers such as `AutofillType`, `InputType`, `EditorInfo`.
297333

334+
Rule-driven scanners like PulseAPK Core implement this model to quickly surface anti-analysis logic and potential secrets in Smali.
335+
336+
## References
337+
- [PulseAPK Core](https://github.com/deemoun/PulseAPK-Core)
338+
- [PulseAPK Smali Detection Rules](https://github.com/deemoun/PulseAPK-Core/blob/main/APK_ANALYSIS_RULES.md)
298339
- SoTap: Lightweight in-app JNI (.so) behavior logger – [github.com/RezaArbabBot/SoTap](https://github.com/RezaArbabBot/SoTap)
299340
- Android Developers: [apksigner](https://developer.android.com/tools/apksigner) and [zipalign](https://developer.android.com/tools/zipalign)
300341
- apk.sh: [github.com/ax/apk.sh](https://github.com/ax/apk.sh)

0 commit comments

Comments
 (0)