BUUOJ [CISCN2019 华北赛区 Day2 Web1]Hack World
???黑人问号
https://www.cnblogs.com/20175211lyz/p/11435298.html
https://www.cnblogs.com/kevinbruce656/p/11342580.html
本题源码,希望对各位大佬有帮助
<?php $dbuser='root'; $dbpass='root'; function safe($sql){ #被过滤的内容 函数基本没过滤 $blackList = array(' ','||','#','-',';','&','+','or','and','`','"','insert','group','limit','update','delete','*','into','union','load_file','outfile','./'); foreach($blackList as $blackitem){ if(stripos($sql,$blackitem)){ return False; } } return True; } if(isset($_POST['id'])){ $id = $_POST['id']; }else{ die(); } $db = mysql_connect("localhost",$dbuser,$dbpass); if(!$db){ die(mysql_error()); } mysql_select_db("ctf",$db); if(safe($id)){ $query = mysql_query("SELECT content from passage WHERE id = ${id} limit 0,1"); if($query){ $result = mysql_fetch_array($query); if($result){ echo $result['content']; }else{ echo "Error Occured When Fetch Result."; } }else{ var_dump($query); } }else{ die("SQL Injection Checked."); }