阿里云被植入了挖矿程序, 请大佬帮个忙啊

2019-12-23 12:50:54 +08:00
 CoderLife

目前还不知道怎么引入的.

请各位大神帮忙解一下.

ps aux

postgres  9961  0.0  0.0   2236    72 ?        Ss   11:56   0:00 fE8fEp
postgres 11962  102 61.7 2432548 2396640 ?     Ssl  12:18  14:57 IS47Dj

阿里云报告

恶意进程(云查杀)-挖矿程序

该告警由如下引擎检测发现:
中控 IP:101.64.182.145
中控端口:443
进程路径:/tmp/363188e0133843515b9d6f1c487f017c (deleted)
命令行参数:IS47Dj

杀了还是会自启动

我的 ps aux

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  51724  2596 ?        Ss   Oct29  10:18 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root         2  0.0  0.0      0     0 ?        S    Oct29   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Oct29   0:10 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kworker/0:0H]
root         7  0.0  0.0      0     0 ?        S    Oct29   0:02 [migration/0]
root         8  0.0  0.0      0     0 ?        S    Oct29   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        R    Oct29  44:01 [rcu_sched]
root        10  0.0  0.0      0     0 ?        S<   Oct29   0:00 [lru-add-drain]
root        11  0.0  0.0      0     0 ?        S    Oct29   0:25 [watchdog/0]
root        12  0.0  0.0      0     0 ?        S    Oct29   3:51 [watchdog/1]
root        13  0.0  0.0      0     0 ?        S    Oct29   0:02 [migration/1]
root        14  0.0  0.0      0     0 ?        S    Oct29   0:11 [ksoftirqd/1]
root        16  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kworker/1:0H]
root        18  0.0  0.0      0     0 ?        S    Oct29   0:00 [kdevtmpfs]
root        19  0.0  0.0      0     0 ?        S<   Oct29   0:00 [netns]
root        20  0.0  0.0      0     0 ?        S    Oct29   0:01 [khungtaskd]
root        21  0.0  0.0      0     0 ?        S<   Oct29   0:00 [writeback]
root        22  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kintegrityd]
root        23  0.0  0.0      0     0 ?        S<   Oct29   0:00 [bioset]
root        24  0.0  0.0      0     0 ?        S<   Oct29   0:00 [bioset]
root        25  0.0  0.0      0     0 ?        S<   Oct29   0:00 [bioset]
root        26  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kblockd]
root        27  0.0  0.0      0     0 ?        S<   Oct29   0:00 [md]
root        28  0.0  0.0      0     0 ?        S<   Oct29   0:00 [edac-poller]
root        29  0.0  0.0      0     0 ?        S<   Oct29   0:00 [watchdogd]
root        36  0.0  0.0      0     0 ?        S    Oct29   2:57 [kswapd0]
root        37  0.0  0.0      0     0 ?        SN   Oct29   0:00 [ksmd]
root        38  0.0  0.0      0     0 ?        SN   Oct29   0:13 [khugepaged]
root        39  0.0  0.0      0     0 ?        S<   Oct29   0:00 [crypto]
root        47  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kthrotld]
root        49  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kmpath_rdacd]
root        50  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kaluad]
root        51  0.0  0.0      0     0 ?        S<   Oct29   0:00 [kpsmoused]
root        52  0.0  0.0      0     0 ?        S<   Oct29   0:00 [ipv6_addrconf]
root        65  0.0  0.0      0     0 ?        S<   Oct29   0:00 [deferwq]
root        97  0.0  0.0      0     0 ?        S    Oct29   0:05 [kauditd]
root       232  0.0  0.0      0     0 ?        S<   Oct29   0:00 [ata_sff]
root       254  0.0  0.0      0     0 ?        S    Oct29   0:00 [scsi_eh_0]
root       260  0.0  0.0      0     0 ?        S<   Oct29   0:00 [scsi_tmf_0]
root       263  0.0  0.0      0     0 ?        S    Oct29   0:00 [scsi_eh_1]
root       264  0.0  0.0      0     0 ?        S<   Oct29   0:00 [scsi_tmf_1]
root       305  0.0  0.0      0     0 ?        S<   Oct29   0:00 [ttm_swap]
root       317  0.0  0.0      0     0 ?        S<   Oct29   0:42 [kworker/0:1H]
root       323  0.0  0.0      0     0 ?        S<   Oct29   0:13 [kworker/1:1H]
root       328  0.0  0.0      0     0 ?        S    Oct29   1:45 [jbd2/vda1-8]
root       329  0.0  0.0      0     0 ?        S<   Oct29   0:00 [ext4-rsv-conver]
redis      375  0.1  0.1 310892  6812 ?        Ssl  Nov08  65:03 /usr/bin/redis-server 127.0.0.1:6379
root       397  0.0  0.8 149876 32136 ?        Ss   Oct29   1:38 /usr/lib/systemd/systemd-journald
root       421  0.0  0.0  44460   956 ?        Ss   Oct29   0:00 /usr/lib/systemd/systemd-udevd
root       474  0.0  0.0  55520   692 ?        S<sl Oct29   0:24 /sbin/auditd
root       577  0.0  0.0      0     0 ?        S<   Oct29   0:00 [nfit]
root       600  0.0  0.0  26612  1340 ?        Ss   Oct29   1:29 /usr/lib/systemd/systemd-logind
polkitd    606  0.0  0.2 612328  9220 ?        Ssl  Oct29   1:11 /usr/lib/polkit-1/polkitd --no-debug
dbus       607  0.0  0.0  58228  1260 ?        Ss   Oct29   3:11 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
chrony     619  0.0  0.0 117908  1160 ?        S    Oct29   0:18 /usr/sbin/chronyd
root       661  0.0  0.0  25904   204 ?        Ss   Oct29   0:00 /usr/sbin/atd -f
root       663  0.0  0.0 126316  1084 ?        Ss   Oct29   0:22 /usr/sbin/crond -n
root       673  0.0  0.0 110104   128 ttyS0    Ss+  Oct29   0:00 /sbin/agetty --keep-baud 115200,38400,9600 ttyS0 vt220
root       674  0.0  0.0 110104   132 tty1     Ss+  Oct29   0:00 /sbin/agetty --noclear tty1 linux
root       840  0.0  0.0 107464  1996 ?        Ss   Oct29   0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H iZ8vb1nz5l71xucapbkndaZ eth0
root       901  0.0  0.3 573920 13260 ?        Ssl  Oct29   9:42 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
root       905  0.0  0.3 451608 13688 ?        Ssl  Oct29   7:20 /usr/sbin/rsyslogd -n
root      1087  0.0  0.0      0     0 ?        R    10:35   0:01 [kworker/1:1]
root      1115  0.0  0.0 112864  1256 ?        Ss   Oct29   0:05 /usr/sbin/sshd -D
root      1413  0.0  0.1 122428  4668 ?        Ss   Oct29   0:00 nginx: master process nginx
root      5011  0.0  0.1 157260  5056 ?        Ss   11:23   0:00 sshd: root@pts/1
root      5013  0.0  0.0 115572  1280 pts/1    Ss+  11:23   0:00 -bash
root      7006  0.0  0.0  32528  2992 ?        S<sl Nov15  30:00 /usr/local/aegis/aegis_update/AliYunDunUpdate
root      9471  0.0  0.0      0     0 ?        S    11:50   0:00 [kworker/0:1]
root      9838  0.0  0.1 154652  4752 ?        Ss   11:55   0:00 sshd: root@pts/0
root      9841  0.0  0.0 115572  1252 pts/0    Ss+  11:55   0:00 -bash
postgres  9961  0.0  0.0   2236    72 ?        Ss   11:56   0:00 fE8fEp
postgres 10931  0.2  0.0  16008   104 ?        Ssl  12:08   0:05 tracepath
postgres 11962  102 61.7 2432548 2396640 ?     Ssl  12:18  20:12 IS47Dj
root     12097  0.0  0.0      0     0 ?        S    12:20   0:00 [kworker/1:2]
root     12500  0.0  0.1 154652  5568 ?        Ss   12:25   0:00 sshd: root@pts/2
root     12503  0.0  0.0 115572  2184 pts/2    Ss+  12:25   0:00 -bash
postgres 12782  0.0  0.3 396672 12344 ?        Ss   Dec10   1:18 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data/
postgres 12785  0.0  0.0 249468  1580 ?        Ss   Dec10   0:00 postgres: logger   
postgres 12787  0.0  0.6 396796 27100 ?        Ss   Dec10   0:05 postgres: checkpointer   
postgres 12788  0.0  0.1 396672  6728 ?        Ss   Dec10   0:15 postgres: background writer   
postgres 12789  0.0  0.1 396672  5608 ?        Ss   Dec10   0:38 postgres: walwriter   
postgres 12790  0.0  0.0 397224  2744 ?        Ss   Dec10   0:36 postgres: autovacuum launcher   
postgres 12791  0.0  0.0 251872  1872 ?        Ss   Dec10   1:16 postgres: stats collector   
postgres 12792  0.0  0.0 397088  2112 ?        Ss   Dec10   0:01 postgres: logical replication launcher   
root     13401  0.0  0.0      0     0 ?        S    Dec22   0:01 [kworker/u4:1]
root     14259  0.0  0.0      0     0 ?        S    12:35   0:00 [kworker/1:0]
root     14447  0.5  0.1 154652  5568 ?        Ss   12:38   0:00 sshd: root@pts/3
root     14450  0.0  0.0 115572  2104 pts/3    Ss   12:38   0:00 -bash
root     14470  0.0  0.0 155332  1816 pts/3    R+   12:38   0:00 ps aux
root     24612  0.0  0.0  41828  2596 ?        Ssl  Nov15  23:48 /usr/sbin/aliyun-service
root     26707  0.0  0.0      0     0 ?        S    09:00   0:00 [kworker/0:2]
root     26894  0.0  0.0      0     0 ?        S    01:21   0:00 [kworker/u4:0]
root     27890  3.2  0.3 137752 14064 ?        S<sl Dec21  96:39 /usr/local/aegis/aegis_client/aegis_10_75/AliYunDun
nginx    31630  0.0  0.1 123032  6340 ?        S    Dec21   0:22 nginx: worker process
nginx    31631  0.0  0.1 123304  6580 ?        S    Dec21   0:30 nginx: worker process
8539 次点击
所在节点    程序员
39 条回复
msg7086
2019-12-23 12:58:39 +08:00
重装啊,难道你打算查杀?
CoderLife
2019-12-23 13:03:44 +08:00
@msg7086 重新好吓人, 里面的东西太多了
cyannnna
2019-12-23 13:12:48 +08:00
没快照或者备份么?
luozic
2019-12-23 13:14:39 +08:00
看到 redis 很有可能是通过 redis 开放端口入侵的。
MadHouse
2019-12-23 13:17:38 +08:00
直接 kill 不行吗
CoderLife
2019-12-23 13:19:34 +08:00
@cyannnna 没有开 杯具了

