Communitygithub.com

Linux 持久化机制分析

扫描 Linux 系统的持久化机制,包括 crontab/systemd 条目、LD_PRELOAD 注入、Shell 配置文件修改(.bashrc、.profile)以及 SSH authorized_keys 后门,并将发现与 auditd 日志关联,形成安装时间线。在事件响应或威胁狩猎中使用,以检测或确认攻击者如何在受感染的 Linux 主机上维持访问。

Linux 持久化机制分析 是什么?

该技能旨在帮助安全分析师在事件响应或威胁狩猎过程中,系统性地扫描 Linux 系统中常见的攻击者持久化机制。它支持检测 crontab 作业、systemd 服务/定时器单元、LD_PRELOAD 库注入、Shell 配置文件(如 .bashrc 和 .profile)的篡改、SSH authorized_keys 后门以及 init 脚本操纵。该技能通过检查文件时间戳和完整性来验证发现,并与 auditd 日志关联,构建出持久化机制安装的时间线。它适用于 root 或 sudo 访问权限的实时系统或取证镜像,需要 Python 3.8+ 环境,并可选的 OSSEC/Wazuh 集成。最终输出包含风险评分、MITRE ATT&CK 映射以及可执行的修复命令,帮助分析人员快速评估威胁并采取行动。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-persistence-mechanisms-in-linux

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

分析 Linux 中的持久化机制

概述

攻击者通过 crontab 作业、systemd 服务/定时器单元、LD_PRELOAD 库注入、Shell 配置文件修改(.bashrc、.profile)、SSH authorized_keys 后门以及 init 脚本操纵来在 Linux 系统上建立持久化。该技能扫描所有已知的持久化向量,检查文件时间戳和完整性,并将发现与 auditd 日志关联,以构建持久化安装的时间线。

使用时机

  • 当调查安全事件需要分析 Linux 中的持久化机制时
  • 当为此领域构建检测规则或威胁狩猎查询时
  • 当 SOC 分析师需要此类分析的结构化流程时
  • 当需要验证相关攻击技术的安全监控覆盖范围时

前置条件

  • 目标 Linux 系统的 root 或 sudo 访问权限(或取证镜像)
  • 配置了持久化路径文件监视规则的 auditd
  • Python 3.8+ 以及标准库(os、subprocess、json)
  • 可选:用于文件完整性监控告警的 OSSEC/Wazuh 代理

步骤

  1. 扫描 Crontab 条目 — 枚举所有用户的 crontab、/etc/cron.d/、/etc/cron.daily/ 和 anacron 作业,查找可疑命令
  2. 审计 Systemd 单元 — 检查 /etc/systemd/system/ 和 ~/.config/systemd/user/ 中非包管理的服务和定时器单元
  3. 检测 LD_PRELOAD 劫持 — 检查 /etc/ld.so.preload 和 LD_PRELOAD 环境变量中注入的共享库
  4. 检查 Shell 配置文件 — 扫描 .bashrc、.bash_profile、.profile、/etc/profile.d/ 中注入的命令或反向 Shell
  5. 检查 SSH 授权密钥 — 审计所有 authorized_keys 文件中的未授权公钥及其命令限制
  6. 关联 Auditd 日志 — 搜索 auditd 日志中持久化路径上的文件修改事件,构建安装时间线
  7. 生成持久化报告 — 生成包含所有发现持久化机制的风险评分报告

预期输出

  • 所有发现的持久化机制及风险评分的 JSON 报告
  • 从 auditd 关联得到的持久化安装时间线
  • MITRE ATT&CK 技术映射(T1053、T1543、T1574、T1546)
  • 每个检测到的持久化机制的修复命令

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

相关技能