Blog FOSS by Lê Trung Nghĩa

https://letrungnghia.mangvn.org


Các công cụ dò tìm phần mềm độc hại và Rootkit là phần mềm tự do nguồn mở

Free & Open Source Rootkit and Malware Detection Tools

March 25, 2013

Article by Jay Turla first published on infosecinstitute

Theo: http://linuxaria.com/article/free-open-source-rootkit-and-malware-detection-tools?lang=en

Bài được đưa lên Internet ngày: 25/03/2013

Lời người dịch: Một tham khảo rất tốt cho các quản trị viên hệ thống để thực hiện một số nhiệm vụ phòng thủ mạng của đơn vị mình bằng việc sử dụng các công cụ an ninh là các phần mềm tự do nguồn mở như Chkrootkit, Rootkit Hunter, ClamAV, BotHunter, avast!, NoePI, Ourmon và Grep để tìm ra các dạng phần mềm độc hại như sniffers, rootkits, botnets, backdoor shells trong hệ thống mạng của mình.

Nhiều phần mềm độc hại dạng sniffers, rootkits, botnets, backdoor shells và các dạng khác vẫn đang bùng nổ ngày nay, chúng được những kẻ tấn công sử dụng sau khi thành công trong việc chui vào một máy chủ nhất định hoặc một mạng đang hoạt động để duy trì sự truy cập của chúng, nâng quyền ưu tiên truy cập của chúng và gián điệp những người sử dụng khác trong một mạng. Để bảo vệ mạng hoặc máy chủ của chúng ta khỏi những thâm nhập trái phép và thiệt hại xa hơn như vậy, có những công cụ dò tìm là phần mềm tự do nguồn mở mà có thể được triển khải và sử dụng như một phần của chiến lược an ninh của chúng ta. Chúng là bắt buộc khi máy chủ hoặc mạng của chúng ta được thiết lập và chạy, đặc biệt nếu một người sử dụng nhất định đang tải về một tệp mà có khả năng là độc hại hoặc gây hại.

Ưu điểm của việc sử dụng các công cụ bảo vệ là phần mềm tự do nguồn mở là việc bạn rõ ràng không cần trả một xu nào và các sách chỉ dẫn rất dễ dàng có được và hiểu được vì các sách chỉ dẫn được đưa vào thường có tên là README (hãy đọc tôi) và chắc chắn sẽ là RTFM (Hãu đọc Sách chỉ dẫn …).

Đây là một số công cụ có thể bạn muốn sử dụng:

A lot of sniffers, rootkits, botnets, backdoor shells and malwares are still on the wild today, which are used by malicious attackers after successfully pawning a certain server or any live network in order to maintain their access, elevate their access privilege, and spy other users in a network. In order to protect our network or server f-rom such intrusions and further damage, there are free and open source detection tools that can be deployed and used as part of our security strategy. They are mandatory when our server or network is up and running, especially if a certain user is downloading a file which could possibly be malicious or harmful.

The advantage of using free and open source detection tools is that you obviously don’t need to pay a single penny and that tutorials are very easy to get and understand because manuals are included which are usually named as README so be sure to RTFM (Read the F****** Manual).

Here are some tools which could be of use to you guys

Chkrootkit

Chkrootkit

Chkrootkit hoặc Check Rootkit là một chương trình hoặc công cụ nguồn mở phổ biến được sử dụng để quét các rootkits, botnet, phần mềm độc hại... trong máy chủ hoặc hệ thống Unix/Linux của bạn. Nó được kiểm thử đầy đủ trên: Linux 2.0.x, 2.2.x, 2.4.x, 2.6.x, and 3.x.x, FreeBSD 2.2.x, 3.x, 4.x, 5.x and 7.x, OpenBSD 2.x, 3.x and 4.x., NetBSD 1.6.x, Solaris 2.5.1, 2.6, 8.0 and 9.0, HP-UX 11, Tru64, BSDI và Mac OS X. Công cụ này được cài đặt sẵn trong BackTrack 5 như các công cụ nghiên cứu pháp lý chống virus (Anti-Virus Forensic Tools).

