 Hello, YouTube. This is a video right up for the challenge diversity for 30 points in the cryptography category of HATCON CTF 2018 So the challenge from here is so much diversity my mind boggles and we're given this text Which looks like it has a lot of numbers with supposedly a B preface saying an X preface saying a D preface saying an O preface saying for different kinds of Numbers or data just represented in different ways maybe base 2 or base 16 or base 10 etc. So binary hexadecimal decimal and octal So let's go ahead and just convert all these to what we would expect to see and then see if they actually translate into anything else So I'm gonna open up my terminal I'm just going to create a script here that I can work with them Go ahead and make a shebang line for Python and I'm gonna make a string for this Just call it s and we'll start to work So what I want to do is gonna go ahead and replace just kind of a quick and easy thing to remove all the spaces with a B the preface it to change them to a space zero B So it puts them in a form that Python can understand The only thing that we're gonna miss here is this very first binary value because there is no space Prefacing this so I'm just gonna put a zero there and that'll make things easier for us in the long run And we'll do the same thing with the hexadecimal values. We'll put a zero X and said Taking note of the space So we'll keep track of all those and that way Python will be able to handle them very easily same thing with octal and for decimal. It's a little bit different because binary, I'm sorry Python doesn't use a D to preface a decimal number. It just doesn't have anything to preface it It's just the regular number so if I wanted to I could print out s now and view it and we have all of these in a form that Python could Understand if we were to just slap this in a Python interpreter. Let's go ahead and actually make it an array So we can handle it pretty easily So I'm gonna change all the spaces to commas and I'm gonna go ahead and say s can equal start of a Brace here with the string added in and same thing with an ending string brace here So we've got all this now and Python gonna handle this very very easily if we let it eval this However, I don't want to just straight up eval because that's kind of bad What I'm gonna do is I'm gonna actually just get it from the PON module because they have a safe eval function You can check out in their documentation. So what I'm gonna do is it going to run Python Safe eval and that function comes from the PON module here And we actually want to use the expression so .expr and then we'll pass in s I'll go ahead and print this out looks like sublime text won't want to run it So I'll have it in my terminal here We just run Python 8 and you can see okay It has converted all of those different like bases whether or not it be binary decimal hex or octal into just straight decimal So what we can do now is do some handy list comprehension to go ahead and take the character values of all of these Let's use character of X for X in that string or that list there And we can go ahead and run this and now you can see we've got some English text coming together Well, let's go ahead and join these as a string and Now you should be able to see hey welcome to hack on 18 organize blah blah blah here is your flag I wish all the tasks were this easy dark code sweet So we could carve that out if we really wanted to let's do that just for nice practice I suppose write our own get flag script. We don't need to import the whole name space Let's just import re and then we'll say New s can equal that re dot find all With our flag format dark code Everything inside the curly braces and the current s to print that out We get a hit after we run in the terminal great Let's get the first element out of that and that is our flag go ahead and move this if we wanted to make that a power get flag script Mark it as executable Take that flag Create a static file with it just in case our script no longer works for whatever reason and we can mark that challenge as complete So simple and easy pretty cool. Just recognizing that it were just different kinds of bases denoting those numbers Quick shout out to all my supporters on patreon. Thank you guys so much I cannot say it enough one dollar a month or more on patreon will give you a special shout out Just like this at the end of every video five dollars or more on patreon will give you early access to everything They're released on YouTube before it goes live because I know in their court in bulk and let YouTube gradually release them slowly on a schedule If you did like this video, please do like comment and subscribe Join our discord server link the description. It is a cool community of CTF players programmers and hackers You should totally join it if you want to hang out with me and other awesome people We're gonna tackle I CTF when it's coming up next weekend I think Nighthawk CTF just got postponed, but there are some practice challenges. So jump on there and game with us Hey, I would love to see you guys on patreon and I would love to see you in the next video. See you soon