0Pricing
Cloud & IT Cert Prep · Lesson

Rootkits, Spyware, and Keyloggers

Discover how rootkits hide malware from the OS, how spyware silently exfiltrates data, and how keyloggers capture credentials in real time.

Rootkits, Spyware, and Keyloggers is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Stealth Malware: Hiding in Plain Sight

While many malware types announce their presence through visible damage, a class of malicious software is specifically designed to remain hidden from users, administrators, and security tools while silently accomplishing attacker goals. Rootkits, spyware, and keyloggers represent the stealth end of the malware spectrum. Their effectiveness depends on persistence without detection — they may remain active for months or years, quietly exfiltrating credentials and data. Understanding their hiding techniques is essential for forensic investigation and for selecting detection tools that can find what standard scans miss.

Rootkits: Subverting the OS Itself

A rootkit modifies the operating system or low-level software to hide the attacker's presence. The term comes from Unix 'root' (highest privilege) + 'kit' (set of tools). Rootkits intercept OS functions to hide files, registry keys, processes, and network connections from standard system inspection tools. A process running a rootkit might not appear in Task Manager, its network connections won't show in netstat, and its files won't appear in directory listings — because all these tools query the OS through the same APIs the rootkit has compromised. Rootkits are extremely difficult to detect from within the infected OS.

# 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 Types by Location

Rootkits are classified by where they operate in the system. User-mode (application-level) rootkits run in user space and hook API calls; they are the easiest to detect and remove. Kernel-mode rootkits operate with OS-level privileges, modifying kernel data structures — they are highly stealthy and require a driver or kernel exploit to install. Bootkit (MBR rootkit) infects the Master Boot Record or Volume Boot Record, loading before the OS — invisible to the OS during operation. Hypervisor rootkits (VM-based) sit below the OS, running the original OS as a virtual machine — theoretically undetectable from within the guest.

# 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

Detecting Rootkits

Because rootkits compromise the OS's own reporting mechanisms, detection requires looking from outside the infected OS. Techniques include: cross-view analysis (comparing kernel data structures directly in memory against what APIs report — discrepancies reveal hidden items), integrity verification (comparing hashes of critical system files against known-good baselines from a trusted source), offline scanning (booting from a clean USB and scanning the drive), and Secure Boot with TPM attestation (cryptographically verifying the boot chain has not been modified). Tools include GMER, Malwarebytes Anti-Rootkit, and chkrootkit/rkhunter for Linux.

# 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: Silent Data Exfiltration

Spyware secretly monitors user activity and transmits information to the attacker without the user's knowledge or consent. It may capture browsing history, search queries, screenshots, application usage, and location data. Some spyware is commercially marketed as 'monitoring software' for parental control or employee monitoring (though legality varies by jurisdiction). Malicious spyware is used by criminals and nation-states to silently exfiltrate sensitive business data, personal information, and intellectual property. Spyware often bundles with free software (PUPs — Potentially Unwanted Programs), making the source hard to identify.

# 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 and Commercial Spyware

Stalkerware is spyware designed to covertly monitor intimate partners, marketed to abusers as partner surveillance tools. It captures location, calls, texts, and social media. Commercial spyware (like NSO Group's Pegasus, Candiru, and FinFisher) is sold to governments and law enforcement agencies — often targeting journalists, activists, and dissidents. Pegasus exploited zero-click iPhone vulnerabilities to install with no user interaction. The Coalition Against Stalkerware and security researchers have worked to add stalkerware detection to mainstream AV products. Detection often requires forensic analysis of the device with tools like Amnesty International's Mobile Verification Toolkit (MVT).

Keyloggers: Capturing Every Keystroke

A keylogger records every keystroke the user types, capturing passwords, messages, credit card numbers, and any other typed data. Software keyloggers operate at different levels: user-mode hooks (SetWindowsHookEx API), kernel-mode drivers (more stealthy), or form-grabbing hooks that intercept browser form submissions before encryption. Hardware keyloggers are physical devices plugged between the keyboard and computer — completely invisible to software-based detection. They store keystrokes in internal memory for later retrieval. Organizations protecting high-security areas should inspect hardware ports regularly for unauthorized devices.

# 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)

Form Grabbers and Browser Credential Theft

Form grabbers intercept data submitted in browser forms before it is encrypted and sent over the network — capturing usernames, passwords, and credit card numbers at the point of entry. Zeus (Zbot), a notorious banking Trojan, used form-grabbing hooks injected into browser processes. Unlike network-level sniffers that are blocked by HTTPS, form grabbers operate at the application level, making encryption irrelevant. They typically hook browser functions like InternetReadFile or inject into the browser process memory. Modern EDR tools detect process injection and browser API hooking patterns indicative of form-grabber activity.

# 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 and PUPs

Adware displays unwanted advertisements and may redirect browser traffic to generate revenue for its operators. While less destructive than other malware, adware degrades system performance, compromises privacy, and creates security risks by redirecting to malicious sites or bundling with more dangerous software. PUPs (Potentially Unwanted Programs) are software that users may not have intentionally installed, often bundled with free software through deceptive installation dialogs. PUPs occupy a gray area — they may not be strictly malicious, but they consume resources, compromise privacy, and create a pathway for more dangerous infections.

# 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 Dumping and LSASS

Once malware is installed with sufficient privileges, credential dumping extracts stored credentials from memory or disk for lateral movement. The Windows LSASS process stores credentials in memory for single sign-on. Tools like Mimikatz dump plaintext passwords or NTLM hashes from LSASS memory. Defenders counter this with Credential Guard (Windows 10+, uses Virtualization-Based Security to isolate LSASS in a secure container), Protected Users group membership (prevents credential caching), and EDR rules that alert on LSASS memory access from non-system processes.

# 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

Removing Rootkits and Persistent Threats

Attempting to remove a rootkit from a running system is risky — the rootkit actively hides itself and may detect removal attempts. Best practice for rootkit remediation is to reimage the system from a trusted baseline after forensic evidence preservation. If full reimaging is not immediately possible: boot from a trusted external medium (USB with offline scanner), run rootkit detection tools before the OS loads, document all artifacts, and plan for reimaging at the earliest opportunity. For bootkits, use Secure Boot with UEFI to prevent unsigned bootloaders, and consider writing zeros to the MBR before OS reinstallation.

# 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

Quick Check

Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.

Lesson Recap

In this lesson you learned: rootkits subvert OS APIs to hide processes, files, and network connections, making detection from within the infected OS unreliable — requiring offline scanning or cross-view analysis, spyware and keyloggers silently exfiltrate credentials and data with behavioral indicators detectable through network monitoring and EDR process inspection, and credential dumping tools like Mimikatz targeting LSASS are mitigated by Windows Credential Guard and Protected Users group policies. Next up we explore fileless malware and living-off-the-land attacks.

Frequently asked questions

Is the “Rootkits, Spyware, and Keyloggers” lesson free?

Yes — the full text of “Rootkits, Spyware, and Keyloggers” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Rootkits, Spyware, and Keyloggers”?

Discover how rootkits hide malware from the OS, how spyware silently exfiltrates data, and how keyloggers capture credentials in real time. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Rootkits, Spyware, and Keyloggers” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Viruses, Worms, and Trojans
  2. Ransomware and Cryptolockers
  3. Rootkits, Spyware, and Keyloggers
  4. Fileless Malware and Living-off-the-Land Attacks
← Back to Cloud & IT Cert Prep