69 — Malware Analysis: Cheat Sheet
Dense reference. Full explanation in README.md .
Nothing in this repository is live malware. All indicators shown are RFC
2606 .invalid names. Never analyse a real sample on a device you care
about.
1. The triage checklist
#
Step
Command
Stop if
0
Isolate
disposable VM, no sync folder, egress sinkholed
you cannot
1
Hash
sha256sum sample.apk
never
2
Record provenance
write down where it came from, now
never
3
Triage
python3 -B scripts/apk-triage.py sample.apk
—
4
Config
python3 -B scripts/config-decrypt.py --apk sample.apk --auto
—
5
Signer
apksigner verify -v --print-certs sample.apk
—
6
Decide
capability consistent with claimed purpose?
yes → close, with reasoning
7
Manifest audit
python3 ../32-Manifest/scripts/manifest-audit.py work/AndroidManifest.xml
—
8
Container
python3 ../10-APK-Internals/scripts/apk-container-triage.py sample.apk
—
9
Native
../15-Native-Code/scripts/so-triage.sh --apk sample.apk
no lib/
10
Decompile + sweep
jadx -d out sample.apk && python3 ../52-StaticAnalysis/scripts/static-sweep.py out
packed
11
Packed?
identify the product from .so names; find the published method
—
12
Dynamic
emulator, snapshot, sinkhole, restore
no isolation
13
Write it up
including what you did not do
never
Three legitimate outcomes only: close · escalate · hand over.
2. Capability → indicator table
Capability
Manifest indicator
Resource indicator
DEX indicator
Device check
Accessibility
<service android:permission="…BIND_ACCESSIBILITY_SERVICE"> + action android.accessibilityservice.AccessibilityService
<accessibility-service> with canRetrieveWindowContent, canPerformGestures, no packageNames , accessibilityEventTypes=typeAllMask
getSource, findAccessibilityNodeInfosByViewId, performGlobalAction, dispatchGesture
settings get secure enabled_accessibility_services
Notification access
<service android:permission="…BIND_NOTIFICATION_LISTENER_SERVICE">
—
onNotificationPosted, cancelNotification , ACTION_NOTIFICATION_LISTENER_SETTINGS
settings get secure enabled_notification_listeners
Overlay
SYSTEM_ALERT_WINDOW
—
TYPE_APPLICATION_OVERLAY, ACTION_MANAGE_OVERLAY_PERMISSION, WindowManager.addView
cmd appops get <pkg> SYSTEM_ALERT_WINDOW
Overlay trigger
PACKAGE_USAGE_STATS
—
UsageStatsManager, queryEvents, getRunningTasks (dead)
cmd appops get <pkg> GET_USAGE_STATS
Device admin
<receiver android:permission="…BIND_DEVICE_ADMIN"> + meta-data android.app.device_admin
<device-admin><uses-policies>
DevicePolicyManager, lockNow, wipeData, ACTION_ADD_DEVICE_ADMIN
dumpsys device_policy
SMS interception
RECEIVE_SMS, READ_SMS
—
SmsMessage, getMessagesFromIntent, content://sms
dumpsys package <pkg> grants
Dropper
REQUEST_INSTALL_PACKAGES
—
PackageInstaller, createSession, ACTION_INSTALL_PACKAGE
pm list packages -i
Target enumeration
QUERY_ALL_PACKAGES
—
getInstalledPackages, getInstalledApplications
—
Provider persistence
<provider> (any)
—
ContentProvider.onCreate with stub data methods
dumpsys package <pkg> providers
Boot persistence
RECEIVE_BOOT_COMPLETED + receiver filter
—
BOOT_COMPLETED, MY_PACKAGE_REPLACED, QUICKBOOT_POWERON
reboot the emulator
Foreground persistence
FOREGROUND_SERVICE + android:foregroundServiceType
—
startForegroundService, startForeground
dumpsys activity services <pkg>
Watchdog pair
android:process=":name" on 2+ components, stopWithTask="false"
—
each class naming the other's component
ps -A \| grep <pkg>
Scheduled restart
—
—
JobScheduler, androidx.work, setExactAndAllowWhileIdle
dumpsys jobscheduler, dumpsys alarm
Battery exemption
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
—
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
dumpsys deviceidle whitelist
Icon hiding
<activity-alias> with LAUNCHER filter
—
setComponentEnabledSetting
cmd package resolve-activity --brief <pkg>
Recents hiding
android:excludeFromRecents="true"
—
—
—
Runtime code load
—
high-entropy assets/ entry
DexClassLoader, InMemoryDexClassLoader , System.load
/proc/<pid>/maps
Early native code
—
—
System.loadLibrary
—
Native pre-observation
—
ELF DT_INIT_ARRAY
—
spawn-gate required
Hidden JNI mapping
—
ELF has RegisterNatives, few Java_*
native methods with no .so symbol
hook art::JNI::RegisterNatives
Config encryption
<meta-data> naming an asset
entropy > 7.5, ratio ≈ 1.0
SecretKeySpec, a static final String of length 16/24/32
—
Installer attribution
—
—
getInstallerPackageName, com.android.vending
dumpsys package <pkg> \| grep -E 'installer\|Initiator'
Anti-analysis
—
—
TracerPid, /proc/self/maps, goldfish, ranchu, generic_x86, frida, /system/bin/su
—
3. Weighting — what a signal is worth alone
Weight
Meaning
Examples
***
Rarely legitimate outside a narrow app class
Unfiltered accessibility descriptor; notification access; SYSTEM_ALERT_WINDOW; REQUEST_INSTALL_PACKAGES; SMS read/receive
**
Common in malware and in legitimate apps
Device admin; QUERY_ALL_PACKAGES; battery exemption; activity-alias; multi-process
*
Context only
RECEIVE_BOOT_COMPLETED; FOREGROUND_SERVICE; INTERNET; READ_PHONE_STATE
The three combinations that matter:
Set
Aimed at
accessibility + overlay + PACKAGE_USAGE_STATS + QUERY_ALL_PACKAGES
Device-takeover fraud
notification access + RECEIVE_SMS + READ_SMS
Second-factor interception with suppression
REQUEST_INSTALL_PACKAGES + accessibility + empty launcher Activity
Self-granting dropper
4. Accessibility descriptor — how to read it in ten seconds
Attribute
Benign shape
Hostile shape
accessibilityEventTypes
two or three named types
typeAllMask / 0xffffffff
canRetrieveWindowContent
true, with a reason
true
canPerformGestures
absent
true
packageNames
present , naming the served apps
absent
accessibilityFlags
minimal
flagReportViewIds\|flagRetrieveInteractiveWindows\|flagIncludeNotImportantViews
Read every res/xml* variant. aapt2 splits descriptors by API qualifier;
measured in this chapter: res/xml/ lacked canPerformGestures while
res/xml-v22/ had it.
5. Provenance — what each artefact is worth
Artefact
Worth
Not worth
File SHA-256
This exact file. Unforgeable
This family
classes.dex SHA-256
This exact code. Survives re-signing
Survives recompilation
Certificate SHA-256
Signed by that key holder. Best cheap corpus link
Same actor — keys leak and are sold
Certificate subject/issuer
Whoever ran keytool typed it
Identity
Certificate validity dates
Whoever ran keytool chose them
Build date
installerPackageName
The installer's claim
Play provenance — adb install -i sets it
installInitiator
System-recorded session UID
User intent
packageSource
The SessionParams hint
Anything authoritative
Strings / comments
Evidence about the file
Evidence about the author
ELF build id
Corpus link to a library
Identity
Sentences to use: "No family association was established." · "No static path
found." · "No attributable change was observed on the exercised paths."
Sentences to avoid: "Possibly related to X." · "Unreachable." · "Clean."
6. Config decryption — the four shapes
Shape
Form
Break it with
Cost
A
Repeating-key XOR
config-decrypt.py … xor --recover (frequency analysis, no key needed) or --crib '{"schema"'
ms
B
AES, key a 16/24/32-char literal
config-decrypt.py --apk x --auto (harvests DEX strings by shape)
s
C
AES, key derived at runtime
Read the derivation. String harvesting cannot help
min–h
D
Key fetched from the network
Often unrecoverable offline
—
python3 -B scripts/config-decrypt.py --apk x.apk --auto # everything
python3 -B scripts/config-decrypt.py --apk x.apk --scan-dex # key candidates
python3 -B scripts/config-decrypt.py --file c.bin xor --recover
python3 -B scripts/config-decrypt.py --file c.bin xor --crib '{"schema"'
python3 -B scripts/config-decrypt.py --file c.bin xor --key 'k'
python3 -B scripts/config-decrypt.py --file c.bin aes --key hex:00112233… --iv-prefix
CBC note: a wrong IV corrupts exactly one block (the first). Two
candidates tying on score → compare the first 16 bytes.
Entropy note: high entropy is not evidence of encryption. Signal =
entropy + ratio ≈ 1.0 + magic not matching the extension.
7. Persistence — kill test
adb shell ps -A | grep <pkg> # note every pid
adb shell kill <pid-A> ; adb shell ps -A | grep <pkg>
adb shell kill <pid-B> ; adb shell ps -A | grep <pkg>
adb shell am force-stop <pkg> ; adb shell ps -A | grep <pkg>
adb shell dumpsys jobscheduler | grep -A 20 <pkg>
adb shell dumpsys alarm | grep -A 10 <pkg>
Survives
Means
one kill, not force-stop
process pair
force-stop
a system-scheduled arm — job or alarm
reboot
boot receiver, or a periodic job
app data clear
files outside the data dir, or another package
8. Native — the four facts that change your method
Fact
Consequence
DT_INIT_ARRAY present
Constructors run before dlopen returns → spawn-gate, do not attach
RegisterNatives + few Java_* exports
Java-to-native mapping is not in the file
Entropy > 7.5 over first 256 KiB
Packed or compressed
ABI set
What it expects to run on; x86 only → emulator-targeted or very old
../15-Native-Code/scripts/so-triage.sh --apk sample.apk
python3 ../15-Native-Code/scripts/elf-inspect.py lib/arm64-v8a/x.so --init
python3 ../15-Native-Code/scripts/elf-harden-check.py sample.apk
Load order: DT_INIT → DT_INIT_ARRAY → dlopen returns → JNI_OnLoad.
9. Packer recognition — any two is conclusive
<application android:name> points at a class with no meaningful code
classes.dex is 20–150 KB inside a multi-megabyte APK
A .so matching a known product
High-entropy asset, compression ratio ≈ 1.0
Product
Library names
Jiagu / 360
libjiagu
Bangcle / SecNeo
libsecexe, libsecmain, libDexHelper
Tencent Legu
libshell, libshella
Ijiami
libexec, libexecmain
DexProtector
varies
Identify before reversing. Second analyst spends hours where the first
spent weeks.
10. Version matrix
API
Change
Effect on malware
23
Runtime permissions; overlay becomes special access
In-context prompts
24
User CAs untrusted by default; obscured-touch filtering in Settings
Interception harder; deactivation blocking harder
26
Background execution limits; TYPE_APPLICATION_OVERLAY; per-source install toggle; STOPPED-state rules
Watchdogs need a foreground service; droppers need a launcher icon
28
Cleartext off by default; device-admin policies deprecated
Device admin declines
29
Background activity starts restricted; DO/PO provisioning tightened
Overlay cannot be replaced by startActivity
30
Package visibility ; getInstallSourceInfo()
Target enumeration becomes visible
31
exported explicit; background FGS starts restricted; HIDE_OVERLAY_WINDOWS
Naive restart path closes
33
Restricted settings ; POST_NOTIFICATIONS runtime
Biggest single mitigation for accessibility abuse
34
FGS types enforced ; restricted settings extended
Declared type becomes a checkable claim
35
Further FGS / background tightening
Trend continues
11. Isolation rules
#
Rule
1
Emulator, not a phone
2
Snapshot before, restore after
3
No Google account
4
No SIM
5
No shared folder, clipboard or drag-and-drop
6
All egress sinkholed, or no route
7
Sample store not in a synced folder
8
Nothing leaves unhashed
9
Never on a device you care about
12. False-positive arithmetic — expect this
Measurement
Source
16,836 hits → 13,220 validator kills → 168 leads (100:1)
52-StaticAnalysis, commercial app
15 of 17 HIGH-confidence leads rejected by hand (88%)
52-StaticAnalysis
132 high-confidence hits, 132 false positives
33-Storage leak-hunter.py
12 of 14 apps had a pinning surface, only 4 pinned
36-CertificatePinning
Detector reported 18/18, truth was 13/18
38-TamperDetection
1,393 @kotlin.Metadata grep hits, all empty shells
42-R8
jadx console said 61 errors; tree had 2,104 refused methods
56-JADX
A hit is not a lead and a lead is not a finding.
13. One-liners
# identity + provenance + capability + persistence + native + loading
python3 -B scripts/apk-triage.py sample.apk
# corpus mode, one line each
python3 -B scripts/apk-triage.py corpus/*.apk --quiet
# machine-readable
python3 -B scripts/apk-triage.py sample.apk --json
# only the sections you want
python3 -B scripts/apk-triage.py sample.apk --only capability,persistence
# the device's record of where a package came from
adb shell dumpsys package <pkg> | grep -E 'installer|Initiator|originating|packageSource|firstInstallTime'
# every granted special access, at once
adb shell settings get secure enabled_accessibility_services
adb shell settings get secure enabled_notification_listeners
adb shell cmd appops get <pkg> SYSTEM_ALERT_WINDOW
adb shell cmd appops get <pkg> GET_USAGE_STATS
adb shell dumpsys deviceidle whitelist | grep <pkg>
adb shell dumpsys device_policy | grep -A 5 <pkg>
# is the launcher icon hidden?
adb shell cmd package resolve-activity --brief <pkg>
# before ANY trust-store claim
adb shell mount | grep cacerts
14. Report skeleton
0 Metadata analyst, date, sha256, source, analysis type, tooling
1 Identity hashes, package, versions, DEX facts, code fraction
2 Provenance signing schemes, certificates, AND what each is not worth
3 Capability the model, with every res/xml variant read
4 Persistence every hook, mechanism named
5 Native the four facts, and what they change
6 Configuration decrypted, indicators DEFANGED
7 NOT DONE the section reviewers read first
8 Conclusion close | escalate | hand over