 And welcome, this is the first in a series on many web browsers. We're going to be looking at using Netcat, talk about more of that in a moment, to set up a web server. And you may be thinking, oh, I've seen this before, blah, blah, blah, well, hopefully in this series I'm going to show you some things you haven't seen before. And I'm also in this first video going to touch on some problems you might have if you've tried this before and it didn't work. So first off, there are three different programs that we're looking at that are very similar. We have Netcat, which is also sometimes on your system as NC. We have NCAT, which is a very similar program but technically different. And then we also have the lightweight NC or the lightweight version of Netcat that's built in the busy box, which is a very stripped down version. And although they work a lot alike, there are some differences that if you were unaware of may cause problems and make this little technique not work for you. So let's quickly look at them. So actually let me make my shell full screen here and I'm going to split the screen. Now I have all three installed on my system right now. I have Busybox and Busybox is a program that I've talked about a lot in the past. If you have a very lightweight Linux device such as a router, modem, or even your cell phone, there's a good chance there's Busybox on there. Some systems might have Toybox, which is a program that's kind of like Busybox. I'm not going to go into the details of that. But Busybox you can get running on pretty much anything. It has, it fully compiled with all its tools built in. It has I think over 200 tools and it's around one megabyte. So it's great for these lightweight systems and you can strip it down a whole lot. And so we definitely want to make sure this works because the whole point of this series is lightweight web servers. So maybe you're going to want to use this on something like a router or modem or some lightweight device. Now that being said, the full version of Busybox has an actual web server built in and use that before you use this or really use any web server, whether it's Python's built in web server, Apache or any of the others. This is kind of like a, I have no other options. I want to set up a web server and all I have is Netcat because it's on pretty much everything. And so it's for these series are for when you're in a pinch or just to understand it better and have some fun with it. Anyway, I've talked enough. Let's move into the actual tutorial. So real quick, if I man Netcat and down here I man NC, you'll see it's the same program once just linking NC is just linking to Netcat, most likely. So you can see that they have the same same man file because the same program they even referred to it as NC inside here. Let me quit out of that. Now let me man NCAT. And for years, I didn't realize there was a difference between these two. And as you can see, the man files different, it is a different program, a lot of the same commands, but a lot of different commands as well. And if we go down the bomb, I believe this is made by the same people who make NMAP, which is a port scanner you've probably used before. Yeah, you can see right here that it's made by those same people. And I think somewhere either in here or on their website I read today, they refer to it as NC or sorry, Ncat as Netcat for the modern day or something along those lines. So anyway, now let's also look at Busybox, so I'm going to type in Busybox and I'm going to type in NC and hit enter. And you can see its help file here is very limited, but it has enough to do what we need to do today. But one of the things that you may have experienced that you may have tried that this creating a web server didn't work. So let's give an example of that. Let me go ahead and close this here and move this back up here. So on top screen here, I have my shell where I'm going to be running my server. And I have a web browser down here. I have it in private mode to make sure I'm not cashing anything and cheating. And oops, I just accidentally grabbed that. Let's try that again. Okay, so you could do something like this. We can say netcat-l for listen-p for port and give it a port. It's got to be a port that you have permission to use. So a lot of times lower ports, regular users don't have access to. And it also has to be a port that's not being used. So I'm just using 8000 in my case. So use whatever port that you have available. And of course, web servers normally run on port 80. And if you run it on port 80, which you probably need permission to do as a normal user, you probably can't do that in most cases. But if you run it on port 80, then the user doesn't have to type in what port because it's going to default to port 80 in their web browser. Anyway, then we do dash C and we can give it a command. And inside these single quotes, we have two commands. They're both echo commands. So we're echoing out this part right here. Now since netcat is running as a web server, you've got to give it the web server headers. So normally when you run a web server like Apache, for example, and you pass out HTML files, Apache automatically puts these headers in. We're going to have to put this in here. And basically we're saying, you know, this is an HTTP server version, 200 is your code saying you've connected successfully, OK. Then we've got new line character. And then we're just giving it the date and then two more new line characters here. And then we can pass it our HTML. In this case, we're just going to pass it a paragraph tag saying, how are you today? So if I hit enter and I run this, so it's running now, I can go down to my web browser and I can type in the IP address. But since I'm on the same machine, I can just type in local host and I'm going to give it the port of 8,000. Again, if you're running it on port 80, you don't have to give it a port. I'm going to go ahead and hit enter. And that didn't work. Did I type something wrong? The answer is yes, I did type something wrong. Yes, that's kind of my point that this can get confusing because there's different programs. That command works with NCAT, but not netcat. So I'm going to hit enter here. I'm going to refresh down here. And you can see I got my HTML output down here. So again, that command is NCAT-L for listen-P for port and give a port and then dash C for a command you want to run and pass the text to the client. So that doesn't work with netcat. It doesn't work with busybox because busybox doesn't even have the dash C option. Netcat doesn't. Not sure why it doesn't work in netcat. I feel like it may have for me in the past, but doesn't now. So I'm going to show you a way that works with all three. And that way is by, and I'm going to copy and paste code in this just because there's a lot to type. So here I'm saying that same little part that's up here in this string. I'm saying echo out this. And again, we're passing it that this is a HTTP server, code 200 saying that you've connected successfully OK. And then we're giving it some new line characters here. And then we're saying, echo, how are you today inside paragraph tags? And we're putting that around in curly braces here, saying that we want to pass all the output. And we're going to pipe that, pipe that into netcat-L for local or listen. That means listen-P8000 and we'll hit Enter. And again, it's waiting. And if I refresh down here, you can see that it gave me the output here. Actually, let's go ahead and stop that and refresh it so you can see since it was the same message, we'll change the message up here. We'll say it, we'll say, let us say films by Chris. And we will refresh that. And you can see we got the output on the web server here. This is the information from the web browser, the web browser, the web browser sends this information, netcat reads it, and then responds with this information here. And to do it again, but this time we'll change it to ncat. And we'll change the message. We'll say, let us say hello from ncat. So we can see a difference. We'll refresh our page down here. And it says hello from ncat. So it works with netcat, ncat. And now let's check it with busybox. So we'll just pass it to busybox and see. Let's actually change the message so that we know from busybox and we'll refresh it. And you can see that it works. So using this technique works on all three of them. So it's a little more universal then. And I've seen a number of ways to do this. And this is the one that I know works with all three. So again, curly braces. And inside the curly braces, we're going to say echo-e. We're going to give it our HTTP header. We're going to echo out our paragraph or whatever HTML we have in here. And we're going to pass it to our client using netcat. We're going to pipe it into whatever netcat or ncat or NC that we are using. Now, you can do the same thing and pass it files, which we're going to get into the next video, because I don't want this video to get too long. We're going to be looking at in the next video, not only passing it HTML this way. We're going to pass HTML files. And then we're also going to pass it command output. And then after that, we'll get into embedding images and sounds and that sort of thing into our web page. So that's it. I think you're watching. Again, this is part of a series. It's the first in the series. There'll be a link hopefully at the end of this video or in the description of this video to the full playlist. So be sure to come back for the next video where we get a little more in depth on this. So, so far, probably haven't shown you anything you haven't seen other than a more universal way of doing it. But we're going to start passing it more things and it's going to get more interesting. I promise, I promise. This first video is the most boring out of the videos in this series. So I do thank you for watching. As always, please visit filmsbychrist.com. That's Chris of the K. There's a link in the description. Visit there, visit my Patreon page, patreon.com. Ford slash Metal X 1000. And as always, I hope that you have a great day.