标签:extra trim flag and pass mysql glob rac cal
打开环境,发现依旧是sql注入
GitHub上有源码(https://github.com/team-su/SUCTF-2019/tree/master/Web/easy_sql)
index.php源码
<?php session_start(); include_once "config.php"; $post = array(); $get = array(); global $MysqlLink; //GetPara(); $MysqlLink = mysqli_connect("localhost",$datauser,$datapass); if(!$MysqlLink){ die("Mysql Connect Error!"); } $selectDB = mysqli_select_db($MysqlLink,$dataName); if(!$selectDB){ die("Choose Database Error!"); } foreach ($_POST as $k=>$v){ if(!empty($v)&&is_string($v)){ $post[$k] = trim(addslashes($v)); } } foreach ($_GET as $k=>$v){ if(!empty($v)&&is_string($v)){ $get[$k] = trim(addslashes($v)); } } //die(); ?> <html> <head> </head> <body> <a> Give me your flag, I will tell you if the flag is right. </a> <form action="" method="post"> <input type="text" name="query"> <input type="submit"> </form> </body> </html> <?php if(isset($post[‘query‘])){ $BlackList = "prepare|flag|unhex|xml|drop|create|insert|like|regexp|outfile|readfile|where|from|union|update|delete|if|sleep|extractvalue|updatexml|or|and|&|\""; //var_dump(preg_match("/{$BlackList}/is",$post[‘query‘])); if(preg_match("/{$BlackList}/is",$post[‘query‘])){ //echo $post[‘query‘]; die("Nonono."); } if(strlen($post[‘query‘])>40){ die("Too long."); } $sql = "select ".$post[‘query‘]."||flag from Flag";
//sql执行语句 mysqli_multi_query($MysqlLink,$sql); do{ if($res = mysqli_store_result($MysqlLink)){ while($row = mysqli_fetch_row($res)){ print_r($row); } } }while(@mysqli_next_result($MysqlLink)); } ?>
SQL执行的语句:$sql="select ".$post[‘query‘]."||flag from Flag";
第二种:
根据SQL执行语句:$sql="select ".$post[‘query‘]."||flag from Flag";
构造出:$sql="select *,1 ||flag from Flag";
所以直接输入“*,1”就可直接出flag
标签:extra trim flag and pass mysql glob rac cal
原文地址:https://www.cnblogs.com/anweilx/p/12353294.html