<?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 Pablo Ajo on Medium]]></title>
        <description><![CDATA[Stories by Pablo Ajo on Medium]]></description>
        <link>https://medium.com/@cr0nos?source=rss-b77e5c958b2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c5mJIHOjbvkuv1vm8pf5YQ.jpeg</url>
            <title>Stories by Pablo Ajo on Medium</title>
            <link>https://medium.com/@cr0nos?source=rss-b77e5c958b2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:45:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cr0nos/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[Understanding Google’s Play Integrity From Scratch]]></title>
            <link>https://medium.com/@cr0nos/understanding-play-integrity-from-scratch-6c4f7e4d8d0b?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c4f7e4d8d0b</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[attestation]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google-play-integrity]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 17:36:53 GMT</pubDate>
            <atom:updated>2026-08-07T17:38:44.456Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6D3uQCn7VXHtlR95tQulg.png" /></figure><p>When I started studying Play Integrity, the hard part wasn’t understanding the API. It was understanding <em>what problem it actually solves</em> and why it drags in so much cryptography to solve it. This article walks through the whole flow, deliberately simplified down to a single piece of example data so the mechanism is easy to follow.</p><h3>The Goal of Play Integrity</h3><p>Imagine Google only wants to check one thing:</p><blockquote><em>Is the bootloader locked?</em></blockquote><p>And assume this value is <strong>hardware-backed</strong>. Google doesn’t want to trust an answer handed to it by Android, because an attacker with root could just change it before it goes out.</p><p>The goal of Play Integrity is to make that answer trustworthy anyway: to give Google’s server a way to trust it <em>despite</em> the device being under the user’s full control.</p><h3>The Flow at a Glance</h3><p>Before going step by step, here is the whole exchange between the five parties involved:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*v_PvP1fPMnn5WOIQ7hq5ag.png" /></figure><h3>Step 1: The Device Leaves the Factory</h3><p>During manufacturing, the vendor burns a cryptographic identity into the device. Simplified, the device ends up holding:</p><ul><li>A <strong>private key</strong>, which stays secret.</li><li>A <strong>public key</strong>, paired to the private one.</li><li>A <strong>certificate</strong> that says: “this public key belongs to this device”, signed by the manufacturer.</li><li>A <strong>certificate chain</strong> that proves the certificate was issued by a trusted authority.</li></ul><h3>Step 2: An App Requests a Play Integrity Token</h3><p>When an app calls Play Integrity, it’s really talking to the <strong>Google Play Services</strong> application, running on the device itself.</p><p>Play Services now has to prove the device’s state to Google. In our example, it wants to prove:</p><pre>bootloader_locked = true</pre><p>Since we assumed this value is hardware-backed, Play Services doesn’t get to decide it on its own. Instead, it asks the <strong>TEE (Trusted Execution Environment)</strong>.</p><h3>Step 3: The TEE Answers</h3><p>The TEE is an environment isolated from the rest of Android.</p><p>When Play Services asks it about the bootloader state, the TEE does <strong>not</strong> simply reply bootloader_locked = true. That would be worthless, because Android could mock the answer before sending it upstream.</p><p>Instead, the TEE produces something like:</p><pre>Value:        bootloader_locked = true<br>Signature:    &lt;digital signature&gt;<br>Certificate:  &lt;device certificate&gt;</pre><p>The signature is made with the private key stored <strong>inside</strong> the TEE. Because of that, any later modification to the value invalidates the signature.</p><h4>Why You Can’t Just Read That Private Key</h4><p>The whole model leans on one assumption: that nobody can pull the private key out of the TEE and start signing arbitrary values with it. So it’s worth being explicit about why that’s hard.</p><p>The TEE is not “a folder Android can’t see”. It’s a separate execution environment, isolated from Android by the hardware itself (on ARM, via TrustZone). Android and the TEE run on the same chip but in different worlds, and the boundary between them is enforced in silicon, not by the OS. The key material lives on the secure side and the signing happens there too. The normal (rich) side never receives the raw key, it only receives the <em>result</em> of an operation it asked for.</p><p>That’s why the usual reverse engineering toolbox doesn’t help here. Getting the key anyway means attacking the hardware directly, and that’s a different sport.</p><h3>Step 4: Play Services Sends the Proof to Google’s Server</h3><p>Play Services makes no important decision here. It just forwards to Google’s server:</p><ul><li>The value (bootloader_locked = true).</li><li>The digital signature.</li><li>The device certificate.</li><li>The certificate chain.</li></ul><p>Now it’s Google’s server that has to decide whether it can trust any of this.</p><h3>Step 5: Google Verifies and Decides</h3><p>Google now has to answer two questions: is the device certificate real, and is the signature on the value valid?</p><p>The first is what the <strong>certificate chain</strong> is for. A certificate on its own proves nothing, I could just as easily mint one claiming “this public key belongs to a Pixel”. That’s why the chain exists:</p><pre>Device certificate<br>        |  signed by<br>        v<br>Pixel CA<br>        |  signed by<br>        v<br>Google Root CA</pre><p>Google already knows the Root CA’s public key. It uses that to verify the next certificate down, then uses <em>that</em> one to verify the next, and so on until it reaches the device certificate. If the whole chain checks out, Google can trust the public key inside it, and with that public key it checks the signature over the value.</p><p>If both hold, Google is now sure the value came from a legitimate device and wasn’t touched in transit. In our example that value is a single data point:</p><pre>bootloader_locked = true</pre><p>So the server concludes it can trust that the bootloader is locked. A real request runs many more checks, but the process is identical.</p><h3>Step 6: Google Issues the Play Integrity Token</h3><p>With the decision made, the server builds the Play Integrity token. For example:</p><pre>{<br>    &quot;device_trusted&quot;: true<br>}</pre><p>This token is signed with <strong>Google’s</strong> private key, not the TEE’s.</p><p>Finally, Google returns the signed token to Play Services. Play Services hands it to the app. The app usually forwards it to its own backend, and the backend verifies the token was signed by Google before trusting it.</p><h3>Summary</h3><p>Play Integrity isn’t just about asking the device whether it’s compromised. It’s about getting a <strong>cryptographic proof</strong> of that state.</p><p>The TEE produces a signed answer using a protected private key. Google’s server verifies the certificate chain, checks the signature, and decides whether to trust the proof. Only then does it issue the Play Integrity token, which comes back signed by Google and is used by the app’s backend to decide whether to allow the requested operation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c4f7e4d8d0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Android Biometric Authentication Works and Where It Fails]]></title>
            <link>https://medium.com/@cr0nos/how-android-biometric-authentication-works-and-where-it-fails-2b6f95faa91a?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b6f95faa91a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Wed, 22 Apr 2026 12:36:06 GMT</pubDate>
            <atom:updated>2026-04-22T12:36:06.661Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncHBZq0GHAvLuLZFI0j1oQ.jpeg" /></figure><h3>The Two Ways to Implement It</h3><p>Android’s BiometricPrompt API looks simple from the outside: show a dialog, wait for a callback, do something when the user authenticates. But there are two fundamentally different ways to implement it, and one of them is trivially bypassable.</p><p>The difference is whether the app uses a CryptoObject or not.</p><pre>App uses BiometricPrompt<br>    ├─&gt; Without CryptoObject: boolean result<br>    │       └─&gt; Bypassable with a two-line Frida script<br>    └─&gt; With CryptoObject: biometric-bound cryptographic key<br>            └─&gt; Bypass requires attacking the TEE (hardware-isolated secure processor)</pre><p>To understand why, you need to understand what the system is actually doing when a user touches the fingerprint sensor.</p><h3>How the Stack Works</h3><p>For now, think of the TEE as a black box running inside your phone’s chip that Android cannot read or write to. It has its own memory, its own execution environment, and its own keys. The rest of the OS can ask it to do things, but cannot see inside it.</p><p>When a user enrolls a fingerprint or face in the device settings, the sensor captures the raw biometric data and sends it directly into the TEE. The TEE processes it and stores a mathematical representation (a template) internally. That template never leaves the TEE, not to the Android OS, not to apps, not even to root. The raw biometric data is discarded after enrollment.</p><p>When an app calls BiometricPrompt.authenticate(), the request travels through several layers before any biometric data is read:</p><pre>App (normal world)<br>    └─&gt; BiometricPrompt API (androidx.biometric)<br>            └─&gt; BiometricService (system process)<br>                    └─&gt; Biometric HAL (Hardware Abstraction Layer)<br>                            └─&gt; TEE (Trusted Execution Environment)<br>                                    └─&gt; Sensor driver</pre><p>The TEE is the critical layer. It’s an isolated execution environment, separate from the Android OS, running on the same SoC (System on a Chip) via ARM TrustZone.</p><p>Biometric templates (the stored fingerprint or face model) never leave the TEE. The sensor collects raw data, sends it into the TEE, and the TEE runs the matching algorithm internally. The only thing that comes back to the normal world is a match result.</p><p>When a match succeeds, the TEE records internally that this user authenticated at a given time. The Android Keystore checks that record before allowing any operation with a biometric-bound key. If the authentication is recent enough, the operation proceeds. If not, it throws UserNotAuthenticatedException.</p><h3>Biometric Classes</h3><p>Not all biometrics are equal. Android classifies them into three tiers:</p><p><strong>Class 1 (Convenience):</strong> Lowest security. Some face unlock implementations fall here. Can unlock the screen, but cannot be used to authorize cryptographic operations with Keystore-bound keys in strict implementations.</p><p><strong>Class 2 (Weak):</strong> Standard fingerprint sensors, basic face detection with anti-spoofing. Can be used with setUserAuthenticationRequired(true) on Keystore keys. Good enough for most app authentication flows.</p><p><strong>Class 3 (Strong):</strong> Highest tier. Requires liveness detection, a very low false acceptance rate, and dedicated secure processing. Required for payment authorization and the most sensitive Keystore operations.</p><p>Apps can specify the minimum class they’ll accept:</p><pre>BiometricManager.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_STRONG)</pre><p>In practice, most apps that use biometrics for convenience (unlocking the app) use Class 2. Apps handling payments or decrypting sensitive local data should use Class 3.</p><h3>The Keystore Integration</h3><p>The secure path ties biometric authentication to a cryptographic key stored in the Android Keystore. The key has nothing to do with the biometric template. It does not contain biometric data and is not derived from the fingerprint. The template is used to verify identity. The key is what the app uses to encrypt or decrypt data. The connection between them is a condition: when the TEE verifies a fingerprint match, it records internally that the user just authenticated. That record is what unlocks access to the key. Until the TEE confirms a valid recent authentication, the key is inaccessible.</p><p>The key is generated with setUserAuthenticationRequired(true):</p><pre>KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(<br>    &quot;my_key&quot;,<br>    KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT<br>)<br>.setBlockModes(KeyProperties.BLOCK_MODE_CBC)<br>.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)<br>.setUserAuthenticationRequired(true)<br>.build();<br><br>KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, &quot;AndroidKeyStore&quot;);<br>keyGen.init(spec);<br>keyGen.generateKey();</pre><p>The key lives in the TEE. It cannot be exported. When the app tries to initialize a Cipher with this key and the user hasn&#39;t recently authenticated, the call throws UserNotAuthenticatedException.</p><p>When biometric auth succeeds, the TEE records the timestamp. For a brief window after that, operations with the key are permitted. The app passes the initialized Cipher to BiometricPrompt as a CryptoObject:</p><pre>Cipher cipher = Cipher.getInstance(&quot;AES/CBC/PKCS7Padding&quot;);<br>SecretKey key = (SecretKey) keyStore.getKey(&quot;my_key&quot;, null);<br>cipher.init(Cipher.ENCRYPT_MODE, key);<br><br>BiometricPrompt.CryptoObject cryptoObject = new BiometricPrompt.CryptoObject(cipher);<br>biometricPrompt.authenticate(cryptoObject, cancellationSignal, executor, callback);</pre><p>If authentication succeeds, onAuthenticationSucceeded receives an AuthenticationResult containing the same CryptoObject. The cipher is now authorized and cipher.doFinal() will work.</p><h3>The Vulnerable Pattern</h3><p>Many apps skip the CryptoObject entirely and just check that the callback fired:</p><pre>biometricPrompt.authenticate(cancellationSignal, executor, new BiometricPrompt.AuthenticationCallback() {<br>    @Override<br>    public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {<br>        isAuthenticated = true;<br>        unlockFeature();<br>    }<br><br>    @Override<br>    public void onAuthenticationFailed() {<br>        showError(&quot;Authentication failed&quot;);<br>    }<br>});</pre><p>There’s no key, no cipher, no cryptographic proof that authentication happened. The app trusts the callback. onAuthenticationSucceeded won&#39;t fire on its own without a real match, but onAuthenticationFailed and onAuthenticationError will fire when the user cancels or puts the wrong finger. The bypass hooks those two and converts them into a success call:</p><pre>Java.perform(() =&gt; {<br>    const AuthCallback = Java.use(&quot;androidx.biometric.BiometricPrompt$AuthenticationCallback&quot;);<br><br>    AuthCallback.onAuthenticationFailed.implementation = function() {<br>        console.log(&quot;[+] onAuthenticationFailed -&gt; triggering success&quot;);<br>        this.onAuthenticationSucceeded(null);<br>    };<br><br>    AuthCallback.onAuthenticationError.overload(<br>        &quot;int&quot;, &quot;java.lang.CharSequence&quot;<br>    ).implementation = function(code, msg) {<br>        console.log(&quot;[+] onAuthenticationError -&gt; triggering success&quot;);<br>        this.onAuthenticationSucceeded(null);<br>    };<br>});</pre><p>Any failed or cancelled attempt now triggers the success path. The user just needs to open the biometric dialog and dismiss it.</p><h3>Why CryptoObject Stops This</h3><p>When the app uses CryptoObject, hooking the callback alone is not enough. The success callback hands the app a Cipher that was authorized by the TEE. Inside onAuthenticationSucceeded, the app calls cipher.doFinal() to actually encrypt or decrypt something.</p><p>If you trigger the callback without real biometric authentication having occurred, the Cipher was never authorized. Calling cipher.doFinal() throws UserNotAuthenticatedException. The Keystore enforcement happens inside the TEE, below any layer Frida can reach.</p><p>A concrete example of what secure usage looks like on the app side:</p><pre>biometricPrompt.authenticate(cryptoObject, cancellationSignal, executor,<br>    new BiometricPrompt.AuthenticationCallback() {<br>        @Override<br>        public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {<br>            // The cipher inside the CryptoObject is now TEE-authorized<br>            Cipher cipher = result.getCryptoObject().getCipher();<br>            byte[] decrypted = cipher.doFinal(encryptedData);<br>            loadUserData(decrypted);<br>        }<br><br>        @Override<br>        public void onAuthenticationFailed() {<br>            showError(&quot;Authentication failed&quot;);<br>        }<br>    });</pre><p>Even if you hook onAuthenticationSucceeded and call it yourself, result.getCryptoObject().getCipher() holds a Cipher that was never authorized by the TEE. cipher.doFinal() throws UserNotAuthenticatedException regardless of what happened at the Java layer.</p><p>To bypass this, you need to attack the key generation itself so the key is created without the authentication constraint. One approach is patching smali: find the KeyGenParameterSpec.Builder call, remove setUserAuthenticationRequired(true), uninstall the app to force the key to be regenerated, and reinstall the patched version. The next time the app creates the key, it does so without the constraint, and the callback hook works from that point on.</p><p>A cleaner approach that requires no recompilation is hooking setUserAuthenticationRequired directly with Frida and making it a no-op:</p><pre>Java.perform(() =&gt; {<br>    const Builder = Java.use(&quot;android.security.keystore.KeyGenParameterSpec$Builder&quot;);<br><br>    Builder.setUserAuthenticationRequired.implementation = function(required) {<br>        console.log(&quot;[+] setUserAuthenticationRequired(&quot; + required + &quot;) -&gt; forced to false&quot;);<br>        return this.setUserAuthenticationRequired(false);<br>    };<br>});</pre><p>With this hook running, any key the app generates will have no authentication requirement regardless of what the original code passes. Uninstall the app first to delete the existing key, then reinstall and launch with the hook active. The app regenerates the key without the constraint, and from that point the callback bypass works.</p><h3>The Validity Duration Weakness</h3><p>Some apps use setUserAuthenticationValidityDurationSeconds() when generating the key:</p><pre>new KeyGenParameterSpec.Builder(&quot;my_key&quot;, KeyProperties.PURPOSE_ENCRYPT)<br>    .setUserAuthenticationRequired(true)<br>    .setUserAuthenticationValidityDurationSeconds(300)  // 5 minutes<br>    .build();</pre><p>This creates a time window: after one successful biometric auth, the key can be used for 300 seconds without re-authenticating. The intent is convenience. The result is a window an attacker can exploit.</p><p>If you can authenticate once (by social engineering, shoulder surfing, or waiting for the user to authenticate normally), you have five minutes to use the key as many times as you want. Larger validity durations make this worse. Some apps set values like 3600 seconds or more, which largely defeats the purpose.</p><p>Apps that need per-operation security should not set this value at all, or set it to 0, which requires biometric authentication before every key operation.</p><h3>So How Do You Actually Secure This?</h3><p>Using CryptoObject correctly raises the bar significantly, but the key generation itself can still be attacked by hooking setUserAuthenticationRequired before the key is created. The bypass requires more effort and device access, but it is not impossible.</p><p>The answer that closes this attack path is <strong>StrongBox</strong>. Keys backed by StrongBox are generated inside a dedicated secure processor physically separate from the main chip. On Pixel devices this is the Titan M2. The key generation parameters are enforced by that processor’s own firmware, not by Android. Hooking setUserAuthenticationRequired at the Java layer still sends the modified parameters down the stack, but StrongBox enforces its own policies independently of what arrives from Android. On top of that, StrongBox applies hardware rate limiting: after several failed authentication attempts it starts locking out with increasing delays, making brute force impractical.</p><p>Most apps do not use StrongBox, either because they did not explicitly request it with setIsStrongBoxBacked(true) or because they want compatibility with devices that do not have it. But for anything that needs to hold against an attacker with physical device access and the ability to run Frida, StrongBox is the only option that closes the gap. The internals of StrongBox and how attestation ties into verifying it remotely deserve their own article.</p><p><em>This post is intended for security professionals and researchers. The techniques described here are shared for educational purposes in the context of security research and mobile application security testing. Do not use this information to access systems or services without explicit authorization.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b6f95faa91a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Faking a Mobile Client from Python with curl_cffi]]></title>
            <link>https://medium.com/@cr0nos/faking-a-mobile-client-from-python-with-curl-cffi-3de815e1673c?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3de815e1673c</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 09:59:24 GMT</pubDate>
            <atom:updated>2026-04-16T09:59:24.464Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KLN6AgXF3x3kbOeC3lfxbw.jpeg" /></figure><h3>The Problem</h3><p>You’ve intercepted the traffic from a mobile app with mitmproxy. You have the endpoints, the headers, the request bodies. You write a Python script using requests and replay the calls. It works once, then starts returning 403s, captchas, or empty responses.</p><p>The server isn’t checking credentials. It’s checking <em>who is making the request</em>. And requests looks nothing like a real mobile client.</p><h3>What Servers Actually Check</h3><p>Modern anti-bot systems don’t just look at the User-Agent header. They fingerprint the TLS handshake itself.</p><p>When a client connects over HTTPS, the TLS handshake contains a set of parameters that vary by implementation: which cipher suites are offered and in what order, which TLS extensions are present, which elliptic curves are supported, whether session tickets are used. This fingerprint is called a <strong>JA3 hash</strong> (or JA3N, which also includes extension ordering). It’s computed from the ClientHello message before any HTTP headers are even sent.</p><p>Python’s requests library uses the system&#39;s OpenSSL. Chrome, Safari, and mobile apps use their own TLS stacks. The JA3 hash of a requests call looks nothing like Chrome or a native mobile app. Servers that care about this will block or flag you before they even look at your headers.</p><p>curl_cffi solves this by wrapping curl-impersonate, a patched version of curl built to produce TLS fingerprints that match specific browsers and runtimes.</p><h3>What curl_cffi Can Impersonate</h3><p>curl_cffi ships with built-in profiles for a range of targets. Each profile replicates the full TLS fingerprint, including cipher suite order, extensions, ALPN negotiation, and HTTP/2 settings frames:</p><ul><li><strong>Chrome</strong> (multiple versions): chrome99, chrome100, chrome101, chrome104, chrome107, chrome110, chrome116, chrome119, chrome120</li><li><strong>Chrome on Android</strong>: chrome99_android</li><li><strong>Safari</strong> (macOS and iOS): safari15_3, safari15_5, safari17_0, safari17_2_ios</li><li><strong>Firefox</strong>: firefox91esr, firefox95, firefox98, firefox100, firefox102, firefox109, firefox117, firefox120</li><li><strong>Edge</strong>: edge99, edge101</li><li><strong>Opera</strong>: opera91, opera100</li></ul><p>For mobile app traffic, chrome99_android is the most useful starting point. Most Android apps that use a system WebView or OkHttp with default settings will produce a fingerprint close to Chrome on Android. iOS apps using URLSession will be closer to Safari on iOS.</p><h3>Installation</h3><pre>pip install curl_cffi</pre><p>No system dependencies needed. The package ships with prebuilt binaries for macOS, Linux, and Windows.</p><h3>Basic Usage</h3><p>The API mirrors requests intentionally. Switching an existing script is usually a one-line change:</p><pre>from curl_cffi import requests<br><br>response = requests.get(<br>    &quot;https://api.example.com/endpoint&quot;,<br>    impersonate=&quot;chrome120&quot;<br>)<br><br>print(response.status_code)<br>print(response.json())</pre><p>For mobile app traffic, use the Android Chrome profile:</p><pre>response = requests.get(<br>    &quot;https://api.example.com/endpoint&quot;,<br>    impersonate=&quot;chrome99_android&quot;,<br>    headers={<br>        &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Linux; Android 12; Pixel 6) ...&quot;,<br>        &quot;X-App-Version&quot;: &quot;4.2.1&quot;,<br>    }<br>)</pre><p>The impersonate parameter controls the TLS fingerprint. The headers are still yours to set. Use whatever the real app sends.</p><h3>Sessions</h3><p>For anything beyond a single request, use a session. Sessions persist cookies, connection pooling, and keep the same fingerprint across calls:</p><pre>from curl_cffi import requests<br><br>session = requests.Session(impersonate=&quot;chrome99_android&quot;)<br><br># Login<br>session.post(&quot;https://api.example.com/auth/login&quot;, json={<br>    &quot;username&quot;: &quot;user&quot;,<br>    &quot;password&quot;: &quot;pass&quot;<br>})<br><br># Subsequent calls reuse the session cookies automatically<br>response = session.get(&quot;https://api.example.com/profile&quot;)<br>print(response.json())</pre><h3>Async Support</h3><p>curl_cffi has a native async implementation built on asyncio. It&#39;s not just requests wrapped in asyncio.run() — it uses curl_cffi.AsyncSession which runs curl asynchronously under the hood:</p><pre>import asyncio<br>from curl_cffi.requests import AsyncSession<br><br>async def fetch(url):<br>    async with AsyncSession(impersonate=&quot;chrome120&quot;) as session:<br>        response = await session.get(url)<br>        return response.json()<br><br>async def main():<br>    results = await asyncio.gather(<br>        fetch(&quot;https://api.example.com/endpoint/1&quot;),<br>        fetch(&quot;https://api.example.com/endpoint/2&quot;),<br>        fetch(&quot;https://api.example.com/endpoint/3&quot;),<br>    )<br>    print(results)<br><br>asyncio.run(main())</pre><p>This is the right approach when you’re making many requests concurrently. The async session reuses connections and shares the impersonation profile across all calls.</p><h3>Practical Example: Replaying Mobile App Traffic</h3><p>The typical workflow after intercepting with mitmproxy:</p><ol><li>Capture the request you want to replicate</li><li>Note the headers the app sends (especially User-Agent, any auth tokens, custom headers)</li><li>Identify the TLS profile (Android app: start with chrome99_android, iOS: try safari17_2_ios)</li></ol><pre>from curl_cffi import requests<br><br>session = requests.Session(impersonate=&quot;chrome99_android&quot;)<br><br># Replicate exactly what the app sends<br>session.headers.update({<br>    &quot;User-Agent&quot;: &quot;Dalvik/2.1.0 (Linux; U; Android 12; Pixel 6 Build/SP2A.220505.002)&quot;,<br>    &quot;Accept&quot;: &quot;application/json&quot;,<br>    &quot;Accept-Language&quot;: &quot;en-US&quot;,<br>    &quot;X-App-Token&quot;: &quot;your-intercepted-token&quot;,<br>    &quot;X-Platform&quot;: &quot;android&quot;,<br>    &quot;X-App-Version&quot;: &quot;4.2.1&quot;,<br>})<br>response = session.get(&quot;https://api.example.com/v2/feed&quot;)<br>print(response.json())</pre><p>If you’re still getting blocked after matching the headers, the fingerprint profile is probably wrong. Try different profiles or check if the app uses a custom HTTP client (some apps pin certificates or use a non-standard TLS stack like BoringSSL with custom settings).</p><h3>Verifying Your Fingerprint</h3><p>To check what JA3 hash your session is producing, make a request to a fingerprinting endpoint (for example <a href="https://tls.peet.ws/api/all">https://tls.peet.ws/api/all</a>) and compare it to what the real app produces.</p><p>To make the difference concrete, we can compare a plain requests call against a curl_cffi impersonated one:</p><pre>import requests as stdlib_requests<br>from curl_cffi import requests as cffi_requests<br><br>FINGERPRINT_URL = &quot;https://tls.peet.ws/api/all&quot;<br><br>plain = stdlib_requests.get(FINGERPRINT_URL)<br>plain_ja3 = plain.json()[&quot;tls&quot;][&quot;ja3_hash&quot;]<br>print(f&quot;Plain requests JA3:      {plain_ja3}&quot;)<br><br>impersonated = cffi_requests.get(FINGERPRINT_URL, impersonate=&quot;chrome99_android&quot;)<br>impersonated_ja3 = impersonated.json()[&quot;tls&quot;][&quot;ja3_hash&quot;]<br>print(f&quot;Impersonated (Android):  {impersonated_ja3}&quot;)</pre><p>Running the file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*33ln1O9rj-Wq3H0M4aKMAA.png" /></figure><p>Run the same endpoint through the real app (patching the app or through Frida) and compare. If the hashes match, you’re indistinguishable at the TLS layer.</p><p><em>This post is intended for security professionals and researchers. The techniques described here are shared for educational purposes in the context of security research, API analysis, and mobile application testing. Do not use this information to access systems or services without explicit authorization.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3de815e1673c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside the Android Keystore]]></title>
            <link>https://medium.com/@cr0nos/inside-the-android-keystore-293ff0f406b5?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/293ff0f406b5</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 07:58:53 GMT</pubDate>
            <atom:updated>2026-04-14T07:58:53.246Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LeE-P00xAbD1RBUW7_tHjA.jpeg" /></figure><p>When you’re reversing an Android app, hooking Cipher.doFinal() with Frida gives you plaintext in seconds. No key needed. So why would an attacker ever care about extracting the key itself?</p><p>Because plaintext is passive. A key is active.</p><p>With intercepted plaintext you can read what the app decrypted on this device, in this session. With the key you can encrypt and decrypt anything, anywhere, at any time, without the original device, without Frida running, and without the user being involved at all. Here are some examples of why keys are important.</p><p><strong>Device binding.</strong> Some apps generate a key on first launch and register it with the server as “this is my device”. Every request carries a signature made with that key. If you extract the key, you can make requests from another device that the server treats as the original.</p><p><strong>Anti-fraud tokens.</strong> Financial and payment apps sometimes use a key to prove that an operation came from a specific previously registered device. With the key, that mechanism is useless.</p><p>That’s why cryptographic key storage matters beyond the obvious use case of encrypting local data. Keys are identity. Whoever holds the key holds the device’s trusted position with the server.</p><h3>What It Is</h3><p>The Android Keystore is the system that lets apps store cryptographic keys in a way that makes them difficult or impossible to extract. It’s not a file or a database in the traditional sense. It’s a provider backed by a daemon (keystored) that forwards operations to the underlying hardware or software implementation.</p><p>From an app’s perspective, you ask the Keystore to generate a key, give it an alias, and then use that alias to perform cryptographic operations. The actual key material never passes through your process:</p><pre>// Generate a key — the alias is the only handle you get<br>KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, &quot;AndroidKeyStore&quot;);<br>keyGen.init(new KeyGenParameterSpec.Builder(&quot;my_key&quot;,<br>        KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT).build());<br>keyGen.generateKey();<br><br>// Use it later — you never touch the raw bytes<br>SecretKey key = (SecretKey) KeyStore.getInstance(&quot;AndroidKeyStore&quot;).getKey(&quot;my_key&quot;, null);<br>Cipher cipher = Cipher.getInstance(&quot;AES/GCM/NoPadding&quot;);<br>cipher.init(Cipher.ENCRYPT_MODE, key);<br>byte[] ciphertext = cipher.doFinal(plaintext);</pre><p>The app calls cipher.doFinal(), the call goes to the Keystore daemon, the daemon sends it to the TEE (hardware-isolated secure processor) or software layer, and the result comes back. At no point does the app hold the raw key bytes.</p><h3>Where Keys Actually Live</h3><p>Not all Keystore keys are equal. A key can be backed by software or by hardware, and the difference is significant.</p><p><strong>Software-backed keys</strong> are stored as encrypted blobs on disk, under /data/misc/keystore/. The encryption uses a device-specific master key. If you have root and can get to that master key, you can extract the key material. These keys can also be included in device backups.</p><p><strong>TEE-backed keys</strong> are generated inside the Trusted Execution Environment and never leave it. The key material exists only in the TEE’s isolated memory. Root access on the Android side cannot reach it. Even a fully compromised kernel cannot extract a TEE-backed key.</p><p><strong>StrongBox keys</strong> go one level further. Instead of the TEE (which runs on the same SoC, System on a Chip, as Android, isolated via ARM TrustZone), StrongBox keys live in a dedicated secure processor, physically separate from the main chip. Pixel phones use Google’s Titan M/M2 chip for this. StrongBox also enforces hardware rate limiting: five incorrect authentication attempts trigger a 30-second lockout, and after 139 attempts the lockout extends to 24 hours per attempt. Brute force is not a viable attack.</p><p>To check programmatically which level a key is at:</p><pre>// Load the private key by alias from the Keystore<br>KeyStore ks = KeyStore.getInstance(&quot;AndroidKeyStore&quot;);<br>ks.load(null);<br>PrivateKey privateKey = (PrivateKey) ks.getKey(&quot;my_key&quot;, null);<br><br>// EC = Elliptic Curve, the algorithm this key was generated with<br>KeyFactory factory = KeyFactory.getInstance(&quot;EC&quot;, &quot;AndroidKeyStore&quot;);<br>KeyInfo info = (KeyInfo) factory.getKeySpec(privateKey, KeyInfo.class);<br><br>int level = info.getSecurityLevel();<br>// KeyProperties.SECURITY_LEVEL_SOFTWARE = 0<br>// KeyProperties.SECURITY_LEVEL_TRUSTED_ENVIRONMENT = 1<br>// KeyProperties.SECURITY_LEVEL_STRONGBOX = 2</pre><h3>Key Types</h3><p>The Keystore supports three categories:</p><p><strong>Symmetric keys (AES, HMAC):</strong> AES in 128 or 256 bits, HMAC with SHA-256/384/512. Used for encryption and message authentication. Generated with KeyGenerator.</p><p><strong>Asymmetric keys (RSA, EC):</strong> RSA at 2048+ bits, EC on P-256. Used for signing and key agreement. Generated with KeyPairGenerator. Only the private key is protected inside the Keystore. The public key can be freely exported.</p><p><strong>Imported keys (Android 9+):</strong> Keys generated outside the device can be imported via a wrapping mechanism. An asymmetric key with PURPOSE_WRAP_KEY decrypts the wrapped key material inside the TEE. Once imported, the key is treated the same as a generated one.</p><h3>Key Constraints</h3><p>Keys aren’t just blobs. They carry a policy that the Keystore enforces on every operation. The most relevant constraints:</p><p>setUserAuthenticationRequired(true) requires the user to authenticate (biometric or PIN) before the key can be used. Without this, any process that can reach the Keystore daemon can use the key.</p><p>setUserAuthenticationValidityDurationSeconds(N) sets a window after authentication during which the key is available. A value of 0 means re-authenticate before every single operation. Higher values trade security for convenience.</p><p>setUnlockedDeviceRequired(true) prevents the key from being used while the device is locked, regardless of authentication state.</p><p>setIsStrongBoxBacked(true) forces the key into the secure processor. If the device doesn&#39;t have StrongBox, key generation fails outright.</p><p>setKeyValidityEnd(date) makes the Keystore refuse operations after a given date. Useful for keys that should rotate.</p><h3>Key Attestation</h3><p>When a key is generated in hardware, the Keystore can produce a certificate chain that proves it. A server that receives this chain can verify it against Google’s root and read the extension to confirm: this key was generated inside genuine Android secure hardware, with these exact constraints, on a device that was not running with an unlocked bootloader. It’s the foundation that Android’s device integrity checks (Play Integrity API) are built on, and it’s how payment processors and DRM systems remotely decide whether to trust a key on a device they don’t control. The full mechanics of attestation verification deserve their own article.</p><h3>Finding Keys During RE</h3><p>The first thing to do is enumerate what aliases the app is using. In smali, key aliases appear as string constants near KeyStore.getKey(), KeyGenerator.init(), or KeyGenParameterSpec.Builder calls:</p><pre>grep -r &quot;AndroidKeyStore&quot; smali/<br>grep -r &quot;getKey\|generateKey\|KeyGenParameterSpec&quot; smali/<br>grep -r &quot;\&quot;key_\|\&quot;aes_\|\&quot;rsa_\|\&quot;ec_&quot; smali/</pre><p>Common patterns: &quot;key_payment&quot;, &quot;biometric_key&quot;, &quot;db_encryption_key&quot;, &quot;signing_key&quot;. The alias tells you what the key is for before you look at anything else.</p><p>Dynamically, with Frida, you can list all aliases the app has registered:</p><pre>Java.perform(() =&gt; {<br>    const KeyStore = Java.use(&quot;java.security.KeyStore&quot;);<br>    const ks = KeyStore.getInstance(&quot;AndroidKeyStore&quot;);<br>    ks.load(null);<br><br>    const aliases = ks.aliases();<br>    while (aliases.hasMoreElements()) {<br>        console.log(&quot;[+] Key alias: &quot; + aliases.nextElement());<br>    }<br>});</pre><p>To check whether a key is hardware-backed:</p><pre>Java.perform(() =&gt; {<br>    const KeyFactory = Java.use(&quot;java.security.KeyFactory&quot;);<br>    const KeyInfo = Java.use(&quot;android.security.keystore.KeyInfo&quot;);<br><br>    const factory = KeyFactory.getInstance(&quot;EC&quot;, &quot;AndroidKeyStore&quot;);<br>    const info = factory.getKeySpec(privateKey, KeyInfo.class);<br><br>    console.log(&quot;[+] Hardware backed: &quot; + info.isInsideSecureHardware());<br>    console.log(&quot;[+] Security level: &quot; + info.getSecurityLevel());<br>    // 0 = software, 1 = TEE, 2 = StrongBox<br>});</pre><h3>Can Keys Be Extracted?</h3><p><strong>Software-backed keys:</strong> Potentially yes. The encrypted blobs are on disk. With root access and the device-specific master key, key material can be decrypted. If the app stores key material in SharedPreferences or files (a common mistake), extraction is trivial even without root.</p><p><strong>TEE-backed keys:</strong> No. Key material never leaves the TEE. With root on the Android side, you can intercept the operations that use the key, but you cannot get the key itself.</p><p><strong>StrongBox keys:</strong> No. The separate secure processor and hardware rate limiting make both software and physical attacks impractical on modern devices.</p><h3>What You Can Get by Hooking</h3><p>When you can’t extract the key, the next layer is intercepting the operations that use it. Hooking Cipher.doFinal() gives you plaintext and ciphertext without ever touching the key:</p><pre>Java.perform(() =&gt; {<br>    const Cipher = Java.use(&quot;javax.crypto.Cipher&quot;);<br><br>    Cipher.doFinal.overload(&quot;[B&quot;).implementation = function(input) {<br>        console.log(&quot;[+] Cipher.doFinal input: &quot; + <br>            Java.use(&quot;java.util.Arrays&quot;).toString(input));<br><br>        const result = this.doFinal(input);<br><br>        console.log(&quot;[+] Cipher.doFinal output: &quot; + <br>            Java.use(&quot;java.util.Arrays&quot;).toString(result));<br><br>        return result;<br>    };<br>});</pre><p>The same applies to Signature.sign() to capture what&#39;s being signed and the resulting signature, and Mac.doFinal() for HMAC operations. You can reconstruct the full cryptographic flow of the app without knowing any key material.</p><p>Hooking Cipher.init() tells you which algorithm and mode are in use, and exposes the IV or nonce if one is passed:</p><pre>Java.perform(() =&gt; {<br>    const Cipher = Java.use(&quot;javax.crypto.Cipher&quot;);<br><br>    Cipher.init.overload(&quot;int&quot;, &quot;java.security.Key&quot;, <br>        &quot;java.security.spec.AlgorithmParameterSpec&quot;).implementation = <br>        function(mode, key, params) {<br>            console.log(&quot;[+] Cipher.init: &quot; + this.getAlgorithm() + <br>                &quot; mode=&quot; + mode);<br>            return this.init(mode, key, params);<br>        };<br>});</pre><h3>Common Mistakes</h3><p><strong>No user authentication on sensitive keys.</strong> A key without setUserAuthenticationRequired(true) can be used by any code that reaches the Keystore daemon. If the app process is compromised, the key is effectively open.</p><p><strong>Key material stored outside the Keystore.</strong> Encoding a key to bytes and saving it to SharedPreferences or a file bypasses all Keystore protections. Search for getEncoded() and Base64.encode() near key objects in smali — this pattern almost always indicates a key being moved outside the Keystore.</p><p><strong>Large authentication validity windows.</strong> A setUserAuthenticationValidityDurationSeconds(3600) means one authentication unlocks the key for an hour. If you can observe or trigger one authentication event, you have a 60-minute window to use the key as many times as you want.</p><p><strong>Not checking whether keys are hardware-backed.</strong> An app that uses setUserAuthenticationRequired(true) but never verifies isInsideSecureHardware() may be operating on software-backed keys without knowing it. On a rooted device, those keys can be extracted.</p><p><strong>Allowing device backup.</strong> If android:allowBackup=&quot;true&quot; in the manifest and the app stores sensitive data encrypted with Keystore keys but also backs up the ciphertext, an attacker with a backup can wait for a Keystore key extraction opportunity rather than attacking the live device.</p><p><em>This post is intended for security professionals and researchers. The techniques described here are shared for educational purposes in the context of security research and mobile application security testing. Do not use this information to access systems or services without explicit authorization.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=293ff0f406b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frida Gadget: Executing Frida Without Root]]></title>
            <link>https://medium.com/@cr0nos/frida-gadget-executing-frida-without-root-667bc952d33d?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/667bc952d33d</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[frida]]></category>
            <category><![CDATA[patching]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 10:12:21 GMT</pubDate>
            <atom:updated>2026-04-11T10:12:21.174Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Problem with frida-server</strong></h3><p>The standard Frida setup requires pushing frida-server to the device and running it as root:</p><pre>adb push frida-server /data/local/tmp/<br>adb shell chmod +x /data/local/tmp/frida-server<br>adb shell su -c &quot;/data/local/tmp/frida-server &amp;&quot;</pre><p>This works fine on rooted devices. The reason root is necessary is not arbitrary: frida-server needs to inject itself into arbitrary processes. That means calling ptrace on processes it doesn’t own, writing into their memory, and bypassing SELinux restrictions that would normally block cross-process operations. All of that requires elevated privileges.</p><h3><strong>What Frida Gadget Is</strong></h3><p>Frida Gadget is a shared library (.so) that you embed directly into an app. Instead of Frida injecting itself from the outside, the library loads as part of the app’s own process. No root needed because you’re operating inside a process that already belongs to you.</p><p>When the app starts, the Gadget library loads, connects to your machine over TCP (or waits for a script, depending on configuration), and gives you a full Frida session from within the app’s process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jv6hb2LFLiVCuhqwxDRu5A.png" /></figure><h3><strong>The Target</strong></h3><p>To walk through the full process we need an app to inject into. We’ll use a Flappy Bird-style game: simple, no protections, easy to verify things are working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*-mu8AxYnKp97IbFzY1ZvzA.png" /></figure><p>Let’s check logcat with the app running to confirm there’s nothing there yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64hNsL-o1Z67JCzN4miUnQ.png" /></figure><p>Goal: inject Frida Gadget into this app and get a script printing “Hello World from Frida Gadget!” to logcat, without root.</p><h3><strong>Downloading Frida Gadget</strong></h3><p>Gadget releases are published alongside the rest of the Frida tooling at <a href="https://github.com/frida/frida/releases">https://github.com/frida/frida/releases</a>. You want the file named:</p><pre>frida-gadget-&lt;version&gt;-android-arm64.so.xz</pre><p>Decompress it and rename it to a valid Android shared library name:</p><pre>xz -d frida-gadget-&lt;version&gt;-android-arm64.so.xz<br>mv frida-gadget-&lt;version&gt;-android-arm64.so libfrida-gadget.so</pre><h3><strong>Pulling and Decompiling the APK</strong></h3><p>This game uses split APKs. The native libraries live in the architecture split, not in the base APK. Pull everything from the device:</p><pre>adb shell pm path com.rectfy.birdybird<br># lists all APK paths for this package<br><br>adb pull /data/app/.../base.apk<br>adb pull /data/app/.../split_config.arm64_v8a.apk<br>adb pull /data/app/.../split_config.en.apk<br>adb pull /data/app/.../split_config.xxhdpi.apk</pre><p>Only the base needs to be decompiled. The manifest and smali changes go there. The architecture split gets patched in place later with zip, no decompile needed:</p><pre>apktool d base.apk -o base/</pre><h3><strong>Fixing extractNativeLibs</strong></h3><p>Before anything else, open game/base/AndroidManifest.xml and find this attribute on the &lt;aapplication&gt; tag:</p><pre>&lt;application android:extractNativeLibs=&quot;false&quot; ...&gt;</pre><p>Change it to:</p><pre>&lt;application android:extractNativeLibs=&quot;true&quot; ...&gt;</pre><p>With extractNativeLibs=”false”, Android maps native libraries directly from inside the APK ZIP without extracting them to disk. Gadget in script mode needs to find the script file next to the .so on the filesystem. If there’s no extraction, there’s no path on disk to look at. Setting this to true forces Android to extract all .so files to data/app/&lt;package&gt;/lib/arm64/ at install time.</p><p>The catch is that Android only extracts files with the .so extension. That’s why we will name our script libfrida-gadget.script.so so Android thinks it is a native library and extracts it alongside the Gadget.</p><h3><strong>Writing the Script</strong></h3><p>We’ll use script mode so the Gadget runs the script automatically at startup, no interactive connection needed.</p><p>Recent versions of Frida Gadget no longer accept plain JavaScript directly. The Gadget expects a compiled bundle produced by frida-compile. Passing a raw .js file will fail silently or throw an error depending on the version.</p><p>Install frida-compile:</p><pre>npm install -g frida-compile</pre><p>Write the source script. The import Java from &#39;frida-java-bridge’line is required by frida-compile to resolve the Java bridge:</p><pre>import Java from &quot;frida-java-bridge&quot;;<br><br>Java.perform(() =&gt; {<br>    const Log = Java.use(&quot;android.util.Log&quot;);<br>    Log.d(&quot;FLAPPY_GADGET&quot;, &quot;Hello World from Frida Gadget!&quot;);<br>});</pre><p>Compile it into a local directory alongside the other Gadget files:</p><pre>frida-compile agent.js -o libfrida-gadget.script.so</pre><h3><strong>Configuring the Gadget</strong></h3><p>Create the config file. The filename must be libfrida-gadget.config.so. The .so extension is what makes Android extract it at install time. The content is plain JSON:</p><pre>{<br>  &quot;interaction&quot;: {<br>    &quot;type&quot;: &quot;script&quot;,<br>    &quot;path&quot;: &quot;libfrida-gadget.script.so&quot;<br>  }<br>}</pre><p>A path with no directory component tells Gadget to look in the same directory it was loaded from. At this point you should have three files ready to inject:</p><pre>libfrida-gadget.so<br>libfrida-gadget.config.so<br>libfrida-gadget.script.so</pre><p>These get zipped into the architecture split in the next step, not copied into a decompiled directory.</p><h3><strong>Loading the Gadget at Startup</strong></h3><p>The Gadget only runs if something loads it. The entry point for this game is AndroidLauncher, declared as the LAUNCHER activity in the manifest:</p><pre>&lt;activity android:name=&quot;com.rectfy.birdybird.AndroidLauncher&quot; 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;</pre><p>Open AndroidLauncher.smali and find onCreate. Before the patch it looked like this:</p><pre>.method protected onCreate(Landroid/os/Bundle;)V<br>    .locals 0<br><br>    .line 1<br>    invoke-super {p0, p1}, Landroid/app/Activity;-&gt;onCreate(Landroid/os/Bundle;)V</pre><p>Add the loadLibrary call before the invoke-super:</p><pre>.method protected onCreate(Landroid/os/Bundle;)V<br>    .locals 1<br><br>    .line 1<br>    const-string v0, &quot;frida-gadget&quot;<br>    invoke-static {v0}, Ljava/lang/System;-&gt;loadLibrary(Ljava/lang/String;)V<br><br>    invoke-super {p0, p1}, Landroid/app/Activity;-&gt;onCreate(Landroid/os/Bundle;)V</pre><p>Three things changed:</p><ul><li>First, .locals 1 instead of .locals 0 because v0 is now used to hold the string. Without this the bytecode verifier rejects the recompiled output.</li><li>Second, const-string v0 “frida-gadget”loads the library name. loadLibrary takes the name without the lib prefix and without .so.</li><li>The call goes before invoke-super so the Gadget loads as early as possible, before the Activity framework initializes anything.</li></ul><h3><strong>Rebuild and Install</strong></h3><p>The base APK gets rebuilt with apktool since that’s where the manifest and smali changes are. The architecture split is handled differently: instead of decompiling and recompiling it, we patch it in place by zipping the Gadget files directly into the existing APK.</p><pre># Rebuild only the base (manifest + smali changes)<br>apktool b base -o base_patched.apk<br><br># Patch the arm64 split by injecting the Gadget files into the existing APK<br>cp split_config.arm64_v8a.apk split_config.arm64_v8a_patched.apk<br>(cd split_config.arm64_v8a &amp;&amp; zip -r ../split_config.arm64_v8a_patched.apk lib/arm64-v8a/libfrida-gadget.*)<br><br># The remaining splits are unchanged, just copy them<br>cp split_config.en.apk split_config.en_patched.apk<br>cp split_config.xxhdpi.apk split_config.xxhdpi_patched.apk</pre><p>The zip command picks up all three Gadget files ( libfrida-gadget.so, libfrida-gadget.config.so, libfrida-gadget.script.so) via the glob.</p><p>Align and sign all APKs with the same keystore. Every split in an install session must share the same signature or Android rejects the install:</p><pre>for apk in base_patched.apk split_config.arm64_v8a_patched.apk split_config.en_patched.apk split_config.xxhdpi_patched.apk; do<br>    zipalign -p -f 4 &quot;$apk&quot; &quot;${apk%.apk}_aligned.apk&quot;<br>    mv &quot;${apk%.apk}_aligned.apk&quot; &quot;$apk&quot;<br>done<br><br>for apk in base_patched.apk split_config.arm64_v8a_patched.apk split_config.en_patched.apk split_config.xxhdpi_patched.apk; do<br>    apksigner sign --ks ~/.android/debug.keystore --ks-pass pass:android --ks-key-alias androiddebugkey &quot;$apk&quot;<br>done</pre><p>Install the app:</p><pre>adb install-multiple base_patched.apk split_config.arm64_v8a_patched.apk split_config.en_patched.apk split_config.xxhdpi_patched.apk</pre><p>Launch it, Et voilà!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCklUGwrrRlCkR_hYHymBA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=667bc952d33d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Patching an Android App: Decompile, Modify, Rebuild]]></title>
            <link>https://medium.com/@cr0nos/patching-an-android-app-decompile-modify-rebuild-3fdfbb0377ad?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fdfbb0377ad</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[patching]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 07:51:23 GMT</pubDate>
            <atom:updated>2026-04-01T07:51:23.300Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Setup</strong></h3><p>For privacy reasons, we won’t disclose the name of the app we’re working with. It’s a standard Play Store release built with split APKs: a base plus a few config splits for architecture, language, and screen density. It uses a third-party license enforcement SDK.</p><p>The goal: install it outside the Play Store without triggering its protections.</p><p>To follow along you’ll need:</p><ul><li><strong>apktool</strong> for decompiling and rebuilding</li><li><strong>zipalign</strong> and <strong>apksigner</strong> from the Android SDK build-tools</li><li>A keystore for signing (we’ll generate one)</li><li><strong>adb</strong> for installation</li></ul><h3><strong>Understanding What You’re Up Against</strong></h3><p>Before touching anything, you need to understand what the protection actually does. This app has two independent layers:</p><p><strong>Layer 1: The OS layer (Play Protect).</strong> Before the app even launches, Android reads the manifest. If it finds splits.required=true combined with stamp.source=https://play.google.com/store, it blocks the install with a “Get this app from Play” screen. This is the OS making a decision, not app code. Patching smali won’t help here at all. We will need to patch the manifest.</p><p><strong>Layer 2: The app layer.</strong> Once the app is running, a ContentProvider fires before any Activity, instantiates a license client, and runs an installer check. That method checks whether the installer is com.android.vending and also tries to connect to Google’s licensing service for a RS256-signed token. The cryptographic part is impossible to fake. The local check is not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*E3MLb7emERsqrkZozL2ccg.jpeg" /></figure><p>The flow looks like this:</p><pre>Play Protect reads the APK<br>    └─&gt; stamp.source / splits.required  &lt;- Layer 1<br>            └─&gt; Blocks before launch<br><br>App starts<br>    └─&gt; ContentProvider.onCreate()      &lt;- remove this<br>            └─&gt; LicenseClient.startCheck()  &lt;- or empty this<br>                    ├─&gt; verifyInstallSource()     &lt;- or force true here<br>                    │       └─&gt; getInstallSourceInfo() != &quot;com.android.vending&quot; -&gt; kills app<br>                    └─&gt; connectToLicensingService()<br>                            └─&gt; RS256 signature from Google -&gt; can&#39;t fake this</pre><p>We will patch both: the manifest to get past the OS layer, and the smali to neutralize the license check inside the app.</p><h3><strong>Step 1: Decompile</strong></h3><pre>apktool d base.apk -o base/</pre><p>This produces a directory with AndroidManifest.xml, resources, and the decompiled smali source under smali_classes*/.</p><h3><strong>Step 2: Patch the Manifest</strong></h3><p>Open base/AndroidManifest.xml and remove these six entries.</p><p><strong>The stamp metadata</strong> (causes the Play Protect block):</p><pre>&lt;meta-data android:name=&quot;com.android.vending.splits.required&quot; android:value=&quot;true&quot;/&gt;<br>&lt;meta-data android:name=&quot;com.android.stamp.source&quot; android:value=&quot;https://play.google.com/store&quot;/&gt;<br>&lt;meta-data android:name=&quot;com.android.stamp.type&quot; android:value=&quot;STAMP_TYPE_DISTRIBUTION_APK&quot;/&gt;</pre><p><strong>The ContentProvider</strong> (bootstraps the entire license check system):</p><pre>&lt;provider<br>    android:authorities=&quot;com.example.app.licensecheck.LicenseContentProvider&quot;<br>    android:exported=&quot;false&quot;<br>    android:name=&quot;com.example.licensecheck.LicenseContentProvider&quot;/&gt;</pre><p><strong>The license activity and permission</strong> (cleanup):</p><pre>&lt;activity android:exported=&quot;false&quot; android:name=&quot;com.example.licensecheck.LicenseActivity&quot;/&gt;<br>&lt;uses-permission android:name=&quot;com.android.vending.CHECK_LICENSE&quot;/&gt;</pre><p>Removing the ContentProvider is the critical move. ContentProvider.onCreate() runs before Application.onCreate() and before any Activity. Without it, the license client never gets instantiated. The smali patches below are not strictly necessary at this point, but they illustrate what would have happened.</p><h3><strong>Step 3: Patch the Smali (Optional but Instructive)</strong></h3><p>Open the license client class under smali_classes2/.</p><h4><strong>verifyInstallSource</strong></h4><p>This method returns a boolean Z. It calls getInstallSourceInfo() and compares the result to &quot;com.android.vending”. If the check fails, the app calls System.exit().</p><p>Find the method signature:</p><pre>.method private verifyInstallSource()Z</pre><p>Replace the entire body so it always returns true:</p><pre>.method private verifyInstallSource()Z<br>    .locals 1<br><br>    const/4 v0, 0x1<br><br>    return v0<br><br>.end method</pre><p>0x1 is true. The method now returns immediately without ever checking the installer.</p><h4><strong>startCheck</strong></h4><p>This is the public entry point that orchestrates both the local check and the remote licensing call. Empty it out:</p><pre>.method public startCheck()V<br>    .locals 0<br><br>    return-void<br><br>.end method</pre><h3><strong>Step 4: Rebuild</strong></h3><p>From the directory containing base/:</p><pre>apktool b base -o base_patched.apk</pre><p>apktool recompiles the smali back to DEX and repacks everything.</p><h3><strong>Step 5: Zipalign</strong></h3><p>Android requires APKs to be memory-aligned before signing:</p><pre>zipalign -v 4 base_patched.apk base_patched_aligned.apk</pre><h3><strong>Step 6: Create a Keystore</strong></h3><p>If you don’t have one already:</p><pre>keytool -genkey -v \<br>  -keystore mykey.jks \<br>  -keyalg RSA \<br>  -keysize 2048 \<br>  -validity 10000 \<br>  -alias myalias</pre><p>Keep the password somewhere. You’ll need the same keystore for every APK in this install session.</p><h3><strong>Step 7: Sign Everything</strong></h3><p>The base APK:</p><pre>apksigner sign \<br>  --ks mykey.jks \<br>  --ks-key-alias myalias \<br>  --out base_signed.apk \<br>  base_patched_aligned.apk</pre><p>The splits must be signed with the same keystore. Android rejects an install if the signatures don’t match across all APKs in the session:</p><pre>apksigner sign --ks mykey.jks --ks-key-alias myalias \<br>  --out split_config.arm64_v8a_signed.apk split_config.arm64_v8a.apk<br><br>apksigner sign --ks mykey.jks --ks-key-alias myalias \<br>  --out split_config.en_signed.apk split_config.en.apk<br><br>apksigner sign --ks mykey.jks --ks-key-alias myalias \<br>  --out split_config.xxhdpi_signed.apk split_config.xxhdpi.apk</pre><p><strong>Step 8: Install</strong></p><p>Split APKs require an install session. adb install-multiplehandles this in one command:</p><pre>adb install-multiple \<br>  base_signed.apk \<br>  split_config.arm64_v8a_signed.apk \<br>  split_config.en_signed.apk \<br>  split_config.xxhdpi_signed.apk</pre><p>And that’s it. The app launches and lands straight on the login screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*5GuFPzBW1IUqlhyzFNeYCQ.jpeg" /></figure><h3><strong>Why the Two-Layer Distinction Matters</strong></h3><p>A common mistake when patching a protected app is going straight for the smali and ignoring the manifest. Here, skipping the manifest patch would have gotten you a “Get this app from Play” screen before a single line of your patched code ever ran.</p><p>The OS layer and the app layer are independent. The manifest controls what the OS does. The smali controls what the app does. If you patch only one, you’re only half done.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fdfbb0377ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reading Android Tombstones: Native Crash Forensics]]></title>
            <link>https://medium.com/@cr0nos/reading-android-tombstones-native-crash-forensics-e51932ced077?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e51932ced077</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Thu, 26 Mar 2026 09:58:29 GMT</pubDate>
            <atom:updated>2026-03-26T09:58:29.001Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>What is a Tombstone?</strong></h3><p>When a native process crashes on Android (a SIGSEGV, SIGABRT, or similar signal), the system doesn’t just close the app and move on. It writes a structured crash report to disk. Android calls these files <strong>tombstones</strong>.</p><p>You’ll find them here:</p><pre>&gt; adb shell ls /data/tombstones/<br>tombstone_00<br>tombstone_01<br>tombstone_02<br>...<br>tombstone_09</pre><p>The system keeps the last ten, cycling through tombstone_00 to tombstone_09. When the slot fills up, the oldest gets overwritten.</p><p>Pull the latest one:</p><pre>adb pull /data/tombstones/tombstone_00 .</pre><p>Or read it directly:</p><pre>adb shell cat /data/tombstones/tombstone_00</pre><h3><strong>Anatomy of a Tombstone</strong></h3><p>Here’s what a typical tombstone looks like:</p><pre>*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***<br>Build fingerprint: &#39;google/sdk_gphone64_arm64/emulator64_arm64:14/UE1A.230829.036/11028240:userdebug/dev-keys&#39;<br>Revision: &#39;0&#39;<br>ABI: &#39;arm64&#39;<br>Timestamp: 2025-03-20 11:42:07.312000000+0000<br>Process uptime: 2s<br>Cmdline: com.example.nativeapp<br>pid: 4512, tid: 4512, name: example.nativeapp  &gt;&gt;&gt; com.example.nativeapp &lt;&lt;&lt;<br>uid: 10185<br>tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)<br>signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000010<br>    x0  0000007b3f2a1000  x1  0000000000000010  x2  0000000000000000  x3  0000000000000000<br>    x4  0000000000000000  x5  0000000000000000  x6  0000000000000000  x7  0000000000000000<br>    x8  0000000000000038  x9  0000000000000000  x10 0000000000000000  x11 0000000000000000<br>    x12 0000000000000000  x13 0000000000000000  x14 0000000000000000  x15 0000000000000000<br>    x16 0000007b3a2c4f80  x17 0000007b3a3d1234  x18 0000007b3f400000  x19 0000007b3f2a1000<br>    x20 0000000000000000  x21 0000000000000000  x22 0000000000000000  x23 0000000000000000<br>    x24 0000000000000000  x25 0000000000000000  x26 0000000000000000  x27 0000000000000000<br>    x28 0000000000000000  x29 0000007ff3c21b80<br>    lr  0000007b3a1d4abc  sp  0000007ff3c21b60  pc  0000007b3a1d4ac4  pst 0000000060001000<br><br>backtrace:<br>  #00 pc 0000000000001ac4  /data/app/~~XZxN==/com.example.nativeapp-==/lib/arm64/libnative.so (Java_com_example_nativeapp_NativeLib_processData+132) (BuildId: 9a3f2c...)<br>  #01 pc 0000000000003210  /data/app/~~XZxN==/com.example.nativeapp-==/lib/arm64/libnative.so (BuildId: 9a3f2c...)<br>  #02 pc 00000000000874b0  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144)<br>  #03 pc 0000000000083a20  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+576)</pre><p>Let’s break it down section by section.</p><h4><strong>Header</strong></h4><pre>pid: 4512, tid: 4512, name: example.nativeapp  &gt;&gt;&gt; com.example.nativeapp &lt;&lt;&lt;<br>uid: 10185<br>signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000010</pre><ul><li><strong>pid/tid</strong>: process and thread that crashed</li><li><strong>signal</strong>: the signal that killed it. SIGSEGV means a segmentation fault. SIGABRT usually means the process called abort() itself, often from an assertion or a sanitizer.</li><li><strong>code</strong>: narrows down the cause. SEGV_MAPERR means the address is not mapped at all. SEGV_ACCERR means the address exists but the access was not permitted (e.g., writing to a read-only page).</li><li><strong>fault addr</strong>: the memory address that caused the fault. 0x10 is a classic null pointer dereference with a small offset, a struct field access through a null pointer.</li></ul><h4><strong>Register Dump</strong></h4><p>The full register state at the moment of the crash. In ARM64:</p><ul><li>x0- x7: function arguments and return values</li><li>x8: indirect result register (also the syscall number)</li><li>x29: frame pointer</li><li>lr: (link register): return address, i.e., where the function would have returned to</li><li>sp: stack pointer</li><li>pc: program counter, the instruction that caused the crash</li></ul><p>The pc is the most useful starting point. Subtract the library’s base address (visible in the backtrace or in /proc/&lt;pid&gt;/maps) to get the offset within the binary, then open it in your disassembler.</p><h4><strong>Backtrace</strong></h4><pre>backtrace:<br>  #00 pc 0000000000001ac4  /data/app/.../lib/arm64/libnative.so (Java_com_example_nativeapp_NativeLib_processData+132)</pre><p>Each frame shows:</p><ul><li>Frame number</li><li>PC offset within the library</li><li>Library path</li><li>Symbol name and byte offset from the start of the function (if symbols are present)</li></ul><p>The +132 means the crash happened 132 bytes into Java_com_example_nativeapp_NativeLib_processData. Open the library in radare2 or Ghidra, seek to that function, and count 132 bytes in.</p><p>If the binary is stripped (no symbols), you’ll just see the raw offset. That’s still enough to navigate with a disassembler.</p><h3><strong>What Tombstones Reveal During Reverse Engineering</strong></h3><p>When you’re analyzing a native library and something crashes, the tombstone gives you the exact instruction that faulted, the full register state at that instant, and the call chain that led there. A null-pointer crash at fault addr 0x10with x0 = 0x0in frame #00 at offset +132 in your target function tells you in seconds what would otherwise take hours of blind disassembly.</p><h3><strong>Forced Crashes as a Defense Mechanism</strong></h3><p>Not every tombstone is an accident. Some apps terminate themselves deliberately when they detect something they don’t like: a debugger attached, Frida in memory, an unexpected environment. Pairipcore does this, for example. The mechanism varies: abort(), raise() with an arbitrary signal, a deliberate null dereference, or killing a specific thread with pthread_kill().</p><p>The tell is in the backtrace. A genuine crash leads to code that was doing real work. A forced crash leads into a detection or integrity-check routine inside a protection library. The signal itself is less important than where the backtrace points.</p><p>When the backtrace from an unexpected crash points into an obfuscated or unfamiliar native library, treat it as a signal: you’ve triggered a tripwire. The tombstone tells you exactly which library initiated the kill and from what offset. That offset is your next target in the disassembler.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e51932ced077" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intercepting and manipulating HTTP traffic with mitmproxy addons]]></title>
            <link>https://medium.com/@cr0nos/intercepting-and-manipulating-http-traffic-with-mitmproxy-addons-4f8ef51dac44?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f8ef51dac44</guid>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Fri, 20 Mar 2026 08:46:31 GMT</pubDate>
            <atom:updated>2026-03-20T08:46:31.418Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Mitmproxy addons</strong></h3><p>Addons are Python scripts that hook into mitmproxy’s event system. The simplest way to run one is passing it to mitmdump with the -s flag:</p><pre>mitmdump -s addon.py</pre><p>For example, here’s an addon that logs every request URL to the console:</p><pre>import mitmproxy.http<br><br><br>class RequestLogger:<br>    def request(self, flow: mitmproxy.http.HTTPFlow) -&gt; None:<br>        print(f&quot;Request to URL: {flow.request.pretty_url}&quot;)<br><br><br>addons = [RequestLogger()]</pre><p>Before running the addon, make sure your Android device is configured to use your machine as an HTTP proxy (connected to the correct port) and that the mitmproxy CA certificate is installed as a trusted certificate. Once that’s done, save the addon as addon.py and run:</p><pre>&gt; mitmdump -p 8081 -s addon.py --quiet<br>Request to URL: https://mobile.events.data.microsoft.com/OneCollector/1.0/<br>Request to URL: https://mobile.events.data.microsoft.com/OneCollector/1.0/<br>Request to URL: https://www.gstatic.com/chrome/ntp/suggested_sites_ES_5.json<br>Request to URL: https://static.xx.fbcdn.net/rsrc.php/v3/yj/r/gB76kJXPYJV.png<br>...</pre><p>Every intercepted request will now print its URL to stdout.</p><h3><strong>Examples</strong></h3><p>Here are some practical examples of what you can do with addons. Domain names and URLs have been replaced with generic placeholders for privacy and security reasons.</p><h4><strong>Modifying requests</strong></h4><p>Add a custom header to every outgoing request. Useful for injecting auth tokens or tracing IDs during testing.</p><pre>from mitmproxy import http<br><br><br>class AddHeader:<br>    def request(self, flow: http.HTTPFlow) -&gt; None:<br>        flow.request.headers[&quot;X-Debug&quot;] = &quot;mitmproxy&quot;<br>        print(f&quot;Added X-Debug header to {flow.request.pretty_url}&quot;)<br><br><br>addons = [AddHeader()]</pre><p>Output:</p><pre>&gt; mitmdump -p 8081 -s addon.py --quiet<br>Added X-Debug header to https://api.example.com/v1/feed<br>Added X-Debug header to https://api.example.com/v1/user/me<br>Added X-Debug header to https://cdn.example.com/logo.png<br>...</pre><h4><strong>Blocking requests to tracking domains</strong></h4><p>Kill requests to known analytics or tracking domains before they leave the device. The app keeps running but those requests are silently dropped. Useful for observing how an app behaves without telemetry.</p><pre>from mitmproxy import http<br><br>BLOCKED_DOMAINS = {<br>    &quot;analytics.example.com&quot;,<br>    &quot;events.data.microsoft.com&quot;,<br>    &quot;www.google-analytics.com&quot;,<br>}<br><br><br>class BlockTrackers:<br>    def request(self, flow: http.HTTPFlow) -&gt; None:<br>        if flow.request.pretty_host in BLOCKED_DOMAINS:<br>            print(f&quot;Blocked: {flow.request.pretty_host}&quot;)<br>            flow.kill()<br><br><br>addons = [BlockTrackers()]</pre><p>Output:</p><pre>&gt; mitmdump -p 8081 -s addon.py --quiet<br>Blocked: events.data.microsoft.com<br>Blocked: www.google-analytics.com<br>Blocked: events.data.microsoft.com<br>...</pre><h4><strong>Save headers for later usage</strong></h4><p>Capture the request headers of every intercepted request and append them to a local JSON file for later replay.</p><pre>import json<br>from mitmproxy import http<br><br><br>class SaveHeaders:<br>    def request(self, flow: http.HTTPFlow) -&gt; None:<br>        headers = dict(flow.request.headers)<br>        entry = {&quot;url&quot;: flow.request.pretty_url, &quot;headers&quot;: headers}<br>        with open(&quot;captured_headers.json&quot;, &quot;a&quot;) as f:<br>            f.write(json.dumps(entry) + &quot;\n&quot;)<br><br><br>addons = [SaveHeaders()]</pre><p>Each request appends one line to captured_headers.json:</p><pre>{&quot;url&quot;: &quot;https://api.example.com/v1/feed&quot;, &quot;headers&quot;: {&quot;Host&quot;: &quot;api.example.com&quot;, &quot;User-Agent&quot;: &quot;ExampleApp/2.1.0 (Android)&quot;, &quot;Authorization&quot;: &quot;Bearer eyJhbGci...&quot;, &quot;Accept&quot;: &quot;application/json&quot;}}<br>{&quot;url&quot;: &quot;https://api.example.com/v1/user/me&quot;, &quot;headers&quot;: {&quot;Host&quot;: &quot;api.example.com&quot;, &quot;User-Agent&quot;: &quot;ExampleApp/2.1.0 (Android)&quot;, &quot;Authorization&quot;: &quot;Bearer eyJhbGci...&quot;, &quot;Accept&quot;: &quot;application/json&quot;}}</pre><h4><strong>Returning a fake response (without hitting the server)</strong></h4><p>Intercept a specific endpoint and return a hardcoded response directly. The request never reaches the real server. Useful for mocking config endpoints.</p><pre>import json<br>from mitmproxy import http<br><br><br>MOCK_CONFIG = {<br>    &quot;maintenanceMode&quot;: False,<br>    &quot;forceUpgrade&quot;: False,<br>    &quot;minVersion&quot;: &quot;1.0.0&quot;,<br>    &quot;features&quot;: {&quot;darkMode&quot;: True, &quot;newDashboard&quot;: False},<br>}<br><br><br>class MockConfigEndpoint:<br>    def request(self, flow: http.HTTPFlow) -&gt; None:<br>        if flow.request.pretty_url == &quot;https://api.example.com/v1/config&quot;:<br>            flow.response = http.Response.make(<br>                200,<br>                json.dumps(MOCK_CONFIG),<br>                {&quot;Content-Type&quot;: &quot;application/json&quot;},<br>            )<br>            print(f&quot;Mocked: {flow.request.pretty_url}&quot;)<br><br><br>addons = [MockConfigEndpoint()]</pre><p>Output:</p><pre>&gt; mitmdump -p 8081 -s addon.py --quiet<br>Mocked: https://api.example.com/v1/config</pre><p>Assigning flow.response in the request hook short-circuits the connection. Mitmproxy returns the fake response immediately and never opens a connection to the server.</p><h4><strong>Modifying a response field</strong></h4><p>Intercept JSON responses and flip forceUpgrade from true to false . Common trick to bypass forced update dialogs in mobile apps.</p><pre>import json<br>from mitmproxy import http<br><br><br>class DisableForceUpgrade:<br>    def response(self, flow: http.HTTPFlow) -&gt; None:<br>        content_type = flow.response.headers.get(&quot;content-type&quot;, &quot;&quot;)<br>        if &quot;application/json&quot; not in content_type:<br>            return<br>        try:<br>            data = json.loads(flow.response.content)<br>        except ValueError:<br>            return<br>        if data.get(&quot;forceUpgrade&quot;) is True:<br>            data[&quot;forceUpgrade&quot;] = False<br>            flow.response.content = json.dumps(data).encode()<br>            print(f&quot;Modified forceUpgrade in {flow.request.pretty_url}&quot;)<br><br><br>addons = [DisableForceUpgrade()]</pre><p>Output:</p><pre>&gt; mitmdump -p 8081 -s addon.py --quiet<br>Modified forceUpgrade in https://api.example.com/v1/config</pre><h4><strong>Save connection metadata</strong></h4><p>Log TLS and HTTP version details for each request. Handy for fingerprinting how a client negotiates connections, or to correctly replicate an application behavior.</p><pre>import json<br>from mitmproxy import http<br><br><br>class SaveConnectionMetadata:<br>    def request(self, flow: http.HTTPFlow) -&gt; None:<br>        metadata = {<br>            &quot;url&quot;: flow.request.pretty_url,<br>            &quot;http_version&quot;: flow.request.http_version,<br>            &quot;tls_established&quot;: flow.client_conn.tls_established,<br>            &quot;tls_version&quot;: getattr(flow.client_conn, &quot;tls_version&quot;, None),<br>            &quot;alpn&quot;: getattr(flow.client_conn, &quot;alpn&quot;, None),<br>            &quot;cipher&quot;: getattr(flow.client_conn, &quot;cipher&quot;, None),<br>        }<br>        with open(&quot;connection_metadata.json&quot;, &quot;a&quot;) as f:<br>            f.write(json.dumps(metadata) + &quot;\n&quot;)<br><br><br>addons = [SaveConnectionMetadata()]</pre><p>Each request appends one line to connection_metadata.json:</p><pre>{&quot;url&quot;: &quot;https://api.example.com/v1/config&quot;, &quot;http_version&quot;: &quot;HTTP/2.0&quot;, &quot;tls_established&quot;: true, &quot;tls_version&quot;: &quot;TLSv1.3&quot;, &quot;alpn&quot;: &quot;h2&quot;, &quot;cipher&quot;: &quot;TLS_AES_128_GCM_SHA256&quot;}<br>{&quot;url&quot;: &quot;https://api.example.com/v1/feed&quot;, &quot;http_version&quot;: &quot;HTTP/2.0&quot;, &quot;tls_established&quot;: true, &quot;tls_version&quot;: &quot;TLSv1.3&quot;, &quot;alpn&quot;: &quot;h2&quot;, &quot;cipher&quot;: &quot;TLS_AES_128_GCM_SHA256&quot;}<br>{&quot;url&quot;: &quot;http://telemetry.example.com/ping&quot;, &quot;http_version&quot;: &quot;HTTP/1.1&quot;, &quot;tls_established&quot;: false, &quot;tls_version&quot;: null, &quot;alpn&quot;: null, &quot;cipher&quot;: null}</pre><h4><strong>Conditional proxy routing</strong></h4><p>Route requests through different upstream proxies depending on the target domain. For example, sending sensitive endpoints through a residential proxy while letting everything else go direct.</p><pre>import base64<br>from mitmproxy import http<br>from mitmproxy.connection import Server<br>from mitmproxy.net.server_spec import ServerSpec<br><br>PROXY_ROUTES = {<br>    &quot;api.example.com&quot;: (&quot;residential-proxy.example.com&quot;, 8080, &quot;user&quot;, &quot;pass&quot;),<br>    &quot;auth.example.com&quot;: (&quot;residential-proxy.example.com&quot;, 8080, &quot;user&quot;, &quot;pass&quot;),<br>}<br><br><br>class ConditionalProxyRouter:<br>    def request(self, flow: http.HTTPFlow) -&gt; None:<br>        route = PROXY_ROUTES.get(flow.request.host)<br>        if route is None:<br>            print(f&quot;{flow.request.host} -&gt; direct&quot;)<br>            return<br>        host, port, username, password = route<br>        proxy_spec = ServerSpec((&quot;http&quot;, (host, port)))<br>        if proxy_spec != flow.server_conn.via:<br>            if flow.server_conn.timestamp_start is not None:<br>                flow.server_conn = Server(address=flow.server_conn.address)<br>            flow.server_conn.via = proxy_spec<br>        print(f&quot;{flow.request.pretty_url} -&gt; via {host}:{port}&quot;)<br><br>    def http_connect_upstream(self, flow: http.HTTPFlow) -&gt; None:<br>        route = PROXY_ROUTES.get(flow.request.host)<br>        if route is None:<br>            return<br>        _, _, username, password = route<br>        auth = base64.b64encode(f&quot;{username}:{password}&quot;.encode()).decode()<br>        flow.request.headers[&quot;Proxy-Authorization&quot;] = f&quot;Basic {auth}&quot;<br><br><br>addons = [ConditionalProxyRouter()]</pre><p>Output:</p><pre>&gt; mitmdump -p 8081 -s addon.py --quiet<br>https://api.example.com/v1/feed -&gt; via residential-proxy.example.com:8080<br>https://auth.example.com/oauth/token -&gt; via residential-proxy.example.com:8080<br>cdn.example.com -&gt; direct<br>https://api.example.com/v1/user/me -&gt; via residential-proxy.example.com:8080</pre><p>flow.server_conn.via sets the upstream proxy for the connection. http_connect_upstream injects the Proxy-Authorization header on HTTPS CONNECT requests so the proxy can authenticate the tunnel before it’s established.</p><h3><strong>Conclusion</strong></h3><p>Mitmproxy addons turn a proxy into a programmable layer between your app and the network. With just a few lines of Python you can log, modify, block, or redirect any request without touching the app itself. The examples in this article barely scratch the surface: the same building blocks can be combined to build more complex flows, like capturing specific requests for replay, simulating backend responses, or routing traffic through different proxies per session. If you’re working with mobile apps and need to understand or control what’s going over the wire, addons are the right tool for the job.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f8ef51dac44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Controlling an Android Device Without Root or Accessibility Services]]></title>
            <link>https://medium.com/@cr0nos/controlling-an-android-device-without-root-or-accessibility-services-ea8314822a99?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea8314822a99</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Wed, 18 Mar 2026 10:51:06 GMT</pubDate>
            <atom:updated>2026-03-18T10:51:06.877Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Permission Wall</strong></h3><p>Android apps live in a sandbox. There are things they simply cannot do: uninstall other apps, set a global proxy, read another app’s logcat output, or perform gestures without declaring the Accessibility Services permission.</p><p>These aren’t bugs. They’re deliberate restrictions enforced by the Android permission model. Normal apps run as unprivileged users, and the system blocks these actions at the API level.</p><p>But have you ever connected to your device over adb? All of those actions are available right there:</p><pre># Uninstall an app<br>adb uninstall com.your.package<br><br># Set a global proxy<br>adb shell settings put global http_proxy IP:PORT<br><br># Simulate gestures<br>adb shell input tap X Y<br>adb shell input swipe X1 Y1 X2 Y2<br><br># Read logcat from another app<br>adb logcat | grep com.other.package</pre><p>adb runs as the shell user — one level above a normal app and one level below root. That’s enough for all of the above.</p><p>So the question becomes: what if an app could issue adb commands from within the device itself?</p><h3><strong>Wireless Debugging</strong></h3><p>Android supports Wireless Debugging — a feature that opens two TCP ports: one for pairing, and one for the adb protocol connection itself. Once paired, any device holding the right certificate can send ADB commands over the network, and those commands execute with shell privileges.</p><h3><strong>The App</strong></h3><p>What if we build an app that completes the Wireless Debugging pairing flow, connects to the adb port, and starts sending adb protocol messages directly from the device? It turns out you can — and that’s exactly what this PoC I created does: <a href="https://github.com/pabloajoinglez/AdbShellTool">https://github.com/pabloajoinglez/AdbShellTool</a>.</p><p>To use it, pair the app with Wireless Debugging. After that, it can execute arbitrary shell commands directly from within the app — no root, no special permissions declared.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*hu5LbiMOl56KJYxs_KbdWg.gif" /><figcaption>Application adb pairing and connection</figcaption></figure><h3><strong>What It Can Do</strong></h3><p>Here are some examples:</p><p>Check the current user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*1qgFbQzmJpzNEwxnWwcj0Q.gif" /></figure><p>Uninstall another app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*2wGOTUEptOfSIjiqXpFs7g.gif" /></figure><p>Take a screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*P_rqsoQgBod9Iefg7yqoCQ.gif" /></figure><p>Open a sensitive app without any declared permissions 💀:</p><pre>input keyevent 3; sleep 1; input swipe 500 1500 500 500; sleep 1; input tap 427 1425</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*jHx1C6dXoRZSuevf4OiHtA.gif" /></figure><h3><strong>Consequences</strong></h3><p>An app exploiting this technique can open banking apps and take screenshots of them, access files on the SD card, install or remove apps silently, or intercept traffic by setting a global proxy — all without declaring a single dangerous permission in its manifest.</p><p>What makes it worse: the app that gains these privileges doesn’t have to look suspicious at all. A seemingly harmless app could acquire shell access through Wireless Debugging, and then other apps on the device could leverage it to perform privileged actions through it.</p><p>Wireless Debugging is a legitimate developer feature, but it’s also an unguarded path to shell-level access for any app willing to speak the right protocol. The takeaway is simple: on a device with Wireless Debugging enabled, the permission manifest means a lot less than you’d think.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea8314822a99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Freezing Time: How to Install Older APK Versions Using Aurora Store]]></title>
            <link>https://medium.com/@cr0nos/freezing-time-how-to-install-older-apk-versions-using-aurora-store-727a8b792248?source=rss-b77e5c958b2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/727a8b792248</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Pablo Ajo]]></dc:creator>
            <pubDate>Fri, 13 Mar 2026 09:34:14 GMT</pubDate>
            <atom:updated>2026-03-13T09:34:14.576Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Aurora Store?</h3><p>If you’ve spent any time doing Android reverse engineering, you’ve probably hit this wall: you need a specific version of an app — not the latest one, not whatever Google decides you should have — a <em>specific</em> one. Maybe you’re reproducing a vulnerability, or maybe you’re analyzing an older API flow.</p><p>Google Play doesn’t give you that. APK hosting sites like APKMirror or APKPure are unreliable. <a href="https://github.com/whyorean/AuroraStore"><strong>Aurora Store</strong></a> is the clean solution.</p><p>Aurora Store is an open-source, unofficial Google Play client. It lets you browse, search, and download apps from Google’s own infrastructure. Crucially for our purposes, it gives you access to <strong>version history</strong>: the ability to download older releases of any app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/0*qvVcOzxU671ptWwg.png" /><figcaption>Aurora Store</figcaption></figure><h3>When the App You Need Has Already Been Taken Down</h3><p>For privacy reasons, we won’t disclose the name of the app we’re working with. Let’s call it <strong>SuperSafeApp</strong>.</p><p>We start by searching for older versions of SuperSafeApp and find a few links on APKMirror.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GT_fdh3mOsqYRcitigY30w.png" /><figcaption>SuperSafeApp Google search</figcaption></figure><p>When we try to download them — surprise. The app was taken down due to a DMCA notice. Every link is dead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8GyFVouiO12e_YOEIeuEw.png" /><figcaption>APKMirror result</figcaption></figure><p>This is where Aurora Store becomes essential. Download it from the <a href="https://auroraoss.com/">official site</a>. Once installed, open it and search for SuperSafeApp. Then tap the three-dot menu and select “<strong>Manual Download”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*qqTUna8wPhKvzjfZiSD_uA.png" /><figcaption>Aurora Store manual download</figcaption></figure><p>Enter the version code you found earlier in the APKMirror search results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*ZbTYssTC-10H6oSJHKo9mg.png" /><figcaption>Aurora Store manual download version code</figcaption></figure><p>That’s it — Aurora pulls the APK directly from Google’s CDN, even for apps that are no longer publicly listed on the Play Store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*D6tOnhZZz66Vq6GIjEvKpw.png" /><figcaption>SuperSafeApp version information</figcaption></figure><p>One last thing: if you launch the app, you’ll likely run into a forced upgrade dialog blocking you from using it because the version is “too old”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*Gn4Db_7B6KFQMDBKtD3xnw.png" /><figcaption>Force upgrade dialog</figcaption></figure><p>But that dialog? It’s just a boolean. And booleans can be flipped — more on that in the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=727a8b792248" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>