 Hello, and this series that we're starting off now is on playing with binary files And I thought a good way to start off is by creating some binary files So I'm on Debian Linux here, and we're going to Compile some stuff both for Linux and for Windows Right here on my Debian machine. So I have this folder made and you can see I've got two C programs in it One is just a basic Shell output and the other one is a very very basic GUI dialogue for Windows Both are just hello worlds and then we also have a folder that if I list out you can see as an icon file in it Which we'll be using towards the end of this tutorial. So first off. Let's just cat out our Main dot C here and you can see it's very basic. We got our main function and we got our hello world returning zero Okay, so let's compile that I'm going to use GCC Which if you don't already have installed you can install with aptitude or apt-get or whatever package manager you prefer I'm gonna say main dot C. I'm gonna say the output is main. It's compiled We got no errors on the output there. So we're gonna say dot slash main and it we get hello world Now let's go ahead and do the same thing but for Windows and we're going to use Ming 32 Ming W 32 And the name of the file may change Depending on what operating system you're running But if I say aptitude and I just search or apt-get if that's what you use and I search for a package I just say mean W You can see you get a bunch of packages and you just want to make sure you have the one installed that you want You can do 64 bit or 32 bit. I'm on a 64 bit Linux system, but I'm gonna be compiling for win 32 I'm gonna be testing this out on a XP 32 bit machine and a virtual machine But all depending on what your goal is 32 bit is good because it's 64 bit is backwards compatible. So what we do now is once we have that installed and again, this may change slightly this command I'll say I I 586 dash Ming W 32 MS VC and if we hit tab a few times here, you can see there's a bunch of different ones here. I'm gonna use GCC and again, this may change depending on your distribution. It might be I 686 but once you have it installed you should be able to find it using aptitude or apt-get But one now we're gonna use that we're gonna say main dot cease we're using the same C file because It's gonna work on both operating systems without any changes and we're gonna say dash O and because it's a Windows Xcube over now on to dot exe So we've created that we list it and it's right there. Of course, we can't run it on here Natively anyway, so let's go to XP over here. I have a web server set up on my main machine there So I can say one nine two One six eight and we'll go to where I have that save. So there it is I'm going to download that Save it Open that folder and of course if I double click on this and click run you're not gonna see very much We have no pause or anything so it open and close real fast. So actually let's do this and we will run cmd and we'll go to my documents downloads Durout the directory. Sorry. This isn't any bigger But you can see we have in there main dot exe when I hit it. Hello world. So our executable worked there So let's go back over here and actually no, I'll do that later on I'm thinking about adding something to the tutorial I don't have already planned. So let's do the same thing but with our GUI for Windows So let's go ahead and cat out main If we used to see our code here very very simple We're using the Windows header file, which I don't necessarily recommend because now you're using something that's only going to work natively on Windows and there are other options out there But for the sake of the tutorial keeping things simple without having to install any other libraries We're going to use it and we're going to do a message box that says hello world with an okay button and returns zero So basically same as our last command But we're going to tell the new File which is main GUI and we'll call the output When hello sure that works and we will hit enter And so we've created that we can list that out you can see it right there a little more information on them So that's it right there. We're going to go back over here if we refresh the browser There it is We're gonna click save Come over here there it is and if I double-click it and click run you can see we get our hello world But we also still get our little console window over here So let's go ahead and remove that console window. You don't change anything in the code to get rid of that you just give the Compiler different arguments, so we're writing the same argument as before We're going to just add dash M Windows telling it that this is a Windows not a DOS or you know shell or console program for Windows Doing that same thing so without changing the code just adding dash M windows coming back over here Redownloading it Which Firefox will append to it a one there now you can run that click run And as you can see we got our pop-up here dialog box without the console window So great, but you also notice that these programs all have the very basic generic icon because we haven't issued it an icon so we're gonna come in here and We're going to look as it get as it said earlier under my RES it's just a folder. I made you could have it in the same folder, but I put my resource files under a different folder I have an icon let's go ahead and Display that out so you can see what it looks like icon there you go I made it 64 by 64. It's just an image. I got off Google and it's just a tux on a hard drive or something so We're going to use that so what we have to do is we have to use the compiler to make that into an object That we're going to get to then embed into our exe. So we need what we will call a Resource file. So we're gonna say main dot RC. Oh, sorry Let's use Vim a text editor whatever text editor you prefer main RC and then here. We're just going to type in a line We're going to say ID space icon and we're going to say where the Resources so it's in my resource folder since we'll be compiling from this current folder the name of it and that is pretty much it There's other things you can do with the resource files, but we're just doing an icon That's all you have to do to create that file now We're going to use the compiler and that file to create the actual object. So we'll say I5 86 and this time instead of GCC. We're going to say win dress So so wind resource dash oh and We're going to I'll put it in that same folder the icon is in but we'll call it icon dot oh Because it's an object file. We're creating you can also do this to embed images for other uses in your xk wheels But we're not going to go into that today, but we're creating the object and we're going to use what we put into our resource File here. So no errors on the output there now if I list my resource folder Not only do we have the icon itself, which we can now delete Yeah, I don't know why you would do that save for future use, but you also have our objects So now we can run our same compile command that we ran earlier We're going to add in here to use this resource file and again, we're going to have our No windows on this one. So I'll hit enter no errors and by the way, I keep overriding the same file You do want to take that into account that GCC and other compilers don't tend to warn you if you're going to overwrite a file So save this and it's going to create a new one and look we have an icon with tux on it and We can click that run it same thing no console, but we got a little pop-up here and control L to clear the screen So I just want to say also that let's say you do have a console or shell program That you're compiling and it's gonna be running a lot of things maybe going through lots of files and stuff like that And you don't necessarily want the shell window to show up You can do the same thing of dash M Windows on a non GUI program and that way you won't see that console or terminal window pop open Although if you do do a system call it may open up a new window that you went will then see But all depending on how you write the program But just be aware if you wanted a program to run in the background with no GUI you can use the dash M Windows Argument for the compiler So that's a quick look at Compiling cross compiling adding icons I know somebody will probably ask the question of how do you embed icons and executable for Linux? And the simple answer is you don't because is it's not a good way to do things For lots of reasons, but I do thank you for watching in the next tutorial We're going to get into picking apart these binaries We just created as well as other binary files and then the week after that I think we'll be diving into picking apart binary files that are Network package packages that you captured while sniffing either using wire sharp shark or TCP dump or ether cap So I hope that you're going to enjoy this series. I hope you look forward to them and Hope to see you next week Have a great day. Oh and also as always, please visit films by Chris comm that's Chris the decay Should be a link in the description as well as a link to all the notes for this tutorial Thank you for watching and have a great day As we're talking before we started this interview he's going to touch on this lightly in this interview But in the future he's probably going to go into more detail and more technical aspect of it in future talks Sure, so, um, you know what we did at this company is we used a versioning software called If you enjoy my tutorials and would like to see more Please think about contributing to my patreon account at patreon.com forward slash metal x 1000