Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

© 2026 Fun with Learning TechnologyRSS
Home›Courses›cyber security›How would you respond to a ransomware attack on a corporate network?

Interview Prep

How would you respond to a ransomware attack on a corporate network?

Ransomware is malicious software that encrypts corporate assets, demanding payment for decryption keys or the prevention of data exposure. Responding effectively is critical to business continuity, data integrity, and minimizing financial and reputational damage. This structured response framework is utilized immediately upon the detection of widespread encryption activity to isolate threats and begin recovery.

Phase 1: Immediate Containment and Network Isolation

The primary objective upon identifying ransomware is to halt the lateral movement of the malware and prevent further encryption of files. You must isolate infected segments of the network immediately. This is effective because ransomware often relies on network shares or domain-wide service accounts to propagate. By severing network connectivity, you force the malware into a vacuum where it cannot reach additional command-and-control servers or discover new targets. However, you must avoid simply powering off machines immediately, as this destroys volatile memory that is crucial for forensics and potential key recovery. Instead, isolate at the switch or firewall level to maintain persistence while stopping the propagation. This containment is the most high-stakes phase, as improper isolation can lead to data loss or trigger self-destruct mechanisms within some modern ransomware variants.

# Script to isolate an infected host using local firewall rules
import subprocess

def isolate_host(ip_address):
    # Block all incoming and outgoing traffic to isolate the host
    # This prevents the malware from communicating with C2 servers
    subprocess.run(['iptables', '-A', 'INPUT', '-s', ip_address, '-j', 'DROP'])
    subprocess.run(['iptables', '-A', 'OUTPUT', '-d', ip_address, '-j', 'DROP'])
    print(f"Host {ip_address} has been isolated.")

isolate_host('192.168.1.50')

Phase 2: Identification and Forensic Analysis

Once the initial spread is halted, you must determine the scope and nature of the infection. Analysis involves identifying the specific strain of ransomware, the entry point, and the extent of data compromise. Understanding the specific encryption method is vital because it determines whether a public decryption tool exists or if you are dealing with a known threat actor with a track record. You look for indicators of compromise (IoCs), such as malicious hashes, unique file extensions, or specific registry modifications. Analyzing memory dumps at this stage can reveal encryption keys still stored in RAM before they are wiped. The reasoning here is to gather intelligence that informs your recovery strategy; if you identify the malware early, you can correlate it with known vulnerabilities, allowing you to patch the entry point before re-enabling services.

# Basic artifact collector to identify ransomware entry
import os

def scan_for_ioc(file_path):
    # Checking for known ransom note patterns or suspicious extensions
    known_ext = ['.locked', '.encrypted', '.crypted']
    if os.path.exists(file_path):
        for ext in known_ext:
            if file_path.endswith(ext):
                return True
    return False

# Check a target directory
print(scan_for_ioc('/home/user/documents/report.pdf.locked'))

Phase 3: Secure Backups and Data Integrity Validation

Recovery relies entirely on the integrity of your offline or immutable backups. You must verify that your backups were not also encrypted by the ransomware, as modern attacks specifically hunt for network-attached backup storage to encrypt those as well. Validation involves checksumming critical data from the last known clean state to ensure no corruption has occurred. This works because having a verified restore point allows you to bypass the need for decryption keys entirely. If the backups are intact, the business can restore services without paying the ransom. You must also ensure that the restore environment is sanitized; if you restore data onto a network that still has the original vulnerability, you risk immediate reinfection. Validating data integrity before restoration prevents the disastrous scenario of restoring already-infected files back into production.

# Verification of file integrity using hashes
import hashlib

def verify_backup(file_path, expected_hash):
    sha256 = hashlib.sha256()
    with open(file_path, 'rb') as f:
        while chunk := f.read(8192):
            sha256.update(chunk)
    # Compare actual hash with original to ensure no tampering
    return sha256.hexdigest() == expected_hash

# Validate backup integrity
print(verify_backup('backup_01.tar', 'e3b0c44298fc1c149afbf4c8996fb924'))

Phase 4: Eradication and System Restoration

Eradication involves the wholesale removal of infected elements. This is not just about deleting the malware files, but identifying and removing persistent scheduled tasks, malicious service accounts, and unauthorized backdoors created by the attacker. You must rebuild affected systems from trusted, hardened base images to ensure no hidden payloads remain. This is the only way to guarantee a clean slate, as simply deleting files may leave deep-system hooks behind. The restoration process follows a prioritized list: critical infrastructure (like identity management and core databases) must come online before general user machines. By systematically rebuilding in a secure VLAN, you verify the health of the system before exposing it to the wider corporate network. This rigorous approach prevents the re-entry of the threat actor and cleans the environment of lingering malicious components.

