Reputation: 113
I'm trying to do an SQL Injection attack, (This is for an assignment, so I'm not doing anything illegal) and I need to see what the current database name is. However, I'm limited to 15 characters for the input, which is 13 when you factor in escaping the string and commenting out the remainder. SELECT DATABASE() is too long because of this, so is there a way to return the database name in 13 characters or less?
Upvotes: 1
Views: 279
Reputation: 562348
The command SHOW TABLES
is only 11 characters, and the heading of the result set reveals the current database.
Here's an example:
mysql> use test;
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| ... |
+----------------+
Upvotes: 1
Reputation: 853
Use STATUS
. It gives you several status variables including the name of the database you are connected to.
https://dev.mysql.com/doc/refman/5.7/en/show-status.html
Upvotes: 1
Reputation: 18524
You can use SCHEMA() as it's a synonym for DATABASE(). See https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_schema
Upvotes: 2