SyntaxPilot
Courses/Cybersecurity Fundamentals/Lesson 6

Cybersecurity Fundamentals · Lesson 6 of 90 · 15 min

Social engineering and phishing: how to spot it

social engineeringphishingspear phishingwhalingbusiness email compromise (BEC)vishingsmishingquishing (QR phishing)pretextingbaitingquid pro quotailgatingpiggybackingwatering hole

These are the notes for Cybersecurity Fundamentals (defensive), episode 6. Last time we met every malware family and noticed that most of them need one thing first: someone clicks. Today: how attackers get that click, by hacking people instead of computers, and how to spot every trick. You'll invent each idea from a real-life problem and build small Python checks: social engineering and the levers it pulls, phishing, spear phishing, whaling, vishing, smishing and quishing, reading a link's real host, typosquatting, homograph (IDN) domains and punycode, business email compromise (BEC) and deepfake fraud with call-back verification, pretexting, baiting, quid pro quo, tailgating, piggybacking, watering hole attacks, a red-flags checklist, and finally reporting culture, security awareness training and phishing simulations. Every term is explained the first time it appears, and the Glossary at the end defines them all again.

All banks, domains and emails here are made up (chaibank.in, railticket.in, *.example); nothing is contacted. Every code sample runs as-is; outputs are real (Python 3).

The problems you'll solve

Problem Idea it teaches
A phone call opens the strongest lock Social engineering and its levers
One net, one spear, one whale Phishing, spear phishing, whaling; vishing, smishing, quishing
"The link contains our bank's name" Reading the real host of a link
One wrong letter, and an "unknown" verdict Typosquatting, lookalike detection
Two names that look identical Homographs, IDNs, punycode (xn--)
"Please use our new bank account"; a CFO on video who isn't real BEC, deepfakes, call-back (out-of-band) verification
Tricks at the office door Pretexting, baiting, quid pro quo, tailgating, piggybacking, watering hole
Kiran clicked, and hid it Reporting culture, awareness training, phishing simulations

Problem 1: hacking people (social engineering)

Meena's bank account has a strong password and an OTP (one-time password: a short code sent to her phone that works once). Breaking that by force would take forever. So the attacker calls: "Ma'am, I'm calling from your bank. Your account will be blocked in ten minutes. Read me the code we just sent you." Scared, she reads it out. No lock was broken; the person was.

Social engineering is tricking people into giving access, information or money. It pulls the same few levers:

Lever What it sounds like Why it works
Urgency "in 10 minutes", "today only" No time to think or check
Authority "I'm from the bank", "this is your CEO" People obey authority
Fear "your account will be blocked", "legal action" Fear overrides caution
Greed "you won a prize, pay a small fee" Too good to miss
Helpfulness "please, I'm new, just this once" Good people want to help

The rule: the moment a message makes you feel rushed, scared or excited, that feeling is the signal to stop and check. A real bank never asks you to read out an OTP.

Problem 2: phishing and its cousins

Fishing Phishing Meaning
A wide net Phishing A fake message pretending to be someone you trust, sent to thousands, hoping a few click
A spear at one fish Spear phishing A message written for one person, using their name, boss and current project
Hunting the biggest fish Whaling Spear phishing aimed at top bosses (CEO, CFO), because one success is worth a lot

Phishing is the most reported cybercrime: the FBI's Internet Crime Complaint Center (IC3) 2024 report counted 193,407 phishing/spoofing complaints, more than any other type, and US$16.6 billion in total reported losses across all cybercrime. Spoofing means faking the sender, for example making an email look like it came from your bank.

The same trick arrives through every channel:

Name Channel Example
Phishing Email "Your account is suspended, log in here"
Vishing Voice (phone call) Meena's "bank" call
Smishing SMS and chat messages "Your parcel is held, pay ₹5 here"
Quishing QR code A sticker over the real QR on a parking meter opens a fake payment page

Before you pay by QR, read the address or payee name it opens.

Ravi gets an SMS: "Update your KYC or your account will be closed" (KYC, know your customer: the identity details a bank must keep). He checks that the link contains chaibank.in. It does. It isn't the bank.

