 Hey everyone, this is another YouTube video right up for the challenge Caesar's Complication for 20 points on TJCTF, the most recent capture-to-flag competition. It says King Julius Caesar was infamous for his word search solving speed. So we have a file we can download here, I will copy that, and we can W get it to get it in our possession, and it is simply just a puzzle, so I'll name it puzzle.tex. If we cat it out, we can view it on the terminal, and it looks like a bunch of garbage and nonsense. So I'm going to do some deductive reasoning from this challenge title and the challenge prompt in that this is a Caesar cipher, but it's also a word search. So that means that this is a 100 by 100 word search, however there are other permutations of it or different renditions of it that are going through each of the different Caesar cipher. So our flag must be in one of these word searches that has to be computed via a Caesar cipher. So it's got to be shifted all the 26 positions in the alphabet, and then we'll have to solve the word search to find the flag. So I looked at this and I said, okay, I can do that. I know that I can program something to figure this out, and I was pretty determined to solve this challenge. So I've written code to do a Caesar cipher, but I have not written code to solve a word search. I've written code to generate a word search. So I thought, all right, let's go to the internet and just try and find a Python word search solver. And a couple results I found myself were some GitHub project that actually already did this all for me. So I wanted to go ahead and get cloned this. I want to take a look, see what I can work with, open it up because it looks like all it needs is just, okay, these are the words I want to try and find. You can offer a puzzle in plain text just like that, and it'll tell you where the words are. Sweet. So I checked out the word search puzzle. I opened up a word search pie, but let's actually just get the puzzle in this directory so we can work with it, because I'm going to be modifying the word search script itself. I'm going to give myself a shebang line and props to this guy, Robbie Barrett, whoever you are, because this is going to be the awesome win for our solution here. We know we want to track down our flag, and that's going to be in simply tjctf. I'm actually going to be using it in the lower case. They say that this program should be running 100% uppercase or 100% lowercase. It looks like our puzzle is already in lowercase. And I had the curiosity as to whether or not our curly braces would also be translated. Like will my shift go through all 255 letters or characters in the ASCII table or just alphabet characters? I had, I actually asked in the IRC, didn't really get any results. So I figured, all right, I'll just try both. And I'm going to go through a methodology that does keep the curly braces in place. So some of you may have seen the other video that I've written for a Caesar cipher. And I'm just going to quickly bang that out right now, because it's pretty handy. We do want the collections module for a deck or a DQ object or data type that we can rotate. And I want the string library so I have letters that I can work with as well. So I will say that I want a lower variable that is just a deck or DQ type. Someone please tell me how to pronounce this because I'm going to go forever always calling it the wrong thing, but created type for that. And then we'll rotate it by the number we want to rotate by. So that does our simple Caesar cipher for us. And let's create it as a list rather than leaving it in that data type that it's already in. And then we can actually rotate the string as we need to return rotate string dot translate with the string modules function make trans between the original lower case variable and our new lower case variable that we just rotated. So that will run through a simple Caesar cipher for us. So let's actually import our puzzle now. We can just say original can equal like open puzzle dot text and original actually I should call that handle so I can close it handle dot read cool. So let's just print that out to make sure we've got it exits and I need to run collections my bad. Okay, so now we've got that puzzle loaded and if we wanted to we can run Caesar on it to shift it by say one character the very very top of this is UX GA. So if I run this now collections my bad very very top of this is now TWF. So okay, we know that our Caesar cipher is working just fine for us. So let's go ahead now and recreate puzzle can equal Caesar with our original puzzle rotated with an iterator for I in range 26 characters right all letters in the alphabet. Let's indent the entirety of this and then we can say that we want to Caesar cipher it with I and then let's actually just print out what permutation we were on permutation I and then we display it blah blah blah. We don't need that keep in mind thing that's very annoying. Let's actually just run this here and it looks like we got a hit at the very bottom you can see TJ CTF is at row 74 and column 67 going upwards and right diagonally cool. So let's go ahead that was on what index yeah permutation 18. So now that we have that solved we can go ahead and just write a new solution one text with right and then we can write to it Caesar of original 18 and then we can exit. So now we should have the solution dot text and it said when we ran this it's at row 74 and column 67. So let's go to line number 74 cool and column should be 67. Okay, I see a T there and it says it's going up and right diagonally okay. So what I did in this case was I actually split my window and tried to get them both side by side so I could see the TJ CTF right here and then I would go one by one it literally just copying this flag out with a space character so that I could keep my place in the loop and also like in the grid and still extract these characters just for me. I will bury you I will save you from the pain of going through this and I'll just get the flag here. The flag that I end with is TJ CTF IDES of March so you can submit that and that is the solution to this challenge. But I was pretty neat I thought this was kind of a cool challenge interesting idea to put a Caesar cipher into a word search we can go ahead and save that in the file that we want. I don't need to write a get flag script for that but that would bring you up 20 points on a pretty neat challenge from TJ CTF. Hey quick shout out to my supporters and the people that love me on Patreon thank you guys so much for all of your help and your support and donations. One dollar a month on Patreon will give you a special shout out just like this at the end of every video. Five dollars a month on Patreon will give you early access to everything that I release on YouTube before it gets set to go live. Hey if you did like this video and you want to see more CTF video write ups, programming tutorials or other things that I do please do like comment and subscribe. Click in the description for our Discord server if you want to play other capture flag competitions with me or other cool people. It is an awesome community of CTF players, programmers, hackers so definitely check it out. Hey I'd love to see you on Patreon and I hope to see you in the next video. Thanks guys.