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.
- Get a puzzleIt might be a coded message, a strange file, or a practice website.
- Find the flagUse clues and free tools to uncover the hidden text.
- 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.
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.
Web
Web puzzles use a practice website built for the event. A website is made of code your browser reads, and you can read it too. Clues are often tucked into parts of the page you do not normally see.
Forensics
Digital forensics means looking for evidence left behind on a computer. A forensics puzzle gives you a file, a picture, or a long record of events called a log. The flag hides somewhere inside.
Reverse engineering
You are given a finished program, but not the code a person wrote. Your job is to work out what it does and what it is waiting for. It is like taking apart a toy to see how it works.
Binary and "pwn"
A binary is a program in the 1s and 0s a computer runs. This category studies how programs use memory, and how careless code can be tricked. It is the hardest group, so most beginners start elsewhere. It only ever happens on practice programs made for the contest. (Players say "pwn", said like "own".)
OSINT-lite
OSINT stands for open-source intelligence. It means finding facts from public information, like a photo or a map. In a beginner CTF, the "lite" version uses only the material the puzzle gives you. It is never about looking up real people.
Two ways to play: Jeopardy and attack/defense
Most CTFs for beginners use one of two formats.
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.
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.
Why a CTF is legal and ethical
Here is the rule every security pro follows: only test systems you own or have clear, written permission to test. A CTF gives you that permission. The targets are built for the game, and the organizers want you to attack them.
Real systems are different. Breaking into a real website, school network, game account, or phone without permission is illegal. Laws like the Computer Fraud and Abuse Act in the United States cover it. Even "just looking around" can count.
Fair game
- Challenges inside a CTF you signed up for
- Practice labs and tutorials built for learning
- Your own devices, with a parent or teacher's okay
- Following each event's rules
Never okay
- Real websites or apps you do not own
- School or family networks without permission
- Guessing other people's passwords
- Attacking another team's server outside the contest rules
The people who do this for a living are called ethical hackers. They always get permission first. Read the full story in What Is Ethical Hacking?
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
Warm-up: Inspect
Web50 ptsNothing 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.
Your browser can show you the code of any page. Right-click the page and look for "View page source" or "Inspect".
Press Ctrl+U (Cmd+Option+U on a Mac) to open the source. Then press Ctrl+F and search for the words hidden-note.
What you learned: browsers show you a page's code, so never hide a secret there. Real websites sometimes leak by mistake this way.Base64
Crypto100 ptsYou intercepted this odd message. It uses only letters, numbers, and a couple of symbols, and it ends with = signs. That is a clue. It is probably Base64, a way to write any data using just 64 safe characters.
Base64 is encoding, not secret-keeping. Anyone can undo it. That makes it a classic first CTF puzzle.
Q09ERUhTe2Jhc2U2NF9pc19ub3Rfc2VjcmV0fQ==Tool: Base64 decoder
The word "Base64" is in the title for a reason. The decoder tool below the message does the work for you.
Click "Copy the message into the decoder". The decoded text is the flag. Type it into the box, with the braces.
What you learned: encoding hides nothing. It only changes how data is written. Real secrets need encryption with a key.Caesar
Crypto100 ptsA Caesar cipher scrambles a message by moving every letter the same number of steps along the alphabet. Julius Caesar used the idea over 2,000 years ago. This flag was scrambled that way. Numbers and symbols stayed the same.
FRGHKV{vkliw_lw_edfn}Tool: shift slider
You know every flag starts with CODEHS. Slide until the start of the output reads CODEHS.
The letter C was moved 3 steps forward and became F. Set the slider to 3.
What you learned: with only 25 possible shifts, you can try them all. That is called brute force. Knowing the flag format is a big clue too.Needle in a Log
Forensics125 ptsA made-up web server wrote this log. A log is a diary a computer keeps about what happened. Almost every line is ordinary. One line is not, and it holds the flag.
Scrolling works, but searching is faster. Use the filter box to show only lines that contain your words.
Tool: log filter
Look at the second column. Most lines say INFO. Which kind of line is different, and why might it matter most?
Type ALERT into the filter box. One line is left, and it holds the flag.
What you learned: investigators rarely read every line. They filter to the part that matters. Real tools like grep do the same thing.Hex Bytes
Binary125 ptsComputers store everything as numbers. A byte is one small number, and one byte can be one letter. People often write bytes in hex, a counting system with 16 digits: 0 to 9, then a to f.
Here is how it works. The letter C is the number 67. In hex that is 43. In binary (just 1s and 0s) it is 01000011. This flag is written as hex bytes.
Tool: byte converter
Each pair of hex digits is one letter. The first pair, 43, is the C in CODEHS. Check the next pair, 4f, in the converter.
Set the converter to "Hex bytes to text". Copy the whole row of bytes from above and paste it in.
What you learned: letters are really numbers underneath. Reading hex and binary is the base of reverse engineering and binary puzzles.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.
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.
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.
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
- Take notes. Write down every idea you try, even the ones that fail. Later you will know what is left.
- Search the unknown. See a word or file type you do not know? Look it up. Experts do this all day.
- 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.
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.
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.