docs.rapid7.com

The Metasploitable virtual machine is an intentionally vulnerable version of Ubuntu Linux designed for testing security tools and demonstrating common vulnerabilities. Version 2 of this virtual machine is available for download  and ships with even more vulnerabilities than the original image. This virtual machine is compatible with VMWare, VirtualBox, and other common virtualization platforms. By default, Metasploitable’s network interfaces are bound to the NAT and Host-only network adapters, and the image should never be exposed to a hostile network. (Note: A video tutorial on installing Metasploitable 2 is available here  .)

This document outlines many of the security flaws in the Metasploitable 2 image. Currently missing is documentation on the web server and web application flaws as well as vulnerabilities that allow a local user to escalate to root privileges. This document will continue to expand over time as many of the less obvious flaws with this platform are detailed. Getting Started After the virtual machine boots, login to console with username and password . From the shell, run the command to identify the IP address.

Services From our attack system (Linux, preferably something like Kali Linux), we will identify the open network services on this virtual machine using the Nmap Security Scanner  . The following command line will scan all TCP ports on the Metasploitable 2 instance:

Nearly every one of these listening services provides a remote entry point into the system. In the next section, we will walk through some of these vectors.

TCP ports 512, 513, and 514 are known as “r” services, and have been misconfigured to allow remote access from any host (a standard “.rhosts + +” situation). To take advantage of this, make sure the “rsh-client” client is installed (on Ubuntu), and run the following command as your local root user. If you are prompted for an SSH key, this means the rsh-client tools have not been installed and Ubuntu is defaulting to using SSH.

This is about as easy as it gets. The next service we should look at is the Network File System (NFS). NFS can be identified by probing port 2049 directly or asking the portmapper for a list of services. The example below using to identify NFS and to determine that the ”/” share (the root of the file system) is being exported. You will need the rpcbind and nfs-common Ubuntu packages to follow along.

Getting access to a system with a writeable filesystem like this is trivial. To do so (and because SSH is running), we will generate a new SSH key on our attacking system, mount the NFS export, and add our key to the root user account’s authorized_keys file:

On port 21, Metasploitable2 runs vsftpd, a popular FTP server. This particular version contains a backdoor  that was slipped into the source code by an unknown intruder. The backdoor was quickly identified and removed, but not before quite a few people downloaded it. If a username is sent that ends in the sequence [ a happy face ], the backdoored version will open a listening shell on port 6200. We can demonstrate this with telnet or use the Metasploit Framework module  to automatically exploit it:

On port 6667, Metasploitable2 runs the UnreaIRCD IRC daemon. This version contains a backdoor that went unnoticed for months  - triggered by sending the letters “AB” following by a system command to the server on any listening port. Metasploit has a module  to exploit this in order to gain an interactive shell, as shown below.

Much less subtle is the old standby “ingreslock” backdoor that is listening on port 1524. The ingreslock port was a popular choice a decade ago for adding a backdoor to a compromised server. Accessing it is easy:

In addition to the malicious backdoors in the previous section, some services are almost backdoors by their very nature. The first of which installed on Metasploitable2 is distccd. This program makes it easy to scale large compiler jobs across a farm of like-configured systems. The problem with this service is that an attacker can easily abuse it to run a command of their choice, as demonstrated by the Metasploit module  usage below.

Samba, when configured with a writeable file share and “wide links  ” enabled (default is on), can also be used as a backdoor of sorts to access files that were not meant to be shared. The example below uses a Metasploit module  to provide access to the root filesystem using an anonymous connection and a writeable share.

Weak Passwords In additional to the more blatant backdoors and misconfigurations, Metasploitable 2 has terrible password security for both system and database server accounts. The primary administrative user has a password matching the username. By discovering the list of users on this system, either by using another flaw to capture the passwd file, or by enumerating these user IDs via Samba, a brute force attack can be used to quickly access multiple user accounts. At a minimum, the following weak system accounts are configured on the system.

Account NamePassword
msfadminmsfadmin
useruser
postgrespostgres
sysbatman
klog123456789
serviceservice

In addition to these system-level accounts, the PostgreSQL service can be accessed with username and password , while the MySQL service is open to username with an empty password. The VNC service provides remote desktop access using the password . Vulnerable Web Services Metasploitable 2 has deliberately vulnerable web applications pre-installed. The web server starts automatically when Metasploitable 2 is booted. To access the web applications, open a web browser and enter the URL where is the IP address of Metasploitable 2. One way to accomplish this is to install Metasploitable 2 as a guest operating system in Virtual Box and change the network interface settings from “NAT” to “Host Only”. (Note: A video tutorial on installing Metasploitable 2 is available here  .)

In this example, Metasploitable 2 is running at IP 192.168.56.101. Browsing to http://192.168.56.101/  shows the web application home page.

metasploitable-web-home-page.png

To access a particular web application, click on one of the links provided. Individual web applications may additionally be accessed by appending the application directory name onto to create URL . For example, the Mutillidae application may be accessed (in this example) at address . The applications are installed in Metasploitable 2 in the directory. (Note: See a list with command .) In the current version as of this writing, the applications are

  • mutillidae (NOWASP Mutillidae 2.1.19)
  • dvwa (Damn Vulnerable Web Application)
  • phpMyAdmin
  • tikiwiki (TWiki)
  • tikiwiki-old
  • dav (WebDav)