Để cài đặt chkrootkit lên một phát tán dựa vào Ubuntu hoặc Debian, bạn có thể chỉ cần gõ:

sudo apt-get install chkrootkit.

Để bắt đầu kiểm tra liệu có rootkits và các cửa hậu có khả năng trong hệ thống của bạn hay không, hãy gõ lệnh:

sudo chkrootkit.

Chkrootkit or Check Rootkit is a common open source program or tool used for scanning rootkits, botnets, malwares, etc. in your Unix/Linux server or system. It is fully tested on: Linux 2.0.x, 2.2.x, 2.4.x, 2.6.x, and 3.x.x, FreeBSD 2.2.x, 3.x, 4.x, 5.x and 7.x, OpenBSD 2.x, 3.x and 4.x., NetBSD 1.6.x, Solaris 2.5.1, 2.6, 8.0 and 9.0, HP-UX 11, Tru64, BSDI and Mac OS X. This tool is pre-installed in BackTrack 5 under Anti-Virus Forensic Tools.

To install chkrootkit on a Ubuntu or Debian based distro, you can just type :

sudo apt-get install chkrootkit.

To start checking for possible rootkits and backdoors in your system, type the command:

sudo chkrootkit.

chkrootkit

Here are other options you can use after issuing the command sudo chkrootkit -h:

Đây là những lựa chọn khác mà bạn có thể sử dụng sau khi đưa ra lệnh sudo chkrootkit -h:

-h show the help and exit

-V show version information and exit

-l show available tests and exit

-d debug

-q quiet mode

-x expert mode

-e exclude known false positive files/dirs, quoted, space separated, READ WARNING IN README

-r dir use dir as the root directory

-p dir1:dir2:dirN     path for the external commands used by chkrootkit

-n skip NFS mounted dirs

Rootkit Hunter

Trình săn Rootkit - Rootkit Hunter

Rootkit hunter hoặc rkhunter là một trình quét Rootkit có giấy phép nguồn mở GPL tương tự như chkrootkit là cũng được cài đặt sẵn trước trong BackTrack 5 theo Anti-Virus Forensic Tools. Công cụ này quét để biết các rootkits, các cửa ậu và các khai thác cục bộ bằng việc chạy các kiểm thử như: so sánh hàm băm MD5, tìm kiếm các tệp mặc định được các rootkit sử dụng, các quyền sai của các tệp được các rootkit sử dụng, các quyền sai của các tệp cho các tệp nhị phân, tìm kiếm các chuỗi khả nghi trong các module LKM và KLD, tìm kiếm các tệp ẩn, và quét tùy ý trong văn bản thô và các tệp nhị phân.

Để cài đặt rkhunter lên một phát tán dựa vào Ubuntu hoặc Debian, bạn có thể chỉ cần gõ:

Rootkit hunter or rkhunter is an Open Source General Public License (GPL) Rootkit Scanner similar to chkrootkit which is also pre-installed in BackTrack 5 under Anti-Virus Forensic Tools. This tool scans for rootkits, backdoors and local exploits by running tests like: MD5 hash compare, look for default files used by rootkits, wrong file permissions for binaries, look for suspected strings in LKM and KLD modules, look for hidden files, and optional scan within plaintext and binary files.

To install rkhunter on a Ubuntu or Debian based distro, you can just type :

sudo apt-get install rkhunter.

To start the scanning in your file system, type the command:

sudo rkhunter –check.

And if you want check for up-dates, issue the command:

sudo rkhunter –up-date.

rkhunter

After rkhunter has finished scanning your file system, all the results are logged at /var/log/rkhunter.log.

Here are other useful options for rkhunter as shown in the -h flag:

Sau khi rkhunter đã kết thúc việc quét hệ thống tệp của bạn, tất cả các kết quả được lưu ký trong /var/log/rkhunter.log.

Đây là những lựa chọn hữu dụng khác cho rkhunter như được chỉ ra trong cờ -h:

–append-log      Append to the logfile, do not overwrite

–bindir … Use the specified command directories

