Listing MySQL databases

MySQL servers may contain several databases. As system administrators with legitimate access or penetration testers who just compromised the server, we can list the available databases using Nmap.

This recipe teaches how to use Nmap NSE to list databases in a MySQL server.

How to do it...

Open a terminal and enter the following command:

$ nmap -p3306 --script mysql-databases --script-args mysqluser=<user>,mysqlpass=<password> <target>

The databases should be listed under the script results.

3306/tcp open  mysql
| mysql-databases:  
|   information_schema
|   temp
|   websec
|   ids
|_  crm

How it works...

The argument -p3306 --script mysql-databases --script-args mysqluser=<user>,mysqlpass=<password> tells Nmap to attempt a connection ...

Get Nmap 6: Network Exploration and Security Auditing Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.