<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Posts - Anand Tiwari</title>
  <subtitle>Sharing what i&#39;ve learned.</subtitle>
  <link href="https://anandtiwari.com/feed.xml" rel="self"/>
  <link href="https://anandtiwari.com/"/>
  <updated>2017-04-25T00:00:00Z</updated>
  <id>anandtiwari.com/posts</id>
  <author>
    <name>Anand Tiwari</name>
    <email>anandtiwarics@gmail.com</email>
  </author>
  
  <entry>
    <title>Hack Android Application Through Exposed Components</title>
    
      <link href="https://anandtiwari.com/posts/2017/04/Hack-Android-Application-Through-Exposed-Components/"/>
    
    <updated>2017-04-25T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2017/04/Hack-Android-Application-Through-Exposed-Components/</id>
    <content type="html">&lt;p&gt;In this blog, we&#39;ll walk through how we can use exposed components to perform attack on android application.&lt;/p&gt;
&lt;p&gt;The first thing strike in mind what is components ? well component is an entry point through which the system or user can interact with app and some components depend on others.&lt;/p&gt;
&lt;p&gt;There are four different types of app components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Activity&lt;/strong&gt; : An activity is the first thing which allow users to interact with app. It represents a single screen with a user interface. For example an password storing app first activity is login page and second activity is show your list of password already saved into application. As such, a different app can start any one of these activities if the app allows. For example, a camera app can start the activity in the email app that composes new mail to allow the user share a picture.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Service&lt;/strong&gt; : A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons. It is a component that runs in the background to perform long-running operations or to perform work for remote processes. For example music player.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Broadcast receivers&lt;/strong&gt; : Broadcast Receivers simply respond to broadcast messages from other applications or from the system. For example, applications can also initiate broadcasts to let other applications know that some data has been downloaded to the device and is available for them to use, so this is broadcast receiver who will intercept this communication and will initiate appropriate action.Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Content Providers&lt;/strong&gt;: We can simply say &amp;quot;Content Providers are used to share data between the applications&amp;quot;. Through the content provider, other apps can query or modify the data if the content provider allows it. For example, the Android system provides a content provider that manages the user&#39;s contact information. As such, any app with the proper permissions can query the content provider, such as ContactsContract.Data, to read and write information about a particular person.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Intents&lt;/strong&gt;: Intent is used to invoke components. It is mainly used to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start the service&lt;/li&gt;
&lt;li&gt;Launch an activity&lt;/li&gt;
&lt;li&gt;Display a web page&lt;/li&gt;
&lt;li&gt;Display a list of contacts&lt;/li&gt;
&lt;li&gt;Broadcast a message&lt;/li&gt;
&lt;li&gt;Dial a phone call etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Test Application:&lt;/h2&gt;
&lt;p&gt;I&#39;m using sieve vulnerable app for the demonstration of the vulnerabilities. Sieve is A ‘Password Manager’ App, showcasing some common Android vulnerabilities created by MWR Labs.&lt;/p&gt;
&lt;h2&gt;Viewing Manifests&lt;/h2&gt;
&lt;p&gt;We&#39;ll get the manifest file using apktool :&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/1.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/2.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now you can analyze the manifest file and list all activity to check the exposed data through activity and explore application functionality. Some time activity exposing user sensitive data by calling activity without providing credential which cause expose users sensitive data.&lt;/p&gt;
&lt;h2&gt;Activity Manager (am) :&lt;/h2&gt;
&lt;p&gt;Within an adb shell, you can issue commands with the activity manager (am) tool to perform various system actions, such as start an activity, force-stop a process, broadcast an intent, modify the device screen properties, and more.&lt;/p&gt;
&lt;p&gt;$ adb shell am start -n &amp;lt;package_name&amp;gt;/&amp;lt;activity_name&amp;gt;&lt;/p&gt;
&lt;p&gt;Let&#39;s call the .PWList/ activity and check the list of password saved into application.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/3.png&quot; width=&quot;600&quot; height=&quot;50&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/4.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;We can use the Drozer a semi-automatic framework developed by MWR InfoSecurity, which help us to extract exposed component of the application and perform attack on the application.&lt;/p&gt;
&lt;p&gt;Drozer uses an agent (APK) which is installed on the device and provides a shell for executing the commands. First, download drozer agent from MWR Labs website and install it on the tested device/emulator. After installing the agent, launch the app and turn-on the agent.&lt;/p&gt;
&lt;p&gt;After that, set up a port-forward so that your PC can connect to a TCP socket opened by the Agent inside the emulator, or on the device:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;             $ adb forward tcp:31415 tcp:31415&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then launch the drozer console.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;             $ drozer console connect&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/5.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Lets search the target application package name using drozer command.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/6.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Check application attack surfaces.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/7.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;As we can see there are 3 Activities, 2 Content Providers, and 2 Services are exported. For further, we can analyze  all exported attack surfaces.&lt;/p&gt;
&lt;p&gt;Lets start with the activities :&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/8.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;There are three packages are listed. Lets check hidden Activities.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/9.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;In picture we can see some hidden activities are listed which could may expose user sensitive information.&lt;/p&gt;
&lt;p&gt;Executing the following command will launch an activity.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/10.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Exploiting Insecure Content Providers&lt;/h2&gt;
&lt;p&gt;A common root cause of content provider problems is the fact that they are not explicitly
marked as exported=&amp;quot;false&amp;quot; in their manifest declarations because the assumption is
that they follow the same default export behavior as other components.&lt;/p&gt;
&lt;p&gt;Lets explore the content providers in sieve application try to understand the vulnerabilities.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/11.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;This reveals that two content providers don’t require any permissions for users who want
to read from or write to them. However, the DBContentProvider requires that users have
permissions to read from or write to the /Keys path.&lt;/p&gt;
&lt;p&gt;Lets check the content URIs.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/12.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Using Drozer list of URIs&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/13.png&quot; width=&quot;610&quot; height=&quot;450&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;The newly discovered path is /Passwords. This does not have any permissions protecting it, and querying this URI leads to the disclosure of all the accounts stored in this password manager. Here is the command for querying this content URI:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/14.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;The content provider leaked the all the stored password but the developer of the application was clever and encrypted or obfuscated the password field.&lt;/p&gt;
&lt;p&gt;Lets scan for SQL injection and try to figure out whether we can extract information from content providers.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/15.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Looks like injection in projection. We can confirm sql injection by providing single quote into the projection which causes an error in the structure of the query that SQLite received.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/16.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;You can now use this injection point to find all the tables available in the same SQLite database by using a projection of * from sqlite_master where type=&#39;table&#39;--.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/17.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Lets extract the data from key table&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/android-app/18.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Great... Here we got the login password and pin of the application. This shows a complete compromise of the password manager’s master password and pin used to protect the data.&lt;/p&gt;
&lt;h2&gt;Conclusion:&lt;/h2&gt;
&lt;p&gt;In this article we walk through the android application components and technique to exploit them. We also understand the Drozer framework to perform security Assessment on Android Application.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>CTF Mr-Robot 1 Challenge</title>
    
      <link href="https://anandtiwari.com/posts/2016/08/CTF-Mr-Robot-1-Challenge/"/>
    
    <updated>2016-08-04T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/08/CTF-Mr-Robot-1-Challenge/</id>
    <content type="html">&lt;p&gt;If you looking to start real pentesting and want to hack any box or do real time pentesting I would suggest start with the CTF.&lt;/p&gt;
