0Pricing
Security+ Academy · 课时

Rootkit、间谍软件与键盘记录器

了解 Rootkit 如何将恶意软件隐藏在 OS 中、间谍软件如何悄悄窃取数据,以及键盘记录器如何实时捕获凭据。

Rootkit、间谍软件与键盘记录器 是 CoddyKit 上的免费 Security+ Academy 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Security+ Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Security+ Academy 课程共包含 4 节课。

隐蔽 Malware:藏身于众目睽睽之下

许多 Malware 类型会通过明显的破坏来暴露自身,而有一类恶意软件则专门设计为在用户、管理员和安全工具面前保持隐藏,同时悄悄完成攻击者的目标。Rootkit、Spyware 和键盘记录器代表了 Malware 光谱中最隐蔽的一端。它们的有效性取决于在不被 Detection 的情况下保持持久性——它们可能活跃数月甚至数年,悄悄窃取凭据和数据。了解它们的隐藏技术,对于取证调查以及选择能够发现标准扫描遗漏内容的 Detection 工具至关重要。

Rootkit:颠覆 OS 本身

Rootkit会修改操作系统或低级 Software,以隐藏攻击者的存在。这个术语来自 Unix 的“root”(最高权限)和“kit”(工具集)。Rootkit 会拦截 OS 功能,使文件、Registry keys、Processes 和 Network connections 不被标准系统检查工具发现。运行 Rootkit 的进程可能不会出现在 Task Manager 中,其 Network connections 不会显示在 netstat 中,其 file 也不会出现在目录列表中——因为所有这些工具都通过 Rootkit 已经入侵的相同 API 查询 OS。要从受感染的 OS 内部 Detection Rootkit 极其困难。

# What rootkits hide:
# - Malicious processes from task manager / ps
# - Files and directories from file system listings
# - Registry keys from regedit
# - Network connections from netstat/ss
# - Kernel modules from lsmod
# - Loaded DLLs from process listings

# Why standard tools fail:
# Task Manager calls NtQuerySystemInformation() -> rootkit intercepts
# Rootkit patches return value to exclude hidden process

按位置划分的 Rootkit 类型

Rootkit 按其在系统中的运行位置分类。用户模式(应用层)Rootkit运行在用户空间并 Hook API 调用;它们最容易 Detection 和 Removal。内核模式 Rootkit以 OS 级别权限运行,修改内核数据结构——它们高度隐蔽,并需要驱动程序或内核 Exploit 才能安装。Bootkit(MBR Rootkit)会感染 Master Boot Record 或 Volume Boot Record,在 OS 之前加载——运行期间对 OS 不可见。Hypervisor Rootkit(基于 VM)位于 OS 下方,将原始 OS 作为 Virtual machine 运行——从理论上说,在 guest 内部无法 Detection。

# Rootkit detection approaches by type:
# User-mode:   Standard AV + process hollowing detection
# Kernel-mode: Rootkit scanners that compare in-memory data
#              with on-disk data (GMER, RootkitRevealer)
# Bootkit:     Boot-time scan from trusted environment
#              Secure Boot with UEFI TPM attestation
# Hypervisor:  Hardware-based integrity measurement

# Best removal approach for all types:
# Boot from trusted external media
# Image the drive for forensics, then reimage the system

Detection Rootkit

由于 Rootkit 会入侵 OS 自身的报告机制,Detection 必须从受感染 OS 的外部进行。相关技术包括:Cross-view analysis(直接比较内存中的内核数据结构与 API 报告的内容——差异可以揭示隐藏项目);完整性 Verify(将关键系统 file 的哈希值与来自可信来源的已知良好基线进行比较);离线扫描(从干净的 USB 启动并扫描驱动器);以及Secure Boot 与 TPM 证明(通过加密方式 Verify 启动链未被修改)。工具包括 GMER、Malwarebytes Anti-Rootkit,以及适用于 Linux 的 chkrootkit/rkhunter。

# Linux rootkit detection:
rkhunter --check --skip-keypress
chkrootkit

# Cross-view analysis concept:
# Hidden process detection:
# Walk the kernel EPROCESS list directly (avoids API hooks)
# Compare to what NtQuerySystemInformation() returns
# Processes in EPROCESS but not in API list = hidden (rootkit)

# Verify critical file hashes:
aids --check  # Advanced Intrusion Detection Environment
trip          # Tripwire IDS

Spyware:无声窃取数据

