事由:近段时间生产环境被攻击删库,这里记一下。
付款
4月下旬,数据库一部分数据被删,要求付0.1BTC。不理会。
5.20 早上约11时,数据库被删。要求付0.05BTC。信息:
1 | To recover your lost Database and avoid leaking it: Send us 0.05 Bitcoin (BTC) to our Bitcoin address 1MAikeLUHocwmKZLZfZAoh6n9G9j4CKp13 and contact us by Email with your Server IP or Domain name and a Proof of Payment. Your Database is downloaded and backed up on our servers. Backups that we have right now: contract, ttcddata, ttcddata2, yzmailbox, If we dont receive your payment in the next 10 Days, we will make your database public or use them otherwise. |
后付款0.05BTC,结果:石沉大海。
ssh登陆
另外发现无法访问主机,经查,是denyhosts拒绝本地电脑的公网IP。删除即可。
进程:
1 | python /usr/bin/denyhosts.py --daemon --config=/usr/share/denyhosts/denyhosts.cfg |
查/usr/share/denyhosts/denyhosts.cfg
文件,有HOSTS_DENY = /etc/hosts.deny
。/etc/hosts.deny
文件保存的是拒绝IP列表。示例如:
1 | # DenyHosts: Wed May 22 07:51:29 2019 | sshd: 193.32.163.81 |
数据库
mysql数据历史命令记录文件:~/.mysql_history
。
数据库被攻击日志:
1 | MySQL Database Privilege Escalation - Create 'plugin' Folder |
整改措施
- 修改云主机密码、数据库密码。
- 在
/etc/hosts.allow
文件输入可访问IP列表。在/etc/hosts在
/etc/hosts.deny中输入:
sshd: ALL`表示拒绝所有IP。 - 删除mysql历史命令文件,并做链接:
ln -s /dev/null $HOME/.mysql_history
经验教训
- 加强意识,第一次出现时需要有危机意识,并进行整改。同时举一反三。(第一次被删库未做任何整改)
- 定期修改密码(云主机、数据库),密码需要一定复杂性。不同云主机、服务,密码不同相同。密码不能让太多人知道。(2台云主机密码相同,密码较简单。更严重的是,密码很早就没改过,且经过几波开发人员,而这些人已不可觅其踪迹,再者,从密码字面可大胆猜测密码由云主机运营商那边提供的,我方没改过。——因为出现的人名、手机号,不是我方的)
- 不必要的端口,不开放。修改默认服务的端口。如数据库的3306端口,ssh的22端口。
PS:因个人权限和职责,文中所述并未真正参与。