fromjpeg')) { copy($sourcefile, $destfile); $return = array('filesize' => filesize($destfile), 'width' => $src_width, 'height' => $src_height); return $return; } $src_scale = $src_width / $src_height; $des_scale = $forcedwidth / $forcedheight; if ($src_width <= $forcedwidth && $src_height <= $forcedheight) { $des_width = $src_width; $des_height = $src_height; } elseif ($src_scale >= $des_scale) { $des_width = ($src_width >= $forcedwidth) ? $forcedwidth : $src_width; $des_height = $des_width / $src_scale; $des_height = ($des_height >= $forcedheight) ? $forcedheight : $des_height; } else { $des_height = ($src_height >= $forcedheight) ? $forcedheight : $src_height; $des_width = $des_height * $src_scale; $des_width = ($des_width >= $forcedwidth) ? $forcedwidth : $des_width; } $des_width = ceil($des_width); $des_height = ceil($des_height); switch ($getimgsize['mime']) { case 'image/jpeg': $img_src = imagecreatefromjpeg($sourcefile); !$img_src && $img_src = imagecreatefromgif($sourcefile); break; case 'image/gif': $img_src = imagecreatefromgif($sourcefile); !$img_src && $img_src = imagecreatefromjpeg($sourcefile); break; case 'image/png': $img_src = imagecreatefrompng($sourcefile); break; case 'image/wbmp': $img_src = imagecreatefromwbmp($sourcefile); break; default : return $return; } if (!$img_src) return $return; $img_dst = imagecreatetruecolor($des_width, $des_height); imagefill($img_dst, 0, 0, 0xFFFFFF); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $des_width, $des_height, $src_width, $src_height); $tmppath = isset($conf['tmp_path']) ? $conf['tmp_path'] : ini_get('upload_tmp_dir') . '/'; '/' == $tmppath AND $tmppath = './tmp/'; $tmpfile = $tmppath . md5($destfile) . '.tmp'; switch ($destext) { case 'jpg': imagejpeg($img_dst, $tmpfile, 75); break; case 'jpeg': imagejpeg($img_dst, $tmpfile, 75); break; case 'gif': imagegif($img_dst, $tmpfile); break; case 'png': imagepng($img_dst, $tmpfile); break; } $r = array('filesize' => filesize($tmpfile), 'width' => $des_width, 'height' => $des_height);; copy($tmpfile, $destfile); is_file($tmpfile) && unlink($tmpfile); imagedestroy($img_dst); return $r; } function well_image_clip($sourcefile, $destfile, $clipx, $clipy, $clipwidth, $clipheight, $getimgsize = '') { global $conf; empty($getimgsize) AND $getimgsize = getimagesize($sourcefile); if (empty($getimgsize)) { return 0; } else { $imgwidth = $getimgsize[0]; $imgheight = $getimgsize[1]; if (0 == $imgwidth || 0 == $imgheight) { return 0; } } if (!function_exists('imagecreatefromjpeg')) { copy($sourcefile, $destfile); return filesize($destfile); } switch ($getimgsize[2]) { case 1 : $imgcolor = imagecreatefromgif($sourcefile); break; case 2 : $imgcolor = imagecreatefromjpeg($sourcefile); break; case 3 : $imgcolor = imagecreatefrompng($sourcefile); break; case 15: $imgcolor = imagecreatefromwbmp($sourcefile); break; case 18: $imgcolor = imagecreatefromwebp($sourcefile); break; } if (!$imgcolor) return 0; $img_dst = imagecreatetruecolor($clipwidth, $clipheight); imagefill($img_dst, 0, 0, 0xFFFFFF); imagecopyresampled($img_dst, $imgcolor, 0, 0, $clipx, $clipy, $imgwidth, $imgheight, $imgwidth, $imgheight); $tmppath = isset($conf['tmp_path']) ? $conf['tmp_path'] : ini_get('upload_tmp_dir') . '/'; '/' == $tmppath AND $tmppath = './tmp/'; $tmpfile = $tmppath . md5($destfile) . '.tmp'; imagejpeg($img_dst, $tmpfile, 75); $n = filesize($tmpfile); copy($tmpfile, $destfile); is_file($tmpfile) && unlink($tmpfile); return $n; } function well_image_ext($filename) { return strtolower(substr(strrchr($filename, '.'), 1)); } ?>注意!PostgreSQL 存在安全漏洞,请及时更新版本或者停用删除相关服务,防止中招!
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

注意!PostgreSQL 存在安全漏洞,请及时更新版本或者停用删除相关服务,防止中招!

网站源码admin0浏览0评论

注意!PostgreSQL 存在安全漏洞,请及时更新版本或者停用删除相关服务,防止中招!

前言

昨天半夜收到短信提醒,说我的服务器遭受了恶意挖矿程序攻击:

短息提醒

短信提醒

APP提醒

APP提醒

中午有空打开后台,一看 CPU 占用率居然怎么高了!

CPU 使用率

CPU 使用率

赶紧登录看看情况,

卡住了进不去

卡住了进不去

正文

追因溯源

先确认是否有异常 CPU 或内存使用情况:

代码语言:javascript代码运行次数:0运行复制
top -c
polkitd

polkitd

COMMAND 是 perfctl:这个名字看起来像是在伪装系统性能控制命令,但实际上 CentOS 或其他主流 Linux 发行版并没有叫 perfctl 的标准程序。

占用 CPU 高达 99%:明显异常,这基本可以确认是挖矿程序伪装的。

代码语言:javascript代码运行次数:0运行复制
ps -o pid,ppid,cmd -p 27519
代码语言:javascript代码运行次数:0运行复制
ps -fp 19226
查找父进程

查找父进程

握草,居然是熟悉的 PostgreSQL,之前的文章里介绍过它,因为安装了Konga部署过网关!

Docker 部署过 PostgreSQL

Docker 部署过 PostgreSQL

文件藏在 /tmp/.perf.c/ 并带有 隐藏目录名(点号开头),是典型的恶意行为

代码语言:javascript代码运行次数:0运行复制
ls -l /proc/27519/exe
lrwxrwxrwx 1 polkitd input 0 Apr 21 13:25 /proc/27519/exe -> /tmp/.perf.c/perfctl (deleted)

它的父进程是 postgres(PID 19226),但运行用户是 polkitd,极不寻常;

代码语言:javascript代码运行次数:0运行复制
Docker shim (容器进程)
   └── postgres (polkitd 身份运行)
         └── perfctl (后门)
处理

杀掉恶意进程:

代码语言:javascript代码运行次数:0运行复制
kill -9 27519

检查可疑文件

代码语言:javascript代码运行次数:0运行复制
ls -alh /tmp
ls -alh /dev/shm
ls -alh /var/tmp
排查可疑文件

排查可疑文件

没发现可疑文件,已经运行之后就删除了文件,

停止进程:

代码语言:javascript代码运行次数:0运行复制
docker stop c70e5c3e6045

删除容器:

代码语言:javascript代码运行次数:0运行复制
docker rm 027ccf656dc1

删除镜像:

代码语言:javascript代码运行次数:0运行复制
docker rmi 027ccf656dc1

总结

攻击提醒

攻击提醒

回头看,攻击提醒里居然已经定位到了问题在哪了!真的太厉害了,呼吁各位不要像我一样,折腾这么多新玩意,太容易中招了!

最后发现这个漏洞一直存在

江南大学的预警提示

江南大学的预警提示

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。原始发表:2025-04-21,如有侵权请联系 cloudcommunity@tencent 删除postgresql安全漏洞程序服务进程
发布评论

评论列表(0)

  1. 暂无评论