Triage write-up — inert-sample.apk¶
This is a MODEL WRITE-UP about a sample that is not malware.
inert-sample.apkwas written from scratch for chapter 69 of this repository. It has no payload, no C2 client, no exfiltration, no evasion and no working persistence. All of its indicators are RFC 2606.invalidnames that can never resolve. It is analysed here exactly as a real sample would be, so that the SHAPE of the deliverable is learnable without anybody having to handle live malware to learn it.Where a section would say something about a real sample that cannot honestly be said about this one, the section says so. That is not padding — the honest-limits paragraphs are the part of a malware write-up that gets read by the person who has to act on it.
0. Metadata¶
| Field | Value |
|---|---|
| Analyst | (your name) |
| Date | (date of analysis, not date of the sample) |
| Sample | inert-sample.apk |
| Source of sample | Built locally from examples/inert-sample/ by build.sh |
| Analysis type | Static only. No execution, no device, no emulator. |
| Tooling | apk-triage.py, config-decrypt.py, apksigner, jadx (optional) |
| Classification | Not malicious. Purpose-built teaching artefact. |
Definition Triage is the pass that decides what a sample deserves, not what it is. It ends in one of three outcomes: close it, escalate to full analysis, or hand it to someone with a capability I do not have (a sandbox, a corpus, a native reverser). A triage write-up that ends in a paragraph of speculation instead of one of those three has not finished.
1. Identity¶
file inert-sample.apk
size 20.8 KiB (21308 bytes)
md5 c44732c35a1f35270208a52c85b25777
sha1 36e4ec04e86768075ebe17cd09653fb8b4c43ae1
sha256 bd123b446b378f6400177fe33325f853a2882722778c90ce75a37b0c7ade3c4c
zip entries 12
package com.pentest.ch69.inert
version code=1 name=0.1-inert
sdk min=21 target=33
application allowBackup=false, extractNativeLibs=true,
hasFragileUserData=false, label=Inert Sample CH69
dex classes.dex 11.2 KiB v035 10 classes, 88 methods, 185 strings
sha256 9ef03c6f536d760aac962f30f55deacce7205fd11f9e992b75c23a83b72bfbc3
code fraction 53.9% of the file is DEX
These hashes will not match your build.
build.shgenerates a fresh signing key on every new$OUTDIR, which changes the signing block, which changes every whole-file hash. Theclasses.dexhash is stable across builds on the same toolchain; the APK hash is not. That difference is itself a lesson: when you want to say "these two samples are the same code", compare the DEX, not the container. Chapter 42 measured the extreme version of this — three APKs byte-identical in size at 12,757 bytes with DEX sizes of 7,384 / 2,920 / 7,180, becauseapksignerpads the signing block to a 4 KiB boundary.
Reading. Ten classes and 88 methods is a very small application. For a real sample that is a strong signal in one of two directions and you must decide which:
- A stage-one dropper is genuinely this small. Its entire job is to obtain one capability and install stage two.
- A packer stub is also this small, and looks almost identical, except that the real code is elsewhere in the container. The discriminator is the code fraction: a stub is a small DEX inside a large file.
Here the DEX is 53.9% of a 21 KB file, so there is no hidden bulk. This is a
small app, not a stub over a large one. apk-triage.py makes this check
explicitly and would have raised it if the fraction had been low.
2. Provenance¶
scheme APK Signature Scheme v2 0x7109871a
scheme APK Signature Scheme v3 0xf05368c0
scheme padding 0x42726577
scheme JAR signing (v1) v1
certificate APK Signature Scheme v3
subject C=XX, O=Android Security Handbook, CN=CH69 Inert Sample
issuer C=XX, O=Android Security Handbook, CN=CH69 Inert Sample
validity 260812174545Z .. 360809174545Z
serial 37ff951c
sha256 e434de8c3032b3425dfa993ea371947e9488dc12cf0be57b9d51a5a93a927b28
sha1 3f6a9ce261a5cbc8e5760ac85c8e850e2e043f35
What this establishes. One key signed this file. Any other APK carrying
certificate SHA-256 e434de… was signed by whoever holds the matching private
key. That is the cheapest and strongest corpus link available and it is the
first thing to pivot on.
What this does not establish, stated explicitly because write-ups get this wrong:
| Tempting conclusion | Why it is wrong |
|---|---|
| "Self-signed, therefore suspicious" | Every Android app is self-signed. This is not a signal at all. |
"O=Android Security Handbook, therefore attributed" |
The subject fields are free text chosen by whoever ran keytool. They are worth recording and worth nothing as evidence. |
| "The validity dates tell us when it was built" | They tell you what was typed into keytool. They are attacker-controlled. |
| "Same certificate, therefore same actor" | Usually a strong link — but private keys leak, get sold, and get reused by shared build infrastructure. The CN=Android Debug key is on millions of unrelated APKs and links nothing. |
| "The signature is valid" | This tool did not check. It parsed the certificates out of the signing block; it verified no digest. Run apksigner verify -v --print-certs and quote its output separately. |
What is absent from the file entirely, and must come from a device.
Installer attribution is not a property of the APK. It is recorded by
PackageInstallerService at install time. See chapter 09 §5.5, and ask the
device:
# host — the device's record, not the file's claim
adb shell dumpsys package com.pentest.ch69.inert \
| grep -E 'installerPackageName|installInitiator|originating|packageSource'
Three fields matter and they are not equal:
| Field | Trust | Why |
|---|---|---|
installerPackageName |
Low | Settable with one flag: adb install -i com.android.vending. Chapter 09 measured this. |
installInitiator |
Higher | Recorded by the system from the UID that opened the install session, so it cannot be set by the caller. |
originating |
Contextual | Where the installer said the file came from, when known. |
3. Capability profile¶
The question this section answers is not "what does it do". It is "what could it do if every request it makes were granted" — which is the right question for Android, because Android malware overwhelmingly uses capability the user granted rather than capability it stole.
| Weight | Request | Capability |
|---|---|---|
*** |
SYSTEM_ALERT_WINDOW |
Draw over other apps |
*** |
REQUEST_INSTALL_PACKAGES |
Install other packages (dropper) |
*** |
READ_SMS / RECEIVE_SMS |
Read and intercept SMS |
*** |
<service> with BIND_ACCESSIBILITY_SERVICE |
Read and drive every app |
*** |
<service> with BIND_NOTIFICATION_LISTENER_SERVICE |
Read and cancel every notification |
** |
<receiver> with BIND_DEVICE_ADMIN |
Uninstall resistance |
** |
REQUEST_DELETE_PACKAGES |
Prompt removal of other packages |
** |
QUERY_ALL_PACKAGES |
Enumerate every installed app |
** |
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS |
Battery exemption |
** |
RECEIVE_BOOT_COMPLETED |
Start at boot |
* |
FOREGROUND_SERVICE, POST_NOTIFICATIONS, INTERNET |
Enablers |
The descriptors are where the real answer is. A <meta-data> in the
manifest points at a resource ID, not at behaviour. The accessibility
descriptor it names says:
res/xml-v22/accessibility_config.xml <accessibility-service>
accessibilityEventTypes 0xffffffff (typeAllMask)
accessibilityFlags 0x52
canRetrieveWindowContent true
canPerformGestures true
packageNames ABSENT -- every package
Read as a sentence: this service wants every event type, from every app on
the device, with the ability to read window contents and to synthesise taps
and swipes. A screen reader for one publisher's books does not need that. A
password-manager autofill helper names the packages it fills. The absence of
packageNames is the strongest single line in this whole document, and it
is absent from the manifest — you only see it by reading the descriptor.
The device-admin descriptor is the counter-example, and it is why "requests device admin" alone is a weak finding:
res/xml/device_admin.xml <device-admin>
uses-policies (empty)
An empty policy list means no wipe-data, no reset-password, no
force-lock. But note the counter-intuitive part: uninstall resistance
comes from being an active admin at all, not from any policy. So an empty
list is not a weaker declaration for that specific purpose, and a write-up
that says "requests no policies, therefore harmless" is wrong.
If it is real, this combination is the interesting one¶
SYSTEM_ALERT_WINDOW + accessibility + notification access + SMS + install +
QUERY_ALL_PACKAGES, in a sideloaded app, is the full device-takeover
capability set: see what is on screen, act on what is on screen, read the
second factor, suppress the alert, enumerate targets, install more. No
memory corruption is involved anywhere in that list.
4. Persistence¶
| Weight | Hook | Component | Detail |
|---|---|---|---|
** |
ContentProvider | .BootstrapProvider |
initOrder=900, exported=false |
** |
Boot receiver | .BootReceiver |
BOOT_COMPLETED, MY_PACKAGE_REPLACED, QUICKBOOT_POWERON |
** |
Foreground service | .SentinelService |
type=dataSync, stopWithTask=false |
** |
Multi-process | :guard |
One extra process |
* |
Foreground service | .GuardService |
stopWithTask=false |
The provider is the one to lead with. ContentProvider.onCreate() is
called from ActivityThread.installContentProviders(), which runs before
Instrumentation.callApplicationOnCreate(). Chapter 09 measured the gap on a
real device: provider at 11:20:31.118, Application.onCreate at
11:20:31.141 — 23 ms, and the provider is first. So any integrity check,
any "initialise security first" logic in Application.onCreate(), has already
been preceded.
The watchdog pair is declared but not implemented. The manifest has the
shape — two services, two processes, stopWithTask=false on both, each naming
the other in a constant. The Java has the restart call removed and replaced
with a log line. In a real sample you would confirm the pair on an emulator by
killing one pid and watching whether it comes back:
# emulator only, never on a device you care about
adb shell ps -A | grep com.pentest.ch69.inert
adb shell kill <pid-of-:guard>
adb shell ps -A | grep com.pentest.ch69.inert
A pair that survives killing either half but dies to am force-stop is a
process pair. A pair that survives am force-stop has a third arm, and
dumpsys jobscheduler is where it usually is.
What the manifest cannot tell you. JobScheduler, WorkManager and
AlarmManager persistence is code, not manifest. A manifest with no
persistence hooks is not an app with no persistence. This sample's string pool
mentions startForegroundService and nothing else in that family, which is
consistent with the source — but consistency is not proof, and on a real
sample you would check the string pool for JobScheduler, androidx.work and
setExactAndAllowWhileIdle before concluding.
5. Native surface¶
lib/arm64-v8a/libinertstub.so 6.8 KiB
ELF64 aarch64 entropy 3.80 has .symtab
DT_INIT=False DT_INIT_ARRAY=True DT_NEEDED=3
JNI_OnLoad=True Java_* symbols=2 RegisterNatives=True
sha256 dd06d7607c122c4a98bae5917ac460af8af4536e8437143efaffe86a1bd0267c
Two facts here change what you do next, and both come from chapter 15.
DT_INIT_ARRAY is present. Those functions run when the dynamic linker
loads the library — before dlopen returns, therefore before ART calls
JNI_OnLoad, therefore before any Java code can observe the library at all.
If you intend to instrument this library you must spawn-gate, not attach.
Attaching to a running process has already missed the window.
RegisterNatives is called and only two Java_* symbols are exported.
The library binds at least one method dynamically, and a dynamically bound
native method has no record in the file connecting it to a Java method
name. That mapping is recoverable only by hooking art::JNI::RegisterNatives
at runtime, or by reading the JNINativeMethod table out of JNI_OnLoad in a
disassembler. 52-StaticAnalysis/scripts/blindspot-recorder.js does the
former; chapter 57 does the latter.
Only one ABI is present (arm64-v8a). On a real sample this is worth a
line: a sample that ships only armeabi-v7a is targeting older or cheaper
devices, and a sample that ships x86 is either very old or expects to be run
in an emulator — which some samples check for and refuse.
6. Configuration¶
Two encrypted blobs, in the two commonest real-world shapes. Both were recovered offline, with no execution and — for one of them — with no key material at all.
assets/cfg-aes.bin — AES-128-CBC, key embedded in the DEX¶
key : aes-cbc utf8 '6b39ff0e2c7a41d5' iv=prefix
score : 0.82 (printable=1.00 json_markers=1 url_markers=3)
{
"campaign": "CH69-INERT-DEMO",
"capabilities_requested": ["accessibility", "notification_listener", "overlay"],
"fallback": [
"https://alt1.c2-example.invalid/v1/beacon",
"https://alt2.c2-example.invalid/v1/beacon"
],
"gate": "https://gate.c2-example.invalid/v1/beacon",
"pin_sha256": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"poll_seconds": 300,
"targets": [
"com.example.invalid.bank.alpha",
"com.example.invalid.bank.beta",
"com.example.invalid.wallet.gamma"
]
}
The key is a 16-character ASCII string in ConfigVault.java, passed straight
to SecretKeySpec. That is the single most common form there is, and its tell
is a static final String of length exactly 16, 24 or 32 that is never
compared and never displayed.
Under the Hood — a result worth understanding rather than skipping.
config-decrypt.py --autoreported two answers at the same score, 0.82: one withiv=prefixand one withiv=zero. Both look right in the output because the tool prints the first 4,000 bytes and the difference is 16 of them. That is CBC behaving exactly as specified: a wrong IV corrupts exactly one block — the first — and every subsequent block decrypts correctly, because each block is XORed with the previous ciphertext, which is right in both cases. When two candidate plaintexts tie, look at the first sixteen bytes.
assets/cfg-xor.bin — repeating-key XOR, recovered without the key¶
Real triage rarely hands you the key. This blob was decrypted by classical frequency analysis over the ciphertext alone:
key : statistically recovered len=14 'ch69/inert-xop'
score : 0.61 (printable=1.00 json_markers=2)
{
campaign : "CJ69-INERT/DEMO ,
"kiln_swivch": "NO/OP: vhis builf convains no gxecuvion path ,
min_battgry_pat": 15,
"next]stagg_url": "jttps8//stage2,c2-ezample.intalid-p/loader,bin",
poll]seconds"8 900.
"requkre_skm": falsg,
schema":"1,
""stage":""one
}
Twelve of the fourteen key bytes are correct, and the plaintext is readable
through the errors. You can already see the next-stage URL, the poll interval
and the campaign tag. Two positions are wrong because those columns had too few
samples for the frequency argument to settle; you fix them by eye in about ten
seconds — CJ69 is plainly CH69, so that key byte is off by one bit — and
then re-run with --key.
The point is not the last two bytes. The point is that "we encrypted the config with XOR" is not a delay, let alone a defence. The whole search took milliseconds and needed nothing from the DEX.
Indicators, defanged¶
| Type | Value | Note |
|---|---|---|
| URL | hxxps://gate[.]c2-example[.]invalid/v1/beacon |
RFC 2606 reserved — cannot resolve |
| URL | hxxps://alt1[.]c2-example[.]invalid/v1/beacon |
RFC 2606 reserved |
| URL | hxxps://alt2[.]c2-example[.]invalid/v1/beacon |
RFC 2606 reserved |
| URL | hxxps://stage2[.]c2-example[.]invalid/p/loader[.]bin |
RFC 2606 reserved |
| Package | com.example.invalid.bank.alpha |
Fictional |
| Package | com.example.invalid.bank.beta |
Fictional |
| Package | com.example.invalid.wallet.gamma |
Fictional |
Warning — an indicator is a claim about the past, not the present. A hostname in a config is what the author intended at build time. Whether it ever served anything, whether it still does, and who controls it now are three separate questions that this analysis cannot answer and that no amount of static work will. Passive DNS and public reporting answer them. Writing "C2 server: gate.c2-example.invalid" without that caveat produces a blocklist entry that may be a parked domain, a sinkhole, or a shared CDN.
7. What was not done, and why¶
This is the section most write-ups omit and the one a reviewer reads first.
| Not done | Why | What it would have added |
|---|---|---|
| Execution | Static-only analysis by choice. The chapter's rule is that a sample runs on a disposable emulator or not at all, and no emulator was used for this pass. | Runtime behaviour, actual network traffic, the runtime-registered receiver surface, whether the watchdog actually restarts. |
| Signature verification | apk-triage.py parses the signing block; it verifies nothing. |
Whether the file is internally consistent, and whether a v1/v2 mismatch exists (the Janus shape). Run apksigner verify -v --print-certs. |
| Full manifest audit | Owned by 32-Manifest/scripts/manifest-audit.py. |
Exported-component posture, provider grant flags, permission protection levels, the targetSdk version matrix. |
| Container audit | Owned by 10-APK-Internals/scripts/apk-container-triage.py. |
Duplicate entries, LFH/CDFH divergence, trailing bytes, signing-block smuggling. |
| Decompilation | Not needed for this sample; 88 methods were readable from the string pool and the manifest. | On a real sample, always. jadx -d out then 52-StaticAnalysis/scripts/static-sweep.py out. |
| Corpus pivot | No corpus was available. | Whether the signer hash or the DEX hash appears elsewhere. This is usually the highest-value single step and it needs infrastructure a lone analyst does not have. |
| Splits | The sample is a single APK. | On a real target, run everything against every path pm path <pkg> returns. Chapter 38 hit a large app showing zero controls in base.apk because its code shipped in splits. |
8. Conclusion¶
inert-sample.apk is not malicious. It is a purpose-built teaching
artefact that carries the declarations of a capable sample and the
implementation of none of them. Every capability path terminates in a log
statement, every indicator is an RFC 2606 reserved name, and the source is
shipped alongside the file.
If this were an unknown sample, the correct triage outcome would be escalate, not close, and the reasoning would be:
- The accessibility descriptor requests every event type from every package, with gesture dispatch. That alone justifies full analysis.
- Notification access plus SMS permissions is a second-factor interception capability.
REQUEST_INSTALL_PACKAGESin a 21 KB app is the dropper shape.- Provider persistence plus a two-process service pair is deliberate survivability engineering, which benign utilities do not do.
- An encrypted config naming three target packages is target selection.
Any one of those five is a lead. Together they are a plan for the next four hours, which is what triage is for.
What triage still could not say, and would have to be answered by a dynamic pass in isolation and by a corpus search:
- Whether the capability is used, or merely requested.
- Whether the C2 hostnames were ever live.
- Whether the signing key appears on other samples.
- Whether the sample refuses to run in an emulator — which, if it does, is itself a classification signal and not merely an obstacle.
Related¶
../README.md§5.11 — how to write this document../labs/lab-03-attribution-and-its-limits.md— produce your own version../../80-Appendix/README.md— the repository's templates and severity rubric