-C, –config-check Check the configuration file(s), then exit

–cs2, –color-set2 Use the second color set for output

–configfile Use the specified configuration file

–cronjob Run as a cron job

–dbdir Use the specified database directory

–debug      Debug mode

–disable [,...] Disable specific tests

–display-logfile Display the logfile at the end

–enable [,...] Enable specific tests

–hash {MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512}

                 Use the specified file hash function

–list [tests | languages | List the available test names, languages, checked rootkits | perl] for rootkits, or perl module status, then exit

-l, –logfile [file] Write to a logfile (Default is /var/log/rkhunter.log)

–noappend-log Do not append to the logfile, overwrite it

–nocf Do not use the configuration file entries for disabled tests (only valid with –disable)

–nocolors Use black and white output

–nolog Do not write to a logfile

–nomow, –no-mail-on-warning Do not send a message if warnings occur

–ns, –nosummary Do not show the summary of check results

–novl, –no-verbose-logging No verbose logging

–pkgmgr {RPM | DPKG | BSD | Use the specified package manager to obtain or SOLARIS | NONE} verify file property values. (Default is NONE)

–propupd [file | directory | Up-date the entire file properties database, package]… or just for the specified entries

-q, –quiet Quiet mode

–rwo, –report-warnings-only Show only warning messages

-r, –rootdir Use the specified root directory

–sk, –skip-keypress Don’t wait for a keypress after each test

–summary Show the summary of system check result

–syslog [facility.priority] Log the check start and finish times to syslog

–tmpdir Use the specified temporary directory

–unlock      Unlock (remove) the lock file

–vl, –verbose-logging      Use verbose logging (on by default)

-V, –version      Display the version number, then exit

–versioncheck Check for latest version of program

-x, –autox Automatically detect if X is in use

-X, –no-autox Do not automatically detect if X is in use
ClamAV

ClamAV

ClamAV là một phần mềm chống virus nguồn mở nổi tiếng trong Linux. Nó là phần mềm chống virus nổi tiếng nhất trong Linux mà có một phiên bản giao diện đồ họa cho người sử dụng GUI bây giờ được thiết kế cho việc dò tìm các Trojan, các virus, phần mềm độc hại và các mối đe dọa độc hại các một cách dễ dàng hơn. ClamAV cũng có thể được cài đặt trong Windows, BSD, Solaris và thậm chí cả Mac OS X. Nhà nghiên cứu về an ninh Dejan Lukan có một sách chỉ dẫn chi tiết ở đây trên trang Các tài nguyên Nghiên cứu của InfoSec (InfoSec Institute Resources) về cách để cài đặt ClamAV và cách làm việc với giao diện dòng lệnh.

ClamAV is a known open source anti-virus software in Linux. It is the most famous Linux anti-virus which has a GUI version now designed for detecting Trojans, viruses, malware and other malicious threats easier. ClamAV can also be installed in Windows, BSD, Solaris and even in MacOSX. Fellow security researcher Dejan Lukan has a detailed tutorial here in InfoSec Institute Resources page on how to install ClamAV and how to work with its command line interface.

BotHunter

Trình săn lùng các Botnet - BotHunter

BotHunter là một hệ thống dự báo các botnet dựa vào mạng, theo dõi dòng chảy giao tiếp 2 chiều giữa máy tính cá nhân của bạn và Internet. Nó được Phòng thí nghiệm Khoa học Máy tính (Computer Science Laboratory), SRI International phát triển và sẵn sàng cho Linux và Unix, nhưng bây giờ chúng đã phát hành một Phiên bản Kiểm thử Riêng rẽ và một Phiên bản sớm cho Windows.

Bạn có thể tải về phần mềm này ở đây. Bạn cũng có thể kiểm tra các trình bổ sung của nó được gọi là BotHunter2Web.pl. Trình bổ sung này chuyển các hồ sơ lây nhiễm của BotHunter thành các trang web, có thể thấy được thông qua trình duyệt của bạn một cách trực tiếp hoặc thông qua máy chủ web riêng. Các hồ sơ lây nhiễm của BotHunter thường được đặt trong ~cta-bh/BotHunter/LIVEPIPE/botHunterResults.txt.