&lt;p&gt;Mr-Robot – CTF Let’s takes this challenge and cracks this CTF. You can get the VM from VulnHub.&lt;/p&gt;
&lt;p&gt;If you want to do pentesting on any target you should have to start with these following steps&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reconnaissance&lt;/li&gt;
&lt;li&gt;Scanning.&lt;/li&gt;
&lt;li&gt;Exploitation.&lt;/li&gt;
&lt;li&gt;Gaining Access.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let’s start with Reconnaissance and Scanning phase on the target and get the valuable information to use for future steps.&lt;/p&gt;
&lt;p&gt;So here I have target IP is “192.168.56.103”. Let’s do Nmap scan to know about the open ports on the target IP.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/1.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;As we got the nmap result and we found that there are two ports are opened 80 and 443 and Apache service is running on.&lt;/p&gt;
&lt;p&gt;Let’s browse this on port 80.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/2.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Whenever I do testing me always using Nikto to start first point of scan the target and get some information. It is also important for web application to spider the host. Let’s do both things.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/3.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/4.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;So here what we interesting things found after scans.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Robots.txt is a text (not html) file you put on your site to tell search robots which pages you would like them not to visit. Robots.txt is by no means mandatory for search engines but generally search engines obey what they are asked not to do.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/wp-login/&lt;/code&gt; :
word press admin path found.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let’s check the Robots.txt file and explore the unhidden paths.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/5.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Wawoo !! we found first flag as key-1.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/6.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Let’s check the second path.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/7.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Seems that its contain huge amount of word list.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/8.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now let’s check the other part of the scan which is wp-loin page.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/9.png&quot; width=&quot;610&quot; height=&quot;450&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;The first thing in my mind pop-up with that we should have to do brute force attack on login page to get the username password.&lt;/p&gt;
&lt;p&gt;We previously found the huge amount of word list data while exploring robots.txt file.&lt;/p&gt;
&lt;p&gt;Before moving the next step we should have to check for removing duplicate value from the fsocity.dic.&lt;/p&gt;
&lt;p&gt;root@kali:~#sort fsocity.dic | uniq &amp;gt; sorted.dic&lt;/p&gt;
&lt;p&gt;Now we have sorted.dic file with removed duplicate values.&lt;/p&gt;
&lt;p&gt;Let’s move the next step and figure out the username by bruteforce using burp intruder.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/10.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/11.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Here we found three correct usernames ELLIOT, elliot, Elliot.&lt;/p&gt;
&lt;p&gt;Now it’s time to get the password using same method by burp intruder.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/12.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Here we go… and found password as ER28-0652.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/13.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now it’s time to get the root access on the machine.&lt;/p&gt;
&lt;p&gt;We can upload the php shell into wordpress and get the reverse shell on it.&lt;/p&gt;
&lt;p&gt;I previously aware about the pentestmonkey php-reverse shell http://pentestmonkey.net/tools/web-shells/php-reverse-shell let’s download this and upload in the .php page.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/14.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/15.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Boom !!! we got the shell as daemon. Now let&#39;s figure out the flags inside the box.&lt;/p&gt;
&lt;p&gt;After checking some file systems and folders got that in home &amp;gt; robot folder containing two files as key-2-of-3.txt, password.raw-md5.&lt;/p&gt;
&lt;p&gt;Here we got the second flag in key-2-of-3.txt file.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/16.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Oh!! Wait… we don’t have access on this file.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/17.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Let’s check the second file password.raw-md5.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/18.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Looks like this is password of user robot as MD5. We need to crack this password as we know we can use John the Ripper tool.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/19.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Congrats!! we got the robot user password. Next is to login into as robot user.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/20.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;When you try to su robot here I got the error. Let’s get as terminal by using python.&lt;/p&gt;
&lt;p&gt;python -c &#39;import pty; pty.spawn(&amp;quot;/bin/sh&amp;quot;)&#39;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/21.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/22.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Here we got the second flag key-2-of-3.txt&lt;/p&gt;
&lt;p&gt;822c73956184f694993bede3eb39f959&lt;/p&gt;
&lt;p&gt;Now the next thing in my mind to go into root folder and get check the what data are stored into.&lt;/p&gt;
&lt;p&gt;But wait we don’t have permission. We need to get the root privilege.&lt;/p&gt;
&lt;p&gt;No luck to get any clue after all the file systems and folder I checked. Now it’s time to check what applications installed under which privilege.&lt;/p&gt;
&lt;p&gt;After checking the all file folders finally got to know that there is nmap installed as root privilege which will useful to get the root privilege.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/23.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;After googling and reading many article got to know that –interactive help us to escalate the privilege.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/24.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/robot-ctf/25.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;And finally catch the third flag into key-3-of-3.txt&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Windows Mobile Application Security Testing - Part 6</title>
    
      <link href="https://anandtiwari.com/posts/2016/03/Windows-Mobile-Application-Security-Testing-Part-6/"/>
    
    <updated>2016-03-02T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/03/Windows-Mobile-Application-Security-Testing-Part-6/</id>
    <content type="html">&lt;p&gt;In this article we will learn how to analysis the local storage of device and will look into way to do static analysis by doing reverse engineering. If you had not yet rooted your device please read my previous article where I have written the process to root the device.&lt;/p&gt;
