Please enable JavaScript to use CodeHS

Capture the Flag Game!

By Jennifer Campbell

What is Capture the Flag?

two students holding flags on top of separate mountains

In cybersecurity, a Capture The Flag (CTF) competition is where participants solve various security challenges to capture hidden "flags" or pieces of information. CTFs are fun, practical learning experiences that simulate real-world cybersecurity scenarios. Within this lesson, you will have the opportunity to find "flags" by locating specific information using the View Page Source feature as well as other features that you will learn about. A flag is a secret word hidden somewhere on the site. Here is an example:


Keep track of all the flags you find!

Good luck!


Page Source Code

Did you know that you can see the underlying programming code of any web page? Could this be a potential risk? Could cybercriminals use this in a malicious way?

screenshot showing the View Page Source option in the right-click menu

The "view page source" option on a browser allows you to view the HTML, CSS, and JavaScript code that is being used to display the content you see. This option lets you peek behind the scenes and see the actual code that makes up the webpage!


It's a handy tool for understanding how different elements on a page are structured and styled, but could this be a potential risk? What important information might be stored in the code of a webpage?


Your Task


  1. Right-click on this page and choose View Page Source (If your right-click is disabled, copy and paste this into your web browser: view-source:https://codehs.com/tutorial/jennifer/capture-the-flag)
  2. What do you see? Anything interesting?

Find the Flags!

In this activity, you will find four flags (and an optional bonus flag) hidden somewhere within the website. Each flag will include a word. Keep track of the words.


Open the site in a new tab: Capture the Flag Site


1. The first flag is hidden in the site's source code. Use the View Page Source feature to find it. If your right-click is disabled, copy and paste this into your web browser: view-source:https://capturetheflag-8785761.codehs.me/index.html


2. In the source code, there is a style.css file. Search this file for the second flag. Take note of the web address of this file. How is it different than the original website?


3. In the source code, there is also a script.js file. Search this file for the third flag. Look at the web address here as well. What is the only part of the address that is different in each file?


4. Lastly, there is another file that is NOT listed on the website or in the source code. You can only access this file by typing it in the web address bar. To find this file, unscramble the following word and place it in the web address in the format shown:


  1. Unscramble this word: rescet
  2. Use the following format to navigate to the hidden file. Replace the blank before .txt with the unscrambled word and go to that site:


https://capturetheflag-8785761.codehs.me/___________.txt


5. Advanced Bonus Flag (Optional): Right-click on the image of the cat and save the file to your desktop. Open the file with a text editor (either Notepad on a Windows computer or TextEdit on a Mac). Find the bonus flag!

Learn More about Developer Tools


Read through the slides or watch the recorded video here.

Console Secrets


In this activity, you will explore the console using the developer tools to find two flags!


  1. Open this site in a new tab: Console Secrets
  2. Using your developer tools, go to the console and follow the directions.
  3. Write down the flag words that you find along the way!


If your developer tools are disabled, click on this link to complete a similar activity: Simulated Console


Reflection:

1. Warning messages and errors are listed in the console. Why might the developer of the website be interested in knowing these?

2. Why might a cyber criminal be interested in knowing a website's errors?


Local Storage


In this activity, you will explore local storage using the developer tools to find one more flag!


  1. Open this site in a new tab: Local Storage
  2. Using your developer tools, go to the console and follow the directions.
  3. Write down the flag word that you find along the way!


If your developer tools are disabled, click on this link to complete a similar activity: Simulated Local Storage


Reflection:

1. What could be a risk of keeping information in local storage?

2. How could you ensure that the information stored in local storage is secure?