ข้ามไปยังเนื้อหา

บทเรียนที่ 75 · Projects

Final project: Defensive Security Review of a Small Office

A guided defensive capstone: list assets, rank risks, analyze practice logs with Python, write a hardening plan and summarize your findings clearly.

Juniper Lane Bookkeeping is a made-up office with six people. They keep client records on one shared Linux file server, use hosted email, run a small client upload page, and share an office Wi-Fi network. The owner, Mrs. Okafor, has asked you, in this fictional story, to review their security and tell her what to fix first.

By the end you will have a short review folder: a scope note, an asset list, a ranked risk register, a log analysis written in Python, a hardening plan and a one-page summary for a reader who is not technical. You can review a practice app that you built yourself instead. The milestones work the same way.

This is defensive work on invented data or on things you own. Review only systems that belong to you, or that the owner has authorized in writing, within the limits they set. Do not scan, test or log in to anything else, including a neighbor's network, your school or your employer. Nothing here asks you to attack a system.

What you need first

This project closes the Cybersecurity Foundations path, so it draws on all six tutorials:

The brief

Here are the facts you have been given. Anything not listed is unknown, and your report should say so instead of guessing.

  • The file server holds client records. All six people use one shared account named office.
  • Remote login over SSH is open to the internet and accepts passwords.
  • Operating system updates were last installed several months ago.
  • A backup drive stays plugged into the server. Nobody has tried a restore.
  • Email has multi-factor authentication (MFA) available, but only two people use it.
  • Visitors and office laptops share one Wi-Fi network.
  • The upload page accepts any file type from clients who have signed in.

Your review must meet these requirements:

  1. State the scope, who authorized it, and what is out of scope.
  2. List at least six assets, each with an owner and the harm if it were exposed, changed or lost.
  3. Record at least six risks with a likelihood and an impact from 1 to 5, and rank them.
  4. Analyze the practice logs with code and separate what they show from what you suspect.
  5. Write a hardening plan in which every action has an owner role, an effort estimate and a way to verify it.
  6. Finish with a summary of no more than one page in plain language.

Milestones

Milestone 1: Scope and assets

Write half a page that names the systems you will review, the person who approved the review, the dates, the allowed methods (reading settings, interviews, analyzing supplied logs) and what to do if you find signs of a real intrusion: stop, preserve the records and tell the owner.

Then build the asset table. Include things that are easy to forget, such as the email accounts, the backup drive, the router's administrator login and the staff's time. Use the CIA triad to describe the harm: confidentiality, integrity or availability. Add a small data flow sketch that shows how a client file travels from the upload page to the server and the backup.

Hint: For each asset ask, "Who would notice first if this disappeared on Monday morning?"

Done when: another person could tell from your scope note whether a given action is allowed, and every asset has an owner and a stated harm.

Milestone 2: Rank the risks

A risk is more than a weakness. Write each one as a sentence: "Because of a weakness, an event could happen to an asset, causing a harm." For example, "Because everyone shares one account, a deleted file could not be traced to a person, which weakens integrity and accountability."

Multiply likelihood by impact to get a score. The numbers are judgments, so add one line of reasoning for each. The checkpoint below turns your scores into a consistent order.

Python Rank the risk register

Your task: Write rank_risks(risks). Each item is a dict with id, likelihood and impact. Return a list of tuples (id, score, level) where score is likelihood times impact. Level is high for a score of 15 or more, medium for 8 to 14 and low otherwise. Order by score (highest first), then impact (highest first), then id (A to Z). Do not change the input list.

Hint

A sort key can be a tuple. Put a minus sign before the numbers that should go from high to low.

Press Run (or Ctrl + Enter) to see the result here.

✅ Correct. Your result matches. ❌ Not yet. Check the output and try again. The answer could not be checked. Please try again.

Expected result


        

One possible solution

def rank_risks(risks):
    ordered = sorted(risks, key=lambda r: (-r["likelihood"] * r["impact"], -r["impact"], r["id"]))
    result = []
    for r in ordered:
        score = r["likelihood"] * r["impact"]
        if score >= 15:
            level = "high"
        elif score >= 8:
            level = "medium"
        else:
            level = "low"
        result.append((r["id"], score, level))
    return result

Done when: at least six risks are ranked, and you have explained any case where you would act in a different order than the score suggests.

Milestone 3: Read the logs

Mrs. Okafor "exported" some sign-in records for you. In this project each line looks like this:

TEXT
2026-03-09T02:14:05 FAIL user=office ip=203.0.113.50

All addresses come from ranges reserved for documentation. Start with parsing. Real files contain blank and damaged lines, so your code must reject them without crashing. Count how many you reject and report that number, because missing data limits what you can conclude.

Python Parse one sign-in line

Your task: Write parse_line(line). A valid line has exactly four space-separated parts: a time, OK or FAIL, user=NAME and ip=ADDRESS, with a non-empty name and address. Return the tuple (time, result, user, ip) with the user= and ip= prefixes removed. Ignore leading and trailing whitespace. Return None for any other line. You do not need to validate the time or the address further.

Hint

Check the number of parts before you unpack them.

Press Run (or Ctrl + Enter) to see the result here.

✅ Correct. Your result matches. ❌ Not yet. Check the output and try again. The answer could not be checked. Please try again.

Expected result


        

One possible solution

def parse_line(line):
    parts = line.split()
    if len(parts) != 4:
        return None
    time, result, user, ip = parts
    if result not in ("OK", "FAIL"):
        return None
    if not user.startswith("user=") or not ip.startswith("ip="):
        return None
    if len(user) == 5 or len(ip) == 3:
        return None
    return (time, result, user[5:], ip[3:])

Next, look for a pattern that matters: several failures followed by a success for the same account from the same address. It could be a person who forgot a password, or it could be someone who guessed it. The log alone cannot tell you which.

Python Find a success after repeated failures

Your task: Write suspicious_logins(events, min_failures). Each event is a tuple (time, result, user, ip); times are ISO strings and the list may be out of order. Process events by time. For each (user, ip) pair, count failures since that pair's last OK. When an OK arrives and the count is at least min_failures, record (time, user, ip, count). Every OK resets that pair's count. Return the records in time order.

Hint

A dictionary keyed by the (user, ip) tuple can hold the running counts.

Press Run (or Ctrl + Enter) to see the result here.

✅ Correct. Your result matches. ❌ Not yet. Check the output and try again. The answer could not be checked. Please try again.

Expected result


        

One possible solution

def suspicious_logins(events, min_failures):
    counts = {}
    found = []
    for time, result, user, ip in sorted(events):
        key = (user, ip)
        if result == "FAIL":
            counts[key] = counts.get(key, 0) + 1
        else:
            if counts.get(key, 0) >= min_failures:
                found.append((time, user, ip, counts[key]))
            counts[key] = 0
    return found

On your own computer, invent about 40 lines in this format, including normal activity, typos and one suspicious sequence. Run your two functions on the file. Then add one more rule, such as many failures from one address within five minutes, and note a harmless situation that would also trigger it. Logging and SIEM and the log analyzer project can help.

Done when: each finding lists the evidence lines, what they show, what they do not show, and the next safe step. Write "a success followed repeated failures", not "the server was hacked".

Milestone 4: Write the hardening plan

Turn your highest risks into actions. Think in layers: prevent, detect and recover. Options for this office include individual accounts with only the access each role needs; SSH reachable only through a protected route, with key-based sign-in and password sign-in turned off after keys are tested; a routine for updates; MFA for every email account; a separate guest Wi-Fi network; an offline or write-protected backup copy with a tested restore; central logs with a named reviewer; and an upload page that limits file type and size, stores files where they cannot run, and checks that each signed-in client can reach only their own files.

Order matters. A change to remote access can lock out the owner, so every risky action needs a way back. Practice Linux changes in your own virtual machine, never on a system you do not control. See endpoint hardening, MFA and passkeys and backup and resilience.

For each action, fill in the risk it reduces, the owner role, the effort (small, medium or large), the target time frame, the verification step and the rollback. Then name the risk that remains.

Python Find the gaps in your plan

Your task: Write plan_gaps(risks, actions). risks is a list of (risk_id, level) tuples. actions is a list of dicts with risk, owner and verify. An action is complete only when owner and verify both contain something other than whitespace. Return a sorted list of the ids of high or medium risks that have no complete action.

Hint

First collect the set of risk ids that have a complete action.

Press Run (or Ctrl + Enter) to see the result here.

✅ Correct. Your result matches. ❌ Not yet. Check the output and try again. The answer could not be checked. Please try again.

Expected result


        

One possible solution

def plan_gaps(risks, actions):
    covered = {a["risk"] for a in actions if a["owner"].strip() and a["verify"].strip()}
    return sorted(r for r, level in risks if level in ("high", "medium") and r not in covered)

Done when: no high or medium risk is left without a complete action or a written decision by the fictional owner to accept it.

Milestone 5: Report to the owner

Write one page for Mrs. Okafor. Open with the overall picture, then the three actions to take first and why, then what you could not check, and finally what to do if something looks wrong. Replace jargon with consequences: "Anyone on the internet can try passwords against your server" is clearer than a protocol name. Put the register, plan and code in appendices.

Reports about security are sensitive. Never include real passwords, keys or personal data, and share a real report only with the people who are authorized to see it.

Done when: someone without security knowledge can read the page and tell you what to do first, who does it and how they will know it worked.

Check your work

The checkpoints only compare the results of small functions. The site cannot grade your review, so use this table or ask a person you trust to read it.

Criterion What good looks like
Authorization Scope, approver, limits and a stop rule are written down
Assets Each has an owner and a specific harm
Risks Each is a full sentence with a scored, explained judgment
Evidence Facts, assumptions and unknowns are clearly separate
Log analysis Code runs on your practice file and reports rejected lines
Plan Actions have owners, verification and rollback
Summary One page, plain language, three clear priorities

Common mistakes

Do not "prove" a weakness by exploiting it. A setting you can read, or a fact the owner confirms, is enough for this review. Also avoid listing tools to buy before you have named the risk, calling a backup safe before a restore has worked, and treating a quiet log as proof that nothing happened.

Take it further

  • Write a one-page incident runbook for a stolen laptop, then talk through it as a tabletop exercise.
  • Review how the upload page protects data in transit using what you learned about TLS and certificates.
  • Review your own accounts and home router, and apply two safe improvements.
  • Save your code and documents in a private repository, using only invented data.

Check your understanding

Quick check · 5 questions

of 5 answered You scored / 5 · perfect!

  1. 1. While reviewing, you notice a device outside the written scope that looks misconfigured. What should you do?

    Scope sets the limit of your permission. Report what you noticed and let an authorized person decide.
  2. 2. The log shows five failures and then a success for one account from one address. What is the most accurate finding?

    The records show the sequence, not who typed or what happened next.
  3. 3. Which is the best verification for a backup action?

    A backup is useful only if you can restore from it.
  4. 4. Why is a shared account a problem even when its password is strong?

    Individual accounts support accountability, least privilege and clean removal of access.
  5. 5. What belongs in the summary for a nontechnical owner?

    Decisions come first. Detailed evidence belongs in appendices.

Summary

  • Permission and scope come before any review, and this one is defensive.
  • Assets and harms give each risk its meaning.
  • Scores help you order work, but you still explain your judgment.
  • Logs show events, so keep facts apart from suspicions.
  • A hardening action needs an owner, a check and a way back.
  • A good report tells the reader what to do first and admits what is unknown.

Back to the path: Cybersecurity Foundations learning path

ติดตามความคืบหน้าของคุณ

สร้างบัญชีฟรีเพื่อติ๊กบทเรียนที่เรียนแล้วและเรียนต่อจากจุดเดิมได้บนทุกอุปกรณ์