Demo 1: the obvious check

links = ["https://chaibank.in/login",
         "https://chaibank.in.kyc-update.xyz/login",
         "https://login-chaibank.in/verify",
         "https://chaibank.in@evil.example/pay"]

for url in links:              # "is it our bank?"
    print("chaibank.in" in url, url)

Output:

True https://chaibank.in/login
True https://chaibank.in.kyc-update.xyz/login
True https://login-chaibank.in/verify
True https://chaibank.in@evil.example/pay

Every fake passes. The name being somewhere in the link proves nothing.

Demo 1b: read the real host

from urllib.parse import urlparse
BANK = "chaibank.in"

links = ["https://chaibank.in/login",
         "https://chaibank.in.kyc-update.xyz/login",
         "https://login-chaibank.in/verify",
         "https://chaibank.in@evil.example/pay"]

for url in links:              # read the REAL host
    host = urlparse(url).hostname
    ok = host == BANK or host.endswith("." + BANK)
    print(f"{str(ok):5} {host}")

Output:

True  chaibank.in
False chaibank.in.kyc-update.xyz
False login-chaibank.in
False evil.example

The host (hostname) is the name of the server a link really goes to. urlparse splits a URL (a web address) into its parts properly. A subdomain is a name under the main one, like login.chaibank.in, which is why we also accept names ending in .chaibank.in.

  • The host is the part between // and the next single /.
  • Read it from the right: the ending (.in, .com, .xyz, called the top-level domain), then the word just before it is the real owner (the registered domain).
  • chaibank.in.kyc-update.xyz belongs to kyc-update.xyz.
  • Anything before an @ in the host part is a username and is ignored: chaibank.in@evil.example goes to evil.example.
  • Safest habit: don't click links in messages. Type the address yourself, or open the official app.

Problem 4: lookalike domains

Someone types chaibank in a hurry and hits e instead of a. An attacker has bought chaibenk.in and put a perfect copy of the login page there. Registering misspellings of popular names is typosquatting.

Demo 2: an allowlist only says "unknown"

TRUSTED = ["chaibank.in", "railticket.in"]
seen = ["chaibank.in", "chaibenk.in", "rai1ticket.in",
        "chaibank-in.co", "weather.in"]

for d in seen:
    status = "trusted" if d in TRUSTED else "unknown"
    print(f"{d:15} {status}")

Output:

chaibank.in     trusted
chaibenk.in     unknown
rai1ticket.in   unknown
chaibank-in.co  unknown
weather.in      unknown

A fake bank and a harmless weather site get the same verdict.

Demo 2b: flag names similar to trusted ones

from difflib import SequenceMatcher

TRUSTED = ["chaibank.in", "railticket.in"]
seen = ["chaibank.in", "chaibenk.in", "rai1ticket.in",
        "chaibank-in.co", "weather.in"]

for d in seen:
    status = "trusted" if d in TRUSTED else "unknown"
    for t in TRUSTED:
        r = SequenceMatcher(None, d, t).ratio()
        if d != t and r > 0.75:
            status = f"LOOKALIKE of {t} ({r:.2f})"
    print(f"{d:15} {status}")

Output:

chaibank.in     trusted
chaibenk.in     LOOKALIKE of chaibank.in (0.91)
rai1ticket.in   LOOKALIKE of railticket.in (0.92)
chaibank-in.co  LOOKALIKE of chaibank.in (0.80)
weather.in      unknown

SequenceMatcher(...).ratio() gives a similarity score from 0 (nothing in common) to 1 (identical). Similar but not equal is suspicious. (rai1ticket uses the digit 1 instead of the letter l.)

Demo 3: names that look identical but aren't

real = "chaibank.in"
fake = "сhaibank.in"    # 1st letter: Cyrillic 'с'

print(real, fake)            # look the same?
print(fake == real)
print(fake.encode("idna"))   # what the browser sends

Output:

chaibank.in сhaibank.in
False
b'xn--haibank-xjg.in'

