Skip to content
Tutorials Center
My learning

Topics

Lesson 51 of 80 ยท Malware and Endpoint Security

Phishing and Social Engineering

Understand phishing, pretexting and business email compromise, learn the warning signs, and build a simple phishing-score heuristic in Python on fake emails.

The easiest way into most organizations is not a clever exploit. It is a person. Social engineering is the art of manipulating people into giving up information, access or money, and phishing is its best-known form: a message that pretends to be someone trustworthy so that you click, log in, open a file or pay. It works because it targets habits (answering quickly, obeying authority, helping a colleague), not software flaws.

In this lesson you'll learn how phishing messages are built, the other common social-engineering techniques, how business email compromise steals money without any malware, and how training and technical controls work together. You'll also write a small scoring heuristic for suspicious emails. All messages and domains in the examples are invented, using reserved example names. Related reading: Malware Types and How They Spread shows what happens after a click.

Why it works

Attackers lean on a few psychological levers, and once you can name them, you notice them:

  • Authority: "This is the CEO" or "IT Security".
  • Urgency and fear: "Your account will be closed in 24 hours."
  • Reward and curiosity: a prize, a refund, a "photo of you".
  • Helpfulness and reciprocity: a colleague who "just needs a quick favor".
  • Familiarity: a message that looks like one you get every week.

None of this needs technical skill, which is why the same tricks work on engineers and executives alike. Treat susceptibility as normal, not as a personal failing.

Anatomy of a phishing email

flowchart LR
    A["Sender<br/>(spoofed or lookalike)"] --> B["Hook<br/>(urgent or tempting subject)"]
    B --> C["Call to action<br/>(click, open, reply, pay)"]
    C --> D["Landing page<br/>or attachment"]
    D --> E["Result: stolen password,<br/>malware, or payment"]

Each stage is a chance for a person or a filter to stop the attack.

Most phishing messages share a handful of features:

  1. A sender that is not what it seems. The display name says "Payroll", but the address belongs to an unrelated domain. Or the domain is a lookalike: examp1e-support.com, example.co instead of example.com, or a long subdomain such as example.com.login-check.net, where the real registered domain is login-check.net.
  2. A link whose visible text and real target differ. Hovering shows where it goes. Shortened links hide the target.
  3. Pressure. A deadline, a threat or a secret.
  4. A request for something sensitive: a password, a code, a gift card, a change of bank details.
  5. Generic or slightly odd wording. Less reliable than it used to be, because AI tools now write fluent messages in any language.
  6. An unexpected attachment, especially archives, macro-enabled office files and HTML files.

Beyond email

  • Spear phishing is targeted: the attacker researches you (your job, your boss, a project) and writes a tailored message. Whaling targets executives.
  • Smishing (SMS) and vishing (voice calls) use the same tricks over other channels. A caller who claims to be from the bank's fraud team and asks you to "move your money to a safe account" is running a vishing scam. Deepfake voices make calls more convincing.
  • Pretexting builds a believable story to obtain information: a caller claims to be an auditor, a new employee who lost a badge, or a vendor needing a quick reset.
  • Quishing hides the link in a QR code, which many mail filters cannot read.
  • Adversary-in-the-middle phishing uses a live proxy page that relays your real login, including your one-time code, to the genuine site and steals the session. Codes typed by a human can be phished this way; hardware keys and passkeys cannot, because they verify the website's address. See Multi-Factor Authentication and Passkeys.
  • Baiting and tailgating are physical: a "lost" USB stick left in a car park, or someone following you through a badge door with their arms full.
  • MFA fatigue spams push-approval requests at 3 a.m. until someone taps "approve" to make it stop.

Business email compromise

Business email compromise (BEC) is a fraud that often contains no malicious link or file at all. The attacker impersonates an executive or a supplier, or takes over a real mailbox, and asks the finance team to pay an invoice to a new bank account or to buy gift cards. Losses per incident can be huge because the payment is voluntary and the message looks routine.

A typical version: after reading a compromised supplier's mailbox for weeks, the attacker waits for a real invoice thread, then replies with "our bank details have changed". The email arrives in the right conversation from the right address, so filters see nothing wrong. The defense is a process, not a detector: any change to payment details is confirmed by calling a known number, large payments need two approvers, and urgent requests from "the CEO" for secrecy are treated as a red flag in themselves.

Never use contact details from the suspicious message to verify it. Use a phone number or address you already had from a trusted source.

A phishing-score heuristic

Mail security products combine hundreds of signals with machine learning. The idea can be shown with a few readable rules. The function below scores a message on invented features: urgency words, a mismatch between the display name and the sending domain, a link whose text names one host while the target points to another, a lookalike domain, a risky attachment, and requests for credentials. Each rule adds points, and the total decides a label. It is a teaching tool: real filters need far more signals and still make mistakes.

Python Score fake emails for phishing signals

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.

Three things to notice. The score for the second email comes from many weak signals adding up, which is how real filters behave. The honest messages score zero, but a determined attacker who sends from a real compromised mailbox with a clean link would also score low, which is why filters never replace trained people. And you must tune thresholds: too sensitive and staff drown in false alarms and stop trusting the warnings.