@luozic redis 都没有对外: ```bind 127.0.0.1```
@MadHouse kill 了一会又出来了, 且找不到痕迹
sambawy
2019-12-23 13:21:47 +08:00
crontab -l 看下有没有定时任务
CoderLife
2019-12-23 13:22:43 +08:00
@sambawy 排查了, 没有, 估计有一个守护进程.
amaranthf
2019-12-23 13:26:13 +08:00
看一下 pstree ?
CoderLife
2019-12-23 13:28:02 +08:00
systemd─┬─AliYunDun───24*[{AliYunDun}]
├─AliYunDunUpdate───3*[{AliYunDunUpdate}]
├─2*[agetty]
├─aliyun-service───2*[{aliyun-service}]
├─atd
├─auditd───{auditd}
├─chronyd
├─crond
├─dbus-daemon
├─dhclient
├─nginx───2*[nginx]
├─node─┬─3*[node───9*[{node}]]
│ └─5*[{node}]
├─polkitd───6*[{polkitd}]
├─postmaster───14*[postmaster]
├─redis-server───2*[{redis-server}]
├─rsyslogd───2*[{rsyslogd}]
├─sshd─┬─5*[sshd───bash]
│ └─sshd───bash───pstree
├─systemd-journal
├─systemd-logind
├─systemd-udevd
└─tuned───4*[{tuned}]

