Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 53 ยท Systems and Post-Exploitation Concepts

Malware Types and Social Engineering Defense

Learn the main malware families, how phishing and pretexting work, how SPF, DKIM and DMARC protect email, and how to analyze malware safely in a lab.

Technical defenses are strong when they work, but attackers know that the easiest component to compromise is often a person. Social engineering manipulates people into doing something that helps the attacker: opening an attachment, sharing a password, approving a payment. Malware is the software that is frequently delivered that way, and its goal is to run code the victim never intended to run.

This lesson names the malware families so you can recognize the vocabulary, explains the common social engineering tricks and the defenses that work, and describes how email authentication blocks forgery. It does not teach how to write malware, and it shows no malicious code. Analysis of suspicious files belongs in an isolated lab. The runnable parts are Python stand-ins that score made-up phishing emails and check made-up email authentication results.

Malware families

Virus and worm Spread by files or by themselves.
Ransomware Encrypts data and demands payment.
Spyware Watches and steals information.
Trojan and RAT Pretends to be useful, gives remote control.

The categories overlap; one sample can do several jobs.

1 / 2

Malware families

Malware is any software designed to do harm or act against the user's interest. Names describe behavior, and real samples often combine several:

  • Virus: attaches itself to files or programs and spreads when they are shared or run.
  • Worm: spreads by itself across networks, usually through a vulnerability or weak credentials, with no human action needed.
  • Trojan: looks like something useful (a game, an invoice, a cracked program) but contains a hidden payload.
  • Ransomware: encrypts files, often after stealing a copy, and demands payment. Modern campaigns include data theft as a second threat.
  • Spyware and infostealers: collect passwords, browser data, keystrokes and files.
  • Remote access trojan (RAT) and backdoors: give an attacker ongoing control. See Persistence, Lateral Movement and Detection.
  • Rootkits: hide malware from the operating system and from tools.
  • Botnet clients: turn the machine into a node used for spam, fraud or denial-of-service attacks.
  • Fileless malware: runs in memory or abuses built-in tools instead of dropping a new executable, which makes simple file scanning less effective.
  • Adware and unwanted programs: less destructive but still a nuisance and a risk.

Typical delivery

Malware usually arrives through a few routes: phishing attachments and links, malicious or trojanized downloads, drive-by downloads that exploit an unpatched browser, infected removable media, compromised software updates (a supply-chain attack), and stolen credentials on exposed services.

Defenses that cover most of it

  • Keep systems and applications patched, so drive-by exploits fail.
  • Endpoint protection with behavior detection, not only signature matching.
  • Least privilege: ordinary users cannot install system-wide software (Privilege Escalation Concepts and OS Hardening).
  • Application allow-listing and blocking macros from the internet.
  • Offline, tested backups: the best answer to ransomware is being able to restore. Backups that are always connected can be encrypted too.
  • Network segmentation and egress filtering, which limit spread and stop malware from contacting its controllers.
  • Email and web filtering and MFA on all accounts.

Social engineering

Social engineering does not exploit code; it exploits human habits. Common forms:

  • Phishing: mass messages that imitate a trusted brand or colleague and push you to click a link, open a file or enter credentials on a fake page.
  • Spear phishing: the same, aimed at one person using details found online. Whaling targets executives.
  • Business email compromise: an attacker poses as a manager or supplier to redirect a payment or request sensitive data. No malware is needed.
  • Smishing and vishing: phishing over text messages and phone calls.
  • Pretexting: inventing a believable scenario ("I'm from IT and need to verify your account") to obtain information.
  • Baiting: leaving something tempting, such as an infected USB drive, or offering a free download.
  • Tailgating: following an authorized person through a secured door.

Look at the "levers" slide again. Almost every attack uses urgency, authority, fear or reward, because those emotions make people skip the checks they would normally do.

What actually reduces the risk

  1. Awareness training that is short, frequent and blame-free. The aim is to report suspicious messages quickly, not to punish clicks. A "report phishing" button and a fast response from the security team matter more than a perfect score.
  2. Verification habits. Confirm unusual requests, especially for money or credentials, using a different channel such as a known phone number.
  3. MFA, ideally phishing-resistant methods such as security keys or passkeys, so a stolen password alone does not give access.
  4. Process controls. Payments to new bank details need a second approver. Password resets require identity checks. Visitors are escorted.
  5. Technical filtering of attachments, links and look-alike domains.

Authorized phishing simulations are a normal part of security programs, but they need written approval, a clear scope and care for employees. Never run one against people or an organization without permission.

Email authentication: SPF, DKIM and DMARC

