 How's it going everybody? My name is John Hammond, and I wanted to show you now in this video more of the last the CTF challenges and stuff on All the challenges that I've solved so far have been really simple and I figured I was going to try and go through them and Actually create a like little get flag script as to how I actually solve all of them So the ones that I have completed I normally in a folder that I keep track of everything for a CTF I would try to create a get flag script that will actually just return the flag for us in some Easy way so I try to do this for all the ones that I have completed right now like the easy one the easy dot exe It was just a simple strings thing. So every time it get flag. It's actually just the same Output or whatever I need to do to actually display the flag out So if I were to just simply run get flag to this H it gives me the flag now an earlier one that I solved was the easy symbols and That one it was Morse code right whenever we opened up. I can get some blind text open for us I Should be able to open up Where's this file? It was Morse code and I did that with the online tool But since I want to create this get flag script I need to be able to actually do that Morse code translation in a script and I want to do that in Python So what I did was I went ahead and googled Python Morse code and Actually the first thing I found I kind of just wanted to steal so that one I didn't end up using I actually ended up using the simple one in get because I thought it was a little cleaner and did more of what I needed it to do so I literally literally just stole this code and Let's actually work with it. Let's go ahead and create a in our last CTF folder Let's go ahead and create one in our easy symbols thing. Let's just call it Morse code dot pi and I will go ahead and add our shebang line and I will actually remove my name from The stuff that file output X like exercises for us because I will actually finish this with everything that the guy had Displayed for so that I found online and I'll throw the link in there Okay, now I'll actually start to clean the script up because if I'm gonna steal it I might as well at least make it clean. I notice it is nowhere near a pep 8 standard compliant So I figured I'd fix that So everything that I have selected. Let's try and remove Whatever is in there. I Want to remove that trailing space? so what I did was I took regular expression matches this and Oh forgot to Wrap those in parentheses there so it will regular expression replace those More self of it needs to have a space afterwards That should be on the same line and it'll have to indent everything to go along with it Looks like that is not spaced out enough. So let's bring that out a little more I'm again to do that with some regular expressions Remembering as much of the space characters as I can I'll throw that in an expression And then I'll replace them all and add another space character in there. So they're all in line and then I'll close This space there. So now our indentation is correct and there's a Pepe compliant there What is that air closing bracket does not match visual indentation should you match that way? Is that what you want? All right has to be just in line with all the data that's already there. Okay, that's fine Let's add a few space characters in with all of this code here to make that Pepe compliance That looks fine test code looks fine. It's actually had another line there To remove those spaces between those keyword arguments kill any white space in a line Same thing with adding two spaces make sure there is no white space on blank lines Again, and we're pretty good Cool. So let's make sure this code actually works. It looks like decode morse is a function this guy created to actually Decode morse code looks like test code is already in morse for us So if I run this it says hello daily programmer. Good luck on the channels today. Cool And We should now be good Let's use this as a module or something as a library we can actually work with and I'll create a new get flag dot pi Scripts I'll add my shebang line Once my shift key works that has like that I feel like my shit key has like food stuck underneath it or whatever So it's it's occasionally very sensitive. So let's go ahead and import morse code and what we will do is we will Let's try and run. Actually, let's let's take the take the value that we're grabbing here easy symbols It's out of the easy text, right? So yeah, you could have read this from a file. I don't really want to Little lazy for writing this code here Morse string I suppose can be What is it? What is it we want right now? Oh We want to use our string replacing the ampersand character With a dot I think that was one represent. Yeah that rip now represented a dot a dash and Then the exclamation point represented a period and We can print morse code dot since we're using that as a module We can run the function inside there decode morse Was the name of the function and then we'll pass in our morse string now when we run this Oh, oh string dot replace Why is that wrong? Yeah, Nate string and none type Where's that going wrong? Okay, do after doing a little bit more hunting it looks like The morse code that I found online does not even support the lowercase letters So let's keep hunting to see if there are Things that actually do Work with lowercase characters Okay. Yeah, this one this one has it all Can I steal this I'm gonna steal this our morse code library That we're kind of using cool, that looks like it works for us Morse tab is the name of the variable that we were using so let's just keep that there Again, let's make this pep8 compliant And let's make everything a line again So I'll just take all of the beginning white space And slap on another space character. So that's all online And then we'll bring our Trailing curly brace to the end with it as well And now we should be able to run this Nope Still not getting it. Hmm Okay, after doing a little bit more testing and debugging I noticed since this is a recursive function and we're getting these errors here that okay Can't concatenate string and none type whenever we try and return letter plus decode morse blah, blah, blah I'm assuming it's not starting with an empty string Since this is all inside of an if and l statement may not actually be returning a empty string so Just to as a catch all I put a return empty string right here And now when I run it we do get the whole morse was cool thing But we're missing our l morse was cool And I noticed again that oh it's actually testing this stuff With the character with a space character. So I actually just append it on a Space character and then it gets the full l So not the best algorithm. I think that morse code is using I guess that's kind of what happens and we don't write it ourselves And we trust someone else and someone someone else's code, but whatever We do successfully get the uh morse was cool flag um Yeah, so That's it. We're done. I guess we did write our get flag script and we successfully stole cold off the internet to work for us And clean it up a bit But even then it's still not the best thing for us It took a little bit of debugging to actually get it to work the way we wanted it to and even then it's still Not the best, but whatever. Here's our our get flag Script in our terminal. We can of course, uh make this Executable we can ch mod plus x Get flag dot pi and whenever we were in the terminal if we were looking back at our stuff later on We could use our get flag script and finally get the what we would have submitted in our uh in our ctf So cool. Thanks for watching guys. Hope you enjoyed that one a little bit of more python code and uh stealing stuff off the internet To get it to work the way you wanted to Good idea anyway to create a get flag script and everything that you do just to automate the process of how you solve the challenge in ctfs so three See you in another video