Page cover

MySQL Pentesting

It is a relational database management system. A default port is 3306.

nmap --script mysql-info -p 3306 <target-ip>
nmap --script mysql-enum -p 3306 <target-ip>
nmap --script mysql-brute -p 3306 <target-ip>
nmap --script mysql-databases -p 3306 <target-ip>
nmap --script mysql-users -p 3306 <target-ip>
nmap --script mysql-* -p 3306 <target-ip>
Copied!

hydra -l username -P passwords.txt <target-ip> mysql
hydra -L usernames.txt -p password <target-ip> mysql
Copied!

cat /etc/mysql/my.cnf
cat /etc/mysql/mysql.conf.d/mysqld.cnf
Copied!

mysql command can be replaced with mariadb .

After connecting MySQL, you can load a local .sql file. Note that you need to change the current directory to the directory in which the .sql file is located.

Belows are basic commands.

We can inject the OS command to column values e.g. email address. Depending on the situation, we may be able to execute arbitrary command.

We can run the system command in MySQL shell as below. Depending on the situation, we may be able to escalate privileges.

Last updated