MarzleyTech Learn

Home / Learn / Cybersecurity / Passwords and two-factor authentication: how passwords are attacked, strong passphrases, password managers and MFA

Passwords and two-factor authentication: how passwords are attacked, strong passphrases, password managers and MFA

Your passwords protect your email, M-Pesa-linked apps, bank, social media, school portal and work systems. Stolen or guessed passwords are one of the most common ways accounts get taken over, and when one password is reused everywhere, a single leak opens every door. This unit explains how attackers break passwords, how to create ones they can't, how password managers make it easy, and how two-factor authentication (2FA/MFA) stops most account takeovers even when a password leaks.

How attackers get passwords

MethodHow it worksDefence
GuessingTrying common passwords: 123456, password, qwerty, names, birthdays, "Kenya2026"Avoid anything predictable
Brute forceTrying every combination, very fast on stolen password hashesLength: long passwords take impossibly long
Dictionary attacksTrying lists of millions of real leaked passwords and variations ("P@ssw0rd!")Random passphrases, not clever substitutions
Credential stuffingUsing email+password pairs leaked from one site on other sitesUnique password for every site
PhishingFake login pages that capture what you typeCheck URLs, use a password manager, 2FA
Keyloggers/malwareRecording keystrokes on infected or shared computers (cybers)Avoid logging in on public PCs, keep devices clean
Shoulder surfing / social engineeringWatching you type, or asking "for support"Never share; cover the keypad

What makes a password strong

Strength comes mostly from length and unpredictability. Each extra character multiplies the possibilities:

Python · runs live in the interactive lesson
import math

def guesses(length, alphabet):
    return alphabet ** length

rate = 10_000_000_000      # 10 billion guesses per second (a powerful cracking rig against weak hashes)
for desc, length, alphabet in [
    ("8 lowercase letters", 8, 26),
    ("8 mixed letters, digits, symbols", 8, 94),
    ("12 mixed characters", 12, 94),
    ("4 random common words (7,776-word list)", 4, 7776),   # each 'character' is a whole word
    ("6 random common words", 6, 7776),
]:
    seconds = guesses(length, alphabet) / rate
    years = seconds / (3600 * 24 * 365)
    print(f"{desc:42} ~{seconds:.3g} seconds (~{years:.3g} years) worst case")

The numbers show why short passwords fall quickly no matter how "complex", while long random ones become impractical to brute force. (Real cracking speed depends on how the site stored the hash; good sites use slow hashes like bcrypt, which makes attacks far slower.)

Weak patterns attackers try first: names + years (Wanjiku1998), keyboard walks (qwerty123), team names, simple substitutions (P@ssw0rd), and the site name (Facebook2026!).

Passphrases

A passphrase is several random words: maize-lantern-orbit-tuesday-pebble. It's long (strong) and easy to remember. Rules:

  • At least 4–6 random words (not a famous quote or song lyric).
  • Add separators or a number if a site insists.
  • Use passphrases for the few passwords you must remember: your password manager's master password, your device login, your email.

Password managers