с is the Cyrillic (Russian alphabet) letter "с", which looks exactly like the Latin "c".

  • Homoglyphs are characters from different alphabets that look the same.
  • A homograph attack uses a domain built from homoglyphs to imitate a real one.
  • IDNs (internationalised domain names) let domains use letters from any script, which is good for Hindi, Tamil or Russian speakers, but enables homographs.
  • On the wire, IDNs are sent as punycode, an ASCII form that starts with xn--. That's how browsers and filters spot them: .encode("idna") shows it.

Problem 5: business email compromise and deepfakes

An email from a supplier you pay monthly: "We've changed banks, please send future payments to this new account." The accounts team replies "is this real?" and gets "yes" back, from the attacker, who has taken over the supplier's mailbox or is using a lookalike address. The next invoice goes to the attacker.

Business email compromise (BEC) is tricking a company into sending money or data using a real (hijacked) or faked business email. The FBI's IC3 2024 report counted US$2.77 billion lost to BEC across 21,442 incidents.

Deepfakes are fake video or voice made with AI to look and sound like a real person. In 2024 the engineering firm Arup confirmed that a finance worker in Hong Kong joined a video call with deepfake re-creations of the company's CFO and colleagues, and made 15 transfers totalling HK$200 million (about US$25.6 million).

Verify on the same channel (fails) Call-back / out-of-band verification (works)
Reply to the email: the attacker answers Call the number you already have on record
Call the number written in the email: the attacker Walk to their desk, or use a known internal chat
Ask on the same video call: deepfake Any change of bank details is put on hold until verified
"It looked and sounded like him" Big payments need two approvers (separation of duties)

Out-of-band verification means confirming through a different channel that you already trust, not the one the request came on.

Problem 6: tricks without a computer

What happens Name Meaning
"I'm from IT, I need your login to fix the printer" Pretexting A made-up story (the pretext) to get information or access
A pen drive labelled "Salaries 2026" in the office lift Baiting Leaving a tempting item that carries malware; curiosity does the rest
"Free laptop check, just tell me your password" Quid pro quo Latin for "something for something": a service offered in exchange for access
Someone with boxes follows you through the secure door Tailgating Entering a restricted area behind an authorised person, without them noticing
You hold the door open for them, to be polite Piggybacking Same, but the authorised person knowingly lets them in
Infecting a news site the target's staff visit often Watering hole Like poisoning the chai stall where the whole team takes its break

Defences: never share passwords or OTPs with anyone (IT never needs them), never plug in found USB drives (hand them to IT), and everyone badges in, politely, every time.

Problem 7: a red-flags checklist

Demo 4: count the red flags

mail = {"from":     "support@chaibank-help.xyz",
        "reply_to": "kyc.desk@mailbox.example",
        "subject":  "URGENT: account blocked in 24 hours",
        "asks_for": "OTP"}

flags, subj = [], mail["subject"]
if not mail["from"].endswith("@chaibank.in"):
    flags.append("sender is not chaibank.in")
if mail["reply_to"] != mail["from"]:
    flags.append("reply goes somewhere else")
if "URGENT" in subj or "24 hours" in subj:
    flags.append("pressure: urgency")
if mail["asks_for"] in ("OTP", "PIN", "password"):
    flags.append("asks for a secret")

print(len(flags), "red flags:")
for f in flags:
    print(" -", f)

Output:

4 red flags:
 - sender is not chaibank.in
 - reply goes somewhere else
 - pressure: urgency
 - asks for a secret

Reply-to is the address your reply goes to; it can differ from the visible sender. One flag: slow down. Two or more: don't touch it, report it.

The red-flags checklist

  1. The sender or link host is off (read it from the right).
  2. Urgency or fear ("in 10 minutes", "blocked").
  3. It asks for a secret: OTP, PIN, password. Never share.
  4. A change to money or bank details: call back on a known number.
  5. Too good to be true: prizes, refunds, free help.
  6. An unusual request from a boss, especially "keep this secret, do it now".

Problem 8: people as the defence

