text
stringlengths
0
1.99k
official GitHub and website didn't offer such old versions of the app. We
then created BinExport files for all OATs and present the results of the
full cross-comparison below. All confidence scores were above 98%.
```txt
,-org.tm.archive_7.2.4.2
| | 1./ ,-org.thoughtcrime.securesms_7.2.4
| 2. | 88% | 2./ ,-org.thoughtcrime.securesms_7.12.2
| 3. | 80% | 88% | 3./ ,-org.thoughtcrime.securesms_7.22.2
| 4. | 77% | 84% | 91% | 4./ ,-org.thoughtcrime.securesms_7.32.2
| 5. | 71% | 78% | 84% | 89% | 5./
| 6. | 69% | 76% | 81% | 86% | 94% | 6. -org.thoughtcrime.securesms_7.42.2
```
Two clear outcomes of this cross-comparison of app versions are visible:
Versions that are closer also show, unsurprisingly, a higher similarity
score. The similarity is also high between the app clone TM SIGNL and
Signal, even though additional functionality was added that allows for
"archiving" messages. This also holds for app versions close to the version
used as basis for our TM SGNL build.
No table is needed for comparing Organic Maps to Signal versions: Any
version of Signal scores only 6% similarity with Organic Maps. The
confidence plummets as well to less than 30%.
However, BinDiff reports a similarity of 85% with a confidence of 98% for
the original and obfuscated versions of Organic Maps.
--[ 5 - A Bit of an Outlook
> Warning: API levels rising.
Creating BinExport files takes a long time for complex apps and if a use
case like clustering is the goal, we're looking at days of preprocessing.
As mentioned, the oatdump output contains many details about the binary
code, and we started working on a proof-of-concept binexport2oatdump tool,
included in this submission.
The idea is simple: use the presented commands to compile an APK to an OAT
file (takes seconds), run oatdump (takes seconds), parse the output (takes
about a minute, they are large), and then just create a BinExport protobuf
(protocol buffer) file, containing all disassembly information one would
need Ghidra for.
We implemented this as a Python script that can utilize all the information
oatdump provides to speed up the preprocessing step. We have exact function
boundaries with mnemonics and resolved branch targets if they are known at
compile time. We can parse the Dalvik code to create the call graph instead
of trying to reverse it from the binary information. Functions contain
basic blocks in one sequence without weird branches (except thunks). Our
PoC successfully creates BinExport files from oat files an order of
magnitude faster than Ghidra.
> But ...
But it currently makes BinDiff run an order of magnitude longer for
calculating a similarity score. For clustering, this is the opposite of
what we want. The preprocessing step only runs once per app, so it scales
linearly with the number of apps: O(n). But the comparison runs between
each app pair, O(n^2). (Well, half of that but big-O doesn't care about
such details). Out of time, out of ideas, and motivated to test in
production, we've still attached our work in progress and will continue
improving it. For now, dear reader, you have the choice between slow
preprocessing and slow comparisons. Hopefully, not for long, then
comparisons will be fast, robust, and useful to you!
Just one more thing. We talked about how apps are using native libraries
for performance. Integrating them into a code-analysis framework always
required to bridge the gap between Dalvik and machine code. If we have the
Dalvik code as binary, though, we don't need to bridge a gap that doesn't
exist. We're working on using our trick of using dex2oat not just to
process an app's Dalvik code, but also its native libraries, making
holistic app analysis and comparison possible. Until then, you can use your
favorite binary tooling to analyze them all without having to maintain two
toolchains.
--[ 6 - A Bit of Summary and Thanks
> ceterum censeo scientia vult esse libera
In a system as complex as Android, change is the only constant. The fact
that Dalvik is unique to this ecosystem does not make it easy to maintain
tools, and so a lot of things that once were useful become more error-prone
with time. But this evolution also opens up new possibilities.
We looked at how Android changed and how it currently builds and executes
apps. The problems this creates, but also the doors this opens. We walked
through the process of creating binary odex files from APKs and how to
prepare them for BinDiff. We show that it's practical to compare apps and
that this approach even applies free code normalization, removing some
obfuscations in the process of recompilation.
Finally, we also provide a PoC script showing that there is significant
speedup to be gained: Sidestepping the long disassembly process and
utilizing oatdump to create BinExport files directly. This hack will make
code-based similarity scalable for a large amount of apps and allow hunting
for suspicious APKs, be it to find clones, for malicious apps, just for
fun, or for profit.
It's our pleasure to submit this work to Phrack, which inspired not only
this line of work but also our enthusiasm for looking behind the curtain,