攻防世界32-easyphp-CTFWeb

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
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
highlight_file(__FILE__);
$key1 = 0;
$key2 = 0;

$a = $_GET['a'];
$b = $_GET['b'];

if(isset($a) && intval($a) > 6000000 && strlen($a) <= 3){
if(isset($b) && '8b184b' === substr(md5($b),-6,6)){
$key1 = 1;
}else{
die("Emmm...再想想");
}
}else{
die("Emmm...");
}

$c=(array)json_decode(@$_GET['c']);
if(is_array($c) && !is_numeric(@$c["m"]) && $c["m"] > 2022){
if(is_array(@$c["n"]) && count($c["n"]) == 2 && is_array($c["n"][0])){
$d = array_search("DGGJ", $c["n"]);
$d === false?die("no..."):NULL;
foreach($c["n"] as $key=>$val){
$val==="DGGJ"?die("no......"):NULL;
}
$key2 = 1;
}else{
die("no hack");
}
}else{
die("no");
}

if($key1 && $key2){
include "Hgfks.php";
echo "You're right"."\n";
echo $flag;
}

?> Emmm...

代码审计

get 得到a,b,a要>6000000,len又要小于3,考虑科学计数法1e9

‘8b184b’ === substr(md5($b),-6,6) b的mdt最后6个要强等于8b184b,暂时想到爆破(如果b不是数字的话就寄了)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import hashlib

string = '8b184b'

for i in range(0,1000000):

# 创建MD5加密对象
md5_obj = hashlib.md5()

# 添加要加密的文本
md5_obj.update(str(i).encode())

# 获取加密后的字符串
md5_result = md5_obj.hexdigest()

if md5_result[-6:] == string:
print(i)
break

53724

c是个数组里面的m要大于2022,又不能是数字,那就m=2023a可以绕过,c[n]也要是个数组,长度为2,第0位也是队列,第二就是在c[n]中search,也就是比较,DGGJ==0弱比较可以绕过

c={“m”:”12345a”,”n”:[[0,1,2],0]}

payload:?a=1e9&b=53724&c={“m”:”12345a”,”n”:[[0,1,2],0]}

得Flag