 Hello and welcome to a video from filmsbychrist.com. That's Chris the K. I am Chris. There's a link to my website in the description This video and today we're gonna be looking at a poor man's port scanner Now if you need to do port scanning my personal opinion the best port scanner out there is gonna be nMap And you should use that if you can but let's say you don't have nMap There are other options that you may not know about and map is on is easy to install on systems But if you're on a minimal system you may not but if you have bash I specifically say bash because this is a bash feature you may not know about unless you've been around the Linux world for a while Is that bash actually has networking capabilities built in if I was to list out? Stuff in my dev directory, which is my devices. So, you know, all basically mostly hardware stuff You can see all this stuff here, you know video would usually be webcams or other video inputs But if we look at T's here, see we have these TTY's, but there's no TCP now if I was to Echo into dev and give it a file name that either exists or doesn't exist most cases I'm going to get a permission denied right because I don't have permission to write stuff there But if I was to write to TCP and give it some a number and then another number It just kind of hangs. What's going on there? Why why is it not giving me permission denied or file does not exist or something along those lines? Control C to kill that because even though you don't see the dev TCP inside that directory it does exist within bash bash will create these things as we go so if I was to echo into that I could give it a IP address or domain name and a port and I can retrieve information or at least detect information from those servers you can use this to pull down files and Web pages from the internet the problem with it and and that's something you can look up I'm not gonna go over in this video It's not as useful as it used to be because of HTTPS as far as I'm I know HTTPS the encryption doesn't work through this so you'll just basically get an error if anyone Can correct me and point me to tutorials on doing this with HTTPS that'd be great But even though it's not as useful as it used to be for downloading files and information from web servers You can still use it as a port scanner now There'll be directions or notes in the description of this video to everything I'm about to go over But if I was to echo Into TCP or dev TCP again give it an IP address or a domain name I'll just give it one two seven dot zero dot zero dot one which is same as local hosts I'm pointing it at my own machine and then I go forward slash in a port number in this case I'll do eight right where we're gonna do Oh, we get an error connection refuse because I don't have port eight open But if I would say port 80 which I do that I'm running a web server on my computer. I get no error So of course we can detect what's the last command successful or not So here I can say ampersand ampersand and I can say echo port is open And when I do that I get port is open But if I was go back to like any port that's not open I'll do eight again. You can see we get our error now We can always then say our or operator. So pipe pipe and I can say echo port is closed and Now we'll get our error message with port is closed So we have port is closed and if I was to scan port 80 we have port is open now Let's say we don't probably don't want this error message We just want to know that the port is closed what I could do is wrap this in parentheses And then say to greater than and pipe all the errors into dev null and now we'll get either port is open or Port is closed and of course we can do this with a for loop now to loop through everything So I'm not going to print out if a port is closed because I'm gonna be scanning a bunch of directories So what we're gonna do here is I'm just gonna say for and we're gonna create a variable called I and we're gonna loop through the number 20 in this case to 10,000 You can also give it a list of ports that you want to scan I'm just gonna scan a bunch of ports then we're gonna take that information and we're going to again echo basically nothing basically putting a new line character into dev TCP and then an IP address or domain name and then that port that we're generating over here Dump all errors and all and then we'll just if the port is open if that is successful We'll say port and then give it the port name is open. I'll run that on my local host here and you can see It's listing all my open ports And it doesn't take too long because I'm running on my local machine if you were to do a remote machine It'd be a little bit slower, but I could do something like so I could say instead of looking at my local host I'll just point it at my router and I will run this and now it's gonna start listing all the open ports on my router So that is a poor man's port scanner. So again, this is a functionality of bash and possibly other shells I know it doesn't work in Z shell, but it's it's built in bash And that's why you won't see this directory because it doesn't really exist If you just look at it in bash bash goes, okay We're looking for a server a port and again There's commands you can do to download files from a website or other network operations, but again with current modern web Sites mostly using HTTPS. That's I as far as I know has become mostly useful useless But if you are on a bash system, you don't have nmap and you need to do a quick simple scan of ports This is something you can do again There's links in the description of this video to all the notes that went over so you can look at those I hope that again, this is not something you're probably going to use regularly because nmap is just a better option But in a pinch Having this information this knowledge could be very useful. I thank you for watching Please visit my website films by Chris comm again, that's Chris the K They'll be linked in the description. I also have a patreon page I have a PayPal account and a Libre pay account if you couldn't support me financially. Oh, that would be so great I would appreciate it. If not, I do. Thank you for watching for sharing subscribing commenting giving thumbs up or likes or whatever and I just hope that you have a great day