hakers.info » Android Penetration Testing http://localhost:8008/site Hacking made easy... Tue, 18 Oct 2011 06:20:51 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 Android Penetration Testing (PenTesting Android Apps) http://localhost:8008/site/2011/10/android-penetration-testing-pentesting-android-apps/ http://localhost:8008/site/2011/10/android-penetration-testing-pentesting-android-apps/#comments Tue, 18 Oct 2011 05:37:46 +0000 w0rm http://hakers.info/site/?p=256 A report by McAfee for last quarter states that the
‘Count of new Android-specific malware moved to number one, with J2ME (Java Micro Edition), coming in second while suffering only a third as many malware.’ In simple words if you own a Android phone, the chances of it being compromised is 2.5 times more than any other platform.

With industry reporting so many new android exploits and malwares, it is becoming a tedious job for developers to secure their applicaitons. With nearly all IT companies having expertise in Web penetration Testing solutions, they have started building solutions for Mobile Penetration testing. But whats the need of creating a different solution for mobile apps testing? Isn’t it same as web applicaiton testing? If you consider ‘Thin client’ mobile apps, the answer is yes. For thin client mobile apps, penetration testing is almost same as that of Web application testing. But If you consider ‘Thick Client’ or ‘Native Mobile Apps’ which gets installed into the device, the penetration testers have to add some more test cases and the testing environment needs a bit of tweak.
If we compare Web penetration Testing and Mobile PT, what exactly is the difference?? One of the major difference is that the user in the case of Web applicaitons do not have access to the files of application (php,asp,jsp files) whereas in the case of mobile, user has access to the application as it is installed in the device itself. All of the platforms provide some kind of databases for those applicaitons to store data(SqlLite3 in Andoid). In case of web, applicaitons only have privilages to store data temporarily using cookies or cache. One more major drawback with mobile apps is that they can be reversed very easily, whether it’s a dex(android), jar/jad(j2me) or a sis(Symbian).
For Penetration testing of Android Application we have to mainly consider the following things ;-

* Settings up the PT lab/Environment.
In this you will learn about how to setup the test environment using emulator,proxy tools. Using these proxy tools you can force emulator to pass the traffic via a proxy. But this setting only works for browser inside the emulator. For apps to work with proxy you need some different environment setting which is discussed in detail. Click here to read more..

* Using debugging tools like ADB,DDMS.
Using debugging tool like ADB you can run commands on emulator and device itself to perform any kind on action. You can get the shell,view the files stored, databases,install new apps, uninstall apps,pull and push files from the device. DDMS in just a GUI version of ADB. To get more detail about all this click here.

* Reversing Apps.
One of the major drawbacks with Mobile apps is that they can be Reversed. We have many opensource tools for reversing android apps like apktool,baksmali,dex2jar. Click here to read more about this.

Thanks for Watching.. Next article will be on “Deep Dive into Android Malwares”
Njoy!!

]]>
http://localhost:8008/site/2011/10/android-penetration-testing-pentesting-android-apps/feed/ 0
Using Adb and DDMS for Android Penetration Testing http://localhost:8008/site/2011/10/using-adb-and-ddms-for-android-penetration-testing/ http://localhost:8008/site/2011/10/using-adb-and-ddms-for-android-penetration-testing/#comments Tue, 18 Oct 2011 05:24:05 +0000 w0rm http://hakers.info/site/?p=254 Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:

* A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
* A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
* A daemon, which runs as a background process on each emulator or device instance.
Source: developers.android.com
To view the Best available description about ADB visit http://developer.android.com/guide/developing/tools/adb.html.
To see how adb can be helpful for Penetration testing of Android apps watch the video embedded below.

]]>
http://localhost:8008/site/2011/10/using-adb-and-ddms-for-android-penetration-testing/feed/ 0
Reversing and Spoofing Android Applications http://localhost:8008/site/2011/10/reversing-and-spoofing-android-applications/ http://localhost:8008/site/2011/10/reversing-and-spoofing-android-applications/#comments Tue, 18 Oct 2011 05:16:50 +0000 w0rm http://hakers.info/site/?p=251 One of the major drawbacks with Mobile apps is that they can be Reversed. If we look at the Android app architecture, it contains a source code which is developed by user. That source code is compiled and finally created as a ‘.dex’ file which is the dalvik executable. This ‘.dex’ file can be compared with ‘.jar’ file of java. Dex file clubbed with the resources files are archived to become a APK file. So this apk file is just a archive file similar to a zip file whose contents can be extracted using any archive explorer tool like winzip or 7-zip. After extracting files from an apk file you’ll get a ‘classes.dex’ file which contains the actual code of the application. This dex file can be reversed using my opensource tools like Baksmali(click here to download), dex2jar , apktool.
The video attached below will show you how we can use baksmali tool to decompile and compile the application again. The one thing which gets eliminated by this process is the Application signature. After compiling the application we need to add signature to it so that it can be installed on a device or emulator.

.
.

.
.

Hope you enjoyed it!!
We’ll upload some more tutorials for dex2jar and apktool pretty soon!!

]]>
http://localhost:8008/site/2011/10/reversing-and-spoofing-android-applications/feed/ 0
Setting up proxy for apps in android emulator http://localhost:8008/site/2011/08/setting-up-proxy-for-apps-in-android-emulator/ http://localhost:8008/site/2011/08/setting-up-proxy-for-apps-in-android-emulator/#comments Tue, 16 Aug 2011 11:52:55 +0000 w0rm http://hakers.info/site/?p=132 Proxy for Android apps not working even after u tried all proxy settings in emulator? Is your android proxy setting only working for browser not for apps in emulator?

