Skip to content

69 — Malware Analysis: FAQ

Real questions, including the ones people are embarrassed to ask. Full treatment in README.md.

This chapter ships no live malware. Every sample here was written from scratch, is inert, and uses RFC 2606 .invalid indicators.


1. How do I know if an APK is malicious?

You do not, from the file alone, and any tool that tells you it does is lying to you.

What you can determine from the file is capability: what this app could do if every request it makes were granted. What you determine from the device is provenance: how it got there. What you determine from a dynamic pass is behaviour: what it actually did, on the paths you exercised.

The judgement is then a comparison:

Question If the answer is worrying
Is there a plausible feature behind each request? You cannot find the UI for it
Is the capability scoped? An accessibility service with no packageNames
Does it hide? activity-alias plus setComponentEnabledSetting
Does it persist beyond its function? Provider + boot + a process pair + stopWithTask=false
Is the config encrypted, and does it name other apps? Almost always the decisive one

A legitimate app very rarely encrypts a configuration file that lists other applications by package name.


2. Is it safe to install a suspicious APK just to have a look?

Not on a device you use. Ever.

Not because installing is inherently dangerous — the sandbox is real, and an app cannot trivially root your phone — but because:

  • Your phone has your accounts signed in, and an app the user "just looked at" can be granted accessibility during that look.
  • Your phone has a SIM, and premium-rate SMS costs money.
  • Your phone has your contacts, your photos and your notification stream.
  • You cannot restore your phone to a known state afterwards. An emulator snapshot takes two seconds.

The habit is the point. This chapter itself did not install anything on the attached device, even though the sample it built is provably inert and was written by the same person who was analysing it.

If you want to look, look statically first. Section 8 of the README is forty minutes of work that requires no execution at all, and it answers most questions.


3. What is a dropper, exactly?

A sample whose only job is to get a second sample onto the device.

It is small, it looks harmless, and it is the only thing a store or a scanner usually sees. Its capability set is narrow and recognisable:

  • REQUEST_INSTALL_PACKAGES
  • a launcher Activity — often with nothing in it
  • frequently accessibility, so it can press "Install" and "Allow" for the user
  • sometimes REQUEST_DELETE_PACKAGES, to remove itself once stage two lands

Why the separation exists. Review and scanning happen at distribution. Whatever gets reviewed is the dropper, and the dropper genuinely does nothing bad. The payload arrives afterwards, over a channel nobody reviews.

Dropper versus stager. A dropper installs a package, which leaves a second app on the device that you can find. A stager loads code into the current process, through DexClassLoader or dlopen, and leaves nothing to find.


4. Why does it ask for accessibility? What does that actually give it?

Three things, and no other single grant on Android gives all three:

  1. Read the content of every window in every app. Not screenshots — a structured tree of every visible string, every content description, and (with one flag) the resource id of every view. That crosses the app sandbox completely.
  2. Act on every window. dispatchGesture() synthesises taps and swipes at arbitrary coordinates, delivered by the system, so they carry the system's authority.
  3. Be kept alive and restarted by the system, because a disabled screen reader is a device the user cannot recover.

Put together, that is a general-purpose remote control for the device.

It is not a bug. The framework must be able to do those things to serve somebody who cannot see the screen. The security boundary is the user reading a dialog, and that is the whole boundary.


5. Can malware survive a factory reset?

Almost never, for ordinary Android malware, and this is worth being precise about because the folklore is confused.

Where it lives Survives a factory reset?
An installed app (/data/app) No — /data is wiped
App data (/data/user/0/<pkg>) No
External storage (/sdcard) Usually no on modern devices; the userdata partition is wiped
A device-admin or profile-owner app No — still in /data
An app restored from a cloud backup afterwards Effectively yes — the reset worked and the user reinstalled it
A pre-installed app in /system or /vendor Yes — those partitions are not wiped
A modified boot image or recovery Yes — but this needs bootloader access
A firmware-level implant Yes — supply-chain compromise, not app malware

