Phishing and social engineering

Introduction

Most break-ins do not start with clever code. They start with a message: "Your account will be closed today, verify here", "Your parcel is waiting, pay the 50 taka fee", or a call from someone who says they are from your bank and needs the code they just sent you. Phishing and other social engineering attacks trick people into handing over what technology protects: passwords, one-time codes, money or access.

They work because they target feelings, not software: urgency, fear, curiosity and trust. This lesson shows how to read where a link really goes, the warning signs, and what organisations do so that one click is not a disaster.

How it works

A phishing message has three parts: a pretext (a believable story), a lure (a link, an attachment, a phone number) and a request (log in, pay, read me the code). Variants have their own names: spear phishing targets one person using details about them, smishing comes by SMS, and vishing comes by phone.

The most useful technical skill is reading a link. A browser goes to the host name, and what matters is its end: in https://login.bank.example/reset the site is bank.example. Attackers hide the real site in places people do not read:

  • Subdomain tricks: bank.example.secure-check.net belongs to secure-check.net, whatever comes before it.
  • Look-alike names: secure-bank-example.com, bank-examp1e.com (a digit 1 for the letter l), or letters from other alphabets that look identical.
  • The @ trick: in https://bank.example@verify-now.net/, everything before @ is a user name; the host is verify-now.net.

The example applies these rules to five links. (Real browsers use the Public Suffix List to find a site's registrable name, because endings such as .com.bd have more than one part.)

// Phishing links hide the real site inside a long address. What matters is the end of the host name.
// (Simplified: real browsers use the Public Suffix List, because endings like .com.bd have more than one part.)
const trusted = ["bank.example", "university.example"];

function hostOf(url) {
  const afterScheme = url.split("://")[1] ?? url;
  return afterScheme.split("/")[0].split("?")[0].split("@").pop().split(":")[0].toLowerCase();
}
function registrable(host) {
  const parts = host.split(".");
  return parts.slice(-2).join(".");
}

const links = [
  "https://bank.example/login",
  "https://login.bank.example/reset",
  "https://bank.example.secure-check.net/login",
  "https://secure-bank-example.com/login",
  "https://bank.example@verify-now.net/login",
];
for (const url of links) {
  const site = registrable(hostOf(url));
  console.log((trusted.includes(site) ? "ok    " : "DANGER") + "  really goes to " + site);
}
Open in compiler

Other warning signs: urgency or threats, a request for a password or a one-time code (genuine services never ask for the code they sent you), unexpected attachments, a sender address that does not match the organisation, and a request to keep something secret.

Example

The program extracts each link's host, keeps the last two labels as its site, and checks the site against a list of trusted ones.

Line by line

  1. hostOf drops the scheme (https://), then cuts the address at the first /, removes any query, takes what comes after the last @ and removes a port.
  2. registrable keeps the last two labels of the host, the simplified "real site".
  3. The first two links really go to bank.example, so they are fine, including the subdomain login..
  4. The third hides bank.example at the front, but its site is secure-check.net.
  5. The fourth uses a look-alike name, and the fifth uses the @ trick; both go somewhere else.

Expected result

ok      really goes to bank.example
ok      really goes to bank.example
DANGER  really goes to secure-check.net
DANGER  really goes to secure-bank-example.com
DANGER  really goes to verify-now.net

In the real world

  • Password managers fill in passwords only on the exact site they were saved for, so they quietly refuse to fill a look-alike page: a useful phishing check.
  • Passkeys and security keys cannot be phished, because they sign for the real site's address only (see the two-factor lesson).
  • Organisations run phishing awareness training and make reporting easy: a "report phishing" button, and no blame for people who report a mistake quickly.
  • Email checks such as SPF, DKIM and DMARC help receiving servers spot forged sender addresses, but a look-alike domain can pass them, so people still need to read links.

Common mistakes

  • Reading the start of a link instead of the end. The site is decided by the end of the host name.
  • Trusting the lock icon. Phishing sites have valid HTTPS certificates for their own look-alike names.
  • Sharing a one-time code with a caller. Anyone who asks for it is the attacker.
  • Hiding a mistake. Reporting quickly lets the team reset passwords before damage is done.

Best practices

  • Type the address yourself, or use a bookmark, for banks and important accounts.
  • Use a password manager and passkeys, which refuse to work on look-alike sites.
  • Verify unusual requests through a different channel, such as calling the number on the official website.
  • Report suspicious messages, even if you already clicked.

Summary

Phishing tricks people with a believable story, a lure and a request, often using urgency or fear. The site a link really leads to is decided by the end of its host name, so subdomain tricks, look-alike names and the @ trick all hide the real site where people rarely look. Genuine services never ask for passwords or one-time codes; password managers and passkeys refuse look-alike sites; and quick, blame-free reporting limits the damage when someone does click.

Quick check

1. Which site does https://bank.example.secure-check.net/login really go to?
2. In https://bank.example@verify-now.net/, what does the browser treat as the host?
3. Someone calls, says they are from your mobile wallet, and asks for the code you just received. What should you do?
4. Why does a password manager help against phishing?

Key takeaways

  • Read the end of the host name: that decides the real site.
  • Genuine services never ask for your password or one-time code.
  • Password managers and passkeys refuse to work on look-alike sites.
  • Report quickly and without blame; speed limits the damage.

Practice problems for this lesson

Was this lesson clear?

My notes

Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.