&lt;p&gt;Exploring application binaries, .NET assemblies, and other assets&lt;/p&gt;
&lt;p&gt;In device installed applications have two main directories one is where application binaries, .NET assemblies assets are stored and another is app’s local storage directory where the app can store the local data.&lt;/p&gt;
&lt;p&gt;All installed app have their own installation directory located at &lt;code&gt;D:\Computer\Windows Phone\Phone\Data\PROGRAMS\{GUID}\Install\.&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/1.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Also each app has its own local storage directory which run in their own filesystem sandbox. The local storage directory for an app is located at &lt;code&gt;D:\Computer\Windows Phone\Phone\Data\Users\DefApps\APPDATA\{GUID}&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/2.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Application Manifests file&lt;/h2&gt;
&lt;p&gt;Let&#39;s start with Manifest file of application which give us information about the application and their structure which help us to understand about the application.&lt;/p&gt;
&lt;p&gt;In Windows Phone 8 Manifests file name as WMAppManifest.xml in XAP files and in Windows 8.x application Manifests name as Package.appxmanifest in APPX packages.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/3.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Manifest file support multiple XML elements, some of them are interesting as security view.
Capabilities (&lt;Capabilities&gt;) - Which defines the capabilities required by the application.
File Type Association (&lt;FileTypeAssociation&gt;) - Which defines the file extensions that are associated with the application.
Protocol (&lt;Protocol&gt;) - Defines URL schemes that the app wishes to register for Activatable Class (&lt;ActivatableClass&gt;) - Defines classes that are used by the app that are external to it.
Interface(&lt;Interface&gt;) - Specifies interfaces that the app implements that are external to it&lt;/Interface&gt;&lt;/ActivatableClass&gt;&lt;/Protocol&gt;&lt;/FileTypeAssociation&gt;&lt;/Capabilities&gt;&lt;/p&gt;
&lt;p&gt;Check the capabilities&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capabilities&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_IDENTITY_DEVICE&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_IDENTITY_USER&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_LOCATION&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_MICROPHONE&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_NETWORKING&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_PHONEDIALER&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_PUSH_NOTIFICATION&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_SENSORS&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_WEBBROWSERCOMPONENT&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_ISV_CAMERA&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_CONTACTS&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_APPOINTMENTS&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_MEDIALIB_AUDIO&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_MEDIALIB_PHOTO&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_MEDIALIB_PLAYBACK&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;Capabilities&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Seems that application using Capability Location, Microphone, Networking, phone dialer, contacts, Medialib Photo. These all susceptible and collecting user information.
Analysis Local Storage
As we know that application need local storage to save or cache file and folder for further uses. Lets analysis the local storage of the application into device.&lt;/p&gt;
&lt;p&gt;Application data — &lt;code&gt;C:\Data\Users\DefApps\APPDATA\{GUID}\...&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Install directory — &lt;code&gt;C:\Data\Programs\{GUID}\Install\...&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here are the some interesting folders to analysis the local storage.&lt;/p&gt;
&lt;p&gt;Framework Temp - Some framework temporary data storing.&lt;/p&gt;
&lt;p&gt;INetCache - Storing webView cache files&lt;/p&gt;
&lt;p&gt;INetCookies - Storing WebCookies data.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/4.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;INetHistory - Storing History of the web pages&lt;/h2&gt;
&lt;p&gt;Local - This is the folder where most of the application storing sensitive data. Also we can call isolated storage of application.&lt;/p&gt;
&lt;p&gt;LocalLow - Low integrity code execute in this folder. Code executing with low integrity can only write to a small number of locations on the disk, such as the LocalLow folder you mentioned. (FOLDERID_LocalAppDataLow)&lt;/p&gt;
&lt;p&gt;PlatformData - The system will create a directory in the top level of the app’s isolatedstorage.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/5.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Let&#39;s move into the local storage &amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;D:\Data\Users\DefApps\APPDATA\{513D7B13-D7A9-4B59-ACB0-B4629E4A7EEE}\Local&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/6.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;So above we have list of all local storage data. &lt;code&gt;__ApplicationSettings&lt;/code&gt; and userdata seems that storing sensitive data. Lets open the &lt;code&gt;__ApplicationSettings&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Wooo!! application login username and password stored plain text in__ApplicationSettings&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/7.png&quot; width=&quot;510&quot; height=&quot;420&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now check the userdata database file where all data has been stored.&lt;/p&gt;
&lt;p&gt;In order to open userdata.sdf file which is in the form of SQL Server compact database we need to use sdf viewer or Compact Viewer.&lt;/p&gt;
&lt;p&gt;You can download &lt;a href=&quot;https://sourceforge.net/p/compactview/home/Home/&quot;&gt;CompactView_1.4.12.0&lt;/a&gt; and install in your system.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/8.png&quot; width=&quot;600&quot; height=&quot;450&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Okay, so here we got the database where all data has been stored. But seems that data has been encoded into some numeric value. To get the know about which numeric value these data has been encoded we have to do reverse engineering and from the code let&#39;s understand the data encoding.&lt;/p&gt;
&lt;h2&gt;Reverse Engineering on the Application&lt;/h2&gt;
&lt;p&gt;In order to analyzing application binaries we have to extract all application binaries and .NET assemblies from the device where application installation files has been installed. Move into install directory &lt;code&gt;C:\Data\Programs\{GUID}\Install\..&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;D:\Data\PROGRAMS\{513D7B13-D7A9-4B59-ACB0-B4629E4A7EEE}\Install&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/8.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Okay, after extract all the binaries from the device we’ll going to disassembled/decompiled and analyzed by doing manual testing. It is also need to review source code.&lt;/p&gt;
&lt;p&gt;Most of the .dll files are seems that googleAds and GoogleAnalytics but we have to decompiled application .dll file. PhoneApp5.dll is seems that application .dll file. Let’s decompile this file using ILSpy. Its allow you to decompile .NET assemblies.&lt;/p&gt;
&lt;p&gt;Now let&#39;s load the PhoneApp5.dll file into ILSpy and decompile assemblies.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/9.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/10.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;As above picture you can view all the class has dicomplied and we are able to view C# code. Now let&#39;s review the code and figure-out some security issue.&lt;/p&gt;
&lt;p&gt;We can start looking into .net Libraries, namespace and classes. So let’s start from first class AboutUs as by name it&#39;s look like all information about the application.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/11.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;If you look into the code, he has embedded his name with his mail ID. Which will used for further attacks. Many time and most of the application you can able to extract information about developers. Let’s move other classes.&lt;/p&gt;
&lt;p&gt;On the top of the class you can review the .net Libraries which will help you to figure out security issues.&lt;/p&gt;
&lt;p&gt;Here in the action class if you look on the top you can see there are some Libraries list.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;GoogleAds&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;GoogleAnalytics&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;Microsoft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Phone&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Controls&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ComponentModel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Diagnostics&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;IO&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;IsolatedStorage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Windows&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Windows&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Controls&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Windows&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this class action  using &lt;code&gt;System.IO.IsolatedStorge&lt;/code&gt; which mean that the class using IsolatedStorage to store data.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/12.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;If you look into snippet code username and password storing into &lt;code&gt;__ApplicationSettings()&lt;/code&gt; without doing any encryption that found in our local storage analysis into &lt;code&gt;__ApplicationSettings&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Lets move another classes to check for local storage database.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;GoogleAnalytics&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;Microsoft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Phone&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Controls&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;PhoneApp5&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;MyClasses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Diagnostics&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Linq&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Windows&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Windows&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Controls&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;using &lt;span class=&quot;token class-name&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Windows&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Navigation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you look into these Libraries list there is using &lt;code&gt;System.Linq&lt;/code&gt; namespace provides classes and interfaces that support queries that use Language-Integrated Query (LINQ).&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/13.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;In this picture if you look closely &lt;code&gt;UserDataContext&lt;/code&gt; is publicly used class were DB connection established and created as &lt;code&gt;userdata.sdf&lt;/code&gt; database file were all the data has been stored.&lt;/p&gt;
&lt;p&gt;Next things all Bank data has stored and updated by class userDataContext. If you look closely in the code before storing data into database they parse with Function Scramble.&lt;/p&gt;
&lt;p&gt;In our local storage analysis we got userdata.sdf database file and using compactView we have view the data which being stored into userdata.sdf file. But data has encoded into some numeric value which is not in plain text. So the application using Scramble function to puzzle the words using some programming method.&lt;/p&gt;
&lt;p&gt;Let&#39;s look closely and figure out how the data has been decoded.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-6/14.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Okay, we manage to get the function UnScramble which is using decoding the data stored into database file while display the information to the users. Also we got he unscramble program to decode all users data from the database.&lt;/p&gt;
&lt;p&gt;By the way for this application we got the username password in plain text stored into &lt;code&gt;__ApplicaitonSetting&lt;/code&gt; file which will use to unlock the application and view all data of users. But I want to show you approach for source code review by doing reverse engineering on the application.&lt;/p&gt;
&lt;h2&gt;Secure way Storing Data in Windows Phone&lt;/h2&gt;
&lt;p&gt;If you are developer and used to save data in local storage of device then I would say saving confidential data in a phone’s isolated storage is not secure. Also if you encrypted your all data and save decryption key inside the device its not increase your security, its about how well the key is hidden.&lt;/p&gt;
&lt;p&gt;Microsoft have DPAPI (Data Protection API)to encrypt and decrypt entire isolated storage. DPAPI generating and storing a cryptographic key by using the user and device credentials to encrypt and decrypt data. You can use the Protected Data class that provides you access to DPAPI through Protect and Unprotect methods. You use the Protect method to encrypt the data and the Unprotect method to decrypt the data. On a Windows Phone device, every app gets its own decryption key, which is created when you run the app for the first time. Calls to Protect and Unprotect will implicitly use the decryption key and make sure that all the data remains private to the app.&lt;/p&gt;
&lt;p&gt;Protect and Unprotect API using optional parameter call optionalEntropy.If you are using DPAPI recommended to use OptionalEntropy because of all data protected by DPAPI on Windows Phone is encrypted using the same key. If an attacker on the device or any app is able to get access to a DPAPI-encrypted data, and if the target app not using an optionalEntropy parameter, then it can recover the data by simply calling into ProtectedData.Unprotect().So you should always use the optionalEntropy parameter if you want to use DPAPI in your apps. However hard code optionalEntropy or store it on the device will allow to attackers to decrypt entire data if he/she have full access on the device. In this case you should base it on secret passphrase known only by the app user. You can use PBKDF2 which password only the user knows.&lt;/p&gt;
&lt;h2&gt;Windows Phone local database encryption&lt;/h2&gt;
&lt;p&gt;If you want to encrypt your database you can simply use the Password property in your database’s connection string:&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create the data context.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;MyDataContext&lt;/span&gt; db &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyDataContext&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Data Source=&#39;isostore:/mydb.sdf&#39;;Password=&#39;securepassword&#39;;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create an encrypted database after confirming that it does not exist.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;/span&gt;DatabaseExists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;/span&gt;CreateDatabase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if you hard coding the key or secure credential is not good idea. As we see how we can decompile the code by doing reverse Engineering on the application and get the secrete key.&lt;/p&gt;
&lt;p&gt;In this case you can use SQLite-based database and use SQLite Encryption Extension (SEE) and SQLCipher.&lt;/p&gt;
&lt;h2&gt;Conclusion:&lt;/h2&gt;
&lt;p&gt;In this article we did analysis internal device local storage and database of the application. Also we learned secure way to store data into the device. We learned how to perform source code review by doing reverse engineering.&lt;/p&gt;
&lt;p&gt;If you want to learn more about the Windows Mobile Application security I recommend you to read
&amp;quot;&lt;a href=&quot;http://www.amazon.com/The-Mobile-Application-Hackers-Handbook/dp/1118958500&quot;&gt;The Mobile Application Hacker&#39;s Handbook&lt;/a&gt;&amp;quot;.&lt;/p&gt;
&lt;h2&gt;Reference:&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/hh487164(v=vs.105).aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/windows/apps/hh487164(v=vs.105).aspx&lt;/a&gt;
&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/hh202861(v=vs.105).aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/windows/apps/hh202861(v=vs.105).aspx&lt;/a&gt;
&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/hh133478(v=vs.105).aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/windows/apps/hh133478(v=vs.105).aspx&lt;/a&gt;
&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/system.security.cryptography.protecteddata(v=vs.105).aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/windows/apps/system.security.cryptography.protecteddata(v=vs.105).aspx&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Windows Mobile Application Security Testing - Part 5</title>
    
      <link href="https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-5/"/>
    
    <updated>2016-02-29T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-5/</id>
    <content type="html">&lt;p&gt;In this article we will going to learn how to root WP8 Nokia lumia device and inspect internal storage. I am using Nokia Lumia 720 for demo purpose. However Lumia 520, 521, 525, 620, 625, 820, 920, 925, 928, 1020 and 1320 are supported.&lt;/p&gt;
