1 00:00:12,320 --> 00:00:18,240 Welcome back to the second day of live CTF here at the DEF CON CTF finals. 2 00:00:18,700 --> 00:00:21,400 I'm Zita2 and I'm here with Mark. 3 00:00:21,400 --> 00:00:22,200 Mark Griffin here. 4 00:00:22,200 --> 00:00:24,000 Yep, so we're jumping back into it. 5 00:00:24,000 --> 00:00:25,560 Same format as we've been doing. 6 00:00:25,560 --> 00:00:27,120 Excited to see this challenge. 7 00:00:27,120 --> 00:00:28,460 Yeah, this is going to be great. 8 00:00:28,460 --> 00:00:32,500 I think let's not keep this for long. 9 00:00:32,500 --> 00:00:39,440 Let's get the game started and then we can talk more once they have started looking at the challenge. 10 00:00:39,440 --> 00:00:41,460 So I'm just going to get a final confirmation from production. 11 00:00:41,460 --> 00:00:42,280 We have that. 12 00:00:42,280 --> 00:00:51,760 So we're going to start the second round of the second day in 5, 4, 3, 2, 1, go. 13 00:00:51,760 --> 00:00:52,960 All right. 14 00:00:52,960 --> 00:00:54,460 Let's jump over and see. 15 00:00:54,460 --> 00:00:58,400 Yep, let me just find this. 16 00:00:58,400 --> 00:01:04,180 So we have the teams participating in this match that we're casting. 17 00:01:04,960 --> 00:01:08,660 Shellfish versus TWN48. 18 00:01:10,540 --> 00:01:16,520 Yeah, this is in the lower bracket of the tournament. 19 00:01:16,640 --> 00:01:21,640 So whoever loses this match is unfortunately eliminated from the tournament. 20 00:01:21,860 --> 00:01:25,100 Yeah, there's definitely a lot on the line. 21 00:01:25,100 --> 00:01:30,600 But with the double elimination bracket, they also have the chance to go all the way back up and win the whole thing. 22 00:01:30,600 --> 00:01:31,280 Right. 23 00:01:31,280 --> 00:01:40,300 So maybe they just had a bit of a rusty start yesterday and now they will just go all the way back to the top. 24 00:01:40,460 --> 00:01:45,160 And we can see we've got Shellfish over here already digging into the code. 25 00:01:45,160 --> 00:01:46,660 It's a Python challenge. 26 00:01:47,300 --> 00:01:50,540 And so they've got the whole challenge right in front of them. 27 00:01:50,540 --> 00:01:51,700 They can read the code. 28 00:01:51,700 --> 00:01:53,760 They just have to figure out what to do. 29 00:01:54,020 --> 00:01:56,280 And so I think we saw a prompt already. 30 00:01:56,420 --> 00:02:01,720 And this is an interesting problem. 31 00:02:01,720 --> 00:02:05,220 I wanted to do a riff on a standard Python jail. 32 00:02:05,220 --> 00:02:15,200 So Python jail problems are, hey, we're going to establish some sort of constraint that makes it hard to do arbitrary things from within the jail. 33 00:02:15,280 --> 00:02:20,960 Instead, this one is more of a, it looks kind of like a jail, but it's actually a bytecode problem. 34 00:02:20,980 --> 00:02:21,400 Right. 35 00:02:21,400 --> 00:02:29,740 So roughly they have to provide some Python code that goes through a filter. 36 00:02:31,280 --> 00:02:43,980 But then after the filter, they are allowed to swap out the bytecode, which is part of the whole code object. 37 00:02:43,980 --> 00:02:46,180 So they can basically modify the code object. 38 00:02:46,180 --> 00:02:58,780 And this way they can then change the code from doing something that passes the check, supposedly something benign, into something malicious that will get them there. 39 00:02:58,780 --> 00:02:59,380 Yeah. 40 00:02:59,380 --> 00:03:02,160 And so there's not a ton of code in this. 41 00:03:02,160 --> 00:03:06,600 There's enough that it's, you know, they've got to take a little bit of time and read through it. 42 00:03:06,600 --> 00:03:17,880 There's some stuff that sounds like it's debug related, which does kind of mirror real world problems where developers leave in some extra debug functionality. 43 00:03:17,880 --> 00:03:21,700 They didn't intend it to go into production and can be leveraged. 44 00:03:21,700 --> 00:03:22,020 Yeah. 45 00:03:22,020 --> 00:03:25,020 So a little bit of... 46 00:03:25,020 --> 00:03:29,160 So I was attempting to try to solve this challenge. 47 00:03:29,160 --> 00:03:33,700 I also noticed that, well, we don't have the camera on, but our banner is falling down behind us. 48 00:03:33,700 --> 00:03:34,860 But that's fine. 49 00:03:36,040 --> 00:03:37,460 We're overcoming today. 50 00:03:37,460 --> 00:03:37,920 Yeah. 51 00:03:38,980 --> 00:03:51,000 No, but what I was going to say that, yeah, there is like a bunch of stuff in the code, almost like, you know, decoy code or like stuff that's not quite relevant. 52 00:03:51,000 --> 00:03:58,060 Which I think it's, we kind of balanced this a little bit by most of the challenges we have are like compiled machine code. 53 00:03:58,640 --> 00:04:05,680 But very, very minimal, like pretty much all the code in the challenges are relevant to the solution. 54 00:04:05,680 --> 00:04:07,480 In this case, it's Python. 55 00:04:07,480 --> 00:04:09,540 So it's like by default, more readable. 56 00:04:09,580 --> 00:04:13,420 But then there's a little bit more stuff there that you don't actually care about. 57 00:04:13,420 --> 00:04:13,680 Yeah. 58 00:04:13,680 --> 00:04:17,200 And it's just trying to toe that line, right? 59 00:04:17,200 --> 00:04:26,280 Get it so it's not going to be solved in like five minutes, but it's not too hard that you can separate the chaff from what actually matters here. 60 00:04:26,280 --> 00:04:37,760 And we've already seen the competitors looking at that, the code module, which allows you to build these Python objects, which is ultimately what we're going to see modified. 61 00:04:37,760 --> 00:04:38,000 Right. 62 00:04:38,000 --> 00:04:45,120 And if we switch over to Shellfish here, you can see that they are playing around, having a more dynamic approach. 63 00:04:45,120 --> 00:04:47,680 You know, trying various inputs. 64 00:04:47,680 --> 00:04:52,000 You saw that they were running the program with various inputs. 65 00:04:52,000 --> 00:04:57,560 You see like the answer is they are looking at what different objects are available. 66 00:04:57,700 --> 00:05:04,200 This looks to me a little bit like the approach you would take if you were to the jail challenge. 67 00:05:04,200 --> 00:05:07,260 You're looking at like what various attributes. 68 00:05:07,260 --> 00:05:21,060 In Python, there's a lot of like reflection and like various ways to access, you know, like parent objects and global kind of meta objects and stuff like this. 69 00:05:21,220 --> 00:05:21,960 Exactly. 70 00:05:21,960 --> 00:05:30,760 And, you know, with a problem like this, I certainly expected that maybe they could come up with something that I didn't expect and they'd bypass the check and win that way. 71 00:05:30,760 --> 00:05:32,640 I'm not open to anything here. 72 00:05:32,680 --> 00:05:44,640 These competitors, not only have they seen and studied Python jail problems from the past, but they may even have stuff in their back pocket that is non-public, you know, bypass type stuff that could come into play here. 73 00:05:44,640 --> 00:05:45,900 Yeah, definitely. 74 00:05:45,900 --> 00:05:55,080 I mean, it would not be the first time we saw, you know, zero days and so on at the DEF CON CTF. 75 00:05:55,080 --> 00:05:57,600 So, yeah. 76 00:05:57,860 --> 00:06:06,260 Let's switch back over to TWN and you can see them like going around in the code. 77 00:06:06,260 --> 00:06:12,380 I feel like they are taking a more static analysis approach to the problem. 78 00:06:12,380 --> 00:06:17,820 And they're also, though, because this is a Python problem, it's very easy to modify. 79 00:06:17,820 --> 00:06:26,740 And I think I've seen both players do something along these lines, but certainly TWN48, they're changing the code at least to make it more readable. 80 00:06:26,740 --> 00:06:38,160 But they're also thinking, hey, I can just skip this or add an extra print here, changing the challenge a little bit so that they can understand what they've got to deal with. 81 00:06:38,160 --> 00:06:41,900 And you can see the comment there, cannot call built-in and function. 82 00:06:42,860 --> 00:06:52,060 So they're like, you know, kind of like figuring out the implications of the constraints that are given in this problem. 83 00:06:52,400 --> 00:06:56,760 Also, like looking here, cannot use DEF and class. 84 00:06:56,980 --> 00:07:02,360 So they're like, you know, just trying to figure out what the playing field is here. 85 00:07:02,360 --> 00:07:07,080 Yeah, and both competitors immediately trying to find the bounds of what they can do. 86 00:07:07,080 --> 00:07:08,700 I think that's a great approach. 87 00:07:09,100 --> 00:07:16,340 It is kind of interesting to see what the limits are, because the limit is done at that bytecode level. 88 00:07:16,660 --> 00:07:19,760 So they may not be used to seeing that. 89 00:07:19,760 --> 00:07:22,360 I know that writing this challenge, it was interesting to see. 90 00:07:22,360 --> 00:07:28,920 I was checking a lot of different things that competitors might do and making sure that the filter was sort of going to stop those things. 91 00:07:28,920 --> 00:07:29,940 Right. 92 00:07:29,940 --> 00:07:38,540 We saw there that CWM, they were trying to define a lambda function, but they were having some problems with that. 93 00:07:38,540 --> 00:07:42,420 So, you know, we'll see how that turns out. 94 00:07:43,060 --> 00:07:48,720 If we can switch over to Shellfish here, I see them highlighting some of these functions. 95 00:07:48,720 --> 00:07:54,100 This is really some keyword checking is what's going on here. 96 00:07:54,100 --> 00:07:56,840 And you can see that there's some different if conditions here. 97 00:07:56,840 --> 00:08:01,540 I see that they've highlighted AI log text, which looks like it's logging. 98 00:08:02,100 --> 00:08:07,620 There's also another function you can see sort of sandwiched in between those that's different AI log code. 99 00:08:07,620 --> 00:08:13,900 And that's really the it's a little bit of an innocuous sounding function, but really what they're going to be most interested in. 100 00:08:13,900 --> 00:08:14,560 Right. 101 00:08:14,760 --> 00:08:15,080 Yeah. 102 00:08:15,080 --> 00:08:28,260 So I think a lot of the, as we kind of mentioned, like a lot of the initial work here will be focused on trying to like separate, you know, what are we actually interested in here? 103 00:08:28,260 --> 00:08:32,600 Like which part of this code actually is relevant? 104 00:08:32,600 --> 00:08:43,260 Yeah, and this is this is actually a problem that I've been very fascinated about recently, which is when you're looking at a whole file full of Python, how do you understand how these functions relate to each other? 105 00:08:43,260 --> 00:08:44,980 How do you understand the overall whole? 106 00:08:45,140 --> 00:08:50,020 I actually feel like the linear view, actually reading the code is a pretty inefficient way to do it. 107 00:08:50,020 --> 00:08:55,260 If you could see all of the functions sort of arranged, I feel like it would give you a big advantage in this case. 108 00:08:55,260 --> 00:08:56,040 Right. 109 00:08:56,520 --> 00:09:11,620 That's, you know, get some kind of flow view, some flow visualization, like a call graph and, you know, something like this to help you understand the flow that these things are going through. 110 00:09:11,620 --> 00:09:17,620 Yeah, because in this case, there's really one core module here that that is being used for that bytecode manipulation. 111 00:09:17,620 --> 00:09:22,460 And so obviously anything related to that module is going to be very interesting to the compiler. 112 00:09:22,460 --> 00:09:28,100 And speaking of that module, we can switch over to TWN again. 113 00:09:28,100 --> 00:09:36,160 I saw, let's see if it comes up again, but it looked like they were looking into the documentation around the code module. 114 00:09:36,160 --> 00:09:42,460 And, oh, it seems like... 115 00:09:42,460 --> 00:09:50,220 It looks like they're trying to figure out what keywords do I need to put in to get to the different functions there. 116 00:09:50,220 --> 00:09:52,760 And so they were looking at AI log code, I think. 117 00:09:54,920 --> 00:09:59,060 And they're adding print statements again to make it easier for them to debug. 118 00:09:59,060 --> 00:10:01,400 Hey, how do I get to this spot? 119 00:10:01,400 --> 00:10:14,220 And I think, yep, you can see that they're enumerating what each of these words as they relate to a bit field, they're sort of like binary flags packed. 120 00:10:14,620 --> 00:10:18,320 And they're seeing that this is a function of interest. 121 00:10:18,360 --> 00:10:23,220 And I think we're on the right track here to see them explore this. 122 00:10:23,220 --> 00:10:34,100 So it was cool to see how they went from testing the bounds of the Python jail to enumerating what these keyword functions were. 123 00:10:34,320 --> 00:10:34,400 Yeah . 124 00:10:34,400 --> 00:10:49,940 And maybe start trying to figure out how they can circumvent these things or what things they are going to need to care about more here. 125 00:10:49,940 --> 00:10:57,340 So this AI log code function, what is it doing? 126 00:10:57,340 --> 00:11:06,760 Yeah, so really you can see the argument input obj is the same code object that they put in earlier. 127 00:11:06,760 --> 00:11:09,060 And so it has to pass a filter check. 128 00:11:09,060 --> 00:11:22,900 But then you can see, if you get a good look at the code again, it also allows the user to, so that defend the eggs prompt is saying, hey, take in some more input here and then we're going to do something with it. 129 00:11:22,900 --> 00:11:26,020 And it looks like they're exploring exactly what they can do with it here. 130 00:11:26,340 --> 00:11:29,120 But it's going to modify that code object. 131 00:11:29,120 --> 00:11:40,900 And so that really the path to exploitation here is to understand that you have to set up an object that has the pieces that you want in order to run your payload. 132 00:11:40,900 --> 00:11:43,400 But it still needs to bypass that filter. 133 00:11:43,400 --> 00:11:45,860 That's very nice. 134 00:11:45,860 --> 00:11:54,680 And I think we just saw here that they just tried inputting this hex string here. 135 00:11:54,680 --> 00:12:00,400 They just took like the string hello and sent it as this additional input. 136 00:12:00,400 --> 00:12:02,860 So now we have like a Python crash. 137 00:12:03,880 --> 00:12:07,540 Right, because it's raw bytecode is what is being selected. 138 00:12:07,540 --> 00:12:10,340 So it's platform specific, interpreter specific. 139 00:12:11,180 --> 00:12:18,680 I expect that they will quickly move from trying to put raw hex into it to getting some sort of bytecode production. 140 00:12:19,340 --> 00:12:27,020 And this is a little bit of a challenge when it comes to solving this, right? 141 00:12:27,020 --> 00:12:32,820 Because they need to kind of match the version running on the server, right? 142 00:12:32,880 --> 00:12:34,240 For the Python. 143 00:12:34,240 --> 00:12:34,800 That's right. 144 00:12:34,800 --> 00:12:37,600 I believe there's a comment in the code that says what it was tested on. 145 00:12:37,600 --> 00:12:39,440 And they can verify that. 146 00:12:40,900 --> 00:12:43,940 Yeah, I think it will print out the version. 147 00:12:43,940 --> 00:12:50,740 So if they connect to the, if I remember correctly, like if you connect to the server, it will print out the version as well, right? 148 00:12:50,740 --> 00:12:52,960 You can also query using this. 149 00:12:52,960 --> 00:12:55,360 Right, since you can execute code. 150 00:12:55,360 --> 00:12:55,760 Right. 151 00:12:55,760 --> 00:12:56,140 Yeah. 152 00:12:56,700 --> 00:13:02,960 That was the way we made it so that they can use the remote servers to get the rights. 153 00:13:02,960 --> 00:13:16,920 And I want to go over back to TWN because I saw that they had a, you know, here they're like printing the, like they have the disassembly of the bytecode. 154 00:13:16,920 --> 00:13:19,920 So you can see there's a load constant and return value. 155 00:13:20,340 --> 00:13:20,780 Right. 156 00:13:21,180 --> 00:13:23,920 There's a hidden debug function that allows them. 157 00:13:23,920 --> 00:13:26,140 And so, again, this is trying to point them in the right direction. 158 00:13:26,140 --> 00:13:37,300 Hey, we'll show you this object, give you an idea of what's in it, which should help you understand how to solve it, which is, you know, modifying that bytecode as we talked about. 159 00:13:37,300 --> 00:13:37,760 Right. 160 00:13:37,760 --> 00:13:44,520 And maybe just, you know, to kind of explain this for people who might not be like too familiar with Python. 161 00:13:44,520 --> 00:14:11,040 So like the Python programming language, you have like a bunch of different implementations of this with the kind of standard one that most people use is CPython, which when it executes Python code, it will take the human readable text code, do all the parsing and so on and compile this into an internal bytecode format. 162 00:14:11,040 --> 00:14:15,240 And then it will execute that within its virtual machine. 163 00:14:15,500 --> 00:14:15,620 Right . 164 00:14:15,620 --> 00:14:30,420 So they are allowed to modify like not the text code that they send in, but like the bytecode that the interpreter has produced after, you know, parsing and so on the code. 165 00:14:30,420 --> 00:14:31,040 That's right. 166 00:14:31,040 --> 00:14:34,420 It's almost the lower level language. 167 00:14:34,420 --> 00:14:54,960 So you're typing the text, your print hello world that we're seeing, but really what they're going to want to do here is they're going to want to take the code that they want to run at that high level language and then get the bytecode that does the equivalent and then stuff that into the code object that they're able to modify. 168 00:14:56,560 --> 00:14:57,300 Yep. 169 00:14:57,440 --> 00:15:03,500 And let's see if we can see what's going on here with TWN48. 170 00:15:03,500 --> 00:15:07,460 They're looking at the filter again. 171 00:15:07,600 --> 00:15:11,080 They've got the debug output going on. 172 00:15:11,080 --> 00:15:15,840 So they're starting to think about, okay, what is really possible here? 173 00:15:15,840 --> 00:15:30,540 I'm not sure that I've seen them look and see if they've found the code modification bit, but that is the first hint that we tell them that it's perhaps not the problem that it first appears to be. 174 00:15:30,540 --> 00:15:31,780 It's not a Python GL problem. 175 00:15:31,780 --> 00:15:33,220 It's more of a patching problem. 176 00:15:33,220 --> 00:15:34,160 Right. 177 00:15:34,160 --> 00:15:44,760 So at this stage, I would say that Shellfish might be just a little bit ahead in the progress. 178 00:15:45,600 --> 00:15:56,920 And let's switch over to them and see that they are, in fact, I think you could see it there very briefly, but they were compiling some code there in the script. 179 00:15:57,710 --> 00:16:00,920 So they have this test script. 180 00:16:00,920 --> 00:16:02,040 You can see there. 181 00:16:02,040 --> 00:16:06,180 So they have these two calls to compile command. 182 00:16:06,640 --> 00:16:09,600 And they have two different code inputs. 183 00:16:09,600 --> 00:16:13,080 I think this is very much along the right line. 184 00:16:13,080 --> 00:16:27,740 They are trying to, well, if I would guess, they might be trying to produce two different text inputs, which result in maybe the same byte code or different byte code. 185 00:16:27,740 --> 00:16:35,600 And they're trying to see how changing the text of the code changes the compiled result of that. 186 00:16:35,600 --> 00:16:35,840 Exactly. 187 00:16:35,840 --> 00:16:40,680 You can see that they've got this fn.replace.co.code. 188 00:16:40,680 --> 00:16:43,240 That's exactly the construct that they've got in the challenge. 189 00:16:43,240 --> 00:16:43,260 Right. 190 00:16:43,260 --> 00:16:50,760 So they have basically taken the whole big program and they have distilled it down to the core thing that's going on here. 191 00:16:50,760 --> 00:16:57,120 And then moved that out into a small test environment, which is excellent. 192 00:16:57,120 --> 00:16:58,320 Great approach. 193 00:16:58,320 --> 00:17:08,800 And you can see in that other terminal window there, you can see the byte code, that load name, load const, very simple operations there. 194 00:17:08,800 --> 00:17:13,740 But it also is going to refer to these strings, for example. 195 00:17:13,740 --> 00:17:15,100 The strings aren't in the byte code. 196 00:17:15,100 --> 00:17:16,200 They're being referenced. 197 00:17:16,280 --> 00:17:22,280 And so what they're determining now is how do I end up with the things that I want to have happen? 198 00:17:23,060 --> 00:17:24,920 The references have to line up. 199 00:17:24,920 --> 00:17:25,420 Right. 200 00:17:25,540 --> 00:17:30,060 And I think you can see that they're printing out these various attributes of the code object. 201 00:17:30,120 --> 00:17:36,920 So if I were to take a guess, they realize that they can only change those... 202 00:17:37,500 --> 00:17:38,120 The byte code. 203 00:17:38,120 --> 00:17:38,900 The byte code. 204 00:17:38,900 --> 00:17:41,300 So they need to make sure that all the other things agree. 205 00:17:41,300 --> 00:17:42,020 Exactly. 206 00:17:42,020 --> 00:17:56,160 But if we go back to TWN, we can see here that they're also looking at the documentation for the compile command function and doing some... 207 00:17:56,800 --> 00:17:59,420 Yeah, looks like they're looking right at it. 208 00:18:14,440 --> 00:18:15,200 Yeah. 209 00:18:16,660 --> 00:18:17,540 And it's funny. 210 00:18:17,540 --> 00:18:23,060 If you look at the documentation for this, a lot of the documentation is kind of like, don't poke around with this. 211 00:18:23,060 --> 00:18:25,600 It's negative and you should be using other stuff. 212 00:18:25,600 --> 00:18:25,980 Yeah. 213 00:18:25,980 --> 00:18:30,600 But here we're a competition for hackers and that's what we're asking them to do. 214 00:18:30,600 --> 00:18:30,960 Right. 215 00:18:30,960 --> 00:18:40,540 And you can see here they were copying the system command and trying to... 216 00:18:40,540 --> 00:18:44,500 They have here a piece of code that they want to run. 217 00:18:44,500 --> 00:18:46,920 So this is kind of the goal, I think. 218 00:18:46,920 --> 00:18:56,860 But now I guess they're trying to get... this looks like they were trying to figure out the byte code of this. 219 00:18:56,860 --> 00:19:03,500 So what they probably kind of missed there is that they need to compile that code into code object and then get the code attributes. 220 00:19:03,640 --> 00:19:12,460 Yeah, they're definitely in the phase of understanding the primitives that they have, the code module itself, and what they can do with it. 221 00:19:12,460 --> 00:19:13,000 Right. 222 00:19:13,000 --> 00:19:17,080 And I want to switch back over to Shellfish because you can see here now there's some progress on their script here. 223 00:19:17,080 --> 00:19:18,960 You can see the two pieces of code. 224 00:19:18,960 --> 00:19:24,600 They have print high and import OS and now comparing these two things. 225 00:19:24,860 --> 00:19:32,000 And what I think is an important thing that they will want to look at is this list of constants. 226 00:19:32,000 --> 00:19:42,100 The CO constants there, you can see there is a high in one of them and... OK, no, they're only printing one object, so it's high in all of them. 227 00:19:42,820 --> 00:19:46,880 So, yeah, definitely look like some progress there. 228 00:19:46,880 --> 00:19:55,460 But then that's exactly the approach, though, is they're looking at, hey, I've got two objects and I understand I can only change one of these other things. 229 00:19:55,460 --> 00:20:00,500 What do these other parts need to be so that when I do make the swap, it'll all work? 230 00:20:00,500 --> 00:20:01,160 Right. 231 00:20:01,460 --> 00:20:05,100 I feel like they're making great progress and they're on the right track. 232 00:20:05,660 --> 00:20:06,420 Yep. 233 00:20:06,620 --> 00:20:13,140 And they're here again looking at just a little bit of documentation for the compile command function. 234 00:20:13,220 --> 00:20:16,000 Yeah, this is actually a key detail here. 235 00:20:16,120 --> 00:20:29,020 That compile command, the third argument there, the eval argument, controls how the input is going to be parsed, whether it's a single expression, whether you can do multiple expressions, a whole block of code like a module. 236 00:20:29,020 --> 00:20:29,460 Right. 237 00:20:29,460 --> 00:20:46,980 And this explains why, so it's set to eval, which is a single expression, which explains why earlier when TWN were trying to define their lambda function, because an assignment in Python is not an expression, it's a statement. 238 00:20:46,980 --> 00:20:50,680 So you cannot have that in an eval context. 239 00:20:50,680 --> 00:21:09,000 However, with the new walrus operator that was, well, relatively recently introduced in Python, you can have an assignment as a statement. 240 00:21:09,960 --> 00:21:20,660 I actually wrote a little bit of a blog post about this, how this enables you to write certain types of these Python payloads more easily with this. 241 00:21:20,660 --> 00:21:28,300 Yeah, so if they would have changed the code that they had, it was like A equals lambda something something. 242 00:21:28,300 --> 00:21:34,200 If they would have just added a colon to the assignment thing there, that would have worked fine. 243 00:21:34,280 --> 00:21:38,800 They would still not have been able to call that function, but they could have defined it, right? 244 00:21:38,800 --> 00:21:40,980 Right, and that's exactly what I was talking about. 245 00:21:40,980 --> 00:21:45,440 When you've got competitors at this level, I totally expect stuff like that. 246 00:21:45,440 --> 00:21:49,680 The walrus operator was not something I was thinking about when I was writing this challenge. 247 00:21:49,680 --> 00:21:51,860 But it's modern, right? 248 00:21:51,860 --> 00:21:55,640 Python 3.10, we've got some extra tools in the toolkit. 249 00:21:55,640 --> 00:22:01,820 Right, and if we do switch over to TWN, we see that they are looking at these code objects. 250 00:22:01,940 --> 00:22:06,840 You can see that they did compile a piece of code, and they were looking at what different attributes. 251 00:22:07,000 --> 00:22:12,080 And now googling again about the code attributes. 252 00:22:12,280 --> 00:22:18,700 Yeah, and that co underscore code, that is the key to zero in on here, so I'm glad that we've got both competitors looking at that. 253 00:22:19,400 --> 00:22:21,540 And that's just the byte code. 254 00:22:22,040 --> 00:22:22,720 Right. 255 00:22:22,720 --> 00:22:24,260 As we've talked about. 256 00:22:24,260 --> 00:22:24,880 Yeah. 257 00:22:24,880 --> 00:22:28,720 So the larger code object has these other pieces. 258 00:22:29,200 --> 00:22:33,760 I think that they've both realized they have the ability to modify that co underscore code. 259 00:22:34,440 --> 00:22:39,400 So at this point, it's off to the races who can figure out exactly how to use that to gain execution. 260 00:22:39,400 --> 00:22:50,320 Yeah, and I feel like, even though I still think Shellfish is a little bit ahead, I feel the gap has become smaller. 261 00:22:50,320 --> 00:22:50,680 Definitely . 262 00:22:51,100 --> 00:23:03,720 Because TWN is definitely in the right area here, looking at these, compiling this code, looking at how it behaves in various contexts like exec here. 263 00:23:03,740 --> 00:23:09,720 So yeah, it's definitely still very much an open game. 264 00:23:09,720 --> 00:23:15,800 Yeah, I think that we see this in all sorts of challenges where one competitor will find something. 265 00:23:15,800 --> 00:23:18,220 That's the insight that they need. 266 00:23:18,220 --> 00:23:20,240 They'll sprint ahead to the next roadblock. 267 00:23:20,240 --> 00:23:22,860 And then it's really, it's not over. 268 00:23:22,860 --> 00:23:29,320 They get a temporary advantage, but then the other competitor can bust through that insight and then maybe overtake them really quickly. 269 00:23:29,320 --> 00:23:30,360 It stops and starts. 270 00:23:30,360 --> 00:23:31,240 Absolutely. 271 00:23:33,100 --> 00:23:45,400 Looking here at Shellfish again, you can see now that they have the thing they want to do down there. 272 00:23:45,400 --> 00:23:54,440 There was an interesting approach where they make use of a second layer of evaluation. 273 00:23:54,440 --> 00:24:09,160 So it seems like their goal is to just take the thing they want to execute, put it in a string, and then in their initial code just print that string, but then in their second code do eval on that string again. 274 00:24:09,160 --> 00:24:09,960 That's right. 275 00:24:09,960 --> 00:24:11,980 I really like this approach. 276 00:24:11,980 --> 00:24:26,100 And whenever we see somebody jumping back to the rule page there when they're close to the end, we are watching out because that shows them exactly what they need to run to win the challenge. 277 00:24:26,100 --> 00:24:27,340 It looks like they're very close. 278 00:24:27,340 --> 00:24:30,340 They've got the sort of secret keyword there, which is omelet. 279 00:24:30,340 --> 00:24:33,940 Again, I don't think that's the first time we've seen reference to eggs and shells. 280 00:24:34,100 --> 00:24:36,620 So Python shellcode kind of challenge here. 281 00:24:36,620 --> 00:24:43,900 I think they were going back to the info page because we released the hint there. 282 00:24:43,900 --> 00:24:49,100 So you can see the hint that said this is not a jail problem, it's a patching problem. 283 00:24:49,100 --> 00:24:52,840 These competitors both see what the problem is. 284 00:24:53,880 --> 00:24:56,280 I think we're pretty close here. 285 00:25:01,960 --> 00:25:05,800 It's going to be really cool to see there if they can get this going. 286 00:25:05,800 --> 00:25:09,620 They seem like they're making some small changes to the exact code they want to run. 287 00:25:09,620 --> 00:25:13,880 Yeah, try and subprocess instead of OS system. 288 00:25:14,000 --> 00:25:14,480 Right . 289 00:25:14,660 --> 00:25:20,960 And you can see here they are going straight for running the submitter binary instead of popping a shell. 290 00:25:20,960 --> 00:25:31,660 So that's a good opportunity to talk about how the goal of this challenge is to solve the challenge and it will always end in you getting code execution on the server. 291 00:25:31,660 --> 00:25:38,660 And then on the server you have a small binary called submitter which you need to run to kind of prove that you have code execution. 292 00:25:38,700 --> 00:25:44,240 So most of the times you usually just go for like popping a shell and then you manually run that binary. 293 00:25:44,240 --> 00:25:48,740 But here you're baking in the submitter run straight into the code. 294 00:25:49,140 --> 00:25:50,040 That's right, yeah. 295 00:25:50,040 --> 00:25:54,260 And the reference solution that I wrote was more of the shell approach. 296 00:25:54,260 --> 00:26:03,020 But I can see that just looking to iterate, get that submitter run, feels it is close. 297 00:26:03,060 --> 00:26:03,680 Yep . 298 00:26:07,060 --> 00:26:19,340 And over on the TWM side, we have again some more progress around investigating these code objects, compiling stuff, printing these objects, trying to like... 299 00:26:19,340 --> 00:26:28,180 It seems like this person is not that familiar, so they're trying to just understand how these things work. 300 00:26:28,460 --> 00:26:33,300 What are these attributes and how do they interact with each other? 301 00:26:33,300 --> 00:26:36,520 Right, looking at that eval, understanding exactly how it works. 302 00:26:36,520 --> 00:26:42,620 So I'm dropping the keyword omelette in there and trying to understand, okay, what does this need to be? 303 00:26:42,620 --> 00:26:45,700 Is this going to cause problems if I need to have it in there? 304 00:26:45,700 --> 00:26:50,500 But yeah, zeroed in on the ALogCode function so that they know they need to get in there. 305 00:26:50,500 --> 00:26:53,780 It's just a question of what's the next step. 306 00:26:53,780 --> 00:26:58,120 I actually want to go back again to Shellfish because I saw some really interesting progress here. 307 00:26:58,120 --> 00:27:03,200 You can see they compiled the code, they're inputting this, and they win. 308 00:27:03,840 --> 00:27:04,880 I think they ran it. 309 00:27:04,880 --> 00:27:05,220 They win. 310 00:27:05,220 --> 00:27:07,220 I think they dropped the hex bytecode in there. 311 00:27:07,220 --> 00:27:09,360 Do we have the confirmation? 312 00:27:09,580 --> 00:27:10,760 Yep, Shellfish won. 313 00:27:10,820 --> 00:27:11,820 Shellfish takes it. 314 00:27:11,820 --> 00:27:13,840 So very, very good job. 315 00:27:14,040 --> 00:27:16,280 Let's switch over here. 316 00:27:16,380 --> 00:27:21,640 It went from they kind of had it and then suddenly they won. 317 00:27:21,640 --> 00:27:23,840 So that's really, really cool to see. 318 00:27:23,840 --> 00:27:25,000 Great job. 319 00:27:25,640 --> 00:27:30,000 Congratulations, Shellfish, advancing to the next round. 320 00:27:30,000 --> 00:27:34,700 Unfortunately, that means goodbye to TWM. 321 00:27:34,700 --> 00:27:37,040 Yeah, best of luck to them in the rest of the finals. 322 00:27:37,040 --> 00:27:39,440 But this was really a great challenge to see. 323 00:27:39,440 --> 00:27:42,080 Both competitors start moving down the right track. 324 00:27:42,080 --> 00:27:45,240 Really, I feel like they kept up their lead. 325 00:27:45,380 --> 00:27:53,160 But this was actually one of the problems that I think we thought internally was potentially a harder one that might have gone the distance. 326 00:27:53,160 --> 00:27:53,840 Oh, absolutely. 327 00:27:53,840 --> 00:27:58,900 I think because it's like, you know, maybe not something you're not quite as familiar with. 328 00:27:59,040 --> 00:28:02,320 So, yeah, definitely... 329 00:28:04,080 --> 00:28:05,980 Yeah, could have been definitely a challenge. 330 00:28:05,980 --> 00:28:06,780 Could be stuck. 331 00:28:06,780 --> 00:28:08,240 To be fair, we do have... 332 00:28:08,240 --> 00:28:14,520 So in this tournament, this is a good time to mention this, is that we are running two matches in parallel. 333 00:28:14,560 --> 00:28:14,900 Right. 334 00:28:14,900 --> 00:28:18,100 So we are commentating one of the matches. 335 00:28:18,380 --> 00:28:21,180 But then there's another match going on simultaneously. 336 00:28:21,180 --> 00:28:23,060 And that one has not finished yet. 337 00:28:23,080 --> 00:28:26,840 Yeah, and all of these competitors are from DEF CON finals teams. 338 00:28:26,840 --> 00:28:29,060 So everybody is top, top tier. 339 00:28:29,240 --> 00:28:35,120 We do give the teams a little bit of a heads up in that they know that this is a Python challenge coming in. 340 00:28:35,120 --> 00:28:40,260 So they're probably sending in their people who are the very best on their team at dealing with Python. 341 00:28:40,580 --> 00:28:42,460 Yeah, totally. 342 00:28:42,540 --> 00:28:47,520 And I mean, it's really, you know, the pressure, the stress of being there. 343 00:28:47,540 --> 00:28:50,020 Just you, no help from your team. 344 00:28:50,380 --> 00:28:53,240 You know that you're kind of like representing your whole team. 345 00:28:53,240 --> 00:28:55,980 And there's a bunch of points on the line for this. 346 00:28:56,140 --> 00:28:57,180 It adds up. 347 00:28:57,180 --> 00:28:57,440 Right. 348 00:28:57,440 --> 00:29:02,240 So definitely not an easy task to play these matches. 349 00:29:02,240 --> 00:29:03,440 Yeah, a lot of pressure. 350 00:29:03,440 --> 00:29:10,700 And again, you can't, it can't be understated or overstated how much the fatigue is going to set in. 351 00:29:10,700 --> 00:29:12,460 We're in day two of the finals. 352 00:29:12,460 --> 00:29:13,940 Tomorrow is going to be even tougher. 353 00:29:13,940 --> 00:29:14,500 Yep. 354 00:29:14,500 --> 00:29:19,960 And before we go to a break here, let's bring up the bracket. 355 00:29:20,340 --> 00:29:25,340 We do have, as we said there, Shellfish beating TWN. 356 00:29:25,340 --> 00:29:32,020 We still have the Orge crowd versus Pigbuttsad going on in the background. 357 00:29:33,020 --> 00:29:40,420 So, yeah, the winners of these two matches actually will face off in the next round, which will be coming up... 358 00:29:40,420 --> 00:29:41,360 Very shortly. 359 00:29:41,360 --> 00:29:42,300 Very shortly. 360 00:29:42,340 --> 00:29:46,380 So it's going to be exhausting for the players. 361 00:29:46,380 --> 00:29:47,920 Yeah, that's tough. 362 00:29:47,920 --> 00:29:54,840 But I think when we were putting the bracket together, it was, hey, somebody is going to have to play back to back to jam in all of these matches. 363 00:29:54,840 --> 00:29:56,420 That's just the way it's going to have to be. 364 00:29:56,420 --> 00:30:01,420 So I think that's it for now. 365 00:30:01,860 --> 00:30:03,300 It was a great match. 366 00:30:03,300 --> 00:30:08,240 Really cool to see these teams approaching this problem. 367 00:30:08,640 --> 00:30:11,020 And, yeah, we will go to a break. 368 00:30:11,020 --> 00:30:15,100 We will be back with the next match in a bit. 369 00:30:15,100 --> 00:30:20,420 You can check out, if you want to see the raw feed from the other match, we're just streaming the screens without any commentary. 370 00:30:20,420 --> 00:30:25,800 You can go to livectf.com and there will be links there to the YouTube channel and so on. 371 00:30:27,020 --> 00:30:30,520 But otherwise, yeah, we will be back in a bit. 372 00:30:30,840 --> 00:30:31,340 Yeah. 373 00:30:31,420 --> 00:30:32,620 Yeah, great match. 374 00:30:32,620 --> 00:30:34,120 Great commentating with you, Carl. 375 00:30:34,120 --> 00:30:35,020 Yeah, it was great. 376 00:30:35,020 --> 00:30:37,800 And I will be back for the next match. 377 00:30:38,000 --> 00:30:42,100 And, yeah, they will see you later. 378 00:30:42,100 --> 00:30:42,680 Yep. 379 00:30:42,720 --> 00:30:43,280 Great. 380 00:30:43,280 --> 00:30:43,840 Till then. 381 00:30:43,840 --> 00:30:44,400 Bye.