MySQL Post-Exploitation Enumeration
After gaining authenticated access to MySQL, post-exploitation enumeration maps the full attack surface beyond the immediately visible databases and tables. Stored procedures and functions may contain credentials or business logic worth reviewing. Scheduled events run commands on a timer and can be abused for persistence. Triggers fire on data changes and are worth checking for data interception opportunities. Replication configuration reveals other database servers in the environment. Each of these surfaces provides either additional credential material or lateral movement paths.
Enumerate Stored Procedures and Functions
Stored procedures frequently contain hardcoded credentials, internal service addresses, and sensitive business logic:
Read the full definition of any interesting procedure:
Enumerate Scheduled Events
MySQL events are SQL statements that execute on a schedule. They can be abused for persistence and may contain credentials or reveal automated maintenance operations:
Enumerate Triggers
Triggers fire automatically on INSERT, UPDATE, or DELETE operations. A trigger on a users table could be logging credential changes to a separate table:
Enumerate Replication Configuration
Replication configuration reveals other MySQL servers in the environment and the replication user credentials:
The replica status output includes the source host, replication user, and port. This reveals additional database servers in the environment. The replication user account is a valid MySQL credential on the source server and worth testing against both MySQL and other services on the source host.
Enumerate Active Connections and Running Queries
The process list shows all currently connected clients, their source hosts, and what queries they are running:
Application servers connecting to the database are visible in the process list with their source IP addresses. These are internal hosts in the environment worth enumerating for lateral movement.
Check General and Binary Logs
If query logging is enabled, the general log contains a record of every query executed including those with embedded credentials:
References
-
MySQL — information_schema.ROUTINES tabledev.mysql.com/doc/refman/8.0/en/information-schema-routines-table.html (opens in new tab)
Stored procedure and function enumeration field reference
-
MySQL — SHOW REPLICA STATUSdev.mysql.com/doc/refman/8.0/en/show-replica-status.html (opens in new tab)
Replication configuration output fields and source host reference
Was this helpful?
Your feedback helps improve this page.