Sử dụng ví dụ BotHunter2Web.pl:

BotHunter is a network-based botnet diagnosis system which tracks the two-way communication flows between your personal computer and the Internet. It is developed and maintained by the Computer Science Laboratory, SRI International and available for Linux and Unix but now they have released a Private Test Release and a Pre-Release for Windows.

You can download this software here. You could also check its addon which is called BotHunter2Web.pl. This addon converts BotHunter infection profiles into web pages, which can be viewed through your browser directly or via private webserver. BotHunter infection profiles are typically located in ~cta-bh/BotHunter/LIVEPIPE/botHunterResults.txt.

Sample Usage for BotHunter2Web.pl:

perl BotHunter2Web.pl [-date YYYY-MM-DD] -i sampleresults.txt

Additional Options and Switches:

-h — help message

-date YYYY-MM-DD — [or TODAY, YESTERDAY]. Blank = build one massive table

-i FILE — BotHunter profile file (e.g., botHunterResults.txt)

-wl — A list of victim IPs you wish to surpress f-rom the HTML table

-outdir — Output Directory(default = current dir)

-MaxEvents N — Max number of event entries per row

-MaxCC N — Max number of CC entries per row

-lookup — Perform nslookup on victim IP

avast! Linux Home Edition

avast! Linux Home Edition is an anti-virus engine offered free of c-harge but only for home and not for commercial use. It includes a command line scanner and based on my experience it detects some of the Perl IRC bots I have been collecting like w3tw0rk’s modified IRC (Internet Relay Chat) bot (originally made by Pitbul) that contains malicious functions like udpflood & tcpflood functions and allows its master or bot controller to execute arbitrary commands with the use of the system() function for Perl.

You can download this antivirus software here.

avast! Phiên bản dành cho Linux ở nhà (Linux Home Edition)

avast! Linux Home Edition là một động cơ chống virus được đưa ra miễn phí những chỉ cho sử dụng ở nhà chứ không cho sử dụng thương mại. Nó bao gồm một trình quét dòng lệnh và theo kinh nghiệm của tôi nó dò tìm một số bot Perl IRC mà tôi đã và đang thu thập như IRC (Internet Relay Chat) bot được sửa đổi của w3tw0rk mà có chứa các chức năng độc hại như các chức năng udpflood & tcpflood và cho phép máy chủ hoặc trình kiểm soát của nó thực thi các lệnh tùy ý bằng việc sử dụng chức năng system() cho Perl.

Bạn có thể tải về phần mềm chống virus này ở đây.

NeoPI

NeoPI is a Python script which is useful for detecting obfuscated and encrypted content within text or script files. The intended purpose of NeoPI is to aid in the detection of hidden web shell code. The development focus of NeoPI was creating a tool that could be used in conjunction with other established detection methods such as Linux Malware Detect or traditional signature or keyword based searches. It is a cross platform script for Windows and Linux. Not only does it aid users to detect possible backdoor shells but also malicious scripts like IRC botnets, udpflood shells, vulnerable scripts, and other malicious stuffs.

To use this Python script, just checkout the code in its official github site and navigate through its directory:

NoePI

NeoPI là một script Python hữu dụng cho việc dò tìm nội dung đen tối và được mã hóa trng các tệp văn bản hoặc script. Mục đích có ý định của NeoPI là để giúp dò tìm các mã shell web ẩn. Trọng tâm phát triển của NeoPI là tạo ra một công cụ có thể được sử dụng trong sự kết hợp với các phương pháp dò tìm nổi tiếng khác như Dò tìm Phần mềm độc hại của Linux (Linux Malware Detect) hoặc chữ ký hoặc từ khóa truyền thống dựa vào các nghiên cứu. Nó là một script liên nền tảng cho Windows và Linux. Nó không chỉ giúp những người sử dụng dò tìm ra các shell cửa hậu có khả năng, mà còn cả các script độc hại như các botnet IRC, các udpflood shells, các script có khả năng bị tổn thương và các loại độc hại khác.

