Linux系統對付惡意軟件的三款應用軟件
譯文【51CTO.com快譯】即使你使用Tripwire,也應該意識到惡意攻擊者仍會在你不知情的情況下在系統上植入惡意軟件。在本文中,你將學習如何安裝和運行三款不同的反惡意軟件應用軟件:chkrootkit、rkhunter和ClamAV,它們可以幫助你的系統遠離惡意軟件。
在嘗試修復惡意軟件感染之前,切換至單個用戶模式,確保惡意攻擊者不會察覺你的活動,或無法掩蓋其行蹤。
1.chkrootkit
我使用chkrootkit有多年。簡而言之,它可掃描系統中的重要文件以查找rootkit。 rootkit是一堆惡意程序,旨在危及root用戶帳戶,并長時間訪問系統。rootkit很難檢測,也很難從系統中刪除。我聽好多系統管理員這么說:如果系統是rootkit的受害者,應為系統重建映像(格式化并從存儲介質重新安裝),然后從干凈備份還原所有數據。
是的,這是一種解決方案,但是你是否曾為系統重建映像,能夠讓系統恢復到感染之前的狀態?反正我從來沒有過。新系統總是遺漏一些東西,這些總是“關鍵”的東西。我花了無數時間尋找舊版軟件、搜索舊文檔,并尋找存儲介質來重新安裝再也沒人支持、可能再也沒有合法許可證的一些必要軟件。話題扯遠了。
你可以使用chkrootkit掃描許多類型的rootkit,并檢測某些日志刪除。雖然它無法刪除任何受感染的文件,但確實會告訴你具體哪些文件被感染,以便你可以刪除/重裝/修復文件或軟件包。
請遵照以下簡單過程,使用chkrootkit下載、安裝和掃描系統。使用sudo或su成為root用戶。
- # yum update
- # yum install wget gcc-c++ glibc-static
- # wget -c ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
- # tar –zxvf chkrootkit.tar.gz
- # mkdir /usr/local/chkrootkit
- # mv chkrootkit-0.xx/* /usr/local/chkrootkit
- # cd /usr/local/chkrootkit
- # make sense
- << compile output >>
- # /usr/local/chkrootkit/chkrootkit
- ROOTDIR is `/'
- Checking `amd'... not found
- Checking `basename'... not infected
- Checking `biff'... not found
- Checking `chfn'... not infected
- Checking `chsh'... not infected
- Checking `cron'... not infected
- Checking `crontab'... not infected
- Checking `date'... not infected
- Checking `du'... not infected
- Checking `dirname'... not infected
- Checking `echo'... not infected
- << more output >>
chkrootkit腳本報告受感染的文件。我從未遇到過誤報,但你碰到的情況可能不一樣。我在管理的每個Linux系統上都安裝了chkrootkit。我還設置了計劃任務(cron job),執行上述所有步驟(除安裝依賴項之外),以便我始終擁有更新后的集合。我還將輸出重定向到用戶帳戶主目錄中的一個文件。可以選擇在腳本末尾通過電子郵件將文本報告發送給你。
chkrootkit腳本僅需幾秒鐘即可掃描和報告,因此使用它并不浪費時間或精力。
2.rkhunter
RootKit Hunter(rkhunter)是一個rootkit檢測腳本,可以自動掃描許多不同的rootkit及其他本地漏洞。我愛rkhunter,用它也已有多年。與chkrootkit不同,rkhunter在/var/log/rkhunter/rkhunter.log中提供了記錄發現結果的完整日志。如果你只安裝和運行一款惡意軟件掃描應用軟件,它可能應該是rkhunter。
以下是在系統上安裝和運行rkhunter的方法。使用sudo或su成為root用戶。
- # yum -y install epel-release
- # yum -y install rkhunter
- # rkhunter -c
- [ Rootkit Hunter version 1.4.6 ]
- Checking system commands...
- Performing 'strings' command checks
- Checking 'strings' command [ OK ]
- Performing 'shared libraries' checks
- Checking for preloading variables [ None found ]
- Checking for preloaded libraries [ None found ]
- Checking LD_LIBRARY_PATH variable [ Not found ]
- << lots of output >>
- System checks summary
- =====================
- File properties checks...
- Required commands check failed
- Files checked: 129
- Suspect files: 4
- Rootkit checks...
- Rootkits checked : 494
- Possible rootkits: 0
- Applications checks...
- All checks skipped
- The system checks took: 1 minute and 38 seconds
- All results have been written to the log file: /var/log/rkhunter/rkhunter.log
- One or more warnings have been found while checking the system.
- Please check the log file (/var/log/rkhunter/rkhunter.log)
rkhunter有時會標記你手動更改的文件。我的四個“可疑”文件中有兩個是passwd和group,這兩個都是我手動更改的文件。它還會通過touch、vi或者更改原始訪問或修改日期的另外某個程序,標記你有意或無意修改的文件。ifup和ifdown是我系統上被標為可疑的另外兩個文件。我還沒有搞清楚原因,但覺得這兩個都不是問題。
就算你認為自己知道情況,也要核查所有被標記的文件。
3.ClamAV
ClamAV官網頁面介紹:ClamAV是一種可用于各種場景的開源(GPL)防病毒引擎,包括電子郵件掃描、Web掃描和端點安全。它提供了許多實用程序,包括靈活且可擴展的多線程守護程序、命令行掃描程序以及用于數據庫自動更新的高級工具。
要安裝ClamAV,請成為root或sudo用戶,使用以下命令:
- # yum -y install clamav
- # freshclam
- ClamAV update process started at Fri Apr 3 17:21:48 2020
- daily database available for download (remote version: 25772)
- Time: 27.3s, ETA: 0.0s [=============================>] 57.90MiB/57.90MiB
- Testing database: '/var/lib/clamav/tmp.63140/clamav-5feeeb4cb75d1c44dd7c48b836fe457c.tmp-daily.cvd' ...
- << output >>
- # clamscan -r -i /
- LibClamAV Warning: fmap_readpage: pread fail: asked for 4085 bytes @ offset 11, got 0
- LibClamAV Warning: fmap_readpage: pread fail: asked for 4088 bytes @ offset 8, got 0
- LibClamAV Warning: fmap_readpage: pread fail: asked for 4088 bytes @ offset 8, got 0
- LibClamAV Warning: fmap_readpage: pread fail: asked for 4085 bytes @ offset 11, got 0
- LibClamAV Warning: fmap_readpage: pread fail: asked for 4093 bytes @ offset 3, got 0
- LibClamAV Warning: fmap_readpage: pread fail: asked for 4093 bytes @ offset 3, got 0
- << Lots of output >>
- ----------- SCAN SUMMARY -----------
- Known viruses: 6801836
- Engine version: 0.102.2
- Scanned directories: 13294
- Scanned files: 64849
- Infected files: 0
- Total errors: 11295
- Data scanned: 2668.46 MB
- Data read: 2094.11 MB (ratio 1.27:1)
- Time: 509.652 sec (8 m 29 s)
- #
如你所見,掃描整個系統耗時幾分鐘,所以通過cron掃描并重定向輸出來得更容易。
結束語
靠譜建議是通過cron安排自動更新和掃描。一旦啟動了新系統,你還應立即執行初步掃描,因為這為你提供了基準情況。每次更新和安裝軟件后掃描。所有操作系統都有特定的惡意軟件,因此,切勿因個人偏見而影響你對系統和用戶執行正確的操作。要假設任何系統都不是完全干凈的。
原文標題:3 antimalware solutions for Linux systems,作者:Ken Hess
【51CTO譯稿,合作站點轉載請注明原文譯者和出處為51CTO.com】