{"id":1388,"date":"2019-01-03T17:26:41","date_gmt":"2019-01-04T01:26:41","guid":{"rendered":"http:\/\/www.hybridclassroom.com\/blog\/?p=1388"},"modified":"2019-01-03T17:26:41","modified_gmt":"2019-01-04T01:26:41","slug":"homemade-capture-the-flag-part-2","status":"publish","type":"post","link":"http:\/\/www.hybridclassroom.com\/blog\/?p=1388","title":{"rendered":"Homemade Capture-the-Flag, part 2"},"content":{"rendered":"\n<p>In the last post I was talking about the Homemade Capture-the-Flag competition that I&#8217;d created for my students as part of a culminating, end-of-semester activity. Students, working in teams, used their computers and technological\/programming skills to solve a series of puzzles that I&#8217;d created for them.<\/p>\n\n\n\n<p>As mentioned before, there are two main challenges in implementing the CTF: first, the creation of the problems themselves, discussed in the last post. The other challenge is programming the infrastructure that will manage the competition: the delivery of problems, solution submission, scoring, and leaderboard updating. <\/p>\n\n\n\n<p>To do this, I leveraged some of my website, PHP, and MySQL skills to create the small website that students would use to log in, read problems, submit answers, and access the leaderboard. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"313\" src=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-1024x313.jpg\" alt=\"\" class=\"wp-image-1389\" srcset=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-1024x313.jpg 1024w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-300x92.jpg 300w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-768x235.jpg 768w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database.jpg 1235w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The MySQL database consisted of three tables that teams of students would interact with. There is the <strong>users<\/strong> table which included their a <code>user_id<\/code> (a primary key), a team name (identified by the <code>email<\/code> field in the screenshot here), a hash of their password (<code>pass<\/code>, and the time\/date of the team&#8217;s last login.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"141\" src=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-users-1024x141.jpg\" alt=\"\" class=\"wp-image-1390\" srcset=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-users-1024x141.jpg 1024w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-users-300x41.jpg 300w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-users-768x106.jpg 768w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-users.jpg 1244w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The second table was the <strong>problems<\/strong> table, with fields for the <code>problem_id<\/code>, the <code>problem_num<\/code>, the problem itself (<code>statement<\/code>, the correct <code>answer<\/code>, and the <code>points<\/code> awarded for successfully solving the problem.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"356\" src=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-problems-1024x356.jpg\" alt=\"\" class=\"wp-image-1391\" srcset=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-problems-1024x356.jpg 1024w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-problems-300x104.jpg 300w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-problems-768x267.jpg 768w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-problems.jpg 1243w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Finally there was the <strong>successes<\/strong> table which identified for each problem successfully solved the <code>success_id<\/code>, the <code>problem_id<\/code>, the <code>solver_id<\/code> of the problem, and the time it was solved.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"577\" src=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-successes-1024x577.jpg\" alt=\"\" class=\"wp-image-1392\" srcset=\"http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-successes-1024x577.jpg 1024w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-successes-300x169.jpg 300w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-successes-768x433.jpg 768w, http:\/\/www.hybridclassroom.com\/blog\/wp-content\/uploads\/2019\/01\/database-successes.jpg 1242w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Manipulating these three tables with various queries allowed the site to display the Leaderboard with a running total for all teams: <code>SELECT users.email, SUM(problems.points) from users, problems, successes WHERE successes.solver_id = users.user_id AND problems.problem_id = successes.problem_id GROUP BY users.user_id ORDER BY SUM(problems.points) DESC<\/code><\/p>\n\n\n\n<p>For people who have worked with PHP, MySQL, and querying databases, putting together this kind of thing can range in difficulty from a trivial activity for an afternoon to a week-long exercise in PHP debugging hell. For myself, it was <em>just<\/em> enough of a challenge for me that I found the process to be entertaining and engaging.<\/p>\n\n\n\n<p>If you are not a PHP\/MySQL person and don&#8217;t have any experience with writing &#8220;normalized&#8221; databases, you may be wondering whether or not it would be possible to find some way to avoid this whole &#8220;build an entire database-driven website just so students can solve a few puzzles.&#8221; These are just puzzles, of course, each with a simple answer that a student could submit on paper or whisper in your ear. You&#8217;re still almost certainly going to have to deliver computer-based problems by computer, however\u2014a 6MB text file for students to search through, for example, is not something that you can hand out on paper\u2014and without the database, there&#8217;s no practical way to create a live leaderboard indicating who is in the lead at any point. For a do-it-yourself CTF, I&#8217;d strongly recommend finding a way to make the website experience happen.<\/p>\n\n\n\n<p>If you don&#8217;t decide to conduct your own Capture the Flag event, however, there are a number of publicly available competitions for high school-aged students that will work for your students. A quick search online will yield results for CTF events and their corresponding schedules.<\/p>\n\n\n\n<p>I encourage all Computer Science teachers to give these activities a try, and consider making them a part of your curriculum.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last post I was talking about the Homemade Capture-the-Flag competition that I&#8217;d created for my students as part of a culminating, end-of-semester activity. Students, working in teams, used their computers and technological\/programming skills to solve a series of puzzles that I&#8217;d created for them. As mentioned before, there are two main challenges in &hellip; <a href=\"http:\/\/www.hybridclassroom.com\/blog\/?p=1388\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Homemade Capture-the-Flag, part 2<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1388"}],"collection":[{"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1388"}],"version-history":[{"count":5,"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1388\/revisions"}],"predecessor-version":[{"id":1397,"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1388\/revisions\/1397"}],"wp:attachment":[{"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1388"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hybridclassroom.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}