So the honest answer is: a factory reset removes ordinary Android malware. The realistic failure modes are the last four rows, and two of them are not app malware at all.

The one that catches people in practice is the backup restore: the user resets, then restores from Google Drive, and the app comes back because it was in the backup. Advise a reset without restore, and a manual re-setup.


6. Everyone says "the sandbox holds". Then how does anything get stolen?

Because the sandbox controls what apps can do to each other, and it says nothing about what a user may choose to grant.

Think of it as two different questions:

  • "Can app A read app B's files?" — the sandbox answers this, and the answer is no.
  • "Can the user authorise app A to read app B's screen?" — the sandbox does not answer this at all. The accessibility framework does, and its answer is yes, by design.

Every capability in section 3.1 of the README lives in the second question. None of them is a sandbox bypass. That is exactly why signature and exploit detection do so badly here.


7. Why do I need to hash the file first? Is that not just bureaucracy?

Three reasons, and each has bitten somebody:

  1. It is the only unforgeable identifier in the whole process, and it is the key you use to ask whether the world already knows this file.
  2. It proves you did not modify it. Analysts modify samples constantly and accidentally — unzipping in place, letting a tool rewrite the archive, opening it in something that "helpfully" repairs it. Without a starting hash you cannot tell.
  3. A hash is admissible and a memory is not. If the analysis ends up anywhere formal, "the file I looked at had this SHA-256" is a fact.

It takes two seconds. Do it before anything.


8. What is the difference between a hit, a lead and a finding?

Borrowed from chapter 52, and it is the single most useful distinction in the whole repository:

  • A hit is one match on one line of one file.
  • A lead is one distinct value or construct, with every site it appears at attached to it.
  • A finding is a lead that has survived validation: it really is there, it is reachable, you know who can reach it, and you know what reaching it gets them.

The measured ratios are sobering. Chapter 52 swept a commercial app: 16,836 hits → 168 leads → 15 of 17 high-confidence leads rejected by hand. Chapter 33's leak hunter returned 132 high-confidence hits, all 132 false positives.

Expect the same here. apk-triage.py deliberately prints "signals", not findings, and has no verdict line.


9. The tool printed fifteen signals. Is the app malicious?

No. Fifteen signals is fifteen things worth thinking about.

For this chapter's own inert sample the tool printed exactly fifteen, and the sample is provably harmless — it was written for the chapter and every code path ends in a log statement.

What matters is which signals and whether they form a coherent set aimed at one outcome. Five of the fifteen justified escalation; ten were context. The README's §9.3 walks that judgement.


10. Why is my config decryption producing garbage?

In descending order of likelihood:

  1. There is a wrapper you have not stripped. base64(gzip(aes(json))) is common, and trying AES on the base64 text fails. config-decrypt.py peels layers automatically; if you are working by hand, check for 1f 8b (gzip), 78 (zlib) and pure-base64 alphabets first.
  2. The key is derived, not literal. Read the derivation. Common inputs: the package name, the signing certificate hash, ANDROID_ID, a build property.
  3. Wrong mode or wrong IV. If only the first sixteen bytes are garbage and the rest is fine, that is CBC with a wrong IV — the IV is probably the first 16 bytes of the blob.
  4. It is not encrypted, it is compressed or it is a protobuf. High entropy is not evidence of encryption.
  5. The decryption is native. The key may never exist as a Java string.

11. Can I just decompile it and read the code?

Sometimes. Four things get in the way, and you should check for all four before concluding that the code is boring:

  1. Packing. The real DEX is not in the file. Look for a stub-sized classes.dex inside a large APK.
  2. Runtime loading. InMemoryDexClassLoader takes a ByteBuffer; nothing touches disk.
  3. Native code. The logic may be entirely in a .so.
  4. Decompiler failure. Chapter 56 measured jadx's console reporting errors, count: 61 while the output tree contained 2,104 refused methods across 1,424 files — a 30× under-report. Count the tree, not the summary.

