Please enable JavaScript to use CodeHS

// Cybersecurity for students

Capture the Flag for Beginners: Your First Hacking Puzzles

What is capture the flag? It is a safe, legal game where you solve security puzzles to find hidden text called a flag. Learn how CTF competitions work, then crack five beginner challenges right on this page.

CYBERSECURITY ~20 min No coding needed
$ ls notes.txt flag.txt $ cat flag.txt CODEHS{welcome_to_ctf} FLAG CAPTURED $
01 /The big idea

What is capture the flag?

You may know capture the flag as a game played outside with two teams. In cybersecurity, it is a puzzle contest on computers. People call it a CTF.

A CTF organizer builds practice challenges on purpose. Each one hides a secret piece of text called a flag. Your job is to solve the puzzle, find the flag, and type it in to score points. A flag usually looks like this: CODEHS{example_flag}

CTFs are one of the best ways to try hacking skills the safe way. Nothing real can break, and nobody gets hurt. That is why CTF for students has grown so fast, and why many cybersecurity competitions for middle school and high school use this format.

  1. Get a puzzleIt might be a coded message, a strange file, or a practice website.
  2. Find the flagUse clues and free tools to uncover the hidden text.
  3. Submit and scoreType the flag in. If it is right, you get the points.

New word: hacking just means using clever tricks to make a computer do something its designers did not plan. In a CTF, that is a game skill. Outside of a CTF, it needs permission. More on that below.

02 /The map

CTF categories: what kinds of puzzles are there?

CTF puzzles come in groups called categories. Pick one below to see what it means and a tiny example. You will try three of these in the mini CTF.

Crypto (cryptography)

Cryptography is the science of secret codes. A crypto puzzle gives you a scrambled message. You work out how it was scrambled and turn it back into plain words. Scrambling is called encrypting. Unscrambling is called decrypting.

Tiny exampleShift every letter 3 steps forward in the alphabet. CODE becomes FRGH. Shift back to read it.
03 /How contests work

Two ways to play: Jeopardy and attack/defense

Most CTFs for beginners use one of two formats.

Best for beginners

Jeopardy-style

Like the quiz show, you see a board of challenges sorted by category. Harder ones are worth more points. You pick any challenge, in any order. When you find a flag, you submit it and the scoreboard updates.

You can play alone or on a team. The mini CTF below is Jeopardy-style.

More advanced

Attack/defense

Every team gets its own practice computer system. You must protect your system from the other teams and also try to break into theirs. You score for both.

This needs teamwork and more skills, so players usually try it after a few Jeopardy contests.

05 /Your turn

Try a mini CTF: five flags to capture

This contest runs only in your browser. Nothing is sent anywhere, and everything is made up. Every flag looks like CODEHS{...}, so include the letters and curly braces when you submit.

Each challenge has two hints. Hint 1 is free. Hint 2 costs 20 points, so try the free one first. Your progress stays in this page only. If you reload, you start fresh.

Your score

0 / 500 pts
0 of 5 flags captured

Warm-up: Inspect

Web50 pts

Nothing on this card shows a flag. But a web page is more than what you see. It is built from code, and the code can hold notes that people leave for each other.

Your mission: find the flag that is hiding in this card's code.

Captured: What you learned: browsers show you a page's code, so never hide a secret there. Real websites sometimes leak by mistake this way.

All five flags captured!

Final score: 0 out of 500.

You just did real CTF skills: reading page source, decoding, brute forcing, filtering evidence, and converting bytes. What to try next:

  • Play a free beginner CTF, like picoCTF from Carnegie Mellon University. Check its site for current rules.
  • Learn how ciphers get stronger in the Caesar cipher tutorial and encryption and the modulus.
  • Dig into evidence with digital forensics.
  • Learn to code in Python or JavaScript. Scripts make harder puzzles easy.
  • Ask a teacher about starting a school CTF team.
06 /Gear up

The CTF toolkit

You do not need fancy gear. Most beginner players use free tools they already have.

  • Browser developer toolsPress F12 to see a page's code, hidden parts, and what it loads.
  • An online decoderFree sites such as CyberChef turn Base64, hex, and many other formats into text. Use ones your teacher approves.
  • A search engineNo one knows everything. Searching for the unknown word is a core skill.
  • A notes fileWrite down what you tried and what you found. It saves you from repeating work.
  • A plain text editorOpens odd files so you can read what is inside them.
  • A little PythonA short script can try all 25 Caesar shifts at once. Coding speeds you up later on.
07 /Why it matters

Skills and careers: where CTFs can lead

CTFs teach habits that cybersecurity teams use every day: stay curious, break a big problem into small steps, and keep notes. They also show you whether you like this kind of work.

Jobs that use these skills include:

  • Security analyst: watches systems for signs of an attack.
  • Penetration tester: is hired to test a company's systems, with permission, and report weak spots.
  • Incident responder: jumps in to stop and clean up after an attack.
  • Digital forensics examiner: finds and protects computer evidence.
  • Security engineer or developer: builds software that is hard to break.

Security teams also need many people who are not hackers: writers, teachers, managers, and lawyers. Everyone's skills help.

08 /Level up

How to start: your first real CTF

After this page, try a full contest. picoCTF is a free beginner-friendly CTF made by Carnegie Mellon University. It is built with middle school and high school students in mind, and it has practice challenges to play at any skill level. Check the picoCTF website for its current rules, ages, and schedule.

Many schools also run CTF clubs and teams. Ask your teacher or counselor if yours has one. A team makes it easier, since everyone knows different things.

Three tips that win more flags

  1. Take notes. Write down every idea you try, even the ones that fail. Later you will know what is left.
  2. Search the unknown. See a word or file type you do not know? Look it up. Experts do this all day.
  3. Try the simplest thing first. Look at the page source. Try a decoder. Read the file name. Most beginner flags hide behind easy steps.

Stuck is normal. Take a break, ask a teammate, or read a write-up after the contest ends. Learning from a solved puzzle counts.

09 /FAQ

Common questions about CTF for students

What is capture the flag in cybersecurity?

It is a safe, legal contest where you solve security puzzles to find hidden text called flags. Each flag you submit earns points.

Is CTF legal?

Yes, when you only work on the practice systems the organizers built. Trying the same moves on a real system without permission is illegal.

Do I need to know how to code?

No. Many beginner challenges use encodings, ciphers, and clues in files. Coding helps more as the puzzles get harder.

Are there cybersecurity competitions for middle school and high school?

Yes. Several events are made for students. picoCTF, from Carnegie Mellon University, is a free beginner-friendly option. Check each event's site for current rules, ages, and dates.

10 /Check yourself

Quick quiz

1. In a CTF, what is a flag?

2. Which of these is okay for a beginner?

3. You find the text SGVsbG8= in a puzzle. What should you try first?

Keep learning cybersecurity

You solved your first puzzles. Next, learn why the ethics rule matters, or explore full CodeHS cybersecurity courses with hands-on labs.

CodeHS cybersecurity courses go deeper on encryption, networks, and defending systems, all in safe practice labs.