Để sử dụng script Python, hãy kiểm tra mã trên site chính thức của github và di chuyển qua thư mục của nó:

git clone https://github.com/Neohapsis/NeoPI.git

cd NeoPI

Then we use the -h flag to see the options for running the script:

Sau đó chúng ta sử dụng cờ -h để xem các lựa chọn cho việc chạy script:

shipcode@projectX:/opt/NeoPI$ sudo ./neopi.py -h

Usage: neopi.py [options] regex>

Options:

–version         show program’s version number and exit

-h, –help         show this help message and exit

-c FILECSV, –csv=FILECSV    generate CSV out-file

-a, –all         Run all (useful) tests [Entropy, Longest Word, IC, Signature]

-z, –zlib         Run compression Test

-e, –entropy         Run entropy Test

-E, –eval         Run signature test for the eval

-l, –longestword         Run longest word test

-i, –ic         Run IC test

-s, –signature         Run signature test

-S, –supersignature         Run SUPER-signature test

-A, –auto         Run auto file extension tests

-u, –unicode         Skip over unicode-y/UTF’y files

Dựa vào các lựa chọn ở trên, nếu chúng ta muốn chạy tất cả các kiểm thử như Entropy, Longest Word, IC, Signature và chạy các kiểm thử mở rộng tệp chạy tự động trong thư mục /var/www, thì chúng ta có thể sẽ đưa ra lệnh:

Based on the options above, if we want to run all tests like Entropy, Longest Word, IC, Signature and run auto file extension tests in the /var/www directory, we can just issue the command:

sudo ./neopi.py -a -A /var/www

Nếu bạn muốn tạo một CSV out-file cho các tham chiếu trong tương lai, chúng ta có thể sử dụng lệnh:

If you want to generate a CSV out-file for future references, we can use the command:

sudo ./neopi.py -C out-file.csv -a -A /var/www

neopi

Hai nhà nghiên cứu an ninh (Scott Behrens và Ben Hagen) tại InfoSec Institute và các lập trình viên gốc ban đầu của dự án NeoPI cũng đã viết một sách chỉ dẫn chi tiết có đầu đề 'Dò tìm Web Shell bằng việc sử dụng NeoPI', nó giải thích nội chuyển lực, từ dài nhất, IC, chữ ký và những kiểm thử hữu dụng khác.

Two security researchers (Scott Behrens and Ben Hagen) here in InfoSec Institute and the original developers of the NeoPI project have also written a detailed tutorial entitled ‘Web Shell Detection Using NeoPI‘ which explains Entropy, Longest Word, IC, Signature and other useful tests.

Ourmon

Ourmon is a Unix-based open source program and a common network packet sniffing tool in FreeBSD but it can also be used for detecting botnets as explained by Ashis Dash in his article entitled ‘Botnet detection tool: Ourmon‘ in Clubhack Magazine or Chmag.

Ourmon

Ourmon là một chương trình nguồn mở dựa vào Unix và một công cụ ngửi gói mạng phổ biến trong FreeBSD nhưng nó cũng có thể được sử dụng cho việc dò tìm các botnet như được Ashis Dash giải thích trong bài báo của ông với đầu đề 'Công cụ dò tìm Botnet: Ourmon' trên Tạp chí Clubhack hoặc Chmag.

Grep

And the last but not the least, we have the grep command which is a powerful command-line tool in Unix and Linux. It is used for searching and probing data sets for lines that matches a regular expression. As a short history, this utility was coded by Ken Thompson on March 3, 1973 for Unix. Nowadays, Grep is known for detecting and searching for pesky backdoor shells and malicious scripts too.

Grep can also be used for detecting vulnerable scripts (e.g the PHP function shell_exec which is a risky PHP function that allows remote code execution or command execution). We can use the grep command to search for the shell_exec () function as our advantage in our /var/www directory to check for possible PHP files that are vulnerable to RCE or command injection. Here is the command:

Grep