And a fifth, subtler one: chapter 56 also built a case where a method decompiles to clean, warning-free Java that returns 100 while the bytecode returns 105. Decompiled Java is evidence toward a finding, not the finding.


12. What does it mean when I run the sample and nothing happens?

Six possible causes, and only one of them is "it is benign":

  1. It never started — check the process list and take a liveness measurement.
  2. It was absorbed by a dialog. Chapter 51 measured exactly this: am start was swallowed by a pending permission prompt and all nine observation channels went silent.
  3. The trigger has not fired — many samples wait for a reboot, a screen unlock or a specific app coming to the foreground.
  4. The C2 is down or sinkholed, so the sample has nothing to do.
  5. It is time-gated.
  6. It detected your environment and declined.

Cause 6 is a result, not an obstacle. Characterise the checks statically first, so you can tell 6 apart from 1.


13. How much can I say about who wrote it?

Very little, honestly, and the professional move is to say so.

Evidence Strength
Same signing certificate SHA-256 across samples Strong — but keys leak and are sold
Same unusual structure, custom protocol, bespoke crypto Strong — but builders exist
Same C2 infrastructure Medium
Same distinctive strings Weak — shared SDKs manufacture this constantly
Same permission set Very weak
Same packer Very weak — it is a commercial product
Language of comments, timezone in timestamps Essentially nothing — all copyable, and false flags are cheap

Publish the chain of inference so a reader can disagree with a specific link. And when you do not know, the sentence is "No family association was established" — not "possibly related to X", which becomes somebody's citation.


14. Why does a dropper have an app icon if it wants to hide?

Because of a platform rule that has nothing to do with UI: an app that has never been launched is in the STOPPED state, and a stopped app receives no broadcasts at all — not BOOT_COMPLETED, not MY_PACKAGE_REPLACED, nothing.

The only way out of the stopped state is an explicit user action, which in practice means one tap on an icon.

So the shape you learn to recognise is: a launcher Activity with a trivial or absent layout, which shows a message or asks for something and calls finish() — and then, on many samples, the icon disappears, because an <activity-alias> carrying the LAUNCHER filter was disabled with setComponentEnabledSetting().

You can confirm the disappearance on a device:

adb shell cmd package resolve-activity --brief <pkg>   # returns nothing
adb shell dumpsys package <pkg>                        # disabledComponents

15. Is device admin still a big deal?

Much less than it was, and this is a genuine platform success story.

It mattered because an active device admin cannot be uninstalled — the package manager refuses. That gave uninstall resistance with no exploit at all, which is why it was the standard persistence mechanism for Android ransomware and early banking trojans.

Then: API 24 filtered obscured touches on the deactivation screen; API 26 deprecated several policies; API 28–29 deprecated or ignored most legacy policies for ordinary admins; API 29+ put device owner and profile owner behind provisioning a sideload cannot reach; API 33 added restricted settings.

So in a modern sample, BIND_DEVICE_ADMIN is often legacy code or a genuine MDM agent. Weight it medium and falling, and read the policy XML.

One counter-intuitive fact to keep: uninstall resistance comes from being an active admin at all, not from any policy it requested. An admin with an empty <uses-policies> still resists uninstall. "Requests no policies, therefore harmless" is wrong.


16. What is RegisterNatives and why does everyone keep mentioning it?

There are two ways a Java native method reaches C:

  • Statically: the C function is named Java_<pkg>_<Class>_<method>, the runtime finds it with dlsym, and the name is in the ELF symbol table. A purely static read recovers the whole mapping.
  • Dynamically: JNI_OnLoad calls RegisterNatives() with a table of {name, signature, function pointer}. The C function can be static and therefore absent from every symbol table. Nothing on disk says which Java method it serves.

That is why chapters 15, 51 and 52 all name it as the same blind spot, and why it is the concrete reason native reverse engineering is not optional in this discipline. Recovery is runtime (hook art::JNI::RegisterNatives) or manual (read the table out of JNI_OnLoad in a disassembler).


17. Why do I have to spawn-gate instead of attaching with Frida?

