 Hello everyone and welcome back to another Python programming video. We're on the Python challenge We're finally on to challenge number 12 and we were presented with this picture of Some guy dealing cards. I think there isn't any hint at the bottom. There is no scroll bar. So there's no more to this page I guess by default we do some investigation some to view the page source and It's pretty bare bones the title of the page is dealing evil Same old CSS file that we've always seen the only thing we actually see here is this image The image is called evil one dot jpeg Well instinctively I want to kind of research if there is a evil module in Python I don't know why there would be I don't think there is Yeah, I mean I see Python is not Java Bad ideas for Python, but no documentation for a module. So I don't think that is the case In the last couple of videos and tutorials. We were looking at the image itself, and I think I do see some like lines through it maybe it is Let's save the image. I'll put in my desktop and We'll take a gander at it. Now if I open this in paint Let's see if we get anything there's our image and I see like a pattern of Stuff You can see all these Blocks and things here Different colors looks like kind of a filter though because it changes with each color like whatever the Color is behind it. See this is all red Don't think there would be Like any messages hidden in the text or messages that we have to work with through the pixels We've been doing that in the other tutorials and the other challenges Because there's just no way that like this color over and over and over again, especially in the black zone because see This is all black There's nothing that we can really get from this. I don't think remove this dealing evil Which are only hidden the title of the page. I see pictures Cards Take the source one more time Dealing evil style CSS Image source equals evil one dot JPEG. Let's go there in our URL evil Evil one dot JPEG Yeah, same image 640 by 480. I think Who's to say there isn't an an evil like to evil to Oh, oh, yeah, there is Not JPEG Hi fin What is that? Dot GFX not JPEG. Okay, maybe it's evil to dot GFX. Oh Yep, that's a file. All right, let's save that Okay, and is there is there an evil one GFX is I mean if we change the file extension there might be another one No, that doesn't exist. Is there an evil three JPEG? No more evils, okay, sure Sure, whatever I'm an evil 4 JPEG Okay, so there must be a file of evil JPEG though evil 4 JPEG. I'm gonna save evil 3 JPEG To my desktop along with evil 4 JPEG even if it is corrupt Because I might be able to like look through then maybe there are secrets in there check evil 5 JPEG Okay, now that one doesn't exist evil 6 7 Doesn't exist here. I'm an evil zero. I think that's all that we're gonna get Evil 2 is kind of our big hint here now Not JPEG dot GFX All right, so go back to my desktop. Here are the files. We just downloaded three JPEG I'm gonna zoom in Pretty sure there's nothing else here. I really don't think I'm gonna find these all part of investigation evil 4 Windows photo viewer can't open this picture because it's corrupt. Okay, great. Can this thing be open with? Windows view photo viewer. I'll just drag it in And no does not open. I want to see what's in evil Evil 2.gfx. I'm gonna put it in open it with sublime text Crap That is not an easily readable text file This looks like like some weird format Probably bites or something. I'll look through it bites. So let's create a Python script 12.pi is working out right now. Yeah, so GFX equals open Evil 2.gfx. Let's just print GFX dot read and GFX close run this Decode error output not utf-8. That's fantastic So normally if you're opening a file in Python you the open Like function will open the file for reading by default it has like a mode of r for reading But if we're trying to read through like each individual bite You can add a B for binary for binary reading to look through each individual bite So I Think I'm gonna end up doing that because if it's this if this file is like full of all this kinds of data We're gonna we can only look through it not as plain text obviously because that's just not gonna work for us But we have to look through it as bytes. So now if I try this They can do For bite GFX read Print bite Okay, now we get a bunch of this stuff, but we can't look through this so If you want to get like the value of bytes, I think you pass it to int Int No, in Val literal for int with base 10 Okay, no, so I'm getting confused it should be ord or does the function she be burning them now we run this whoa, okay It's a lot of stuff I don't know what to do it's like any of this stuff. I want to try and find a pattern It looks because it looks like there might be one with like these zeros here you can see him like These like three sets of zeros and another three sets of zeros This is at the very bottom of the output though unlike here. They have them in fours But if I scroll all the way back up to the top There isn't that pattern Like all the numbers are different. It's a different bite or some different representation or something Looks like two five five here. There's another two five five here. That's a separation of three Same kind of thing with two two four right here separation of three But it looks like there was stuff down at the bottom I'm gonna scroll back down to that I think I might be able to do a little bit better investigation on there because these zeros really like prove to me Okay, that there is some separation and it does Like I see them in fours here the four zeros and then another number and then four zeros and then another number If I keep scrolling I keep scrolling up and I see like tons more of these You seem to okay. That's a lot of zeros But look, there's like one two three four This would be where the other number would be and then there's one two three four again So this this zero the one that's separating the others must be just another Value of okay, see now it's 38 and 43 and it's just these four zeros that are being separated But those other places would have had values way up here So it's got to be some kind of data It's not plain text obviously, but if we want this data, we want to like look through it We got to be able to index it cuz right you see how these other Like separated by four values that means there are other I'm thinking that there's like they're like separate pieces of data so What I'll do is we'll say gfx equals dot read and then we'll do for bite in I'll change this to be for be in length of Sort of be in range of length of GFX because now we're reading through it with an index so we can do ord gfx Be we'll have the same output, but now we're working with numbers And it has no attribute close so gfx file can equal this And then gfx can equal File handle not read about that So file handles will close so we run this and We can see all of these like separation with these zeros in either pairs of three or later on I guess I'm not really pairs if they're but it's like sets of four But earlier they had data so they must have something there Like at the very top right if we've been working with jpegs. I feel like they're probably gonna store something in jpegs So I'm just gonna go with first three Because these these separations of three here What I'm gonna do is I'm gonna say Let's say images equals a dict because I'm gonna use I'm gonna try and use jpegs I'm gonna try and put the data in jpegs And what I'm gonna do is for I in range Four because if we want three And we're doing like one two Four Because if they're being separated by Three is that means I know there's there's four here, but that doesn't make sense because if we got one two three This is so hard to think about Ranging for image Caps lock Images images I Equal we need the image of module import image capital I image dot new RGB form and Size would be like 640 by 480 or something wait a second We can't put pixels so the image because we're reading the reading pure data We're reading like the bytes out of gfx out of this gfx like file so image We're not gonna need we're gonna have to do this with the same Python Open file buffer so image plus string I Jpeg so it's indexed with the like proper number right and We'll have to write to it and Because we want binary here. So now at the very end. I'll do for I and range for Images I So now if I run this all of my I'll show you These four images zero one two and three have been created. So that works fine for us And what I want to do More time see the output zero zero zero So three being separated which means there might be four but It looks like if it were to start at these zeros look there are two more at the very even at the very end here So one two three four and then five It's like I have to go through five of them So I'm just gonna set a variable for this number is going to equal five for range in number Do the same thing down here when we close them for range in number run this Now I've got four images that I'm working with. Oh, I'm sorry Getting ahead of myself Just I just want to show you these these images four images that we got sorry five images But it goes up to four because of the computer counting move and What I'll try and do is Write to each of the images so for I in range Number I'll do images I Dot right and we're gonna get some data out of gfx We're not gonna use or in this case because we want the actual bite We want the actual data, so we'll comment this out I write gfxb For the bite that we're looking at plus I So this means that for every five ones that we're looking at it'll get all five of those in separate ones And if we're counting like that by the fours or by the fives we have to step by that number So Now when I do this M is not to find Oh fuck what M run Okay, oh I got something I got something guys. I got something. Let me show you. Let me show you Here we go Image zero image one image two inches three and four look like they have been filled with something this pro port Image four is itty right, but that's crossed out this this pro This pro this professional sport Itty This pro port T. I don't know what this image three is iron iron all I know I know disproportionate This proportionality Hey disproportionality Why is it why crossed out? I'm just gonna try it Go to our webpage Disproportionality I was almost the right dot JPEG. Is there a dot JPEG? No dot HTML disproportionate Okay It was crossed out. So maybe Maybe it's just Disproportional Disproportional dot HTML. Oh Oh We got it sweet Holy crap that took forever and I still don't even really know what what my code is doing But I mean we got there challenge number 13 baby look at that. All right, so What I am to understand is that gfx is Raw data of Probably a JPEG file because if all of these other images that we're creating are JPEGs and it's like it's like containing them inside it with different different bites at an indexes of five, right and The only way that we like figured that out I'm just gonna go back to our original for loop for be in range of the length of gfx Then what would we kind of notice that was by print gfx? Or we have to pass it toward because or does what kind of showed us like actual values that we can look at and kind of investigate and Like there are these patterns of Four zero separating other numbers so okay Those this must be a separation for something and it also must show that because at the beginning of these data of this data There was stuff there right like these aren't zero as this is 137 and 71 and 137 again, so I don't know maybe they're I we figured out or at least took a guess that these were different files Different pieces of data that will correspond to some other thing which I mean JPEG files work and JPEG files We'll be working with this entire time evil three evil four and all the other images and the other challenges so reading by bites and re in writing by bites and Doing them in five different images images zero one two three and four. That's kind of what we built here and Let me all right. I'll run it with our correct loop get our images back for us Except it's just disproportion. I don't know what's up with image three. I don't know why it's like cutting half whatever Only dude here we are Challenge number 13 we did it All right. Thanks for watching guys. I hope you enjoyed this video. I mean I'm a little speechless, but it works like we got it Thanks guys. Hope you enjoyed this. Hope you're enjoying the series if you are maybe like the video Maybe leave me a comment. Maybe subscribe. It's up to you. See you soon