Và cuối cùng, chúng ta có lệnh grep, là một công cụ dòng lệnh mạnh trong Unix và Linux. Nó được sử dụng cho việc tìm kiếm và kiểm thử các tập hợp dữ liệu cho các dòng mà khớp với một biểu thức thông thường. Như một lịch sử ngắn ngủi, tiện ích này từng được Ken Thmpson viết mã hôm 03/03/1973 cho Unix. Bây giờ, Grep nổi tiếng cho việc dò tìm và tìm kiếm các shell cửa hậu phiền hà và các script độc hại.

Grep cũng có thể được sử dụng cho việc dò tìm các script có khả năng bị tổn thương (như hàm shell_exec của PHP, nó là một chức năng PHP mạo hiểm mà cho phép thực thi mã hoặc thực thi lệnh ở xa). Chúng ta có thể sử dụng lệnh grep để tìm kiếm các hàm shell_exec () khi ưu thế của chúng ta trong thư mục /var/www để kiểm tra các tệp PHP có khả năng bị tổn thương đối với RCE hoặc sự tiêm lệnh. Đây là lệnh đó:

grep -Rn “shell_exec *( ” /var/www

grep

Backdoor shells commonly use the shell_exec function for executing arbitrary commands. Aaside f-rom shell_exec function, most PHP backdoor shells also use functions like base64_decode, eval, phpinfo, system, php_uname, chmod, fopen, fclose, readfile, edoced_46esab, and passthru.

Thus you could also easily grep these functions:

Các shell cửa hậu thường sử dụng hàm shell_exec cho việc thực thi các lệnh tùy ý. Ngoài hàm shell_exect ra, hầu hết các shell cửa hậu của PHP cũng sử dụng các hàm như base64_decode, eval, phpinfo, system, php_uname, chmod, fopen, fclose, readfile, edoced_46esab và passthru.

Vì thế bạn cũng có thể dễ dàng grep các hàm đó:

grep -Rn “shell_exec *(” /var/www

grep -Rn “base64_decode *(” /var/www

grep -Rn “phpinfo *(” /var/www

grep -Rn “system *(” /var/www

grep -Rn “php_uname *(” /var/www

grep -Rn “chmod *(” /var/www

grep -Rn “fopen *(” /var/www

grep -Rn “fclose *(” /var/www

grep -Rn “readfile *(” /var/www

grep -Rn “edoced_46esab *(” /var/www

grep -Rn “eval *(” /var/www

grep -Rn “passthru *(” /var/www

In my recent researches, most Perl IRC botnets use common Perl functions like shell, system, and tcp so we can actually grep these functions just like hunting or detecting PHP backdoor shells. Thus, if we want to scan our /var/www directory again then we could just issue the commands below:

Trong các nghiên cứu gần đây của tôi, hầu hết các botnet Perl IRC sử dụng các hàm Perl phổ biến như shell, system và tcp sao cho chúng ta có thể thực sự grep các hàm đó hệt như việc đi săn hoặc dò tìm các shell cửa hậu PHP. Vì thế, nếu chúng ta muốn quét thư mục /var/www của chúng ta một lần nữa thì chúng ta có thể chỉ cần đưa ra các lệnh bên dưới:

grep -Rn “shell *(” /var/www

grep -Rn “tcp *(” /var/www

grep -Rn “system *(” /var/www

grep2

Grep is such a good tool for manual detection and forensic analysis.

Grep là một công cụ tốt như vậy cho sự dò tìm bằng tay và phân tích pháp lý.

References:

Các tài liệu tham khảo:

http://www.cyberciti.biz/faq/howto-check-linux-rootkist-with-detectors-software/https://github.com/Neohapsis/NeoPIhttp://www.bothunter.net/bothunter2web.html
http://resources.infosecinstitute.com/open-source-antivirus-clamav/
http://pentestlab.org/hunting-malicious-perl-irc-bots/
http://blog.rootcon.org/2012/04/simple-kung-fu-grep-for-finding-common.htmlhttp://resources.infosecinstitute.com/web-shell-detection/

Dịch: Lê Trung Nghĩa

letrungnghia.foss@gmail.com

Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây