Search code examples
mysqlsql-injection

What is this SQL injection doing?


Long story short, through an old asp site I run someone found an unfiltered URL parameter and was able to run this query. I'm trying to figure out what it DOES though...

The query should read:

select * from reserve where id = 345

the one that was ran was:

select * from reserve where id = 345 and ascii(substring((select concat(user,0x3a,password,0x3a,host) from mysql.user limit 0,1),17,1))=53

I'm really not sure what this obtains. Any Input?


Solution

  • It might be probing whether or not the web application is accessing the database as root. Removing the ascii(substring()) portions returns the following when run as root:

    mysql> select concat(user,0x3a,password,0x3a,host) from mysql.user limit 0,1;
    +--------------------------------------+
    | concat(user,0x3a,password,0x3a,host) |
    +--------------------------------------+
    | root:<rootpw-hash>:localhost         |
    +--------------------------------------+
    

    Following a successful probe, they may then attempt to retrieve the contents of mysql.user from which they can start cracking passwords against rainbow tables.