Kiran clicks a fake link on a busy day and types his password. Scared of being blamed, he says nothing. Two weeks later the attacker is deep inside. Reported in the first five minutes, it would have been a password reset and a blocked site. The click wasn't the real damage; the silence was.

  • Reporting culture: people report suspicious messages, and their own mistakes, quickly, and are thanked, never blamed. Make it one click with a "Report phishing" button.
  • Security awareness training: short, regular sessions teaching these tricks with real examples.
  • Phishing simulations: safe, fake phishing emails sent to staff so they can practise spotting and reporting them, like a fire drill.
  • The goal isn't zero clicks (no company achieves that); it's more reports, faster. Every employee becomes a sensor.

Common mistakes (and what they print)

Mistake Real output Why Fix
"chaibank.in" in url True https://chaibank.in.kyc-update.xyz/login The name in the text isn't the host urlparse(url).hostname, exact match or .endswith("." + BANK)
d in TRUSTED as the only check chaibenk.in unknown Lookalikes look like any other site Flag names similar to trusted ones
fake == real "because they look equal" False / b'xn--haibank-xjg.in' Homoglyphs from another alphabet Check for xn-- (punycode)
Replying to the email to confirm "yes, it's real" (the attacker) Same channel = attacker's channel Call back on a number you already have
Hiding a mistake (attacker inside for weeks) Silence turns a slip into a breach Blame-free, one-click reporting

Mini project: a phishing triage helper

Combine every check from today into one function that gives a verdict.

from urllib.parse import urlparse
from difflib import SequenceMatcher

BANK = "chaibank.in"

def check(mail):
    flags = []
    sender_domain = mail["from"].split("@")[-1]
    host = urlparse(mail["link"]).hostname or ""
    if sender_domain != BANK:
        flags.append(f"sender domain is {sender_domain}")
    if mail["reply_to"] != mail["from"]:
        flags.append("reply goes somewhere else")
    if not (host == BANK or host.endswith("." + BANK)):
        flags.append(f"link goes to {host}")
    if host.startswith("xn--") or ".xn--" in host:
        flags.append("punycode (possible homograph)")
    for t in (sender_domain, host):
        if t != BANK and SequenceMatcher(None, t, BANK).ratio() > 0.75:
            flags.append(f"{t} looks like {BANK}")
    words = ("urgent", "blocked", "24 hours", "immediately")
    if any(w in mail["subject"].lower() for w in words):
        flags.append("pressure: urgency")
    if mail["asks_for"] in ("OTP", "PIN", "password"):
        flags.append("asks for a secret")
    verdict = "REPORT" if len(flags) >= 2 else "slow down" if flags else "looks ok"
    return verdict, flags

mails = [
    {"from": "alerts@chaibank.in", "reply_to": "alerts@chaibank.in",
     "subject": "Your monthly statement", "link": "https://chaibank.in/statements",
     "asks_for": ""},
    {"from": "support@chaibenk.in", "reply_to": "kyc.desk@mailbox.example",
     "subject": "Account BLOCKED - verify immediately",
     "link": "https://chaibank.in.kyc-update.xyz/login", "asks_for": "OTP"},
]
for m in mails:
    verdict, flags = check(m)
    print(m["subject"], "->", verdict)
    for f in flags:
        print("   -", f)

Output:

Your monthly statement -> looks ok
Account BLOCKED - verify immediately -> REPORT
   - sender domain is chaibenk.in
   - reply goes somewhere else
   - link goes to chaibank.in.kyc-update.xyz
   - chaibenk.in looks like chaibank.in
   - pressure: urgency
   - asks for a secret

Real email systems add more signals, such as SPF, DKIM and DMARC (checks that an email really came from the domain it claims; covered later in the course).

Practice

  1. Add these links to Demo 1b and predict each result: https://www.chaibank.in/offers, https://chaibank.in.evil.example/, https://xn--haibank-xjg.in/login.
  2. Add a "link" field to Demo 4 and a fifth check: is the link's host really chaibank.in?
  3. Name the technique: (a) "Hi, this is Priya from HR, I'm updating records, can you confirm your employee ID and date of birth?"; (b) a QR sticker on a restaurant table that opens a payment page; (c) a fake "IT helpdesk" offering a free speed-up in return for remote access; (d) an email to the CFO that mentions a real acquisition and asks for an urgent transfer.
  4. Who really owns these links? https://secure.chaibank.in/login, https://chaibank.secure-login.in/, https://chaibank.in-verify.com/.
  5. Write your family's "call-back rule" in one sentence.