&lt;p&gt;XDA developer &lt;a href=&quot;http://forum.xda-developers.com/member.php?u=3254428&quot;&gt;Heathcliff74&lt;/a&gt; given us powerful tool &lt;a href=&quot;http://www.wpinternals.net/index.php/downloads&quot;&gt;Windows Phone Internals&lt;/a&gt; which allow to unlock the bootloader of selected Lumia Windows Phone models and after unlocking the bootloader, you can enable Root Access on the phone or create and flash Custom ROM&#39;s.&lt;/p&gt;
&lt;h2&gt;OS versions are supported&lt;/h2&gt;
&lt;p&gt;The following OS versions Root Access can be enabled. To enable Root Access, the bootloader must be unlocked first.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;8.10.12393.890&lt;/li&gt;
&lt;li&gt;8.10.12397.895&lt;/li&gt;
&lt;li&gt;8.10.14219.341&lt;/li&gt;
&lt;li&gt;8.10.14226.359&lt;/li&gt;
&lt;li&gt;8.10.14234.375&lt;/li&gt;
&lt;li&gt;8.10.15116.125&lt;/li&gt;
&lt;li&gt;8.10.15148.160&lt;/li&gt;
&lt;li&gt;10.0.10512.1000&lt;/li&gt;
&lt;li&gt;10.0.10536.1004&lt;/li&gt;
&lt;li&gt;10.0.10549.4&lt;/li&gt;
&lt;li&gt;10.0.10581.0&lt;/li&gt;
&lt;li&gt;10.0.10586.11&lt;/li&gt;
&lt;li&gt;10.0.10586.36&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In order to root your device you have to carefully follow the instruction. Download the &lt;a href=&quot;http://www.wpinternals.net/index.php/downloads&quot;&gt;Windows Phone Internals&lt;/a&gt;. The instructions you can find in the tool itself.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/1.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;I followed instruction for my lumia 720 device only may it&#39;s change for your devices, please follow the instruction accordingly.
Before rooting the device we need unlock the bootloader of the device.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/2.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now Connect you device using USB and unlock your screen. And wait for detection.
In order to unlock the bootloader of device its ask you to phone needs to be switched to flash-mode. Click on “Ok”&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/3.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now we need FFU-image file which is fresh ROM image of your device. It’s important to get the exact same FFU file for your device. To get the FFU file, you need to use &lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkID=525569&quot;&gt;Windows Device Recovery Tool&lt;/a&gt; which help you to download FFU file for your device. (You need to switch your device in normal mode by Press and hold the Volume Down and Power buttons at the same time until you feel a vibration (about 10-15 seconds). Your phone will restart automatically.)&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/4.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now Connect your device and open Windows Recovery Tool, your device will detect after some seconds.&lt;/p&gt;
&lt;p&gt;In case you&#39;r getting error while downloading ROM image from Windows Recovery Tool for your device I recommend you to restart your system as well as your device.&lt;/p&gt;
&lt;p&gt;After downloaded the ROM image for your device, the ffu file will be located to path&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C:\ProgramData\Microsoft\Packages\Products\RM-885&lt;/code&gt; in your system.&lt;/p&gt;
&lt;p&gt;Now again switch to Unlock bootloader in windows phone internals.&lt;/p&gt;
&lt;p&gt;Select your .ffu file (Fresh ROM image) which is located at path&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C:\ProgramData\Microsoft\Packages\Products\RM-885&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/5.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;You should also select a folder where you have Lumia Emergency Flash Loaders. This tool will try to select the Loader that is suitable for your phone.&lt;/p&gt;
&lt;p&gt;Select as &lt;code&gt;C:\ProgramData\Microsoft\Packages\Products\RM-885&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/6.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now it is very important to use Engineering SBL3 and be careful before using sbl3 file for you device. Make sure that the sbl3 file should work for your device otherwise your device will not work after using wrong sbl3 file.
You can download sbl3 file from xda-developers site for 520, 620, 625, 810, 820, 822, 920, 925 and the 1020.
For me lumia 720 I didn&#39;t found sbl3 file but when I research on internet someone posted that lumia 520 sbl3 file will work for lumia 720. So pleae do on your risk.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/7.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now click on continue&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/7.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;After the booting your device, as your device bootloader has been unlocked. Now move to “Enable Root Access” and click on Unlock Phone. You device will turned into flash mode and switch to Mass Storage mode. In your system you will see drive “MainOS” get active which is your device internal storage.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/8.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/9.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/10.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Root Tool&lt;/h2&gt;
&lt;p&gt;Root tool help you to edit your device registry and provide you to full access on device file system, which can easily access all internal files by only connecting your phone with your system.&lt;/p&gt;
&lt;p&gt;Previously Windows phone Internal it give you mass storage mode by flashing your phone, but root tool make your task easier in terms of file access.
&lt;a href=&quot;https://mega.nz/#F!8IJ1BICS!9gy7cFsNQQPmCSb8kF4V_A&quot;&gt;Download Root Tool&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now extract the file and Deploy .XAP file into device.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/11.png&quot; width=&quot;300&quot; height=&quot;450&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Be careful while using this tool. If you selected any wrong file path or setting may its break your device.&lt;/p&gt;
&lt;p&gt;Now select “Lumia Registry Edit”&lt;/p&gt;
&lt;p&gt;Go to options &amp;gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/12.png&quot; width=&quot;210&quot; height=&quot;160&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now click on Templates&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/13.png&quot; width=&quot;210&quot; height=&quot;350&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Select both Interop/Capability Unlock and Full FS Access with MTP &amp;gt; Now Apply the setting.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/14.png&quot; width=&quot;210&quot; height=&quot;350&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now you can able to view or edit your device internal storage without switching into flash mode.&lt;/p&gt;
&lt;h2&gt;WP8 Native Access Webserver&lt;/h2&gt;
&lt;p&gt;There is also cool way to access your device file systems. WP8 Native Access Webserver which provide you to install Client WP8 Native Access .XAP file in your device and by using port you can enable your device into webserver. You can download this app from here.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/15.png&quot; width=&quot;210&quot; height=&quot;350&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-5/16.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Conclusion:&lt;/h2&gt;
&lt;p&gt;In this article we learned how we will root our device and inspect internal storage. Next article we will going to learn attack vectors of WP8 application and their vulnerabilities.&lt;/p&gt;
&lt;p&gt;Reference:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.wpinternals.net/&quot;&gt;http://www.wpinternals.net/&lt;/a&gt;
&lt;a href=&quot;http://forum.xda-developers.com/&quot;&gt;http://forum.xda-developers.com/&lt;/a&gt;
&lt;a href=&quot;https://wp8webserver.codeplex.com/&quot;&gt;https://wp8webserver.codeplex.com/&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Windows Mobile Application Security Testing - Part 4</title>
    
      <link href="https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-4/"/>
    
    <updated>2016-02-24T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-4/</id>
    <content type="html">&lt;p&gt;Before I start this part of article I want to thanks all of you who have appreciated me for this series. I’m very excited to continue writing on WP8 application security testing.&lt;/p&gt;
&lt;p&gt;Previous article we learned setup proxy with device and perform dynamic analysis on the WP8 Applications. In this article we are going to learn analysis of Isolated storage or local file system using Windows power tool.&lt;/p&gt;
&lt;p&gt;In case you haven&#39;t rooted your device and wants to analysis dynamically local storage of the application, then this article will help you to check local storage of the application. You can able to check local storage or isolated storage for only developer signed apps using Unlocked device. If you haven&#39;t Unlocked your device yet then I recommend you to unlock your device using my part 1 article.&lt;/p&gt;
&lt;p&gt;So next we need one developer signed application for our demo purpose right. In my previous article I mention found youtube developer signed app from XDA forum. You can also download this application for your learning purpose from here.&lt;/p&gt;
&lt;h2&gt;Isolated storage&lt;/h2&gt;
&lt;p&gt;Isolated storage is used to store local data on a Windows Phone. It is &amp;quot;isolated&amp;quot; because other applications can&#39;t access this data.&lt;/p&gt;
&lt;p&gt;All I/O operations are restricted to isolated storage and do not have direct access to the underlying OS file system, which helps to provide security and prevents unauthorized access and data corruption from other apps. If you want to share data between two applications, you will need some kind of cloud-based service that can share that data for you.&lt;/p&gt;
&lt;p&gt;Microsoft has provided two way to store data locally for their developers. The first way is to collection of name/value pairs call IsolatedStorageSetting and other way is through the creation of actual files and folders called IsolatedStorageFile. We will check this later while doing static or reverse engineering analysis.&lt;/p&gt;
&lt;h2&gt;Windows Phone power Tool&lt;/h2&gt;
&lt;p&gt;As in my previous article I already written about Windows Phone Power Tool which is powerful tool to deploy WP8 Applications (Only developer signed App) and analysis isolated storage in device. We will use this tool for analysis dynamically storing data into device. If you want to install Windows Phone Power Tool please read my previous blog post.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/1.png&quot; width=&quot;610&quot; height=&quot;350&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Let deploy the Youtube application into device using WP power tool&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/2.png&quot; width=&quot;590&quot; height=&quot;300&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;You can see the information about the application in Dev Apps&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/3.png&quot; width=&quot;750&quot; height=&quot;400&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now we’ll going to inspect isolated storage. As you can see there is no data found at this time.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/4.png&quot; width=&quot;750&quot; height=&quot;400&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Lets use the application by exploring application functionality and save some data. You can also login into application using google account.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/5.png&quot; width=&quot;350&quot; height=&quot;600&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;After using the application you can refresh the app in WP Power tool by right click on application. Now you can see there are bunch of data available for inspection.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/6.png&quot; width=&quot;750&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Isolated Storage Explorer&lt;/h2&gt;
&lt;p&gt;This is one more tool which can help you to explore or modify dynamically storing data into device (isolated storage). You can download and install from here.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/7.png&quot; width=&quot;650&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Isolated Storage Explorer (ISETool.exe)&lt;/h2&gt;
&lt;p&gt;Isolated Storage Explorer (ISETool.exe) is a command-line tool that is installed with the Windows Phone SDK. ISETool provide you to explore list of Isolated Storage or you can copy and replace the files into directories of the application.&lt;/p&gt;
&lt;p&gt;This tool you can find from the following path.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\IsolatedStorageExplor&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/8.png&quot; width=&quot;650&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;ISETool.exe &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;cmd&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;:param&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;target-device&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;:param&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;product-id&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;desktop-path&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;cmd&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;:param&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; - Specifies the &lt;span class=&quot;token builtin class-name&quot;&gt;command&lt;/span&gt; to be executed &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;one of the following&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt; ts -&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;takesnapshot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; to download the contents of isolated store from &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;target-device&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; to desktop&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;    rs -&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;restoresnapshot&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; to upload the contents of isolated store from desktop to &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;target-device&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token function&quot;&gt;dir&lt;/span&gt; - lists the contents of the device folder.&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;    EnumerateDevices  - lists the valid device targets along with their device indices.&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;target-device&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;:param&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; - Specifies the target device &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;one of the following&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;    xd - default emulator&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;    de - Windows Phone device connected to the desktop&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;    deviceindex:n - device listed at index n. To get the list of devices use the following &lt;span class=&quot;token builtin class-name&quot;&gt;command&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;                    &lt;span class=&quot;token string&quot;&gt;&quot;ISETool EnumerateDevices&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;product-id&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; - Specifies the GUID of the product. This is located &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;                 WMAppManifest.xml &lt;span class=&quot;token function&quot;&gt;file&lt;/span&gt; of the project&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;desktop-path&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; - desktop path &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; download and upload&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get the list of devices use the following command&lt;/p&gt;
&lt;h2&gt;ISETool EnumerateDevices&lt;/h2&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/9.png&quot; width=&quot;550&quot; height=&quot;200&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;If you want to get application Product ID or GUID of the product which is located in WMAppManifest.xml. In order to get manifest file you have change application extension .xap to .zip and extract the file. (Only this is for developer signed applications)&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/10.png&quot; width=&quot;550&quot; height=&quot;200&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now lists the Application contents of the device folder.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\IsolatedStorageExplorerTool\ISETool.exe dir de dcbb1ac6-a89a-df11-a490-00237de2db9e&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/11.png&quot; width=&quot;550&quot; height=&quot;300&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now to download the contents of isolated store from device to desktop.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\IsolatedStorageExplorerTool

