<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashish Bhatia</title>
    <description>The latest articles on DEV Community by Ashish Bhatia (@ashishb).</description>
    <link>https://dev.to/ashishb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F90784%2Fd10f863f-10ec-4279-89f0-233c4166fcd1.jpeg</url>
      <title>DEV Community: Ashish Bhatia</title>
      <link>https://dev.to/ashishb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashishb"/>
    <language>en</language>
    <item>
      <title>Android Security: Don't leave WebView debugging enabled in production</title>
      <dc:creator>Ashish Bhatia</dc:creator>
      <pubDate>Wed, 14 Aug 2019 06:00:16 +0000</pubDate>
      <link>https://dev.to/ashishb/android-security-don-t-leave-webview-debugging-enabled-in-production-5fo9</link>
      <guid>https://dev.to/ashishb/android-security-don-t-leave-webview-debugging-enabled-in-production-5fo9</guid>
      <description>&lt;p&gt;WebView debugging can be enabled via &lt;code&gt;WebView.setWebContentsDebuggingEnabled(true)&lt;/code&gt;. Leaving WebView debugging enabled in production Android apps is a bad idea. Anyone who gets hold of the unlocked phone can access the app’s data forever.&lt;/p&gt;

&lt;p&gt;Consider this, the Tripit app exposes WebView debugging and by using that I can read all the files inside the private data directory. As an example, by connecting a user’s unlocked mobile phone to my laptop, I can extract TripIt OAuthToken.&lt;/p&gt;

&lt;p&gt;First connect the phone via ADB, open chrome://inspect in the Chrome browser, then enter the following in there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.location="file:///data/data/com.tripit/shared_prefs/com.tripit.xml"
document.getElementsByTagName("html")[0].innerHTML
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, you can see all the entries like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;string name=”oauthTokenSecret”&amp;gt;f731d36cdbf9006f917307…&amp;lt;/string&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;These auth tokens can be copied and used to get permanent access to the user’s TripIt account.&lt;/p&gt;

&lt;p&gt;Original post at &lt;a href="https://ashishb.net/security/android-security-dont-leave-webview-debugging-enabled-in-production/"&gt;ashishb.net&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>security</category>
      <category>androidsecurity</category>
      <category>webview</category>
    </item>
    <item>
      <title>Introducing ADB-enhanced: A swiss army knife for Android development</title>
      <dc:creator>Ashish Bhatia</dc:creator>
      <pubDate>Sun, 03 Feb 2019 23:14:11 +0000</pubDate>
      <link>https://dev.to/ashishb/introducing-adb-enhanced-a-swiss-army-knife-for-android-development-3b78</link>
      <guid>https://dev.to/ashishb/introducing-adb-enhanced-a-swiss-army-knife-for-android-development-3b78</guid>
      <description>

&lt;p&gt;Android development requires tons of disconnected approaches for the development and testing. Consider some scenarios&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To test runtime permission – Go to Settings -&amp;gt; Applications -&amp;gt; Application info of the app you are looking for and disable that permission.&lt;/li&gt;
&lt;li&gt;To test a fresh install – &lt;code&gt;adb shell pm clear-data com.example&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To test your app under the battery saver mode – turn on the battery saver mode by expanding the notification bar&lt;/li&gt;
&lt;li&gt;To stop the execution of an app –  kill it via activity manager, &lt;code&gt;adb shell am kill com.example&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To test your app under doze mode – first, make the device believe that it is unplugged via &lt;code&gt;adb shell dumpsys battery unplug&lt;/code&gt;, then, make it think that it is discharging via &lt;code&gt;adb shell dumpsys battery set status 3&lt;/code&gt;, and then enable doze mode via &lt;code&gt;adb shell dumpsys deviceidle force-idle&lt;/code&gt;. And don’t forget to execute a set of unrelated complementary commands once you are done to bring the device back to the normal state.&lt;/li&gt;
&lt;li&gt;To see the overdraw of an app – Go to the developer options and enable/disable it there.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Over time, this became a significant mental burden that I first wrote some of these flows in a text file and then converted them to automated shell scripts. But when even that felt insufficient, I created a tool for myself called adb-enhanced.&lt;br&gt;
How it works:&lt;br&gt;
First, install the tool. I wrote this in Python, so, if the following command does not work, install Python&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip3 install adb-enhanced # I would discourage Python 2 based install at this point&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s look at the about use-cases again with this tool:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To test a runtime permission :&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use grant instead of revoke to grant the permission
adbe permission revoke com.example camera  # See all possible such permissions via "adbe -h"

# Use grant instead of revoke to grant the permission
adbe permission revoke com.example camera  # See all possible such permissions via "adbe -h"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To test a fresh install –&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Unlike adb shell pm clear-data com.example, this command will 
# produce an error if com.example is not installed 
# which is good for catching typos
adbe clear-data com.example
# Unlike adb shell pm clear-data com.example, this command will 
# produce an error if com.example is not installed 
# which is good for catching typos
adbe clear-data com.example
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To test your app under the battery saver mode –&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# As you would guess, use "off" to turn the battery saver off
adbe battery saver on
# As you would guess, use "off" to turn the battery saver off
adbe battery saver on
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To stop the execution of an app –&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# For a more aggressive kill, try adbe force-stop com.example
adbe stop com.example
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To test your app under doze mode&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;adbe doze on # Use "off" to turn the doze mode off
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To see the overdraw of the app&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;adbe overdraw on
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I open-sourced the code at &lt;a href="https://github.com/ashishb/adb-enhanced"&gt;https://github.com/ashishb/adb-enhanced&lt;/a&gt;. See the GitHub repository for what all this tool can do. Feedbacks and pull requests are welcome.&lt;/p&gt;


</description>
      <category>android</category>
      <category>androiddevelopment</category>
      <category>adb</category>
    </item>
  </channel>
</rss>