# Secure cleanup script to remove persistent malicious services
import subprocess

def remove_malicious_service(service_name):
    # Stopping and deleting unauthorized system services
    subprocess.run(['systemctl', 'stop', service_name])
    subprocess.run(['systemctl', 'disable', service_name])
    print(f"Service {service_name} has been eradicated.")

remove_malicious_service('malicious_win_update')

Phase 5: Post-Incident Review and Hardening

The final phase is the post-incident review, where you evaluate the incident response process to find weaknesses in your defense. This is essential for long-term survival because an attacker who has breached your network once knows exactly where to look for future gaps. You must implement stronger controls based on your findings, such as multi-factor authentication, segmenting critical data, and enforcing the principle of least privilege. You also need to rotate all credentials, as the attacker likely harvested passwords during the breach. By documenting the incident and updating your response playbooks, you turn a catastrophic event into a learning opportunity that makes future ransomware attempts much less likely to succeed. This proactive hardening ensures the attack was not in vain, effectively closing the gaps that allowed the initial intrusion.

# Policy enforcement script to reset compromised user passwords
import subprocess

def rotate_credentials(username):
    # Enforce a mandatory password reset for an account
    subprocess.run(['passwd', '-e', username])
    print(f"Credentials reset initiated for user: {username}")

rotate_credentials('admin_user_01')

Key points

  • Always prioritize network isolation to stop the spread of encryption.
  • Do not power off infected machines until volatile memory is captured for forensic analysis.
  • Verify the integrity of backups before restoration to ensure they are not compromised.
  • Identify the specific strain of ransomware to determine if existing decryption keys are available.
  • Rebuild infected systems from verified, clean images rather than attempting to clean individual files.
  • Rotate all credentials across the infrastructure because attackers likely captured them during the breach.
  • Implement network segmentation to limit the reach of future ransomware attempts.
  • Conduct a post-incident review to identify the entry point and harden security controls against recurrence.

Common mistakes

  • Mistake: Immediately paying the ransom. Why it's wrong: Payment does not guarantee decryption and funds criminal activity. Fix: Consult with legal, law enforcement, and incident response experts before considering any negotiations.
  • Mistake: Restarting affected systems to 'fix' the glitch. Why it's wrong: Reboots can wipe volatile memory (RAM) which contains critical forensic evidence. Fix: Isolate the machines from the network while keeping them powered on for forensic capture.
  • Mistake: Trying to manually delete encrypted files. Why it's wrong: This causes data loss and does not remove the threat actor's persistence. Fix: Follow a structured incident response plan to ensure root cause analysis and eradication.
  • Mistake: Communicating through insecure channels. Why it's wrong: Threat actors may monitor internal email, tipping them off that a response is underway. Fix: Use out-of-band communication, such as encrypted messaging apps or physical meetings.
  • Mistake: Ignoring backups without verifying their integrity. Why it's wrong: The ransomware might have already encrypted or corrupted existing backups. Fix: Regularly test offline, immutable backups to ensure they are clean and restorable.

Interview questions

What is the very first step you would take upon confirming a ransomware infection on a corporate network?

The absolute first step is isolation to prevent lateral movement. I would immediately disconnect the affected host or network segment from the internet and the internal LAN. By severing the network connection, we stop the malware from communicating with its command-and-control server and prevent it from spreading to other critical assets. I would use a command like 'ipconfig /release' or physically unplug the Ethernet cable to ensure the containment is immediate while maintaining the system's power state for potential forensic memory analysis.

Why is it critical to preserve the infected system's state before attempting any remediation or recovery?

Preserving the state is critical because the infected system serves as the primary source of evidence for incident response. If you reboot or wipe the machine, you destroy volatile data held in RAM, such as encryption keys, running processes, and active network connections. By creating a disk image and performing a memory dump first, we can identify the specific strain of ransomware and determine the attack vector. This evidence allows the security team to perform root cause analysis and ensure that the vulnerability exploited is patched so the attack cannot simply recur.

Explain the difference between a sector-level backup restoration and a file-level restoration in the context of ransomware.

A file-level restoration involves selectively restoring individual documents or directories that were encrypted. This is often faster but poses a risk if the ransomware payload or a backdoor remains dormant in a system file. A sector-level backup restoration replaces the entire partition or disk image to a known-good state. This is much more secure because it effectively wipes out the ransomware binary, registry persistence, and any malicious scripts. I prefer sector-level restores for ransomware recovery because they guarantee the system is returned to a clean, verified state before the network connection is restored.

Compare the approach of paying the ransom versus rebuilding systems from offline backups. What are the security and operational implications?