λ ISETool.exe ts de dcbb1ac6-a89a-df11-a490-00237de2db9e G:\test\
&lt;/code&gt;&lt;/pre&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/12.png&quot; width=&quot;550&quot; height=&quot;100&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-4/13.png&quot; width=&quot;350&quot; height=&quot;300&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now you can inspect all the file and folder manually. Later we will learn more about the individual files and their functionality.&lt;/p&gt;
&lt;h2&gt;Conclusion :&lt;/h2&gt;
&lt;p&gt;In this article we learned about Isolated Storage, tools and technique to inspect isolated files and folders. You can analysis the data of application and how/which data storing inside isolated storage. Later will learn more about the file and their functionality in terms of security.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Windows Mobile Application Security Testing - Part 3</title>
    
      <link href="https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-3/"/>
    
    <updated>2016-02-22T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-3/</id>
    <content type="html">&lt;p&gt;In this blog post will going to learn how will perform Dynamic analysis on Windows phone 8 Mobile applications. Previous article we learned WP8 applications and sideloading developer signed apps.&lt;/p&gt;
&lt;h2&gt;Dynamic Analysis&lt;/h2&gt;
&lt;p&gt;Dynamic analysis is way to audit any mobile applications communication which application can communicate or give away data in two way communicating with server or storing to and loading from device storage. We can dive into how to intercept request using proxy tool and how to analysis isolated storage data into device. We can analysis traffic between device and server by intercepting and modifying parameter. For application storage we can just observe the results the data that application has saved.&lt;/p&gt;
&lt;h2&gt;OWASP Zed Attack Proxy (ZAP)&lt;/h2&gt;
&lt;p&gt;Most of them are familiar with Zap proxy and using while doing Application penetration testing. Zap proxy is powerful proxy tool for intercepting traffic between client and server. It is open source tool. You can download from here.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/zap.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Intercept HTTP and HTTPS Traffic&lt;/h2&gt;
&lt;p&gt;In order to setup zap proxy and intercept request you have to install zap proxy properly. It is important to connect you system and device with same wifi network.&lt;/p&gt;
&lt;p&gt;Check your system IP address, if you connected with Wifi you should also connect your device with same Wifi.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/sysem%20ip%20addres.png&quot; width=&quot;450&quot; height=&quot;100&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now you have to put your interface IP address inside zap proxy setting. Go to Tools &amp;gt; Options (Ctrl+Alt+O) &amp;gt; Local proxy&lt;/p&gt;
&lt;p&gt;Address would be your system interface IP address (in my case 192.168.198.1)&lt;/p&gt;
&lt;p&gt;Port you can put as 8080&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/local%20proxy.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now open you device and go to setting &amp;gt; WiFi &amp;gt; select your connected wifi network.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/wifi.png&quot; width=&quot;350&quot; height=&quot;400&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Turn on Proxy and provide your system interface IP i.e 192.168.198.1 in Server/URL, 8080 in port and save the setting.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/prxymobile.png&quot; width=&quot;250&quot; height=&quot;400&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Installing Certificate&lt;/h2&gt;
&lt;p&gt;It is very important to install ZAP certificate inside your device to intercept HTTPS enabled applications. Without certificate you can’t intercept the HTTPS request and response. In order to install certificate first you have to export certificate from ZAP and then install certificate by sending certificate into device using e-mail. You can also install certificate using SD card but it may not work properly.&lt;/p&gt;
&lt;p&gt;Export the certificate from zap. Go to Tool &amp;gt; Options &amp;gt; Dynamic SSL Certificates (Ctrl+Alt+O). Now save the certificate .&lt;/p&gt;
&lt;p&gt;Fig 6. ZAP SSL Certificate&lt;/p&gt;
&lt;p&gt;Now you can save this certificate and send certificate using any E-mail. In device download certificate from the attached file. Make sure that the certificate extension should be .cer&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/certificateexport.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;And then install the certificate.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/mail%20cert.png&quot; width=&quot;350&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;In windows phone you can only install any one certificate at a time. Also WP8 does not provide a way to delete it later on.&lt;/p&gt;
&lt;p&gt;After installing ZAP certificate you can able to intercept HTTPS enabled applications in your devices.&lt;/p&gt;
&lt;p&gt;Most of peoples are comfortable with Burp proxy. In similar way you can also setup BurpProxy and certificate.&lt;/p&gt;
&lt;p&gt;But many time burp certificates are not work properly, in this case you can use ZAP outgoing proxy to divert all HTTP/HTTPS request and response traffic via burp proxy.&lt;/p&gt;
&lt;p&gt;Go to Tools &amp;gt; Options (Ctrl+Alt+O) &amp;gt; Connection and use proxy chain.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/proxychain.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Provide Burp proxy interface in address/Domain and port.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/burpporxy.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-3/inercept.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now you can able to intercept any application in device in order to do dynamic analysis.&lt;/p&gt;
&lt;h2&gt;Conclusion :&lt;/h2&gt;
&lt;p&gt;In this article we learned how we setup proxy with Windows Phone and intercept HTTPS request and response in order to perform Dynamic analysis on applications. Next article we learn analysis of Isolated storage or windows internal file system using Windows power tool.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Windows Mobile Application Security Testing - Part 2</title>
    
      <link href="https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-2/"/>
    
    <updated>2016-02-22T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-2/</id>
    <content type="html">&lt;p&gt;Previous article we learned about the windows phone 8 security basics and their features. In this article we’ll going to learn about windows phone 8 applications and sideloading developer signed app in device.&lt;/p&gt;
