What a cyber attack is
A cyber attack is any deliberate attempt to steal, expose, alter, disable, or destroy data or the systems that hold it. Most real breaches do not use exotic zero-days. They reuse a small set of well-known techniques against three targets: people, networks, and web applications. Learning to recognize these patterns is the core skill of a defender. For each attack on this sheet, focus on four things: what it is, how it works at a high level, one tell-tale sign that gives it away, and the primary defense that shuts it down. Everything here is defensive and conceptual. It teaches you to spot and stop attacks, not to carry them out.
| Attack | How it works | Tell-tale sign | Primary defense |
|---|---|---|---|
| Phishing | Fake messages impersonate a trusted source to steal credentials or plant malware | Mismatched sender domain, urgency, a link that hovers to a different URL | User training plus email authentication (SPF/DKIM/DMARC) and MFA |
| Spear phishing | A phishing message tailored to one person using real personal details | An unexpected money or credential request from a known contact | Verify through a second channel, MFA, least privilege |
| Social engineering | Manipulating people instead of systems using authority, fear, or urgency | Someone pressures you to skip normal procedures | Verification steps and a confirm-before-you-act culture |
| Man-in-the-middle | An attacker secretly relays or alters traffic between two parties | Certificate warnings, HTTP instead of HTTPS, odd site behavior | TLS/HTTPS everywhere, HSTS, VPN on untrusted Wi-Fi |
| DoS / DDoS | Flooding a service with traffic so real users cannot reach it | Sudden spike, site slow or unreachable, requests from many IPs | Rate limiting, CDN or scrubbing service, traffic filtering |
| SQL injection | Untrusted input is executed as database commands | App errors leaking SQL, inputs that change query results | Parameterized queries, input validation, least-privilege DB user |
| Cross-site scripting | Malicious script is injected into a page other users view | User input echoed back unescaped, unexpected scripts run | Output encoding, Content-Security-Policy, HttpOnly cookies |
| Brute force | Automatically trying many passwords until one works | Many failed logins, logins from unusual locations | Account lockout, rate limiting, strong passwords, MFA |
| Password attacks | Guessing, cracking, or replaying stolen credentials | Reused-password logins, cracked hashes, one password sprayed widely | MFA, salted slow hashing (bcrypt/argon2), password managers |
Social engineering, phishing, and spear phishing
Phishing is a fraudulent message (email, text, or phone call) that impersonates someone you trust to trick you into handing over credentials, clicking a malicious link, or opening an attachment. It is the most common way attackers gain their first foothold. Variants worth knowing: Spear phishing targets one specific person using real details about them or their job. Whaling is spear phishing aimed at executives or other high-value targets. Smishing arrives by SMS text, and vishing arrives by voice call. All of these are forms of social engineering, which means manipulating a human being instead of exploiting a software bug. The attacker leans on authority, urgency, fear, or the promise of a reward to push you into acting before you think.
Phishing red flags
Slow down when a message stacks several of these together: an urgent deadline or threat, a request for a password, payment, or gift cards, a sender address that almost matches a real one, a generic greeting, and a link whose real destination (revealed by hovering) differs from its text. Any single flag can be innocent. Together they form a phishing signature.
Verify out of band
When a request feels off, confirm it through a channel the attacker does not control. Call the person back on a number you already have, or open the site by typing its address yourself instead of clicking the link in the message.
Man-in-the-middle (MITM)
In a man-in-the-middle attack, the attacker quietly positions themselves between you and the server you think you are talking to, so they can read or change the traffic in transit. Classic settings include open coffee-shop Wi-Fi, a rogue access point named to look legitimate, and ARP spoofing on a local network. The main defense is encryption in transit. When traffic is protected with TLS (HTTPS), an attacker in the middle sees only ciphertext and cannot silently tamper with it. That is why a valid certificate matters, and why you can inspect a server's certificate yourself before trusting it.
The padlock is not a trust badge
HTTPS and the padlock icon only tell you the connection is encrypted, not that the site is honest. Attackers routinely obtain free certificates for their phishing pages, so a padlock on examp1e-bank.test still means fraud. Encryption protects the pipe. It does not vouch for who is on the other end.
Denial of service (DoS and DDoS)
A denial-of-service (DoS) attack tries to make a system unavailable to its real users, usually by exhausting a resource such as bandwidth, connections, CPU, or memory. A distributed denial-of-service (DDoS) attack does the same thing from thousands of compromised machines at once, often a botnet, which makes it much harder to block by simply banning one address. The goal is disruption, not data theft, though a DDoS is sometimes used as a smokescreen to distract defenders from another attack. Defenses work in layers: absorb the flood with a CDN or scrubbing service, filter obviously bad traffic, rate-limit each client, and keep spare capacity in reserve to ride out a spike.
Flood versus flash crowd
A tell-tale sign is a service that suddenly slows to a crawl or goes offline while logs show a massive burst of requests from a wide spread of addresses. Legitimate viral traffic can look similar, so defenders correlate request patterns and behavior, not raw volume alone.
Web attacks: SQL injection and XSS
Web applications get attacked when they treat untrusted user input as trusted code. Two classics dominate. SQL injection happens when input from a form or URL is glued straight into a database query, so a crafted value runs as SQL instead of being stored as data. The fix is to never build queries by concatenating strings. Use parameterized queries (prepared statements), which send the code and the data separately so input can never change the query's structure. Cross-site scripting (XSS) happens when an application returns user-supplied content in a page without escaping it, so a malicious script runs in another visitor's browser and can steal their session. The fix is to encode output for the context it lands in, add a Content-Security-Policy header, and mark session cookies HttpOnly so scripts cannot read them.
One pattern that stops SQL injection
Parameterized queries are the single most effective defense. Instead of building "... WHERE name = '" + input + "'", you pass a placeholder and bind the value, for example SELECT * FROM users WHERE name = ? with the input supplied separately. The database then treats the input as a value, never as commands. Input validation and least-privilege database accounts are useful backups, but parameterization is the real fix.
Brute force and password attacks
A brute-force attack simply tries password after password until one works. On its own it is slow, so attackers use smarter variants: Dictionary attacks try common words and known-bad passwords first. Credential stuffing replays username and password pairs leaked from other breaches, betting that people reuse passwords. Password spraying tries one common password (like a season plus a year) against many accounts to stay under lockout limits. Offline cracking runs against stolen password hashes, where rainbow tables can reverse unsalted hashes quickly. The defenses stack up: rate-limit and lock out repeated failures, require long unique passwords (a password manager makes this painless), store hashes with a per-user salt using a slow algorithm like bcrypt or argon2, and above all turn on multi-factor authentication, which makes a stolen password nearly useless on its own.
MFA is the highest-value control here
Multi-factor authentication defeats brute force, credential stuffing, and most password phishing at once, because a stolen or guessed password is not enough by itself. If you add only one control to an account, make it MFA. Prefer an authenticator app or hardware key over SMS codes, which can be intercepted.
Ports, protocols, and defensive checks
Many attacks target a handful of well-known network services. Knowing the port and what runs on it helps you read logs, spot exposure, and reason about defenses.
Services attackers probe most often.
| Port | Protocol | Common attack relevance |
|---|---|---|
| 80/tcp | HTTP | Unencrypted web, readable in a MITM position |
| 443/tcp | HTTPS (TLS) | Encrypted web, blocks eavesdropping and tampering |
| 22/tcp | SSH | Remote login, a top brute-force target |
| 53/udp | DNS | Name lookups, spoofing can redirect victims |
| 3389/tcp | RDP | Remote desktop, heavy credential-attack target |
| 25/tcp | SMTP | Email transport, abused for phishing and spam |
Read-only checks a defender can run to inspect a system.
| Command | What it does | Example |
|---|---|---|
| openssl s_client -connect HOST:443 | openssl - OpenSSL, the open-source Secure Sockets Layer/TLS toolkit (the sclient subcommand opens a test TLS connection): inspect a site's certificate to confirm you reached the real server | openssl s_client -connect example.com:443 -servername example.com |
| dig +short DOMAIN | dig - Domain Information Groper: resolve a domain to see the real address a link points to (+short prints just the answer, no boilerplate) | dig +short example.com |
| whois DOMAIN | whois - reads as the plain question 'who is' (not an acronym): check a domain's age and registrar, since brand-new lookalike domains signal phishing | whois example.com |
| curl -sI URL | curl - client URL: read a page's HTTP response headers to check for HSTS and Content-Security-Policy (-s silences the progress meter, -I fetches headers only) | curl -sI https://example.com |
| grep "Failed password" /var/log/auth.log | grep - Global Regular Expression Print: review failed SSH logins to catch brute-force activity | grep -c "Failed password" /var/log/auth.log |
Only test what you own
Every command on this sheet is for inspecting and defending systems you own or have written permission to test. Scanning, flooding, or logging into systems without authorization is illegal under laws like the US Computer Fraud and Abuse Act, even when you cause no damage. Practice on your own machines, a lab VM, or a sanctioned range.
Defense in depth and practice
No single control stops every attack, so defenders stack independent layers, an approach called defense in depth. Patch software to remove known holes, train people to resist social engineering, encrypt traffic to defeat interception, validate and parameterize input to block injection, and require MFA to blunt password attacks. If one layer fails, the next still stands. Notice how a few controls appear again and again across the whole table: MFA, encryption in transit, input validation, and user awareness. Master those and you cover the large majority of real attacks.
Try it yourself
ssh-auth.logDownload ssh-auth.log: https://restedteacher.com/practice-files/cybersecurity/ssh-auth.log
A sample SSH login log from a fictional web server, with failed and accepted logins. Every IP address in it comes from a range reserved for documentation, so nothing in the file points at a real computer.
suspicious-email.txtDownload suspicious-email.txt: https://restedteacher.com/practice-files/cybersecurity/suspicious-email.txt
A training copy of a phishing email sent to a student at a fictional school district. Every link is defanged so it cannot be clicked, and every name, school, and domain in it is made up.
Get to the files first
Your browser saves the files to your Downloads folder. Move them into a labs folder and go there:
mkdir -p ~/labs && mv ~/Downloads/ssh-auth.log ~/Downloads/suspicious-email.txt ~/labs/ && cd ~/labs
Then run ls and confirm you can see both files. On WSL, your Windows Downloads folder is /mnt/c/Users/<your-name>/Downloads instead of ~/Downloads. You can also open the email in any text editor. A defanged link is written so it cannot be clicked: hxxp stands for http, hxxps for https, and [.] for a dot.
Using ssh-auth.log, write ONE command for each question using pipes. Every failed-login line ends with from <IP> port <number> ssh2, so awk '{print $(NF-3)}' prints the IP address and awk '{print $(NF-5)}' prints the username, even on invalid user lines.
1. How many lines record a failed password? ( grep -c "Failed password" )
2. List each IP address that had a failed password, with a count of its failures, sorted from most to least. ( grep, awk, sort, uniq -c, sort -nr )
3. The busiest attacking IP eventually got in. Which account did it log into, and at what time? ( grep "Accepted" )
4. How many different usernames did that same IP try in its failed-password lines? ( grep, grep, awk, sort -u, wc -l )
Using suspicious-email.txt, find each red flag:
5. The domain in the From: address differs from the real school domain in the To: address by exactly one character. What is the lookalike domain, and which character was swapped for what?
6. If you replied to this email, what address would your reply actually go to? ( grep "Reply-To" )
7. How many defanged links are in the file? Count the lines containing ://. ( grep -c )
8. The Step 2 link starts with kestrelvalley, but a hostname belongs to the domain at its right-hand end. After refanging it, what registered domain (the last two labels of the hostname) does it really go to?
9. Exactly one link uses unencrypted http instead of https. Which step is it in, and what registered domain does it go to? ( grep "hxxp://" )