<?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 Muhammedmedhat on Medium]]></title>
        <description><![CDATA[Stories by Muhammedmedhat on Medium]]></description>
        <link>https://medium.com/@muhammedmedhat235?source=rss-7e73af291e3c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WO7VMfNjcANyIj78</url>
            <title>Stories by Muhammedmedhat on Medium</title>
            <link>https://medium.com/@muhammedmedhat235?source=rss-7e73af291e3c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:25:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhammedmedhat235/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[Android — Bypassing Commercial RASP Solutions]]></title>
            <link>https://meetcyber.net/android-bypassing-commercial-rasp-solutions-1427f66ba335?source=rss-7e73af291e3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1427f66ba335</guid>
            <category><![CDATA[mobile-app-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[android-security]]></category>
            <dc:creator><![CDATA[Muhammedmedhat]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 15:21:50 GMT</pubDate>
            <atom:updated>2026-11-17T15:21:50.513Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Disclaimer:</em></strong><em> This write-up is for educational purposes and authorized security research only. The techniques described come from hands-on Android reverse-engineering work and should only be used against applications you own or are explicitly authorized to test.</em></p><h3>Introduction</h3><p>This write-up walks through the approach I use during Android security assessments to analyze and bypass various commercial Runtime Application Self-Protection (RASP) solutions.</p><p>I’ve applied this methodology successfully against several commercial RASP implementations. My main tools are static analysis and Smali patching, and I bring in dynamic analysis and runtime instrumentation only when they’re actually needed.</p><p>Rather than treating every RASP solution as a brand-new puzzle, I try to understand how its protection mechanisms are wired into the app, figure out where the application layer talks to the native protection layer, and then adjust the execution flow so the app runs normally.</p><p>The methodology breaks down into these stages:</p><ol><li>Static analysis and RASP identification</li><li>Understanding the application and native protection layers</li><li>Native library loading and function analysis</li><li>Smali patching and native function replacement</li><li>Crash analysis and execution flow correction</li><li>Handling runtime string decryption</li><li>Handling additional protections, including app sealing</li></ol><h3>1. Step One — Static Analysis and RASP Identification</h3><p>The first step is static analysis, aimed at understanding how the RASP solution is wired into the app.</p><p>At this stage, I’m trying to build a picture of the protection architecture, so I ask myself a few questions:</p><ul><li>When does the RASP initialize?</li><li>At what point does the app load its native protection libraries?</li><li>Which lifecycle methods kick off the initialization?</li><li>What security checks happen at the application level?</li><li>What gets delegated down to native code?</li><li>How does the app talk to the RASP implementation?</li></ul><p>Jadx-GUI, Apktool, and JD-GUI all work well for this.</p><p>One of the first things I look for is how System.load() and System.loadLibrary() are used:</p><pre>System.load()<br>System.loadLibrary()</pre><p>I search the app’s code for these calls and check which libraries are actually being loaded, to figure out which ones belong to the RASP solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B3KyzLuQz0ipCT9vwuSjxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d4zOT2ReAJcBIsWL_bbAHg.png" /></figure><p>I also look at the surrounding code to understand when and why each library gets loaded.</p><h3>1.1. Different RASP Implementation Approaches</h3><p>Commercial RASP vendors don’t all build things the same way. A few patterns I keep running into:</p><p><strong>Approach A — Early Integrity Checks</strong></p><p>Some solutions kick off their protection mechanisms very early, inside Application.attachBaseContext():</p><pre>Application.attachBaseContext()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRkC6pPTvoYDv_j-1CPVJg.png" /></figure><p>In one app I looked at, an integrity check runs during attachBaseContext(), right before the native protection library gets loaded — meaning the protection starts before the app even reaches its normal startup flow.</p><p><strong>Approach B — Runtime String Encryption and Decryption</strong></p><p>A different approach encrypts sensitive strings inside the app. Instead of keeping readable strings in the DEX files, the app stores encrypted values and decrypt them at runtime through native functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kCN3nZc4eSXrao7Xm3vyRw.png" /></figure><p>Here, the native library isn’t just doing initialization and integrity checks — it’s also providing functionality the app depends on while it’s running.</p><p>Figuring out which approach you’re dealing with matters, because the patching strategy changes depending on how deeply the protection is woven into the app.</p><h3>2. Step Two — Understanding the Native Protection Layer</h3><p>Once I’ve identified the RASP implementation and its native libraries, I move on to the native layer.</p><p>Commercial RASP native libraries are usually obfuscated pretty heavily, which makes reversing them directly slow going. So instead of burning all my time trying to fully understand the native code, I focus on the application layer and look at how the app talks to the library.</p><p>What I’m after:</p><ul><li>Which native methods the app declares or exposes</li><li>Every call site for those methods</li><li>When they get invoked</li><li>Whether they handle initialization, integrity checks, runtime decryption, or something else</li><li>Which execution paths depend on what they return</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXU814vb_UosUoP6PzeHUQ.png" /></figure><p>For example, I’ll look at native method declarations alongside where they’re actually called from in the app.</p><p>That’s usually enough to understand what a native function is doing without reversing the whole library — the key is understanding how the native functions relate to the app’s execution flow, not necessarily what’s happening inside them.</p><h3>2.1. Native Activity Lifecycle Callbacks</h3><p>Another thing I run into often with commercial RASP: native implementations of Android Activity lifecycle callbacks.</p><p>Instead of plain Java implementations, some RASP solutions declare lifecycle methods as native and hand them off to the protection library — callbacks like:</p><pre>onActivityCreated()<br>onActivityStarted()<br>onActivityResumed()<br>onActivityPaused()<br>onActivityStopped()<br>onActivityDestroyed()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*-VGyiT1XDY_BxGr805Gyuw.png" /></figure><p>During static analysis, I specifically check whether any of these callbacks are native, and how they’re registered and invoked. Since these can be part of the RASP’s monitoring and init logic, stripping out the native library without dealing with them first usually causes crashes or weird behavior down the line.</p><p>So I treat them as part of the native method analysis and patch them at the same stage as everything else.</p><h3>3. Step Three — Native Library Loading and Smali Patching</h3><p>Once I understand how the app talks to the RASP’s native library, I start modifying it at the Smali level. First, decompile with apktool:</p><pre>Apktool d app.apk    // decompile</pre><p>Then I find the Smali class that holds the methods I need to patch, using Jadx-GUI to locate the class first:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*JaY0biGj4080kwJq7Uw8_Q.png" /><figcaption>Smali folder here is Smali_classes</figcaption></figure><p>It’s usually right at the top of the class.</p><p>My changes generally fall into two categories:</p><ol><li>Removing or bypassing the native library loading.</li><li>Swapping native method implementations for regular application-level ones, where that’s safe to do.</li></ol><p>For example, if a native method is just handling initialization or a security check, I look at whether I can safely replace it with a plain Java implementation. In Smali, that means turning the native method declaration into a normal method body.</p><p>Depending on the method’s signature and what the app expects back, the replacement might:</p><ul><li>Return true</li><li>Return false</li><li>Return some fixed value</li><li>Return a placeholder string</li><li>Do nothing, if the original method returns void</li></ul><p>Which one is correct depends entirely on how the app uses the result.</p><p>One thing worth flagging: these changes shouldn’t be made blindly. A method that looks like a security check might also be doing initialization that some other part of the app relies on. So before I touch anything, I check its callers and the context it runs in.</p><h3>3.1. Replacing Native Activity Lifecycle Methods</h3><p>When I find lifecycle callbacks implemented natively, I replace them with regular Java methods at the Smali level too, keeping the original method signatures intact.</p><p>For callbacks that don’t need to do anything app-specific, an empty implementation usually works fine, as long as it doesn’t break the app’s normal lifecycle behavior.</p><p>This matters because the Android framework calls these methods automatically — if you leave a native declaration without a backing native implementation, the framework will crash trying to invoke it.</p><p>Two screenshots show this change:</p><ul><li><strong>Before patching:</strong> the original Java code, with lifecycle methods declared using the native keyword.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*x7xTm3rb7j8ByqLdKywFKw.png" /></figure><ul><li><strong>After patching:</strong> the same methods in Smali, now implemented as regular Java methods instead of native declarations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*D4nZKAVihslhNHt04jqMoQ.png" /></figure><p>That’s the full swap — native lifecycle callbacks replaced at the application layer.</p><h3>3.2. An Extra Step for Approach A (“Early Integrity Checks”)</h3><p>For Approach A — the early integrity check pattern — the check and native library loader both live inside Application.attachBaseContext(). I patch that method first, replacing it with a standard empty one.</p><p>Original:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRkC6pPTvoYDv_j-1CPVJg.png" /></figure><p>Replaced:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*jx3LWLqK8EH3dAN0JU-S6w.png" /></figure><h3>4. Step Four — Handling Integrity Checks and Application Crashes</h3><p>With the early-integrity-check approach, removing the native library loader can crash the app — which makes sense if other parts of the app still rely on those native methods, or if there are more integrity checks elsewhere. This is where crash analysis comes in.</p><h3>4.1. Identifying the Crash Point</h3><p>I generally use one of two approaches here.</p><p><strong>Approach A — Runtime Hooking</strong></p><p>I use Frida to hook the relevant methods and pull runtime info: where the exception happens, the exception itself, the path that led there, and the backtrace. That’s usually enough to tell me which component is failing and why.</p><p><strong>Approach B — Android Crash Logs</strong></p><p>Or I just pull the crash log buffer:</p><pre>adb logcat -b crash -v threadtime</pre><p>This gives me the exception details and stack trace directly, which I can use to find the exact function and line number in Smali.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhvDSLVCh9btH9_hMilvGw.png" /></figure><h3>4.2. Fixing the Flow, Not Just the Crash</h3><p>Here’s the important part: I don’t just patch the crash itself.</p><p>Instead, I go back one or two steps in the execution flow to find the condition or branch that actually caused the failure, and fix that instead.</p><p>This distinction matters a lot. If you only silence the exception or edit the code right at the crash site, the app might stop crashing there but still fail to finish initializing — it’ll just run into the next failure a bit further down the line, because the underlying path never got corrected.</p><p>So the real goal is to find the condition that’s causing the problem and fix it at the right point, repeating this for each exception until the app initializes cleanly and runs normally.</p><p><strong>The point isn’t to stop the crashes — it’s to get the app back onto a valid execution path.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*SF9QGaT-dSjmBy75qMaOsw.png" /></figure><h3>5. Step Five — Handling Runtime String Decryption</h3><p>The string-encryption approach needs a slightly different game plan.</p><p>In apps that rely on native string decryption, most native methods tend to run during attachBaseContext() — except for the decryption function itself. That&#39;s a pretty good sign that most of those other methods are handling init/integrity checks, while decryption is something the app needs throughout normal use.</p><h3>5.1. Replacing Native Methods</h3><p>Same as before — I replace the relevant native methods with regular Java ones at the Smali level. The decryption function needs more care, though.</p><p>If I just rip out its native implementation, the app will break the moment it tries to read an encrypted string. So instead, I first swap the native declaration for a method that returns a placeholder string — just enough to let the app keep running while I dig into the actual decryption logic separately.</p><h3>5.2. Figuring Out the Decryption Algorithm</h3><p>The core of this step is reproducing what the native decryption function does.</p><p>My usual approach is to build a simulation environment for the native library — feed it the encrypted input it expects and capture the plaintext it produces. Once I understand that input/output behavior, I can work on reproducing the logic outside the native code entirely.</p><p>I’ll sometimes use AI assistance to help turn the observed behavior into a working Python implementation, which then becomes the script that reproduces the decryption.</p><h3>5.3. Wiring the Python Logic Back In</h3><p>Once I’ve got a working Python version, I build a Frida-based bridge between the app and the Python script. Roughly:</p><ol><li>Hook the app’s string-decryption method.</li><li>Capture the encrypted string it’s passed.</li><li>Send that value over to the Python implementation.</li><li>Get back the decrypted plaintext.</li><li>Return that plaintext to the app.</li></ol><p>This lets the app get the strings it needs without touching the original native decryption code. The key thing to get right is matching the original function’s input/output behavior exactly — if the decryption logic works but the values come back in the wrong shape, the app can still fail downstream.</p><p>Here’s the AI prompt I use to help generate the Python implementation, included as a practical reference:</p><pre>I have a native Android library that encrypts API endpoint strings (or other sensitive strings). I need you to:<br><br>1. Analyze the binary to understand its encryption/decryption mechanism<br>2. Bypass any anti-tampering/RASP protections<br>3. Build a Unicorn-based emulation decryptor<br>4. Decrypt the provided encrypted strings<br><br>## Target Binary<br><br>- File path: [PATH_TO_SO_FILE]<br>- Architecture: [ARM64 / ARM32 / x86 / x86_64]<br>- Known encrypted strings (Base64-encoded):<br>  - [ENCRYPTED_STRING_1]<br>  - [ENCRYPTED_STRING_2]<br>  - [ENCRYPTED_STRING_3]<br><br>## Constraints<br><br>- No dynamic analysis (Frida/GDB) — the library has RASP protection<br>- The encryption key must be static (works across devices without device-specific data)<br>- Work entirely through static analysis + Unicorn emulation<br><br>## Methodology to Follow<br><br>### Step 1: Reconnaissance<br>- Parse the ELF structure (segments, DYNAMIC, relocations)<br>- Find JNI entry points: JNI_OnLoad and any registered native methods<br>- Identify obfuscation: OLLVM (control-flow flattening, string encryption), VMProtect, etc.<br>- Locate crypto library signatures: mbedTLS, OpenSSL, BoringSSL, or custom implementations<br>- Search for known constants: AES S-box (63 7C 77 7B...), DES tables, ChaCha constants, etc.<br><br>### Step 2: Identify the Decrypt Function<br>- Trace from JNI_OnLoad → RegisterNatives to find the native method that handles decryption<br>- The function typically: receives a jstring → JNI GetStringUTFChars → Base64 decode → decrypt → NewStringUTF → return<br>- Identify the core crypto functions by looking for xrefs to S-boxes, key schedule tables, or known crypto function signatures<br><br>### Step 3: Map RASP / Anti-Debug<br>- Look for BRK instructions (ARM64) or BKPT (ARM32) used as signal-based init<br>- Find BSS-section flags that gate execution paths (usually 4-byte integers checked with CMP/CBZ)<br>- Identify calls to: __system_property_get, getauxval, ptrace, /proc/self/maps reads, fopen(&quot;/data/local/tmp/...&quot;)<br>- Document all flag addresses and their roles<br><br>### Step 4: Build the Unicorn Emulator<br>Use Python + Unicorn Engine. The emulator must:<br><br>a) **Load the ELF correctly:**<br>   - Map all PT_LOAD segments at their virtual addresses<br>   - Process ALL relocation types from the RELA table:<br>     - R_AARCH64_RELATIVE (0x403) — base + addend<br>     - R_AARCH64_ABS64 (0x101) — symbol value + addend<br>     - R_AARCH64_GLOB_DAT (0x401) — symbol value + addend<br>     - R_AARCH64_JUMP_SLOT (0x402) — symbol value + addend<br>   - For imported symbols (st_value=0), allocate stub addresses in a dedicated region and write RET instructions there<br><br>b) **Mock the JNI environment:**<br>   - Create fake JavaVM with GetEnv function<br>   - Create fake JNIEnv with full vtable (300 function pointers → RET stubs)<br>   - Implement key JNI functions: FindClass, GetStringUTFChars, NewStringUTF, RegisterNatives, DeleteLocalRef<br>   - GetStringUTFChars should return a pointer to the input Base64 string<br><br>c) **Bypass RASP:**<br>   - Pre-set all initialization flags in BSS to 1<br>   - Handle BRK interrupts: set the next unset flag and restart execution<br>   - Return 0/NULL for: __system_property_get, getauxval, fopen, ptrace, etc.<br><br>d) **Emulate imported functions:**<br>   - Memory: malloc (bump allocator), calloc, free (no-op), memcpy, memset, memmove, memcmp, memchr<br>   - Strings: strlen, strcmp, strncmp, strcpy, strcat, strdup, strchr<br>   - Threading: pthread_mutex_lock/unlock (no-op), pthread_once (call init_routine once)<br>   - System: time (return fixed value), gettimeofday, getpid<br>   - Everything else: return 0<br><br>e) **Capture the decrypted result:**<br>   - Hook memcpy: when destination is on the heap and the data is valid printable UTF-8, capture it as the decrypted plaintext<br>   - Alternatively hook NewStringUTF to capture the return value<br><br>f) **Execution sequence:**<br>   1. Run JNI_OnLoad(JavaVM*) — registers native methods<br>   2. Run decrypt_function(JNIEnv*, jclass, jstring) — with the encrypted string as input<br>   3. Use a restart loop (up to 10 attempts) to handle BRK-based lazy initialization<br>   4. Capture plaintext from memcpy-to-heap or NewStringUTF<br><br>### Step 5: Iterate and Debug<br>- If emulation crashes with UC_ERR_READ_UNMAPPED: check if relocations were missed<br>- If BLR Xn → 0x0: imported symbol stub not resolved — check R_ABS64 / R_GLOB_DAT handling<br>- If stuck in infinite loop: check RASP flags or OLLVM dispatch values<br>- Add targeted hooks at suspected crypto functions to trace key material and round operations<br><br>### Step 6: Package the Decryptor<br>Create a clean decrypt.py that:<br>- Takes Base64 ciphertext strings as command-line arguments<br>- Initializes the emulator once (expensive: ~2 seconds)<br>- Decrypts each string individually (~1 second each)<br>- Prints plaintext results<br><br>## Output Expected<br>- The decrypted plaintext for each provided string<br>- A clean, reusable decrypt.py tool<br>- A brief summary of the protection layers and how they were bypassed</pre><h3>6. Step Six — Handling Additional Protection Mechanisms: App Sealing</h3><p>Some apps add extra protection like app sealing, which makes static analysis harder. In these cases, the original DEX files aren’t sitting in the APK in a form you can analyze with the usual tools.</p><p>So before I can even start the normal analysis process, I need to get the app running and pull the DEX files straight from the device. My workflow:</p><ol><li>Install and launch the app.</li><li>Let it finish its loading/initialization process.</li><li>Pull the DEX files out of the running app.</li><li>Convert them to JAR with dex2jar.</li><li>Open the JARs in JD-GUI.</li><li>Start analyzing the recovered classes and find the RASP integration points.</li></ol><p>This lets me keep working with the recovered code instead of being stuck with just the original APK.</p><h3>6.1. Handling the Native Library</h3><p>Depending on how the app is built, I might also need to deal with the native library itself.</p><p>If removing or modifying the native library loading at the application level is enough, there’s often no need to delete the library from the APK at all. But if the app still needs it, or tries to load it some other way, I look at whether removing the library itself makes sense.</p><p>That decision comes down to the app’s dependencies and how the RASP initialization is implemented. My preference is always to make changes at the application layer first, and only touch other components if I really have to.</p><h3>7. Rebuilding the App</h3><p>After making the changes, I build the app with apktool and test it:</p><pre>apktool b Patched_app_folder/</pre><p>Once it’s built, sign it and you’re ready to go.</p><h3>8. Overall Methodology</h3><p>Commercial RASP solutions differ in how they’re implemented, but my general workflow stays pretty consistent across all of them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*JOBnhf8N6Ltf-tKmhSmoog.png" /></figure><h3>9. Conclusion</h3><p>What I’ve learned from working through commercial Android RASP solutions is that understanding how the application layer talks to the native protection layer is usually more useful than trying to fully reverse engineer a heavily obfuscated native library.</p><p>The core idea is to figure out what the app actually depends on from the RASP implementation, understand the execution flow, and work out which native operations can be replaced or reproduced at the application level — not just native init and integrity checks, but native lifecycle callbacks and runtime string decryption too.</p><p>Smali patching is still my go-to technique, since it gives direct control over the app’s execution flow and lets me fix the relevant methods and conditions without having to fully reverse the native protection layer.</p><p>For the trickier cases, I combine static analysis with Frida, Android crash logs, Python-based logic reproduction, and DEX extraction.</p><p>In the end, the right approach depends on how the RASP is architected, how much the app relies on native functionality, and whatever extra protections the vendor has layered on top.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1427f66ba335" width="1" height="1" alt=""><hr><p><a href="https://meetcyber.net/android-bypassing-commercial-rasp-solutions-1427f66ba335">Android — Bypassing Commercial RASP Solutions</a> was originally published in <a href="https://meetcyber.net/">MeetCyber</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Xamarin Root and SSL Pinning Bypass]]></title>
            <link>https://meetcyber.net/xamarin-root-and-ssl-pinning-bypass-1a7da039b39b?source=rss-7e73af291e3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a7da039b39b</guid>
            <category><![CDATA[ssl-pinning-bypass]]></category>
            <category><![CDATA[root-detection-bypass]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[xamarin-android]]></category>
            <dc:creator><![CDATA[Muhammedmedhat]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 10:35:02 GMT</pubDate>
            <atom:updated>2026-01-26T13:11:29.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoXjFyt8xLCGZtBqObPW3A.png" /></figure><h3>Introduction</h3><p>Many Android applications implement root detection and SSL pinning mechanisms to prevent tampering, protect sensitive functionality, and secure network communications. While effective against casual users, these controls can hinder legitimate security research by restricting analysis on rooted test devices and blocking traffic inspection.</p><p>In this post, I describe how both root detection and SSL pinning were bypassed in a Xamarin-based Android application using static reverse engineering techniques. The approach focuses on de-compiling the application, extracting and modifying Xamarin assemblies, and rebuilding the app without relying on runtime hooking or dynamic instrumentation frameworks.</p><p>This work was conducted strictly for educational and authorized security testing purposes, with the goal of understanding and evaluating mobile application security controls.</p><h3>Tools Used</h3><p>The following tools were used throughout the analysis and bypass process:</p><ul><li><strong>ADB</strong> (installed within Android SDK platform tools)</li><li><strong>Jadx-Gui</strong></li><li><strong>APKTool</strong></li><li><a href="https://github.com/jakev/pyxamstore"><strong>pyxamstore</strong></a></li><li><strong>dnSpy</strong></li><li><strong>zipalign</strong> (installed within Android SDK platform tools)</li><li><strong>apksigner</strong> (installed within Android SDK platform tools)</li></ul><h3>Target Application Overview</h3><p>The target application is a Xamarin-based Android app that implements managed root detection and SSL pinning logic within its .NET assemblies.</p><p>The primary challenge of this assessment was bypassing these security mechanisms, as the checks are enforced at the managed code level rather than through native libraries, making traditional smali-only patching ineffective</p><h3>High-Level Attack Methodology</h3><p>The overall approach followed in this research can be summarized in the following steps:</p><ul><li>Extracting the APK from a rooted device</li><li>Reverse engineering application package</li><li>Extracting Xamarin (.NET) assemblies</li><li>Patching the managed root detection logic and SSL pinning Methods</li><li>Rebuilding, aligning, and re-signing the application</li></ul><h3>Step-by-Step Technical Walk-through</h3><h3>Step 1: Extracting the APK from a rooted device</h3><p>The first step is extracting the target APK from the rooted device to begin static analysis.</p><p>To do this, we first need to identify the application package name. In my case, this was done using the following command:</p><pre>adb shell pm list packages</pre><p>To save time and filter the results, I used <strong>grep </strong>to search for the target package name:</p><pre>adb shell pm list packages | grep -i example</pre><blockquote><strong>Note: </strong>On Windows systems, <strong>Select-String</strong> can be used instead of <strong>grep</strong>.</blockquote><p>The output revealed the package name: like `com.example.com`</p><p>Next, I retrieved the APK path associated with this package using:</p><pre>adb shell pm path com.example.com</pre><p>This command returned the full path to the APK file onto the device.</p><p>Finally, I pulled the APK from the device to my local machine using:</p><pre>adb pull &lt;APK_PATH_FROM_PREVIOUS_COMMAND&gt;</pre><p>At this point, the APK was successfully extracted and ready for further reverse engineering and analysis.</p><h3>Step 2: Reverse Engineering the APK and extracting DLL files</h3><p>At this stage, the extracted APK is reverse engineered to access its internal structure and resources.</p><p>First, <strong>APKTool</strong> was used to de-compile the application:</p><pre>apktool d com.example.com.apk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ivshdQ1muXyKDBDhX5-xBQ.png" /><figcaption><em>Figure 1 De-Compiled Files</em></figcaption></figure><p>Once the de-compilation process is completed, I navigated to the following directory within the extracted application folder:</p><blockquote><strong>app_folder/unknown/assemblies</strong></blockquote><p>This directory contains the Xamarin assemblies bundled with the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*8QbzgdozE8YuRAtUwG_OGg.png" /><figcaption><em>Figure 2 Assemblies files in app_folder/unknown/assemblies</em></figcaption></figure><p>To avoid modifying the original extracted files, the <strong>assemblies</strong> folder was copied to a new working directory.</p><p>Next, the <strong>pyxamstore</strong> tool was used to unpack the Xamarin assemblies into readable <strong>.dll</strong> files:</p><pre>pyxamstore unpack -d assemblies_folder_path</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_knxg9u7cuEFXGlSkMujg.png" /><figcaption><em>Figure 3 Unpacking to extract DLL Files</em></figcaption></figure><p>After running this command, two important artifacts were generated</p><ul><li>A new directory named <strong>out</strong>, containing the extracted <strong>.dll</strong> files</li><li>An <strong>assemblies.json</strong> file, which will later be required when repacking the patched assemblies</li></ul><p>At this point, the managed assemblies were successfully extracted and ready for static analysis and patching, which will be covered in the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*pkQe_OWoau96dBhhbkPpug.png" /><figcaption><em>Figure 4 Unpacked DLL Files</em></figcaption></figure><blockquote>Beginners often try to patch the classes.dex file (Smali) first. but in Xamarin, the Java/Smali code is just an <strong>Android Callable Wrapper (ACW)</strong>. It acts as a bridge. The “brain” of the app — where the security logic lives — is inside the .dll files within the assemblies.blob. Patching Smali is like trying to fix a car’s engine by painting the steering wheel.</blockquote><blockquote>Some high-security Xamarin apps enable a feature called “Bundle into Native Code.” * The Difference: Instead of finding .dll files in /assemblies, you might find a massive libmonodroid_bundle_app.so file in the lib/ folder.</blockquote><blockquote>Pro-Tip: If you encounter this, pyxamstore won’t work directly. You would first need to extract the DLLs from the .so file (which is essentially a compressed archive) before you can use dnSpy. Mentioning this edge case adds massive credibility to your report.</blockquote><h3>Step 3: Static Analysis and Patching the Root Detection Logic</h3><p>With the Xamarin assemblies extracted, the next step was to analyze and patch the root detection logic.</p><p>Using <strong>dnSpy</strong>, I imported the suspected <strong>.dll</strong> files that potentially contained the root and debugger detection mechanisms. The analysis started by locating the <strong>MainActivity</strong> and following the application execution flow to identify where security checks were triggered.</p><p>During the analysis, multiple root-related methods were identified, including:</p><ul><li><strong>isDeviceRooted</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxRzdEN-6bZ5EyqQDm7bcA.png" /><figcaption><em>Figure 5 Static Analysis to Get the root detection mechanism</em></figcaption></figure><p>As an alternative approach, dnSpy’s search functionality was also used to quickly locate relevant detection logic by searching for common keywords such as:</p><p><strong>rooted, hooked, frida, superapk, magisk</strong>, <strong>integrity</strong>.</p><p>This helped uncover additional root detection mechanisms scattered across the assemblies.</p><p>Once the relevant methods were identified, <strong>dnSpy</strong>’s Edit Class feature was used to modify the logic. The return values of the root and debugger detection methods were patched to always return <strong>false</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1u1ZV0tVKio0iZngpd4Nxw.png" /><figcaption><em>Figure 6 Editing the Method Return or Logic</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMZIAcQa_NOoZuSONXXs0Q.png" /><figcaption><em>Figure 7 Modified Function</em></figcaption></figure><p>After saving the modified assemblies, the root detection logic was successfully neutralized, completing the patching phase.</p><h3>Step 4: Patching the SSL Pinning Logic</h3><p>After successfully bypassing the root detection logic, the next step was to disable the SSL pinning mechanism implemented at the managed code level.</p><p>Using the same static analysis approach in <strong>dnSpy</strong>, I searched through the extracted Xamarin assemblies for certificate validation–related methods. This was done by looking for common SSL and networking keywords such as:</p><p><strong>HttpClientHandler, ServerCertificate, ValidationCallback, SslPolicyErrors</strong></p><p>During this process, I identified the following method responsible for enforcing SSL certificate validation:</p><blockquote><strong>ServerCertificateCustomValidationCallback</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WI9lSoJDO5BHXC3mBQf2bA.png" /><figcaption><em>Figure 8 ServerCertificateCustomValidationCallback Function</em></figcaption></figure><p>This method is part of the <strong>HttpClientHandler</strong> implementation and is used to validate the server’s TLS certificate during HTTPS connections. The application relied on this callback to enforce SSL pinning by rejecting untrusted or intercepted certificates.</p><p>To bypass SSL pinning, the method was patched using dnSpy’s <strong>Edit Class</strong> feature. The validation logic was modified so that the callback always returns <strong>true</strong>, effectively instructing the application to trust all certificates, regardless of their validity or trust chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I2xbLlu9VSk8Kt37H4Qb5Q.png" /><figcaption><em>Figure 9 After Modifications to bypass SSL Pinning</em></figcaption></figure><p>By forcing the certificate validation callback to always return <strong>true</strong>, SSL pinning was completely disabled. This allowed HTTPS traffic to be intercepted and analyzed without triggering certificate validation errors.</p><p>At this point, both root detection and SSL pinning mechanisms were successfully bypassed using purely static patching techniques, without relying on runtime hooking frameworks such as <strong>Frida</strong> or <strong>Xposed.</strong></p><h3>Step 5: Repacking the Patched Assemblies Using pyxamstore</h3><p>After patching the required <strong>.dll </strong>files, the next step was to repack the modified assemblies back into Xamarin’s original format.</p><p>Using <strong>pyxamstore</strong>, and from within the directory containing the <strong>out</strong> folder and the <strong>assemblies.json</strong> file, the following command was executed:</p><pre>pyxamstore pack</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*OHu3RPe9QplId5rkQ5OjiA.png" /><figcaption><em>Figure 10 Packing the Patched DLL Files</em></figcaption></figure><blockquote>Important: This command must be executed from the same directory that contains both the out folder and the assemblies.json file.</blockquote><p>Upon successful execution, two new files were generated:</p><ul><li><strong>assemblies.blob.new</strong></li><li><strong>assemblies.manifest.new</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*Xo7llPPl4ImdiHoVJMbvXQ.png" /><figcaption><em>Figure 11 New Assemblies after Patching and Packing</em></figcaption></figure><p>These newly generated files were then used to replace the original files located in:</p><pre>app_name/unknown/assemblies</pre><p>With this step completed, the patched Xamarin assemblies were successfully repacked and integrated back into the application structure.</p><h3>Step 6: Rebuilding, Aligning, and Signing the APK</h3><p>With the patched assemblies in place, the final step was to rebuild the APK and prepare it for installation.</p><ul><li><strong>Rebuilding the APK</strong></li></ul><p>The application was rebuilt using APKTool:</p><pre>apktool b app_folder</pre><p>After a successful build, the rebuilt APK is located at:</p><p><strong>app_folder/dist</strong></p><ul><li><strong>Aligning the APK</strong></li></ul><p>To optimize the rebuilt APK for proper memory alignment, the zipalign tool was used:</p><pre>zipalign -v 4 the_extracted_apk out.apk</pre><p>This produces a new aligned APK named <strong>out.apk</strong></p><ul><li><strong>Signing the APK</strong></li></ul><p>Before installation on a device, the APK must be signed using <strong>apksigner</strong>. A keystore is required for signing. If a keystore is not available, it can be generated using:</p><pre>keytool -genkeypair -v -keystore keystore-name.jks -alias alias -keyalg RSA -keysize 2048 -validity 10000</pre><p>Once the key store is ready, the APK can be signed:</p><pre>apksigner sign - ks-key-alias alias -ks ~/keystore-name.jks out.apk</pre><blockquote><strong>Note:<em> </em>apktool</strong>, <strong>zipalign</strong>, <strong>apksigner</strong>, and <strong>keytool</strong> are available via Android Studio or the Android SDK Platform Tools from the official Android website.</blockquote><p>After completing these steps, the APK is fully rebuilt, patched, aligned, and signed, making it ready for installation on a device using</p><pre>adb install out.apk</pre><blockquote>Professional apps often have a <strong>Secondary Integrity Check</strong>. Even if you bypass Root and SSL, the app might check its own signature at runtime.</blockquote><blockquote>If the app crashes immediately after your “Step 6,” it’s likely because the app detected it was re-signed with your debug key instead of the original developer’s key.</blockquote><blockquote><strong>The Fix:</strong> You would need to find the logic that calls PackageManager.getPackageInfo(..., GET_SIGNATURES) and patch that to return the original hash.</blockquote><h3>Step 7: IP-tables Traffic Routing to Burp Suite</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*7NhVIb9w7OCRi7pjhkBTwg.png" /><figcaption>IP-tables Traffic Routing to Burp Suite</figcaption></figure><p>In this final step, we redirect the device’s network traffic to <strong>Burp Suite</strong> by configuring iptables rules on the Android device. This allows all HTTP and HTTPS requests to be transparently intercepted without modifying proxy settings at the application level.</p><h4>1. Flush Existing NAT Rules</h4><p>Start by clearing up any existing NAT rules to avoid conflicts:</p><pre>adb shell &quot;iptables -t nat -F&quot;</pre><h4>2. Redirect Outbound Traffic to Burp Suite</h4><p>Add DNAT rules to redirect all outbound HTTP and HTTPS traffic to Burp Suite:</p><pre>adb shell &quot;iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 172.16.35.138:8080&quot;</pre><pre>adb shell &quot;iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 172.16.35.138:8080&quot;</pre><blockquote>These rules ensure that any application traffic destined for ports <strong>80</strong> or <strong>443</strong> is transparently forwarded to Burp, regardless of the app’s internal networking logic.</blockquote><h4>3. Enable Masquerading (SNAT)</h4><p>To ensure proper return routing and prevent connection issues, enable masquerading for both HTTP and HTTPS traffic:</p><pre>adb shell &quot;iptables -t nat -A POSTROUTING -p tcp --dport 80 -j MASQUERADE&quot;</pre><pre>adb shell &quot;iptables -t nat -A POSTROUTING -p tcp --dport 443 -j MASQUERADE&quot;</pre><p>Masquerading rewrites the source address, allowing responses from Burp Suite to be correctly routed back to the originating application.</p><p>In conclusion, this research demonstrates that security mechanisms such as root detection and SSL pinning in Xamarin-based applications can be effectively bypassed through static analysis when implemented solely at the managed code level. This highlights the importance of adopting defense-in-depth strategies, including native-level protections and server-side controls, to strengthen mobile application security against reverse engineering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a7da039b39b" width="1" height="1" alt=""><hr><p><a href="https://meetcyber.net/xamarin-root-and-ssl-pinning-bypass-1a7da039b39b">Xamarin Root and SSL Pinning Bypass</a> was originally published in <a href="https://meetcyber.net/">MeetCyber</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>