In some of the previous posts(http://hakers.info/site/2011/08/setting-up-proxy-for-android-emulator/) we saw how to setup a proxy for android emulator using settings available in emulator itself. The problem with that approach is that it works only for the browser, it does not work with the apps installed inside the emulator. As I couldn’t find any solution for this problem in android emulator I thought of finding a work around to perform this task. One workaround I found is that we should use the base machine itself to capture the packets which emulator (the apps in emulator) is sending.

We can use many network analyzer tools like wireshark etc to capture and analyze the packets but using these tools you can only capture the packets, there is no option to tamper the packets at runtime. If there is a requirement in which you just have to capture the packets and analyze them wireshark will suffice the needs. But if you want to tamper the request and response(which we normally do using Paros/fiddler in web applications) you need to have a tool which can capture network packets and has a capability to intercept and tamper them.

One of these tools I can suggest is Echo Mirage by BindShell which has nearly all of the features we need. It uses DLL injection and function hooking techniques to redirect network related function calls so that data transmitted and received by local applications can be observed and modified. Using these techniques this tools gives you an advantage that it will attach itself to a particular ‘exe’, due to this packets of only a particular exe are captured(in case of wireshark we have to use filter as it captures each and every packet with goes out of the machine).

To setup a proxy using Echo Mirage use the steps given below:

1.)    Download latest version of Echo Mirage.

Latest version of Echo Mirage can be downloaded from:

http://www.bindshell.net/tools/Echo Mirage.html

2.)    Open Echo Mirage and emulator.

3.)    After both the applications are running, using Echo Mirage we need to inject into emulator.exe. To do so click on second tab on Echo Mirage (inject into process). Enter the process name emulator.exe or click on select process to select emulator.exe and click on start.

 

 

 

 

 

 

4.)    If everything works fine you will get a window like this.

 

 

 

5.) Echo Mirage is now ready to trap and intercept all your requests which are sent through emulator.exe.  The screenshot of interceptor below was taken when I tried to open maps application in emulator after setting up Echo Mirage.

 

You can watch this video to see how to use paros and echomirage to setup the proxy for android emulator or devices.

Hope this article was helpful to you and will further help you in penetration testing of android apps.

 

Please comment if you have some questions or you want some more clarifications.

]]>
http://localhost:8008/site/2011/08/setting-up-proxy-for-apps-in-android-emulator/feed/ 4
Setting up proxy for android emulator http://localhost:8008/site/2011/08/setting-up-proxy-for-android-emulator/ http://localhost:8008/site/2011/08/setting-up-proxy-for-android-emulator/#comments Mon, 08 Aug 2011 13:20:32 +0000 w0rm http://hakers.info/site/?p=89 Facing some issues in setting up a proxy from android emulator??

This article will tell you the steps you need to follow to set up the proxy for android applications using emulator.  For this you require three basic things i.e “Machine Connected to internet”,”Android SDK”,”Proxy Tools (Paros, Fiddler, Burpsuit etc)”. If we are ready with all these software, the first step is to setup the proxy server using any of these tools like paros, fiddler, burpsuit etc. I’ll show you how to do it with paros.

In paros go to Tool>>Options>>Local proxy and enter the address(127.0.0.1 for localhost) and port number(e.g. 8080) on which you want your proxy server should listen. Please refer to the screenshot below for the options page in paros.

Android Proxy Paros Settings

Android Proxy Paros Settings

If your machine is using a outgoing proxy server for accessing internet, you can enter these settings (including authentication details) in connection tab as shown below. Click on OK to save your setting and your proxy server is configured to listen on the address and port number you just mentioned.

Android Proxy Paros outgoing proxy settings

Android Proxy Paros outgoing proxy settings

The next step is to make some changes in emulator so that it sends all http requests to the proxy server we have just configured. The simplest method to do it is by changing the APN settings in the emulator. To change the APN settings in emulator, start the emulator and  go to Settings>>Wireless and networks>>Mobile networks>>Access Point Names and click on the APN name you are using (By default it’s Telkila). In ‘proxy’ and ‘port’ option you have to enter the address and port on which your proxy server is listening. So under proxy ideally we should write 127.0.0.1, and it should point to the localhost of the base machine, but in case of android emulator this ip will be localhost for emulator itself. To resolve this issue android emulator has some hardcoded ip addresses which will do this work for us. If we have to access base machine’s localhost the ip we have to use is 10.0.2.2. So under proxy mention “10.0.2.2” and under port mention the port number which you mentioned in proxy server (port 8080 in my case). Save your settings and your proxy setup is done.

Android Emulator Proxy Settings

Android Emulator Proxy Settings

Now if you try to open a website in emulator’s browser, proxy tool will be able to catch those requests. Now you can tamper any request and response and test your android app.

Google on Android Browser

Google on Android Browser

Tampering Request using Paros

Tampering Request using Paros

NOTE : Using this proxy environment you can only trap requests from emulator’s browser. I could not find a way through which you can trap requests going through apps installed in emulator. But you can use a alternate method to do so. My next article on ““setting-up-proxy-for-apps-in-android-emulator” will help you to do so.

You can watch this video to see how to use paros and echomirage to setup the proxy for android emulator or devices.

]]>
http://localhost:8008/site/2011/08/setting-up-proxy-for-android-emulator/feed/ 4