ctfshow web10-12

web10

 由于9的经验使用index.phps下载源码




<?php
		$flag="";
        function replaceSpecialChar($strParam){
         $regex = "/(select|from|where|join|sleep|and|\s|union|,)/i"; //过滤了select|from|where|join|sleep|and|\s|union|
             return preg_replace($regex,"",$strParam);
        }
        if (!$con)
        {
            die('Could not connect: ' . mysqli_error());
        }
		 if(strlen($username)!=strlen(replaceSpecialChar($username))){    //避免了双写绕过下同
			die("sql inject error");
		}
		if(strlen($password)!=strlen(replaceSpecialChar($password))){
			die("sql inject error");
	
		}
		$sql="select * from user where username = '$username'";
		$result=mysqli_query($con,$sql);
			if(mysqli_num_rows($result)>0){
					while($row=mysqli_fetch_assoc($result)){
						if($password==$row['password']){
							echo "登陆成功<br>";
							echo $flag;
						}

					 }
			}
    ?>

代码表示写在了里面

这里介绍一下group by 和 with rollup 两个分组函数

 

 第一张是正常查询使用是通过id来排列的

而加上group by 之后指定name 使表按name来排列

 with rollup 会生成一条新的记录 值为总和

于是构建'or/**/1=1/**/group/**/by/**/password/**/with/**/rollup;#

 成功登录得到flag值

web11

注意这句 if($password==$_SESSION['password']){

password 要和session 

果断f12

 删除session 右键鼠标点delete

 然后因为密码等于session所以空密码登录

web12

 

 f12查看发现提示?cmd

这里介绍两个函数highlight_file 表示高亮显示文本显示包括隐藏内容

glob查询函数可以查文件

构建?cmd=highlight_file("index.php");

 显示了网页源码但没有有用信息构建?cmd=print_r(glob("*"));

print_r用于打印变量  glob(“*” )表示显所有文件*代表所以文件

 这里表示文件包含903c00105c0141fd37ff47697e916e53616e33a72fb3774ab213b3e2a732f56f.php在index.php下

构建?cmd=highlight_file("903c00105c0141fd37ff47697e916e53616e33a72fb3774ab213b3e2a732f56f.php");

 得到flag值

猜你喜欢

转载自blog.csdn.net/qq_61988806/article/details/121808068