Plain email lets anyone write any "From" address. Three DNS-based standards make forgery much harder, and domain owners should set up all three.

  • SPF (Sender Policy Framework): a DNS record that lists the servers allowed to send mail for the domain. A receiver checks whether the connecting server is on the list.
  • DKIM (DomainKeys Identified Mail): the sending server signs selected parts of the message with a private key; the receiver fetches the public key from DNS and verifies that the signature is valid and the message was not altered.
  • DMARC: ties the two to the visible "From" domain and tells receivers what to do when checks fail (none to monitor, quarantine, or reject), plus where to send reports. It requires that SPF or DKIM pass and align with the From domain.

A read-only example of the DNS records involved (the domain is reserved for documentation):

TEXT
example.com.            TXT  "v=spf1 ip4:203.0.113.10 include:mail.example.net -all"
sel1._domainkey.example.com. TXT  "v=DKIM1; k=rsa; p=<public key>"
_dmarc.example.com.     TXT  "v=DMARC1; p=reject; rua=mailto:[email protected]"

A good rollout starts DMARC at p=none to read the reports and find legitimate senders you forgot, then moves to quarantine and reject. These records stop attackers from sending mail that pretends to be your exact domain. They do not stop look-alike domains (examp1e.com) or messages from a genuine but compromised account, so training and filtering are still needed. See Passive Reconnaissance and OSINT for how DNS records like these are read.

Safe malware analysis

Analysts study suspicious files to understand them and write detections. Real malware must never be examined on a normal computer. The safe principles:

  • Work in an isolated lab: a virtual machine with no connection to your real network, with snapshots to restore, as described in Building a Safe Home Lab.
  • Never run an unknown file on your everyday machine. Start with static analysis: hashes, strings, file type and metadata. Hashes can be looked up in public reputation services without opening the file.
  • Only use dynamic analysis (running the sample) in a disposable environment, with network access either blocked or simulated.
  • Handle samples with care, label them, and delete them securely afterwards. Possession of live malware may be restricted by your employer or local rules, so follow policy.
  • For learning, use publicly provided, intentionally harmless test files, such as the standard antivirus test string, and training exercises on legal practice platforms.

Stand-in: score sample phishing emails

This program is a toy phishing scorer. It reads made-up emails and adds points for typical warning signs. A real mail filter uses far more signals, machine learning and reputation data; the point here is to show how clues combine into a score and why no single clue is enough.

Python Stand-in: phishing email scorer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real filters tune scores against large collections of known good and bad mail. Even here you can see the weakness of a rule-based approach: an attacker who removes every keyword scores zero, which is why people and process controls remain essential.

Stand-in: check email authentication results

A mail server records the result of each check in the message headers. This stand-in reads made-up results and applies a simplified DMARC decision: the message passes only when SPF or DKIM passes and the domain aligns with the visible From address.

Python Stand-in: simplified DMARC decision

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Message 2 shows why alignment matters: SPF passed for a different domain (the bulk sender), so it does not prove the mail came from example.com. The fix is to have the bulk sender sign with DKIM using your domain.

Malware scanning limits, riskware and countermeasures

Scanners give quick answers, but free tools have limits: fewer detection layers, no behavior blocking, slower signature updates and sometimes upsells. Good scanners also tell threat types apart (virus, trojan, adware, riskware) and provide a clear interface so users can respond. Riskware is legitimate software that creates risk when misused. Countermeasures: keep systems patched, use application allow-listing, filter email, restrict admin rights, keep offline backups and enable two-factor authentication so a stolen password alone is useless.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which description fits ransomware?

    Ransomware locks files, often after copying them too. Tested offline backups are the strongest recovery defense.
  2. 2. What is the most useful reaction to a suspicious email at work?

    Reporting quickly helps the security team protect everyone. Clicking, replying or forwarding can spread the problem.
  3. 3. What does DMARC add on top of SPF and DKIM?

    DMARC requires a passing, aligned SPF or DKIM result and tells receivers whether to monitor, quarantine or reject failures.
  4. 4. Where should a suspicious unknown file be analyzed?

    Malware must never run on machines connected to real data or networks. Use a snapshot-capable VM with the network blocked, and start with static analysis.
  5. 5. Which defense does NOT stop a look-alike domain such as examp1e.com?

    Your records protect your exact domain. A look-alike is a different domain the attacker controls, so other defenses must catch it.

Summary

  • Malware families (viruses, worms, trojans, ransomware, spyware, RATs, rootkits, botnets, fileless) are defined by behavior and often combine.
  • Social engineering exploits urgency, authority, fear, reward and trust; it includes phishing, spear phishing, business email compromise, pretexting, baiting and tailgating.
  • The best defenses combine patching, least privilege, tested offline backups, filtering, MFA (preferably phishing-resistant), verification habits and blame-free reporting.
  • SPF, DKIM and DMARC protect your exact domain from forgery; they do not stop look-alike domains or compromised accounts.
  • Analyze suspicious files only in an isolated lab, starting with static analysis.
  • The stand-ins used made-up emails and results; real filters use many more signals.

Next: Persistence, Lateral Movement and Detection.