Hello, everyone. Welcome back to live CTF. We are on the third round of the second day. My name is Zita2, or Carl, and I'm here with Vy. Hi, I'm Vy Weiss. Yeah, excited to be here. Scorpio Sun. So, let's go. Nice. So, we have a match here between Shellfish and Pigbuttsad, and we're just going to get the match started and we will talk more about the teams and the challenge they are solving. So, I'm just going to check a quick OK there. Yes? So, we'll start the match. Let's do a countdown in 5, 4, 3, 2, 1. Let's go. Awesome. So, we are off to the races. So, yeah, the first thing that will happen is that the teams download the challenge and start looking at it. Well, it's going to be interesting to see what various tools they will be using. We have here, as I said, Pigbuttsad and Shellfish. Although, we just learned before the match started that the player from Pigbuttsad is at... is it ASU? Yes, ASU, where Shellfish is from. Right, so it's kind of like, you know, internal battle. And, yeah, let's switch over to just look at Pigbuttsad's screen. OK, they're interacting with the challenge, just seeing what it is. Already opened in IDA, finding the right function right now. Right. It looks like a string format, possibly. Right. OK, so... So we have a classic, like, pawn challenge with, like, a menu. You can choose various options. You can see them highlighting these, like, core functions here, like the delete message, edit message. OK, there's a const char star being casted there. OK, so for more details, it's a messaging type of menu, so there'll be some user input, it looks like. Yeah. We can have a look at Shellfish. So on their side, we also see IDA also doing, like, the initial reversing. Looks like they're looking at a little bit of a different part of the code, just tidying up the types, which are a bit messy initially. Yeah, so... They're finding the size of the buffer over here at Pigbuttsad, doing initial reconnaissance to find the inputs for any type of function writing to it. Right. So we see both the teams going for a pretty... starting out with the static analysis, doing, like, the decompilation and so on. And we've seen throughout the event, you know, the amount of time people spend on the initial, like, static analysis before they go to kind of, like, the dynamic analysis differs quite a lot. Like, some people like to do quite a lot of reversing before they start trying exploiting, and some people just do, like, a very cursory look before they, you know, bring out, like, a debugger and so on. Oh, that's interesting. So, you know, both teams just went to static analysis first. Right. Like, spending a few minutes here. Yeah. And I mean, I think most of them do that, like, initially. Yeah. But we'll see how long they stay here before they start writing some exploits code. Yeah. Pigbuttsad is very fast with searching, finding, getting the function pointers, focusing on... Right. So we have some kind of structure here being defined. Kind of, like, reconstructing this. Is it, like, a message struct, I think? Yeah. It looks like there might be different fields to a message, a message head area. We'll see what they can do with that. Right. And it's a little bit interesting with the... Okay, there it looks starting to look a bit better once you start defining these types. And, you know, this helps you get a clear, you know, understanding of what's going on. Yeah. We can switch over to Shellfish. Interesting. So Shellfish is actually putting comments in their IDA output. And you can see they wrote overflow there. So it seems like they have, well, potentially found the bug. Yeah. And, you know, now they're trying maybe to figure out how do you get there. Yes. Yeah. Did you see where they had overflow? Which function? I think it was the same function that we were looking at before. Yes. But I'm not entirely sure. You can see there, like, they called something like a maybe next. Which is, I think, a good strategy. Like, sometimes, you know, you're not completely sure. You write something, but you make a note to make sure that, like, you know, don't trust this too much. Yeah. In a limited time, you just keep going. Pigbuttsad instead of comments, just renaming variables, cleaning up everything. Right. Yeah. So they're looking at the string compares right now. Okay. So there's bad words. So it seems in this challenge, it's a message one, but it seems like there's going to be certain words you can't say as the bad word. And so that might be kind of where we'll want to put any type of payload or bypass there. So it'll be interesting to see what the bad words are as well as we go through the challenge. So you can see that big hex constant there. It looked very much in the printable ASCII range. So there was probably a string that was incorrectly interpreted as a number. And now we can see some interaction with the binary again. To be honest, this is how I know that they're kind of competent. Like, I would just spam the binary. I would just be interacting with it at first. They're really trying to be more methodical. And yeah, it's over three minutes in, and they haven't really interacted much with the binary, just spending time. Yeah, taking their time. It's a big challenge, the kind of meta game or the strategy here. Because you want to go quick, but if you rush it too much, you might get tangled up in these go-downs. It might become very messy, and you might actually lose time in the end. Yeah, for sure. Okay, so Pigbuttsad is figuring out where the pointers are going to, where the function pointers are going to. How is Shellfish doing over there? Right, so here we actually start seeing some exploits. Oh, they start writing. Yeah, so you can see here they're using Python with PwnTools. You know, the popular choice. Very standard. And they are kind of defining a new, I guess this is like a new message, this whole interaction with the program. They're writing these helper functions to make it easy to write these things. So it looks like they are, you can see there they put hack is probably a bad word. Yes. Controversial. Hacking is not a crime. But yeah, so it looks like, you know, they already have their string initially being constructed. They're going to start sending a payload over. Maybe they're going to send it a few times and try and debug it that way, see what the response is. But it's interesting that Shellfish is already doing that. Meanwhile, this team is, they're doing a great job, like really commenting everything, knowing what pointer is doing what. And so this is clean, very clean what they're doing. Yeah, so this is kind of what we were talking about. Shellfish went for starting writing the exploit a bit faster. And then it's like, was it the right timing or was it too fast? And will it end up costing them or is it going to give them the win? Absolutely. Versus going through the binary more thoroughly. So this seems like a very basic string sanitization type of bug. So this seems like a really good beginner CTF if anyone's watching and wants to take notes. We should actually point that out, that all of the challenges that we run here throughout the event, we will be publishing them. So if you want to try these things out, we will actually also post all the times that the participants had. So if you want to try to benchmark yourselves against these very, very good players, there will be a possibility to do so as well. So right now, Pigbuttsad's focusing on the delete message function here. What's Shellfish looking at right now? Switching over to Shellfish, I see that... Yeah, so you can see that it was very quick. But in their solve script, they have this thing to create a new message. And they put in these bad words. And this is actually the exact right way to go. Because if I remember correctly, maybe you looked into this more. The point is that when a bad word gets filtered, it gets replaced by something that's longer. So it will expand the size of your message, which will eventually overflow the buffer that it's located in. And you can see that they're concatenating... Sorry, my eyes are bad. Yeah, so they're creating new messages. Those messages don't have any bad words, those are just big sequences of A's and B's. Yeah, getting padding in to try and make it the right size already without having to have that penalty for writing the bad word. Exactly. But the interesting thing is that it seems like they're listing out the messages. And you can see that long sequence of B's, but there were some garbage characters at the end. So that would kind of suggest that that is a leak. So maybe they need that for the exportation part. Are there any Unicode characters or any type of certain interesting characters or just random ones? Yeah, it looked just like random. So I suspect this is like you make a message that's just the right amount and then it will print out stuff afterwards. So a very simple stack overflow there. Yeah. And so, oh wow, we have some very nice Python happening over here with pigbuttsad. Yeah, so they have these templates for their script. And this is actually kind of cool, you can see that the teams are prepared, right? Because you have these short two, three-letter functions that are used to just make it faster to type these scripts. That's very methodical. They're just encoding the strings to send over to... There's a GDB attach function that they'll be filling out soon. Right. I think it's really cool, they come prepared with these kind of templates. And I've even heard some teams have been practicing. They took the challenges from last year and used it as a way to train their speed-pwning abilities. So teams are definitely taking it seriously. Here you can see, you hack using one of the bad words and posting just a lot of these bad words. Yeah, and that's interesting. Instead of doing random characters for getting the padding before a hack, it's just using hack the whole time. So this means that... I would say that it seems a little bit like pigbuttsad kind of caught up to Shellfish here with this. Very quickly. Yeah, so I think it's a very, very close race. You can see they're grabbing some offsets from Ida. And I actually don't know what that command was in GDB. But that's going to be interesting to see. And now they are running this with the debugger. They're just checking the breakpoints. Yeah. And that's interesting, the offset he found so quickly in Ida, really doing some nice static analysis paid off there. Yeah, just putting a breakpoint there to be able to analyze the exploit here. And you can see those hack, hack, hack messages. Yeah, so it's a pretty close race here, I would say. It's not sure exactly what they're doing right now. But if we look here again at Shellfish, I think they have a very clean exploit script here. You can see these helper functions for, I think it's like a new message, edit message, delete message. Yeah, right. And using these to interact. So here you can see, it's very nice because it's easy to follow. Like, oh, they're creating two new messages, deleting one, editing one. There's some sequence of operation there. It's nice to follow. So I appreciate that as a commentator here. Yeah, absolutely. It's very clean. And they were able to really quickly find the sanitization function. They were able to do this very quickly. Yeah. And if we go back to Pig again, still doing some debugging. It looks like now they are in some... Yeah, I was trying to see where they were doing the break, but I couldn't quite make it out. Yeah, it's kind of going fast there. It's going very fast. So the players, they sit behind us here, behind a wall. And I've seen some of the matches, like the speed at which they are just typing the stuff is insane. Oh, so there we can see, on the right side there, you saw the deleted. The words being removed. Yes, and then since the string deleted is longer than the string hack, this is what causes the bug. And they are stepping through the sanitize function. A lot of stepping to get to the right place. Yeah, just tapping the button. Yeah, that's... We have, if we switch over to Shellfish again, you can see that they run the check sec thing. And they highlight, I saw the player highlighting the NX enabled. Oh, here you can see... You can see the 41, so you can see their payload, the padding for the A's starting. And trying to maybe figure out the various addresses and offsets, just checking that what ends up in memory corresponds to what they would expect from their exploits. This is really classic debugging. Pigbuttsat is going back and checking... Right, so it looks like they have... I'm just trying to see where they are putting their breakpoints. Because you saw that they were analyzing some contents of the memory there. But I couldn't quite make out where that was. It was like in the string comparison stuff. Oh, at first I thought the word was misspelled, but it's just backwards. The endian miss. The deleted endian is backwards, it's great actually. That's a good team name, Dateled. If you want to join, we're looking for members. Have you played any CTFs recently? Oh man, we did a Hack the Box CTF recently at work. It was really wholesome. That's a very good CTF. It was like a VM reversing challenge, which was nice. I recommend that as just a really relaxing one too. What about you? I'm mostly retired from playing. I organize a bunch of stuff. I do every year play the Flareon group. Hopefully that one should be coming up right now in a few weeks. I'm looking forward to that. Hopefully that happens. Other than that, I've been more organizing than playing the competitions. When was the last Defcon CTF you played? Village or main? I founded NorseCode in 2019. I played the two COVID years of the Defcon CTF. I've never played the Defcon CTF on site. I think it was Defcon 2018. There was an RMV8x86 polyglot. Some of the challenges in 2018 were pretty nasty. It must have been 20 and 21 that I played. Those were the COVID years. We can check in with PigBatSat again. NorseCode is here playing. That's a good segue to mention that we are running two matches in parallel. We are commentating this one between Shellfish and PigBatSat. We also have a match between BlueWater and NorseCode. They are playing the same challenge, but off-stream. We have some more debugging action going on here. Just making sure that the start of the payload is being put in the right place. He is using hexadecimal 6-2s to figure out where he needs to... He is left-adjusting the padding. I love seeing an L-adjust and a right-adjust. Using every single convenience function. The built-in Python ones. To your fullest advantage. And... Yeah, it's... Also here looking at... Double-checking the memory mappings to find offsets. Yeah, it's... Switching things up. They got rid of the hack words for now. Maybe they needed to take a step back and check some of their assumptions. Where things are located. He is writing another function here for just editing the message. Okay, yeah. Similar to what Shellfish did over here. You have these helper functions for managing your messages. To not have to repeat so many things in the exploits. I feel like the Shellfish exploit code looks very similar to... Not much has changed, I feel, since we looked at it a moment ago. But hopefully they've been gathering some... Debugging, looking at GDB, setting breakpoints as well. So they've written GDB attached to... That was part of the template that sadbutpig had. Yeah, definitely they came prepared. So pigbuttsad is going back to hack and using the word hack. But now they just have it in their payload. So to simplify it, they made their payload just be the hack bytes. Sending that over. Right, now there's... Yeah, I think something went wrong there. Maybe there was a very large amount of outputs. Yeah, it might be on the size for the 100 hexadecimal. What size of A's and B's are they sending over there? Also 100? Yeah, so Shellfish, I think it was... I've seen various things in their code. Let's see if they switch back to it. I've seen 100, 200... But you can see there's a read call there, reading hex 100 characters. And that's what they're sending there in their two new calls. So, you know, the size is down. It seems like the verbiage is down. It's just really getting the right hexadecimal values in the right places. Which is all CTF. You put the hex in the right memory addresses and then you get it. You know, the good bytes, the bad bytes. The medium bytes, they're all here. But yeah, let's go back to... So, yeah, Pigmetat is still debugging. A lot of A's, a lot of B's we're seeing. I wish I knew the hexadecimal for hack. That would make this a lot helpful. Do you have YouTube comments? Oh, yeah, we should have. If someone knows hack... 69, maybe? Yeah, so 69, 41... No, 41 is the capital. So it's 61. Oh, true, 61, yeah. We know how to do the alphabet really easily. 68. 68, 61, I think, would be the start. And then 63. Wow, great reverse engineering. I feel like this is like a hexadecimal class. Like an intro comp sci. You have to convert. Hello, kids, today we're learning about hexadecimal. We'll go to decimal next. So make sure everyone knows 1 to 10. Or 0 to 9, really. And then next week is binary. Or homework, maybe. We'll give homework. That's what this is. You can do this at home. The challenges are in GitHub. They will be on GitHub. A lot of single-stepping again. So hack is going... Copying and pasting the offsets from Ida. Putting the breakpoint there. All right. So now... They stopped right at the return instructions. Maybe they were looking at the stack layout. At the point of executing the return. Yeah. They're right by RBP, RSP. Yeah. It's... I really feel like both the teams are kind of on to it. They have the pieces. But then, like you said, doing this fiddling and getting things just right can be a big challenge. And especially in this stressful context. And that's so realistic. Because I feel like when you have a code base, finding the bug is easy. Exploiting is way more difficult sometimes. So... Yeah, this is really realistic, I think, of anyone doing a sanitized string buffer overflow situation here. Yeah. I do have a notification here that NorseCode... Let me just confirm this. This is breaking news. We're getting messages. So NorseCode did win the match that we are not commentating. The other match that's running in parallel. Great job to them. Do you feel like a father to the team? Because you found it? It's... You know, father sounds maybe a bit important. Maybe it's like the drunk uncle. Something like this. Every CTF team. Or like the old grandpa who still thinks they're relevant. That's why we're here. Yeah. Like, well, back in my day... Yeah. Something like that. No, but I have some good friends in the team. For example, the guy who did play the match for NorseCode. Yeah, a close friend of mine. So, of course, I'm very happy for them doing well in this CTF. Yeah, definitely cheering for them. Although I have some colleagues from work in some of the other teams as well. Oh, so it's like you're conflicted. How's that doing for you? Is that why you're the drunk uncle and not just the uncle? You have, like, the children. Your nephew's over there. Your niece is there. Oh, yeah. No, it's like... I mean, I like the people in NorseCode. I was not expecting them to... I was expecting them to do okay. But then suddenly they're performing pretty well and they're in fifth place in the overall main event. So now I have to actually cheer for them. So that's super cool to see. Set your expectations low. I think that's kind of moral. Tip of the day. Yeah. I know your alphabet. Yep. Let's check in with Shellfish here. They are going back and forth a bit with AIDA and the debugger. Looks like they are trying to... I'm not sure looking at the sizes of these buffers or something. I don't quite understand the code that's going. They just got the address for where the return happens. I think they're going to put a breakpoint there. That's definitely what's happening. This is really cool over with PigButtSAD. Using GDB, they've got the offsets. They saw where strcpy is getting called, where puts is being called. And now they're just putting that value that ends with 4028 into RDI. So now we're finally seeing some registers be called in their Python scripts. A small ROP chain being put together here, which could indicate that they are close. Let's see who gets ripped first. This is exciting, actually. Look what you have. There was a bunch of nullbytes on the stack there, I think. Yeah, right at the RET instruction. So there's something that's slightly off because they got a nullbyte at the RET location. And now there are only two... Well, there's only one nullbyte before there were three. So they're slowly adjusting... I think it's the number of bad words or something. So I feel like they are close. So he called searchmem to see... That went too fast. Okay, so... Okay, and so they have the bitmask in the payload too. They're trying to make sure everything lands in the right place. So... They're getting the length of the payload. I'm starting to get excited here now. I feel like they could be one small step away from... They're close to popRDI here. Yeah. Let's see. They're doing some small adjustments. You see some subtracting some stuff from the payloads. So, yeah. Cool, simple wrap chain based exploit for this. This would be a really cool wrap chain beginner on GitHub if anyone wants to do this. I think for a lot of these challenges, because we wanted to be able to solve it within the 15 minutes we have, I think we have been fairly generous. Sometimes we put some very useful gadgets. Yeah, so they calculated a little bit of an offset there. Yeah. They got the base address going. Oh, they weren't sure if it was going to be a plus or minus, I think. So, yeah. It's very close. How's Shellfish doing? Let's go back at Shellfish. This is so exciting. Pigbuttsat is almost getting it. We'll have to have one eye over on that screen. Okay, you do that. It seems like the Shellfish player is flailing around a little bit with a bunch of typos in the terminal. Maybe the stress is getting... Oh, right. He's running RopGadget. He's trying to find some convenient RopGadget. He dumped that out. That would suggest that they're about to put some RopChain together. In Pigbuttsat, they have 0xDeadBeef right now in their RopChain. Oh, so they're using this as a marker thing to make sure that they know that if they put this somewhere in memory and they find where it ends up in memory and then they can use this as a marker. That's where the SearchMem command is super helpful. I think they're doing a great job manually backtracing and figuring out... You could see that they were close, but it was something that was a little bit off. You have to backtrack a little bit. This is like a blog post of they already edited everything. They know exactly what they're doing. No mistakes. I haven't seen any typos. I feel bad for you. If typos are happening... Someone should get him a lemonade. Maybe we should. Yeah. And still there's the null byte there when they're at the red instruction. Something is misaligned or something with their exploits. It must be very stressful knowing that you are this close. You don't know how far along the other player is. But it seems like everything is so smart, right? It's not like there's that much lag time. There's constant typing for him. With Shellfish, let's spend some more time here. I feel like we've spent so much time with PigBot 7. They are now putting together the ROP chain here. They used ROP Gadget before, which is a tool to find ROP Gadgets in a binary. They dumped it to a text file. Looking through this and picking and choosing the various things you can see here. They're using this one PopRDI RET Gadget here. They're building up this ROP Chain. You can see a few lines below. They have the start of the payload to trigger the vulnerability. Then they add on the ROP Chain at the end there. Very methodical here. Great comments too. I like how they have PopRDI RET for what they're looking at. Not just making the Gadget, they're showing exactly what instructions they want to start using for their ROP Chain. I think this is really cool to see. A moment ago, I felt like PigBot 7 was a little bit behind with the ROP Chain and stuff. But then something went wrong and they had to debug this. Now, Shellfish is writing this. If they can land this without too big of an issue, they might be able to catch up and overtake them again. It's a really, really close race here. At PigBot 7, they're still using 0xDeadBeef to find where in memory they're at right now. They're so close to getting the right return address and being put in the right place. To recap a little bit for the listeners, the idea here is that you have a message and you put bad words into it. The bad words can be short and they get replaced by a longer word, which expands your message and pushes the end. Eventually, it will overflow a buffer. The approach would be you put a bunch of bad words and then an appropriate amount of padding to align everything, and then your ROP chain. You have to align this up so that the thing expands just the right amount of bytes to put your ROP chain in the correct place. We can see there's definitely something going wrong. You can see here, now they have aligned it. You can see they are at the RET instruction and the top is one of their gadgets, I believe. That's very significant. PopRDI is a great gadget to start using there. This is so close. Really? If we switch over to Shellfish... They are typing the same words, basically. I like how with Shellfish you can see the way they are naming it. They are getting the base address of the library. This is a very academic tutorial way to write it. This is export code that I really like. Not too different from how I like to write it. You have some log statements, proper variable names, the whole thing. Of course, that might not necessarily be the most efficient way in a speed pwning setting like this. On the other hand, doing a methodical approach and making sure you do everything right can save you costly mistakes. There's something to be said. You want to be super careful with subtracting the right base address to the function address that you're looking for. Right. Yeah. They have BNSH already written. Yes. I think they could... It's so close here. They're doing maybe some final debugging. Could we possibly see this working? I want to just look at them for a short moment more here to see if things are... Oh, look. You have the RET that was pointing at the ROP address. Sorry. The ROP chain was on the stack at the RET address. It really looks like they are right there. Yeah. Oh, and now they are duplicating the... Interesting. They're duplicating getting their shell. They have the SHN system. Oh, actually, that was very interesting. The first ROP chain goes back to main. Wow, this is pretty... It looks like they're doing one ROP chain... To overwrite the entry point of the message? I don't know. Because that first ROP chain ends with the main symbol, so it would jump back to main and essentially restart the program. And then Ewing is doing some kind of leak. And then... Oh, I think this is... I mean, this might absolutely be a solution, but it looks way more complex than our reference solution. Pigbuttsad is also looking at it. Yeah, yeah, yeah. But, I mean, in the end, a flag is a flag. A win is a win. Yeah. If you took a long detour and still got there faster, then good on you. Okay, so they're putting agent now into their payload for debugging. Okay, so they're unpacking. They have U64 being called for unpacking. So they did a small leak. And then... Okay, and there they have the libc address as well. Did we... Yeah, okay. It's getting the base text. Okay, so this is just basic calculating the base. Meanwhile, it's interesting. Shellfish is already writing, like, a second prop chain. And we're just over here still getting... Not that it's bad. I really like how methodical Pigbuttsad is. But it's interesting to see that Shellfish is basically just brute-forcing the second prop chain. Yeah, it's actually interesting if you look at the screen here. They're kind of debugging here. You can see they are at the ret instruction in the debugger. And then you have this 41 string at the top of the stack. So I think they are using that to double-check that the prop chain is being put in the proper location in memory. So they could be close. And now they are copying some data from the top of the stack. Oh, they're using the cyclic. Yeah, that's cool. So Shellfish is using a lot more, like, tooling. So the cyclic function it generates a sequence which you can then input into your program. And then you can take a very small substring of that sequence and then calculate back the index. So this can really help you figure out what offset, you know... That's interesting. We have more manual offset calculation here. Yeah, a lot less commands happening. Right. It's... Oh! There was a shell here. Oh, we have a shell. Yeah, yeah, yeah. I saw the execve. So they have execve being called. They're switching to the remote. You see instead of process, they're switching to remote. Oh, they might have something there. Yeah, yeah. So this is going to be a solve. They're putting in the host and the port name. And let's see. They're running it. Pigbuttsad hasn't even... Oh, right. They removed the db. And they have... Yeah. Okay, let's see. They got it. They got it. Wow. They got it. Congratulations. Really nice. Really nice. Congrats to shellfish. Yeah, shellfish. Advancing in the tournament. Unfortunately, Pigbuttsad are knocked out of the live CTF tournament, but they had a great run. Really well played. That was excellent. Seeing the template that they brought, too. You could tell this team really is sophisticated, knows what they're doing. Good luck to them throughout the entire CTF, too. Right. And shellfish, this was great. Seeing the second attempt for roping there. Yeah, it's really, really cool. So that means they will advance on to the next round. Yeah, this was super fun. This was great, yeah. Yeah, thanks for coming on as a commentator. Thanks for commentating. And we will go to a short break. We will be back. I'm 0xSleep on Twitter. If anyone wants to talk, I'm Vee on BlueSky. If anyone's on BlueSky. So see ya. Have a good one. Before I sign off here, just take a quick look at the bracket. As I said, we had PigBotSAD will be facing Shellfish in the next one. And then no, sorry, that was just what happened. Shellfish won against PigBotSAD. And NorseCode won their match. So it's Shellfish versus NorseCode? No, so what's happening is this is the lower bracket. So you have the upper bracket here. You have Macaroni versus Hypeboy. And then you have MMM versus StrawHat. And the respective losers of those matches will face against Shellfish or NorseCode. Okay. So that's it. Shout out to StrawHat. Great team name. Big One Piece fan. So love to see it. So who is the next one coming up? I think we have it's both of those two matches. Macaroni and Hypeboy and MMM and StrawHat. I don't remember which one of those we are commentating. But we will be back here soon. And yeah. Have a nice day. Bye.