Week 5 - Analysing Android Apps Flashcards
adb - SDK tool
Most commonly used to interact with devices and emulators (install new apps, gain a shell on the system, read system logs, forward network ports, or do a multitude of other useful tasks).
Monitor - SDK Tool
Useful for viewing processes running on a device and taking screenshots of the device’s screen (useful for pen testers who need to gain evidence of an action for reporting purposes).
android - SDK Tool
Used to manage and create new Android emulators.
aapt - SDK Tool
Converts code into binary form to be packaged with apps.
Also useful for reverse-engineering APKs by converting app binaries to readable text.
Physical Devices vs Emulators
Emulators provide root access by default, physical devices do not.
Emulators do not operate correctly for certain apps (eg: USB, headphones, Wi-Fi, Bluetooth, etc) that require physical hardware.
Emulators do not allow making/receiving real phone calls (this can, however, be emulated to a degree using an interface).
Android Apps and the Common User
Users may or may not pay attention to permission requirements when installing.
Users experience apps through app UI.
As analysts, we are more interested in what happened behind the scenes when the app installed.
How did this app reach your device?
How did it go from a packaged download to an installed app that can be used securely?
Android OS
Consists of a stripped-down and modified Linux kernel, with some differences.
It includes an application virtual machine for running Java-like apps.
Each app is usually assigned its own unique user ID (UID) (10000 to 99999) and group ID (GID).
Special accounts like “system” and “root” exist.
Developers must assign unique package names to their apps.
Dalvik VM
A Google-customized Java Virtual Machine (JVM) bundled with core libraries.
It was designed to replace the JVM on resource-constrained hardware.
Multiple can run simultaneously.
They run Dalvik bytecode, converted from Java code into Dalvik Executable (DEX) files using the dx SDK utility.
Use Just In Time (JIT) compilation, which dynamically compiles bytecode into machine code during each app run.
Android Runtime (ART)
Each Android app runs in its own process with its own instance of ART.
Uses Ahead Of Time (AOT) compilation, translating the entire bytecode into machine code during app installation.
AOT compilation is a one-time event during installation, and it doesn’t require compilation at runtime.
Uses more storage space but offers faster execution.
Android Package (APK)
Android apps are usually distributed in the form of zipped archives with file extension .apk (Android Package)
APKs contain code, resources, and metadata.
aapt - APK Packaging Process
Converts XML resource files to binary form.
Source code and output from aapt are compiled into .class files by Java compiler.
aidl - APK Packaging Process
Converts .aidl files to .java.
Source code and output from aidl are compiled into .class files by Java compiler.
dx utility - APK Packaging Process
Converts .class files to a single classes.dex file.
apkbuilder tool - APK Packaging Process
Combines all resources, both compiled and non-compiled, and the DEX file into an APK.
jarsigner tool - APK Packaging Process
Signs the APK.
zipalign tool - APK Packaging Process
Aligns app resources for optimal loading into memory, reducing RAM usage.
/assets - APK Folder Structure
Contains files to bundle with the app.
/res - APK Folder Structure
Contains activity layouts, images, etc., for code access.
/lib - APK Folder Structure
Contains native libraries bundled with the application, split by CPU architecture.
/META-INF - APK Folder Structure
Contains the app’s certificate, inventory list of files in the zip archive, and their hashes.
classes.dex - APK Folder Structure
Executable file containing the app’s Dalvik bytecode.
AndroidManifest.xml - APK Folder Structure
Contains app configuration information, including security parameters.
resources.asrc - APK Folder Structure
Contains strings and resources that can be compiled into this file instead of being placed in the res folder.
Installing Packages
Google Play could have required users to visit a website (through Google Play app) and select their desired app.
GTalkService is invoked when the user clicks “Install.”
GTalkService maintains a connection to Google via a pinned SSL connection.
Users can also install APKs from other stores, including Samsung Apps, Amazon Appstore, GetJar, SlideMe, F-Droid, and others.
Users may install any APK of their choice through an Android SDK tool called Android Debug Bridge (ADB).