Setting Up Emulation Environment on Ubuntu (with Marketplace): Here we are downloading and prepping a basic Ubuntu environment. We need to get Ubuntu up and running with an older version of the SDK (newer ones break proxying), the markeplace apks’s, java, and setup an Android Virtual Device:
- Install Ubuntu
- Download THIS SPECIFIC SDK Version – http://www.securityaegis.com/grabz/android-sdk_r08-linux_86.tgz
- tar -xzvf android-sdk_r08-linux_86.tgz /home/[username]/android-sdk-linux_x86
Install Java in Ubuntu via a repository provided by lffl.org:
- sudo add-apt-repository ppa:ferramroberto/java
- sudo apt-get update
- sudo apt-get install sun-java6-jre sun-java6-plugin
- Install rar – apt-get install rar
- Extract marketplace apk files to /home/[username]/Desktop/android-sdk-linux_x86/platform-tools/
- Start the AVD manager – /home/[username]/Desktop/android-sdk-linux_x86/tools/android
!!! Important, under available packages click Android Repository BUT, once it has filled everything out with various options, do *NOT* download Android SDK Tools, revision 12. This will screw you over big time. Just download the individual android image versions you need like 1.5 or 2.2. !!!
Once your AVD is running:
We need to install the apks for the android market, these are older but worked for me:
- Cd /home/[username]/Desktop/android-sdk-linux_x86/platform-tools/
- ./adb install GoogleServicesFramework.apk
- ./adb install Vending.apk
- ./adb install Gmail.apk
- Restart the AVD
- Start Marketplace and enter Google account
Getting ADB basic info:
user@dev:~/android-sdk-linux_86/platform-tools$ ./adb
Android Debug Bridge version 1.0.25
Some of the features you may want to immediately mess with are;
listing devices:
user@dev:~/android-sdk-linux_86/tools$ ./adb devices
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
emulator-5554 device
getting an interactive shell on the emulator:
user@dev:~/android-sdk-linux_86/platform-tools$ ./adb shell
# ls
sqlite_stmt_journals
cache
sdcard
etc
system
sys
sbin
proc
init.rc
init.goldfish.rc
init
default.prop
data
root
dev
cat’ing useful stuff inside that shell:
# cat /proc/cpuinfo
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 233.47
Features : swp half thumb fastmult vfp edsp java
CPU implementer : 0×41
CPU architecture: 5TEJ
CPU variant : 0×0
CPU part : 0×926
CPU revision : 5
Cache type : write-through
Cache clean : not required
Cache lockdown : not supported
Cache format : Harvard
I size : 4096
I assoc : 4
I line length : 32
I sets : 32
D size : 65536
D assoc : 4
D line length : 32
D sets : 512
Hardware : Goldfish
Revision : 0000
Serial : 0000000000000000
and probably pulling things off the file system so you can reverse them:
user@dev:~$/android-sdk-linux_86/platform-tools$ ./adb pull /data/app/com.joelapenna.foursquared.apk com.joelapenna.foursquared.apk
2441 KB/s (625416 bytes in 0.250s)
Also installing apk’s from the customer (make sure they are in the /android-sdk-linux_86/platform-tools folder ):
user@dev:~/android-sdk-linux_86/platform-tools$ ./adb install Gmail.apk
Installing Sniffers:
Wireshark:
- sudo apt-get install wireshark
- run wireshark on eth0
Burp:
- Download BurpSuite – http://portswigger.net/burp/downloadfree.html
- Extract burpsuite_v1.4.jar to desktop
- Start BurpSuite :
- user@dev:~$ java -jar -Xmx1g burpsuite_v1.4.jar
- Change its proxy from Listen on loopback interface only to Support invisible proxy for non-aware clients
Now start the AVD with the following flags. Use the following as it’s http proxy server:
- from your android-sdk-linux_x86/tools directory:
- ./emulator –avd [YOUR AVD NAME] –http-proxy http://127.0.0.1:8080
What if you get your APK’s shipped to you on a phone or you got the app through the market?
Use astro file manager to backup the apks for decompilation:
- Start Astro File Manager
- Click menu, then tools
- Then application manager/Backup
- Check you app, then click menu and backup
- Now its on you SD card, pug in your android as a usb device and grab it for decompilation.
Decompilation:
Android packages (“.apk” files) are actually simply ZIP files. They contain the AndroidManifest.xml, classes.dex, resources.arsc, among other components.
- Download apktool1.4.1.tar.bz2 and apktool-install-linux-r04-brut1.tar.bz2 from:
- http://code.google.com/p/android-apktool/downloads/list
- Extract to /usr/local/bin
- In the directory you have you apk in run:
- Apktool d {YOUR APK NAME}
- It will output a folder with decompiled java like source, dalvik.
Enumerating SQLITE3 (from Foundstone Guide):
From the ADB shell you can also run the sqlite3 command line program to query databases created by Android applications and stored in the device memory. These also may reveal sensitive information such as passwords or PINs hashed or stored in clear text. Such databases are stored with a “.db” file extension.
- Navigate to /data/data/<application>/databases/<nameofthedatabase>.db
- Execute the .table command to list all the tables and .schema <tablename> to list the structure of the table.
- You can also execute SQL commands like select * from shortcuts;
Download and Install Moshzuk for poking:
Contains the following vulnerabilities:
- Stack Overflow
- Heap Overflow
- SQL Injection
- Command Injection
- Format Strings
- Double Free
- Directory Traversal
- Race Condition
- Hardcoded Passwords
- Bad code habits
- Overblown permissions
- Bad file permissions
Source: http://www.securityaegis.com/notes-on-setting-up-an-android-pentest-lab/
If you like my blog, Please Donate Me