Solutions

1.

from urllib.parse import urlparse
BANK = "chaibank.in"

links = ["https://www.chaibank.in/offers",
         "https://chaibank.in.evil.example/",
         "https://xn--haibank-xjg.in/login"]

for url in links:
    host = urlparse(url).hostname
    ok = host == BANK or host.endswith("." + BANK)
    print(f"{str(ok):5} {host}")

Output:

True  www.chaibank.in
False chaibank.in.evil.example
False xn--haibank-xjg.in

2.

from urllib.parse import urlparse

mail = {"from":     "support@chaibank-help.xyz",
        "reply_to": "kyc.desk@mailbox.example",
        "subject":  "URGENT: account blocked in 24 hours",
        "asks_for": "OTP",
        "link":     "https://chaibank.in.kyc-update.xyz/login"}

flags, subj = [], mail["subject"]
if not mail["from"].endswith("@chaibank.in"):
    flags.append("sender is not chaibank.in")
if mail["reply_to"] != mail["from"]:
    flags.append("reply goes somewhere else")
if "URGENT" in subj or "24 hours" in subj:
    flags.append("pressure: urgency")
if mail["asks_for"] in ("OTP", "PIN", "password"):
    flags.append("asks for a secret")
host = urlparse(mail["link"]).hostname
if not (host == "chaibank.in" or host.endswith(".chaibank.in")):
    flags.append("link host is " + host)

print(len(flags), "red flags:")
for f in flags:
    print(" -", f)

Output:

5 red flags:
 - sender is not chaibank.in
 - reply goes somewhere else
 - pressure: urgency
 - asks for a secret
 - link host is chaibank.in.kyc-update.xyz
  1. (a) pretexting (possibly vishing if by phone); (b) quishing; (c) quid pro quo; (d) whaling (spear phishing aimed at a top executive), likely BEC.
  2. secure.chaibank.in → chaibank.in (a real subdomain); chaibank.secure-login.in → secure-login.in; chaibank.in-verify.com → in-verify.com.
  3. Example: "If anyone asks for money or an OTP urgently, even if it sounds like family, hang up and call them back on the number saved in your phone."

Quick quiz

An SMS says: update your KYC at https://chaibank.in.secure-kyc.top/login. Which domain really owns this page?

A. chaibank.in · B. secure-kyc.top · C. login · D. https

Answer

B, secure-kyc.top. Read the host from the right: .top, then secure-kyc. The chaibank.in part on the left is just decoration.

Interview questions

  1. What is social engineering, and why does it work? Manipulating people into giving access, data or money, using urgency, authority, fear, greed and helpfulness to bypass careful thinking. It works because it targets people rather than technical controls.
  2. Phishing vs spear phishing vs whaling? Mass, untargeted fake messages; messages tailored to one person; tailored messages aimed at senior executives.
  3. How do you tell where a link really goes? Parse the hostname and read it from the right to find the registered domain; ignore anything before @; watch for lookalikes and xn-- punycode; better still, navigate directly instead of clicking.
  4. What is a homograph attack, and how is it mitigated? A domain using characters from another script that look like Latin letters. Browsers display punycode (xn--) for suspicious mixes, and filters flag mixed-script or lookalike domains.
  5. What is BEC and what control stops it? Business email compromise: fraud using hijacked or spoofed business email, usually changing bank details or requesting urgent transfers. Out-of-band call-back verification on known numbers, holds on bank-detail changes, and dual approval.
  6. Tailgating vs piggybacking? Both are following an authorised person into a restricted area; in tailgating they don't notice, in piggybacking they knowingly allow it.
  7. What makes security awareness training effective? Short, regular, realistic content; blame-free reporting with a one-click button; phishing simulations used for practice, not punishment; measuring report rate and time-to-report, not just click rate.
  8. What is a watering hole attack? Compromising a website the target group visits often, so the targets are infected when they visit.