Because of the load order:

dlopen("lib.so")
  -> relocations
  -> DT_INIT, then every DT_INIT_ARRAY entry      <-- code runs HERE
  -> dlopen RETURNS
  -> ART calls dlsym("JNI_OnLoad") and invokes it
  -> System.loadLibrary() returns to Java

Everything in the third line finishes before ART even knows the library exists. Attaching to a running process has missed it. Hooking JNI_OnLoad has missed it. You must own the process before the linker runs, or hook android_dlopen_ext.

apk-triage.py reports DT_INIT_ARRAY presence precisely so that you know to change technique before you waste an hour.


18. Do I really need an emulator? My phone is rooted anyway.

Root makes a phone more dangerous to use for this, not less. A rooted phone has weakened exactly the boundary you would be relying on.

But the real argument is snapshots. Chapter 51 puts it exactly right: a restorable baseline is the one job an emulator does better than any phone. Every dynamic run should start from an identical state, and the only way to get that on a phone is a factory reset per run.

And there is a specific measured trap: the repository's rooted test device has an APatch trustusercerts module that promoted an interception CA into the system store — 139 certificates in a tmpfs over /system/etc/security/cacerts. A successful intercept there proves nothing about whether the app trusts user CAs. Before any trust-store claim: adb shell mount | grep cacerts.


19. What do I write when I could not finish?

Write what you did, what you did not, and why — as its own section, near the end. It is the section reviewers read first.

Use these sentence patterns:

Instead of Write
"The app is clean" "No attributable change was observed on the exercised paths"
"The method is unreachable" "No static path was found from an exported component to this method"
"Possibly related to family X" "No family association was established"
"Configuration could not be recovered" "Configuration is encrypted with a key derived at runtime from X; recovery requires execution, which was out of scope"

Nobody is impressed by a report that claims completeness. Everybody is helped by one that says exactly where its knowledge stops.


Analysing a sample you lawfully possess is generally fine. Static analysis of a file is reading a file.

The things that create legal exposure are adjacent, not central:

  • Obtaining samples. Downloading from a live distribution site may involve accessing a system without authorisation. Use a reputable sharing platform with terms you have read.
  • Running it. If it reaches out and touches somebody else's infrastructure — including a sinkhole you do not own — that is a network action from your address.
  • Sharing it. Distributing working malware is an offence in many jurisdictions regardless of intent.
  • Interacting with the C2. Connecting to an attacker's server, even to "see what it says", is unauthorised access to somebody's system.

This chapter deliberately requires none of those. Everything in it is done against a sample the reader builds from source that ships alongside it.


21. The sample is packed. Have I lost?

No, and this is the most encouraging fact in the chapter.

The manifest and the resources cannot lie about their own names, because the platform is the consumer and the platform matches by name. So from a file you cannot decompile at all, you still get:

  • the complete capability profile — permissions, component declarations, every res/xml descriptor
  • the complete persistence profile — providers, receivers, services, processes
  • the provenance — signing block and certificates
  • the native surface

What you lose is the behaviour, and that is what the dynamic pass is for.

Also: chapter 40 records that a packer is a one-time cost — days to weeks for the first analyst, hours for the second, because the unpacking method generalises across every app protected by that product. Identify the product from the .so names before you reverse anything.


22. Where do I get samples to practise on, without doing anything stupid?

This chapter ships one. examples/inert-sample/ builds an APK with the shape of a capable sample and the function of none of it. Four labs drive it end to end. That is the right place to start, because you can check every tool's output against ground truth that is printed in the source.

Beyond that, in rough order of risk:

  1. Build your own. Modify the inert sample; add a hook and see whether your tooling catches it. Zero risk, high learning rate.
  2. Deliberately vulnerable apps (this repository uses several) — not malware, but real targets for the static pipeline.
  3. Academic datasets with published terms.
  4. Commercial sharing platforms with an account and terms you have read.

Do not download from a live distribution URL in a report. Do not accept a sample by email from somebody you do not know.