Spyware会秘密监控用户活动,并在用户不知情或未同意的情况下向攻击者传输信息。它可能捕获浏览历史、搜索查询、屏幕截图、应用使用情况和位置数据。一些 Spyware 以“监控 Software”的形式商业销售,用于家长控制或员工监控(但其合法性因司法管辖区而异)。犯罪分子和民族国家会利用恶意 Spyware,悄悄窃取敏感业务数据、个人信息和知识产权。Spyware 经常与免费 Software 捆绑(PUPs——Potentially Unwanted Programs),因此很难确定其来源。

# Spyware behavioral indicators:
# - Unusual outbound network connections (data exfiltration)
# - Increased CPU/disk usage with no obvious cause
# - Browser settings changed (homepage, search engine)
# - New browser toolbars or extensions installed
# - Device battery drains faster (mobile spyware)
# - Slow system performance due to background monitoring

# Anti-spyware scanning:
# Malwarebytes, Windows Defender, HitmanPro
# Check browser extensions: remove unknown extensions

Stalkerware 与商业 Spyware

Stalkerware是一种用于秘密监控亲密伴侣的 Spyware,面向施虐者销售,作为伴侣监控工具。它会捕获位置、通话、短信和社交媒体信息。商业 Spyware(例如 NSO Group 的 Pegasus、Candiru 和 FinFisher)会出售给政府和执法机构,其目标往往是记者、活动人士和异议人士。Pegasus 利用 iPhone 的零点击漏洞,无需用户交互即可安装。反 Stalkerware 联盟和安全研究人员一直致力于将 Stalkerware Detection 加入主流 AV 产品。Detection 通常需要使用 Amnesty International 的 Mobile Verification Toolkit(MVT)等工具对 Device 进行取证分析。

键盘记录器:捕获每一次按键

键盘记录器会记录用户输入的每一次按键,捕获 Password、消息、信用卡号码以及其他所有输入的数据。Software 键盘记录器可在不同层级运行:用户模式 Hook(SetWindowsHookEx API)、内核模式驱动程序(更隐蔽),或在加密前拦截浏览器表单提交的表单抓取 Hook。Hardware 键盘记录器是插在键盘与 Computer 之间的 Physical Device,对基于 Software 的 Detection 完全不可见。它们会将按键记录存储在内部 memory 中,供之后提取。保护高安全区域的组织应定期检查 Hardware port,寻找未经授权的 Device。

# Software keylogger installation vector:
# Trojan download -> installs keylogger driver
# Malicious browser extension -> captures form input
# Office macro -> drops and registers keylogger DLL

# Hardware keylogger detection:
# Physical inspection of keyboard port (USB/PS/2)
# Common types: PS/2 inline, USB inline, USB hub type
# Acoustic side-channel (listening to keystrokes) - exotic

# Defense against software keyloggers:
# Two-factor authentication (keylogged password + OTP)
# Password manager auto-fill (bypasses keyboard input)
# Virtual on-screen keyboard for sensitive systems (limited protection)

表单抓取器与浏览器凭据窃取

表单抓取器会在浏览器表单提交的数据被加密并通过 Network 发送之前拦截这些数据——在输入点捕获 Usernames、Passwords 和信用卡号码。臭名昭著的银行 Trojan Zeus(Zbot)曾使用注入浏览器 Processes 的表单抓取 Hook。与会被 HTTPS 阻挡的 Network 层嗅探器不同,表单抓取器在应用层运行,因此加密对其不起作用。它们通常会 Hook 浏览器的 InternetReadFile 等功能,或注入浏览器进程的 memory。现代 EDR 工具能够 Detection 进程注入和浏览器 API Hook 模式,这些模式表明可能存在表单抓取活动。

# Form grabber detection indicators:
# - Browser process loading unexpected DLLs
# - API hooks in browser memory (InternetReadFile, PR_Write)
# - Unusual child processes spawned by browser
# - Outbound connections from browser process to unknown IPs

# Defense:
# EDR with browser protection (e.g., Cisco AMP, CrowdStrike)
# Isolated browser environment (VMware Browser Isolation)
# MFA: even if credentials captured, OTP prevents reuse

Adware 与 PUPs

Adware会显示不需要的广告,并可能将浏览器流量重定向,以为其操作者创造收入。虽然 Adware 的破坏性低于其他 Malware,但它会降低系统性能、损害隐私,并通过将用户重定向到恶意网站或与更危险的 Software 捆绑而造成安全风险。PUPs(Potentially Unwanted Programs)是用户可能并未有意安装的 Software,通常通过具有欺骗性的安装对话框与免费 Software 捆绑。PUPs 处于灰色地带——它们未必严格意义上属于恶意软件,但会占用资源、损害隐私,并为更危险的感染创造途径。