The part of a URL that decides who you are talking to is the registered domain, the last pieces before the first slash, not the first words. The next demo takes URLs apart and shows the real host.

Python Whose site is this link really on?

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.

Notice the last link: the domain is trusted, but the query string contains a second URL. A trusted site with an open redirect can forward you elsewhere, so a "known" domain is not a guarantee.

Defending people and systems

Technology and training cover each other's gaps:

  • Email authentication: SPF, DKIM and DMARC let receivers check that a message really comes from the domain it claims, and a strict DMARC policy tells them to reject forgeries of your domain.
  • Filtering and sandboxing: block known-bad senders, rewrite or scan links when clicked, and detonate attachments in a sandbox.
  • Phishing-resistant sign-in: passkeys or hardware keys make a stolen password nearly useless.
  • Least privilege and application control: even a successful click should not give an attacker administrator rights. See Endpoint Protection and System Hardening.
  • Process controls: call-back verification, dual approval for payments, and a clear rule that nobody is ever asked for their password.
  • A reporting button: one click to send a suspicious email to the security team. Make reporting easy and thank people, even when it is a false alarm. A report within minutes can save the company.
  • Training that works: short, frequent, realistic lessons and simulated phishing tests, without shaming people who click. Measure the report rate, not just the click rate.

If you did click: disconnect from the network if you opened a file, change the password from a clean device, tell the security team at once, and do not wait to see if something happens. The response process is in The Incident Response Process.

Tailgating

Tailgating (or piggybacking) is physical social engineering: an unauthorized person follows an authorized one through a secured door. The attacker carries boxes, wears a plausible uniform or pretends to have forgotten a badge, and relies on politeness. Once inside they can plug in a rogue device, read screens or reach an unlocked workstation.

Countermeasures: turnstiles or mantraps for sensitive areas, badge-in and badge-out rules (anti-passback), a polite culture of challenging strangers ("May I see your badge?"), visitor logs with escorts, cameras at entrances, and locking screens when you step away. Treat a refusal to wait for an escort as a red flag, not rudeness.

Pretexting

Pretexting is an invented, believable story used to obtain information or access. The attacker pretends to be IT support, an auditor, a new colleague or a vendor, and builds trust with a few correct details gathered earlier from social media or earlier calls. The goal is often a password reset, a one-time code, a bank detail or a building pass.

Impact: fraudulent payments, account takeover, and leaked records, plus the loss of trust once it comes out. Countermeasures: verify identity through a second channel you already know (call the number on the directory, not the one the caller gives), use a written reset procedure that no one may skip, never read out one-time codes, and train staff with realistic calls.

Baiting and scareware

Baiting offers something tempting: a USB drive labeled "Salaries Q4" left in a car park, a free movie download, a prize link. Curiosity does the attacker's work. Defenses: disable autorun, block unknown removable media with policy, hand found devices to IT.

Scareware uses fear. A pop-up claims "Your computer is infected, call this number" or shows a fake antivirus scan with red warnings. It exploits panic and the wish to fix things now. It reaches the system through malicious ads, compromised sites and bundled downloads, and then pushes you to buy useless "cleaning" software, install a remote-access tool, or phone a scammer. Prevent it by keeping browsers updated, using an ad blocker, ignoring browser alerts that claim to be a scan (a real browser cannot scan your disk), closing the tab from the task manager, and only installing security software from known vendors. Real-life campaigns have netted tens of millions of dollars from fake-antivirus sales.

Reputational damage is the cost many organizations underestimate: after a social-engineering breach, customers and partners lose trust long after the money is recovered.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which URL really belongs to the domain example.com?

    The registered domain is the part just before the first slash. In the others the real host is account-check.net, evil.test or the lookalike examp1e.com.
  2. 2. Why is business email compromise hard to stop with filters?

    BEC relies on trust and routine. Controls such as call-back verification and dual approval of payment changes are what stop it.
  3. 3. What makes a hardware security key or passkey resistant to adversary-in-the-middle phishing?

    Passkeys are bound to the real site's origin. A human can be fooled into typing a code on a fake page, but the key will not answer for the wrong domain.
  4. 4. Which training metric best shows a healthy security culture?

    Prompt reporting lets defenders react before damage spreads. Punishing clicks makes people hide mistakes.
  5. 5. A message from 'the CEO' asks for gift cards and secrecy. What should you do?

    Unusual payment requests combined with urgency and secrecy are classic signs. Verify independently and report the attempt.

Summary

  • Social engineering exploits trust, authority, urgency and helpfulness; phishing is the delivery method most often used.
  • Warning signs include a mismatched sender, lookalike or deceptive domains, links that go elsewhere, pressure, sensitive requests and risky attachments.
  • Variants include spear phishing, smishing, vishing, quishing, pretexting, MFA fatigue and physical tailgating.
  • Business email compromise steals money through ordinary-looking requests, so payment changes need independent verification and dual approval.
  • Layer defenses: email authentication, filtering, phishing-resistant sign-in, least privilege, easy reporting and realistic training.

Next: Endpoint Protection and System Hardening, where you'll make each machine harder to compromise even when a person slips.