You can't remember 80 unique strong passwords. A password manager does it for you:

  • Generates long random passwords for every site.
  • Stores them encrypted, unlocked by one strong master passphrase (plus 2FA).
  • Fills them in automatically on the real site only (so it won't fill on a phishing look-alike, a useful warning sign).
  • Syncs across your phone and computer.
OptionNotes
BitwardenFree, open source, works on all devices
Google Password Manager / Apple PasswordsBuilt into Chrome/Android and iPhone/Mac; easy start
KeePassXCFree, offline file you control
1Password, Proton Pass and othersPaid or freemium options

How to start in one evening:

  1. Install a manager and create a strong master passphrase (write it down and keep it somewhere physically safe until memorised).
  2. Turn on 2FA for the manager account.
  3. Change your most important passwords first: email, banking/M-Pesa-related apps, social media.
  4. Change others as you log in to them over the following weeks.

Have your accounts leaked?

Sites like Have I Been Pwned (haveibeenpwned.com) let you check whether your email appeared in known data breaches. If it did, change that password and any other site where you reused it. Many password managers include breach alerts too.

Two-factor authentication (2FA / MFA)

Authentication factors:

  1. Something you know: password, PIN.
  2. Something you have: phone, authenticator app, security key.
  3. Something you are: fingerprint, face.

2FA/MFA requires two or more different factors. Even if criminals get your password, they still need your phone or key, which stops the large majority of automated account takeovers.

MethodSecurityNotes
Security key / passkey (FIDO2)StrongestResists phishing completely
Authenticator app (Google Authenticator, Microsoft Authenticator, Authy, 2FAS)Strong6-digit codes change every 30 seconds; works offline
Push approval (tap "Yes, it's me")GoodBeware "MFA fatigue": never approve a prompt you didn't start
SMS / phone call codesWeakest of these, but far better than nothingVulnerable to SIM swap and interception
Email codesDepends on your email securitySecure your email first

Turn on 2FA in each account's Security settings. Save the backup/recovery codes somewhere safe (in your password manager or printed and stored securely); you'll need them if you lose your phone.

Secure these first

  1. Email: the "key to everything", because password resets for other accounts go there. Strong unique password + 2FA (authenticator app or key).
  2. Phone number and SIM: set a SIM PIN, keep your M-Pesa PIN secret, and contact your provider immediately if your phone suddenly loses network (possible SIM swap).
  3. WhatsApp: Settings → Account → Two-step verification (a PIN that stops others registering your number on their phone).
  4. Banking and money apps: app PINs, biometrics and transaction alerts.
  5. Social media: 2FA and login alerts (accounts are hijacked to scam your contacts).

Passkeys

Passkeys replace passwords with a cryptographic key stored on your phone or computer, unlocked with your fingerprint, face or device PIN. They can't be phished or reused, and there's nothing to remember. Google, Apple, Microsoft, WhatsApp, PayPal and many others support them: look for "Create a passkey" in security settings.

For organisations and developers

  • Require MFA, especially for email, VPN, admin and remote access.
  • Follow modern guidance (e.g. NIST): favour length (allow long passwords and all characters), check new passwords against breach lists, don't force arbitrary regular changes (only change after suspected compromise), no password hints.
  • Store passwords only as slow salted hashes (password_hash in PHP, bcrypt/Argon2); never plain text or MD5.
  • Limit login attempts and alert on suspicious logins.
  • Offer passkeys/SSO where possible.
Think about it: Brian uses "Brian@2003" for Gmail, Facebook, his school portal and his bank app. The school portal gets hacked and its passwords leak. What could happen, and what three changes should Brian make?Show answer

Attackers try the leaked email+password on other sites (credential stuffing), so his Gmail, Facebook and bank could be taken over, and from Gmail they can reset other accounts. He should: use a password manager with a unique strong password per site (changing the bank and Gmail first), turn on 2FA (authenticator app) for email, bank and social media, and check Have I Been Pwned for other leaks.

Summary

  • Attackers guess, brute force, use leaked password lists (credential stuffing), phish and use keyloggers.
  • Length and randomness make passwords strong; random passphrases are strong and memorable.
  • Use a password manager for unique passwords everywhere, starting with your most important accounts.
  • Turn on 2FA everywhere: security keys/passkeys > authenticator apps > SMS; save recovery codes; never share codes.
  • Secure email, SIM/WhatsApp and money apps first; organisations should require MFA and store only strong hashes.

Check yourself

  1. Which is stronger: a long passphrase or a short complex password?

    Show answer

    passphrase

  2. Name a free password manager.

    Show answer

    Bitwarden

  3. Which 2FA method is weakest because of SIM-swap fraud?

    Show answer

    SMS

  4. Which account is "the key to everything" and must have 2FA first?

    Show answer

    email

  5. Using leaked passwords from one site on other sites is called what? (two words)

    Show answer

    credential stuffing

  6. Which WhatsApp setting adds a PIN to stop others registering your number? (two words)

    Show answer

    two-step verification

Lesson 2 of 13 in Cybersecurity · Written by · Course notes