# 爆破

### web21

题目给了压缩包，结合提示应该是爆破题目。

随机输入值，抓包后发现 **Authorization** 参数为**用户名:密码**格式的**base64编码**后的字符串，将 Payload type 设置为 Custom iterator，设置好三个Position，加密方式为 base64，取消掉提交的转义。

### web22

直接盲猜 flag.ctfer.com 就没爆破了

### web23

题目提示了爆破，写个脚本爆破，由于不知道几位数，先从两位数试，运气好就出了：

```
<?php
error_reporting(0);

$string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';


for ($i1 = 0; $i1 < 62; $i1++) {
    for ($i2 = 0; $i2 < 62; $i2++) {
        $exp = $string[$i1] . $string[$i2];
        $token = md5($exp);
        if (substr($token, 1, 1) === substr($token, 14, 1) && substr($token, 14, 1) === substr($token, 17, 1)) {
            if ((intval(substr($token, 1, 1)) + intval(substr($token, 14, 1)) + substr($token, 17, 1)) / substr($token, 1, 1) === intval(substr($token, 31, 1))) {
                echo $exp . "\n";
                echo 'flag';
            }
        }
    }
}
```

直接出了两个，解还是挺多的。

### web24

利用到了伪随机数的特性，在种子确定时，随机数的值是确定的。

```
<?php
mt_srand(372619038);
echo mt_rand();
?>
```

payload：

```
?r=1155388967
```

### web25

上源码：

```
<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-09-03 13:56:57
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-03 15:47:33
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/


error_reporting(0);
include("flag.php");
if(isset($_GET['r'])){
    $r = $_GET['r'];
    mt_srand(hexdec(substr(md5($flag), 0,8)));
    $rand = intval($r)-intval(mt_rand());
    if((!$rand)){
        if($_COOKIE['token']==(mt_rand()+mt_rand())){
            echo $flag;
        }
    }else{
        echo $rand;
    }
}else{
    highlight_file(__FILE__);
    echo system('cat /proc/version');
}
```

逻辑很清晰，首先输入 `r=0`，求出第一次mt\_rand()值（由于flag随机，每次容器启动，答案都是不一样的）

```
-1504369762
```

提交 `r=628900174` ,就可以绕过第一个过滤了。

接下来要求出在这个seed下再算出两次mt\_rand()，种子是flag md5加密后的前八位，写个垃圾脚本爆破：

```
<?php
$string = "0123456789abcdef";
$exp = 0;

for ($i1 = 0; $i1 < 16; $i1++) {
    for ($i2 = 0; $i2 < 16; $i2++) {
        for ($i3 = 0; $i3 < 16; $i3++) {
            for ($i4 = 0; $i4 < 16; $i4++) {
                echo $exp . "\n";
                for ($i5 = 0; $i5 < 16; $i5++) {
                    for ($i6 = 0; $i6 < 16; $i6++) {
                        for ($i7 = 0; $i7 < 16; $i7++) {
                            for ($i8 = 0; $i8 < 16; $i8++) {
                                $exp = $string[$i1] . $string[$i2] . $string[$i3] . $string[$i4] . $string[$i5] . $string[$i6] . $string[$i7] . $string[$i8];
                                mt_srand(hexdec($exp));
                                if (mt_rand() == 1504369762) {
                                    echo 'answer is ' . $exp;
                                    exit();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```

脚本写的很垃圾，跑的也很久，因为不知道PHP多线程怎么写，于是写了四个exp，$i1的初始值分别设成0/4/8/12，算是缩短了四倍的时间，最后出了seed。

然后跑出token值提交就行

### web26

查看源码有个`check()`函数：

```
function check() {
        $.ajax({
            url: 'checkdb.php',
            type: 'POST',
            dataType: 'json',
            data: {
                'a': $('#a').val(),
                'p': $('#p').val(),
                'd': $('#d').val(),
                'u': $('#u').val(),
                'pass': $('#pass').val()
            },
            success: function (data) {
                alert(data['msg']);
            },
            error: function (data) {
                alert(data['msg']);
            }

        });
    }
```

尝试POST后返回json文件，抓包既得。

### web27

进来是ZFsoft正方教务系统，起先想的是这个系统的登录有没有弱密码，后来没有找到后台，发现POST参数提交的时候没有用户的类型，且没有找到root的默认密码，就没有搞这个洞。

然后发现录取名单是可以下载的。下载下来的名单有八位打码：

<figure><img src="/files/KrnvxTrXDEj2yCDWrn6p" alt=""><figcaption></figcaption></figure>

然后有个学员录取查询系统，输入学生的身份证和姓名，结合刚才的表格，推测这里需要爆破。

身份证打码的位置比较微妙，是身份证的年月日，使得爆破难度大幅度下降，本来是十的八次方，现在只要一万多次。爆一下这位高先伊同学的身份证。

由于生日就在1990，所以很快就出了。

提交之后给了初始密码和用户名，直接登录就拿到flag了。

### web28

略


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook-88.gitbook.io/ctf-writeup/ba-chang/ctfshow/bao-po.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
