在CentOS/Fedora/Ubuntu/Debian上安装和使用Linux Malware检测
Linux Malware Detect(LMD)是GNU GPLv2许可证下的Linux的恶意软件扫描仪,它围绕共享托管环境所面临的威胁。
在本教程中,我们将讨论如何在Linux上安装和使用Linux Malware检测 - CentOS/Fedora/Ubuntu/Debian/Arch 等。
LMD使用来自网络边缘入侵检测系统的威胁数据来提取积极用于攻击的恶意软件并生成检测的签名。
威胁数据也可以通过用户提交的用户提交,并从恶意软件社区资源中获取。
LMD签名是MD5文件哈希和十六进制模式匹配,并且可以轻松地将任何数量的检测工具(如CLAMAV)导出到。
在Linux上安装Linux Malware检测 - CentOS/Fedora/Ubuntu/Debian
我们将从GitHub存储库中克隆该项目,并运行安装程序脚本以在我们的Linux系统上使用Linux恶意软件检测 - CentOS/Fedora/Ubuntu/Debian/Arch 等。
第1步:克隆项目存储库。
Linux恶意软件检测项目位于GitHub上。
使用Git命令下载它,可通过系统包管理器轻松安装 - 适用于Debian基于Systems,Yum/DNF for Rhel/Fedora或者Pacman for Arch及其衍生物。
# RHEL/CentOS sudo yum -y install git sudo dnf -y install git # Ubuntu/Debian sudo apt-get -y install git # Arch/Manjaro sudo pacman -S git
克隆代码来自github。
$git clone https://github.com/rfxn/linux-malware-detect.git Cloning into 'linux-malware-detect'... remote: Enumerating objects: 81, done. remote: Counting objects: 100% (81/81), done. remote: Compressing objects: 100% (49/49), done. remote: Total 1991 (delta 47), reused 57 (delta 32), pack-reused 1910 Receiving objects: 100% (1991/1991), 1.79 MiB | 1.56 MiB/s, done. Resolving deltas: 100% (1446/1446), done.
第2步:运行安装程序脚本
源代码在本地可用后,导航到Project目录并运行Sudo的安装程序脚本install.sh。
$cd linux-malware-detect/ $sudo ./install.sh Created symlink from /etc/systemd/system/multi-user.target.wants/maldet.service to /usr/lib/systemd/system/maldet.service. Linux Malware Detect v1.6.4 (C) 2002-2019, R-fx Networks <proHyman@theitroad> (C) 2019, Ryan MacDonald <Hyman@theitroad> This program Jan be freely redistributed under the terms of the GNU GPL installation completed to /usr/local/maldetect config file: /usr/local/maldetect/conf.maldet exec file: /usr/local/maldetect/maldet exec link: /usr/local/sbin/maldet exec link: /usr/local/sbin/lmd cron.daily: /etc/cron.daily/maldet maldet(6686): {sigup} performing signature update check... maldet(6686): {sigup} could not determine signature version maldet(6686): {sigup} signature files missing or corrupted, forcing update... maldet(6686): {sigup} new signature set 2019052829145 available maldet(6686): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-sigpack.tgz maldet(6686): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-cleanv2.tgz maldet(6686): {sigup} verified md5sum of maldet-sigpack.tgz maldet(6686): {sigup} unpacked and installed maldet-sigpack.tgz maldet(6686): {sigup} verified md5sum of maldet-clean.tgz maldet(6686): {sigup} unpacked and installed maldet-clean.tgz maldet(6686): {sigup} signature set update completed maldet(6686): {sigup} 15519 signatures (12707 MD5 | 2035 HEX | 777 YARA | 0 USER)
确认安装Linux Malware Detect的版本。
$maldet --version Linux Malware Detect v1.6.4 (C) 2002-2019, R-fx Networks Hyman@theitroad (C) 2019, Ryan MacDonald Hyman@theitroad This program Jan be freely redistributed under the terms of the GNU GPL v2 public scanning is currently disabled (scan_user_access=0), please contact your system administrator to enable scan_user_access in conf.maldet.
第3步:配置Linux恶意软件检测(LMD)
Linux恶意软件检测的主要配置文件位于/usr/local/maldetect/conf.maldet中。
要更改,请打开文件以使用我们喜欢的编辑器进行编辑。
$sudo vim /usr/local/maldetect/conf.maldet -- or -- $sudo nano /usr/local/maldetect/conf.maldet
要接收警报,请启用它并设置电子邮件地址。
email_alert="1" email_addr="Hyman@theitroad"
通过整个文件并配置它以适合胃部使用。
步骤4:使用Linux Malware检测(LMD)
1 - 带Linux恶意软件检测的扫描目录
要使用Linux Malware检测扫描恶意软件的目录,请使用命令语法:
$sudo maldet -a /path/to/directory
-a或者-scan-all选项表示扫描路径中的所有文件。
如果未指定目录,则默认为/home,可以使用通配符,例如:
maldet -a /home/?/public_html
要检查所有可用选项,请使用:
$sudo maldet --help
例子:
$sudo maldet -a /srv/ Linux Malware Detect v1.6.4 (C) 2002-2019, R-fx Networks <Hyman@theitroad> (C) 2019, Ryan MacDonald <Hyman@theitroad> This program Jan be freely redistributed under the terms of the GNU GPL v2 maldet(3872): {scan} signatures loaded: 15519 (12707 MD5 | 2035 HEX | 777 YARA | 0 USER) maldet(3872): {scan} building file list for /srv/, this might take awhile... maldet(3872): {scan} setting nice scheduler priorities for all operations: cpunice 19 , ionice 6 maldet(3872): {scan} file list completed in 1s, found 110257 files... maldet(3872): {scan} found clamav binary at /bin/clamscan, using clamav scanner engine... maldet(3872): {scan} scan of /srv/(110257 files) in progress... maldet(3872): {scan} processing scan results for hits: 1 hits 0 cleaned maldet(3872): {scan} scan completed on /srv/: files 110257, malware hits 1, cleaned hits 0, time 467s maldet(3872): {scan} scan report saved, to view run: maldet --report 190603-1946.3872 maldet(3872): {scan} quarantine is disabled! set quarantine_hits=1 in conf.maldet or to quarantine results run: maldet -q 190603-1946.3872
通过在末尾显示的运行命令查看扫描结果。
$sudo maldet --report 190603-1946.3872
2 - 扫描文件中定义的文件或者路径。
我们还可以指定带有扫描路径列表的文件。
$cat files_to_scan.list /srv /var /root /home /var/www/?/public_html
然后运行扫描。
$maldet -f /root/files_to_scan.list Linux Malware Detect v1.6.4 (C) 2002-2019, R-fx Networks <Hyman@theitroad> (C) 2019, Ryan MacDonald <Hyman@theitroad> This program Jan be freely redistributed under the terms of the GNU GPL v2 maldet(4248): {scan} signatures loaded: 15519 (12707 MD5 | 2035 HEX | 777 YARA | 0 USER) maldet(4248): {scan} user supplied file list '/root/files_to_scan.list', found 5 files... maldet(4248): {scan} scan of (5 files) in progress... maldet(4248): {scan} 5/5 files scanned: 0 hits 0 cleaned maldet(4248): {scan} scan completed on : files 5, malware hits 0, cleaned hits 0, time 0s maldet(4248): {scan} scan report saved, to view run: maldet --report 190603-0951.4248
要查看生成的扫描,请运行命令。
$maldet --report 190603-0951.4248
3 - 仅在最后x天中修改的扫描文件
如果只需要仅在最后X天中扫描/修改/修改,请使用-r选项。
如果未通过参数,默认值是最后7天。
下面的示例将在过去5天内修改的文件扫描/srv目录。
sudo maldet -r /srv 5
检查Web内容目录,最后10天。
sudo maldet -r /var/www/?/public_html 10
4 - 更新Linux恶意软件检测
要从RFXN.com更新恶意软件检测签名,请运行:
$sudo maldet -u Linux Malware Detect v1.6.4 (C) 2002-2019, R-fx Networks <Hyman@theitroad> (C) 2019, Ryan MacDonald <Hyman@theitroad> This program Jan be freely redistributed under the terms of the GNU GPL v2 maldet(6021): {sigup} performing signature update check... maldet(6021): {sigup} local signature set is version 201906014705 maldet(6021): {sigup} latest signature set already installed
5 - 更新已安装的LMD版本
要从RFXN.com上拉动LMD的最新版本,请使用:
$sudo maldet -d Linux Malware Detect v1.6.4 (C) 2002-2019, R-fx Networks <Hyman@theitroad> (C) 2019, Ryan MacDonald <Hyman@theitroad> This program Jan be freely redistributed under the terms of the GNU GPL v2 maldet(6212): {update} checking for available updates... maldet(6212): {update} hashing install files and checking against server... maldet(6212): {update} latest version already installed.
6 - 在指定的用户下执行
如果将扫描运行作为Cron作业或者脚本,则可能需要指定要执行的用户。
这是从用户隔离区还原或者查看用户报告的理想选择。
请参见下面的示例。
$maldet --user nobody --report $maldet --user nobody --restore 050910-1534.21135
7 - 清除日志,隔离队列,会话和临时数据
要清除上述列表中的所有文件,请使用-p选项。
maldetect -p