I think it's live now. Welcome back to the second round of live CTF. I'm still here, Carl, ZD2, but I have replaced Jordan with Mark. Hello. Hi, I'm Mark Griffin. I've been around the CTF community for a while, big into vulnerabilities and secure software, and I'm really into explaining bugs and visualizing bugs, so I'm really excited for this. Yeah, this is going to be awesome. We are going to get straight into it, so I'll just check with the production that we are ready to go, and then we'll do a countdown of 5, 4, 3, 2, 1, go. All right, so the teams are off to the races. In this match, again, same thing as before, we have two matches running in parallel. We are casting one of them. This match is Shellfish versus NorseCode, and I'm really excited about this because I was pretty much the person who founded NorseCode a couple of years ago. I guess you are a bit excited about this match as well. Yeah, that's right. This bug has a lot of history. This is a really cool one to me because this bug was found over 20 years ago. This is a famous bug called the crack adder bug found by Mark Dowd, and originally this bug was found with manual auditing, as in just looking through the source code and seeing this bug, which is pretty incredible. But what made it famous was several years later it was popularized by Howard Blake, who pointed it out as this is the kind of bug that's difficult to solve automatically with program analysis or symbolic execution techniques. So today, these competitors, fast forward 10 years, they have all of these techniques at their disposal. So I'm interested to see if anybody tries to solve it with anger or other symbolic execution tools. Yep, it's going to be super cool to see. Let's take a look at what the two players are doing. If we can start by going to NorseCode here, we can see a bit of an IDA window in the background, but also diving straight into starting to write the exploit script. Again, like in the last match we saw, using Python with PwnTools, a very popular choice. Oh yeah, it really helps to be able to get your script going real fast, have everything in place, and then you're just filling in the blanks once you find the bug. Right. So we can see here that the player from NorseCode is looking at this main... there's kind of like a parsing function in here, right? Yeah, exactly. And they're going through the code, renaming variables. You can see that there was a P, there was a C, there was a current. Trying to figure out what's going on here, really. And we see there like... is that a conveniently placed address to the system function there as well? Yeah, so this is definitely something that's designed to be solved quickly. It's really getting at the heart of the head-to-head competition and trying to solve these things quickly, I think, is what makes this competition so exciting. Yeah. So I think we can then switch back over to... well, not back, but switch to Shellfish for the first time and just see what they're doing. Also, using IDA, we are four out of four on IDA so far as the reverse engineering platform of choice. You can see them looking at... looking at the same piece of code here. Yeah, I think this is really interesting because this is the part when they're starting to figure out what are the key tokens or key characters that are driving the parsing because they know that there's a bug. This is a small target. They know that there's probably a pretty easy bug or at least something isn't right here. And so watching this part is really exciting to me because it's just a matter of time until you see it happen in their head when they figure out going from reading the code to, oh, I see it, and then they'll start writing their overflow or at least testing what they think is their theory. Yeah, and it's a really interesting challenge. I test solved this challenge internally within the LiveCTF group. And I actually, just for fun, I decided to try to just run a fuzzer. I'm not knowledgeable in fuzzing, but I was like, I'm just going to try it for this. And it did, in fact, find the crash pretty much immediately. But I had such a hard time converting the fuzz, like the crash example, into anything useful that I could actually write and exploit out of. So I had to kind of go back, start over, and do a more manual approach to actually be able to solve the challenge. Yeah, and that's one of the things here. So this same bug was featured in the DARPA Cyber Grand Challenge 2015-2016 timeframe, and it was solved by the competitors in that match, by automating competitors, but using fuzzing. Fuzzers work really well against this target, and so I don't see that either of the competitors were watching or trying any fuzzing. But as you said, sometimes fuzzing, you still have to go through the effort of cleaning up the crash that you get. And in this particular case, there's only so many characters, and so if you have a really messy-looking crash, it may not be obvious what the bug is. And I want to switch over a bit to NorseCode's side again. I saw that, you know, they started... Yeah, you can see here they're running it in the debugger. You know, classic, inputting a bunch of As just to see what's going on. Comparing this with the code and seeing what's going on. You can see they're grabbing an offset there as well. Yeah, adding, you know, some debugs. We're probably going to set a breakpoint. Yeah, exactly. So, you know, they're kind of setting up their environment, you know, wiring everything up to do the further analysis for this. Yeah, and it's really interesting for me. One of the things I love to see, especially in a competition like this, is to see the tools that everybody uses and the different strategies. Pretty much everybody's going to use a debugger, but it is really cool to see just top competitors like this and what their different techniques are about how they understand a program. Right. And I was just about to say that we have pretty much the exact same setup for every player so far, but that's not true. Because if we look here at Shellfish, they're using Jeff as their GDP add-on framework, which I mentioned in the previous match that there are two big names here currently, and it's PonyBug and Jeff. And we saw that the NorseCode player was using PonyBug and the Shellfish player is using Jeff. I'm a Jeff guy. Yeah, me too, me too. I started out with Peta, and then it stopped being maintained, I think, or so. It got a bit outdated. Someone came up with PonyBug, and I think PonyBug grew kind of big and heavy. And then someone came up with Jeff, which is a bit more slimmed down, but in my opinion contains everything that I care about, really. Yeah. So, yeah. Well, and one thing that I want to bring up on that note is that some people, I mean, the GDB experience out of the box is very, very vanilla, but it's easy to sort of underestimate how much of a difference it really makes to have a clean display of your information. So like the color coding, it's not an accident that these color codings are, you know, very similar across because it allows you to build an intuition and see, oh, hey, this pointer, this is a code pointer, a stack pointer, a heap pointer, or like this is where my input is. Very powerful because then you're talking about an experience where previously if you're using GDB by itself, you'd have to do a lot of commands to get that same amount of information. Oh, yeah, yeah. And then like, yeah, just having this thing like immediately output all of this thing and like bringing in some like context and a set of colors. See, someone's already got an idea of what the bug is. Right. So if we look here, we see all of these like various bracket pairs. And this is definitely a key to the solution here. It's, if I remember correctly, there's like in a place, there's basically a global variable that's being incremented. And then it should be like, there should be a corresponding decrement of the same variable, but that never happens. So like a, basically a bound grows and then you can kind of get outside the intended memory region. Is that basically, yeah. That's exactly right. I mean, this is, imagine, you know, 20 years ago, it was a different environment for coding, but really what this came from is this code had an inbound that was, that left a little bit of room at the end of the buffer. And then they sort of said, okay, well, you know, we'll increment that bound a little bit. We've got a little extra space there, but they didn't really expect a specially designed malicious input to push that down farther than the buffer itself. Yeah. Because it's, so in this case, it's packaged as like a mail quoting thing. Was that the original context as well? Yeah, so crack adder. It was an email parsing because, you know, naturally, everybody thinks about these things. Well, email address, how complex could that be? But, you know, parsing is difficult. I think that's what we've learned. Yep, yep, yep. Truly. And if we look here at Shellfish, you can see there's some of their exploit code just passed by. Yeah, and there is a couple of different components that are going on. You have the pairs. It looks like there's a little bit of a leak going on there as well. Right, they're leaking a base address or they're trying to leak a base address there. So there's definitely progress on that side. Oh, yeah. Let's switch over to Norse code and check. A lot of action in this room. He's really happy over there. So we are here at the DEF CON, like in the CTF room on the DEF CON floor. So, you know, if you're here and during the weekend you want to stop by and, you know, say hello, you know, please come here. We have stickers. We do have stickers. And, yeah, that also means there can be some noises from other people here, enthusiastic players of the CTF. But anyway, we can see here some analysis going on in Aida trying to figure out all these quotation. You can see these variables like quotation, round quote. There's this flag being toggled on and off. And you can see that, you know, the player here is like trying to, you know, look what's going on. I think he's got an idea looking at it about what it's supposed to be. I definitely saw his cursor, you know, jumping back and forth between the key things. And didn't you say that there was a particular pattern you saw when you were... Right, so when I solved this, because the parser has like two quote types. I think it's like, you know, the regular parenthesis and then it's like angle brackets. Yeah, angle brackets. And my intuition was like, well, these two should behave the same. Like, it doesn't really matter if you have a parenthesis or an angle bracket. So I kind of like compared them, like pair-wise the piece of code, and I saw that there's like in one of the arms of the switch statement there was like a line that was missing. Right. Compared to the other corresponding piece of code. And then I was like, okay, that has to be significant. And I looked further into that and got, yeah, to the solution. So, I wonder. But we can see here in the exploit, he also has this, the parenthesis pair as part of the payload there. You know, sending a number of... So you can see, like, he wants to send hex C8 number of bytes. And then, so he divides that by two, but then sends a pair for that number. So, definitely clearly on the way there. Yeah, making good progress. And I don't have the timer right in front of me, but this is moving quickly. I mean, there's really only so many steps here because it is a smaller target for speed purposes. The original was actually quite a large function and this is much more streamlined. Right. But, so, I think the steps that they're trying to do is discover the bug, leak an address, which they'll want, and then use that for ROP. Or, I think that this one has a pretty friendly mitigation scenario. I think that most of the protections are off. Right. Which definitely would have been the case many years ago. Yeah. What mitigations? Yeah, exactly. That didn't exist back then. Yeah. But we can see here from Shellfish, they're also, you know, fiddling around with this payload, looking at how many brackets to send. Yeah, we can definitely see that he's leaked the... Oh, the base address. The address of the... Very nice. ...the binary itself. I think you may have leaked the stack pointer when you solved it. Yeah, I'm trying to remember because I know that we had a slight... So, you had your reference solution. That's right. And I had a solution. And they were, like, the overall idea was the same, but there was one step that differed a bit. The check sec there, I think that that's the key. And you can see there's no canary, NX is disabled, RWX segments, that means that they can execute code on the stack. Right. And that's very important to look out for because I think I mentioned this in the previous match. Nowadays, having challenges with, like, NX disabled is not super common. So, it's easy, you know, if you're a CDF player, it's easy to kind of forget about stats and, like, start to get into more complicated things when, like, all you had to do was to, like, put your shellcode on the stack and execute it. Right, right. Well, you know, it rewards paying close attention. But also, I mean, sometimes I feel like the exciting part is finding the bug. For me, anyway. I love finding the bug and then going through all the steps to actually exploit the bug can be a little tedious because sometimes there's, you know, it's a lot of doing the same thing or maybe there's, like, little gotchas that trip you up, but you know you have it. Yeah. No, it's... Yeah. So, especially in these, like, stressful situations with, like, the one-on-one. Like, the players... So, you don't see it here, but, like, the players are literally... They're sitting behind this wall. They're sitting opposite each other, like, at the same table. I see some shellcode going down here. Oh, oh, oh, okay. So, yeah, we should, you know, keep our attention here on the shellfish. Let's, you know, quickly switch over to Norse code while keeping a little bit of attention on the shellfish. But we can see that, like, you know, there is stuff going on here as well with the brackets, but I don't see kind of, like, shellcode and stuff yet. So, I would... If I were to take a guess, like, I would say the shellfish is, like, slightly ahead here. I'm switching back until I'm here. And, yeah, is that a... Oh, there was... Oh, I see the ID command going down. Yeah, okay. So, they believe that they should have a shell, but it doesn't seem to work quite yet. Oh, they're, like, single-stepping. Yeah, and I got to say, I don't know if everybody can appreciate it. Oh, but they were single-stepping through the shellcode, right? Yes, that's what it looks like. Right. So, they were just checking, like, why... See that? Using host lib thread, executing new program. Oh, they do have the shell. They do have the shell. Okay, okay. Oh, my God. So, Shellfish is, I'm pretty sure, going to... Yep, they're switching over to the remote. They're switching over to the remote, copy-pasting the server. That's good. So, you know, we're going to have Shellfish as the winners of this match. Remember, there is a second match going on in the background, which we don't have the results of yet. But it is streaming. If you haven't seen it, there's... Right. There's another link on the live CTF YouTube... Right. ...that you should be able to watch both of the other two competitors. Right. There is no commentary going on there, just the perspectives of the players. If you want a more zen approach to this event, which is completely valid. Okay, they're running. And... Yes, there it is. Well done. Great job, Shellfish. Well done. Congratulations. Really nice work. So, what's going to happen now is that let me just switch back to this view. And, as I said, we have another match going on in the background. You can switch to the other stream to see that thing going on. I think we're not going to really continue here. We're going to go to an intermission and come back with the next set of matches. So, what's going to happen, the second match needs to finish. We need to do some setup and then we'll be back with a new round of matches. I will be replaced. You will stay on for the next one. Yeah, really nice to commentate with you. This was a fairly quick one, I would say. Yeah, but I had a lot of fun. Yeah, it was great. I also hope all of you had fun with this. And, yeah, we will be back in a bit.