The Mutillidae web application (NOWASP (Mutillidae)  ) contains all of the vulnerabilities from the OWASP Top Ten plus a number of other vulnerabilities such as HTML-5 web storage, forms caching, and click-jacking. Inspired by DVWA, Mutillidae allows the user to change the “Security Level” from 0 (completely insecure) to 5 (secure). Additionally three levels of hints are provided ranging from “Level 0 - I try harder” (no hints) to “Level 2 - noob” (Maximum hints). If the application is damaged by user injections and hacks, clicking the “Reset DB” button resets the application to its original state.

mutillidae-home-page.png

Enable hints in the application by click the “Toggle Hints” button on the menu bar:

mutillidae-tutorial.png

The Mutillidae application contains at least the following vulnerabilities on these respective pages:

PageVulnerabilities
add-to-your-blog.phpSQL Injection on blog entry
SQL Injection on logged in user name
Cross site scripting on blog entry
Cross site scripting on logged in user name
Log injection on logged in user name
CSRF
JavaScript validation bypass
XSS in the form title via logged in username
The show-hints cookie can be changed by user to enable hints even though they are not supposed to show in secure mode
arbitrary-file-inclusion.phpSystem file compromise
Load any page from any site
browser-info.phpXSS via referer HTTP header
JS Injection via referer HTTP header
XSS via user-agent string HTTP header
capture-data.phpXSS via any GET, POST, or Cookie
captured-data.phpXSS via any GET, POST, or Cookie
config.inc*Contains unencrytped database credentials
credits.phpUnvalidated Redirects and Forwards
dns-lookup.phpCross site scripting on the host/ip field
O/S Command injection on the host/ip field
This page writes to the log. SQLi and XSS on the log are possible
GET for POST is possible because only reading POSTed variables is not enforced.
footer.php*Cross site scripting via the HTTP_USER_AGENT HTTP header.
framing.phpClick-jacking
header.php*XSS via logged in user name and signature
The Setup/reset the DB menu item can be enabled by setting the uid value of the cookie to 1
html5-storage.phpDOM injection on the add-key error message because the key entered is output into the error message without being encoded
index.php*You can XSS the hints-enabled output in the menu because it takes input from the hints-enabled cookie value.
You can SQL injection the UID cookie value because it is used to do a lookup
You can change your rank to admin by altering the UID value
HTTP Response Splitting via the logged in user name because it is used to create an HTTP Header
This page is responsible for cache-control but fails to do so
This page allows the X-Powered-By HTTP header
HTML comments
There are secret pages that if browsed to will redirect user to the phpinfo.php page. This can be done via brute forcing
log-visit.phpSQL injection and XSS via referer HTTP header
SQL injection and XSS via user-agent string
login.phpAuthentication bypass SQL injection via the username field and password field
SQL injection via the username field and password field
XSS via username field
JavaScript validation bypass
password-generator.phpJavaScript injection
pen-test-tool-lookup.phpJSON injection
phpinfo.phpThis page gives away the PHP server configuration
Application path disclosure
Platform path disclosure
process-commands.phpCreates cookies but does not make them HTML only
process-login-attempt.phpSame as login.php. This is the action page.
redirectandlog.phpSame as credits.php. This is the action page
register.phpSQL injection and XSS via the username, signature and password field
rene-magritte.phpClick-jacking
robots.txtContains directories that are supposed to be private
secret-administrative-pages.phpThis page gives hints about how to discover the server configuration
set-background-color.phpCascading style sheet injection and XSS via the color field
show-log.phpDenial of Service if you fill up the log
XSS via the hostname, client IP, browser HTTP header, Referer HTTP header, and date fields
site-footer-xss-discusson.phpXSS via the user agent string HTTP header
source-viewer.phpLoading of any arbitrary file including operating system files.
text-file-viewer.phpLoading of any arbitrary web page on the Interet or locally including the sites password files.
Phishing
user-info.phpSQL injection to dump all usernames and passwords via the username field or the password field
XSS via any of the displayed fields. Inject the XSS on the register.php page.
XSS via the username field
user-poll.phpParameter pollution
GET for POST
XSS via the choice parameter
Cross site request forgery to force user choice
view-someones-blog.phpXSS via any of the displayed fields. They are input on the add to your blog page.

From the DVWA home page: “Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is damn vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, help web developers better understand the processes of securing web applications and aid teachers/students to teach/learn web application security in a class room environment.”.

DVWA contains instructions on the home page and additional information is available at Wiki Pages - Damn Vulnerable Web App  .

  • Default username - admin
  • Default password - password
dvwa.png

Additionally, an ill-advised PHP information disclosure page can be found at . In this example, the URL would be http://192.168.56.101/phpinfo.php  . The PHP info information disclosure vulnerability provides internal system information and service version information that can be used to look up vulnerabilities. For example, noting that the version of PHP disclosed in the screenshot is version 5.2.4, it may be possible that the system is vulnerable to CVE-2012-1823  and CVE-2012-2311  which affected PHP before 5.3.12 and 5.4.x before 5.4.2.

phpinfo.png

You can download Metasploitable 2 here  .

Read the original on docs.rapid7.com ↗