 Hello, what is going on everybody welcome back in the YouTube video? My name is John Hammond, and I'm back with the Python challenge This has been requested so many times and it gets a lot of comments this whole series gets a lot of interest So I want to return. I know it's been a long time So I'm wiping the dust off kind of getting rid of the cobwebs and let's see how we can jump back into the Python challenge So I think I left off on level 19 The URL for this one is PC forward slash hex forward slash bin dot HTML this extension there whoa and The login is butter and fly butterfly as the epiphany came in the last video from two years ago Geez, that's insane. So all right. I don't know what I'm looking at right now This looks like a picture of India At least I'm pretty sure that's India. I sure hope so Again more threats to my intelligence the Python challenge videos. Okay. Yeah, this definitely looks like India those two match a Little inverted colors though. That's kind of weird Let's view the source here because there's nothing else on this page other than this image I hit control you and it looks like there's a lot. Okay. There's HTML comments just following the page That looks like an email. We've got a from line Leopold Maws at Python challenge calm subject. What do you mean by open the attachment? Okay Content type. Okay, it looks like it is including some stuff the message here is it's so much easier for you youngsters Maybe my computer is out of order. I have a real work to do and I must know what's inside Okay, and it looks like there's some stuff here to denote that there is an attachment There would have been an attachment had this been a kind of sent through a real email client, but okay in just this raw Type here. It looks like it's using the base 64 encoding to pass along a wave file named Indian wave Okay, Indian Indian wave. It looks pretty long, but I guess that probably correlates to This picture of India here. I guess Um, okay, let's just see what we can get out of that Let's see if we can get this Indian that way if I we could copy and paste this and run the base 64 command from the command Line and bash and stuff, but that's boring We want to be doing this in Python since that's the name of this video series so let's create Pi challenge folder and we'll call this level 19 dot pi and again This is just kind of a scratchpad. This is gonna be ugly code probably Let's I put a disclaimer I think at the very beginning of the series like four years ago six years ago Whoever long it was and it's been bad code all the way So I'm gonna use the request module here. You may have seen me use that in other other videos Again, if you haven't heard of it, it's like an awesome better version of the URL lib So let's just let let's just run it like regular HTTP requests to get and post like you'd interact with the web page Through Python if you don't have it installed you can pseudo pip install Requests and if you don't have pip you can pseudo app get install Python attack pip But I'm sure you're kind of up to speed on that stuff. So let's just get the page here Let's call that response Whoa, stupid sublime text trying to make me buy your product. I don't want any of that stuff. Okay. We have an error here Response 404 that is because we have not Authenticated so we can specify an authentication tuple with our username and password Which I remember saying was butter and fly So now we get the whole page of the website Okay, let's scrape out just this base 64 stuff. Looks like it starts with the UK and ends in a Equal sign Are there any other a equal signs in this mess? Whatever. I'm gonna scrape it out with RE the request I'm sorry the regular expressions module. That's built in. You don't have to pip install that I read not find all UK Anything to a equals With response text Let's see what we get Nothing we Do we need to say are a multi-line or something? Let's Do my testing and if we're getting to remove things that looks like it's retrieving some things But not everything of what I wanted response dot text we could just do kind of a hack and get new line character new line character this stuff you know new nine and The very top of it is Bay 64 new line new line Do we get it now? No, maybe I need to specify that it's a multi-line Will that work in the find all function flags? Yes RE dot multi-line Please work. What the crap? All right, I guess I suck need to be a rostering. No I've embarrassed myself in this video already all right, well, let's just kind of bail on that and do a Kind of disgusting split and cut up methodology so we can get the Just about last one We don't need the text there so Second from the last one and that has the header at the very top, right? So Why is it getting the whole thing? Is that not the boundary that I just specified? No, it's not because it has the two hyphens at the end. Okay, whatever. So now the one two three four Fourth lines. We don't need split by new line characters. Let's get the fifth on So the fourth on because we're zero based here that gets it and we don't need the very last two So let's slice to those and let's join this by a new line character So we carve it out Gross, okay We actually don't need to join by new line character since we're gonna end up using this whole thing as a base 64 string, right? so base 64 Let's just call this B64 because we want to import the module base 64 and that will let us decode it base 64 Dot B64 decode of Base 64 variable we can print this out, but we know it's probably just gonna be binary stuff Because it is a wave file. It is an audio file. So let's just write that out H equals a Handle that we can open called indian.wave H dot write this let's make sure we include the right modifier here in that open and Let's close it when we run this there is no output, but we should be able to See a new file here in our pie challenge folder Indian wave. All right, let's try and play that. I don't know if you can hear that whatsoever But it was just static for me Sounds like someone said the word sorry in the middle of it. Okay That doesn't help us. What is this? It looks like there's nothing else we can really do here nothing else in this Page please title. I don't know if that could be a hint What do you mean by open the attachment? Okay, so we got the attachment already we got the sound file we got indian.wav Indian.wave it's so much easier for you youngsters. Maybe my computer is out of order. I Have real work to do and I must know what's inside India Indian Indian oh Indian and out of order Indie Indian Indian. Oh my gosh. Okay. They're trying to refer to Indian, right? So nd in this little nd in or big nd in this That is the byte order that Files or bytes are stored that it's the order in which bytes are arranged into larger Nomenic or values when stored in memory or when transmitted over to data links So any instances of interest computer science because too conflicting if incompatible formats are in use words or like segments of data Can be represented either big nd or little nd in format depending on whether bits or bytes or other components are over from the big end The most significant bit or the little nd least significant bit So that's kind of how you're looking at binary in a 0 1 1 0 1 0 1 Is that that's not 8 bytes that's 7. Okay. Cool. Now we have 8 bytes or 8 bits here and that is 1 byte so that would be The most significant bit would be this one here and the least significant would be this one here The very very end versus the very very start. So when you put them in the other nd in this it's like as if these are reversed so Now is your 0 1 0 1 0 1 1 0 We switch the nd in this we swap the bytes in that case Hopefully that's a decent description and hopefully I'm not wrong in saying that But okay, it looks like that's what we need to deal with I think anyway If this is India nd nd in nd in that must be kind of a hint that they're getting out here. So this WAV file is Currently little nd in at least according to our File command here Let's See if we can Swap that or change it Right. Is it this guy says maybe my computer is out of order? Okay, so maybe the byte order is not right Maybe we have to change the nd in Little nd in the big nd in How do we do that in Python? Python WAV file There's a default library it looks like Python 3 Python 2 I Should really be moving into Python 3 complete disclaimer I know everyone probably hates me because I have not really moved into Python 3 yet And I absolutely have to because Python 2 is going away very soon, but I just can't stand not having parentheses or Who and I'm trying to use the print statement. I need I need to have No parentheses when I use my print statement. I hate the fact. It's a function now It I don't want to use parentheses. I'm just kidding. This is all a joke. I Don't see anything in this page about nd in this I literally control f for nd in and I can't change okay, I Don't know if that will help us But it looks like you can do a lot of cool things like get information about the file And we'll probably need that if we're going to end up like copying it or re-changing it to modify the modify the nd in this So let's not try that. Let's make this broader. I found sound file. I Think I've researched this stuff before like in another CTF or something. Okay. Yeah, there is a pie sound file This looks pretty good. I always love like to read the docs IO stuff Those are normally pretty good. The lights just went off in my room stupid auto sensors All right, cool. Sorry This can read and write sound files. Okay, that's what we need to do Can I just pip install this thing? Yeah, okay, cool pip install pie sound file That's probably pretty easy. I don't know if we have all I don't know if I have all those Dependencies probably I would think so Import sound file as FS. So just a nickname or an alias for it Sound file objects. Okay, that looks like it'll handle it already Like it'll be able to figure stuff out and it'll just like automatically detects everything on it Let's try I'm gonna try this with idle real quick because I'll put idle in my current directory Actually, let me make sure that I am in the right directory. I'll blow this up So you can see a little bit better change the font size to a Wapping 22 because that's all the idle lets me use Now if I see HDR am I already in the Python challenges folder? Okay, I guess I am whatever now. Let's import sound file, but it's not installed yet. So let's kill this pseudo pip install pie sound file type in my password You do the same I guess if you follow along and now I should be able to idle Import sound file neat. I put a random backslash there. Sorry. So sound file dot sound file capital S capital F that will Auto-detect just about everything looks like Indian web. Oh sweet. Okay. Yeah already gets the sample rate gets the channels knows why having everything and Indian this is file Indian this Looks like this module will handle things in Indian then. Oh cool. Okay By default it will go to little that makes sense because that's kind of common If you're reading big Indian data, you can set Indian to big accordingly. Okay, so that lets us do stuff and We can write out a file with a different Indian format. Perfect Let's Try that I guess We can just write with the file that we've read the data from this and put it into Whatever whatever sample rate whatever channels that ever subtype the other one to had since it already read all that right if I save this as a Excuse me. If I save this as just an object. I can read a sample rate and Channels. Oh cool. Yeah, these variables just already exist So let's do that in our scripts let's import sound file and Sound file sound file of Indian web is what we just wrote. Let's call that Indian I guess so Now we can read the data from it with Dot read I thought I saw that function. Yep. There is that that is a thing sound file dot read Holy cow. Holy cow. I Just want to Read from a file and return the data as numpy array that should do it for us. I think I guess I didn't really check a Dot read an idle to go back to our little test bed here. Looks like it gets stuff Let's try it The sound file Dot write So documentation here if I check out the write function that takes arguments The file name that we want So I'll call this like something that we have the data that we want so Indian read and The sample rate so Indian dot sample rate will work with all the same content that we've seen before Indian subtype Subtype is that a thing? That is a thing right sub sub type. Yeah, okay, perfect sub type What else do we need Indian and Nick so in this case we can just give it a string big like we had seen earlier and the format What is the what is the format does that exist? Yeah, okay, sweet. It's just string life. Whatever Indian dot web Format dot format dot format neat So what's one this no output, but do we have a new file? We do we have something dot laugh. What is that thing something dot web? Riff big Indian perfect. Can I play this will it work? Okay, I don't know if you can hear that but that was a another chanting chorus that I am an idiot You are an idiot. Haha. Okay, so What does that mean what that's not like a that's not a flag or anything? Is that what I needed to do all along you are an idiot is That I know we've been to like an idiot before right? Oh, okay Idiots just on its own in the hex folder. I guess now you should apologize. What? What is okay stuff of picture labeled oh idiot to continue to the next level heck, yeah Oh, perfect. Okay, sweet. I guess we just did it. That was all neat um I didn't think that was that bad I did a little bit of research on how to change stuff to the beginning or little ending in in in WAV files and Wave files. I did some disgusting string processing here a little bit of get content from with with Request module and getting stuff from web page just downloading that stuff so we didn't have to kind of do it by hand base 64 decoding right Some good Python stuff something simple stuff too and just I don't know working with sound files That's a pretty cool module the sound file thing that uh, I think I had seen that before in other Capture flag competitions like other stuff I've done But it's so easy to forget like this is a nook and cranny of some of Python stuff that I don't do a whole lot I don't do a whole lot of like signal processing in audio audio file management stuff. So that's pretty neat though I hope you guys enjoyed this video. I'm glad we ran through a whole nother level of the Python challenge and Let's keep them moving. Let's let's get to level 20. I'll see you guys in a later video