 Hello, everybody, and welcome back to another YouTube video looking at the HSCTF for 2019. Still in the miscellaneous category, we're on the real reversal challenge now. This has 276 points worth. It says, my friend gave me some fancy techs, but it was reversed. So I tried to reverse it, but I think I messed it up even further. Can you figure out what the tech says? And we have reverse.tech. So let's go ahead and download that. I'm just going to put it in that HS directory that I've been storing a bunch of stuff. As long as you have a folder, you can dedicate to some of this. That's a good idea. I haven't really organized this, although I should. Again, practice is that you should do at home. Do as I say, not as I do, right? Okay, so this is the reverse.tech. Let's take a look at what it actually is. That, lots of raw binary data, stuff that our terminal can't easily interpret. So if I actually open this up in sublime.techs, that reverse.techs, we can take a gander and it looks like still nonsense. So that doesn't help us at all. If we try and reverse it, right, we can cat reverse.techs and I piped it to rev to reverse it invalid or incomplete multi bytes or wide character. That tips me off that there might be some weird stuff in there. So then I thought, all right, let's just do this in Python. So we'll just do reverser.py. And what I will do is have a little shebang line here. We'll use a context manager because that's what the world wants us to do. So with open, reversed.techs, I think that was it, right? Yep. As h or whatever, we'll do h.read and we'll actually go ahead and print that out as it is reversed. So colon, colon, negative one is a quick way to loop through or iterate through, slice in this case, because that's the operator we're using from the beginning to the end. So no digits in there as normal, but the way that we iterate or step through that, excuse me, is through negative one. So we're going backwards. So it will reverse the string. That's a good trick and technique. Let's go ahead and hit ctrl B to run this. And that gave me at least letters now in English words. If we go ahead and try and run that from the command line, reverser.py, we get the exact same thing. Interesting thing to note, however, I'm using Python 2 to do that. If I were to use Python 3, it will give me an error because, hey, unicode, decode error, utf8, code that can't decode byte, blah, blah, blah at that position. So what I'm determining is that this is utf8, and that's why it wasn't easily or easily visible on the command line when we tried to view it. However, Python and Sublime Text was able to keep track of that. Python 2 was able to keep track of that because Python 2 doesn't really worry about these codecs as much. It just throws them away, pretends their abstractions, and will do things that it maybe shouldn't do just to fake it for your sake as the programmer. The way that we in Python 2 have anything.incodehex, or I should have used please subscribe or whatever, do that. If we were to try to use that and decode hex, that's not really a thing. Decoding hex, it's all data, and the ASCII interpretation is a representation of data in a different way than this is. That's why you use modules in Python 3 like binasci to hexlify or unhexlify. That's a better term than hex decoding because it takes in place these codecs, and utf8 is no exception. The codec and the way to represent that data is just different, and Python 2 pretends that it's not there abstracts it away, and it might do things that you as the programmer should be cognizant of, but it's not letting you be. Anyway, Python 2 in this case is saving the day for us, disclaimer. Let's see what all this is, and let's go ahead and try and reverse that. It says, wow, this is cool, all of my text is backwards, this is actually so cool. We can track down if we were to keep scrolling through this. The flag is hsctfutf8 for the win. If I try and copy that and paste it, it would tell me, oh, you see that weird format, right? And if I were to have that in sublime text, it looks totally fine, however it is utf8. So something, I don't know if that format is visible to you, but if I were to try and type something, that string looks very, very different from hsctf noted there and hsctf noted there. So it's the wide characters in utf8. So if we just recreated it, we can type it utf8 for the win, and then we would be able to copy and paste that in, and then that's the flag. So that's how that's done. I maybe I stumbled upon it, maybe that's how, maybe there's no better or formal way that I could explain to track that down, because just looking at the file, I would not have been able to say, oh, that's obviously utf8, I don't have that super, what is the word for that? It's not superstition, super, it's not like paranormal. I don't know what word I'm thinking of. Do you guys know? Okay. Hey, that's that. Thank you guys for watching. I hope you enjoyed this. That wasn't really too much Python code, right? We're just reversing a string, but noting it and keeping track of that Python 2 versus Python 3 difference. Keep that in mind. So thanks for watching. If you guys enjoyed this video, please do like, comment, and subscribe. I would love to see you guys in the Discord server. There is a link in the description. It's a cool community full of CTF players, programmers, and hackers. Tons of smart people in there are much smarter than me, and I know a lot of people went ham on this on the CTF. Now that it has ended, I think that we had a few people that were up there on the Discord board, like top 10, top 5, top stuff. I'd love to see you on Patreon, love to see you on PayPal. I am super duper thankful and grateful for anything you are willing to do to help support the channel. Thank you, thank you. Thanks for watching, guys. I'll see you in the next video.