&lt;h2&gt;About XAP Files&lt;/h2&gt;
&lt;p&gt;XAP is the file format used to distribute and install application software and middleware onto Microsoft&#39;s Windows Phone 7/8 operating system, and is the file format for Silverlight applications. Beginning with Windows Phone 8.1, XAP will be replaced by APPX as the file format used to install apps on the Windows Phone platform, a move which was done by Microsoft in order to unify the app development platforms for Windows Store apps and Windows Phone apps.&lt;/p&gt;
&lt;p&gt;XAP files are ZIP file formatted packages. The MIME type associated with XAP files is application/x-silverlight-app.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/Unziped.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;If you downloaded app from store and wants to unzip then you can’t able to do so. It&#39;s because microsoft signed every app with DRM encryption. However if the app is developer signed then you can easily unzip the XAP file.&lt;/p&gt;
&lt;h2&gt;Encrypted and Unencrypted XAP file&lt;/h2&gt;
&lt;p&gt;The difference between a XAP file from the app store and an unencrypted XAP can be inspected by opening the XAP file headers in text editor. A limitation of encrypted XAP files downloaded from the app store is that they cannot run in emulators. When conducting penetration tests of a windows Phone application using emulators it&#39;s is required to obtain the XAP files of the application compiled by the developer, not from the Windows Store.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/Encrypted%20XAP.jpg&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/Unencrypted%20XAP.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;After some google search I found Youtube XAP unencrypted XAP file from &lt;a href=&quot;http://forum.xda-developers.com/showthread.php?t=2525841&quot;&gt;xda-developers&lt;/a&gt; forum which help us to understand the Encrypted and Unencrypted applications and difference between them.&lt;/p&gt;
&lt;h2&gt;Sideloading developer signed app&lt;/h2&gt;
&lt;p&gt;If you want to perform security testing on your client applications in un-rooted devices then you have to ask them for their developer signed app and by sideloading the App you can able to perform dynamic as well as static analysis.&lt;/p&gt;
&lt;p&gt;If you downloaded or installed app from store you will only able to perform dynamic analysis on the app. To perform analysis into internal file system (Isolated storage only) you need to get the developer signed app. Later blog post we will learn inspection of isolated storage.&lt;/p&gt;
&lt;p&gt;You can sideload your developer signed app using Application Deployment app which will installed in your system while installing SDK.&lt;/p&gt;
&lt;p&gt;Search in your system for “Application Deployment” and open the application. In case you would not found the app then you can use the system path C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\XAP Deployment located, where you can run XapDeploy.exe .&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/application%20deployement.png&quot; width=&quot;550&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;You can use any developer signed app and sideload app in your device using this application.&lt;/p&gt;
&lt;h2&gt;Windows Power Tool.&lt;/h2&gt;
&lt;p&gt;Windows power tool is very useful while doing pentesting on WP8 application. It is developed for the developers to deploy application, testing the app, check isolated storage and other useful functions. You can download this application from codeplex.&lt;/p&gt;
&lt;p&gt;However many time I face below error while installing Windows Power tool, may you can also face the same issue.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/windows%20powertool%20error.png&quot; width=&quot;380&quot; height=&quot;200&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;So it&#39;s better to install offline file which you can find from &lt;a href=&quot;http://forum.xda-developers.com/showthread.php?t=2668378&quot;&gt;XDA Developer forum&lt;/a&gt;. Download the WPPowerToolsStandaloneAmir.zip file and extract the file.&lt;/p&gt;
&lt;p&gt;Now run the WindowsPhonePowerTools.exe file.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/wp%20powertool.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;In order to connect your device with windows power tool you have to unlock your screen and then click on Connect.&lt;/p&gt;
&lt;p&gt;After you have successfully connected with windows power tool you can able to install your developer XAPs file and other useful task able to perform for analysis the application.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-2/wpowertool.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://forum.xda-developers.com/windows-phone-8/development/tutorial-deploy-xaps-easily-wpv-xap-t3263968&quot;&gt;Deploy XAPs easily with WPV Xap Deployer&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Project My Screen App&lt;/h2&gt;
&lt;p&gt;Microsoft has developed application for users to project phone screen to an external display which can using USB cable and connect with system to project phone display on systems.&lt;/p&gt;
&lt;p&gt;This app is useful for us while doing pentesting on Windows mobile application to get the display on our system.&lt;/p&gt;
&lt;p&gt;You can download application from Microsoft site Project My Screen App&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/sdk%20installation.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Conclusion :&lt;/h2&gt;
&lt;p&gt;In this article we understanding of how WP8 applications are packaged and distributed. Also we now know the sideloding developer signed app into device. Next article will learn how will do dynamic analysis on WP8 application using Device.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Windows Mobile Application Security Testing - Part 1</title>
    
      <link href="https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-1/"/>
    
    <updated>2016-02-21T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2016/02/Windows-Mobile-Application-Security-Testing-Part-1/</id>
    <content type="html">&lt;p&gt;In this article series we will learn about the tool and technique required to perform WP application security assessment. Also we’ll create Window mobile application testing environment to perform security assessment on WP applications.&lt;/p&gt;