Glossary

Term Meaning in plain words Example
Social engineering Tricking people into giving access, information or money The fake "bank" call
OTP One-time password: a short code that works once A 6-digit SMS code
Urgency (lever) Pressure so you don't stop to think "in 10 minutes"
Authority (lever) Pretending to be someone you obey "I'm your CEO"
Phishing A fake message pretending to be someone you trust, sent widely "Your account is suspended"
Spoofing Faking the sender of a message An email that looks like it's from your bank
Spear phishing Phishing written for one specific person Mentions your boss and project
Whaling Spear phishing aimed at top executives An email to the CFO
Vishing Voice phishing: by phone call "Read me the OTP"
Smishing SMS (and chat) phishing "Parcel held, pay ₹5"
Quishing QR-code phishing A fake QR sticker on a meter
KYC Know your customer: identity details a bank must keep "Update your KYC" scam
URL A web address https://chaibank.in/login
Host / hostname The name of the server a link really goes to chaibank.in
Subdomain A name under the main domain login.chaibank.in
Top-level domain The last part of a domain .in, .com, .xyz
Registered domain The part someone actually owns, just left of the ending kyc-update.xyz
urlparse Python function that splits a URL into parts .hostname
Typosquatting Registering misspellings of popular names chaibenk.in
Lookalike domain A domain made to resemble a trusted one chaibank-in.co
Similarity ratio A score from 0 to 1 of how alike two strings are 0.91
Homoglyph A character from another alphabet that looks the same Cyrillic "с" vs Latin "c"
Homograph attack A domain built from homoglyphs to imitate a real one сhaibank.in
IDN Internationalised domain name: domain letters from any script Hindi or Russian domains
Punycode The ASCII form of an IDN, starting with xn-- xn--haibank-xjg.in
BEC Business email compromise: money fraud via real or faked business email "New bank account"
Deepfake Fake video or voice made with AI The fake CFO on a call
Out-of-band verification (call-back) Confirming on a different, already-trusted channel Call the saved number
Pretexting A made-up story to get information "I'm from IT"
Baiting A tempting item that carries malware "Salaries 2026" pen drive
Quid pro quo A service offered in exchange for access "Free laptop check"
Tailgating Following someone into a restricted area unnoticed Slipping in behind you
Piggybacking Being knowingly let in by an authorised person You hold the door
Watering hole attack Infecting a site the targets often visit A poisoned industry news site
Reply-to The address your reply is sent to Can differ from the sender
Red flag A warning sign Urgency, a request for an OTP
Reporting culture Reporting fast, being thanked, never blamed One-click "Report phishing"
Security awareness training Regular short lessons on spotting attacks Real phishing examples
Phishing simulation Safe fake phishing emails for practice Like a fire drill
SPF, DKIM, DMARC Email checks that a message really came from the domain it claims Covered later in the course

Summary

  • Social engineering hacks people with urgency, authority, fear, greed and helpfulness. Feeling rushed is the signal to stop.
  • Phishing (email), vishing (voice), smishing (SMS), quishing (QR); spear phishing targets one person, whaling targets bosses.
  • Read a link's real host from the right; ignore anything before @; better, type the address yourself.
  • Watch for typosquatting and homographs; xn-- (punycode) means look closer.
  • BEC and deepfakes: verify money requests out of band, on a number you already have; hold bank-detail changes; two approvers.
  • Pretexting, baiting, quid pro quo, tailgating, piggybacking, watering holes: never share secrets, never plug in found USBs, badge in every time.
  • Use the red-flags checklist, and build a reporting culture with training and phishing simulations: more reports, faster.

Next episode: threat modelling: data flow diagrams, trust boundaries, STRIDE, attack trees and the four questions.

Sources: FBI IC3 2024 Internet Crime Report, as summarised by Proofpoint ("Email attacks drive record cybercrime losses in 2024"); CNN, "British engineering giant Arup revealed as $25 million deepfake scam victim" (16 May 2024). Fetched 28 Oct 2026.