This is part 2 out of a series! The next part will go into some tricks for bypassing basic security measures used against SQL injection. This tutorial is completely about MySQL version 4.
Read my previous tutorial:
|What are Google Dorks?|
Before we get into the injected part I would like to elaborate on how to find vulnerable sites. In the last tutorial I mentioned google dorking and how to check if a site is vulnerable.
FYI I will not go over finding the number of columns or using the UNION function in this tutorial. Please check the last one if you do not know what that is because it is crucial. Now… on to dorking.
Google has many hidden tools and commands within its search engine. We can use those to detect patterns in sites. The sites that come upcan be tested by us to find targets.
Below I have provided a “starter pack” or around 200 dorks:
Most of them provide shopping sites but there is a variety in that list.
|Injecting in MySQL4|
This is assuming you have used the union function and found vulnerable points. You can put in the @@version variable in one of the injection points to see the version. For example:
http://www.site.com/news.php?id=5 union all select 1,@@version,3
If it prints out 5.x.x use the last tutorial for this part. Otherwise use this one! Most websites use MySQL 5 but knowing both versions is useful!
Throughout this section we are assuming that column 2 out of 3 is injection.
In MySQL 4 there is no information_schema. We must guess the table names. This is easier than you probably think but requires more trial and error. Common table names are admin, users, usernames, etc.
http://www.site.com/news.php?id=5 union all select 1,2,3 from admin
The code above checks if the table admin exists. If we see a 2 on the screen (or whatever injectable number) we know that locating table admin was successful. We can try this until we find a successful table.
Checking for what columns exist in a table is similar. If the injectable data shows up we know it is successful. For example:
http://www.site.com/news.php?id=5 union all select 1,password,3 from admin
To retrieve the data is the same as MySQL 5 once we find the columns and tables:
http://www.site.com/news.php?id=5 union all select 1,concat(username,0x3a,password),3 from admin
|That’s all folks!|
There you go! Injecting MySQL 4! Hope this helped and remember to check out the other tutorial!
Disclaimer: The subject matter database system is indeed a much older version than mainstream MySQL. The findings in this article as of 3/6/2020 are no longer supported.