1 00:00:08,580 --> 00:00:10,260 Good afternoon. 2 00:00:10,800 --> 00:00:13,480 It's a wonderful honor to be here today. 3 00:00:13,480 --> 00:00:17,460 Tonight, or this afternoon, I'm going to be talking about Capture the Flag. 4 00:00:17,920 --> 00:00:21,880 Capture the Flag is a contest we like to run at DEF CON. 5 00:00:21,920 --> 00:00:24,340 DEF CON, you're here. 6 00:00:24,380 --> 00:00:30,280 We've run Capture the Flag at DEF CON in Las Vegas for several years now. 7 00:00:31,160 --> 00:00:35,400 In 1996, the first Capture the Flag game at DEF CON was held. 8 00:00:35,880 --> 00:00:40,840 And in the year 2000, so after four years, they formalized how it was run. 9 00:00:40,840 --> 00:00:52,500 So for the first few years, how Capture the Flag worked at DEF CON was players would either bring software that they wanted somebody to hack for them, or they would hack somebody else's software. 10 00:00:52,660 --> 00:01:06,400 And the human judges that were authenticating and running the contest had to make the these decisions every time something got hacked, whether it was easy, whether it was hard, who got the points, and it was very, very confusing. 11 00:01:06,720 --> 00:01:13,680 So starting in the year 2000, the DEF CON goons running Capture the Flag created rules, and they created services. 12 00:01:14,640 --> 00:01:21,700 So starting in 2002 and running through 2004, a group called Ghetto Hackers took over Capture the Flag. 13 00:01:21,700 --> 00:01:29,380 And this is kind of how Capture the Flag became a name brand event, where the Ghetto Hackers had a different brand name, slightly different from DEF CON. 14 00:01:29,380 --> 00:01:31,500 They had continuity from year to year. 15 00:01:32,820 --> 00:01:36,920 Starting in 2005, a new team called Kenshoto took over. 16 00:01:36,920 --> 00:01:39,580 And this is also when I started playing Capture the Flag. 17 00:01:39,660 --> 00:01:45,560 Kenshoto had a much more difficult game that made a lot more people more interested in Capture the Flag. 18 00:01:47,200 --> 00:01:59,020 Starting in 2009, the next team called DD Tech and started running Capture the Flag themselves. 19 00:01:59,880 --> 00:02:07,580 And then, starting in 2013 and running up until last year, my team, the legitimate business syndicate, took over. 20 00:02:08,260 --> 00:02:15,160 And starting literally tomorrow, the new team, Order of the Overflow, is taking over running DEF CON Capture the Flag. 21 00:02:16,500 --> 00:02:22,700 So the way we think about Capture the Flag and how Capture the Flag works with DEF CON is that there are two distinct formats. 22 00:02:23,120 --> 00:02:26,220 This format is Jeopardy format, named after the U.S. 23 00:02:26,220 --> 00:02:27,200 game show. 24 00:02:27,320 --> 00:02:31,020 And how this works is teams pick a question or a challenge from this grid. 25 00:02:31,020 --> 00:02:34,680 They receive a prompt and solve the challenge for some points. 26 00:02:35,040 --> 00:02:38,120 The main part of this game is the scoreboard that we just saw. 27 00:02:38,300 --> 00:02:40,480 On the scoreboard, you find a prompt. 28 00:02:40,720 --> 00:02:46,900 In this case, the prompt is giving us a network address, including a port number and a file to download. 29 00:02:47,680 --> 00:02:49,960 From there, we solve the challenge. 30 00:02:50,200 --> 00:02:55,300 In a lot of cases, these challenges involve a lot of assembly programming or reading assembly. 31 00:02:55,300 --> 00:02:56,680 And they involve Python. 32 00:02:57,740 --> 00:03:04,680 Once the challenge has been solved, you return the answer to the question to the scoreboard for points. 33 00:03:04,880 --> 00:03:07,560 And then you go on to the next challenge. 34 00:03:07,620 --> 00:03:12,880 Right here, we see a handful of challenges that have been solved by somebody with different point amounts. 35 00:03:12,880 --> 00:03:19,560 And one challenge that has not been solved yet and that will give the person who solves it scoreboard control. 36 00:03:20,380 --> 00:03:25,880 So Defcon Capture the Flag qualifiers is one of the most famous Jeopardy-style CTFs in the world. 37 00:03:25,880 --> 00:03:32,780 But I'm going to talk about a challenge from a different event, the Shaw 2017 Capture the Flag contest. 38 00:03:32,780 --> 00:03:41,300 So Shaw 2017 was an outdoor computer festival held in the Netherlands last August, the week after Defcon. 39 00:03:41,300 --> 00:03:43,980 And I went there and had a wonderful time. 40 00:03:44,000 --> 00:03:49,220 And part of the wonderful time was a contest that the Dutch team Eindhoven ran at this event. 41 00:03:49,820 --> 00:03:52,660 I'm going to talk about a challenge called Asby. 42 00:03:52,720 --> 00:03:55,100 With Asby, we get a file. 43 00:03:55,100 --> 00:04:03,920 This is the prompt that has a little bit of backstory where their team member named Asby got a reputation for solving challenges the wrong way. 44 00:04:04,740 --> 00:04:09,240 So once I downloaded this file, I discovered it was a Windows executable. 45 00:04:09,620 --> 00:04:17,340 And because I just, like, downloaded this executable randomly from the internet, I decided to run it and figure out what I had to do. 46 00:04:17,700 --> 00:04:29,260 So the goal with this is we need to enter in the flag, and the executable will tell us if it's correct or not, and starting from here, how many characters are correct. 47 00:04:30,160 --> 00:04:32,740 So I need to guess the correct input. 48 00:04:32,820 --> 00:04:35,100 So I have three ways that I can do this. 49 00:04:35,100 --> 00:04:43,320 I can either reverse engineer a Windows binary, and I'm not very good at reverse engineering and I don't usually use Windows, so that was kind of out. 50 00:04:43,400 --> 00:04:53,220 I could guess each character by hand, which looked like it would take a long time, or I could write a program, which I foolishly believed would go really, really quickly. 51 00:04:55,880 --> 00:04:58,080 So I chose to write the program. 52 00:04:58,580 --> 00:05:00,280 And this is the program. 53 00:05:00,280 --> 00:05:08,640 It's a little Ruby script, and mostly what it does is it opens the wine emulator with the Asby executable. 54 00:05:09,060 --> 00:05:14,680 I hand guessed a bunch of the flag before I tried writing the program, so I have that part of the flag at the top. 55 00:05:14,760 --> 00:05:22,060 And then we just loop over and over, guessing which of our flag characters goes into the executable and tells us it's correct. 56 00:05:22,520 --> 00:05:28,220 If we get to a point where something weird happens, we print out what we have so far and exit. 57 00:05:29,220 --> 00:05:39,620 In theory, after a long time writing this program and switching back and forth between, oh, I can't program computers anymore, I'm just going to do this by hand, I eventually got the solution. 58 00:05:39,880 --> 00:05:44,180 The solution is right here, right above the stack trace, which is cool. 59 00:05:44,180 --> 00:05:51,540 I solved it, I got some points, the organizers gave me some beverages while I was sitting there, and I had a lot of fun. 60 00:05:51,680 --> 00:05:53,160 So that's Jeopardy style. 61 00:05:53,160 --> 00:05:56,480 You get a challenge, you solve it, and you get some points. 62 00:05:57,360 --> 00:06:02,860 This is the visualization from our finals game, which is an attack-defense format capture the flag. 63 00:06:02,880 --> 00:06:04,680 It's very, very different. 64 00:06:04,680 --> 00:06:13,940 Here we see teams shooting successful attacks at each other in a soundboard-themed, or like audio mixer-themed event. 65 00:06:14,460 --> 00:06:18,020 So how this works is all these steps happen at the same time. 66 00:06:18,020 --> 00:06:21,480 Teams are reverse engineering the challenges or the services. 67 00:06:21,480 --> 00:06:27,940 They're patching the flaws in the services at the same time they're trying to exploit other teams' services. 68 00:06:28,120 --> 00:06:32,580 And in all of this, they're trying to not break their own services to lose points. 69 00:06:33,620 --> 00:06:37,340 So here's a small example of how attack-defense works. 70 00:06:37,380 --> 00:06:41,460 At the top, we have the score bot, or the scoring system of the capture the flag game. 71 00:06:41,600 --> 00:06:47,980 On the left, we have PPP's service called AppMail, and on the right, we have a team called Shellfish. 72 00:06:49,020 --> 00:07:00,100 So, every round, the score bot deposits a new flag or a new piece of random data in PPP's AppMail service, and everybody else's services as well. 73 00:07:02,100 --> 00:07:13,660 Sometime during the round, Shellfish manages to send some network traffic to AppMail that causes it to disclose this flag, or as we call it, Shellfish has stolen the flag. 74 00:07:15,020 --> 00:07:21,620 Then, they take that flag, submit it to the score bot, or they redeem it to the score bot, and get some points. 75 00:07:23,220 --> 00:07:28,900 In the meantime, score bot is checking PPP's AppMail service to make sure it's working okay. 76 00:07:28,900 --> 00:07:30,160 Can it send messages? 77 00:07:30,160 --> 00:07:31,680 Can it receive messages? 78 00:07:31,820 --> 00:07:32,880 Is it happy? 79 00:07:33,880 --> 00:07:46,240 And, if PPP has broken their AppMail, if they've, you know, turned it off or deleted it, or just written a bad patch that makes it do things wrong, that's a failed availability check. 80 00:07:46,260 --> 00:07:56,580 And we assume that if there's a failed availability check, that Shellfish is also not able to steal from it, so we make a failed availability check lose a whole lot of points. 81 00:07:57,120 --> 00:08:00,800 And, again, this is the format we used for Defcon Capture the Flag finals. 82 00:08:01,700 --> 00:08:02,940 Here's an example. 83 00:08:02,940 --> 00:08:04,560 It's a service called Rubix. 84 00:08:04,560 --> 00:08:07,680 This is a service we put in place last year. 85 00:08:08,180 --> 00:08:19,700 How it works is teams connect to the Rubix service on another team, and it simulates this Rubix puzzle cube where you rotate the cube and try and get all the colours on the same side. 86 00:08:20,100 --> 00:08:22,260 But it's a virtual version of that. 87 00:08:22,340 --> 00:08:33,800 Teams submit instructions to rotate the cube into a valid configuration, and once the Rubix cube is happy, it executes the instructions as if they were CPU instructions. 88 00:08:34,940 --> 00:08:36,760 Which is kind of clever. 89 00:08:37,620 --> 00:08:42,200 So we're going to follow along with a write-up from a team called Lab Rats. 90 00:08:42,240 --> 00:08:44,940 They publish this write-up and we can follow along. 91 00:08:45,380 --> 00:08:56,860 So the first steps to solve this, the computers we used for Defcon CTF finals last year was one we made up, and it used 9-bit bytes instead of 8-bit bytes to make it miserable for teams. 92 00:08:57,200 --> 00:09:04,340 So they first had to write software that could deal with 9-bit traffic, which nobody has normally. 93 00:09:04,760 --> 00:09:13,760 Then they had to figure out what parts of these binaries were part of the standard C library, and what parts of these binaries were which functions in the C library. 94 00:09:14,640 --> 00:09:20,140 After that, they can figure out how the main gets called and what the part of the program that they care about actually is. 95 00:09:20,800 --> 00:09:27,520 Once they've done all that work, which took several hours, they could actually start analyzing what the service does. 96 00:09:27,860 --> 00:09:29,200 So what are they analyzing? 97 00:09:29,200 --> 00:09:30,740 How is it supposed to work? 98 00:09:30,740 --> 00:09:34,200 What is the benign traffic supposed to do? 99 00:09:34,880 --> 00:09:36,980 Once they figure that out, how can they attack it? 100 00:09:36,980 --> 00:09:39,380 How can they make the service release its secrets? 101 00:09:39,760 --> 00:09:43,480 And after they figure that out, they can try and figure out how to defend it. 102 00:09:43,480 --> 00:09:48,120 How can we prevent the service from revealing its secrets to other teams? 103 00:09:48,900 --> 00:09:52,220 So all this is in support of the game goals. 104 00:09:52,220 --> 00:10:00,160 You get points by capturing flags, you lose points by having flags captured, and you lose lots of points by failing availability checks. 105 00:10:01,100 --> 00:10:05,420 It's extremely complicated, it's extremely frustrating, but it's a lot of fun. 106 00:10:05,420 --> 00:10:09,720 For both organizers and most importantly, it's fun for players. 107 00:10:10,700 --> 00:10:12,180 But I should go back. 108 00:10:12,180 --> 00:10:15,720 Every kind of Capture the Flag game is extremely ambitious. 109 00:10:15,860 --> 00:10:20,840 Jeopardy style, they're extremely ambitious to run, they're difficult to play on purpose. 110 00:10:20,880 --> 00:10:23,580 Attack defense, also difficult. 111 00:10:24,340 --> 00:10:31,260 So some of our goals for Capture the Flag games are making them run smoothly, making them a fair contest, and having fun challenges. 112 00:10:31,520 --> 00:10:36,080 If the game doesn't run smoothly, players are going to get frustrated and find something else to do. 113 00:10:36,180 --> 00:10:39,500 If it's not fair, players aren't going to put in a legit effort. 114 00:10:39,620 --> 00:10:45,600 You know, if the same team is always going to win because they're friends with the organizers, why play? 115 00:10:45,640 --> 00:10:49,540 And if the challenges aren't fun, then the challenges aren't fun. 116 00:10:49,920 --> 00:10:52,460 So let's talk about running the game smoothly. 117 00:10:52,540 --> 00:10:57,900 And just like any big ambitious project, running a Capture the Flag game project starts early. 118 00:10:58,100 --> 00:11:03,920 And the most important part of it is who you're running it with, who is on the organizing team. 119 00:11:04,600 --> 00:11:14,400 So legitimate business syndicate is about half of us are friends from university that competed together then, and about half were people that worked together in 2012. 120 00:11:15,140 --> 00:11:18,520 So here's my friend Gino, kind of the team captain and I. 121 00:11:19,000 --> 00:11:24,620 Twelve years ago, we were participating in a college level contest, and we just solved a difficult problem. 122 00:11:24,620 --> 00:11:26,640 And we were very, very happy about it. 123 00:11:26,640 --> 00:11:30,920 And also a little bit weird from being in a windowless room all day. 124 00:11:32,820 --> 00:11:35,840 So how did we start to run DEF CON CTF? 125 00:11:35,840 --> 00:11:43,100 We found out during closing ceremonies at DEF CON 2012, that the previous organizers, DD Tech, were stepping down. 126 00:11:43,660 --> 00:11:51,060 In December, Gino realized that, hey , I should make a team that runs CTF because that's my dream. 127 00:11:51,320 --> 00:12:00,220 So he started talking to us, and I remember at a chicken wing restaurant, the day after Christmas is when he told me about this, and I was in. 128 00:12:00,760 --> 00:12:10,540 So in February 2013, we all got together in the same room, wrote down a proposal for how we wanted the game to work, and found out in March that the proposal got accepted. 129 00:12:10,780 --> 00:12:12,680 And then the real work began. 130 00:12:14,120 --> 00:12:16,800 So what is our group made out of? 131 00:12:16,940 --> 00:12:21,240 So about three quarters of the group are people that I would normally call reverse engineers. 132 00:12:21,680 --> 00:12:24,740 But people, you know, people aren't just their skills. 133 00:12:24,800 --> 00:12:27,140 And all these people have different specialties. 134 00:12:27,320 --> 00:12:32,380 So we have a radio specialist who did a lot of work on our 2014 Challenge Badger. 135 00:12:32,600 --> 00:12:42,820 We have several people who were good just with computer hardware in general, which was really useful for 2015, the year we brought, I think, 40 different computers to Las Vegas. 136 00:12:43,160 --> 00:12:50,780 And in 2017, the game ran on the work of our esoteric computing expert for the Clemency system. 137 00:12:52,020 --> 00:13:00,520 But besides reverse engineers, my friend Salir is just a genius when it comes to computer infrastructure of any kind. 138 00:13:01,020 --> 00:13:01,640 Networking. 139 00:13:01,640 --> 00:13:06,100 He can type commands into routers faster than I could just mash my fingers on a keyboard. 140 00:13:06,100 --> 00:13:07,740 I don't understand it. 141 00:13:08,420 --> 00:13:13,560 I worked on the database-backed web application because that's something I really enjoy. 142 00:13:13,840 --> 00:13:17,460 But the most important part is that people grow and change. 143 00:13:17,680 --> 00:13:20,000 I'm not the same person I was five years ago. 144 00:13:20,000 --> 00:13:21,100 None of us are. 145 00:13:21,260 --> 00:13:27,920 So whenever somebody, you know, grows into a new skill set or gets excited about something, don't say you're the web app person. 146 00:13:27,920 --> 00:13:29,240 Just deal with that. 147 00:13:29,700 --> 00:13:33,680 Like, if they're excited about something, that's a big benefit for everybody. 148 00:13:34,680 --> 00:13:39,540 And that means that players' role or team members' roles also grow and change over time. 149 00:13:40,140 --> 00:13:48,820 So if you are putting together a capture -the-flag team, either for playing or for organizing, think about who you know and who you know that you trust and who do you like? 150 00:13:48,820 --> 00:13:50,620 Who do you want to hang out with a lot? 151 00:13:52,480 --> 00:13:56,380 So once you've figured out who's on the team, you need to be able to talk to your team. 152 00:13:56,380 --> 00:13:58,420 And that's what communication is for. 153 00:13:58,940 --> 00:14:06,860 We, after the first year, we ended up using Slack or the chat program Slack for asynchronous chat basically all the time. 154 00:14:06,860 --> 00:14:11,020 It's great because you don't have to, you know, talk to somebody immediately. 155 00:14:11,020 --> 00:14:12,820 They'll just see the message later. 156 00:14:13,240 --> 00:14:22,440 We did eventually settle on having meetings every week, which is really, really useful to, you know, have these little iterations where you commit to something and get it done. 157 00:14:23,220 --> 00:14:27,700 But whenever we have an actual contest to run, we like to be all in the same place. 158 00:14:27,920 --> 00:14:32,480 So this is the rental house we had for our 2017 qualifiers. 159 00:14:32,560 --> 00:14:36,800 And this is right before the game starts where we're figuring out what order challenges get unlocked. 160 00:14:38,080 --> 00:14:50,260 Once we get to Vegas, we find it really nice to have a shared hotel room where we set up all the noisy computers and stash all the snacks and stash all the drinks, including lots of water because it's important to stay hydrated. 161 00:14:51,340 --> 00:14:55,020 And, you know, that's kind of our home base when we're in Vegas. 162 00:14:56,260 --> 00:15:02,160 And the snacks and the drinks are really, really important because your team is a team made out of people. 163 00:15:02,380 --> 00:15:07,540 And people, you know, people require food and snacks. 164 00:15:07,880 --> 00:15:12,980 So in 2014, we were having computer problems. 165 00:15:12,980 --> 00:15:25,680 One of the team's instances, their actual physical hardware was acting really flaky and it needed to get unplugged and plugged back in a lot, like more than any other team should. 166 00:15:25,740 --> 00:15:32,520 And it was causing a delay of the game because processes would be trying to talk to that machine and it was just not on. 167 00:15:32,600 --> 00:15:36,840 So I was on stage trying to figure out why the scoreboard was going slow. 168 00:15:36,840 --> 00:15:48,560 And Salir was walking back and forth between his computer on stage to read logs and the rack of hardware off the stage to unplug and plug it back in to power cycle the machine. 169 00:15:49,000 --> 00:15:52,560 And I was kind of like getting impatient with how things were going. 170 00:15:52,560 --> 00:15:57,120 And I just kind of asked him, how much longer is this going to take? 171 00:15:57,820 --> 00:16:01,340 And whenever he walked off stage, he didn't go to the hardware. 172 00:16:01,340 --> 00:16:03,260 He just kind of left the room. 173 00:16:04,300 --> 00:16:11,220 And Salir is normally like the most stable, level-headed, friendliest person. 174 00:16:11,220 --> 00:16:13,440 And that's not something that ever happens. 175 00:16:13,440 --> 00:16:17,720 And that really, really scared the rest of us running this game. 176 00:16:18,140 --> 00:16:22,760 And eventually after about half an hour, he came back with a drink. 177 00:16:22,760 --> 00:16:27,380 He came back with a sandwich and he solved the problem basically instantly. 178 00:16:27,720 --> 00:16:37,300 And what I'd kind of neglected was to think about what he needed, you know, both in emotional terms and also it was lunchtime and that's why we were both kind of crabby. 179 00:16:37,840 --> 00:16:44,520 So supporting the CTF players means supporting the organizing team and making sure everybody's well fed. 180 00:16:46,500 --> 00:16:52,720 The final point I need to talk about with smooth operation is that Capture the Flag software is still software. 181 00:16:52,980 --> 00:17:00,320 And just like any kind of software or any other computer system, the way to make this software work reliably is really screwed up. 182 00:17:00,320 --> 00:17:08,360 By the end, we could have another machine spun up in about five minutes and we usually had hot spares ready to go anyways, which was great. 183 00:17:09,660 --> 00:17:12,760 So next up, I'm going to talk about running a fair contest. 184 00:17:12,760 --> 00:17:25,860 And a fair contest is really challenging because Capture the Flag is a game about computer hacking, but DEF CON CTF is also a computer system, which means that we have to be really, really paranoid. 185 00:17:25,860 --> 00:17:30,600 And we have to worry about teams trying to hack the right service the wrong way. 186 00:17:31,680 --> 00:17:35,120 We also want to make sure that teams don't hack the wrong thing. 187 00:17:35,120 --> 00:17:37,060 We want them to hack a vulnerable service. 188 00:17:37,060 --> 00:17:39,260 We don't want them to attack the scoreboard. 189 00:17:40,300 --> 00:17:49,280 And for attack defense games, we have another problem where teams may want to fix a broken software the wrong way. 190 00:17:49,460 --> 00:17:55,440 And the way we eventually, you know, solve this is by restricting what players can do more. 191 00:17:55,980 --> 00:17:59,780 So for qualifiers, we tend to run services on separate hosts. 192 00:17:59,780 --> 00:18:03,940 And we eventually got to running multiple hosts in multiple locations. 193 00:18:04,280 --> 00:18:12,840 So for the different challenges we have in qualifiers, each one would get at least one machine per data center. 194 00:18:13,000 --> 00:18:14,500 So teams in the U.S. 195 00:18:14,500 --> 00:18:18,180 would connect to a data center in North Virginia or something. 196 00:18:18,220 --> 00:18:25,120 Teams in Europe would go to Ireland, Asia Pacific, wherever Amazon's Asia Pacific hub is, which was great. 197 00:18:25,120 --> 00:18:30,920 Teams got lower ping times and we didn't have to worry about the entire service getting screwed up globally. 198 00:18:32,200 --> 00:18:43,300 Next, each connection to a vulnerable service would get a separate container using the run C container run time and xinitd to actually manage the connections. 199 00:18:43,300 --> 00:18:54,700 Using xinitd also has a really nice benefit where instead of writing each service having to have its own, like, network handling code, we could write all these services as just standard in and out executables. 200 00:18:55,420 --> 00:19:04,460 And then finally, in 2015, what we started doing was limiting what system calls each service would be able to make using the set comp tools in Linux. 201 00:19:06,580 --> 00:19:11,300 Finals is a much more complex game with much more complex problems. 202 00:19:11,440 --> 00:19:18,640 And one of the problems that we had was we kept trying to keep the game about reverse engineering and not a game about operating system administration. 203 00:19:19,560 --> 00:19:35,180 Starting in 2013, what we did was each team, whenever they connected to their machine, instead of getting root or super user access, they'd get an unprivileged team account that all it could really do is overwrite the service binaries that then ran under their own accounts. 204 00:19:35,800 --> 00:19:43,560 So we had a problem starting that year, and it got really bad in 2014, and it was a phenomenon we called the Superman defense. 205 00:19:43,560 --> 00:19:49,960 After the comic book character who just, like, one of his special powers is, oh, he just doesn't get hurt ever. 206 00:19:50,260 --> 00:20:03,080 So some of the Superman defenses would be like a firewall rule that says this traffic coming from the scoring system is okay, let it through, but this traffic coming from an opponent team is not okay, so just block it. 207 00:20:03,080 --> 00:20:05,560 And we never let teams have firewalls that way. 208 00:20:06,280 --> 00:20:11,960 However, a Superman defense that was very successful was preventing the flag being read from disk. 209 00:20:12,760 --> 00:20:18,440 So teams would run the service in an emulator, and the emulator wouldn't have flag access, and that was that. 210 00:20:18,520 --> 00:20:26,440 And we tried to solve that with making legitimate pollers read the flag, but it didn't always fit into a service nicely. 211 00:20:27,600 --> 00:20:31,580 So what we learned was that the U.S. 212 00:20:31,620 --> 00:20:38,780 Defense Advanced Research Projects Agency, or DARPA, started this project called Cyber Grand Challenge in 2014. 213 00:20:39,680 --> 00:20:47,780 And one of their goals was to, or their one goal, was to build a capture the flag game for autonomous computers with extremely formal rules. 214 00:20:48,560 --> 00:20:57,780 So for their thing, instead of having, you know, just services on a disk that would run, they came up with new jargon for it called challenge binaries, or CBs. 215 00:20:58,060 --> 00:21:07,660 These CBs were all 32-bit x86 binaries, but they used a special executable format that had limited system calls and couldn't store state. 216 00:21:07,820 --> 00:21:13,460 So what this meant was that teams couldn't just break out of the jail, or they couldn't wrap it in an emulator. 217 00:21:13,600 --> 00:21:17,240 They had to solve these things the, quote, right way. 218 00:21:18,900 --> 00:21:31,660 Similar to that, instead of just launching exploits over a network, CGC gave us this idea of a proof of vulnerability, which was the same kind of executable, but it had a few extra functions it could do. 219 00:21:31,660 --> 00:21:42,700 It could declare that it was going to demonstrate that it could control registers of a target program, or leak memory from the target program, and the scoring system instead of the teams managed how they ran. 220 00:21:44,560 --> 00:21:55,020 So these were put in place to support this goal of offline evaluation, where teams connect to a website and they get the binaries, the challenge binaries that other teams are using. 221 00:21:55,200 --> 00:22:00,100 And whenever they go to patch it, they upload it to the team interface website again. 222 00:22:00,240 --> 00:22:04,740 Whenever they have an attack, they write a proof of vulnerability and submit it. 223 00:22:05,040 --> 00:22:10,480 So the scoring system then runs the availability checks and proofs of vulnerability and isolation. 224 00:22:10,720 --> 00:22:19,160 And the value there is that we can run those offline, or we can run them later in a way that's designed to be reproducible and auditable. 225 00:22:20,940 --> 00:22:26,380 So once we learned about that, in finals, we could bring some of that technology to our game. 226 00:22:26,420 --> 00:22:32,220 Starting in 2015, we would restrict what system calls vulnerable services could make. 227 00:22:32,440 --> 00:22:41,320 And in 2016, the day after the Cyber Grand Challenge, we ran our game using their same format, with challenge binaries with proofs of vulnerability. 228 00:22:42,160 --> 00:22:51,560 And then finally, for our last year, we ran the entire game in a limited emulator that didn't have a lot of hooks into the messy real world of Linux. 229 00:22:54,280 --> 00:22:58,980 Another part of our fair contest is releasing the scoring information after the game's over. 230 00:22:59,320 --> 00:23:05,580 For qualifiers, we release the, you know, scoring information and a little bit of that. 231 00:23:05,580 --> 00:23:15,680 For finals, we release just, here's the database dump from Postgres, here's all the binaries teams uploaded, here's packet captures for the entire game. 232 00:23:16,020 --> 00:23:22,400 And that meant that a lot of teams could spend time after the game analyzing what was being used against them. 233 00:23:22,440 --> 00:23:27,300 Third parties could audit the scores and figure out how the actual scoring system in the game worked. 234 00:23:30,360 --> 00:23:34,580 An important part of running a fair contest is thinking about accessibility. 235 00:23:34,700 --> 00:23:38,640 And accessibility can mean a lot of things, and all these things are important. 236 00:23:39,040 --> 00:23:43,760 Our first year, we had a challenge called Die Hard, which required sensitive timing. 237 00:23:43,880 --> 00:23:52,940 This was a problem because the name of the challenge was supposed to be a clue, based on a popular movie in the US, about what players had to do. 238 00:23:53,200 --> 00:24:00,640 And the timing was difficult if you were on a, you know, internet connection that wasn't super close to where the game was being run. 239 00:24:00,760 --> 00:24:06,720 And what we had to do in future years, well, that year we, you know, had a really bad solution. 240 00:24:06,720 --> 00:24:17,740 We told teams to rent space near our servers and play from there and write a program, which is like, I don't want to be in the middle of a CTF game renting new servers. 241 00:24:18,800 --> 00:24:23,500 Long term, what we had to do was we had to rethink how a lot of our challenges were being built. 242 00:24:23,500 --> 00:24:34,500 We had to remove this idea that, you know, teams should be familiar in, you know, United States online, you know, hacker culture from our game. 243 00:24:34,500 --> 00:24:38,300 We had to eliminate the whole idea of precise timing for our game. 244 00:24:38,300 --> 00:24:40,560 And I think our game improved for that. 245 00:24:41,500 --> 00:24:48,120 Some of the other accessibility issues are just the languages we use online in our official communication. 246 00:24:48,300 --> 00:24:52,400 Because not everybody's a, you know, the same language as you are. 247 00:24:52,660 --> 00:24:57,100 And a lot of people are going to use machine translation because it works. 248 00:24:57,280 --> 00:25:01,540 But you have to, you know, use shorter sentences, use smaller words. 249 00:25:01,600 --> 00:25:04,640 And it's difficult to get in that frame of mind. 250 00:25:04,640 --> 00:25:08,700 And I don't know if we did a great job, but we thought about it at least. 251 00:25:11,160 --> 00:25:16,700 So, the last aspect of Capture the Flag and what I've learned running it is this idea of fun challenges. 252 00:25:16,920 --> 00:25:24,780 And the fun challenges that we spent a lot of time on, that we think were the most successful, we went and broke expectations. 253 00:25:26,140 --> 00:25:31,280 One of the ones from 2015 was a challenge called DOS Fun For You. 254 00:25:31,400 --> 00:25:34,060 And there's one writeup for this online. 255 00:25:34,060 --> 00:25:41,480 And the writeup starts with discover this challenge is a DOS binary, the disk operating system from the 80s. 256 00:25:42,240 --> 00:25:47,960 And they discovered that the IDA Pro disassembly tool was doing it wrong. 257 00:25:47,960 --> 00:25:54,120 So, they ended up debugging their disassembler and patching it before they could actually start the reverse engineering. 258 00:25:54,660 --> 00:26:06,340 And some teams found out that they had to use the emulator we told them to use because if they used something else, if they used DOS box, it would get some of the subtle timing wrong and they'd have a bad time. 259 00:26:07,880 --> 00:26:12,160 Another fun one was our Badger challenge from 2015 finals. 260 00:26:12,160 --> 00:26:25,480 And what it was, was a service running on MSP430 microcontroller on physical hardware that communicated with other teams with the game network using a custom CDMA radio network. 261 00:26:25,660 --> 00:26:27,320 So, this is it right here. 262 00:26:28,160 --> 00:26:31,960 We had two versions, I think three different versions of this badge. 263 00:26:31,960 --> 00:26:34,020 We had the one for competing teams. 264 00:26:34,020 --> 00:26:38,160 We had the one for organizers and VIPs that showed game scores. 265 00:26:38,160 --> 00:26:44,420 We had the base station which was hung up on a string over the game area and had a bunch of wires hanging out of it. 266 00:26:47,360 --> 00:26:52,580 So, one thing that we learned from Cyber Grand Challenge was this idea of consensus evaluation. 267 00:26:53,380 --> 00:27:05,640 So, with most with a traditional attack defense game, whenever you patch a binary on your machine, your opponents don't get to see how the binary has been patched, they just notice that their attacks don't work anymore. 268 00:27:06,140 --> 00:27:17,200 And what CGC did was they introduced this idea called consensus evaluation, where whenever you patch or you replace a binary with a fixed one, everybody else gets to see that. 269 00:27:17,200 --> 00:27:24,000 Which means that if your patch isn't complete, other teams, you know, can still attack it. 270 00:27:24,060 --> 00:27:28,360 And it also means that if your patch is really good, other teams will start using it. 271 00:27:28,360 --> 00:27:41,740 But the important part of that is that now, instead of us releasing eight services over an entire weekend and only getting eight binaries, every time somebody patches it, there's a new binary that needs reversing. 272 00:27:42,160 --> 00:27:52,160 So, what I wanted to do with these quals challenges was I wanted to push teams into this idea that automated program analysis is important. 273 00:27:52,200 --> 00:27:57,220 You can't just, you know, open up IDA Pro, solve a binary, and then, you know, you're done. 274 00:27:57,220 --> 00:28:03,420 You need to start thinking about programs, not just as software that runs, but as input for other programs. 275 00:28:03,600 --> 00:28:14,160 So, I worked on this thousand cuts category in 2015, 16, and on a category called Crack Me 2000 in 2017. 276 00:28:14,460 --> 00:28:18,960 Each of these challenges had hundreds of binaries that required automated analysis. 277 00:28:19,580 --> 00:28:21,600 And I feel they were successful. 278 00:28:21,700 --> 00:28:29,020 I saw a lot of blog posts and a lot of write-ups about how to solve these that mentioned they'd never done automated program analysis before. 279 00:28:31,720 --> 00:28:35,620 Consensus evaluation and finals gave us some really funny moments. 280 00:28:35,860 --> 00:28:42,760 So, a player from a team that I'm going to refrain from naming walked up to the organizer's table and asked why they were losing points. 281 00:28:43,120 --> 00:28:45,520 You know, their service was being attacked. 282 00:28:46,040 --> 00:28:47,300 We looked at the scoreboard. 283 00:28:47,300 --> 00:28:48,940 It's like, yeah, your service is being attacked. 284 00:28:48,940 --> 00:28:50,040 That's why you're losing points. 285 00:28:50,040 --> 00:28:51,940 It's called capture the flag. 286 00:28:52,200 --> 00:28:57,720 But they claimed they were using the same binaries as the winning team and that it couldn't be that. 287 00:28:57,760 --> 00:29:00,600 And we just kind of, like, looked at them. 288 00:29:02,720 --> 00:29:06,740 And then they just kind of did this and walked away. 289 00:29:06,760 --> 00:29:20,000 Because what they realized was that the winning team had put a secret code in their, or a backdoor in their binary to allow them to attack anybody that didn't, that just used their binary without thinking about it. 290 00:29:20,340 --> 00:29:22,320 That was really funny. 291 00:29:22,320 --> 00:29:26,920 You know, we still laugh about just the expression on that guy's face all the time. 292 00:29:28,400 --> 00:29:31,440 So, the Rubik's service from 2017. 293 00:29:32,040 --> 00:29:34,140 A few minutes ago I mentioned how it worked. 294 00:29:34,140 --> 00:29:43,460 You upload the instructions to rotate a Rubik's cube and then if you've done it successfully, those instructions get evaluated as just CPU byte code. 295 00:29:44,000 --> 00:30:03,860 So, how this worked in practice was teams would start to write code to block the evil, whenever shellcode would come in, the scoring system would submit some that didn't steal the flag, but attacking players would submit shellcode that did try and steal the flag. 296 00:30:04,220 --> 00:30:14,840 So, defenders would start using the extra space in this binary and they'd patch it by saying this shellcode let it through, this shellcode block it, this code let it through, this code block it. 297 00:30:15,040 --> 00:30:34,960 So, what that meant was whenever a team would patch Rubik's, somebody that was already successfully attacking them would disassemble the binary, see their previous attack reflected in it, and have to build a new attack, which felt like the comments we got after the game were that this felt like a multiplayer game against other people. 298 00:30:35,000 --> 00:30:38,480 We were having, I was having a back and forth with somebody on this other team. 299 00:30:38,520 --> 00:30:40,900 They'd patch it, I'd write a new exploit. 300 00:30:41,080 --> 00:30:43,460 They'd patch it, I'd write a new exploit. 301 00:30:43,560 --> 00:30:49,640 And we also had to update the scoring system to, you know, create new good shellcode. 302 00:30:49,640 --> 00:30:55,220 But it was a lot of fun for the players and it just fascinates me. 303 00:30:56,240 --> 00:31:03,660 So, we've talked about running smoothly, we've talked about running a fair contest, and we've talked about fun challenges. 304 00:31:04,040 --> 00:31:10,040 This is not everything that we know about Capture the Flag, and this is not everything that there is to know about Capture the Flag. 305 00:31:10,320 --> 00:31:19,620 There's still a lot more to learn, and there's a lot more work ahead of us building new Capture the Flag games that create new opportunities for new players. 306 00:31:20,960 --> 00:31:23,320 CTF is not a huge community yet. 307 00:31:24,000 --> 00:31:27,360 How many people in here have never played a Capture the Flag game? 308 00:31:29,200 --> 00:31:32,580 Okay, that's actually really impressive. 309 00:31:32,660 --> 00:31:40,440 But I think in a lot of the world, there's still a lot more work that we can do to make Capture the Flag for new players. 310 00:31:41,440 --> 00:31:45,460 The best way to learn how to do Capture the Flag is to do it. 311 00:31:45,460 --> 00:31:54,380 Either play a Capture the Flag game, or once you're happy with that, build your own Capture the Flag game for your friends and for people that you like to play. 312 00:31:56,000 --> 00:32:09,860 Capture the Flag has given me five years with the best group of people I've ever worked with, and it's given me an amazing five years building a contest for the CTF community around the world, the friendliest and smartest community I know. 313 00:32:10,260 --> 00:32:12,380 Thank you for making it amazing. 314 00:32:12,860 --> 00:32:19,220 And if you're curious about DEF CON Capture the Flag, order The Overflow, the new DEF CON CTF organizers. 315 00:32:19,220 --> 00:32:23,000 They're starting their game tomorrow morning at 8am Beijing time. 316 00:32:23,000 --> 00:32:27,160 You can learn more about it at oooverflow.io