Shell 配置创建或修改

编辑

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

规则类型: eql

规则索引:

  • logs-endpoint.events.file*

严重性: 中

风险评分: 47

运行频率: 5 分钟

搜索索引时间范围: now-9m (Date Math 格式, 另请参阅 额外的回溯时间)

每次执行的最大告警数量: 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(端点检测和响应)”作为配置设置,它提供“所有事件;所有预防措施”
  • 在“新代理策略名称”中输入代理策略的名称。如果已存在其他代理策略,则可以单击“现有主机”选项卡并选择现有策略。有关 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