Top8StepsForMobile AppAssessmentFocus

Presented by: Christopher Crowley

Presentation
Resource Thumbnail

The "Top 8 Steps for Mobile App Assessment Focus" segment covers key cybersecurity concepts, including Application Assessment, Mobile Device Security, Network Security, Code Assessment, Inter-process Communication (IPC), Filesystem Content, Methodology, Tools, and Distributions, as well as the importance of Maintenance. These concepts are crucial for a thorough and effective mobile app assessment, enabling the identification of potential security vulnerabilities in mobile applications.

Full Transcript / Content

--- Page 1 --- Top 8 Steps for Mobile - Application Assessment Christopher Crowley @CCrowMontance All Rights Reserved All Wrongs Reversed --- Page 2 --- Top 8 Steps --- Page 3 --- Top 8 Mobile Device Security Steps 1. Enforce Device Passcode Authentication 2. Monitoring Mobile Device Access and Use 3. Patching Mobile Devices 4. Prohibit Unapproved Third-Party Application Stores 5. Control Physical Access 6. Evaluate Application Security Compliance 7. Prepare an Incident Response Plan for Lost or Stolen Mobile Devices 8. Implement Management and Operational Support --- Page 4 --- Each of These 8 Steps Are Important - Each step needs to be: - Considered - Planned - Executed - Maintained - We’ll focus on Application Assessment today - But there are plenty of other items for your mobile deployment --- Page 5 --- Application Assessment --- Page 6 --- Application Assessment Considerations --- Page 7 --- Consideration for Application Assessment - Consider what your objectives are: - Maintain access to organization data - Detect / Prevent loss of data - Detect / Prevent unauthorized modification to data - Leverage employee assets for work purposes? - Protect organizationally owned assets? - Assist employees to protect personal devices? --- Page 8 --- Application Assessment Planning --- Page 9 --- Planning – What is (Un)Acceptable - Two methods for app assessments - Thorough inspection of all app capabilities - Predetermined “red flags” which would prohibit use of application - Example: accesses contacts and copies them off device - Example: tracks location and sends off device - Example: access to photos / photo stream - Example: User login credentials sent in plain text (or logged) --- Page 10 --- Application Assessment Execution --- Page 11 --- Execution of Application Assessment - Technically involved - Even Apple and Google miss code included in applications - XCode Ghost is an example - Malicious library (with C2) included at compile time due to malicious XCode image from: https://www.fireeye.com/blog/threat-research/2015/11/xcodeghost_s_a_new.html --- Page 12 --- Methodology Helps Overcome Limitations - Having a repeatable methodology is helpful to minimize the effort, as well as help the assessor to be sure that important facets aren’t overlooked - It also helps to train the assessors - Long term program will be more productive and train junior people --- Page 13 --- SANS SEC575 - Application Report Cards - https://github.com/joswr1ght/MobileAppReportCard.git --- Page 14 --- Application Report Cards - Report Cards address - Permissions - Executable deficiencies - Local data storage and protection - Confidentiality - Integrity - Protection of network communication - Inter-process communication --- Page 15 --- Assessment Legal Preface - Consult your legal counsel - However, the notion is that assessing an application (which was legally obtained) for suitability of interoperation within your network is legal - Do so for networks only where you have written permission to perform this type of analysis --- Page 16 --- Permission to Assess --- Page 17 --- Methodology – Network - Easiest to perform without specialized tools - Put the mobile device on a network, and monitor the communication through a laptop - Challenge – TLS protected communication - Challenge – interpreting hidden or obfuscated data - Challenge – application has a trigger condition which isn’t met in your testing, obscuring some undesirable but present behavior --- Page 18 --- Methodology – Network - Two basic options - The host, windows or native linux hosts an access point - Use a VM or the host, connect a USB wired NIC, connect a wifi pineapple - My set up is often the latter, as I prefer to use linux as the intercept host – more manipulation options – ettercap, bettercap, burp, etc. --- Page 19 --- Methodology – Network – Windows as an AP - Use Windows laptop with a USB connected network card (In this case the card is a ALFA AWUS 036NHA) - Configure the USB card as an Access Point - Configure the built in wireless connection to connect to the internet - Configure the built in wireless to have Internet Connection Sharing (ICS) --- Page 20 --- Methodology – Network – Windows as an AP - Configure the built in wireless to have Internet Connection Sharing (ICS) - Install Burp CA cert into User store of device - Will use burp to monitor the communications - Lets you determine if certificate pinning is in place, and the data at risk if it is not --- Page 21 --- Methodology – Network – Windows as an AP - Mobile device <--> WAP <--> laptop w/ ICS enabled <--> Wireless <--> Internet - Interface configuration: - wireless USB - WLAN 2 - set as an access point - As admin run – (disable wlan the other wireless interface) netsh wlan set hostednetwork mode=allow ssid=montance key=itisntreallyaword netsh wlan start hostednetwork --- Page 22 --- Methodology – Network – Linux VM - Kali VM - USB NIC passed to Kali VM - Connect device to wifi pineapple as an AP - Run wp4.sh script (My Juiced Up Wifi Pineapple Script SANS Pentest blog for details on my little tweaks to make life easy) https://pen-testing.sans.org/blog/2014/05/07/my-juiced-up- wifi-pineapple-configurator-script --- Page 23 --- Methodology – Network - Transparent firewall rules can direct traffic into a proxy - Or device can be configured to use a proxy --- Page 24 --- Methodology – Network - Either way, proxy is viewing (and can modify) the content --- Page 25 --- Methodology – Network - How to deal with TLS? - Easiest way is to include proxy’s certificate - Burp serves up a .der format file, so convert it openssl x509 –inform der –outform pem –in cacert.der –out cacert.pem python –m SimpleHTTPServer 9090 - Browse to system, collect cert (http://172.16.42.42:9090/) - Install Cert: Settings – Security – “Install from Storage” - Select “cacert.pem” --- Page 26 --- Methodology – Network - TLS continued - Later Android requires an APK rewrite - Decompile using apktool - Edit res/xml/network_security_config.xml - Recompile using apktool <network-security-config> <base-config> <trust-anchors> <certificates src="system" /> <certificates src="user" /> </trust-anchors> </base-config> </network-security-config> --- Page 27 --- Methodology – Network - Get “man in the middle” - Here the cert issuer for www.google.com is my Burp Suite CA – “PortSwigger CA” - Apps vary on how they deal with this depending on how they’re programmed - Cert pinning may be in use --- Page 28 --- Methodology – Network - Additionally, full packet capture (PCAP) via tcpdump, dumpcap, wireshark, etc. during assessment --- Page 29 --- Methodology – Network - You have the benefit of control of the application while you’re doing this work - Don’t rush, provide ample time between actions to help to isolate what you’re reviewing - Record the time of every action you take, use this to correlate to network activity - Search traffic for all (unique) data that you input, also potentially hashes, we’ll talk about code review next --- Page 30 --- Methodology – Network - Wireshark conversations view --- Page 31 --- Methodology – Code Assessment - By reviewing the code, there is an opportunity to see more than the behavior of the app during your observation - You can see all of the things the application is programmed to do - This is more complex than evaluation of network - Requires tools to assist with the code assessment --- Page 32 --- Acquire Application to Assess - Android – a couple of options - Install app, use ES FileExplorer to backup apk - Tool like RealAPK Leecher to pull from Play store - iOS - Must have a jailbroken phone to extract application, but network/behavioral assessment can be done without jailbroken phone - Jailbroken phone: collect executable from within the install directory - Decrypt with gdb or dump_decrypted --- Page 33 --- Acquire Application to Assess - Using ES File Explorer, go to “App” Section - Long press the app of interest. Once selected, choose “backup” - Get the file from the device (I used adb with a USB connection) adb pull /sdcard/backups/GuitarTuna_4.0.2.apk - We now have the application to assess - APK files are just zip files --- Page 34 --- Unzip and View Manifest - Since the Android app is just a zip file, we can unzip it. - Make a copy in a sub directory (just in case something goes wrong) - Unzip file using 7-zip, or any zip utility - Start with AndroidManifest.xml to see permissions declared java –jar AXMLPrinter2.jar AndroidManifest.txt | more - AndroidManifest also declares Activities (windows / interfaces) and intents --- Page 35 --- Unzip and View Manifest - We see the permissions declared, and have an idea of what the app can do - The Manifest is long, and declares several things - In this app, we see a lot of Facebook integration (not pictured) --- Page 36 --- Look at Decompiled Code - With some understanding of the behavior and the permissions, we might want to see in detail what the program does - There are multiple decompilation tools (dex2jar, Procyon) - Jad-X is an easy and free one – providing decompiled Java that is readable directly from the .apk - Others: JEB ($), dex2jar/JD-GUI - In this app, I reviewed the facebook integration, as well as the billing information --- Page 37 --- Obfuscated Code - Tools to obfuscate the code: Dexguard, Proguard, DexProtector - Developer defined methods and variables only - Simplify can help here – removes dead / excessive code private String a(String str, String str2, Boolean bool) { int length = str.length() / 2; int length2 = str2.length() / 2; this.b[0] = str.substring(0, length); this.b[1] = str.substring(length); this.c[0] = str2.substring(0, length2); this.c[1] = str2.substring(length2); return bool.booleanValue() ? this.b[1] + this.c[0] + this.b[0] + this.c[1] : ""; } Jadx Before Simplify private String a(String str, String str2, Boolean bool) { return bool.booleanValue() ? this.b[1] + this.c[0] + this.b[0] + this.c[1] : ""; } Jadx After Simplify --- Page 38 --- Obfuscated Code (2) - Read the code, refactor the code, rename the code - JEB (commercial tool) lets you do that right in the tool - Cheap way: - jad-x decompile at command line - open project in android studio - Read code, refactor methods and variables (globally renames) - Josh Wright has a great webcast on this --- Page 39 --- Methodology – Inter-process Communication - Android – use of “intents” - Android components: - Activities - Services - Content Providers - Broadcast Receiver - iOS – chroot (sandbox) with minor exceptions for data sharing between apps - Document provider (shares with other apps) - Document picker (can import) - Action extension - Custom keyboard - Also, URL handlers such as “twitter://” --- Page 40 --- Methodology – Inter-process Communication - Assessing the IPC is involved in both platforms - Drozer is very helpful for this on Android - iOS no automated tool yet to help with exploration of IPC - Concern of action extension for exposure of app to active content returned into application context - Challenge is time, and exploring potential content provided --- Page 41 --- IPC - Drozer - Install Drozer application on Android - In this case, I’m using adb based connection: adb forward tcp:31415 tcp:31415 drozer console connect - See the attack surface: run app.package.attacksurface com.ovelin.guitartuna - See the Activities: run app.activity.info com.ovelin.guitartuna --- Page 42 --- IPC - Drozer - See the attack surface: run app.package.attacksurface com.ovelin.guitartuna - See the Activities: run app.activity.info com.ovelin.guitartuna --- Page 43 --- IPC - Drozer - See the Activities (a user interface screen): run app.activity.info com.ovelin.guitartuna --- Page 44 --- IPC – “Extras” - Can now go look in the code (probably easiest with dex2-jar) to see if any of the Activities that accept “extras” – with the inter process communication - If so, there is an opportunity for an external application to communicate with this app, there’s an opportunity for abuse --- Page 45 --- Methodology – Filesystem Content - If you have rooted or jailbroken phone, pull full filesystem contents - tar, dd, etc. - If you don’t, you can make a backup of the phone (or specific app) - Android Example: adb backup -f myfile.ab com.company.package Note: in my experience, adb backup crashes without filename for single packages --- Page 46 --- Methodology – Filesystem Content - If you get an encrypted backup, you’ll need to decrypt the content - backupdecrypt.pl - Only through version 1 - android-backup-extractor - abe.jar - Need to add Java crypto library support (see abe.jar README) --- Page 47 --- Methodology – Filesystem Content - java -jar abe.jar unpack myfile.ab decrypted.ab - tar -xvf decrypted.ab - Enjoy the volume of data to inspect! - Sqlite databases frequently encountered --- Page 48 --- Android – items to inspect - As you’re seeing, there’s a lot of work involved in assessing the app - The report cards provide a checklist of items to review --- Page 49 --- Methodology – Tools - Tools to be able to do this work; still extensive manual work - https://bit.ly/crow-gmob has a tool list - https://github.com/tanprathan/MobileApp-Pentest- Cheatsheet --- Page 50 --- Methodology – Distributions - There are some pre-built distributions which give you an environment to work from - MobiSec (SecureIdeas) - Androlab (androl4b) - Santoku Linux (from NowSecure) - Kali Linux - Give you the benefit of the tools already set up - Probably doesn’t have everything you need, but a good start --- Page 51 --- Maintenance - For app assessment, maintain the program through updates to approved applications - Improve analytical capability - Keep up to date on attacker trends - Enhance organizational security posture - Develop exercises --- Page 52 --- Summary - Brief walk through of the idea of application assessment - Develop a program - Develop methodology - Test on an ongoing basis - Twitter: @CCrowMontance - This and other presentations: https://bit.ly/crow-cell-eaves

Related Q&A

  • Q: Overview
    A: Presentation details for Top8StepsForMobile AppAssessmentFocus