# PUP/Adware prevention:
# During software installation:
# - Choose 'Custom' not 'Express' installation
# - Uncheck pre-selected bundled software offers
# - Read each screen carefully before clicking Next

# Removal:
# Malwarebytes Anti-Malware (good PUP detection)
# ADWCleaner (Malwarebytes tool for adware)
# Check installed programs list for unwanted additions
# Check browser extensions for unknown additions

Credential 转储与 LSASS

恶意软件以足够的权限安装后,Credential 转储会从内存或磁盘中提取已存储的凭据,以便进行横向移动。Windows 的 LSASS 进程会将凭据存储在内存中,以实现单点登录。Mimikatz 等工具可以从 LSASS 内存中转储明文密码或 NTLM 哈希。防御方可以采取以下措施进行防护:使用Credential Guard(Windows 10 及更高版本,利用基于 Virtualization 的 Security 将 LSASS 隔离在安全容器中)、将用户加入受保护用户组(防止凭据缓存),以及配置 EDR 规则,在非系统进程访问 LSASS 内存时发出 Alert。

# Credential dump detection:
# Alert on: processes accessing LSASS memory (non-system)
# Alert on: procdump.exe targeting lsass.exe
# Alert on: sekurlsa::logonpasswords in memory artifacts

# Windows Credential Guard (prevents Mimikatz from LSASS):
# LSASS runs in Isolated User Mode (VSM)
# Mimikatz dumps show only encrypted blobs, not plaintext

# Enable Credential Guard:
# gpedit: Computer Config -> Admin Templates -> System -> Device Guard
# 'Turn On Virtualization Based Security' = Enabled

移除 Rootkits 与持久性威胁

尝试从正在运行的系统中移除 Rootkit 是有风险的——Rootkit 会主动隐藏自身,并且可能检测到移除尝试。Rootkit 修复的 Best 做法是在保留取证证据后,根据可信基线重新创建系统映像。如果暂时无法进行完整的系统映像重建,请从可信的外部介质启动(使用包含离线 Scanner 的 USB),在 OS 加载前运行 Rootkit Detection 工具,记录所有工件,并尽早安排系统映像重建。对于 Bootkit,请结合 UEFI 使用安全启动,以阻止未签名的引导加载程序;在重新安装 OS 前,还可以考虑向 MBR 写入零。

# Bootkit removal:
# Boot to Windows Recovery Environment (WinRE)
# Repair boot record:
bootrec /fixmbr
bootrec /fixboot
bootrec /rebuildbcd

# For Linux MBR repair:
dd if=/dev/zero of=/dev/sda bs=512 count=1  # wipe MBR
grub-install /dev/sda                        # reinstall GRUB

# Best practice: full reimage after forensic image captured

快速检查

测试您对本课 CompTIA Security+ (SY0-701) 概念的理解。

课程回顾

本课中您学习了以下内容:Rootkits会篡改 OS API,以隐藏进程、文件和网络连接,因此从受感染 OS 内部进行 Detection 并不可靠——需要进行离线 Scanning 或跨视图分析;间谍软件和键盘记录器会在不被察觉的情况下窃取凭据和数据,其行为特征可以通过网络监控和 EDR 进程检查来检测;针对 LSASS 的Credential 转储工具(如 Mimikatz)可以通过 Windows Credential Guard 和 Protected Users 组 Policy 加以缓解。接下来我们将学习无文件恶意软件和 Living-off-the-land 攻击。

常见问题解答

「Rootkit、间谍软件与键盘记录器」课时是免费的吗?

是的 — 「Rootkit、间谍软件与键盘记录器」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Security+ Academy 课程的其余内容,请升级到 CoddyKit PRO。 Security+ Academy 课程共包含 4 节课。

「Rootkit、间谍软件与键盘记录器」这节课中我会学到什么?

了解 Rootkit 如何将恶意软件隐藏在 OS 中、间谍软件如何悄悄窃取数据,以及键盘记录器如何实时捕获凭据。 你通过在浏览器中直接运行的动手代码来练习 Security+ Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Security+ Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Security+ Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。

「Rootkit、间谍软件与键盘记录器」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Security+ Academy 课中编写并运行代码吗?

能。每节 Security+ Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 病毒、蠕虫与木马
  2. 勒索软件与加密锁定程序
  3. Rootkit、间谍软件与键盘记录器
  4. 无文件恶意软件与寄生式攻击
← 返回 Security+ Academy