metasploitable3
Metasploitable3 is a VM that is built from the ground up with a large amount of security vulnerabilities.
Top Related Projects
Metasploit Framework
Pre-Built Vulnerable Environments Based on Docker-Compose
Damn Vulnerable Web Application (DVWA)
WebGoat is a deliberately insecure application
The OWASP NodeGoat project provides an environment to learn how OWASP Top 10 security risks apply to web applications developed using Node.js and how to effectively address them.
Create randomly insecure VMs
Quick Overview
Metasploitable3 is an intentionally vulnerable virtual machine designed for security training, testing, and tool development. It's a more complex and up-to-date version of its predecessor, Metasploitable2, offering a wider range of vulnerabilities and a more realistic environment for practicing penetration testing and vulnerability assessment.
Pros
- Provides a safe, legal environment for practicing ethical hacking and security testing
- Offers a diverse set of vulnerabilities across different operating systems (Windows and Linux)
- Regularly updated to include modern vulnerabilities and security challenges
- Highly customizable, allowing users to add or remove specific vulnerabilities
Cons
- Requires significant system resources to run, especially when using multiple VMs
- Setup process can be complex for beginners
- Some vulnerabilities may not perfectly mimic real-world scenarios
- Limited documentation for some of the more advanced features or custom configurations
Getting Started
To get started with Metasploitable3:
- Install prerequisites: Vagrant, VirtualBox, and Packer
- Clone the repository:
git clone https://github.com/rapid7/metasploitable3.git
- Navigate to the project directory:
cd metasploitable3
- Build the virtual machine(s):
- For Windows:
packer build --only=virtualbox-iso ./packer/templates/windows_2008_r2.json
- For Ubuntu:
packer build --only=virtualbox-iso ./packer/templates/ubuntu_1404.json
- For Windows:
- Once built, start the VM using Vagrant:
vagrant up
Note: The build process can take several hours depending on your system specifications and internet connection speed. Ensure you have adequate disk space and a stable internet connection before starting.
Competitor Comparisons
Metasploit Framework
Pros of Metasploit-Framework
- Comprehensive penetration testing toolkit with a vast array of exploits and modules
- Active development and frequent updates to address new vulnerabilities
- Extensive community support and contributions
Cons of Metasploit-Framework
- Steeper learning curve for beginners compared to Metasploitable3
- Requires more setup and configuration for testing environments
Code Comparison
Metasploit-Framework (Ruby):
def exploit
print_status("Exploiting target #{target.name}...")
connect
send_payload
handler
end
Metasploitable3 (Vagrant configuration):
Vagrant.configure("2") do |config|
config.vm.box = "rapid7/metasploitable3"
config.vm.network "private_network", ip: "172.28.128.3"
end
Metasploit-Framework is a powerful penetration testing tool with a wide range of capabilities, while Metasploitable3 is a purposely vulnerable virtual machine designed for security training and testing. Metasploit-Framework offers more flexibility and control for experienced users, whereas Metasploitable3 provides a pre-configured environment that's easier for beginners to set up and start practicing with.
Pre-Built Vulnerable Environments Based on Docker-Compose
Pros of Vulhub
- Offers a wider variety of vulnerable environments and applications
- Uses Docker containers, making it easier to set up and tear down individual environments
- Regularly updated with new vulnerabilities and scenarios
Cons of Vulhub
- Requires more setup and configuration for each vulnerability scenario
- Less integrated as a complete vulnerable system compared to Metasploitable3
- May require more technical knowledge to use effectively
Code Comparison
Vulhub (Docker-based setup):
version: '2'
services:
web:
image: vulhub/php:5.4.1-cgi
volumes:
- ./www:/var/www/html
ports:
- "8080:80"
Metasploitable3 (Vagrant-based setup):
Vagrant.configure("2") do |config|
config.vm.box = "rapid7/metasploitable3-ub1404"
config.vm.network "private_network", ip: "172.28.128.3"
config.vm.provider "virtualbox" do |v|
v.name = "Metasploitable3-ub1404"
end
end
The code comparison shows the different approaches: Vulhub uses Docker containers for individual vulnerabilities, while Metasploitable3 sets up a complete vulnerable virtual machine using Vagrant.
Damn Vulnerable Web Application (DVWA)
Pros of DVWA
- Lightweight and easy to set up, requiring minimal resources
- Focused specifically on web application vulnerabilities
- Includes a built-in difficulty setting for different skill levels
Cons of DVWA
- Limited scope compared to Metasploitable3's broader range of vulnerabilities
- Less realistic representation of a full production environment
- Fewer integrated tools and services for comprehensive penetration testing
Code Comparison
DVWA (PHP):
<?php
if( isset( $_GET[ 'Submit' ] ) ) {
// Get input
$id = $_GET[ 'id' ];
// Check database
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
// Get results
while( $row = mysqli_fetch_assoc( $result ) ) {
// Get values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
echo "<pre>ID: {$id}<br />First name: {$first}<br />Surname: {$last}</pre>";
}
}
?>
Metasploitable3 (Ruby):
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username
t.string :password_digest
t.timestamps null: false
end
end
end
Note: The code snippets are examples and may not represent the entire codebase or functionality of each project.
WebGoat is a deliberately insecure application
Pros of WebGoat
- Focused specifically on web application security, providing in-depth learning experiences
- More frequently updated and actively maintained
- Includes a wider range of web-specific vulnerabilities and attack scenarios
Cons of WebGoat
- Limited to web application security, lacking coverage of other cybersecurity domains
- Requires more setup and configuration compared to Metasploitable3's VM-based approach
- May be more challenging for beginners due to its specific focus on web security
Code Comparison
WebGoat (Java):
@GetMapping("/login")
public String login(@RequestParam("username") String username,
@RequestParam("password") String password,
Model model) {
// Login logic here
}
Metasploitable3 (Ruby):
post '/login' do
username = params[:username]
password = params[:password]
# Login logic here
end
Both projects use different languages and frameworks, reflecting their distinct purposes. WebGoat focuses on demonstrating web application vulnerabilities, while Metasploitable3 provides a broader range of security issues across various services and applications.
The OWASP NodeGoat project provides an environment to learn how OWASP Top 10 security risks apply to web applications developed using Node.js and how to effectively address them.
Pros of NodeGoat
- Focused on Node.js security, providing a specialized learning environment for this popular technology stack
- Includes detailed tutorials and documentation on how to exploit and fix vulnerabilities
- Regularly updated with new security challenges and best practices
Cons of NodeGoat
- Limited in scope compared to Metasploitable3's broader range of vulnerabilities and technologies
- Less complex infrastructure, potentially offering fewer real-world scenarios
- May require more setup and configuration for beginners
Code Comparison
NodeGoat (vulnerable code example):
app.get('/benefits', function (req, res) {
var userId = req.session.userId;
Benefits.findById(userId, function (err, benefits) {
if (err) return next(err);
res.render('benefits', {
benefits: benefits
});
});
});
Metasploitable3 doesn't have direct code examples, as it's a vulnerable VM rather than a specific application. However, it includes various vulnerable services and applications that can be exploited.
Both projects serve as valuable resources for security professionals and developers to practice identifying and mitigating vulnerabilities. NodeGoat offers a more focused approach to Node.js security, while Metasploitable3 provides a broader range of vulnerabilities across different technologies and services.
Create randomly insecure VMs
Pros of SecGen
- Highly customizable and flexible VM generation
- Supports creating multiple VMs with different configurations
- Includes a wide range of vulnerabilities and security scenarios
Cons of SecGen
- Steeper learning curve due to its complexity
- Requires more setup time compared to Metasploitable3
- May have higher resource requirements for generating multiple VMs
Code Comparison
SecGen (Ruby):
require 'erb'
require_relative '../helpers/constants'
require_relative '../helpers/print.rb'
require_relative 'system_updater'
Metasploitable3 (PowerShell):
$ErrorActionPreference = "Stop"
. $PSScriptRoot\..\scripts\installs\windows\chocolatey_installs\common.ps1
Both projects use scripting languages for automation, but SecGen relies on Ruby while Metasploitable3 uses PowerShell for Windows-specific tasks. SecGen's code suggests a more modular approach with helper functions and constants, while Metasploitable3's code focuses on Windows-specific installations and configurations.
SecGen offers greater flexibility and customization options, making it suitable for advanced users and complex scenarios. Metasploitable3, on the other hand, provides a more straightforward and quicker setup process, making it ideal for beginners or those seeking a pre-configured vulnerable environment.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Metasploitable3
Metasploitable3 is a VM that is built from the ground up with a large amount of security vulnerabilities. It is intended to be used as a target for testing exploits with metasploit.
Metasploitable3 is released under a BSD-style license. See COPYING for more details.
Quick-start
To use the prebuilt images provided at https://app.vagrantup.com/rapid7/ create a new local metasploitable workspace:
Linux users:
mkdir metasploitable3-workspace
cd metasploitable3-workspace
curl -O https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile && vagrant up
Windows users:
mkdir metasploitable3-workspace
cd metasploitable3-workspace
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile" -OutFile "Vagrantfile"
vagrant up
Or clone this repository and build your own box.
Building Metasploitable 3
System Requirements:
- OS capable of running all of the required applications listed below
- VT-x/AMD-V Supported Processor recommended
- 65 GB Available space on drive
- 4.5 GB RAM
Requirements:
- Packer
- Vagrant
- Vagrant Reload Plugin
- VirtualBox, libvirt/qemu-kvm, or vmware (paid license required), or parallels (paid license required)
- Internet connection
To build automatically:
-
- On Linux/OSX run
./build.sh windows2008
to build the Windows box or./build.sh ubuntu1404
to build the Linux box. If /tmp is small, useTMPDIR=/var/tmp ./build.sh ...
to store temporary packer disk images under /var/tmp. - On Windows, open powershell terminal and run
.\build.ps1 windows2008
to build the Windows box or.\build.ps1 ubuntu1404
to build the Linux box. If no option is passed to the script i.e..\build.ps1
, then both the boxes are built.
- On Linux/OSX run
- If both the boxes were successfully built, run
vagrant up
to start both. To start any one VM, you can use:vagrant up ub1404
: to start the Linux boxvagrant up win2k8
: to start the Windows box
- When this process completes, you should be able to open the VM within VirtualBox and login. The default credentials are U:
vagrant
and P:vagrant
.
To build manually:
- Clone this repo and navigate to the main directory.
- Build the base VM image by running
packer build --only=<provider> ./packer/templates/windows_2008_r2.json
where<provider>
is your preferred virtualization platform. Currentlyvirtualbox-iso
,qemu
, andvmware-iso
providers are supported. This will take a while the first time you run it since it has to download the OS installation ISO. - After the base Vagrant box is created you need to add it to your Vagrant environment. This can be done with the command
vagrant box add packer/builds/windows_2008_r2_*_0.1.0.box --name=rapid7/metasploitable3-win2k8
. - Use
vagrant plugin install vagrant-reload
to install the reload vagrant provisioner if you haven't already. - To start the VM, run the command
vagrant up win2k8
. This will start up the VM and run all of the installation and configuration scripts necessary to set everything up. This takes about 10 minutes. - Once this process completes, you can open up the VM within VirtualBox and login. The default credentials are:
- Username:
vagrant
- Password:
vagrant
- Username:
ub1404 Development and Modification
Using Vagrant and a lightweight Ubuntu 14.04 vagrant cloud box image, you can quickly set up and customize ub1404 Metasploitable3 for development or customization. To do so, install Vagrant and a hypervisor such as VirtualBox, VMWare, or libvirt.
Install the relevant provider plugin:
# virtualbox
vagrant plugin install vagrant-vbguest
# libvirt
vagrant plugin install vagrant-libvirt
Then, navigate to the chef/dev/ub1404 directory in this repository. Examine the Vagrantfile there. Select a base box that supports your provider.
Metasploitable ub1404 uses the vagrant chef-solo
provisioner. Configure the
chef_solo block in the Vagrantfile with the metasploitable chef recipes that you
desire -- you can browse them in the chef/cookbooks/metasploitable
folder. Or, add or edit your own cookbook and/or recipes there.
From the chef/dev/ub1404 directory, you can run vagrant up
to get a development virtual ub1404 instance. After the initial up
build and provision,
when you edit the chef runlist or when you edit a chef recipe, run
vagrant rsync && vagrant provision
from the same directory. For faster
development, you can comment-out recipes that you do not need to rerun -- but
even if they are all enabled, vagrant re-provisioning should not take longer than
one or two minutes. Chef aims to be idempotent, so you can rerun this command often.
Consider taking a snapshot (e.g., vagrant snapshot save fresh
) before modifying
recipes, so that you can always return to an initial state (vagrant restore fresh
).
If you want a totally fresh snapshot, you can do the initialization with
vagrant up --no-provision
, then take a snapshot, followed by vagrant provision
.
Vulnerabilities
More Information
The wiki has a lot more detail and serves as the main source of documentation. Please check it out.
Acknowledgements
The Windows portion of this project was based off of GitHub user joefitzgerald's packer-windows project. The Packer templates, original Vagrantfile, and installation answer files were used as the base template and built upon for the needs of this project.
Top Related Projects
Metasploit Framework
Pre-Built Vulnerable Environments Based on Docker-Compose
Damn Vulnerable Web Application (DVWA)
WebGoat is a deliberately insecure application
The OWASP NodeGoat project provides an environment to learn how OWASP Top 10 security risks apply to web applications developed using Node.js and how to effectively address them.
Create randomly insecure VMs
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot