Skip to content
BoKSA

B10. Capture the Flag (CTF)

B10. Capture the Flag (CTF)

Level Foundation and Intermediate, with a first look at Advanced
Prerequisites B1, B2, B4, B6; for Intermediate also B7, for the Advanced categories also B8
Study time About 8 hours to start (2 h reading and video, 6 h playing), then keep playing
Source Teach-the-Teachers fiche B10
Next topics B11 Penetration testing · B12 Roles and certifications

Why this matters

You cannot learn to swim from a book, and you cannot learn security only from slides. Capture the Flag (CTF) competitions and practice platforms give you a legal, safe place to solve security puzzles and work with deliberately vulnerable systems. Every challenge you solve gives you a flag: a secret piece of text, such as picoCTF{...}, that proves you succeeded.

CTFs are valuable because:

  • you learn by doing: Linux, networking, web, cryptography and forensics come together in one puzzle;
  • you see vulnerabilities in context, which makes theory from B6 and B8 concrete;
  • you train persistence and a structured approach, and experience the moment when all the puzzle pieces click together;
  • you learn to work in a team and to write up what you did, good practice for later reports;
  • employers notice: CTF results, platform profiles and write-ups are visible evidence of your skills;
  • it is fun, and there is a large, welcoming community.

Learning objectives

Foundation. After this topic you can:

  1. Explain what CTF stands for and why CTFs are useful.
  2. Explain the main types of CTF.
  3. Start a beginner challenge with confidence and know what to do when you get stuck.

Intermediate. In addition you can:

  1. Name some common platforms and tools for CTFs and use at least one platform.
  2. Work in a team on a CTF: divide tasks, share notes and document solutions.

Towards Advanced. You can also recognise the usual challenge categories, including steganography and cryptography, and solve beginner challenges in at least three of them.

Foundation: what a CTF is

Types of CTF

Type How it works Good for
Jeopardy-style A board of challenges in categories, each worth points. Solve one, submit the flag, earn points. Harder challenges are worth more Beginners and most online CTFs; you choose what to work on
Attack–Defence Every team gets identical vulnerable servers. You patch (fix) your own services while trying to capture flags from the other teams. You score for captured flags and for keeping your services running Experienced teams; the DEF CON CTF final is the famous example
King of the Hill Teams compete to take and keep control of a shared machine Competitive events
Wargames and practice platforms Permanent challenges with no time limit, to learn at your own pace Everyone, any time

The fiche names two main types: Jeopardy and Attack–Defence. The others are variations.

What is a flag, and why submit it?

A flag is a unique string hidden in the challenge, usually in a fixed format such as CTF{...}. You can only find it by solving the challenge. Submitting it to the scoreboard proves you solved it, awards your points and lets the organisers rank teams fairly without checking every solution by hand.

Rules and ethics

  • Attack only what the organisers say is in scope: the challenge servers. Attacking the scoreboard or platform infrastructure, or other players, is forbidden and can be illegal.
  • Do not share flags or solutions during a running competition. After it ends, publishing write-ups is normal and welcome.
  • Skills you learn in a CTF are still bound by the law outside the CTF (see B11): no testing of real systems without written permission.

How to get started

  1. Pick a beginner-friendly platform: picoCTF, CTFlearn or TryHackMe.
  2. Start in the easiest category, often General Skills, and do several easy challenges before moving on.
  3. Keep a notes file for every challenge: what you tried, what worked, links you used.
  4. Expect to be stuck. That is normal and is where most of the learning happens.

What to do when you are stuck

This answers the fiche question "What would help you if you are blocked in a CTF?":

  • Re-read the challenge title and description. They almost always contain a hint.
  • Look at everything you were given: file type, metadata, page source, the exact wording.
  • Search for unknown terms, error messages and file formats. Learning to search well is a core skill.
  • Take a break, then explain the problem out loud to a teammate (or a rubber duck). Many solutions appear while explaining.
  • Use the hints the platform offers. That is not cheating; it is how you learn.
  • Read write-ups after the event for challenges you could not solve, and redo them yourself.
  • Switch challenges. Coming back later with fresh eyes often works.

Intermediate: platforms, tools and teamwork

Challenge categories

Jeopardy CTFs sort challenges into categories. Each category trains a field you will meet in your career.

Category What it is about Links to Typical tools
General skills Command line, file handling, encodings, small scripts B2 Linux shell, Python, CyberChef
Web Finding flaws in web applications B6, B11 Browser developer tools, Burp Suite, OWASP ZAP
Cryptography Recognising and breaking weak or misused encryption B8 CyberChef, Python, CryptoHack for practice
Forensics Analysing files, disk images, memory and network captures to find what happened B9 Wireshark, file analysis tools such as binwalk
Steganography Finding information hidden inside other files, such as text hidden in an image or audio file B3 Image and file analysis tools such as stegsolve
Reverse engineering Working out what a compiled program does without its source code B2 Ghidra, GDB
Binary exploitation ("pwn") Understanding how memory errors in programs can be abused Advanced GDB and specialist tools
OSINT Finding information from public sources B7 Search engines, maps, metadata viewers
Networking Understanding protocols and traffic B1, B4 Wireshark, Nmap

Hiding a text in an image is called steganography (fiche question Q1). Unlike encryption, which makes a message unreadable, steganography hides the fact that there is a message at all.

Platforms

Platform Type Good for
picoCTF Jeopardy, permanent practice gym and yearly competition The best start; made by Carnegie Mellon University for students
CTFlearn Jeopardy challenges Short beginner challenges
TryHackMe Guided rooms and learning paths Learning with explanation alongside
OverTheWire Wargames Linux skills step by step; start with Bandit
Hack The Box Machines, challenges and CTF events Intermediate and beyond
Root Me Large challenge collection Every category, many levels
CyberTalents Challenges and competitions Practice by category and level
Cyber Security Base (University of Helsinki) Free online course with a CTF part Structured learning
CTFtime Calendar and ranking of all public CTF events Finding events to join

Competitions to know

  • European Cybersecurity Challenge (ECSC): the yearly European competition, supported by ENISA, where national teams of young talent compete. Countries run national selection competitions.
  • picoCTF for school and university students, and Google CTF, which has a beginner's quest.
  • Advanced competitions mentioned in the fiche: DEF CON CTF, PlaidCTF, Codegate and SECCON.

Teamwork

CTFs are usually team events, and teamwork is a learning goal in itself.

  • Divide by category: one person on web, one on crypto, and so on, but help each other when stuck.
  • Share notes live in a shared document or a team chat channel per challenge, so nobody repeats work.
  • Claim a challenge before you start ("I'm on web-200") to avoid duplicate effort.
  • Mix experience levels: pair beginners with experienced players.
  • Write up afterwards and hold a short retrospective: what did we learn, what would we do differently?

To find a team: start one with classmates, ask your study association, or look for student teams on CTFtime and in infosec communities.

Writing a write-up

A write-up explains how you solved a challenge. It helps you remember, helps others learn and shows employers how you think. A good write-up contains:

  1. the challenge name, category and description;
  2. your first observations;
  3. the steps you took, including dead ends, and why you took them;
  4. the solution and what you learned;
  5. how the weakness could have been prevented (the defender's view).

Only publish write-ups after the competition has ended.

Towards Advanced

In practice

Exercise 1: your first flags (Foundation, 2 h)

Create an account on picoCTF and open the picoGym. Solve at least five challenges in General Skills. For each, write two lines: what the challenge asked and what you learned.

Exercise 2: Bandit (Foundation, 2–3 h)

Play the first ten levels of OverTheWire Bandit. It teaches the Linux command line from B2 step by step. Keep a notes file with every new command you learned.

Exercise 3: three categories (Intermediate, 3 h)

On picoCTF or CTFlearn, solve at least one easy challenge in three different categories, for example cryptography, forensics and web. Write a full write-up of one of them using the five parts above.

Exercise 4: team CTF (Intermediate, one event)

Form a team of three to five students. Find a beginner-friendly online CTF on CTFtime (look for events marked for beginners or students) and take part. Agree beforehand how you divide categories and share notes. Afterwards, hold a 30-minute retrospective and publish one team write-up.

Exercise 5: class discussion (Foundation, 30 min)

Discuss the fiche questions in a group: What does CTF stand for? How many types are there? What are the advantages of CTFs? What is the difference between a CTF and testing a real system?

Tools

Tool Use Cost
CyberChef Encoding, decoding and data conversions in the browser Free
Linux command line (for example in a Kali Linux or Ubuntu VM, or WSL) The basis of most challenges Free
Python Small scripts to automate repetitive steps Free
Wireshark Network capture analysis Free
Burp Suite Community Web challenges Free
Ghidra Reverse engineering Free
CTFd Hosting your own CTF Free open-source version

Videos

Handouts and reading

Literature and courses

Common mistakes

  • Starting too hard. Begin with the easiest challenges; confidence is a learning goal (fiche LO3).
  • Giving up too quickly, or staying stuck too long. Set yourself a time limit, then use a hint or switch challenges.
  • Not taking notes. Without notes you cannot write a write-up or repeat the trick next time.
  • Copying write-ups without understanding them. Read, then solve it yourself.
  • Running unknown files from challenges on your own computer. Use a virtual machine.
  • Forgetting the rules: attacking the infrastructure or sharing flags during a competition.
  • Thinking CTF skills give permission to test real systems. They do not (see B11).

Check yourself

  1. What does CTF stand for?
  2. Name the two main types of CTF and explain the difference.
  3. What is a flag, and why do you submit it?
  4. Give three advantages of playing CTFs.
  5. What do we call hiding a text in an image?
  6. What can you do when you are stuck on a challenge?
  7. Why should you not publish a write-up during a running competition?
Answers

1. Capture the Flag.
2. Jeopardy-style: a board of challenges in categories, solved for points. Attack–Defence: teams protect their own vulnerable servers while capturing flags from the other teams' servers.
3. A secret string hidden in the challenge that you can only find by solving it. Submitting it proves you solved it and earns your points.
4. For example: learning by doing in a legal setting; seeing vulnerabilities in context; training persistence; teamwork; visible evidence of skills for employers; fun.
5. Steganography.
6. Re-read the description, inspect everything you were given, search for unknown terms, take a break, explain it to a teammate, use hints, switch challenges, and read write-ups afterwards.
7. It gives away the solution to other players and is against the rules; publishing after the event is fine.