@amaranthf 看看呢
amaranthf
2019-12-23 13:32:00 +08:00
看不出来……不想重装又杀不掉的话,限制一下那个进程的 cpu 占用吧
CoderLife
2019-12-23 13:35:29 +08:00
@amaranthf 嗯, 先观察一下
mikeguan
2019-12-23 13:37:02 +08:00
看进程启动用户是 postgre,估计和 pgsql 有关了
先通过 PID 一步一步查下具体执行文件吧,可以搜索下有关 pgsql 挖矿,可能使用的手法都是一样的
CoderLife
2019-12-23 13:39:38 +08:00
@mikeguan 已经把 postgres 改为 nologin 了, pid 往上查就是 systemd 了, 痕迹太少了, 且找不到这个执行的文件
ragnaroks
2019-12-23 13:41:27 +08:00
再开一台一样的机器,对比下已运行进程二进制的 hash,替换常见二进制是惯用手法
mikeguan
2019-12-23 13:42:52 +08:00
@CoderLife 不一定需要登录才能执行脚本啊
CoderLife
2019-12-23 13:45:08 +08:00
@ragnaroks 应该是替换了系统进程, 客户的机器, 开一台不好说的, 也不要说这事....:dodge:
CoderLife
2019-12-23 13:45:30 +08:00
@mikeguan 只能这样, 能防点算点了
beautwill
2019-12-23 13:50:16 +08:00
不是你的程序的问题,是通过阿里云盾调用过来的,很可能是 AK 泄露了,检查下云助手是否存在 api 调用。
RadishWind
2019-12-23 14:11:25 +08:00
在 proc 目录能还原出正在运行的可执行文件,然后设置 iptables 和安全组,ban 掉 C&C 服务器的 ip

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/631475

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX