Lecture 13 - Ransomware

Updated 28 Oct 2026

What is Ransomware?

  • Ransomware is malicious software (malware) that cyberattackers use to:
    • Take control of victims' systems
    • Encrypt and/or exfiltrate (steal) victims' sensitive and critical data
  • The perpetrators then threaten to:
    • Keep the data encrypted (i.e., inaccessible to the victim), and/or
    • Release the data to the public
  • …unless a ransom is paid, usually in an anonymous "currency" such as Bitcoin

Analogy: A burglar breaks into your house, locks every room with their own padlock, and leaves a note: "Pay me and I'll send you the keys. Don't pay, and I'll also post photos of your diary online."

Key Characteristics

  • Type of malware
  • Encrypts / locks files
  • Holds files for ransom
  • Can affect:
    • PC
    • "Internet of Things" (IoT) devices
    • Removable media (USB, external drives)
    • Devices on the network

Types of Ransomware

  • Locker ransomware
    • Blocks access to computer systems entirely
    • Uses social engineering techniques and compromised credentials to infiltrate systems
    • Example: infects PCs and locks the user's files, preventing access to data and files on the PC until a ransom or "fines" are paid
  • Crypto ransomware
    • More common and widespread than locker ransomware
    • Encrypts all or some files on a computer and demands a ransom in exchange for a decryption key
    • Some newer variants also infect shared, networked, and cloud drives
    • Spreads through various means: malicious emails, websites, and downloads
  • Double extortion ransomware
    • Encrypts files AND exports (steals) data to blackmail victims into paying
    • Attackers threaten to publish stolen data if demands are not met
    • Even if the victim restores from backup, the attacker still has power over them
    • Paying does not guarantee data protection either — attackers still have the stolen copy
  • RaaS (Ransomware-as-a-Service)
    • Perpetrators rent access to a ransomware strain from its author, who offers it as a pay-for-use service
    • RaaS creators host their ransomware on dark net sites and let criminals buy it as a subscription

Analogy:

  • Locker = changing the locks on your front door (you can't get into the house at all).
  • Crypto = scrambling all your documents into gibberish (house is open, but everything inside is unreadable).
  • Double extortion = scrambling your documents and photocopying them first so they can leak them.
  • RaaS = a "burglary kit" sold on a subscription, like Netflix for criminals.

How Do I Get Ransomware?

  • Spam & phishing emails
  • On the web (malicious ads & P2P / peer-to-peer downloads)
  • Unpatched security vulnerabilities

How Prevalent Is It?

Prevalent = widespread, มีอยู่ทั่วไป, usual

  • The average cost of ransomware attacks escalated to 2.73millionin2024∗∗ —anincreaseofnearly ∗∗2.73 million in 2024** — an increase of nearly **1 million (50%) in one year
  • Half of all ransomware attacks in 2023 happened in the United States
  • Hackers earned roughly $1.1 billion from crypto-related ransomware attacks in 2023 — a new record
  • Up to 94% of organizations attacked in 2023 said hackers attempted to compromise their backups
  • LockBit was responsible for around 25% of all ransomware attacks in 2023, with 1,047 victims that year
  • Double extortion ransomware surged in 2023, with a 72% increase from Q1 to Q2
  • The central government sector has the highest attack rate as of 2024 — up to 68% of surveyed central government organizations globally reported an attack

Source: https://www.safetydetectives.com/blog/ransomware-attack-trends-research/


Recognizing Malware: Phishing Emails

  • Example screenshot: a fake "Microsoft account – Unusual sign-in activity" email
    • Shows "sign-in details": Country/region Romania, IP address 827.8.797.52, date
    • Button: "Please check out document for further instructions."
    • Signed "The Microsoft account team"
  • Numbered red flags in the slide:
    1. Sender / header — claims to be "Microsoft account" (impersonation of a trusted brand)
    2. Suspicious call-to-action button — "check out document" (likely leads to malware/attachment)
    3. Urgency / fear message — "a malicious user might have your password"
  • Extra clue: the IP address 827.8.797.52 is invalid (each IPv4 octet must be 00–255255) → the email is fake

Analogy: It's like a "police officer" knocking on your door with a badge made of cardboard — the uniform looks right, but the details (like an impossible IP) give it away.


Encrypt What?

  • Usually user data files — so the system still operates normally (victim can still see the ransom note and pay)
    • Microsoft Office files (.doc, .docx, .xls, .xlsx, .ppt, .pptx, .rtf)
    • OpenOffice files (.odt, .ods, .odp)
    • Adobe PDF files
    • Popular image files (.JPG, .PNG, raw camera files, etc.)
    • Text files (.txt, .RTF, etc.)
    • Database files (.sql, .dba, .mdb, .odb, .db3, .sqlite3, etc.)
    • Compressed files (.zip, .rar, .7z, etc.)
    • Mail files (.pst)
    • Key files (.pem, .crt, etc.)
  • System files or the whole disk
    • E.g., Petya: encrypts the MBR
    • Disables booting

Analogy: Most ransomware is like a thief who locks your valuables but leaves your car running — so you can still drive to the bank and pay. Petya-style is like stealing the car keys too.


MBR (Master Boot Record)

  • The MBR is the information in the first sector of a hard disk or removable drive
  • It identifies how and where the operating system (OS) is located so it can be booted (loaded) into the computer's main storage / RAM
  • Diagram: Entire Disk = [MBR (first sector) + Partition Table] → Partitions 1, 2, 3, 4

Analogy: The MBR is the table of contents on page 1 of a book. Rip it out (or replace it with a ransom note) and the computer doesn't know where "Chapter: Windows" starts.

What Happens When Ransomware Encrypts the MBR

  • When ransomware targets the MBR (e.g., Petya, NotPetya, MBRLocker families):
    1. It overwrites the MBR with malicious code
    2. On reboot, the system executes the ransomware's fake bootloader instead of the legitimate OS loader
    3. This fake bootloader may:
      1. Display a ransom note (asking for Bitcoin payment)
      2. Start encrypting the Master File Table (MFT) or data partitions
      3. Prevent the OS from loading at all
  • Essentially, the victim sees only the ransom screen instead of Windows or Linux starting up

Ransomware Attack Using C&C for Key Management

  • Figure 1: Ransomware attack using command & control (C&C) for encryption key management

    1. Attacker → Victim: Phishing mail delivers the malware
    2. Victim → C&C server: Infected host sends host metadata
    3. C&C server → Victim: Sends encryption keys & ransom info
    • Attacker ↔ C&C server: attacker controls / manages the server

Analogy: The C&C server is the "boss's phone line." The malware on your computer calls the boss, says "I'm in, here's where I am," and the boss replies with "here's the lock to use and the ransom amount."


C&C Function

  • Ransomware uses different asymmetric and symmetric encryption techniques, e.g., RSA and AES, for generating encryption keys

  • Attackers are becoming more sophisticated and use both in combination (hybrid encryption)

  • Process:

    • An AES key is hardcoded within the payload to encrypt the files on the infected machine
    • Then an RSA public–private key pair is generated and used to encrypt the AES key
    • The private RSA key is uploaded to the C&C server
  • Hybrid encryption idea:
    Cfile=AESK(File),CK=RSAPK(K)\boxed{C_{\text{file}} = \text{AES}_{K}(\text{File}), \quad C_{K} = \text{RSA}_{PK}(K)}

  • To decrypt, the victim needs SKSK (RSA private key, held by attacker): K=RSASK(CK)K = \text{RSA}_{SK}(C_K), then File=AESK−1(Cfile)\text{File} = \text{AES}^{-1}_{K}(C_{\text{file}})

Analogy: AES is a fast padlock used on every box (file). The padlock key is then locked inside a safe (RSA). Only the attacker has the combination to the safe — so you need them to open the safe, get the padlock key, and open your boxes.


C&C: Source of Attack

  • The main use of C&C is to contact the C&C server using a domain name
    • If the domain is detected and blocked immediately, the attack can be stopped from spreading to other machines
  • Examples of C&C domains:
    • thisisyourchangeqq.com → used by TeslaCrypt
    • gvludcvhcrjwmgq.in → used by Locky
  • Ransomware connects to the C&C server using DNS queries
  • To establish the connection, DNS resolution queries are made for domains generated by the ransomware
    • These queries are captured in the DNS logs of the system
  • ⭐ By analyzing DNS logs, we can detect domains used for C&C (*****)
  • In machine learning (ML), this is a classification problem with two classes:
    • Benign DNS server
    • Malicious C&C domain server
  • Classifiers that can be used: Random Forest, Support Vector Machine (SVM), Artificial Neural Networks, etc.

Case 1: C&C Communication — Detecting Attacks through DNS

  • DNS queries provide an observable point for identifying malicious C&C domains

How C&C communication occurs

  1. Infected Host — ransomware needs to contact the attacker
  2. C&C Domain — malware uses a domain name, often generated dynamically
  3. DNS Query — host asks DNS to resolve the domain to an IP address
    • → DNS query is recorded in DNS logs
  4. C&C Server — infected host attempts to establish communication
  5. Detect / Block — DNS evidence can reveal and block malicious domains

DNS-log analysis as a classification problem

  • Input: domain-name and DNS-activity features
  • Goal: classify each observed domain
  • Models: Random Forest, SVM, Neural Networks
  • Output classes:
    • BENIGN DOMAIN — normal DNS activity
    • MALICIOUS / C&C DOMAIN — potential C&C communication
  • Key idea: Detecting and blocking a C&C domain at the DNS stage can disrupt malware communication beforefurther malicious activity occurs

Analogy: Before the malware can "call the boss," it has to look up the boss's number in the phonebook (DNS). If you're watching the phonebook lookups, you can spot the weird ones and cut the line before the call connects.


How DNS-based C&C Communication Works

  • Domain Generation Algorithm (DGA)
    • Ransomware dynamically generates domain names each day (e.g., sdke8sa1.biz, 23kd92.info)
    • Tries to resolve them via DNS; one of them will point to an attacker-controlled server
    • ⟹ Infected host does a DNS query to a domain the attacker controls, often with encoded info in the subdomain:
      • <victim-id>.<random>.attacker.com
  • The attacker's authoritative DNS server receives/records the query and returns a DNS TXT record as the answer:
    • TXT "cmd=encrypt;key=AB12CD..."
  • The malware parses the TXT string, extracts cmd and key, then executes the command
    • E.g., start encrypting files using the supplied key (often a symmetric key or a seed to derive one)

We called this DNS Tunneling

Analogy (DGA): The malware and the attacker share a secret "random word generator." Every day both generate the same list of 1,000 random addresses; the attacker only needs to rent one of them. Defenders would have to block all 1,000.


Case 2: How DNS-Based C&C Communication Works

#FinalExam, describe the process how this thing work, before the effect take place

  • Malware can use DNS not only to locate a C&C server, but also as a lightweight channel for exchanging data and commands

Flow

  1. Malware / Infected Host — a DGA may generate many candidate domains each day
  2. DNS Query — host resolves a generated domain; data may also be encoded in a subdomain
  3. Authoritative DNS — an attacker-controlled DNS server receives the query and can return a crafted response
  4. DNS Response — a TXT record (or another record type) may carry configuration or command data
  5. Malware Action — malware parses the response and performs the instructed action

Illustrative DNS exchange

  • Query example: <host-id>.<random>.example-c2.test
    • The subdomain can encode an identifier or small amount of data
  • Response example: TXT "config=<encoded-data>"
    • TXT records can carry attacker-controlled configuration or command data

Important distinction

  • DGA and DNS tunneling are related but different:
    • DGA helps malware find a reachable C&C domain
    • DNS tunneling uses DNS queries/responses to carry data

Why defenders monitor DNS

  • Repeated failed lookups
  • Algorithmic-looking domains
  • Unusual subdomains
  • Suspicious TXT activity
  • → can indicate C&C behavior
  • Key idea: DNS is an observable control point — monitoring and blocking suspicious domains can disrupt malware before successful C&C communication

DNS Tunneling: Using DNS as a Communication Channel

  • DNS tunneling abuses DNS queries and responses to carry data or commands, rather than using DNS only for domain-name resolution

How it works

  1. Infected Host — malware prepares information to send through DNS
  2. Encoded DNS Query — data is encoded inside a subdomain of an attacker-controlled domain
  3. Attacker DNS Server — the authoritative server receives the query and extracts the encoded data
  4. Encoded DNS Response — server may return configuration or command data in a DNS response

Illustrative query

  • <encoded-data>.attacker-domain.com
    • The subdomain may carry a host identifier, system information, or other encoded content

Detection clues

  • Long or random-looking subdomains
  • High / repetitive DNS-query volume
  • Unusual TXT records or high-entropy strings

DGA vs. DNS Tunneling

Purpose
DGAUses DNS to find the C&C infrastructure
DNS TunnelingUses DNS to exchange data with the attacker
  • Key idea: DNS becomes the C&C communication channel — not just a way to resolve the C&C address
  • Note: The attacker may own the authoritative DNS infrastructure; it does not necessarily need to be a compromised legitimate DNS server

Analogy: DNS tunneling is like passing secret notes by writing them as fake "addresses" on envelopes. The post office (DNS) happily delivers them because it only checks that the envelope looks like normal mail.


DNS-based C2 Attack

  • Diagram flow:
    • Infected host → Recursive DNS resolver → Attacker authoritative DNS
    • Attacker DNS returns TXT "cmd=encrypt;key=AB12CD..." back to the host
    • Malware parses TXT → Encrypt files

Recap - Steps

  1. Infected host sends a DNS query (e.g., <victim-id>.<random>.attacker.com) → to its recursive resolver (like 8.8.8.8, 1.1.1.1, or a local resolver)
  2. The recursive resolver contacts the attacker's authoritative DNS server, because it's responsible for the attacker.com zone
  3. The authoritative DNS replies to the recursive resolver with a DNS response (e.g., TXT record: "cmd=encrypt;key=AB12CD...")
  4. The recursive resolver caches that response and sends it back to the infected host
  5. The malware on the host reads the TXT field and acts on it (e.g., start encryption)

Analogy: You (infected host) ask the receptionist (recursive resolver) to "look up a phone number." The receptionist calls the attacker's office (authoritative DNS), and the attacker hides instructions inside the "phone number" answer. The receptionist innocently passes it back to you.


Why It Evades Detection

  • DNS is often allowed by default through corporate firewalls
  • Traffic looks like normal DNS requests
  • Attackers can use DNS tunneling to create bidirectional covert channels
  • In summary, the authoritative server's response flows through the resolver — it never initiates a direct connection to the victim
  • ⭐ This is why DNS-based C2 is stealthy: it blends in with normal DNS traffic

Stealthy - แอบ ๆ ซ่อน ๆ → Difficult to detect!


Detection Signals

  • Unusually long or high-entropy subdomains (encoded data or victim-id in subdomain)
    • Measure length and character entropy
    • Persistent > 60–100 character subdomains are suspicious
  • Frequent TXT record lookups or unusually large TXT responses from a host
    • Malware uses TXT to carry C2
    • Track the ratio of TXT queries vs. normal
  • Bursting query volumes to many different TLDs / many different new/unpopular domains (fast flux / DGA patterns)
  • Consistent timing pattern (daily/hourly DGA lookups at a cadence)
    • Periodicity is a giveaway → use time-series anomaly detection
  • Resolver anomalies: internal clients querying public resolvers (e.g., 8.8.8.8) when policy says to use internal resolvers
  • Endpoint correlation: DNS queries from rare processes, parent/child process anomalies, or followed quickly by file-enumeration/encryption behavior (spike in file writes)
    • Correlate EDR telemetry
  • Shannon entropy of a string (used to measure "randomness" of a domain name):

H(X)=−∑i=1np(xi)log⁡2p(xi)\boxed{H(X) = -\sum_{i=1}^{n} p(x_i)\log_2 p(x_i)}

  • p(xi)p(x_i) = frequency of character xix_i in the string
  • Normal words (e.g., google) → lower entropy; random strings (e.g., gvludcvhcrjwmgq) → higher entropy

Analogy: Entropy is a "randomness meter." Real words have patterns (lots of vowels, repeated letters); a DGA domain looks like a cat walked across a keyboard — the meter spikes.


Detection (ML / Algorithmic)

  • Machine-learning / algorithmic detection
    • Lexical DGA detection:
      • Compute domain features: length, vowel/consonant ratio, n-gram models, Shannon entropy
      • Flag high-entropy names
      • ML classifiers (Random Forest / LSTM) can be effective
    • Behavioral detection:
      • Cluster by query patterns, timing, and resolver hops
      • Separate benign services (CDNs, SaaS) from DGAs

The malware is the one who run DGA, not attacker, not C&C server, not DNS. (By Aj Ohm)


Quick Mitigation

  • Force all endpoints to use managed/internal resolvers
    • Block outbound 53/UDP and 53/TCP to the Internet except to those resolvers
    • Stops hosts from directly reaching attacker authoritative servers
  • Log and retain DNS queries and responses (including TXT answers) for at least 90 days for hunting
  • Rate-limit / alert on excessive NXDOMAINs and TXT queries per host
  • EDR rules to detect:
    • Rapid file encryption
    • Mass file rename/encryption patterns
    • Unusual process behavior
    • → Kill process or isolate host automatically on confirmed ransomware behavior
  • Honeypot DNS / honey domains
    • Configure decoy domains that should never be queried — any query is likely malicious

Analogy (honey domain): Like putting a fake "Secret Vault" door in a building that no employee has any reason to open. Anyone who tries the handle is automatically suspicious.


Sequence of Operation

  1. Connect to the C&C server
  2. Download the RSA public key unique to this computer
  3. Search for target files
  4. Generate a random AES key for each file (only in RAM)
  5. Encrypt files and delete the original files
  6. Encrypt AES keys using the RSA public key, and store them along with the encrypted file
  7. (CryptoWall 4.0) Rename all infected files
    • Makes backup/recovery difficult
  8. After finishing, open a ransom notice window
  • Takes 5 minutes to 1 hour

During Encryption

  • CPU and memory overloaded
    • Loud fan noise
  • File extensions are changed
    • .crypt, .vvv, .zepto, .fun…
  • Users cannot open encrypted files
    • If a user is working on an unencrypted file, the file gets encrypted as soon as it's saved
  • Forcefully disconnects external hard drive or USB drive
    • External drive can be infected, or physically damaged during repeated forceful ejects
  • Threatening letter appears with a timer
    • Not always

Analogy: It's like hearing someone shredding paper loudly in the next room — the noise (fan), the missing documents (renamed files), and things you just saved disappearing are all clues that it's happening right now.


Aftermath

  • Antivirus may be stopped or deleted
  • Cannot open some system programs
    • cmd, some Control Panel items, regedit, msconfig, Ctrl-Alt-Del
  • Cannot boot into Safe Mode
  • OS updates may be blocked
  • Removes Windows rollback (restore) points

Payment Process

  • Bitcoin!
    • Other cryptocurrencies (Ethereum, Litecoin, …) not used (at the time)
    • E.g., TorrentLocker displays the price based on location (local currency), payable in Bitcoin
      • Shows the exchange rate too
    • Example screenshot: "CryptoLocker — Buy decryption software" page (e.g., 500 AUD before deadline, 1000 AUD after; countdown timer)
  • Sometimes Amazon gift cards, Apple iTunes gift cards
  • SMS / call to a premium mobile number

Infected! What Now?

  1. Can you stop it now? → Do something!!!
  2. Got backup? → Restore files
  3. Recovery tools exist? → Recover files
  4. Ummm, no… → Pay ransom OR Lose the files

1. Do Something!!

  • By the time the ransom notice pops up, it is too late
  • Kill the suspicious programs
    • E.g., ransom.exe
  • Change file extensions to uninteresting extensions (e.g., .pdf → .myp) to hide them from ransomware
    • Can be done in advance as preparation
    • You can write an emergency script in advance
  • But can you stay calm enough?
    • Besides, cmd, Ctrl-Alt-Del, Process Explorer may not work

Analogy: Ransomware is a thief looking only for boxes labeled "JEWELRY" (.pdf, .docx). Relabel them "OLD SOCKS" (.myp) and it walks right past.


Delay Tactic

  • Ransomware scans files from the C:\ drive and encrypts files in alphanumeric order
    • → Keep many large junk files in C:\ (slows it down — buys time)
  • Helps detection
    • Store desktop background files in C:\
    • Reload them frequently (slideshow)
    • Image is gone after encryption → visible warning sign

Analogy: Like putting a pile of heavy decoy boxes at the front of a warehouse — the thief wastes time on them, and when the "wallpaper painting" in the lobby disappears, the guard knows someone is inside.


Emergency Measure

  • Unplug power or remove the notebook battery
  • If Safe Mode booting is possible, boot into Safe Mode
    • Remove the ransomware using AV
  • If not, mount the hard drive on another OS, copy files to a backup drive, and reinstall Windows
    • If keys and tools are available, use them to decrypt the files
  • Hard drive MBR-encryption ransomware won't allow any kind of booting, including Safe Mode
    • E.g., Petya, Mischa, GoldenEye, Santana
    • Need to recover the MBR using a Windows CD

Keeping the Encryption Key

  • The AES key is kept in memory, which will be removed after encryption
    • Freezing the memory preserves the AES keys, but shutting down destroys DRAM content
  • Solutions
    • After emergency shutdown, freeze the memory with hair spray (inverted can = very cold), and thaw later for analysis (lasts a few days easily)
    • No hair spray? Hard reset, boot into Linux, and memory dump (dd)

Analogy: RAM is like a whiteboard that fades when the power's off. Freezing it is like spraying fixative on the whiteboard so the writing (the AES key) stays readable long enough to photograph it.


2. Backup, Yes, BACKUP!

  • The most important method!!!
    • Back up multiple versions over time to recover the pre-encryption files
  • Types
    1. External hard drive — not very useful
      • Vulnerable to ransomware attack
      • Must have been disconnected while the attack occurred
    2. DVD-ROM (write-once → can't be encrypted afterward)
    3. NAS
      • Ransomware won't start within the NAS due to a different OS and lack of access rights
      • Make the SMB share read-only, upload files using SFTP
    4. Cloud service

Analogy: One backup is a spare key under the doormat — the burglar can find it. Multiple versioned, offline backups are spare keys kept at your parents' house, your bank, and your friend's place.


WannaCry & SMB

  • WannaCry ransomware attacked through SMB using a zero-day exploit called EternalBlue (slide spelling: "Ethernal Blue")
    • = Remotely execute arbitrary code and gain access to the network by sending specially crafted packets(through SMB v1)
  • Server Message Block (SMB) is a communication protocol used to share files, printers, serial ports, and miscellaneous communications between nodes on a network

Forensic Techniques

  • Recover deleted files
    • If the ransomware did not overwrite them (not CryptoWall 2.0 or later), recovery may be possible (works on TeslaCrypt)
    • Even if it did, it may not actually overwrite the same sector due to the wear-leveling algorithm on SSDs
    • DIY: use R-Studio or PhotoRec
    • Call forensic experts
      • But may be more expensive than the ransom and take longer
  • Recover Windows temporary files
    • Deleted upon finishing editing, but not the file content
  • Caution:
    • Do not continue to use the machine — it makes forensic file recovery more difficult (new writes overwrite old data)

Analogy: "Deleting" a file is like removing a book's entry from the library catalog — the book is still on the shelf until someone puts a new book in its spot. Keep using the PC and new books fill those spots.


Recover Files Using Free Tools


To Pay or Not to Pay

  • Chance of getting the key
    • Was high previously — attackers needed to build trust to encourage payment; had good "customer service"
    • Now getting lower due to more irresponsible "nomadic" attackers
  • Out of 5 who paid, 1 didn't get the key (15=20%\frac{1}{5} = 20\%)
    • Getting worse because "customer service" (troubleshooting capability) is declining as more criminals don't have programming skills

Defense in Depth

  1. Browser level
  2. Email attachments
  3. AV, anti-ransomware tools
  4. OS level
    • Least privilege
  5. Hardware level
    • Physical and logical separation
  6. Network level
    • Mapping drive
    • SIEM
  7. Awareness training and drill
  • Defense in Depth Layers (diagram, inner → outer): Data → Application → Host → Internal Network → Perimeter → Physical → Policies, Procedures, Awareness

Analogy: A medieval castle — moat, outer wall, inner wall, guards, locked keep, and the treasure in a vault. An attacker has to beat every layer, not just one.


1. Browser

  • Avoid drive-by downloads
    • Update / patch
  • Many ransomware use IE, Adobe Flash, Java
    • Don't use IE; use Edge, Chrome, or Firefox
    • Remove Adobe Flash (some vulns exist in Acrobat Reader, Silverlight, Java). Disable ActiveX. Use HTML5
    • Few ransomware use Chrome vulnerabilities
  • If you must use IE, set the security level to high
    • Most ransomware works only at lower security levels
    • IE 10/11: activate sandbox option
  • Ransomware propagates through advertisements (malvertising)
    • Block ads using ad blockers, NoScript browser add-ons

2. Email Handling

  • Be cautious about unsolicited attachments
    • Avoid clicking untrusted email links or opening attachments
  • Don't enable macros
  • Install MS Office Viewer
    • Preview mail attachments
    • Doesn't support macros at all
  • Use spam mail detection tools
    • AV / IDS / IPS / UTM / SIEM
    • Anti-phishing software

3. Anti-Virus

  • Keep updated
  • AV is not perfect!!
    • AV could detect the Angler exploit kit only 5–6% of the time
    • Use specialized tools
  • Angler = one of the leading exploit kits used by cybercriminals to distribute malware ranging from ransomwareand banking Trojans to ad fraud
    • Focused on web-based vulnerabilities in browsers and their plugins

4. OS

  • Keep updating the OS, especially security patches
  • Enable multiboot just in case, and install Linux
  • Use least privilege
    • Activate UAC (Windows 7 or above)
    • Do not stay logged in as Admin for long
    • Don't do web surfing, email, or document editing in an admin account
    • Configure access controls — including file, directory, and network share permissions — with least privilege in mind
      • Limit write access to network-mapped shares
  • Implement Software Restriction Policies (SRP) to block binaries running from:
    • %AppData%, %TEMP%, %LocalAppData%, %ProgramData%
    • Use Windows Group or Local Policy Editor
  • Use application whitelisting — only allows systems to execute programs known and permitted by security policy

Analogy (least privilege): Don't walk around with the master key to the whole building just to check your mailbox. If you get pickpocketed, the thief only gets the mailbox key.

5. Hardware

  • Air gap
    • Separate critical computers from the Internet
  • Use separate computers for risky activities
    • E.g., web surfing, email, BitTorrent
    • Implement rollback on every reboot
    • Much cheaper than ransom!
  • External hard drive
    • Connect only during backup
    • Once backed up, set it to "Read Only" (diskpart command)
  • Virtual machine (VMware, Virtual PC…)
    • Do not share the host folders

6. Network – Enterprise Level

  • Install Firewall / SIEM
    • Block proxy services (TOR, I2P)
    • Block access to known malicious IP addresses
  • Patch operating systems, software, and firmware on devices
    • Consider a centralized patch management system

7. Training

  • Employee education on:
    • Spam email, phishing
    • Drive-by downloads
  • Periodically remind them
  • Simulated attacks
    • Boost user awareness occasionally

Cyber Insurance

  • Cyber insurance lets insured parties mitigate financial losses caused by cyberattacks
    • May cover ransoms organizations need to pay
  • Ransomware insurance — beware of:
    • Time limits
    • Deductibles
    • Fees paid to cybersecurity experts

Detection & Defense

  • Monitor abnormal DNS behavior
    • Excessive NXDOMAIN responses
    • Long or random subdomains (entropy-based detection)
    • Unusual record types (TXT, NULL, oversized queries)
  • Use DNS sinkholing or filtering
    • Redirect known malicious domains to a controlled sinkhole
    • Block domains from DGAs or untrusted Top-Level Domains (TLDs)
  • Threat hunting indicators
    • DNS queries to newly registered domains
    • Encrypted or base32/base64-looking subdomains
    • Outbound DNS to uncommon resolvers (not corporate DNS)

DNS = priamry source เลย ในการที่จะให้ Attacker (C2 server) connect to Users

Analogy (sinkhole): Instead of letting the malware's "phone call" reach the boss, you reroute it to a police switchboard that just listens and records who's calling.


Example Defense Actions against DNS Query Attack

Defense LayerExample Action
DNS FirewallUse services like Quad9, Cisco Umbrella, or Pi-hole to block malicious or DGA domains
Threat Intelligence FeedsRegularly update blocklists for suspicious TLDs
Machine Learning DetectionFlag DNS queries with high entropy or newly registered domains (NRDs)
Policy ControlBlock outbound DNS to public resolvers; force all queries through internal, monitored resolvers

Cost of Ransomware

To the individual

  • Time
  • Corruption or loss of data
  • Typically < $1,000 US

To the enterprise

  • Time
  • Corruption or loss of data
  • Suspension of service
  • Reputation
  • Legal implications
  • Thousands / millions of dollars

Ransomware Victims Posted on Leak Sites (Quarter-over-Quarter)

  • Source: 2024 Q4 cyber threat report
YearQ1Q2Q3Q4
2021650667653696
2022535832696985
20238841,1491,3301,185
20241,0751,2481,2571,661
  • Trend: steadily increasing; 2024 Q4 is the highest (1,661)

Example Attacks

  • Merck (slide: "Merk") — WannaCry
  • Honda — WannaCry
  • Colonial Pipeline — DarkSide ransomware gang
  • Maersk (slide: "Mersk") — NotPetya
  • JBS — REvil / Sodinokibi group
  • Champaign-Urbana Public Health District — NetWalker
  • Image: "The Ransomware Tube Map" (F-Secure State of Cyber Security 2017) — shows the explosion of new ransomware families after CryptoLocker (2013) defined the business model

WannaCry

  • A ransomware worm that spread rapidly across many computer networks in May 2017
  • After infecting a Windows computer, it encrypts files on the hard drive, making them inaccessible, then demands a ransom in Bitcoin to decrypt them
  • The biggest ransomware attack in history
    • Affected hundreds of thousands of systems worldwide
    • Extensive damage to more than 200,000 computers across 150 countries

Analogy: A "worm" doesn't wait for you to open the door — it walks between houses on its own through an unlocked side gate (SMBv1/EternalBlue).


Top 10 Most Well-Known Ransomware Strains


Risk Mitigation Strategies

MitigationStrategies
PreventionDeterrence; Avoidance; System/data architecture
ProtectionPassword protection; Web application firewalls; Avoidance of phishing
ResponsePay ransom (insurance, out-of-pocket); Don't pay – restore systems/data from backups; Don't pay – rebuild systems/data from scratch

Risk Analysis


Application Whitelisting

  • NIST – Guide to Application Whitelisting
  • Microsoft AppLocker
    • AppLocker Overview
  • A/V and EDR
  • Windows Firewall
  • (Meme: "You shall not pass" / "I shall pass" / "You shall pass" — whitelisting decides who is allowed through)

Analogy: A whitelist is a guest list at a party. Blacklist = "these 10 troublemakers can't come." Whitelist = "only these 50 people can come, everyone else is turned away" — much safer against new, unknown troublemakers.


Ransomware Detection Techniques

  • Signature-Based Detection
    • Analyzes an application's code before execution and stops launch if suspected malicious
    • Done by extracting a code string pattern (signature) and comparing it to a repository of known malicious patterns
    • ❌ Often fails if the ransomware binary changes — the mutable nature of ransomware makes signature-only detection hard
  • Content-Based Detection
    • Detects ransomware by monitoring dynamic behaviors of applications and generated data:
      • A file type change (which necessarily follows ransomware attacks)
      • Low similarity between an original file and its modified version
      • High entropy of a modified file (encrypted data looks random)

What is the source of content-based analysis? DNS Log, Log

Limitations of Content-Based Detection

  • Must monitor large volumes of data in real time → high CPU and memory overhead cannot be avoided
  • Involves tweaks in the OS → requires privilege escalation for the monitoring software
  • Must allow the ransomware to run for a while to observe it → loss of original files is unavoidable, unless an expensive constant backup process runs

Analogy: Signature-based = a wanted poster (only catches criminals you already have photos of; a disguise defeats it). Content-based = a security guard watching behavior ("why is this person shredding every document?") — catches new criminals, but some documents are already shredded by the time they notice.


Anomaly Detection

  • Based on machine learning: KNN (K-Nearest Neighbor), SVM (Support Vector Machine), Random Forest, Decision Trees, etc. — can detect encrypted traffic to a certain extent
  • Deep learning networks widely studied for intrusion detection: MLP (Multi-Layer Perceptron), CNN, SAE(Stacked Auto-Encoder), LSTM (Long Short-Term Memory) — achieve good detection performance
  • ❌ However, deep learning relies on large amounts of data, and it's still difficult to detect unknown or variant encrypted ransomware effectively
  • GAN (Generative Adversarial Network):
    • Generator produces adversarial (pseudo) samples as real as possible
    • Discriminator tries to distinguish real vs. pseudo samples as well as possible

Analogy (GAN): A counterfeiter (generator) keeps making better fake money, while a bank teller (discriminator) keeps getting better at spotting fakes. Both improve by competing — useful for generating training data for rare attacks.


What is EDR?

  • Endpoint Detection and Response (EDR) provides multilayered, integrated endpoint protection
  • Key features:
    • Alert Triage: Analysts are overwhelmed by alerts; EDR triages potential malicious events so analysts focus where most effective
    • Threat Hunting Support: Enables an organization to identify and respond to threats not detected/blocked by other security solutions
    • Data Aggregation and Enrichment: Context is vital to tell real attacks from false positives; EDR aggregates data from multiple sources to identify true threats
    • Integrated Incident Response: Supports incident response within the same console → no context switching → faster response
    • Multiple Response Options: Different incidents need different responses; EDR should provide multiple options (quarantine, eradication, etc.)

EDR can provide response not just detect

How EDR Works

  1. Data is collected
  2. Data is filtered and analyzed
  3. Threat is detected
  4. Attack response is deployed

How EDR Works 2 (Diagram)

  • Endpoints → send data → Database / Big Data store & Machine Learning
  • Threat Actor acts on an endpoint → Behavioral data → Database / ML
  • Database / ML → Automation → Remediation
  • Database / ML → Information & context → IT Admins & Analysts
  • IT Admins & Analysts ← Real-time view of endpoint behavior
  • IT Admins & Analysts → Manual → Remediation

What Is Antivirus?

  • Antivirus solutions are designed to identify malicious software or code that has infected a computer
  • Detection methods:
    • Signature-Based Detection: identifies known threats based on signatures such as file hashes, C&C domains, IP addresses, and similar features
    • Heuristic Detection: heuristic/anomaly detection identifies malware based on unusual or malicious functionality → can catch zero-day threats that signatures miss
    • Rootkit Detection: identifies malware designed to acquire deep, administrative access
    • Real-Time Detection: identifies malware at time of use by scanning and monitoring recently accessed files
  • AV enables detection and remediation: terminating malicious processes, quarantining suspicious files, and eradicating infections

Rootkit is a malware that perform on a very low (system, OS) level!
Rootkit can also be implemented in hardware.
We can detect tampering: hashing, signature. แต่ถ้าต้องมาเช็คตลอดก็ต้อง trade-off กับ verification time

what kind of technique of antivirus used that can be detect zero day → Sandboxing
Sandboxing: test environment


Why AV Is Not Enough?

  • AV is designed to identify malware on a computer, but threat actors are increasingly sophisticated
  • Traditional signature-based detection is no longer effective against modern malware due to:
    • Rapid evolution of malware
    • Use of unique malware and infrastructure per campaign
  • EDR integrates a range of security functions, enabling it to detect trends and other indicators of a successful incursion
  • EDR's response capabilities let analysts act more quickly, limiting the impact of an attack

Analogy: AV is a smoke detector — it beeps when it recognizes smoke. EDR is a full security control room with cameras, recordings, and a team that can lock doors remotely.


Comparison Between EDR and Antivirus

AspectAVEDR (Endpoint Detection & Response)
PurposeProtects endpoints from known malwareusing signatures and heuristicsDetects, investigates, and responds to advanced or unknown threats using behavioral analysis
Detection ApproachSignature-based and heuristic — matches files against known threat databasesBehavioral and analytics-based — monitors process, memory, and network behaviors in real time
Data CollectionMinimal logs (focused on infected files)Continuous telemetry — processes, registry, network, and user activities
Threat ScopeKnown malware (viruses, trojans, worms, ransomware)Zero-day, fileless malware, APTs, lateral movement, insider threats
Response ActionsAutomatic quarantine or delete malicious filesIsolate endpoint, kill process, roll back system, collect forensics, notify SOC
VisibilityLocal endpoint onlyEnterprise-wide — integrated view across all endpoints
IntegrationStandalone endpoint protection softwareIntegrates with SIEM/SOAR and threat intelligence feeds
Machine Learning UsageLimited (pattern recognition)Extensive (behavior scoring, anomaly detection)
Administrator RoleMinimal — auto-protection and updatesActive — security analysts investigate, hunt
  • Flow at bottom: Antivirus → detects known (signature/heuristic) → EDR: real-time monitoring, behavioral analytics

Backups, DR and BC

  • You need to have a plan
    • Not a backup plan! A preemptive plan
  • Do you have a Business Continuity Plan (BCP)?
    • Ready.gov BCP
  • Document, Implement, Test, and Repeat
    • IBM – Planning a backup and recovery strategy checklist
  • Don't assume anything!!
    • Who is responsible for ensuring your backups are working? You are!
  • Tabletop exercises are great for identifying failure points where backups can save you
    • 9 Steps to an Effective Tabletop BCP Test

Multifactor Authentication (MFA)

  • Use MFA/2FA for external validation
    • VPN
    • Email
    • Cloud services
    • Password managers
  • Try to avoid SMS-based systems (SIM swapping, interception)
    • Secure token even better (e.g., Yubico / YubiKey)
  • Whenever possible, require a second authentication with a physical/app token
    • CISA.gov – Supplementing Passwords

Analogy: A password is your house key. MFA adds a fingerprint scanner too — a thief who copies your key still can't get in.


Patch Management & Vulnerability Scanning

  • Attack surface reduction
    • Don't make it easy for an attacker
  • Keep an eye on current vulnerabilities and patches needed to mitigate
    • Cisco Talos Intel Blog
    • FireEye Threat Research Blog
    • Palo Alto Unit 42 Threat Research
  • Develop a patch management strategy
    • A Practical Methodology for Implementing a Patch Management Process
    • Creating a Patch and Vulnerability Management Program

Email Security and DNSSEC

  • Attachment filtering
  • DMARC — Domain-based Message Authentication, Reporting & Conformance
  • DKIM — DomainKeys Identified Mail
  • SPF — Sender Policy Framework
  • DNSSEC — DNS Security Extensions

DMARC, SPF, DKIM

  • DMARC is an email authentication, policy, and reporting protocol
    • Builds on SPF and DKIM
    • Adds:
      • Linkage to the author ("From:") domain name
      • Published policies for how recipients handle authentication failures
      • Reporting from receivers back to senders
    • Goal: improve and monitor protection of the domain from fraudulent email
  • SPF allows email senders to define which IP addresses are allowed to send mail for a particular domain
  • DKIM is a signature-based email authentication technique
    • Result of merging DomainKeys and Identified Internet Mail specifications
    • Works by adding a digital signature to email headers
    • Signature is validated against a public cryptographic key in the organization's DNS record

Singature - sign MD + private key → digital signature

What are DMARC, DKIM, and SPF?

  • Three email authentication methods; together they help prevent spammers, phishers, and unauthorized parties from sending emails on behalf of a domain they don't own
  • DKIM and SPF ≈ a business license or a doctor's degree on the office wall — they demonstrate legitimacy
  • DMARC tells mail servers what to do when DKIM or SPF fail:
    • Mark as spam, deliver anyway, or drop the email
  • Domains without correct SPF, DKIM, and DMARC:
    • Emails may get quarantined as spam or not delivered
    • At risk of spammers impersonating them

DKIM vs DMARC

  • In a nutshell: DKIM attempts to verify whether mail is legitimate, and DMARC suggests what to do with mail that isn't

Analogy:

  • SPF = a guest list of which mail trucks (IPs) are allowed to deliver for your company.
  • DKIM = a wax seal on the letter proving it wasn't tampered with and came from you.
  • DMARC = the instructions to the mailroom: "If the truck isn't on the list or the seal is broken, throw it away / put it aside — and send me a report."

How DMARC Works (Diagram 1)

  • Sender publishes DMARC record to its DNS server
  • Sending email server → sends email → Receiving email server
  • Receiving server checks (using sender's DNS):
    1. Check SPF
    2. Check DKIM
    3. Check DMARC
  • Outcome based on DMARC policy:
    • ✅ Accept validated email → Inbox
    • ❌ Reject
    • ⚠️ Quarantine
  • Receiving server sends reports back to the sender

How Does DMARC Work? (Diagram 2)

  • Sender side:
    1. Author composes & sends email
    2. Sending mail server inserts DKIM header
    3. Email sent to receiver
  • Receiver side:
    1. Standard validation tests (IP blocklists, reputation, rate limits, etc.)
    2. Validate and apply sender DMARC policy:
      • Retrieve verified DKIM domains
      • Retrieve "Envelope From" via SPF
      • Apply appropriate DMARC policy
    3. Result: Passed → standard processing (anti-spam filters, etc.) → user; Quarantine; or Reject (🚫)
    4. Failure report sent to sender; periodic aggregate report updated and sent to sender

It's Bound to Happen

  • Example ransom notes:
    • RobbinHood ransomware note — "What happened to your files?"; demands payment within 4 days, price increases $10,000 per day after; warns not to shut down, not to rename files, not to contact FBI; files encrypted with RSA
    • Generic "YOUR FILES ARE ENCRYPTED" note — instructs victim to use Tor Browser to reach the payment address, warns not to rename files or use third-party decryptors

Quote

  • "Until you have experienced something like this, you don't realize just what can happen, just how serious it can be. I had no intuitive idea on how to move forward."
    • — Maersk CEO Søren Skou (after NotPetya)

Incident Response Lifecycle

  • NIST SP 800-61 — Computer Security Incident Handling Guide
  • Four-phase approach to incident handling:
    1. Preparation
    2. Detection and Analysis
    3. Containment, Eradication, and Recovery
    4. Post-Incident Activity
  • Some activities in different phases may happen simultaneously
  • Frameworks are also available from other organizations, such as SANS

Analogy: Like a fire department: (1) train and buy equipment, (2) notice the smoke and figure out where it is, (3) put out the fire and rebuild, (4) investigate the cause and update the fire code.


Preparation Phase

  • Being prepared to respond to an incident is critical
  • Prepare plans for common types of cyber incidents
  • Impossible to prepare for every type of attack
  • Incidents not properly responded to can lead to ransomware
  • "Failing to prepare = prepare to fail"

Preparation Steps

  1. Form an incident response team (CSIRT)
  2. Create playbooks and checklists
  3. Conduct disaster recovery exercises to test backup efficacy
  4. Exercise your Incident Response plans regularly

Preparation Checklists

  • Non-technical
    • Plan communication methods
    • Update call trees / on-call rotations
    • Network diagrams
    • System documentation
    • Temporary "War Room"
    • CSIRT member list
    • Keep offline copies of all of these!
  • Technical
    • Incident reporting software
    • Forensic workstations
    • Laptops
    • Forensics software
    • Adapters, cables, tools
    • Networking equipment
    • Blank removable media
    • Clean OS images

Additional Preparations

  • Be prepared to speak with the media, regulatory bodies, and law enforcement
  • Consider retaining an Incident Response company/service
  • Cyber insurance companies can also assist with response
  • Federal, State, or Local law enforcement may also help

Detection

  • Several ways to become aware of a ransomware incident:
    • End-user reported issue
    • Ransom notes
    • AV / EDR or SIEM tool alerts
    • Threat intelligence or law enforcement notifications
  • Malware operators often sell access to networks
    • Seeing these advertisements can help prevent further action
  • Once a ransomware event is confirmed, consider contacting law enforcement, a retained IR company, or cyber insurance

Analysis

  • Identifying the type of malware helps understand how it will behave and what response is recommended
  • Determine the entire scope of infection
  • The initial infection vector must be identified to prevent re-infection
  • Sometimes other malware is the initial entry point
  • An MSP (Managed Service Provider) can also be an infection vector
  • Identify whether data exfiltration has occurred

Containment

  • If caught early, containing the infection greatly reduces overall impact
  • Isolate infected systems in a coordinated manner
  • Use out-of-band communications — the attacker may be monitoring email or other online communication
  • Consider taking file shares or even the entire network offline
  • Consider taking remote entry points (e.g., VPNs) offline until contained

With vs. Without EDR

With EDRWithout EDR
Use network contain functionality to isolate systemsRemove infected devices from the network
Disable execution of known ransomware binariesIf network containment is impossible, hibernate or power offsystems
Gather forensic informationGather forensic information

Analogy: Containment is closing the fire doors so the fire stays in one room. Out-of-band comms = don't discuss your escape plan over the building intercom the arsonist is listening to.


Eradication

  • Reset passwords on any compromised accounts
  • Remove any emails with malware from all user mailboxes
  • Re-install operating systems on infected systems from trusted sources
  • Reset passwords on any affected system
  • Consider organization-wide password resets
  • Remove any persistence mechanisms
  • Remove malware implants (Metasploit, Cobalt Strike, etc.)
  • EDR tools can make this easier
  • Patch vulnerabilities on internet-facing systems

Recovery

  • Restore data from backup, starting with most critical systems
  • If restore is impossible, attempt to obtain decryption keys — law enforcement or fusion centers sometimes have them
  • If possible, do NOT pay the ransom
  • Certain scenarios may force payment (e.g., hospital with lives at risk, company survival uncertain)
  • Paying does not guarantee recovery of your data
  • Negotiate the payment — there are even services to assist with this
  • Another option: just lose the data if it is not mission critical

Post-Incident Activities

  • Notification of data breach
  • Other regulatory reporting requirements
  • Lessons learned in response activities and general security practices
  • Update technical controls and processes to prevent future occurrences
  • Share indicators of compromise (IOCs) with law enforcement and fusion centers (ISACs, CISA, etc.)
  • Share other lessons learned to benefit the community

Preventing Ransomware Infections

  • Avoid suspicious file attachments & links
  • Say no to executables, scripts, macros
  • Browse carefully
  • Keep software up-to-date

Back It Up!

  • Back up files regularly
  • Keep redundant backups if possible
  • Disconnect backups when not in use

Should You Pay the Ransom?

  • Paying ransom is risky
  • No guarantees
  • Files may still be corrupted
  • May leave other malware behind
  • ⭐ Prevention is the best cure

Related Resources


Questions?