Shell 配置文件创建或修改

编辑

此规则监控 Shell 配置文件的创建/更改。Unix 系统使用 Shell 配置文件来设置环境变量、创建别名和自定义用户环境。攻击者可能会修改或添加 Shell 配置文件以执行恶意代码并在系统中获得持久性。此行为与 Kaiji 恶意软件家族一致。

规则类型: eql

规则索引:

  • logs-endpoint.events.file*

严重性: 中等

风险评分: 47

运行频率: 5 分钟

搜索索引时间范围: now-9m (日期数学格式,另见 附加回溯时间)

每次执行的最大告警数: 100

参考资料:

标签:

  • 领域:端点
  • 操作系统:Linux
  • 用例:威胁检测
  • 战术:持久性
  • 数据源:Elastic Defend

版本: 5

规则作者:

  • Elastic

规则许可证: Elastic License v2

设置

编辑

设置

此规则需要来自 Elastic Defend 的数据。

Elastic Defend 集成设置

Elastic Defend 通过 Fleet 集成到 Elastic Agent 中。配置后,集成允许 Elastic Agent 监控主机上的事件并将数据发送到 Elastic Security 应用。

先决条件

  • Elastic Defend 需要 Fleet。
  • 要配置 Fleet Server,请参阅文档

为了在 Linux 系统上添加 Elastic Defend 集成,应按顺序执行以下步骤

  • 转到 Kibana 首页并点击“添加集成”。
  • 在查询栏中,搜索“Elastic Defend”并选择集成以查看更多详细信息。
  • 点击“添加 Elastic Defend”。
  • 配置集成名称,并可选择添加说明。
  • 选择要保护的环境类型,“传统端点”或“云工作负载”。
  • 选择配置预设。每个预设都带有 Elastic Agent 的不同默认设置,您可以稍后通过配置 Elastic Defend 集成策略进一步自定义这些设置。辅助指南
  • 我们建议选择“完整 EDR(端点检测和响应)”作为配置设置,它提供“所有事件;所有预防措施”。
  • 在“新的 Agent 策略名称”中输入 Agent 策略的名称。如果其他 Agent 策略已存在,您可以点击“现有主机”选项卡并选择现有策略。有关 Elastic Agent 配置设置的更多详细信息,请参阅辅助指南
  • 点击“保存并继续”。
  • 要完成集成,请选择“将 Elastic Agent 添加到您的主机”,然后继续到下一部分,在您的主机上安装 Elastic Agent。有关 Elastic Defend 的更多详细信息,请参阅辅助指南

规则查询

编辑
file where host.os.type == "linux" and event.action in ("rename", "creation") and file.path : (
  // system-wide configurations
  "/etc/profile", "/etc/profile.d/*", "/etc/bash.bashrc", "/etc/bash.bash_logout", "/etc/zsh/*",
  "/etc/csh.cshrc", "/etc/csh.login", "/etc/fish/config.fish", "/etc/ksh.kshrc",
  // root and user configurations
  "/home/*/.profile", "/home/*/.bashrc", "/home/*/.bash_login", "/home/*/.bash_logout", "/home/*/.bash_profile",
  "/root/.profile", "/root/.bashrc", "/root/.bash_login", "/root/.bash_logout", "/root/.bash_profile",
  "/home/*/.zprofile", "/home/*/.zshrc", "/root/.zprofile", "/root/.zshrc",
  "/home/*/.cshrc", "/home/*/.login", "/home/*/.logout", "/root/.cshrc", "/root/.login", "/root/.logout",
  "/home/*/.config/fish/config.fish", "/root/.config/fish/config.fish",
  "/home/*/.kshrc", "/root/.kshrc"
) and not (
  process.executable in (
    "/bin/dpkg", "/usr/bin/dpkg", "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf",
    "/usr/bin/microdnf", "/bin/rpm", "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum",
    "/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
    "/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
    "/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
    "/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
    "/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*",  "/usr/bin/pamac-daemon",
    "/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/sbin/adduser", "/usr/sbin/useradd", "/usr/local/bin/dockerd",
    "/usr/sbin/gdm", "/usr/bin/unzip", "/usr/bin/gnome-shell", "/sbin/mkhomedir_helper", "/usr/sbin/sshd",
    "/opt/puppetlabs/puppet/bin/ruby", "/usr/bin/xfce4-session", "/usr/libexec/oddjob/mkhomedir", "/sbin/useradd",
    "/usr/lib/systemd/systemd", "/usr/sbin/crond", "/usr/bin/pamac-daemon", "/usr/sbin/mkhomedir_helper",
    "/opt/pbis/sbin/lwsmd", "/usr/sbin/oddjobd"
  ) or
  file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
  file.Ext.original.extension == "dpkg-new" or
  process.executable : (
    "/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*",
    "/usr/libexec/platform-python*"
  ) or
  process.executable == null or
  process.name in ("adclient", "mkhomedir_helper", "teleport", "mkhomedir", "adduser", "desktopDaemon") or
  (process.name == "sed" and file.name : "sed*") or
  (process.name == "perl" and file.name : "e2scrub_all.tmp*")
)

框架: MITRE ATT&CKTM