&lt;h2&gt;Introduction: Windows phone&lt;/h2&gt;
&lt;p&gt;Windows Phone is a proprietary smartphone operating system developed by Microsoft. It is the successor to Windows Mobile, although it is incompatible with the earlier platform. With Windows Phone, Microsoft created a new user interface, featuring a design language named &amp;quot;Modern&amp;quot; (which was formerly known as &amp;quot;Metro&amp;quot;). Unlike its predecessor, it is primarily aimed at the consumer market rather than the enterprise market. It was first launched in October 2010 with &lt;a href=&quot;http://en.wikipedia.org/wiki/Windows_Phone_7&quot;&gt;Windows Phone 7&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Windows Phone 8&lt;/h2&gt;
&lt;p&gt;WP8 runs &lt;a href=&quot;http://en.wikipedia.org/wiki/ARM_architecture&quot;&gt;ARM hardware architecture&lt;/a&gt;, similar to iOS, Android, and Blackberry. WP8 migrated to the Windows NT kernel instead of Windows CE which WP7 used. WP8 also uses the Windows Phone Runtime application architecture, not identical to WinRT, to allow developers convergence between Windows 8 and WP8. Applications for WP8 may be coded in .NET (C# or VB.NET) and C++ but not JavaScript.&lt;/p&gt;
&lt;p&gt;WP8 being Windows NT kernel based allows for multiple benefits from a end user security perspective. These security controls do not help a tester but do help make the device more secure and attractive to enterprise users and decision makers.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;128-bit BitLocker for full disk encryption&lt;/li&gt;
&lt;li&gt;NTFS file system&lt;/li&gt;
&lt;li&gt;Sandboxed apps – no access to other apps&lt;/li&gt;
&lt;li&gt;SafeBoot: Secure boot with Unified Extensible Firmware Interface (EUFI)&lt;/li&gt;
&lt;li&gt;This makes it difficult for software without correct digital signature to be loaded on your Windows Phone. Something jailbreakers will need to bypass. More on the jailbreaking later.&lt;/li&gt;
&lt;li&gt;TPM 2.0 standard, requires unique keys to be burned into the chip during production&lt;/li&gt;
&lt;li&gt;All Windows Phone 8 binaries must have legit digital signatures from Microsoft to run&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;New Security Features in Windows Phone 8.1&lt;/h2&gt;
&lt;p&gt;Microsoft added some security features in WP 8.1 to secure users. A Windows Phone 8.1 mobile device is malware resistant as it uses the same technologies that are used by Windows 8.1 desktop operating system. It secures the boot process, specifically UEFI and its Secure Boot component. UEFI Secure Boot verifies that the boot loader is trusted, and then Trusted Boot protects the rest of the startup process by verifying that all Windows boot components have integrity and can be trusted. If any malware has modified any file, Trusted Boot prevents such files from launching. Unsigned apps not from the Windows Store, are unable to run on Windows Phone.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Secured enrollment with MDM systems&lt;/li&gt;
&lt;li&gt;Security policy management&lt;/li&gt;
&lt;li&gt;Lock down the phone to a specified set of applications and settings (Assigned Access)&lt;/li&gt;
&lt;li&gt;Automatically initiate VPN connections (auto-triggered VPN)&lt;/li&gt;
&lt;li&gt;Remote Assistance&lt;/li&gt;
&lt;li&gt;Remote business data removal&lt;/li&gt;
&lt;li&gt;Encryption of apps and confidential organizational data on removable storage&lt;/li&gt;
&lt;li&gt;Support for Secure and Multipurpose Internet Mail Extensions&lt;/li&gt;
&lt;li&gt;Support for enterprise Wi-Fi connectivity&lt;/li&gt;
&lt;li&gt;Support for virtual smart cards&lt;/li&gt;
&lt;li&gt;Support for new virtual private network (VPN) tunnel types.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Digital Right Management (DRM)&lt;/h2&gt;
&lt;p&gt;Microsoft signing all app in order to run into Locked device (non-developer unlocked) it’s similar to apple requires that code have a signed a binary for it to run non-jailbroken iOS device.&lt;/p&gt;
&lt;p&gt;Windows Phone 8 all app are obtained via the windows phone store. Microsoft defined all application submitted to the store are subject to Microsoft defined submission process before being accepted and code signed with a certificate issued by the aptly named Certification Authority, Microsoft Marketplace CA. Signed apps are then made available for purchase or free download to the general public who own Windows Phone 8 devices. In addition to being codesigned, applications from the Store are protected using the FairPlay DRM technology. Tampering with the XAP or APPX files being installed results in the installation being halted.&lt;/p&gt;
&lt;p&gt;All applications have to be Microsoft signed to run on WP8 or 8.1 devices. When developer mode is unlocked on a device, applications can be sideloaded, but in the context of Store applications running on the device of a standard consumer, all apps must be signed. We will learn about sideloading later.&lt;/p&gt;
&lt;h2&gt;Application Sandboxing&lt;/h2&gt;
&lt;p&gt;Windows phone 8.x closed architecture and applications are sandboxed to control their access to system resources to prevent them from accessing other application data. In windows phone 8.x all third-party applications from the store run in AppContainers.&lt;/p&gt;
&lt;h2&gt;AppContainer&lt;/h2&gt;
&lt;p&gt;AppContainer provides high level process-isolation mechanism which offers security permissions check in operating system resources such as file, registry and other resources. Windows phone 8.x all application run inside an appContainer and check app can be only its own private file sandbox. If application wants to read write outside of it, including other application data its fail.&lt;/p&gt;
&lt;h2&gt;Capabilities&lt;/h2&gt;
&lt;p&gt;Capabilities is to ability of application to access OS services such as camera or networking which controls by that app capabilities. Capabilities are also used to provision the security of the least privilege chamber (LPC) and reduce the attack surface by only provisioning ACLs for what the application requires. Applications should only be assigned capabilities which they require to perform their functionality and any unused capabilities removed.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ID_CAP_NETWORKING&lt;/code&gt;—Outbound and inbound network access
&lt;code&gt;ID_CAP_PHONEDIALER&lt;/code&gt;—Access to the dialer functionality
&lt;code&gt;ID_CAP_MICROPHONE&lt;/code&gt;—Access to the microphone API
&lt;code&gt;ID_CAP_LOCATION&lt;/code&gt;—Access to geolocation data
&lt;code&gt;ID_CAP_ISV_CAMERA&lt;/code&gt;—Access to device’s built-in camera&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capabilities&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_NETWORKING&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_WEBBROWSERCOMPONENT&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_CONTACTS&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Capability&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ID_CAP_PHONEDIALER&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;Capabilities&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Capability elements are entries in the manifest file that notify the user while installing the app of special software capabilities that your app receives.&lt;/p&gt;
&lt;p&gt;If you want to check more capability and its function you can check this in &lt;a href=&quot;https://msdn.microsoft.com/en-in/library/windows/apps/jj206936(v=vs.105).aspx#BKMK_Softwarecapabilities&quot;&gt;Microsoft site&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Prerequisites&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows 8 OS&lt;/li&gt;
&lt;li&gt;Physical Device or Emulator&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://download.microsoft.com/download/9/3/8/938A5074-461F-4E3D-89F4-5CE2F42C1E36/wpsdkv80_enu1.iso&quot;&gt;Windows Phone SDK 8.0&lt;/a&gt; (You can download from here http://download.microsoft.com/download/9/3/8/938A5074-461F-4E3D-89F4-5CE2F42C1E36/wpsdkv80_enu1.iso)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Setup Environment for Windows Mobile Applications testing&lt;/h2&gt;
&lt;h3&gt;Windows 8 OS&lt;/h3&gt;
&lt;p&gt;For test environment its required windows 8 OS because of windows phone SDK supports only on windows 8 Operating system.&lt;/p&gt;
&lt;p&gt;We also need the following system requirement for the windows application testing lab.&lt;/p&gt;
&lt;p&gt;System requirements:&lt;/p&gt;
&lt;p&gt;In the BIOS, the following features must be supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hardware-assisted virtualization.&lt;/li&gt;
&lt;li&gt;Second Level Address Translation (SLAT).&lt;/li&gt;
&lt;li&gt;Hardware-based Data Execution Prevention (DEP).&lt;/li&gt;
&lt;li&gt;4 GB or more of RAM.&lt;/li&gt;
&lt;li&gt;64-bit version of Windows 8 Pro edition or higher.
Network requirements:&lt;/li&gt;
&lt;li&gt;DHCP.&lt;/li&gt;
&lt;li&gt;Automatically configured DNS and gateway settings.&lt;/li&gt;
&lt;li&gt;In Windows, Hyper-V must be enabled and running.&lt;/li&gt;
&lt;li&gt;You have to be a member of the local Hyper-V Administrators group.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Windows Phone SDK tool&lt;/h2&gt;
&lt;p&gt;Windows SDK tool is the core tool for development and security assessment on windows 8.x. SDK tool included two of the most important tools are included one is Visual Studio and another is the emulator. Both tool you can use for reviewing code and running apps from source respectively.&lt;/p&gt;
&lt;p&gt;Visual studio is Microsoft official integrated development environment and its used for development of WP applications.&lt;/p&gt;
&lt;p&gt;You can use Visual Studio in you security assessment for&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Manually reviewing source code&lt;/li&gt;
&lt;li&gt;Running project from source on an emulator and devices&lt;/li&gt;
&lt;li&gt;You can use for debugging tools on source code.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Windows SDK installation&lt;/h2&gt;
&lt;p&gt;Download and install windows phone SDK 8 in your system. WP 8 SDK provides you with the tools that you use to development and deploy application in device. Also it’s useful for further analysis.&lt;/p&gt;
&lt;p&gt;You can download windows sdk as &lt;a href=&quot;http://download.microsoft.com/download/9/3/8/938A5074-461F-4E3D-89F4-5CE2F42C1E36/wpsdkv80_enu1.iso&quot;&gt;.iso&lt;/a&gt; format which can be write the image file to blank DVD or use mount the image file virtual as DVD devices like &lt;a href=&quot;http://filehippo.com/download_daemon_tools/&quot;&gt;DAEMON Tools lite&lt;/a&gt;.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/sdk%20installation.png&quot; /&gt;
&lt;/p&gt;
&lt;h2&gt;Windows phone Developer unlocked Device (non-Jailbroken Device)&lt;/h2&gt;
&lt;p&gt;Microsoft has provided feature to developers, sideload apps in device for debugging and testing purpose. You can unlock your device by registering your phone with windows developer phone registration which will provide you to sideload your developer signed app for testing purpose. Only the limitation of unlocked device that you can only install maximum 3 developer signed apps.&lt;/p&gt;
&lt;p&gt;We can use Developer unlocked device to sideload developer signed app and use for further WP application security analysis.&lt;/p&gt;
&lt;p&gt;To unlock the device you must should install SDK and by using developer phone registration you can successfully unlock your device.&lt;/p&gt;
&lt;p&gt;Registering your phone:&lt;/p&gt;
&lt;p&gt;To register a phone, use the Windows Phone Developer Registration tool. This is a stand-alone tool that’s installed as part of the Windows Phone SDK.&lt;/p&gt;
&lt;p&gt;Turn on your phone and unlock the phone screen.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/WP%20screen.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;On your phone ensure the date and time should correct.&lt;/p&gt;
&lt;p&gt;Connect your phone by using USB cable.&lt;/p&gt;
&lt;p&gt;On your system search app “Windows Phone Developer Registration” in start screen&lt;/p&gt;
&lt;p&gt;In case unable to find the app then you can also use this path to locate the developer registration app: &lt;code&gt;C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\Phone Registration\PhoneReg.exe&lt;/code&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/Regpath%20app.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Run the app PhoneReg.exe&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/wp%20registration.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Ensure that your phone should be unlocked the phone screen.&lt;/p&gt;
&lt;p&gt;Now click on the register and provide your any Hotmail or Microsoft account. (If you do not have Microsoft account, recommend you to register account in Hotmail)&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/wp%20registration2.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Congratulation!!! You have successfully registered your device and unlocked your device.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/windows-1/wp%20registration3.png&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now you can now able to sideload apps (only dev signed app) in your device.&lt;/p&gt;
&lt;p&gt;Conclusion:&lt;/p&gt;
&lt;p&gt;In this article we learned Windows Phone application security basics and setup the environment. Next article we learn about application files and how we’ll sideload the app and which tools we need for deploy the developer signed applications.&lt;/p&gt;
&lt;h2&gt;Reference:&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://labs.mwrinfosecurity.com/system/assets/651/original/mwri_wp8_appsec-whitepaper-syscan_2014-03-30.pdf&quot;&gt;https://labs.mwrinfosecurity.com/system/assets/651/original/mwri_wp8_appsec-whitepaper-syscan_2014-03-30.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/library/windows/apps/jj206936(v=vs.105).aspx&quot;&gt;https://msdn.microsoft.com/library/windows/apps/jj206936(v=vs.105).aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://dev.windows.com/en-us/downloads/sdk-archive&quot;&gt;https://dev.windows.com/en-us/downloads/sdk-archive&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-in/library/windows/apps/jj206936(v=vs.105).aspx#BKMK_Softwarecapabilities&quot;&gt;https://msdn.microsoft.com/en-in/library/windows/apps/jj206936(v=vs.105).aspx#BKMK_Softwarecapabilities&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>PayPal Stored XSS using XML file upload</title>
    
      <link href="https://anandtiwari.com/posts/2015/11/PayPal-Stored-XSS-sing-XML-file-upload/"/>
    
    <updated>2015-11-03T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2015/11/PayPal-Stored-XSS-sing-XML-file-upload/</id>
    <content type="html">&lt;p&gt;Hey Guys,&lt;/p&gt;
&lt;p&gt;Today I’m going to share one of my interesting Stored XSS vulnerability found on PayPal Site using XML file upload.&lt;/p&gt;
&lt;p&gt;PayPal allows the users to create an invoice and send to the other users. Also allow attaching the file into invoice. So I started trying to upload file with different types of extensions and found that PayPal allows users to upload XML formatted file.&lt;/p&gt;
&lt;p&gt;So the next steps I&#39;ve tried for XXE vulnerability but no luck which makes me happy. After couple of test cases I&#39;ve applied, but not found any interesting things to make this vulnerable.&lt;/p&gt;
&lt;p&gt;I&#39;ve noticed that if we upload XML file with script tag, which is working perfectly.&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token prolog&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Query&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;   &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;SearchTerm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://www.w3.org/1999/xhtml&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;          alert(document.cookie);&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;   &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;SearchTerm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;Query&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now next steps to exploit!&lt;/p&gt;
&lt;p&gt;The exploitation of the bug is very easy. In order to does this attack, create an invoice with xml file and send to victim. When victim open the attached xml file, the script run into his/her browser.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/4mWKE89ExNM&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;I&#39;ve reported to PayPal security team and the bug was valid. After the fix PayPal team rewarded me with Bounty under PayPal BugBounty program.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/paypal/paypal.png&quot; width=&quot;380&quot; height=&quot;250&quot; /&gt;
&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Bypass Google Drive iOS App Passcode using runtime Analysis</title>
    
      <link href="https://anandtiwari.com/posts/2015/01/Bypass-Google-Drive-iOS-App-Passcode-using-runtime-Analysis/"/>
    
    <updated>2015-01-06T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2015/01/Bypass-Google-Drive-iOS-App-Passcode-using-runtime-Analysis/</id>
    <content type="html">&lt;p&gt;Recently I was working on runtime analysis of iOS applications and found that there is way to bypass passcode by hooking into the application runtime, access &amp;amp; modify the instance variables, invoke the instance methods and override the existing methods.&lt;/p&gt;
