exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

MySQL.fingerprint.txt

MySQL.fingerprint.txt
Posted Feb 23, 2004
Authored by Tonu Samuel

Small write-up discussing methodology for fingerprint the type of MySQL database being used when exploiting SQL injection vulnerabilities.

tags | paper, vulnerability, sql injection
SHA-256 | 7b6c08f5a021bb61015822055f311d65f7fed8629c8880058789c73e4bb31bb8

MySQL.fingerprint.txt

Change Mirror Download
Hi!

While I believe I know something about SQL Injection I have not found any
publications related to way of abuse I am going to describe here. Somewhat it
is not new at all but it seems to work in many weird situations.

Currently all penetration testers efforts seem to be focused on "blind
hacking". Penetration tester can get free access to SQL subsystem and execute
any commands but not able to get any other result back than error messages
(or even not them). There are many publications describing how to fingerprint
databases in blind. This posting just adds one more way.

Often I have found web sites, which also include banks and other usually
not-so-bad-security sites which are vulnerable to blind SQL Injection.

My example uses MySQL because this seems to be most used database on the web
and also I know it best. Meanwhile similar techniques can apply to others. In
every SQL there is a one "feature" which is actually very nice. It allows to
use comments in SQL clauses like this:

SELECT * FROM table /* foo */
In MySQL, there is a extension to it which allows insert MySQL specific code
in way:

SELECT /*! SQL_NO_CACHE */ FROM table

Comments shown above treated as comments in every database except MySQL. MySQL
takes a look inside of comments and may change his behaviour. For example,
this gets executed only, if MySQL is version 4.0.0 or higher:

SELECT /*!40000 SQL_NO_CACHE */ FROM table

It seems bit unusable but in many situations I have found it working through
SQL injection holes when other techiques are not very useful. And this can be
extremely useful for penetration tester to find out database in use and his
version in blind:
Just trying
http://foo/web.php?table=38 I get normal screen
http://foo/web.php?table=38/*%20s*/ I get normal screen
http://foo/web.php?table=38/*!%20s*/ I get different screen because syntax
error in comments - WOW MySQL is in use!
http://foo/web.php?table=38/*!30000%20s*/ same. MySQL is at least 3.x.x
http://foo/web.php?table=38/*!40000%20s*/ same. MySQL is at least 4.x.x
http://foo/web.php?table=38/*!50000%20s*/ Normal screen. MySQL is below 5.x.x
http://foo/web.php?table=38/*!40020%20s*/ Normal screen. MySQL is below 4.0.20
http://foo/web.php?table=38/*!40017%20s*/ broken screen. at least 4.0.17
http://foo/web.php?table=38/*!40018%20s*/ Normal screen. MySQL is below 4.0.18

We can conclude that MySQL running on site is 4.0.17.

Stupid? Yes. But it works really often. This is useful information because
then we may know if we have interest to database or not. In MySQL for example
all series (3.x.x,4.x.x and 5.x.x) have VERY different functionality. It is
good to get information about it so easily.

Another, independent idea. This works on most systems without change. Look at
default behaviour of MySQL database engine:

mysql> select 9e0;
+-----+
| 9e0 |
+-----+
| 9 |
+-----+
1 row in set (0.02 sec)

mysql> select 9e2;
+-----+
| 9e2 |
+-----+
| 900 |
+-----+
1 row in set (0.00 sec)

Most language interpreters are trying to guess something about their input. I
have seen cases when input gets validated against length and passed. So I can
freely pass 9e9 to some database query in backend. PHP guys often suggest
using functions like is_int($_GET['foo']). Yes, it is int! and it is 3 chars
long. But it may take your database server down. I had nice penetration
testing case when there was nearly impossible to get anny error message from
the system. Finally I managed to send some 9e999 somewhere as input which
leaded message similar "PHP timeout of 30 seconds in somehing.inc". Who works
for penetration testing knows how important is any information about system
internals. I was able to download this INC file which leaded to data leak.

About me:

Running company which does some specialized software for secure web
applications. We also sometime do penetration testing and security
consulting. In past I have developed e-banking solutions to different big
banks, worked for MySQL AB as security man and have consulted Fortune 500
companies.


Disclaimer: This is not related to MySQL in any way. Bug is in programmers who
still haven't learned how to treat user input. magic_quotes in PHP just do
mess giving false sense of security. Don't blame me on that. I am just a
messenger.

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close