1

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?

3
  • can you increase the 15 char limit? Commented Aug 31, 2017 at 18:13
  • How would I do that? Isn't the character limit evaluated server side? Commented Aug 31, 2017 at 18:15
  • you could try to send an input longer then 15 chars and test if it works. for more help i would need more information Commented Aug 31, 2017 at 18:26

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

That's still above the character limit
1

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

2 Comments

SHOW STATUS does not include that information. You might be thinking of the mysql client builtin command status which includes the current database. But client builtin commands are not executed by the server, so they're not vulnerable to SQL injection.
No... the OP will not be able to run status using SQL injection. It's a client builtin command. One cannot execute client commands using SQL.
1

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 |
+----------------+
| ...            |
+----------------+

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.