&lt;p&gt;So i started looking for bugs in google iOS applications soon I found that google drive uses a security passcode. once the passcode is set, whenever the app is launched it prompts for the passcode. So this passcode lock can be bypassed by manipulating the iOS runtime with &lt;a href=&quot;http://www.cycript.org/&quot;&gt;cycript&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Before moving into runtime, I have quickly decrypted the app using &lt;code&gt;clutch&lt;/code&gt; and obtained the class information using &lt;code&gt;class-dump&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So now connected to the iPhone over SSH and Launch the Google Drive app and set passcode into Google Drive and also set as Always lock.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/bypass-google-drive/IMG_0126.png&quot; width=&quot;280&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Attached Drive process to &lt;code&gt;cycript&lt;/code&gt; and obtained the view controller instance.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/bypass-google-drive/1.png&quot; width=&quot;700&quot; height=&quot;300&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;The app should be sitting at the lock screen so finding out the controller that is current at the time as this is the one will want to manipulate.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/bypass-google-drive/2.png&quot; width=&quot;500&quot; height=&quot;650&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;The last line we now know the name of the lock screen view controller is &lt;code&gt;GDAPasscodeVC&lt;/code&gt;. This is the one we will want to look into.&lt;/p&gt;
&lt;p&gt;Looked at the class dump for &lt;code&gt;GDAPasscodeVC&lt;/code&gt; interface for interesting methods/variables and noticed an interesting method &lt;code&gt;userWasAuthenticated&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I&#39;ve created a variable named testing to the current &lt;code&gt;ViewController&lt;/code&gt;. This is just to make things easier for the future use. You can alternatively just type the following to get the current &lt;code&gt;ViewController&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;Cy&lt;/span&gt;#testing&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;UIApp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;keyWindow&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;rootViewController&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;visibleViewController&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;Cy&lt;/span&gt;#&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;testing userWasAuthenticated&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/bypass-google-drive/5.png&quot; width=&quot;600&quot; height=&quot;350&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;When Invoking the &lt;code&gt;userWasAuthenticated&lt;/code&gt; method directly from the the &lt;code&gt;cycript&lt;/code&gt; prompt, its logged me into the app.&lt;/p&gt;
&lt;p&gt;This is one thing we can do with runtime analysis. Typically we can manipulate the runtime to break logic checks, escalate privilege or steal information memory.&lt;/p&gt;
&lt;p&gt;Video Demonstration :&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;iframe width=&quot;660&quot; height=&quot;415&quot; src=&quot;https://www.youtube.com/embed/vhs2EZxOyGk&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;/p&gt;
&lt;h2&gt;Remediation :&lt;/h2&gt;
&lt;p&gt;We can add an extra parameter to the function that might prevent it invoking from cycript but its not a fully mitigation to protect bypassing passcode reasoning behind this is that it&#39;s practically impossible to protect the application against the attacker who can run code within the process of that application (which is what we are doing by attaching a debugger).&lt;/p&gt;
&lt;p&gt;The best way to prevent these types of attack is the server side validation. The server side validation is the proper way to protect users from these types of attack.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Password Reset Vulnerability</title>
    
      <link href="https://anandtiwari.com/posts/2014/05/Password-Reset-Vulnerability/"/>
    
    <updated>2014-05-31T00:00:00Z</updated>
    <id>https://anandtiwari.com/posts/2014/05/Password-Reset-Vulnerability/</id>
    <content type="html">&lt;p&gt;Hi guys !&lt;/p&gt;
&lt;p&gt;Today I am going to share one of my finding on password resetting vulnerability which I found recently.&lt;/p&gt;
&lt;p&gt;So while testing mostly I start with login and password resetting functionality. These two functionalities are very critical in any application. If you bypass login functionality you can take over the account and sometime by using password reset functionality you can also compromise an account. So both of these functionalities are very crucial for pentesting and application security.&lt;/p&gt;
&lt;p&gt;While testing most of the sites I found that they implement login mechanism and password functionality properly but some time due to some poor logic or minor flow error it can be vulnerable. So always analyze login and password reset functionality and think what you could do to exploit these using logical flaws. Sometime the exploitation process is not so easy and some other time it can be done in easy way.&lt;/p&gt;
&lt;p&gt;So let’s start with the Password reset vulnerability I found when performing a pentest. I started looking into application which appeared nice (because it was a dating site :) ). I explored all the functionalities  and understood the application work flow which helped me in finding vulnerabilities. Then I focused on the login mechanism. I tried some test cases for authentication bypass but FAILED :(&lt;/p&gt;
&lt;p&gt;Now what ?&lt;/p&gt;
&lt;p&gt;I asked myself do I need to start testing for common flaws like SQLi,XSS,CSRF ? No
I thought of giving them a try after sometime.&lt;/p&gt;
&lt;p&gt;Moving on password reset page. And started analyzing it.
When I visited password reset page it asked me to enter email or user id which is quite common thing in such page and I did enter the email id and got the password reset token in my mail. (I already had an account for testing that site)&lt;/p&gt;
&lt;p&gt;After that  I used that token link and reset my password ,everything worked fine and password was successfully changed.&lt;/p&gt;
&lt;p&gt;Then I started analyzing the password reset token link that I got clicking on the link provided in the mail. It look quite the same as shown below.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;https://site.com/token&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;7c8bab06c29d8264e391d317744b17e0&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;US&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I realize that token parameter value is looking like hashed with MD5. I Started decrypting but unable to do the same.&lt;/p&gt;
&lt;p&gt;I collected  more tokens and analyzed but did not get anything interesting.&lt;/p&gt;
&lt;p&gt;While analyzing suddenly I found that two types of token links were being used, one was when they are sending token on mail (as i mentioned above) and another was when I was using token as shown below&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;https://site.com/qw_email/link/ac&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;VG5wTk1FNVVXVE5OVkd0M1RtcFJlZz09&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;21&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So now I had two token links&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;div class=&quot;highlight-line&quot;&gt;first &lt;span class=&quot;token builtin class-name&quot;&gt;:&lt;/span&gt; https://site.com/qw_email/link/ac&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;VG5wTk1FNVVXVE5OVkd0M1RtcFJlZz09&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;21&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;what i got &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; my mail &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;&lt;/div&gt;&lt;div class=&quot;highlight-line&quot;&gt;second &lt;span class=&quot;token builtin class-name&quot;&gt;:&lt;/span&gt; https://site.com/token&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;7c8bab06c29d8264e391d317744b17e0&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;en &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;what i got after clicking the above &lt;span class=&quot;token function&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Second token was impossible to decrypt !&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/MSpE99u.gif&quot; width=&quot;400&quot; height=&quot;300&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now looking into first token which was in my mail. I found that it was not looking like it is Hashed.
It was something else.&lt;/p&gt;
&lt;p&gt;So I tried to decode it with different decoding techniques but I did not get anything interesting. But after sometime i decode the same with base64 contenuously and after some attempts finally I found some numeric value. :)&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/decoded.png&quot; width=&quot;800&quot; height=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;Now it&#39;s time to understand about numeric value.&lt;/p&gt;
&lt;p&gt;Earlier when I was trying to understand about application workflow, I found that the user id value they are using  is numeric, so immediately I opened my profile and matched that numeric value and yeah ! that value was same.&lt;/p&gt;
&lt;p&gt;So I found that &#39;ac&#39; parameter is having user id value with thrice base64 encoded.&lt;/p&gt;
&lt;p&gt;From my analysis what I got was , when user click on &amp;quot;Reset your password now&amp;quot;.First token was send to the email id which contains ac parameter value (the encoded form of userid) and a req parameter. By clicking on that link it requests for second token from server side by validating user id which is there in the first token to get the reset password form.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/floww.png&quot; width=&quot;600&quot; height=&quot;400&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;I needed to cross check it with another user account.So I created another account and note down the user id value, then encoded it thrice using base64.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Victim UserId = 562199544561
Encoded = VGxSWmVVMVVhelZPVkZFd1RsUlplQT09

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then crafted a password reset token which looks as follows:&lt;/p&gt;
&lt;p&gt;https://site.com/qw_email/link/ac=VGxSWmVVMVVhelZPVkZFd1RsUlplQT09&amp;amp;req=55&lt;/p&gt;
&lt;p&gt;By using this link I was able to reset the password for other user account. Similarly i just need to enumerate the userid (which was possible in that application) then request a password reset in my own account. After getting the password reset link change the ac parameter value to the thrice base64 encoded value of victim account or the account I enumerated. By clicking on the link it will provide me the password reset form to takeover the victim account.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://anandtiwari.com/assets/images/success-1.jpg&quot; width=&quot;450&quot; height=&quot;300&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;This is just an interesting logical flaw that allowed me to compromise victim account using password reset functionality. I will share other interesting scenarios what I met while pentesting soon.&lt;/p&gt;
</content>
  </entry>
</feed>