Paying the ransom is dangerous because it provides no guarantee of decryption and marks the company as a lucrative target for future attacks, while also potentially violating legal sanctions. Rebuilding from offline, immutable backups is the gold standard for operational recovery. While rebuilding takes significantly longer and involves downtime, it ensures data integrity and eliminates the threat entirely. I always advocate for the 'Backup and Rebuild' approach because it reinforces organizational resilience and prevents the moral hazard associated with funding criminal enterprises, which eventually leads to better long-term security posture.

How would you handle the incident communication process during an ongoing ransomware attack?

Communication must be strictly governed by the incident response plan to avoid panic or unauthorized disclosure. I would immediately alert the CISO and the legal department to establish attorney-client privilege regarding the investigation. I would utilize an out-of-band communication channel, such as an encrypted messaging platform, because we must assume the primary corporate email system is compromised. Externally, I would work with PR and legal to draft statements that are transparent but do not disclose technical vulnerabilities that could be exploited by other malicious actors during the recovery window.

Post-recovery, what specific security controls should be implemented to prevent a ransomware recurrence?

Post-recovery requires a defense-in-depth upgrade. I would enforce the principle of least privilege by auditing Active Directory groups to remove excessive administrative rights that ransomware often exploits to escalate privileges. I would implement an Endpoint Detection and Response (EDR) solution to monitor for behavioral indicators of compromise, such as mass file renaming or unauthorized volume shadow copy deletion. Finally, I would script a routine to monitor and alert on suspicious PowerShell execution, specifically looking for obfuscated scripts, which are commonly used in the later stages of a ransomware payload delivery.

All cyber security interview questions →

Check yourself

1. What is the primary reason to isolate an infected machine immediately upon detecting ransomware?

  • A.To prevent the ransomware from spreading to other network segments via SMB or other protocols
  • B.To signal to the attacker that the incident response team has arrived
  • C.To automatically clear the encryption keys stored in the system registry
  • D.To force the ransomware process to uninstall itself from the device
Show answer

A. To prevent the ransomware from spreading to other network segments via SMB or other protocols
Isolating infected hosts prevents lateral movement. Option 1 is wrong because attackers do not uninstall based on network status. Option 2 is wrong because isolation is a defensive move, not a communication tactic. Option 3 is wrong because isolation does not affect registry keys.

2. Which action should be prioritized when preserving evidence before recovery?

  • A.Running the built-in operating system disk cleanup tool
  • B.Capturing a full forensic image and volatile memory dump
  • C.Deleting temporary files to gain more storage space for backups
  • D.Performing a factory reset on all affected hardware
Show answer

B. Capturing a full forensic image and volatile memory dump
Forensic images and memory dumps are vital for understanding the attack vector. Options 1, 3, and 4 destroy evidence, making it impossible to perform a proper post-mortem analysis.

3. Why is it recommended to perform a thorough root cause analysis before restoring from backups?

  • A.To ensure the attackers are impressed by the IT team's speed
  • B.To ensure the backup software is updated to the latest version
  • C.To verify that the vulnerability used for the initial entry is patched
  • D.To calculate the total financial cost of the downtime for insurance
Show answer

C. To verify that the vulnerability used for the initial entry is patched
If the entry point (e.g., an unpatched VPN) remains open, the attackers will simply re-encrypt the restored data. The other options do not address the security risk of re-infection.

4. If your organization decides to engage with an incident response firm, what is their primary objective?

  • A.To pay the ransom on behalf of the company to save time
  • B.To provide a guarantee that the data will be decrypted within 24 hours
  • C.To facilitate containment, investigation, and secure recovery
  • D.To legally blame employees for the initial infection
Show answer

C. To facilitate containment, investigation, and secure recovery
Professional firms specialize in methodical eradication and recovery. They do not guarantee decryption or act as insurance proxies, and they do not focus on blame.

5. When developing a communication plan for a ransomware attack, why is secrecy often prioritized in the early stages?

  • A.To prevent employees from updating their social media profiles
  • B.To avoid tipping off the threat actor that their presence has been discovered
  • C.To keep the IT department's performance metrics private
  • D.To ensure shareholders do not question the company's cybersecurity budget
Show answer

B. To avoid tipping off the threat actor that their presence has been discovered
Threat actors often maintain persistence; if they realize they are being hunted, they may execute 'scorched earth' tactics to destroy more data. The other options are irrelevant to incident security.

Take the full cyber security quiz →

← PreviousDescribe the difference between symmetric and asymmetric encryption.Next →What are the OWASP Top 10 vulnerabilities, and how can they be mitigated?

cyber security

34 lessons, free to read.

All lessons →

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app