Linux Essentials for Ethical Hackers - Full InfoSec Course — Transcript
Full transcript
- 0:00this linux course will teach you the
- 0:02basics you need to know as a penetration
- 0:04tester it was created by hackersploit
- 0:07who has one of the most popular cyber
- 0:09security channels on youtube hey guys
- 0:11hackersploit here back again with
- 0:13another video and welcome to the linux
- 0:15essentials for hackers the 20 you need
- 0:18to know and uh first of all let me
- 0:20explain to you what this series is about
- 0:22before we actually take a look at what
- 0:24we'll be covering and the various issues
- 0:27that uh you know uh
- 0:28beginners in infosec
- 0:30and ethical hacking usually face when
- 0:33dealing with the topic of linux so uh it
- 0:36comes as no surprise that linux is very
- 0:38very important uh to learn if you are
- 0:40going to get into infosec because uh you
- 0:42will be
- 0:43using various linux based uh offensive
- 0:47distributions like kali linux or parrot
- 0:49os and it's it's imperative that you
- 0:51understand how to use the system to your
- 0:53advantage how to become efficient at it
- 0:56and that's primarily what this course is
- 0:58focused on now if you are a system
- 1:00administrator then it is uh worth also
- 1:03going through this course because we'll
- 1:05be covering a various aspects that you
- 1:07might not have known about but again if
- 1:10you're a beginner this is perfect for
- 1:11you this will cover exactly what you
- 1:13need to know to be efficient and
- 1:16effective with linux uh when it comes
- 1:18down to pen testing or ethical hacking
- 1:21getting started is very simple if you
- 1:22are a pen tester or you're a beginner to
- 1:25linux uh you can install linux from
- 1:27scratch or run it in a virtual machine i
- 1:30prefer running you know installing it
- 1:32from scratch on a physical machine
- 1:34however if you are interested in you
- 1:36know delving into the various
- 1:38distributions that exist you can check
- 1:40out distrowatch.com and you can start
- 1:42playing around with them uh you know in
- 1:44a vm
- 1:45or you could opt to set up a linux
- 1:47server all right so that's pretty much
- 1:49all that i wanted to talk about in
- 1:51regards to an introduction to this
- 1:53course and without further ado let's get
- 1:55cracking
- 2:00in this video we're going to get started
- 2:02with taking a look at the various
- 2:03keyboard shortcuts that will help you
- 2:06navigate around the system much easier
- 2:08and work with the terminal at a much
- 2:10more efficient rate all right so let's
- 2:12get started now i'm currently using
- 2:14ubuntu you can be using any other linux
- 2:17distribution that you want
- 2:19and we're going to be primarily working
- 2:21with the terminal first before we
- 2:23actually delve into desktop environments
- 2:26uh and you know various other
- 2:28distributions so we're going to be using
- 2:30debian and again ubuntu is based off
- 2:32debian and for our package manager we'll
- 2:35be taking a look at the aptitude package
- 2:37manager but as i said we'll be delving
- 2:39into all of that later on all right so
- 2:41with ubuntu uh getting opening up a
- 2:44terminal with your keyboard is very
- 2:46simple you have your control alt n t key
- 2:49or you have your super and t if you're
- 2:51running debian or any other distribution
- 2:53so on ubuntu it's ctrl alt n t
- 2:56or your super nt and you can customize
- 2:58your keyboard shortcuts uh however you
- 3:01want all right so
- 3:02let me just uh let me just minimize this
- 3:04now uh the other interesting thing that
- 3:07you can do or very helpful thing that
- 3:09you can do when working with various
- 3:11windows it doesn't have to be a
- 3:13a terminal window is you can perform
- 3:16tiling and that is by using the super
- 3:17key and your arrow keys to direct the
- 3:20location of the windows and you can tile
- 3:22them appropriately right so as you can
- 3:25see i've used the super and up key and
- 3:27that maximizes it and of course i can
- 3:29take it to the left or i can take it to
- 3:31the right and i can you know leave it
- 3:33where where it was previously right so
- 3:35let me just expand it now let me talk
- 3:37about a font size right so font size is
- 3:40very easy to change and to actually
- 3:42increase and reduce so if i wanted to
- 3:44increase my font size i would use the
- 3:46control shift and the plus key on my
- 3:49keyboard and that would increase the
- 3:50font size right
- 3:52i can then minimize it by using the
- 3:54control and the minus key on my keyboard
- 3:56and that will reduce the font size so
- 3:58again increasing it is ctrl shift and
- 4:01and the plus key
- 4:03and reducing the font size is control
- 4:05and the minus key on your keyboard right
- 4:08so
- 4:09that is how to increase and reduce your
- 4:12font size now let's talk about
- 4:14actually clearing your screen which is
- 4:16very very simple so i'll just use a
- 4:18generic command here you don't have to
- 4:20worry about what that command is so if i
- 4:22wanted to clear my terminal i would
- 4:24simply say clear and that will get rid
- 4:26of all the content that was currently on
- 4:28the terminal however
- 4:30i can also use a keyboard
- 4:33keyboard shortcut so again if i just
- 4:36list the same command here i can use the
- 4:38control and l key and that will clear
- 4:40the terminal for me without me having to
- 4:42type the clear command all right so
- 4:44let's talk about some uh some other
- 4:46keyboard shortcuts that you should be
- 4:48aware of right so uh if we are working
- 4:51with a particular process so for example
- 4:54i can say
- 4:55nmap i can run a quick nmap scan here
- 4:58and i can just say sv
- 5:00192.168.1.1
- 5:02and we can hit enter i can use the
- 5:04control c key
- 5:06to actually end the currently running
- 5:09process and it will return you back to
- 5:11your uh to your shell uh in this case
- 5:14we're using the bash shell so if i want
- 5:16to end a process that's currently
- 5:18running like the one i was running which
- 5:20was nmap i use the control and c
- 5:22keyboard shortcut right now if i wanted
- 5:25to suspend or to pause this
- 5:27or to pause a particular task or a
- 5:30process i can use the control and z key
- 5:33right so if i was running nmap s v the
- 5:36same key or the same command i can type
- 5:39that out however here are other useful
- 5:41keyboard shortcuts that you can use so i
- 5:44can cycle through my previously used
- 5:46commands by using the up arrow key and
- 5:49that will again cycle through all my all
- 5:51my previously used commands so again i
- 5:53can just go to this previous command and
- 5:55hit enter and then i can use ctrl and z
- 5:58to actually uh pause and suspend that
- 6:00process uh in memory and remember it
- 6:03hasn't stopped it you have just
- 6:04suspended it all right now let's talk
- 6:06about tab uh
- 6:08let's talk about the tab key and auto
- 6:10completion right so uh we can use the
- 6:13tab key uh to auto complete file and
- 6:16directory names so let me just clear
- 6:18this out and i can use the control and l
- 6:20key so if i go to my uh well i can
- 6:22actually work from my home directory but
- 6:25let's say i wanted to cat a particular
- 6:28file so let me just list all the files
- 6:30in here so let's say i wanted to cat my
- 6:33let's see or let's say i wanted to get
- 6:35my my password file so again i can say
- 6:38cat
- 6:39etsy
- 6:40and i can say password right now
- 6:43if i wanted to auto complete this i
- 6:45could use the tab key and again it'll if
- 6:48i use it two times it will give me the
- 6:50various suggestions here so a single tab
- 6:52will auto complete it if it has an
- 6:55accurate uh id of of the particular file
- 6:58or directory you're referring to so
- 7:00again if i said uh if i give it a bit
- 7:02more information in regards to the file
- 7:04or directory i was looking for i would
- 7:07simply just hit tab and it gives me the
- 7:09file there however i can hit double tab
- 7:12and that again gives me the files that
- 7:14are related to the particular data that
- 7:17have entered here so again if i reduced
- 7:18it just to ap and i hit tab twice it
- 7:21will give us the recommendations as to
- 7:24uh in in reference to the to to the
- 7:27to the particular files that uh that
- 7:29begin with the word p and again if i can
- 7:31increase that uh probability or the
- 7:34specification of the file i'm looking
- 7:36i'm looking for by increasing the amount
- 7:38of letters so again
- 7:40again i can tap it twice and now you can
- 7:41see the results are more fine-tuned so
- 7:43again i can
- 7:45i can use tab to auto complete it to
- 7:47password and i can hit enter and that
- 7:49displays the contents of the password
- 7:50file so that is how to use uh the tab
- 7:53key and those are the various uh you
- 7:55know commands that uh or keyboard
- 7:57shortcuts that you can use while working
- 7:59in the terminal and hopefully those will
- 8:00make your life a whole lot easier so
- 8:02again control and l that clears
- 8:04everything for me
- 8:06now let's talk about how to close your
- 8:08terminal so again closing your terminal
- 8:10is very simple you can use the control
- 8:13shift and w key so again i can say
- 8:15control shift and w here
- 8:18right over here and that works pretty
- 8:20universally among all distributions so
- 8:22again control alt d that opens up your
- 8:25terminal uh increasing the font size
- 8:27control shift and the plus key and so on
- 8:30and so forth and you can tile your
- 8:32terminal or any window in your system by
- 8:34using the super key and your arrow keys
- 8:37or your directional keys here
- 8:39all right so those are all uh the basic
- 8:43keyboard shortcuts that i wanted to
- 8:44start off with i'll be referencing
- 8:46others throughout the series uh let me
- 8:48know which ones are i missed and i'll be
- 8:50seeing you in the next video in this
- 8:52series
- 8:56in this video we're going to be taking a
- 8:58look at file management and file
- 9:00manipulation uh in linux so let's get
- 9:03started so i'm just going to open up my
- 9:05terminal here and let's just expand this
- 9:08and let's increase the font size so we
- 9:10can see what's going on all right so
- 9:12let's start off with a bit of directory
- 9:15navigation and understanding uh what
- 9:18files exist within a directory right so
- 9:21the first question any beginner to linux
- 9:24has is when the in the terminal is how
- 9:26do i know where i am or how do i know
- 9:29what directory i'm in right so they want
- 9:31to know where where they actually exist
- 9:34in the linux file system so by default
- 9:37if you are logged in as a user uh you
- 9:39know that a user is not the root user uh
- 9:42so you know a normal user account for
- 9:44example i'm logged in as a lexis
- 9:47so i'm going to be in my current home
- 9:50directory now you can confirm this by
- 9:53typing in pwd all right pwd means print
- 9:57current working directory or print
- 9:59working directory and that is
- 10:01self-explanatory it prints the current
- 10:03directory that you are in and that you
- 10:06uh will be working in or any commands
- 10:08that you actually run will be executed
- 10:10within this directory right so i'm going
- 10:12to hit enter
- 10:14and as you can see it tells you i'm in
- 10:16the home alexis directory now user
- 10:18accounts are usually sorted out this way
- 10:21so the root account usually has its own
- 10:24folder in the root directory
- 10:26of the file system of the linux file
- 10:29system whereas other users like alexis
- 10:32here
- 10:33will be found within the home directory
- 10:35and then furthermore their own
- 10:36individual directories based on their
- 10:38usernames and this is where all their
- 10:40files will be stored all right which
- 10:42brings us to the next question which is
- 10:44how do i list the files within a
- 10:46particular directory and this is very
- 10:48simple we use the ls command which means
- 10:50list all right so i'm going to hit enter
- 10:53and this will list the files and the
- 10:56directories within the current directory
- 10:58right so i'm going to enter and as you
- 11:00can see it tells us within this current
- 11:02directory we we have the desktop
- 11:04directory uh the documents directory
- 11:07downloads etc etc right so
- 11:10this is the simple way of listing files
- 11:12now the ls command has the ability to be
- 11:15run with other arguments or commands or
- 11:18options that allow you to increase or to
- 11:21modify the way the output is
- 11:24or the way the files are displayed to
- 11:26you right so a quick example of this is
- 11:29by using the ls hyphen or dash l command
- 11:33all right so this will list all the
- 11:35files and directories in this directory
- 11:39uh in the format of a list or a table
- 11:42which makes it easier to read for users
- 11:45right so i'm going to hit enter and
- 11:46immediately you can see it gives you a
- 11:49vital information like the total
- 11:51right of here the permissions the owner
- 11:54the ownership of these files and
- 11:56directories
- 11:57you have the date modified and the name
- 11:59of the file uh of the files and
- 12:01directories
- 12:02all right so
- 12:04that is how to use ls in combination
- 12:06with another command now you can also
- 12:08get more output by combining the ls
- 12:11command with other options so again if
- 12:13we wanted to list all the files that are
- 12:15all the files and directories that are
- 12:17currently in this working directory i
- 12:19can use the a command which essentially
- 12:22is an abbreviation for all now when i
- 12:24say all in the context of a linux it
- 12:26means all hidden files all files within
- 12:29this directory will be displayed all
- 12:31right so if i list the files again here
- 12:33you can see that it only displays the
- 12:36the files and directories that are
- 12:38visible to users if we want to display
- 12:41all the files and directories including
- 12:43hidden files and directories we can say
- 12:44ls and we can say a
- 12:47all right and this again will give us
- 12:49all files and directories including
- 12:51hidden files and directory so you can
- 12:52see the hidden files in linux have the
- 12:55dot or the full stop
- 12:57before the file name here so again the
- 12:59bash aliases file is a file that is used
- 13:02in configuration of your bash profile so
- 13:05again it allows you to configure aliases
- 13:07when working with bash again so the
- 13:09hidden files in nx typically are used
- 13:12for configuration of various system uh
- 13:15system environment variables or various
- 13:18system tools uh you know so on and so
- 13:20forth we'll be working with this later
- 13:22on and it will all make sense shortly
- 13:25now the great thing about the list
- 13:26command is that i can use it in
- 13:28combination with the previous command so
- 13:30if i wanted to list this in a way that
- 13:32was much easier to read i can say ls a l
- 13:36and this will list all the files and
- 13:37directories including the hidden files
- 13:39and directories in the format of a list
- 13:42or a table and i hit enter and there you
- 13:44are you can see
- 13:46it displays all the files and
- 13:47directories in the form of a list here
- 13:49and again it gives you information in
- 13:51regards to the ownership and the
- 13:52permissions more of which we'll touch
- 13:54upon later on in the course all right so
- 13:57i'm just going to clear the terminal
- 13:58here and let's take a look at the ls
- 14:00command a little bit more all right so
- 14:02let's say i wanted to um to actually
- 14:05list the files um in a more
- 14:08readable format for users so again i can
- 14:11just type in ls
- 14:13l and i can use the h command all right
- 14:15so if i hit enter again this displays it
- 14:18in a much easier way for uh for users to
- 14:21understand what's going on and the
- 14:22context i'm referring to is more to do
- 14:26with the size all right so if i say ls l
- 14:28you can see that the data here or the
- 14:31size of the files is in bytes right now
- 14:34when we use the ls h or the h where the
- 14:37h stands for human readable format you
- 14:39can see it displays the actual size in
- 14:41kilobytes a much easier way for you to
- 14:44understand the sizes of files
- 14:46etc etc all right so let me just clear
- 14:49the terminal here
- 14:51and
- 14:52let's take a look at one more uh command
- 14:55that we can use with ls and that is if
- 14:58we wanted to uh show uh subdirectories
- 15:01right so remember when we show when we
- 15:03use the ls command
- 15:05it shows us the directories within this
- 15:07current working directory but let's say
- 15:09we had other directories within um let's
- 15:12see
- 15:13within pictures right so we could have
- 15:15other directories within pictures or
- 15:17documents or the downloads folder etc so
- 15:20again we can say
- 15:22uh if i wanted to list
- 15:24the the the subdirectories within the
- 15:26desktop folder i can say
- 15:29ls
- 15:30l and we'll use the capital r command
- 15:33and this again means recursively so we
- 15:36can then specify the folder we want
- 15:38which is going to be desktop or the
- 15:40directory we want again it's going to be
- 15:41desktop and we hit enter and again it
- 15:44will list for us the files that exist on
- 15:47the desktop first of all and again it
- 15:49shows us that we have
- 15:51a directory called c
- 15:53and a txt file called todo.txt
- 15:57all right within the c folder or the c
- 15:59directory we have three files we have a
- 16:02temp dot c
- 16:03we have a test binary and a test.c file
- 16:06so again it's displayed to us what is on
- 16:09the desktop and then what is uh what is
- 16:12in the directory c on the desktop so
- 16:14again it's used for recursive a listing
- 16:16of the of files and directories and sub
- 16:19directories that way all right so i hope
- 16:22that makes sense now let's talk about uh
- 16:24some directory navigation all right
- 16:27which is quite important here
- 16:29uh before we actually talk about uh file
- 16:31manipulation um and copying files etc so
- 16:36as i said we are currently in the home
- 16:38alexis directory now if i wanted to move
- 16:41a step back or to move to a parent
- 16:43directory i can say cp all right so cd
- 16:47will change directory to the actual home
- 16:49directory uh so again if i type in pwd
- 16:52you can see it will not do anything now
- 16:54if i wanted to go a step back i can type
- 16:57in cd
- 16:58and i can follow that or yes i can
- 17:01follow that up with two full stops and
- 17:03that will take me a step back and
- 17:06immediately on your bash shell you'll be
- 17:08given the current directory that you're
- 17:10in now so again it's telling us we are
- 17:12in the home directory and we can confirm
- 17:14this by typing in pwd right so if we
- 17:17list the files within the home directory
- 17:19you can see that the only directory that
- 17:21exists is the alexis folder and that's
- 17:23because that's the only use on the
- 17:25system so let's take a step back right
- 17:27so i can take a step back and i hit
- 17:30enter and now we are currently in the
- 17:32root directory the root file system
- 17:34directory for the off for linux right so
- 17:37again i can list all the files in here
- 17:39and i can hit enter and as you can see
- 17:41we are now in the root this is the
- 17:44actual root directory of the linux file
- 17:46system not the root folder or the root
- 17:48user directory just the root
- 17:51of the file system so
- 17:53you can now see all the various folders
- 17:55that the linux file system is comprised
- 17:57of all right so that is how to actually
- 18:00navigate a step back now if i wanted to
- 18:02navigate into any one of these
- 18:04directories i could say cd and then i
- 18:07specify cd is an abbreviation for change
- 18:11directory and i can specify the
- 18:12directory i want to move into so i can
- 18:15say cd home
- 18:16right and again that will take me into
- 18:18my home directory and then i can list
- 18:20the files in here and this tells me oh
- 18:22we have a directory called alexisd
- 18:24and then i can say change directory into
- 18:27the directory alexis and that will take
- 18:28me into the uh the directory alexis
- 18:32all right now i can also use um i can
- 18:36also use the forward slash to refer to a
- 18:39directory that is currently not in this
- 18:41particular directory so let's say i
- 18:44wanted to move into the um let's see
- 18:47i wanted to move into the
- 18:50um let's try the etsy folder i can say
- 18:54cd
- 18:56forward slash etsy and this refers to a
- 18:59directory that is currently not in this
- 19:01directory but at the root at the root of
- 19:04the linux file system so i hit enter and
- 19:07that takes us into the etsy folder so
- 19:09again i can confirm this by typing in
- 19:11pwd and again it tells me i'm currently
- 19:13in the etsy folder
- 19:15right now if i want to navigate back to
- 19:18my user home directory so i'm currently
- 19:21logged in as the user alexis if i want
- 19:24to go back to alexis home directory i
- 19:26can simply do this by typing
- 19:29home alexis right that's very very
- 19:31simple but if i want to even make this
- 19:33shorter i can use
- 19:35the command right over here and again i
- 19:38can hit enter
- 19:40and
- 19:41i can
- 19:42easily just navigate back to my home
- 19:43directory so if i hit enter you see and
- 19:46i type in pwd it's going to take me into
- 19:48my home directory right over here all
- 19:51right now that we have taken a look at
- 19:52you know directory navigation and moving
- 19:55around directories let's take a look at
- 19:57uh creating files copying etc all right
- 20:00so i'm currently on my in my home
- 20:02directory so let's talk about
- 20:05actually copying a file
- 20:07now before we actually do that we need
- 20:09to actually understand how to create
- 20:11files really really quickly right so
- 20:13the first thing i want to do is i'll go
- 20:16into my desktop here and i'll say cd
- 20:18desktop and i'm going to hit enter and
- 20:20i'm in my desktop now all right so if i
- 20:23wanted to create a file really easily i
- 20:26can use touch all right so touch is a
- 20:29is a tool or a utility that allows you
- 20:31to you know easily create files again
- 20:33let me show you a command that will help
- 20:35you understand what various commands and
- 20:37tools are so if i want to know uh
- 20:40i want information about a particular
- 20:42command i can use the what is
- 20:44the what is command so i can type in
- 20:46what is and then i can say what is touch
- 20:49and i can hit enter and again it tells
- 20:52me change the file timestamps all right
- 20:54or so i can also say what is
- 20:56uh let's see what is nano right nano is
- 20:59a text editor so i can hit enter and
- 21:02it's going to tell nano is another
- 21:03editor etc so it gives you information
- 21:05about a particular command or tool all
- 21:07right so i can use touch to create a
- 21:09file remember without any content right
- 21:11so i can say touch
- 21:13and i can say the file name is going to
- 21:15be test.txt
- 21:17all right i can hit enter and if i list
- 21:20all the files in the desktop you can see
- 21:22i have the test.txt file right over here
- 21:25all right so
- 21:27i can now
- 21:28direct data into this file so again i
- 21:30can use the ech command and if we want
- 21:33to learn more about the echo command i
- 21:34can type in what is and i can say echo
- 21:37and i can hit enter and it's going to
- 21:39say display a line of text right so we
- 21:41can say echo
- 21:43alexis is
- 21:46alexis is
- 21:47you can say alexis is not cool i know
- 21:51something like that
- 21:52and i can just hit enter and again it
- 21:54will display on our terminal alexis is
- 21:56not cool all right so it simply just
- 21:58displays a line of text however we can
- 22:00redirect this data into a particular
- 22:03file and in this case we want to dis we
- 22:06want to redirect this data into the
- 22:08test.txt file right so i can say echo
- 22:12we can say hello
- 22:14and we'll just use this simple string of
- 22:16text here and i can say
- 22:20redirect to this and we use the greater
- 22:22than sign to redirect data to a
- 22:25particular file or to a particular
- 22:27command so i can say test dot txt all
- 22:30right and i hit enter and now this file
- 22:34should have the words or the string
- 22:36hello now if you want to easily just
- 22:39display the context uh or the content of
- 22:41a file i can use the cat command all
- 22:43right now again we can use the what is
- 22:45command to find uh to find out more
- 22:48about what the
- 22:49cat command does so i can hit enter and
- 22:51it's going to tell us it concatenates
- 22:53files and prints on the standard output
- 22:55so again it gives us the output of all
- 22:57the content it prints out the content of
- 22:59a particular file uh so again i can say
- 23:01cat test dot txt and hit enter and again
- 23:05it prints out what we had redirected
- 23:07into it
- 23:09all right so that is how to use the cat
- 23:11command now again i can redirect a lot
- 23:13of text into this uh so let's say i
- 23:15wanted to edit this uh this file or i
- 23:18wanted to remove this file which is a
- 23:20much better way of actually taking a
- 23:21look at you know file manipulation
- 23:24technique so again i've shown you how to
- 23:25create a file a very simple file
- 23:27redirecting output
- 23:28we can also
- 23:30use cat to redirect output so for
- 23:32example if i wanted to redirect the
- 23:34contents of the password file i can say
- 23:37cat hc password and i'm using the
- 23:39relative directory you can see here so
- 23:41the the the contents of the password
- 23:44file i want to redirect into the
- 23:47test.txt file however if i wanted to
- 23:50create another file i could easily do it
- 23:52directly from here i could say password
- 23:54dot txt and i hit enter and now we can
- 23:57display the contents of the password.txt
- 24:00file and again i can use the tab
- 24:02autocompletion here and i hit enter and
- 24:04again it gives us all the content was
- 24:06redirected into this new txt file
- 24:09excellent so now let's talk about
- 24:11actually you know create removing files
- 24:14copying them etc so if i wanted to
- 24:16remove this file here the test.txt file
- 24:20i use the rm command which stands for
- 24:22remove right again you can use the what
- 24:24is command and again use it again it
- 24:26tells you this is used to remove files
- 24:28and directories so let's talk about
- 24:30removing files first
- 24:33all right so we can say remove uh test
- 24:35dot txt all right and again we use tab
- 24:39auto completion and i hit enter and this
- 24:41will have removed the file over here
- 24:44right so um
- 24:46that is essentially how to remove a file
- 24:48now
- 24:50uh if i want to remove a directory uh i
- 24:53can now i need to specify that it is a
- 24:56recursive action but before we do that
- 24:58let's talk about creating a directory
- 25:00first because that that's quite
- 25:02important as well so if i want to create
- 25:04a directory i use the make directory
- 25:06command which is abbreviated into mkdir
- 25:09so make a directory and i give it a name
- 25:12so i can say test all right so this is
- 25:13going to create a folder or id or a
- 25:16directory called test
- 25:18right once i hit enter and i list all
- 25:20the files here you can see we have the
- 25:21test directory over here uh so what i
- 25:24can do is
- 25:26i can you know i can navigate into it i
- 25:28can copy files into it so let's say i
- 25:31wanted to copy a file into this uh
- 25:33directory so again i can say
- 25:36let's say i wanted to say touch um or we
- 25:39can do the same thing so i can say cat
- 25:41etsy
- 25:43password and i want to redirect this
- 25:45into a file called
- 25:47password.txt and once that is done i
- 25:50want to copy the file so i want to say
- 25:52cp that means copy and i want to specify
- 25:54the file that i want to copy which is
- 25:56going to be password dot txt and i want
- 25:59to copy that into the test directory so
- 26:01i specify the directory i want to copy
- 26:03in i want to copy it into
- 26:05in this case the test directory is
- 26:07within the current working directory so
- 26:09i don't have to specify a relative path
- 26:11if i was specifying a relative path i
- 26:13would use the forward slash here so i
- 26:15can just say test
- 26:17and i hit enter and now if i remember if
- 26:20i wanted to list the contents of the sub
- 26:22directories recursively i could say ls
- 26:25lr and i hit enter and you can see the
- 26:27contents of the test directory uh
- 26:30password.txt
- 26:32excellent so again if i want to remove
- 26:34the the password file i can say
- 26:36removepassword.txt
- 26:38if i want to remove a directory and the
- 26:40directory what we want to remove is the
- 26:42test directory i can say remove and i
- 26:44use the capital r which means
- 26:47recursively remove and i say test and i
- 26:50use the tab autocompletion and i hit
- 26:52enter and now if we list the files in
- 26:54the on the desktop you can see we've
- 26:56gotten rid of all of these folders and
- 26:59files
- 27:00all right so
- 27:01now that we know how to actually create
- 27:04a directory we can actually um
- 27:07let me talk about removing a directory i
- 27:09actually covered it with the remove
- 27:11command however we can also use um
- 27:14another command called remove directory
- 27:16which is abbreviated into rmdir
- 27:20this will only allow you to remove a
- 27:22directory if you do not have any files
- 27:24within that directory right so let's say
- 27:26i uh
- 27:28by the way you can cycle through your
- 27:30previously used commands using your
- 27:31arrow keys in this case you can use the
- 27:34uh the up arrow key so let's say i
- 27:36wanted to catch i wanted to you know
- 27:38redirect output of the password file
- 27:40into a file called password.txt and i
- 27:42wanted to copy this file or let's
- 27:45actually talk about
- 27:46moving files so if i wanted to move a
- 27:48file i would say mv and again you can
- 27:51use the what is command so what is mv
- 27:54so i can say mv i want to move the
- 27:57password txt file into the test
- 28:00directory here i'm going to hit enter
- 28:02and now you can see that the
- 28:04the password file has been moved into
- 28:06the test directory so again i can
- 28:09i can list all the files within the test
- 28:11directory here and that again it tells
- 28:13me that we only have the password.txt
- 28:15file in here so if i use the rm dir
- 28:19command which means remove directory and
- 28:21i say test remove directory test you can
- 28:24see it's going to tell me that this
- 28:26directory is not empty so as a result we
- 28:28need to specify remove
- 28:30recursively
- 28:32test and we're going to hit enter and
- 28:33now it gets rid of the test directory
- 28:36for us all right so those are uh very
- 28:39very simple ways of
- 28:41you know creating copying and of of
- 28:43course deleting commands now uh
- 28:45before we actually end this video which
- 28:47i know has been going on for quite a
- 28:49while i'm going to be covering file
- 28:50directory permissions later but i want
- 28:53to talk
- 28:53i want to talk about file manipulation a
- 28:56little bit more uh so we've talked about
- 28:58uh you know using the cat command
- 29:00redirecting output uh using touch as
- 29:02well moving files let's talk about you
- 29:05know renaming files
- 29:07uh and also taking a look at the content
- 29:09of particular files here so what i want
- 29:12to do now is
- 29:13let's actually take a look at um
- 29:16at actually renaming files all right so
- 29:18i'm going to again use the similar
- 29:20command that we had used i'm just going
- 29:21to you know
- 29:23i'm going to redirect the output of the
- 29:25password file into a file called
- 29:26password.txt
- 29:28and now if i wanted to rename the
- 29:30filepassword.txt
- 29:32into something else i would use the mv
- 29:34command right so there isn't a command
- 29:36to rename files in linux you use the mv
- 29:40command which means move
- 29:42in this case it's very simple the syntax
- 29:44is uh you specify the file that you want
- 29:47to change the name of which is going to
- 29:48be password.txt and i changed the file
- 29:51name to let's say
- 29:53test
- 29:54dot txt
- 29:56and hit enter and now if we list all the
- 29:58files in the directory you can see that
- 29:59it changes it to test.txt and indeed if
- 30:03we actually uh if we actually
- 30:06display the contents of the file you can
- 30:08see that the the content is preserved
- 30:10while we've changed the name and we can
- 30:12also change the extension of the file so
- 30:15i could say move
- 30:16test.txt into test
- 30:19let's say test.c we can we can change
- 30:22the contents into a c file right and now
- 30:24if i say uh cat test dot c
- 30:27i can hit enter and there you are now
- 30:29let's talk about uh editors and then
- 30:31i'll talk about the content of the files
- 30:33uh before we actually end this video so
- 30:37um
- 30:38there are two uh standard editors that
- 30:40are pretty much the standard when it
- 30:42comes to linux and working within the
- 30:44terminal i'm not talking about graphical
- 30:46uh gui based editors like uh g edit and
- 30:50stuff so if i wanted to edit this file
- 30:52within the terminal i have two options i
- 30:54have nano so again i can use the what is
- 30:57command and say what is nano and again
- 30:59that's an editor and i have we have vim
- 31:02which is pretty much the most popular
- 31:04option and i'll be making independent
- 31:06videos on this editors and how to
- 31:07configure them so again if i want to
- 31:10edit the test.txt file i can say nano
- 31:13test.tx
- 31:15test.c
- 31:16let's actually rename it back to
- 31:18test.txt
- 31:20dot txt and we say nano test
- 31:23dot txt and we're hit enter and that
- 31:26takes us into nano now exiting nano is
- 31:28very simple again you can navigate
- 31:30around make changes uh exiting it we use
- 31:32control and x and that's it now with v
- 31:35vim or vi we simply type in vi or vim
- 31:38and we say test.txt hit enter and again
- 31:42with them the syntax is very different
- 31:43if i want to make changes or i want to
- 31:45add content i type in i to insert text
- 31:48and again i can play around with it and
- 31:50once i'm done i hit escape and then i
- 31:52can write changes to this file or i can
- 31:54quit and discard any changes by typing
- 31:56in q
- 31:57and the exclamation mark and hit enter
- 32:00and that's how to use the various
- 32:01editors i'm not covering them uh you
- 32:03know to their full to their fullest
- 32:05extent and that's because we have
- 32:06various videos that will be actually
- 32:09focused on editors themselves so um
- 32:12that's pretty much all that i wanted to
- 32:13cover in this video there's quite a bit
- 32:15hopefully you guys can actually learn a
- 32:17lot from this video
- 32:22in this video we're going to be talking
- 32:23about file and directory permissions and
- 32:26ownership all right so again there's
- 32:28quite a bit to cover and hopefully i'll
- 32:30explain the various ways of doing it and
- 32:32i hopefully i can explain it as best as
- 32:34i can all right so let me just open up a
- 32:37terminal here and we can get started
- 32:38immediately right so
- 32:40let's just expand this and there we are
- 32:42all right so the first thing i'm going
- 32:44to do is i'm just going to go on to my
- 32:45desktop or change my directory onto my
- 32:48desktop and i'm just going to clear this
- 32:50now one thing i want to talk about
- 32:51before i actually get started if i list
- 32:53all the files in here you can see that
- 32:55directories will typically be
- 32:57highlighted in blue and to keep this on
- 33:00a standardized basis you want the color
- 33:02scheme for your terminal to be the linux
- 33:05console or you can use xterm if you want
- 33:07and again that will just keep it really
- 33:09standardized but for the purpose of this
- 33:11video i'm just going to stick to the
- 33:13linux console again just so directories
- 33:16and
- 33:17your directories are highlighted blue
- 33:19and again executable files are
- 33:21highlighted green all right so that'll
- 33:23keep things uh more simple and very easy
- 33:25to understand all right so let's get
- 33:27started so again if i list all the files
- 33:30in this directory uh you can see that um
- 33:34typically when i list it in the form of
- 33:36a list or a table we have various bits
- 33:38of information right so again i can also
- 33:41you know
- 33:42type this in and print it out print it
- 33:44out in human readable format but again
- 33:47that doesn't explain
- 33:49a lot of the information that already is
- 33:51here all right so we have the first
- 33:53column which is your file permissions
- 33:55file and directory permissions um you
- 33:58then have the user and the group all
- 34:01right so this is to do with ownership
- 34:03these two are to do with ownership you
- 34:05then have the file size uh and the date
- 34:07modified and of course you have the the
- 34:10file or the directory name
- 34:12as is
- 34:13as as is and as was created all right so
- 34:17what i'm going to do is the first thing
- 34:18i want to do is i'm just going to create
- 34:20a simple file i'm just going to call it
- 34:21test
- 34:23test dot sh because i know many of you
- 34:25don't like me sticking with one type of
- 34:27file
- 34:28and what i'm going to do is i'm just
- 34:29going to cut the contents of the
- 34:31password file
- 34:32into the test dot sh file right
- 34:36and i can just hit enter and we can
- 34:37clear this out and let me also create a
- 34:39directory here and we'll just call it
- 34:41test and let's clear this out all right
- 34:43so now if i list all the files here
- 34:45you can see that
- 34:47we have the new files that we just
- 34:49created test.sh and the test directory
- 34:52so
- 34:53if we take a look at the permissions for
- 34:55the sh file which is a shell file and is
- 34:58potentially executable however in this
- 35:00current state it isn't and you might be
- 35:02asking well why isn't it executable and
- 35:05that's where file and directory
- 35:07permissions come into play now
- 35:10permissions in linux are very very
- 35:11simple to understand now many people
- 35:14usually you know complicate it quite a
- 35:16bit and there isn't a need for this uh
- 35:19again there are two ways of handling it
- 35:21which is where most of the confusion
- 35:23starts that is the symbolic mode format
- 35:26and the uh the octal mode or the binary
- 35:29mode as it's so referred to as all right
- 35:32and these basically deal with various
- 35:34techniques as to which you can ascertain
- 35:36or set
- 35:37uh you know their various permissions
- 35:40for files and directories but the first
- 35:41thing you need to understand first of
- 35:43all if you're a beginner is there three
- 35:45types of permissions that you can apply
- 35:47to a file or directory in linux those
- 35:50are read which is represented by r as
- 35:53you can see right over here uh the the
- 35:55second one is the w or the right
- 35:58permissions and the last one is the x
- 36:01permission which stands for executable
- 36:03so these basically mean read this allows
- 36:06this means that you're allowed to read
- 36:08the file uh the right permission means
- 36:11you're allowed to write changes to the
- 36:13file and the x permission means you're
- 36:15allowed to execute the file now you
- 36:17might be saying well we have various uh
- 36:20various
- 36:21sequences of these permissions appearing
- 36:24here how is it sorted out and that's a
- 36:26very good question so let's take a
- 36:28simple example of the test.sh file right
- 36:31over here all right so first of all uh
- 36:34as you'll see right over here each of
- 36:36these is sorted into
- 36:38six uh into six columns however they're
- 36:41really not separated but that's how you
- 36:43have to understand them so you have your
- 36:44first one here you have your second one
- 36:47here and you have your third one here
- 36:49now this initial prefix here is
- 36:52is there to tell you the type of file
- 36:55you're dealing with in this case we're
- 36:56dealing with a file so it leaves that
- 36:58blank in the case of if of a directory
- 37:01it will be annotated by a d and that
- 37:04tells you that you're dealing with a
- 37:06directory all right so let's let's talk
- 37:08about the other columns here so the
- 37:10first uh the first one here is for the
- 37:13owner of the file alright so these are
- 37:16the owner permissions now when we're
- 37:18talking about ownership for this
- 37:19particular file we can see that the
- 37:21owner of the file and the group that it
- 37:23belongs to
- 37:25is alexis all right now if it belonged
- 37:27to another user that means that these
- 37:29permissions were specific to that
- 37:31particular user or the owner of the file
- 37:34the second column here is in uh these
- 37:37are the permissions for the group all
- 37:39right so again these are group
- 37:40permissions and the last one are for all
- 37:43other users on the system so let's say i
- 37:46created a file and i'm currently in the
- 37:48alexis uh the home alexis desktop
- 37:51directory here
- 37:52uh let's say i was logged in as another
- 37:55user and i navigated into this directory
- 37:59and i tried to execute this file over
- 38:01here well given that i would be i was
- 38:04using another user
- 38:06the permissions for this file
- 38:08explicitly state that i can read the
- 38:11file however i cannot execute it or i
- 38:14cannot write any particular changes to
- 38:16it so hopefully that makes sense now
- 38:19let's talk about changing these
- 38:20permissions or setting these permissions
- 38:22for these files now this is where the
- 38:24chmod command comes into place all right
- 38:28so the chmod commands allows you to
- 38:30change the mode for files and
- 38:32directories and allows you to change
- 38:34permissions for the file and directories
- 38:36so again i can say i can use the what is
- 38:38command with chmod and you can see it
- 38:41allows you to change the file mode bits
- 38:43and change the permissions of a file or
- 38:45directory right quite simple
- 38:48now let's talk about this for a second
- 38:49it's very easy to use we say chmod
- 38:52and then we specify the options that we
- 38:55want and finally after the options we
- 38:57specify the file to which we want to
- 39:00apply these permissions to all right so
- 39:02very very simple syntax however as i
- 39:04mentioned there are two ways of doing
- 39:05this many people are comfortable with
- 39:07their own way and i recommend that you
- 39:09find your own way of going about this
- 39:11but i will make a recommendation to make
- 39:14things a whole lot easier and maybe uh
- 39:16one way that you can understand it you
- 39:18know a whole lot better all right so
- 39:20that the the first way is by using the
- 39:23symbolic mode format all right and the
- 39:25second way is by using the octal
- 39:28or the binary mode all right so let's
- 39:31start off with the symbolic mode format
- 39:34all right so let's say i wanted to
- 39:36change the permissions
- 39:38for the file
- 39:39the file test dot sh right over here all
- 39:42right so you can see that we we
- 39:45currently cannot execute it so uh what
- 39:47i'm going to do is let me just remove or
- 39:50i can just
- 39:51what i can do is just
- 39:53get etsy or we can just say dev null and
- 39:56don't worry what i'm doing here i just
- 39:58want to
- 40:01dot sh and we can actually just say echo
- 40:05um we can say
- 40:07echo hello world and we can just use
- 40:10this and we can pipe that into the file
- 40:13test.sh and now if we try and execute
- 40:16this file
- 40:17you can see that we hit enter we can see
- 40:20that we do not have the particular or
- 40:22the necessary permissions to execute
- 40:24this so that will be our goal here our
- 40:26goal is to set uh or to provide uh the
- 40:29user lexis with executable permissions
- 40:32all right so let me just list this one
- 40:34more time and we can take a look at the
- 40:35permission so for the owner alexis he
- 40:38can only read and write changes to the
- 40:41file which we we pretty much did already
- 40:43uh for the group they can only read the
- 40:45file uh and for all other users they can
- 40:49only read it all right so let's talk
- 40:50about the symbolic mode format
- 40:52so the symbolic mode format is very
- 40:55simple to understand of course i've
- 40:56mentioned it has to do with the various
- 40:58permissions so read write and execute
- 41:01and it is done in conjunction with the
- 41:03chmod command all right so now with the
- 41:06chmod command i can now specify
- 41:10the specification in regards to the
- 41:12uh to the user the group uh
- 41:16the uh the other or for all users all
- 41:18right so what this means is
- 41:20if i wanted to specify permissions or
- 41:23set permissions for uh for the current
- 41:25user i would do that by typing in chmod
- 41:28u
- 41:29and then i can add permissions i can say
- 41:32you um i can say i can add permissions
- 41:36by using the plus sign or i can say u is
- 41:39equal to and then i would set the
- 41:41permission so i can say user
- 41:44the current user is going to be
- 41:46read write and execute
- 41:48we're going to provide this user with
- 41:50the read write and execute permissions
- 41:52and then we specify the file that we
- 41:54want to apply these permissions to so i
- 41:56can say test dot sh all right and i can
- 41:59hit enter now if i list all the files
- 42:01here again you can now see that the the
- 42:04user alexis or the owner alexis has read
- 42:08write an executable permissions which
- 42:09means we can now execute this file and
- 42:12we just entered a simple piece of uh
- 42:14code here so again we can say test.sh
- 42:17and again we we cannot we can actually
- 42:19just modify this sorry uh we can say
- 42:21just going to test.sh and we can just
- 42:23say
- 42:24echo
- 42:25so that whenever we print it out we can
- 42:27actually get those
- 42:29this little string of text here again so
- 42:31let me just write and exit there and you
- 42:34can see that that was successful so
- 42:36again if we execute the file here you
- 42:38can see it prints out the string hello
- 42:40world excellent so now we have set the
- 42:42permissions for the user using the
- 42:44symbolic mode format all right so we can
- 42:47also remove permissions
- 42:49uh and again i've shown you how to
- 42:51explicitly set the permission so again
- 42:53let's go over that one more second one
- 42:55more time so chmod and now let's say we
- 42:58wanted to apply uh these same
- 43:00permissions for all the users on the
- 43:03system all right and for for for for the
- 43:06group all right so to do this we use the
- 43:09group
- 43:10uh and the o sign uh or we can also use
- 43:13the a sign all right
- 43:15and that will mean a group and all other
- 43:18users on the system so group and all of
- 43:20these users on the system so again the
- 43:23standard definition is
- 43:25for use the current user or the owner of
- 43:27the file g is for the group uh and again
- 43:30o is for other and a is for all all
- 43:33right so that will set for all so we can
- 43:35say group and we can then say group and
- 43:37other
- 43:38uh is will have read write and
- 43:41executable permissions and then we
- 43:43specify the file here and we hit enter
- 43:46and then that will set the permissions
- 43:47explicitly so again if we list all the
- 43:49files now you can see that the the the
- 43:52current user uh the group and all other
- 43:55users have read write and executable
- 43:57permissions which means i can now
- 43:59execute this file if i was logged in as
- 44:01another user that belongs to any other
- 44:04group on the system which is not
- 44:06recommended so let's talk about how to
- 44:08remove these permissions all right so i
- 44:10can say chmod
- 44:13and let's say i wanted to remove the uh
- 44:16the right and executable permissions for
- 44:19for the groups and other users on the
- 44:21system so again we say go and now we say
- 44:25minus
- 44:26wx so the right and executable
- 44:29permissions and we say test dot sh and
- 44:31we hit enter and now if we list all the
- 44:34files here you can see that now we have
- 44:36removed all these permissions so the
- 44:39only the current user is only allowed to
- 44:41read write and execute the file however
- 44:43the group and the other users on the
- 44:45system are only able to read it so that
- 44:48is essentially how to use the symbolic
- 44:50mode format so you can see it's a very
- 44:52simple system to use let me just go over
- 44:54it one more time we use the chmod
- 44:57command we then specify the user uh the
- 44:59group
- 45:00uh other
- 45:02uh other or all all right so again ugo a
- 45:05that is the standard uh
- 45:08the standard definition there and then
- 45:10of course we use the plus or the equal
- 45:12signs to add permissions or to
- 45:14explicitly set them so for example if i
- 45:18wanted to give the group execute
- 45:20executable permissions i would say chmod
- 45:24group plus x all right so we're setting
- 45:27it for the group and we're giving it
- 45:29executable permissions we then specify
- 45:31the file
- 45:32and we hit enter and now if we list all
- 45:34the files here you can see that it gives
- 45:36the group executable permissions so it
- 45:39can read the file and execute it however
- 45:41it cannot it cannot write changes to the
- 45:43file so i can i can also get rid of it
- 45:46so again chmod minus we can say group
- 45:49minus x
- 45:50uh so remove the executable permissions
- 45:52and then we specify the file we hit
- 45:55enter and again if we list the files
- 45:57here you can see we're back to the old
- 45:59uh permission so again a very simple way
- 46:02of setting permissions
- 46:04all right now let's talk about uh the
- 46:06binary or the octal mode of setting
- 46:09permissions
- 46:10all right so now let's talk about the
- 46:12octal or the binary mode of setting
- 46:15permissions right which is again very
- 46:17simple and is my preferred way of
- 46:19actually going about doing it now again
- 46:21as i said it's entirely up to you all
- 46:23right so again we are still using the
- 46:25chmod operator here and again this is
- 46:29the standard so again we can say chmod
- 46:31and then now when dealing with the
- 46:34binary or the octal mode of setting
- 46:36permissions
- 46:37the read write and executable
- 46:40permissions are now denoted in a binary
- 46:43format and you might be saying well if
- 46:45that's the case doesn't that make it a
- 46:47little bit complex well i'll explain why
- 46:50it it will not make it complex all right
- 46:52so let me explain something so typically
- 46:55as i said the read uh right and
- 46:57executable permissions are now
- 46:58represented by a binary value all right
- 47:02so the read value is
- 47:04the the read permission is represented
- 47:06by a value of four all right the right
- 47:09permission
- 47:11is execute is uh is denoted or
- 47:13represented by a value of two sorry and
- 47:17the executable permission is represented
- 47:20by a value of one all right and again
- 47:23we're still following the previous uh
- 47:26the previous format of going of actually
- 47:28uh understanding permissions here so
- 47:31again we have the uh the owner now the
- 47:33owner of the file or the directory uh
- 47:36you then have the group and others uh
- 47:39other users on the system
- 47:41all right so let's work with the test.sh
- 47:44file and i'll talk about setting
- 47:45directory permissions which is again
- 47:47very very simple as well
- 47:49all right so
- 47:51let's say we wanted to get rid of the
- 47:55the write and execute permissions for
- 47:57the owner of the file which is right
- 48:00over here you can see it has read write
- 48:02and execute permissions so to do this
- 48:04with the the binary mode or the octal
- 48:08mode
- 48:09again we need to specify chmod and now
- 48:12the permissions if you already know
- 48:14about this are now represented by the by
- 48:17binary values all right so as i said for
- 48:21the owner
- 48:22we want to actually specify the
- 48:25following so again we can say
- 48:28chmod
- 48:29and for the owner we need to specify the
- 48:33we want to get rid of the right and
- 48:35executable permissions so we only have
- 48:38the
- 48:38the write permission which again as we
- 48:41said is going to have a value
- 48:43of four all right so we start off with
- 48:46the value of four so we're going to say
- 48:47chmod four
- 48:49and then for the other files uh uh also
- 48:51for the other for the group and for the
- 48:54other uh users on the system we want to
- 48:56use the same permission we so we're
- 48:59gonna say chmod four 444
- 49:02and then we specify the file name
- 49:05test.sh and we hit enter and now if we
- 49:08list the files in here you can see that
- 49:10now the file
- 49:11only has read permissions
- 49:14for the owner the group and other users
- 49:16on the system all right so that's how to
- 49:18set it now if i wanted to give the um
- 49:21the owner of the file read write and
- 49:23execute permissions we would need to add
- 49:26these binary values together all right
- 49:28so read is going to be equal to four all
- 49:31right right is going to be equal to two
- 49:34and um
- 49:35and execute is going to be equal to one
- 49:38all right so two plus four
- 49:40is going to be six six plus one is going
- 49:42to be 7. so we say chmod 7 that is for
- 49:46the user permissions or the owner
- 49:48permission so read write and execute
- 49:50let's say for the group and the other
- 49:54users on the system we want to give them
- 49:56only read permissions which again is
- 49:58denoted by four so that's four uh read
- 50:02permissions for the group
- 50:03and for other users on the system the
- 50:05same thing and then we type in the name
- 50:08of the file all right and i'm gonna hit
- 50:10enter
- 50:11and we can now display this and
- 50:13immediately you can see we now have read
- 50:15write and executable permissions for the
- 50:17owner for for the group we only have
- 50:19read permissions and for other users on
- 50:22the system we only have read permissions
- 50:24all right so that's very easy to
- 50:25understand now if it is complex i will
- 50:28leave a uh a resource in the description
- 50:30section that has a table of all of these
- 50:33permissions but the math is very simple
- 50:35right so again we're simply adding 4
- 50:37plus
- 50:38plus 2 plus 1 and that is for all
- 50:41permissions so this is
- 50:43right
- 50:44so again this is
- 50:46sorry this is read write
- 50:48and this is execute so 4 plus 2 plus 1
- 50:50is going to be 7. if i only want read
- 50:53permissions it's going to be four if i
- 50:55only want
- 50:57read and write permissions it's going to
- 50:58be six again that would be uh seven six
- 51:02six or if i only wanted um
- 51:06read
- 51:06uh and execute permissions that would be
- 51:09uh so for example if we wanted for the
- 51:11user or the owner read write and execute
- 51:14permissions that would be seven and then
- 51:16for the group and for all of the users
- 51:18we only wanted read and execute
- 51:20permissions that would be seven five
- 51:21five all right so it's very easy to set
- 51:24permissions this way and again you're
- 51:26always setting explicitly for the user
- 51:29uh for for the owner the the the user
- 51:32the group and then all the other users
- 51:34on the system so that's something you
- 51:36need to take
- 51:37into consideration all right so now
- 51:39let's move on to actually uh changing
- 51:42you know directory permissions all right
- 51:44so if i list all the files here again
- 51:46you can use the symbolic mode or the uh
- 51:48the octal mode whatever is comfortable
- 51:50with you we have the test directory that
- 51:52we created so again if we wanted to
- 51:54provide it with all permissions you can
- 51:56see that it has read write permissions
- 51:59for the current user and for the group
- 52:02and the other users it only has read
- 52:03permission so again we can say chmod
- 52:06uh user we if we use the symbolic mode
- 52:09we can say user
- 52:11uh user group and other that's going to
- 52:13be equal to read write and execute and
- 52:16then we say test the name of the
- 52:18directory and we hit enter and now if we
- 52:20list all the files in here you can see
- 52:22that the permissions have been set
- 52:24uh and then again if we wanted to go
- 52:26back i can say chmod
- 52:29and let's say we only wanted the file to
- 52:32be re we only wanted the user to be able
- 52:35to read and
- 52:37write to this particular directory then
- 52:39we would say this is going to be equal
- 52:41to 4 plus 2 is going to be 6
- 52:444 4 and then we say test and we hit
- 52:46enter we again we can just confirm the
- 52:49permissions have been changed and there
- 52:50you are so that's how to set uh
- 52:52permissions on a directory however if
- 52:55there are other directories and files
- 52:57within this directory then we need to
- 53:00set these permissions we can set them
- 53:02recursively and to do this we can then
- 53:05type in chmod
- 53:07and if we use the r command the capital
- 53:09r command that means recursive
- 53:11permissions so again we can then say uh
- 53:14before we do that let's actually move
- 53:16this file the test file the test.sh file
- 53:20into the test directory
- 53:22and you can see it it tells us that we
- 53:25do not have adequate permissions and
- 53:27that's because again if we list all the
- 53:30if we list all the permissions here for
- 53:32the the directory
- 53:35uh if we say for example uh for this
- 53:37particular file
- 53:39let's say we want to say chmod 755 test
- 53:43dot sh and now we say move uh test dot
- 53:46sh into the test directory and we hit
- 53:49enter that is telling us that we cannot
- 53:51move it nuts primarily because of the
- 53:54the the permissions for the directory so
- 53:56we can say chmod 755 a test and we hit
- 53:59enter and then we can say move
- 54:02we can then say test.sh into the test
- 54:05folder here and we hit enter and now we
- 54:07can move it all right so that proves
- 54:09again that the importance of permissions
- 54:12and understanding them so now if we
- 54:14check the directory test uh the the
- 54:17files within the directory test we have
- 54:19the test.sh file so now if we wanted to
- 54:22to actually provide this directory and
- 54:25all the files within it files and
- 54:27directories within it recursively with
- 54:29all permissions i could say chmod
- 54:33777 and that gives it read write and
- 54:35executable permissions for the the owner
- 54:38uh the group and all other users on the
- 54:40system so again i would say chmod
- 54:43recursively 777 and i'm using the octal
- 54:46mode as you would have guessed and then
- 54:48we specify the directory and hit enter
- 54:50and now if we list all uh the directory
- 54:52itself you can see it has all
- 54:54permissions if we list uh all the files
- 54:57uh within the the test directory if we
- 55:00list the permissions here you can see
- 55:02that the test.sh file now has all has
- 55:04also uh those permissions and they have
- 55:07been applied recursively so if i had any
- 55:10other files or directories within this
- 55:11directory uh they would have been
- 55:13applied as well all right so now that we
- 55:15have actually uh taken a look at file
- 55:17ownership uh sorry file permissions
- 55:20let's take a look at file ownership
- 55:25in this video we're going to be talking
- 55:27about file ownership which is a fairly
- 55:29simple topic to understand and again in
- 55:32the previous video we used the chmod
- 55:35operator
- 55:36or the chmod tool and in this video
- 55:38we're going to be using the ch own tool
- 55:41again which is quite self-explanatory it
- 55:44allows us to change the ownership of
- 55:46files and directories which is quite
- 55:48important all right so as we did in the
- 55:50previous video
- 55:52you can see that we were able to
- 55:54change the permissions for this for the
- 55:57test directory and the test files within
- 56:00it and i've just changed them back to
- 56:02some pretty standard uh uh to some
- 56:04pretty standard permissions here and
- 56:06again uh we also had the
- 56:10we also had the uh the test.sh file
- 56:13within the test directory so
- 56:15let's talk about ownership so as i
- 56:17mentioned the current owner of this file
- 56:20right over here is alexis and this is
- 56:22the this is denoted uh right over here
- 56:24so the ownership information and the
- 56:26group ownership information if there is
- 56:29any
- 56:30now as i said uh we we haven't talked
- 56:32about adding users and groups which is
- 56:34fairly simple we haven't talked about
- 56:36you know setting particular permissions
- 56:37for users uh you know uh within the uh
- 56:40the sudo as file but that's something
- 56:42we'll get to later
- 56:43so if we wanted to change the ownership
- 56:45of this file
- 56:47to
- 56:48uh
- 56:49to to let's say the root user i can do
- 56:51that very very easily so again i can say
- 56:54let me just go into the the root user
- 56:56here and now i'm currently logged in as
- 56:59the root user so if i wanted to change
- 57:00the ownership and i'll go into the test
- 57:03directory if i wanted to change the
- 57:05ownership of the test.sh file
- 57:08what i can do now is i can say ch own
- 57:11and again you can use the what is tool
- 57:13or the what is utility to actually give
- 57:15you some more information about the the
- 57:18ch own tool so again it tells you this
- 57:20allows you to change your file owner and
- 57:23group and of course change the ownership
- 57:25of a file
- 57:26all right so now if i wanted to change
- 57:28the ownership of the test.sh file
- 57:31from alexis to to the root user i can do
- 57:34this very very easily so i can say
- 57:37i can say ch own
- 57:38and then i specify the the the user i
- 57:41want to uh to actually change the
- 57:44ownership to in this case to the root
- 57:46user and then i'll specify the file name
- 57:48which is going to be test.sh and i hit
- 57:50enter and now if i list all the files
- 57:53here you can see that the owner of the
- 57:55file has been changed to root however
- 57:57the group of this file is still alexis
- 58:00all right so that's something that we
- 58:01also have to change to change the group
- 58:04or to change the group order here
- 58:06it's very simple we use the change group
- 58:08command which again is denoted by
- 58:11uh it is denoted by change grp so chgrp
- 58:15and again we can use the what is tool
- 58:16change drp hit enter and this allows you
- 58:19to change group ownership so let's say
- 58:21we want to change the group ownership to
- 58:23root as well or to the root group
- 58:26if we type in groups and we say root
- 58:29again that tells us what
- 58:31what group the root user belongs to and
- 58:34as you can see it belongs to the root uh
- 58:36due to the root group uh and again we
- 58:39can say groups alexis and uh you can see
- 58:42these are the groups that the user lexis
- 58:43belongs to it belongs to the to the
- 58:46group alexis adm cd rom sudo etc etc
- 58:50all right so let's say i wanted to
- 58:52change the group of this file so change
- 58:54group
- 58:55um
- 58:56and then i say change it to the group
- 58:59root
- 59:00and i want you to change the file
- 59:01test.sh and now if we list the
- 59:03permissions here or the ownership sorry
- 59:05um
- 59:07we can see now that the owner of the
- 59:09file is the root user
- 59:11and the the group ownership of this file
- 59:13belongs to the to to to the group uh two
- 59:16to the root group right over here all
- 59:19right so that is how to use the ch own
- 59:22and the ch
- 59:23group or the change group command to
- 59:25change the ownership of a file now again
- 59:27we haven't experimented with users yet
- 59:29and that's something we'll be touching
- 59:30upon quite soon so we'll be explaining
- 59:34this as we move along
- 59:39in this video we're going to be talking
- 59:40about how to use the grep tool in
- 59:42regards to looking for data or
- 59:44information in files all right so this
- 59:46is one of the most important linux
- 59:48utilities or tools that uh you can you
- 59:51can learn how to use and it will really
- 59:52improve your efficiency when dealing
- 59:54with data and working in the terminal
- 59:57okay so let's actually get started with
- 59:59understanding what it is and what it
- 1:00:01does all right so the first thing we can
- 1:00:02do is we can just use the waters command
- 1:00:04to give us a bit of a context or
- 1:00:06information in in regards to what this
- 1:00:07tool is and what it does so again it
- 1:00:09tells you
- 1:00:10this prints lines matching a particular
- 1:00:12pattern and again if you're interested
- 1:00:14in learning more about the tool you can
- 1:00:15always use the manual pages or go
- 1:00:17through the manual pages for the
- 1:00:19particular tool so there you are it
- 1:00:20gives you information or in regards to
- 1:00:22how to use it the purpose of this video
- 1:00:24is to show you how to use it in the most
- 1:00:26efficient way or in a way to therefore
- 1:00:28in increase your understanding on on how
- 1:00:31to use the tool
- 1:00:32and how to make you efficient with using
- 1:00:34it
- 1:00:34all right so uh before we we actually
- 1:00:37take a look at a concrete example of how
- 1:00:39to use grep
- 1:00:40we must understand two things all right
- 1:00:42the first thing you need to understand
- 1:00:44is there are two ways of using grip the
- 1:00:45first way is by using grip on its own
- 1:00:47all right so again we can just type in
- 1:00:50grep here
- 1:00:51uh and the other way of using grip is by
- 1:00:53actually piping the output of another
- 1:00:55command into grep and then finding what
- 1:00:57you're looking for all right so you
- 1:00:59might be a little bit confused but let
- 1:01:00me explain what it does in a very simple
- 1:01:02way so grep is a tool that allows you to
- 1:01:04find strings or patterns in files
- 1:01:06alright so that means you can search or
- 1:01:08specify for the data or the strings
- 1:01:10you're looking for in a particular file
- 1:01:12all right so let's take a look at a com
- 1:01:14at a concrete example uh we're going to
- 1:01:16be looking for a word within a the
- 1:01:19proxychains.configuration file now if
- 1:01:21you're not familiar with what
- 1:01:22proxychains is uh you can check out my
- 1:01:24proxy change video where i show how to
- 1:01:26set it up uh and install it but again
- 1:01:28it's it really doesn't matter because
- 1:01:30you can follow up with any other files
- 1:01:32you're working with all right so let's
- 1:01:34say i
- 1:01:35i wanted to find the word dynamic within
- 1:01:37the file the cro the proxy chains
- 1:01:39configuration file
- 1:01:41let's let's take a look at how to use it
- 1:01:43using the first method which is using
- 1:01:44grep on its own without piping the
- 1:01:46output of another command so we can say
- 1:01:48grep and then the command we want to
- 1:01:50specify after or the parameter
- 1:01:52or the variable rather is the the data
- 1:01:54we're looking for so again you want to
- 1:01:56encapsulate this within double quotation
- 1:01:58marks so again if it's a word we can
- 1:01:59type in dynamic now the thing you you
- 1:02:02must ensure is that this this search
- 1:02:04will be case sensitive and i'll show you
- 1:02:06how to omit at the case sensitive
- 1:02:07searches so let's say we're looking for
- 1:02:09the uh the the word dynamic and then we
- 1:02:12specify the location of the file we want
- 1:02:14to search
- 1:02:15for this particular word in so again
- 1:02:17proxychains.conf
- 1:02:19and again we can use the double tab here
- 1:02:21like so and we hit enter and again that
- 1:02:23displays the word dynamic chain to us
- 1:02:26again that's the the word that it was
- 1:02:28able to find within the entire file
- 1:02:31however as i said this say
- 1:02:34this particular search is going to be
- 1:02:35case sensitive now if we want to omit
- 1:02:38the case sensitive search we can use the
- 1:02:40i parameter or the i argument here
- 1:02:43so once we hit i that means that it will
- 1:02:46search for all files
- 1:02:48or for all words within this particular
- 1:02:50file uh
- 1:02:52called a dynamic all right so once we
- 1:02:54hit enter you can see now it gives us
- 1:02:56two lines in the files uh they are both
- 1:02:58different in the fact that the first one
- 1:03:00is in case and the second one starts
- 1:03:02with an uppercase d all right so again
- 1:03:05it's a very simple tool to to use and
- 1:03:07again you can now see how efficient and
- 1:03:09how great it is at finding bits of
- 1:03:11information within files so again we can
- 1:03:14say let's say we want to look for
- 1:03:16particular users within the password
- 1:03:18file so i can say grep
- 1:03:20and i can say let's say we're looking
- 1:03:22for the user alexis in the password file
- 1:03:24and then i say etsy
- 1:03:26password and we hit enter and then it
- 1:03:28displays the user account information
- 1:03:30for the user lexis all right so that's
- 1:03:32very simply how to use it now let's take
- 1:03:34a look at the second method or way of
- 1:03:37using grep and that's by piping the
- 1:03:39output of one command
- 1:03:41into crep and then of course finding the
- 1:03:43data you're looking for that way and the
- 1:03:45way to do this is by using the pipe the
- 1:03:48pipe symbol or the pipe key on your
- 1:03:50keyboard now you can find this key on
- 1:03:52the extreme right of your keyboard just
- 1:03:54before your numpad if you do have one
- 1:03:57all right so the way we use it is let's
- 1:03:59say we wanted to cut the contents of the
- 1:04:01password file so let's say we wanted to
- 1:04:03say cat etsy
- 1:04:06password and we say we want to look for
- 1:04:09a particular string within this file and
- 1:04:12to do this with grep we now enter the
- 1:04:15pipe symbol
- 1:04:16which means we are redirecting the
- 1:04:18output of this initial command
- 1:04:20and we are now passing it on to grep so
- 1:04:22now grep can do something with this
- 1:04:24output so we say grep i want you to look
- 1:04:26for the word dynamic all right
- 1:04:29and we type we hit enter and we and
- 1:04:31there you are so again it does not give
- 1:04:33us any options here um and that's
- 1:04:36because i did not specify user here so
- 1:04:38again say alexis and again that gives us
- 1:04:40the using the user account information
- 1:04:43for the user lexus and again we can just
- 1:04:45change it to the
- 1:04:46proxychains.configuration file here
- 1:04:48and we hit enter and we change this to
- 1:04:50dynamic sorry um like so and it gives us
- 1:04:53the data now a lot of people have been
- 1:04:55asking me since uh since i covered
- 1:04:58redirecting output uh as i mentioned
- 1:05:00there are two ways of redirecting output
- 1:05:02the pipe
- 1:05:03key or the pipe command is used to
- 1:05:05redirect output and you know further
- 1:05:07process the data that you're outputting
- 1:05:09the difference between the pipe uh the
- 1:05:11pipe uh command or redirecting output
- 1:05:14with pipe and the greater than symbol is
- 1:05:15the greater than symbol will not display
- 1:05:18the information on to your terminal it
- 1:05:20will actually just output everything or
- 1:05:23redirect all the output of the command
- 1:05:25that you have
- 1:05:26that you've used into a file or even
- 1:05:28another command so again if i say cat
- 1:05:31fc password and i use this i wanted to
- 1:05:33redirect the output into it uh into a
- 1:05:35txt file i can say desktop
- 1:05:38and say test.txt and i hit enter and now
- 1:05:41if i actually get uh the the the file on
- 1:05:44my desktop sorry i believe i'm in my
- 1:05:46home directory here and i say test.txt
- 1:05:48hit enter it it actually has the content
- 1:05:50of the file so again that's the
- 1:05:51difference when uh when i'm actually
- 1:05:53talking about uh redirecting output with
- 1:05:56both the pipe and the greater than sign
- 1:05:58uh which is very different so
- 1:06:00again the pipe symbol is the preferred
- 1:06:02way of using or actually passing the
- 1:06:04output of one command and processing it
- 1:06:06with another command
- 1:06:08like
- 1:06:08leg grip and you can use it with other
- 1:06:10utilities that will actually show you
- 1:06:11how to use uh for the further further
- 1:06:14along the series here
- 1:06:16so
- 1:06:17you can use this with any other command
- 1:06:18that displays output onto the screen so
- 1:06:20i'm just going to use one more command
- 1:06:22just to show you how efficient this is
- 1:06:23so let's say i typed in ifconfig and i
- 1:06:26just want my inet information i can pipe
- 1:06:28the output of the ifconfig command and i
- 1:06:30can say i net
- 1:06:32uh and i can just say grab i net here
- 1:06:34and i hit enter and it gives a it gives
- 1:06:36me my inet information whether that be
- 1:06:38ipv4 or ipv6 all right so you can now
- 1:06:41see how useful this is and i want you
- 1:06:44guys to experiment with this let me know
- 1:06:46what you think
- 1:06:47where you're not understanding how to
- 1:06:48use it and i'll be sure to make up for
- 1:06:51full follow-up videos if you guys are
- 1:06:52interested in it
- 1:06:56in this video i'm going to be showing
- 1:06:58you how to use the locate utility to
- 1:06:59find files and i'll be also making an
- 1:07:02another video after this to show you how
- 1:07:03to use the find tool to actually find
- 1:07:06files as well so they're two utilities
- 1:07:07that you can use in this video we're
- 1:07:09going to be taking a look at how to use
- 1:07:10the locate tool it's a tool that goes
- 1:07:12ignored by many beginners or newcomers
- 1:07:14mostly because of its relative
- 1:07:15simplicity but it's a very efficient
- 1:07:17tool and does what it's supposed to do
- 1:07:19so again
- 1:07:20we can use the what is uh utility here
- 1:07:22to tell us more about what this tool is
- 1:07:24so again we can just say what is locate
- 1:07:26and as you can see it tells us it finds
- 1:07:28files by the name which is very simple
- 1:07:30and again you can use the manual page
- 1:07:33you can use the manual for this
- 1:07:34particular tool to learn how to use it
- 1:07:36so i'm just going to be covering just
- 1:07:38enough to make you efficient with the
- 1:07:39tool and make you understand how it
- 1:07:41works and how you can use it in
- 1:07:42conjunction with grip
- 1:07:44all right so
- 1:07:46uh let's actually get started with a
- 1:07:48very simple example right so let's say i
- 1:07:50wanted to locate a file on the system
- 1:07:52right and
- 1:07:53i wanted to locate a the password file
- 1:07:56so i can say locate
- 1:07:57password and hit enter and you can see
- 1:08:00it's given me a lot of a lot of
- 1:08:02information here a lot of files called
- 1:08:04password on my system
- 1:08:05right now this is really not efficient
- 1:08:08because um again i'm looking for a
- 1:08:11particular file that i'm looking for
- 1:08:13which is bill which actually exists in
- 1:08:14the etsy file and we can see the result
- 1:08:17well that's not actually the result here
- 1:08:19with this is the result right at the top
- 1:08:20here all right however this really is
- 1:08:23not efficient or an efficient way of
- 1:08:24going about it right so uh this is where
- 1:08:27we can now specify the options that we
- 1:08:29can use
- 1:08:30uh that we can use with uh with a tool
- 1:08:33like locate so let's say we wanted to
- 1:08:36get only the files that match this
- 1:08:38particular pattern or these particular
- 1:08:40uh strings here so the password string
- 1:08:43so to do this we type a or we use the uh
- 1:08:45we can use the all parameter or option
- 1:08:48here and once we hit enter again that
- 1:08:50gives us the same information so what
- 1:08:51does that means is it's actually
- 1:08:53displaying all the files on the system
- 1:08:56uh that actually match the patterns of
- 1:08:58password here
- 1:09:00and because this file really doesn't
- 1:09:01have any extension we now have to deal
- 1:09:03with the actual path or the path that we
- 1:09:06we might want to be uh finding this file
- 1:09:09in now of course that is counter
- 1:09:11intuitive given that um
- 1:09:13i can say that this belongs in the etsy
- 1:09:15in the etsy directory and again that now
- 1:09:18it now actually narrows down uh the
- 1:09:20files into what they may be so again
- 1:09:22that's the the actual file where we were
- 1:09:24looking for but you can see how tedious
- 1:09:26this is so we can actually shorten this
- 1:09:29now by actually using the grep tool
- 1:09:31which actually showed you how to use and
- 1:09:33it's very very simple so again we're
- 1:09:35simply going to use grip to look for
- 1:09:37particular information related to the uh
- 1:09:40to the information that is is given to
- 1:09:42us by locate so we can now say locate
- 1:09:45and then we say we're looking for
- 1:09:47password and
- 1:09:49we close that and now we say we pipe the
- 1:09:51output and we say grip let's look for
- 1:09:54password uh within etsy within the etsy
- 1:09:58directory so again
- 1:09:59we can now say etsy here sorry fc and
- 1:10:05we say password or we can just say the
- 1:10:07etsy directory here and then we can hit
- 1:10:09close and you can see it gives us the
- 1:10:11results we're looking for it highlights
- 1:10:13them in red or depending on the color
- 1:10:15scheme you're using in your terminal so
- 1:10:16again we can improve the efficiency of
- 1:10:18this by typing in
- 1:10:20etsy password and we hit enter so this
- 1:10:23is a file without a particular extension
- 1:10:25which makes it relatively difficult to
- 1:10:27actually find but you can find it
- 1:10:29relatively easily if you use grep here
- 1:10:31um so so let's actually talk about um
- 1:10:34about another file that has an extension
- 1:10:35that we can use to explain this here
- 1:10:38all right so
- 1:10:40um let's say we're working with the
- 1:10:43the the resolve file or the resolve
- 1:10:46configuration file which is used for to
- 1:10:48modify your name servers which is
- 1:10:50available on our linux systems what we
- 1:10:52can say is we can say locate
- 1:10:56resolve and uh sorry resolve and we hit
- 1:10:58enter and again tons of files but now we
- 1:11:01know that this file has an extension so
- 1:11:03we can say uh locate it's uh we can say
- 1:11:05locate resolve uh dot conf and read
- 1:11:08enter and again it still gives us a lot
- 1:11:09of files but we're looking for the one
- 1:11:11that belongs in the that exists in the
- 1:11:13etsy folder again so what we can do now
- 1:11:16is we can say locate and we want to
- 1:11:18actually
- 1:11:20we're looking for we can use the all uh
- 1:11:22the old parameter here
- 1:11:23and then we say we're looking for
- 1:11:26uh all files with an extension or we're
- 1:11:29looking for a file with the with an
- 1:11:30extension of uh conf or config here so
- 1:11:34we'll use the wildcard option to mean
- 1:11:36that this we're looking for for all
- 1:11:38files with this particular extension so
- 1:11:39we say
- 1:11:40um all and then we say conf and we close
- 1:11:44those um these quotation marks and now
- 1:11:46we pipe the output into grep here and
- 1:11:48now with grep we can then say we are
- 1:11:51looking for resolve here and we sorry
- 1:11:53that is we're looking for resolve when
- 1:11:55we enter and now it gives us the
- 1:11:57information we're looking for
- 1:11:59and the first option here so again
- 1:12:01that's with the
- 1:12:02the actual extension of confirm so again
- 1:12:04we're limiting the results to
- 1:12:07only the files that have an extension of
- 1:12:08config or configuration and then we can
- 1:12:10use grep to find the particular string
- 1:12:13that is most important to us so let me
- 1:12:15give you another example because this
- 1:12:16seems very simple
- 1:12:18so let's say
- 1:12:20we're looking for the proxy chains right
- 1:12:23uh so we can say proxy change and hit
- 1:12:25enter and there you are you can see
- 1:12:27immediately now because that is a unique
- 1:12:29string it gives us the results
- 1:12:31immediately with the uh we with the uh
- 1:12:33the extension here and that's because we
- 1:12:35specified it so again we can just say
- 1:12:37locate you know proxy chains
- 1:12:40and hit enter and there's a ton of files
- 1:12:42now another thing you might find useful
- 1:12:44is actually
- 1:12:46displaying how many results are matching
- 1:12:49the particular pattern you have
- 1:12:50specified exist so let's say i want to
- 1:12:52say locate i can say all that means all
- 1:12:55the the the matching uh the matching
- 1:12:58patterns here so we say all and then we
- 1:13:00can use the c uh the c argument here
- 1:13:03which specifies or prints the number of
- 1:13:05matching results and then we say we
- 1:13:08specify the string we're looking for or
- 1:13:10we can just say we're looking for proxy
- 1:13:12chains and we enter and it tells us here
- 1:13:14that we have 25 uh files
- 1:13:17uh or results that actually have the
- 1:13:19matching patterns here now if we limit
- 1:13:21it to
- 1:13:22conf and we hit enter now you can see we
- 1:13:24only have two so that's essentially how
- 1:13:26to use this tool uh in regards to you
- 1:13:28know displaying the amount of matching
- 1:13:30uh patterns you have and if you wanted
- 1:13:32to locate so if we get rid of this here
- 1:13:36and let's hit enter you can now see the
- 1:13:37results that it tells us here so we have
- 1:13:39the one in the etsy folder and one in
- 1:13:42the the debian package management uh
- 1:13:45the debian package management folder uh
- 1:13:47in regards to its actual configuration
- 1:13:50there so
- 1:13:51that's how to use the locate tool now
- 1:13:52again let me just cover one more
- 1:13:54additional parameter you can use and
- 1:13:56that is the the eye parameter which
- 1:13:58again is very important and that means
- 1:14:00that you want to ignore case uh that's
- 1:14:02something i should have mentioned
- 1:14:03earlier all searches with locate are
- 1:14:05typically going to be case sensitive so
- 1:14:08again i can say proxy chains
- 1:14:10and i hit enter and we have no results
- 1:14:12right so if i wanted to ignore the case
- 1:14:14sensitivity of what i've just hit uh of
- 1:14:16the the pattern i've just entered i can
- 1:14:18just hit i and i'd enter and again we
- 1:14:20get the same results and i can now limit
- 1:14:22this to proxychains.conf and there you
- 1:14:24are and again i can i can partner these
- 1:14:26or i can actually combine these commands
- 1:14:28with each other to give us the
- 1:14:30information we're looking for so again a
- 1:14:32very very simple tool to use but again
- 1:14:34it gives you very consistent results
- 1:14:40in this video we're going to be taking a
- 1:14:41look at how to enumerate uh system
- 1:14:43information on linux now you might be
- 1:14:45wondering what exactly do you mean here
- 1:14:47well i'm simply referring to uh
- 1:14:49important information about your system
- 1:14:51and the user currently logged in as just
- 1:14:54information that you might need when
- 1:14:56you're currently logged onto a system
- 1:14:57and you might want to know more about
- 1:14:59what you're dealing with all right so
- 1:15:00let's get started now the first
- 1:15:03uh the the first thing we need to do is
- 1:15:05we need to find out what user we're
- 1:15:07currently logged in as and the host name
- 1:15:09and the use id etc etc all right so
- 1:15:13let's get started with that
- 1:15:15so the first thing i want to know when
- 1:15:17i'm logged in is who am i exactly and
- 1:15:20that tells me the current user that i'm
- 1:15:21logged in as and then if i type in host
- 1:15:23name
- 1:15:24uh that again gives me the current
- 1:15:26hostname of this workstation or of this
- 1:15:28computer in my case it tells me i'm
- 1:15:30running uh the hostname is alexis
- 1:15:32workstation now if you do want to change
- 1:15:34your uh your hostname you can you can do
- 1:15:38so by by modifying the host name file i
- 1:15:41believe that's what it's called the yeah
- 1:15:44there we are and you can see that mine
- 1:15:46is set to alexis workstation or ws which
- 1:15:49is an abbreviation of workstation so you
- 1:15:51can change this and in my case i don't
- 1:15:53want to do this so i'm just going to
- 1:15:54exit out of here
- 1:15:56so that is how to find out the current
- 1:15:58user logged in as and the host name
- 1:16:01now if you want to find the user id that
- 1:16:03you're currently logged in as you can
- 1:16:04simply type in id
- 1:16:06that gives you the current use id
- 1:16:09and again of course the user you then
- 1:16:10have the group id which is quite
- 1:16:12important and the other groups that this
- 1:16:13user is currently a part of
- 1:16:15now um
- 1:16:17in regards to groups and the groups that
- 1:16:20a particular user may be part of the way
- 1:16:23to enumerate this information is by
- 1:16:25typing in groups and then the name of
- 1:16:27the user so we can type in groups alexis
- 1:16:30and once we hit enter again it tells us
- 1:16:33the user lexis is a part of these groups
- 1:16:35so it's a part of the group alexis sudo
- 1:16:38among the other ones here that are
- 1:16:40essentially system uh system accounts
- 1:16:42here that you or system groups that uh
- 1:16:45really have to do with just permissions
- 1:16:47to a particular service
- 1:16:49um so that is basic user enumeration now
- 1:16:51let's talk about a little bit about the
- 1:16:53system and enumerating information like
- 1:16:56um
- 1:16:57like your uh
- 1:16:59like your linux distribution the version
- 1:17:01stuff like that so uh i'm currently
- 1:17:03using a debian system or i'm using
- 1:17:06ubuntu so again it's based on debian so
- 1:17:08the the practices are all the the
- 1:17:10techniques and the commands are quite
- 1:17:12similar on both ends now when dealing
- 1:17:14with uh you know systemd based
- 1:17:16distributions
- 1:17:17uh and all of course red hat based
- 1:17:18distributions the process is going to be
- 1:17:20slightly different and i'll explain why
- 1:17:22and how
- 1:17:23um so on linux if you on sorry on
- 1:17:27on on tpn or on ubuntu if you want to
- 1:17:29enumerate your linux uh if you want to
- 1:17:32enumerate your linux distribution
- 1:17:34version and the name you simply type in
- 1:17:37lsb release a and of course
- 1:17:40lsb is a utility and you may not have it
- 1:17:43installed but again it comes with um
- 1:17:46with db and ubuntu by default so again
- 1:17:49that tells us the distributor the
- 1:17:50distributor id the description again
- 1:17:53ubuntu 18.04
- 1:17:550.3 lts
- 1:17:57the release name
- 1:17:58sorry the release version and the code
- 1:18:00name here which in this case is bionic
- 1:18:02beaver
- 1:18:03so again you can also use the check the
- 1:18:05contents of the issue file
- 1:18:08so if we type in cat etsy issue you can
- 1:18:10see it tells us the same thing here
- 1:18:12um
- 1:18:14so that is for debian based
- 1:18:16distributions now um
- 1:18:18when dealing with system d distributions
- 1:18:21like um
- 1:18:23centos arch
- 1:18:25red hat
- 1:18:27also debian to to some extent you can
- 1:18:29also use the you can also take a look at
- 1:18:32the content within the os release
- 1:18:34file which will also enumerate on debian
- 1:18:36as well but i just wanted to explain
- 1:18:38that so you guys don't get confused all
- 1:18:40right so what you can do is just simply
- 1:18:42type in cat let's see
- 1:18:44os
- 1:18:46os release and again that gives us the
- 1:18:47information that we were looking for now
- 1:18:50on um on ubuntu and on db and if i hit
- 1:18:53enter it tells us nothing there if i
- 1:18:56then use the star or the wildcard we hit
- 1:18:58enter that gives us the linux
- 1:19:00distribution information
- 1:19:02and a bit more information regarding the
- 1:19:04privacy policy
- 1:19:06uh support url stuff like that
- 1:19:09and um now that's uh now that we've also
- 1:19:12covered the system the uh base
- 1:19:14distributions let's talk about uh
- 1:19:16dealing with red hat now on red hat um
- 1:19:18if you want to take a look at the
- 1:19:20uh the red hat release version uh you
- 1:19:23can i believe you can find it if i type
- 1:19:24in cat hc and then you type in red hat
- 1:19:28release now i'm currently not using a
- 1:19:30red hat based distribution so that would
- 1:19:32pretty much give you the red release
- 1:19:34version um so that's basically
- 1:19:36enumerating your distribution name uh
- 1:19:40your distribution version and name um if
- 1:19:42you are using you know some of these uh
- 1:19:45distributions based on debian or the
- 1:19:47systemd based distributions like arch
- 1:19:50centos or red at enterprise linux
- 1:19:53so again let's talk about you know
- 1:19:56enumerating information about your
- 1:19:57processor or your cpu
- 1:19:59so you can easily do this by typing your
- 1:20:01ls cpu and we can hit enter and again
- 1:20:03that enumerates information about your
- 1:20:05cpu so it gives you information like
- 1:20:07your architecture and the instruction
- 1:20:09set
- 1:20:10um the amount of uh the amount of cores
- 1:20:14the threads per core the cost per socket
- 1:20:17sockets
- 1:20:18vend id
- 1:20:19cpu family the model model name in this
- 1:20:22case it's an i5 8400
- 1:20:25uh the stepping the
- 1:20:27the
- 1:20:28frequency here in megahertz so max and
- 1:20:31minimum as well so 4 gig by 4 gigahertz
- 1:20:34and the minimum of 800 megahertz
- 1:20:36uh
- 1:20:38virtualization and then the l1 l2 and l3
- 1:20:41cache and so information about your cpu
- 1:20:44all right so now that we've taken a look
- 1:20:47at enumerating cpu information let's
- 1:20:48take a look at enumerating kernel uh
- 1:20:50information which is done using the you
- 1:20:52name
- 1:20:53uh
- 1:20:54using the unnamed command or utility
- 1:20:55which essentially stands for unix name
- 1:20:59so again if we just type in what is your
- 1:21:01name here and you can see it says prints
- 1:21:03system information and guess the name
- 1:21:05and information about the current uh
- 1:21:07kernel so using it is very very simple
- 1:21:09so if you type in your name a that
- 1:21:11displays all the information so again it
- 1:21:13gives you information about like your uh
- 1:21:15your host name the current linux kernel
- 1:21:17that's that's installed and currently
- 1:21:19running
- 1:21:20and then you have the uh you then have
- 1:21:23the instruction set here i'm going over
- 1:21:24the the important information so again
- 1:21:27we can uh we can actually take a look at
- 1:21:29the various options that are available
- 1:21:31here so again we can say
- 1:21:33if we want the kernel uh we if we want
- 1:21:36the kernel version here we can type in
- 1:21:38uh we can say you name
- 1:21:41s and that tells us the kernel that
- 1:21:43we're currently running which is the
- 1:21:44linux kernel the version here can be
- 1:21:47printed out by typing you name
- 1:21:49uh i believe it's your name r that's the
- 1:21:51current release so in our case it's
- 1:21:53version 4.15 which i believe is stable
- 1:21:57not too sure
- 1:21:58um and then if you want again if you
- 1:22:00want the
- 1:22:03the information about the the
- 1:22:04instruction set for your processor you
- 1:22:06can type in your name
- 1:22:08you name p
- 1:22:09again that gives you the instruction set
- 1:22:10in our case x 86 64.
- 1:22:14uh and then if we want the hardware
- 1:22:16platform we can type in you name i
- 1:22:19so we can say you name i
- 1:22:21the hardware platform again that's the
- 1:22:23that's uh the information in regards to
- 1:22:25the architecture and then the operating
- 1:22:28system
- 1:22:29uh we can say you name
- 1:22:31o and it enter gnu linux so again just
- 1:22:33basic information regarding your system
- 1:22:36but uh the key bits of the important
- 1:22:39pieces of information here are your
- 1:22:40kernel and the instruction set of course
- 1:22:43so that's essentially all the
- 1:22:45information uh that you might want to
- 1:22:48enumerate regarding your system or you
- 1:22:50might be interested in now dealing with
- 1:22:53um with disk usage and um disk uh and
- 1:22:57disk usage disk space i'll be making a
- 1:22:59separate video on that so uh you guys
- 1:23:01can stay tuned for that but in regards
- 1:23:03to your system this these all the
- 1:23:05commands that you can use to find
- 1:23:06information about your the current user
- 1:23:08that's logged in
- 1:23:10uh so again if i type in who again that
- 1:23:12tells me the current users that are
- 1:23:14logged in in my case it's uh the only
- 1:23:17user is alexis so that's just an
- 1:23:19additional tidbit so again we've covered
- 1:23:22you know the user id the group id and
- 1:23:26we've also covered enumerating
- 1:23:27distribution information and the kernel
- 1:23:29information so
- 1:23:34in this video we're going to be covering
- 1:23:35how to use the find tool and we'll also
- 1:23:37be taking a look at some challenges on
- 1:23:39of the wire bandit uh more related to
- 1:23:41what we're taking a look at in this
- 1:23:42video which is how to correctly utilize
- 1:23:45the find command to look for files or
- 1:23:46directories within your system so an
- 1:23:48extremely uh you know very useful tool
- 1:23:51that will really help you save time when
- 1:23:53looking for particular files and i'll be
- 1:23:55showing you how to use it right now most
- 1:23:56efficiently so again we can use the what
- 1:23:58is utility to find out more information
- 1:24:00about the tool so again it tells you at
- 1:24:02this this tool allows you to search for
- 1:24:04files and in a directory hierarchy you
- 1:24:07can also check out the man pages for
- 1:24:08this particular tool
- 1:24:10and again you can go through all of this
- 1:24:12if you want to i'm going to be covering
- 1:24:14all uh the the information that is
- 1:24:16necessary or that will make you the most
- 1:24:18efficient with this tool
- 1:24:20all right so let's get started let's
- 1:24:21stop wasting time so using the tool is
- 1:24:23very simple we say find and then after
- 1:24:25sayings find we need to specify uh the
- 1:24:28directory we want to we want to search
- 1:24:30in so again we can specify the current
- 1:24:32directory that we are currently in uh by
- 1:24:34you know using the full stop or the dot
- 1:24:37uh or we can specify the entire linux
- 1:24:39file system directory which is done by
- 1:24:41using a forward slash like so as you
- 1:24:43would when navigating directories
- 1:24:45or i can specify an individual directory
- 1:24:47that i want to uh that i want to search
- 1:24:49in so i can say home
- 1:24:51alexis which is pretty much the
- 1:24:52directory we're working in so what i'm
- 1:24:54going to do is i'm just going to search
- 1:24:55the entire linux file system directory
- 1:24:57which if you're going to do you do
- 1:24:58require root or pseudo privileges
- 1:25:00otherwise you'll not be able to access
- 1:25:02files and directories that you know you
- 1:25:04do not have adequate permissions to
- 1:25:05access
- 1:25:06so i will also add the pseudo command
- 1:25:09here
- 1:25:10so again we're going to find files
- 1:25:11within the linux file system directory
- 1:25:13we then specify the other bit of
- 1:25:15information that uh will help us
- 1:25:16fine-tune our results which is of course
- 1:25:18going to be the type that we're dealing
- 1:25:20with so the type in regards to the find
- 1:25:22command is very simple it simply refers
- 1:25:24to what you're dealing with so are you
- 1:25:26looking for a file or a directory and
- 1:25:28that can be denoted by either using f
- 1:25:31for file or d for directory in our case
- 1:25:33we're looking for a file so we're just
- 1:25:35going to hit file all right so very
- 1:25:37simple next we specify the other
- 1:25:39variable that again will help us
- 1:25:40fine-tune our search results and is very
- 1:25:43important which is the name so what is
- 1:25:45the name of the file you're looking for
- 1:25:46so i can say proxy chains
- 1:25:49and i know i'm using the same example
- 1:25:51but again i'll show you how robust this
- 1:25:53is in a second so i can say
- 1:25:54proxychains.conf
- 1:25:56and after this i can pretty much hit
- 1:25:58enter now the important thing to note
- 1:26:00here
- 1:26:01is that i can use uh the grep command in
- 1:26:03conjunction with find to you know pipe
- 1:26:05output and specify configuration files
- 1:26:07by themselves similar to what we looked
- 1:26:09at when we're taking a look at the
- 1:26:10locate tool uh so i can just hit enter
- 1:26:13and you can see we found the
- 1:26:14configuration file and we didn't have
- 1:26:17adequate permission for some files which
- 1:26:19is perfectly fine
- 1:26:20um so that's how to use the find tool
- 1:26:22and i've shown you the various
- 1:26:23parameters you can use so you can
- 1:26:24specify the type uh the name uh which
- 1:26:27i'll show you how to how robust it can
- 1:26:28be in a second so let's take a look at
- 1:26:30the same example so i'm just going to
- 1:26:32say find um and you know we can just say
- 1:26:35sudo sudo find
- 1:26:37and we say the type is going to be
- 1:26:40a file which you can also change to
- 1:26:42directory if you are looking for a
- 1:26:43directory so for example i can say
- 1:26:46directory and then i can say name
- 1:26:48and their name is going to be alexis
- 1:26:50look for the directory lexis and hit
- 1:26:52enter and their ui tells us oh we have
- 1:26:54various uh directories here so we can
- 1:26:56see we have um
- 1:26:58we have the home directory here and a
- 1:27:00few other files here that uh i've
- 1:27:02actually popped up from my external hard
- 1:27:04drive which i don't think are that
- 1:27:05important
- 1:27:07but there you go that just shows you how
- 1:27:09robust this tool is in regards to you
- 1:27:11know looking for particular files so you
- 1:27:13can change that up so so let's go back
- 1:27:14to our previous example so i'm just
- 1:27:15going to say the name is going to be
- 1:27:17proxy chains now i mentioned in the
- 1:27:19previous video the the case sensitivity
- 1:27:21which is quite important so if you are
- 1:27:24performing a search
- 1:27:26uh in which you do not want any case
- 1:27:28sensitivity you use the i name command
- 1:27:30instead of the name command and then
- 1:27:32after this you can say i can say alexis
- 1:27:34for example and of course it will ignore
- 1:27:36all the cases here so i can you know i
- 1:27:39can combine it with whatever uppercase
- 1:27:41up and lowercase uh characters i want
- 1:27:43and i'll still get i'll still get the
- 1:27:45same results
- 1:27:46uh and i can just hit enter
- 1:27:49and uh this time again it gave us uh the
- 1:27:52same results but uh it gave us different
- 1:27:54results because we are looking for a
- 1:27:56file so if we change this into a
- 1:27:57directory here you can see that it's
- 1:27:59going to give us the same results that
- 1:28:00we had in the in the initial run when
- 1:28:02we're looking for uh you know
- 1:28:04directories uh called alexis so that's
- 1:28:06how robust this tool is so i talked
- 1:28:08about using um using extensions which is
- 1:28:11again very very simple so let's say
- 1:28:13we're looking for extensions and we're
- 1:28:15looking for all uh conf files which
- 1:28:17belong in the etsy directory so i'm just
- 1:28:19going to say etsy and we've now written
- 1:28:21it down we can say name is going to be
- 1:28:24i can say um
- 1:28:27uh we can just say conf and we'll use
- 1:28:28the wildcard uh so i say conf we'll just
- 1:28:31use the same configuration file
- 1:28:32extension
- 1:28:33uh and then i can say grep and then i
- 1:28:35specify the name of the file right so uh
- 1:28:38you know i can hit enter and this is
- 1:28:40going to display all the configuration
- 1:28:42files within the etsy directory but
- 1:28:44again i have to specify the
- 1:28:46uh the file specification here and i'm
- 1:28:48going to enter
- 1:28:49and there you are so it gives you all
- 1:28:50the configuration files so very simple
- 1:28:53tool to use now let's talk about the
- 1:28:54other variables that you can use to
- 1:28:56specify
- 1:28:57that will help you fine-tune your your
- 1:28:59search results and that is by specifying
- 1:29:01the size of the file
- 1:29:03and the permissions all right so again
- 1:29:05we can just use a simple example i'm
- 1:29:07just going to say find and i'm going to
- 1:29:09say we'll say type and that's going to
- 1:29:11be you don't really need to specify the
- 1:29:13type if you don't want to it's just
- 1:29:14there to help you fine tune your results
- 1:29:16so i can perfectly ignore it if i know
- 1:29:18what i'm looking for
- 1:29:19precisely i can then say you know name
- 1:29:22and the name is going to be proxy chains
- 1:29:25i can say epoxychains.conf you know i
- 1:29:26have the whole name
- 1:29:28and then i can say size i'm looking for
- 1:29:30a file with a particular size so i can
- 1:29:32then use the various options i have so i
- 1:29:34can say it's going to be plus one
- 1:29:36megabyte which can be done like so uh or
- 1:29:39i can you know i can save plus a hundred
- 1:29:41megabytes whatever i want to say so in
- 1:29:43this case let me just say plus one
- 1:29:44megabytes and hit enter
- 1:29:46and uh well we're getting uh various
- 1:29:48permission errors here and that's
- 1:29:50because we'll just say etsy
- 1:29:52hit enter
- 1:29:54and i will say sudo and
- 1:29:57there we are and we got no results at
- 1:29:59all i just wanted to to actually provide
- 1:30:01it with the adequate the adequate
- 1:30:02permissions so that i can show you that
- 1:30:05if we use uh you know
- 1:30:07if we use parameters like these size and
- 1:30:10we specify it down to due to the actual
- 1:30:13size of the file we can sort of uh
- 1:30:14fine-tune our results very very uh to a
- 1:30:16very deep granular level
- 1:30:18so if i just um
- 1:30:21let's say um etsy and i can then grab
- 1:30:26proxy chains
- 1:30:28conf and
- 1:30:29i hit enter here you can take a look at
- 1:30:32let me just change this to a human
- 1:30:34readable format so you can say it's
- 1:30:36about uh four kilobytes here and uh we
- 1:30:39can then you know you can specify the
- 1:30:41size depending on on how you want it and
- 1:30:43i'll get back to this uh when we'll be
- 1:30:45taking a look at the uh the over the
- 1:30:46wire banded challenges because that's
- 1:30:48where i really want to showcase the
- 1:30:49power of the fine tool
- 1:30:51let's talk about permissions before we
- 1:30:53actually get started with at the over
- 1:30:54the wire bandit challenges and the
- 1:30:56permissions are very simple to to
- 1:30:58actually specify here i'm going to be
- 1:31:00covering you know users and groups and
- 1:31:01we'll be taking a look at that example
- 1:31:03but let's talk about uh permissions
- 1:31:05first so permissions allow you to find
- 1:31:07again files that have particular
- 1:31:09permissions very very straightforward
- 1:31:11here so you know i can say um
- 1:31:14let's say i create a file go to my
- 1:31:16desktop here and i'll say touch
- 1:31:18alexis dot sh you know just a simple
- 1:31:21shell script or a bash script here hit
- 1:31:23enter and i say chmod
- 1:31:25400 alexis dot sh and hit enter and they
- 1:31:29say find within
- 1:31:30the home directory i can then say
- 1:31:34let's say we're looking for a file
- 1:31:36type is going to be a file we don't have
- 1:31:38a name but we have permissions so i can
- 1:31:40say firm
- 1:31:41let's look for
- 1:31:43let's look for files with the permission
- 1:31:44of 400 which means
- 1:31:47um
- 1:31:48which means that the the the owner or
- 1:31:50the user can read the file um but the
- 1:31:53other group and all other users on the
- 1:31:55system are not able to access it so
- 1:31:58again uh that should give us a few
- 1:32:00results but we don't have adequate
- 1:32:01permissions for the other files so you
- 1:32:03can see we get the result right over
- 1:32:05here so you can use permissions to help
- 1:32:07fine-tune your search results and get
- 1:32:09the exact results you're looking for
- 1:32:11you know we can also specify 744 we hit
- 1:32:14enter and uh
- 1:32:16it looks like we had a few files with
- 1:32:18those particular permissions but
- 1:32:20nothing no no important files that we
- 1:32:23that don't have the correct permission
- 1:32:25so you can see that this can help you
- 1:32:26find a files on your system that have
- 1:32:28incorrect permissions and then you can
- 1:32:30rectify them uh you know like so instead
- 1:32:32of going manually and checking for their
- 1:32:34permission so very useful tool now that
- 1:32:36we've taken a look at how to use the
- 1:32:38tool let's take a look at how to
- 1:32:40implement it in some challenges and
- 1:32:42that's what we're going to do in the
- 1:32:43next step which is the over the wire
- 1:32:45challenges so you can follow along if
- 1:32:46you want to and i'll see you there
- 1:32:48all right so we are back on over the
- 1:32:50wire and i'm currently on the bandit uh
- 1:32:53on the bandit web page here and uh you
- 1:32:56you can get access to this challenge by
- 1:32:58following the instructions on level zero
- 1:32:59uh the levels we're interested in are
- 1:33:01going to be levels four five
- 1:33:03uh level fours uh to level four to level
- 1:33:06six so again we'll just go to level four
- 1:33:08here and i currently have access and
- 1:33:09i've solved the challenges uh all
- 1:33:12all up till level four so we can get
- 1:33:14started
- 1:33:15all right so
- 1:33:16uh you can see that uh level four
- 1:33:18pertains uh
- 1:33:20actually finding a file so you can see
- 1:33:22the password for the next file or for
- 1:33:24the next level is stored in the in the
- 1:33:26only human readable file
- 1:33:28in the in here directory uh tip if your
- 1:33:31terminal is messed up you can try the
- 1:33:33reset command and again it gives you the
- 1:33:35various commands that you can use to
- 1:33:36solve this level so again let's go back
- 1:33:38into our terminal as you can see i'm
- 1:33:40currently on bandit 4 and we can list
- 1:33:42the files within this home directory and
- 1:33:44you can see we have an in here directory
- 1:33:46so let's uh let's go in here let's see
- 1:33:48what's going on
- 1:33:50so if you list the files here you can
- 1:33:52see we have various files and if i if i
- 1:33:54try cutting one of these uh one of these
- 1:33:56files you can see that um
- 1:33:59sorry let's specify that hyphen there
- 1:34:02let's say file zero zero we can hit
- 1:34:04enter and you can see it has a various
- 1:34:06uh
- 1:34:07it has various pieces of data and of
- 1:34:09course our job is to look for files
- 1:34:11within this in here directory that have
- 1:34:14uh human readable data so again what we
- 1:34:16can do is we can use the find command
- 1:34:18here uh to actually find uh you know the
- 1:34:21various files that have human readable
- 1:34:23data so i can say uh in this current
- 1:34:25directory and we are looking for um
- 1:34:28[Music]
- 1:34:29we can actually just say find and then
- 1:34:31in this directory uh we're looking for
- 1:34:34the type
- 1:34:35it's going to be a type of file here and
- 1:34:37then we can grip the output or we can
- 1:34:39pipe the output sorry and within we can
- 1:34:41use the x args command here to look for
- 1:34:45um i believe it's uh if we just expand
- 1:34:48this uh let's take a look at how to use
- 1:34:50x cogs one more time
- 1:34:51uh we wanted to display uh the file read
- 1:34:54items from a file uh instead of standard
- 1:34:57uh standard input
- 1:35:00uh
- 1:35:00and yeah this if we type in file that
- 1:35:03should tell us the files that we're
- 1:35:04dealing with all right and this will
- 1:35:06help us shorten the process so let's go
- 1:35:08back in here as we say file in it enter
- 1:35:11and as you can see it tells us that in
- 1:35:13file 0 7 we have some ascii text however
- 1:35:17in all the other files we have data so
- 1:35:18again we can access this file now we can
- 1:35:20just cap the contents of this file and
- 1:35:22we should get the password next level
- 1:35:24all right excellent so we can copy this
- 1:35:26let me exit and we'll go to bandit level
- 1:35:29five here i'm going to enter we'll just
- 1:35:32paste in the password
- 1:35:34and we can get started now all right so
- 1:35:36let's take a look at what a challenge or
- 1:35:38level five uh pertains
- 1:35:40so again it says the password for the
- 1:35:42next level is stored in a file somewhere
- 1:35:44under the in here directory and has all
- 1:35:47of the following properties it's human
- 1:35:49readable um okay all right it's going to
- 1:35:52be a human readable file um 1033 bytes
- 1:35:56in size
- 1:35:57and it's not executable all right so
- 1:35:59that's uh an option these are all the
- 1:36:01these are all parameters that we'll have
- 1:36:03to specify to some extent
- 1:36:05so let's actually get started so
- 1:36:07uh these are going to be in the in here
- 1:36:10directory so i'll just go into the in
- 1:36:11here directory and you can see we have
- 1:36:13uh other directories within this so
- 1:36:15we're going to just say find
- 1:36:17uh and we're going to say type is going
- 1:36:19to be a file uh we were told that we
- 1:36:22have it's going to be human readable so
- 1:36:24you can use x args there
- 1:36:27uh
- 1:36:27size i showed you how to specify size
- 1:36:29now the the thing about specifying size
- 1:36:32in bytes is if we just take a look at um
- 1:36:37we take a look at the at the find tool
- 1:36:38and we just
- 1:36:40grip for some for size you can see that
- 1:36:43it tells us the size does not count
- 1:36:45indirect blocks uh
- 1:36:47etc so size one megabyte is not
- 1:36:49equivalent is not equivalent to size so
- 1:36:51if you're specifying it in bytes you
- 1:36:53need to specify uh the actual number and
- 1:36:55then the c here all right so that's what
- 1:36:58we have to do so um we just go back in
- 1:37:01here and we go to type a file and then
- 1:37:03we say size
- 1:37:04is going to be 10 33 c and then after
- 1:37:07this um
- 1:37:09we're supposed to us
- 1:37:11the file is not
- 1:37:12is not executable so we can then use the
- 1:37:15logic um operators here so we're going
- 1:37:18to say
- 1:37:19not executable and executable is another
- 1:37:22parameter you can specify and then we
- 1:37:24can use xrx here
- 1:37:26and we're going to say file and hit
- 1:37:28enter
- 1:37:29and you can see it tells us
- 1:37:31that maybe here07 and file2 has some
- 1:37:34ascii text with very long lines all
- 1:37:37right so let's cut the content off this
- 1:37:39file
- 1:37:40and just get it we're just going to
- 1:37:42enter here and we have the password so
- 1:37:44let's exit and go on to the final level
- 1:37:46in this particular video so i'm gonna
- 1:37:48go into level six hit enter
- 1:37:51and i'm gonna paste the password in here
- 1:37:53and we can now take a look at what level
- 1:37:56six pertains
- 1:37:58uh so level six the password for the
- 1:38:00next level is stored somewhere on the
- 1:38:02server and has all of the following
- 1:38:04properties so yeah this is now where we
- 1:38:06have the user and group specifications
- 1:38:09which is really simple so again we're
- 1:38:11told to look for a file
- 1:38:13on the entire server
- 1:38:15owned or the the entire linux file
- 1:38:17system that is owned by the user bandit
- 1:38:19seven
- 1:38:20and is owned by the group bandit six and
- 1:38:23in 33 bytes in size all right so we can
- 1:38:27then say um
- 1:38:28it's on the entire server we have any
- 1:38:30files here no we don't so we can say
- 1:38:32find and we're looking for a user which
- 1:38:36is going to be bandit seven and a group
- 1:38:39which is again very easy to specify
- 1:38:41group is going to be bandit 6
- 1:38:46the particular file we're looking for is
- 1:38:48going to be
- 1:38:5033 bytes so 33c
- 1:38:54[Music]
- 1:38:55i think that's pretty much it in regards
- 1:38:57to the options or the parameters that we
- 1:38:59were given so let's actually see if we
- 1:39:01can find this file when it enter
- 1:39:05and
- 1:39:05we get various
- 1:39:07you know permission denied errors here
- 1:39:10and it looks like we get a password file
- 1:39:13here so that's under the var folder or
- 1:39:15the var directory and it's a bandit 7
- 1:39:18password so let's copy the directory do
- 1:39:19that the actual file path the relative
- 1:39:22file path and cat the contents of that
- 1:39:24and we get the password to the next
- 1:39:26level and i'm just going to hit exit and
- 1:39:29we can move on to bandit level 7 which
- 1:39:32is now
- 1:39:32is is going to pertain to another
- 1:39:34challenge which is out of the scope of
- 1:39:36this video so
- 1:39:40in this video i'm going to be talking
- 1:39:41about shells now this might be a little
- 1:39:43bit confusing for you if you're a
- 1:39:45beginner to linux but um
- 1:39:47you the only thing you need to
- 1:39:49understand is that your the various
- 1:39:51types of shields you can use on linux
- 1:39:53now if you're using ubuntu or debian the
- 1:39:56default shell that you'll be you'll be
- 1:39:58given is going to be called the bash
- 1:40:00shell all right and again i can confirm
- 1:40:03this by echoing my variable my shell
- 1:40:05variable here so i can say echo shell
- 1:40:07and again it tells you the the current
- 1:40:09shell that i'm using which is bash now
- 1:40:11bash is an acronym for the born again
- 1:40:14shell
- 1:40:15uh so that means that there was a born
- 1:40:17shell and you're familiar with it and
- 1:40:19that is the sh or the sh shell so uh
- 1:40:23all of these shells can be used to to
- 1:40:26actually work with the linux system
- 1:40:28that's that's entirely up to you my
- 1:40:30objective in this video is to explain
- 1:40:33how to change your default shell and not
- 1:40:35work with the bash shell
- 1:40:37all right now
- 1:40:38on linux if you want to actually display
- 1:40:40all the shelves that you currently have
- 1:40:42that can be used uh you can essentially
- 1:40:45just read the contents
- 1:40:47of the shells file in the etsy directory
- 1:40:49and i can hit enter and you can see it's
- 1:40:52going to tell me it's going to tell you
- 1:40:53the valid login shells you have
- 1:40:55so we have the born shell which is the
- 1:40:58sh we have the born again shell which is
- 1:41:00bash which is the preferred
- 1:41:02shell to use you then have our bash and
- 1:41:04dash which is pretty good and then you
- 1:41:06have fish now i just installed fish and
- 1:41:09again many of you have been asking me to
- 1:41:11cover this i'll explain it after i've
- 1:41:13after actually explained passion how to
- 1:41:15use it how to customize it and stuff
- 1:41:17like that so for the purpose of this
- 1:41:19video i'm going to be using i'm going to
- 1:41:21be using bash and i'll later on cover
- 1:41:23the other the other shelves that you can
- 1:41:24use and you know using fish
- 1:41:27so the first thing is how to switch from
- 1:41:30shell to shell within a given terminal
- 1:41:32instance
- 1:41:33so i'm currently using the bash shell if
- 1:41:36i wanted to switch into the bond shell i
- 1:41:38can just hit sh and hit enter and you
- 1:41:41can see i'm now in the bond shell and
- 1:41:42again all the linux commands work
- 1:41:44perfectly fine i can hit all the various
- 1:41:46linux commands that i could run so i can
- 1:41:49list all the files in here etc etc you
- 1:41:51get the idea right so i can then say cat
- 1:41:54etsy shelves and again we can take a
- 1:41:57look at the shelves we have i can now go
- 1:41:59back into bash
- 1:42:00i can go into dash if i want to and
- 1:42:02again that takes me to in into into dash
- 1:42:05you can say echo and we can again
- 1:42:08confirm this and hit enter and it tells
- 1:42:10us we're still in pin bash that is
- 1:42:12because we're currently within this
- 1:42:14instance but if i changed it as my
- 1:42:16default login shell which i'll show you
- 1:42:18in a second how to do so let me just go
- 1:42:20back into bash
- 1:42:21and we will actually let me just clear
- 1:42:24this out so there we all right so
- 1:42:26you can see how easy it is to switch
- 1:42:28between shells in a particular terminal
- 1:42:30instance now
- 1:42:32by default as a user account on a linux
- 1:42:34system
- 1:42:35uh a
- 1:42:36you will be specified a particular shell
- 1:42:39to use and that can be found in the
- 1:42:40password file so if i hit enter so let
- 1:42:42me just grab it and display my account
- 1:42:45you can see that the shell is specified
- 1:42:47here and i'll explain this when talking
- 1:42:48about users and groups you can see that
- 1:42:50uh the default login shell that i have
- 1:42:53been specified to use is the bash shell
- 1:42:57which is perfectly fine now the great
- 1:42:58thing about linux is when creating the
- 1:43:00user you can specify the shell that
- 1:43:02they're going to use however you can
- 1:43:04also change the shell of the user or the
- 1:43:06user can change the shell that they want
- 1:43:08to use when they log in or every time
- 1:43:10they log in and the way we do that is by
- 1:43:12using the change shell command or the
- 1:43:15change shell utility which is defined by
- 1:43:18chsh or that's an actual abbreviation of
- 1:43:21the command so i can type in what is
- 1:43:23chsh
- 1:43:24and i'm going to enter you can see it
- 1:43:26tells you this allows you to change the
- 1:43:28login shell
- 1:43:29all right so if i want to change uh the
- 1:43:32default login shell all i need to do is
- 1:43:34let me first display the shells that i
- 1:43:36have here one more time all i need to
- 1:43:38specify is their relative path all right
- 1:43:40so if i say chs8 it's going to ask me
- 1:43:42for the password of my user here when it
- 1:43:45enter and it's going to say changing the
- 1:43:46login shell for the user lexis enter new
- 1:43:49value or press enter for the default the
- 1:43:51default login shell for me is bash so if
- 1:43:54i wanted to change it to
- 1:43:56to fish for example i would say
- 1:43:58user
- 1:44:00sorry that is user
- 1:44:02bin and i say fish i'm going to enter
- 1:44:04and that changes it for me all right so
- 1:44:07what this means in essence if i type in
- 1:44:09cat hc password here
- 1:44:12what this means
- 1:44:13let me just display the results here you
- 1:44:15can see that it changes uh the default
- 1:44:17login shell so this means that uh when i
- 1:44:20log out and i log back in
- 1:44:22uh what's gonna happen is that i'm gonna
- 1:44:24be given the fish shell as my default
- 1:44:26shell instead of bash so if you're
- 1:44:28wondering what the fish shell is uh you
- 1:44:30can install it very easily by typing
- 1:44:32sudo apt install or apt-get install
- 1:44:35whatever you find is useful for you
- 1:44:38just hit enter and i already have it
- 1:44:40installed so that's how to install it so
- 1:44:42what is fish fish is a friendly as a
- 1:44:45friendly interactive show it's a great
- 1:44:47show for beginners extremely
- 1:44:48customizable and you can see once i
- 1:44:50typed in fish it allowed me to log in
- 1:44:52the great thing about fish is it allows
- 1:44:54allows me to actually it actually gives
- 1:44:57me predictions in regards to the
- 1:44:59commands that i might be interested in
- 1:45:00running we'll get to this in a second
- 1:45:01let me go into bash
- 1:45:03all right so that is how to change your
- 1:45:05default login shell
- 1:45:07all right so again i'm right now i'm
- 1:45:09currently set to use fish as the default
- 1:45:12shell when i log in every time
- 1:45:14but let's talk about bash because that's
- 1:45:16uh that that's the primary goal of this
- 1:45:18video because it's the most used shell
- 1:45:20and the one you'll be coming across
- 1:45:22mostly so in my current home directory
- 1:45:24so in the user lexis directory here i
- 1:45:27have various bash files bash
- 1:45:29configuration files uh within this
- 1:45:32directory so i'm just gonna grab them
- 1:45:34and i'll say bash and of course they're
- 1:45:36gonna be hidden
- 1:45:37so i'm just gonna hit enter and as you
- 1:45:38can see i have a bash aliases file which
- 1:45:41you're not going to have by default i
- 1:45:42created this and i created it to to
- 1:45:45prove a point and to actually
- 1:45:46demonstrate an example here we then have
- 1:45:48the bash history uh file which has uh
- 1:45:51all your history of all your commands
- 1:45:53and this is very different to your
- 1:45:55actual
- 1:45:56gnu history uh utility
- 1:45:59um
- 1:46:00you have bash log out and bash rc bash
- 1:46:02rc is your bash configuration file i'm
- 1:46:04not gonna cover how to configure it it's
- 1:46:06extremely straightforward and you can
- 1:46:08pretty much configure it directly uh by
- 1:46:10using the preferences tab right over
- 1:46:12here
- 1:46:13but we can take a look at it i just want
- 1:46:15to show you how it is so and if we take
- 1:46:17a look at it here through vim you can
- 1:46:20see that
- 1:46:21it essentially allows you to to
- 1:46:23configure set
- 1:46:25variables i change the color change the
- 1:46:27the size of the history of the history
- 1:46:29file um
- 1:46:31let's see what else you can actually do
- 1:46:34here so there you can you can change the
- 1:46:36color
- 1:46:38this is all to do with color and you can
- 1:46:40you can do a lot of other stuff with uh
- 1:46:42in regards to customizing how it appears
- 1:46:44and and how it works so for example if i
- 1:46:47wanted um if i wanted bash to actually
- 1:46:51run the fish shell instead of the bash
- 1:46:54shell every time i started up
- 1:46:56i started bash up i would type in fish
- 1:46:58right just at the bottom here and let me
- 1:47:01save this file now and if i open up a
- 1:47:03new terminal you can see immediately it
- 1:47:05opens up the fish shell
- 1:47:07so that's pretty cool but this isn't the
- 1:47:09correct way of doing it or the preferred
- 1:47:11way of doing it so i'll just get rid of
- 1:47:13this fish command here
- 1:47:15and i'll save the changes here all right
- 1:47:16so now that we've talked about um
- 1:47:20now that we've talked about the bash rc
- 1:47:22file let's talk about the bash history
- 1:47:25file which is very important all right
- 1:47:26so
- 1:47:27by default in linux you have the history
- 1:47:30command um which again let me just type
- 1:47:32it in the history command is essentially
- 1:47:35the new history library now the the
- 1:47:36history uh
- 1:47:38this essentially allows you to to
- 1:47:40actually check uh a lot it stores a
- 1:47:42history of all the commands you've run
- 1:47:45and uh you know you can clear your
- 1:47:46history very easily by typing in history
- 1:47:49c right and it's as simple as that but
- 1:47:52it's not to be mistaken or confused with
- 1:47:55bash history which is again uh
- 1:47:57is specific to the bash shell or the
- 1:48:00bone again shell
- 1:48:01so again this file will contain a list
- 1:48:04of all the commands that i've run and
- 1:48:06and i'll show you how to clear it so if
- 1:48:08i get the contents of the file
- 1:48:10uh you can see that it it has all of
- 1:48:13these commands that i've been running so
- 1:48:15far you know perfectly fine
- 1:48:17and if i wanted to clear it it's very
- 1:48:20easy i can just redirect the the
- 1:48:22contents of the so i can say dev
- 1:48:25null and then
- 1:48:27[Music]
- 1:48:28i can redirect the output into the
- 1:48:30actual bash history file they bash
- 1:48:33history here hit enter clear this out
- 1:48:36if i now try and catch the contents of
- 1:48:39the bash history file
- 1:48:41you can see it has nothing so i've been
- 1:48:43able to clear my bash history i think
- 1:48:44i've covered this in my one of the
- 1:48:46videos where i spoke about uh actually
- 1:48:49clearing your tracks on linux so this is
- 1:48:51a great way of doing that and of course
- 1:48:53you can then use the history command if
- 1:48:55you want to do that so that's to do with
- 1:48:57actually using the um
- 1:49:00with actually working with the actual
- 1:49:02bash history here now let me talk about
- 1:49:04the bash aliases file all right so the
- 1:49:06aliases file is very simple it allows
- 1:49:08you to specify aliases or command
- 1:49:10aliases that you'd like to use now you
- 1:49:12can just create a file within your home
- 1:49:14directory and just name it bash aliases
- 1:49:16so what i'll do is i'll actually just
- 1:49:18show you the contents of the file
- 1:49:21so i can just show it show it to you
- 1:49:22right over here so bash aliases hit
- 1:49:24enter and you can see i have two aliases
- 1:49:27i have alias update which runs the
- 1:49:29command sudo apt-get update and then i
- 1:49:31have upgrade which runs the command sudo
- 1:49:34apt-get upgrade so it's fairly simple to
- 1:49:36understand what happens so i can just
- 1:49:38type in update and that will update my
- 1:49:40packages and then i can type in upgrade
- 1:49:43and that will upgrade my packages
- 1:49:44instead of typing the commands over and
- 1:49:46over again so that is what
- 1:49:48you know the command aliases are and how
- 1:49:50to specify them so again it's very
- 1:49:52simple in regards to configuring it
- 1:49:57in this video i'm going to be showing
- 1:49:59you uh how to enumerate intermission in
- 1:50:01regards to your current disk usage and
- 1:50:03in information you know in regards to
- 1:50:05how much storage your system is
- 1:50:06consuming how much you have left the
- 1:50:08various disks attached to your system
- 1:50:10etc stuff like that
- 1:50:12all right so as i said in the previous
- 1:50:13videos in regards to enumerating you
- 1:50:15know information about your system it's
- 1:50:17very important to know uh the state of
- 1:50:20view system and that you know could
- 1:50:21include the current ram usage uh what
- 1:50:24you the temperature of your processes
- 1:50:26are you know so again it's very
- 1:50:27important to know as a system
- 1:50:28administrator or someone who is going to
- 1:50:30be you know using linux uh you know more
- 1:50:34and more every day uh how to enumerate
- 1:50:37information and useful information like
- 1:50:39your current disk usage
- 1:50:41and the various drives that you have
- 1:50:43installed on your system so let's talk
- 1:50:45about disk usage first which is quite
- 1:50:47important right because when working
- 1:50:49with the terminal you have no gui you
- 1:50:51know programs
- 1:50:53that can actually you know visualize
- 1:50:54this for you so it's very important that
- 1:50:56you understand how to do this extremely
- 1:50:58important so the tool we're going to be
- 1:51:00using is a tool called du right and
- 1:51:02again it's fairly straightforward what
- 1:51:04that means that means disk usage so i
- 1:51:07can just say what is what is du and i
- 1:51:09can hit enter and as you can see it
- 1:51:10tells you this allows you to estimate
- 1:51:12file space usage right
- 1:51:15now du is a very simple tool to use and
- 1:51:18you can take a look at the man pages or
- 1:51:19in regards to how how to use it
- 1:51:22um so let's actually just run a simple
- 1:51:25command within this current directory
- 1:51:26and i'll show you what i mean so if i if
- 1:51:28i hit du
- 1:51:30uh you can see that
- 1:51:32this is um there's something weird
- 1:51:34happening here right so it's displaying
- 1:51:37a lot of files and uh when i say that it
- 1:51:40really is displaying it's displaying all
- 1:51:43the sizes of all the files within this
- 1:51:45directory recursively all right now you
- 1:51:48might be saying well what does that mean
- 1:51:50exactly
- 1:51:51well it means that it's actually showing
- 1:51:53you the size of all the files within a
- 1:51:56current working directory all right
- 1:51:58that's essentially what it means now
- 1:51:59what current directory am i working in
- 1:52:01i'm working in my home directory so we
- 1:52:03need to make this a little bit more
- 1:52:05human readable and the way we do this is
- 1:52:07by typing du and then we specify some
- 1:52:10arguments the first thing we want to do
- 1:52:12is we want to summarize
- 1:52:14all of these results into a uh into a
- 1:52:16format that we can understand right so
- 1:52:19instead of displaying recursively all
- 1:52:21the files here show us the top level
- 1:52:23directories and the total sizes of those
- 1:52:26directories and then we can go
- 1:52:27recursively within those particular
- 1:52:29directories if we wanted to all right so
- 1:52:32the s command is going to summarize
- 1:52:34everything up and then we want to use
- 1:52:35the h command the human readable format
- 1:52:38within this current working directory
- 1:52:40and i'm going to hit enter
- 1:52:42and as you can see right over here tells
- 1:52:45you it gives you a beautiful list of all
- 1:52:47the directories you have in this
- 1:52:49particular directory and on the left
- 1:52:51hand side you have their sizes in human
- 1:52:53readable format which means they have uh
- 1:52:56they have that they have size uh they
- 1:52:59have uni their various units in
- 1:53:00megabytes and in gigabytes
- 1:53:02and you know so far the the only file
- 1:53:05that's crossed at the threshold of one
- 1:53:07gigabyte is my virtualbox folder so
- 1:53:09again you can use a tool like trep to if
- 1:53:12you're going through tons of files on a
- 1:53:14system i'm just using simple examples
- 1:53:16here so you know i can say grep and you
- 1:53:18know i can say one uh one gig and we can
- 1:53:21hit enter and again that can be used to
- 1:53:23enumerate all of these all of this type
- 1:53:25of information or i can just say g
- 1:53:28g would be much better and there you are
- 1:53:30so again that's how to use grep in
- 1:53:32conjunction with all of these commands
- 1:53:34so that's how to use the disk usage tool
- 1:53:36now again i can go on to my um let me
- 1:53:40just go uh
- 1:53:41actually let's let's just go into the
- 1:53:43linux file system itself and say sudo uh
- 1:53:46eush and we'll run the same command and
- 1:53:48again we can hit enter and again that
- 1:53:50starts to enumerate the sizes of all of
- 1:53:52these directories now mind you it has to
- 1:53:54go through all of these directories and
- 1:53:56the subdirectories uh directories
- 1:53:58recursively to get this size so again
- 1:54:01for some particular files
- 1:54:02you will not have the adequate
- 1:54:04permissions to actually access so again
- 1:54:06there you are it gives you uh all the
- 1:54:08information you're looking for here and
- 1:54:09we can you know we can grab it to we're
- 1:54:12looking for the the big g for a gigabyte
- 1:54:15so the home directory has quite a
- 1:54:17few files the media directory uh the
- 1:54:20snap swap file user var etc etc
- 1:54:24um so let's take a look at one command
- 1:54:26i'll just go back into my home directory
- 1:54:27and i'll say man eu and we'll hit enter
- 1:54:33let's look for one
- 1:54:35one more command that yes the c command
- 1:54:38which will produce a grand total which i
- 1:54:40wanted to explain so i can say to you
- 1:54:42shc and hit enter and again that gives
- 1:54:45you a total of um
- 1:54:48it gives you a total of all of these
- 1:54:49files
- 1:54:50uh it gives you a total of all of the
- 1:54:52files and directories in this current
- 1:54:54working directory all right so that's
- 1:54:55pretty much how to use the disk usage
- 1:54:57tool
- 1:54:58uh to analyze the current disk usage
- 1:55:00within a particular directory now let's
- 1:55:02talk about the df tool so i can type in
- 1:55:04what is the fn8 enter and this is going
- 1:55:07to report file system disk space usage
- 1:55:10so we were talking about disk usage in a
- 1:55:12particular directory right but now we
- 1:55:14want to know our disk usage in relation
- 1:55:17to the total amount available right so
- 1:55:19we want to know how much we've consumed
- 1:55:21uh
- 1:55:22in our current uh disk where we have our
- 1:55:24home directory or just on all our drives
- 1:55:27right and to do this we type in df so
- 1:55:29again let me just open up the man pages
- 1:55:31so df
- 1:55:33um you can go through all the other
- 1:55:35arguments you want and we'll just quit
- 1:55:38and we'll say df for example
- 1:55:40all right so
- 1:55:41that displays a lot of information here
- 1:55:44that we we really don't need
- 1:55:46we're pretty much looking for our our
- 1:55:48system disks uh only
- 1:55:50and uh we can sort of narrow this down
- 1:55:52first of all by typing in so we can say
- 1:55:54df h is going to be for human readable
- 1:55:57format so again we can say man df and we
- 1:55:59say grep
- 1:56:01we're looking for h
- 1:56:03like so
- 1:56:04and uh
- 1:56:05sorry let me just uh we're looking for h
- 1:56:08here
- 1:56:09so again h is for human readable format
- 1:56:12all right so we can then say dfh
- 1:56:15and we can pretty much hit enter all
- 1:56:18right and what this does now is it's
- 1:56:20going to display
- 1:56:21all of all of your drives for you here
- 1:56:24and you then have the various so for
- 1:56:26example storage device c is the current
- 1:56:28uh file uh the current drive that i have
- 1:56:31my system installed on so it gives you
- 1:56:33uh it sorts it out into the file system
- 1:56:35size and a human readable format so
- 1:56:37gigabyte megabyte etc uh the amount used
- 1:56:40the amount available the usage
- 1:56:42percentage and where it's mounted so
- 1:56:44uh you can see that dev sd storage
- 1:56:47device c1 is mounted is the actual linux
- 1:56:50file system directory i then have
- 1:56:52various other
- 1:56:54external right so let's say i just
- 1:56:56wanted to display the storage devices
- 1:56:58right so i can you then utilize the grep
- 1:57:01tool i can say
- 1:57:02uh i can say grip uh sd and hit enter
- 1:57:06and there we are so it tells me all
- 1:57:07right so um you have sd sdc one and sdd1
- 1:57:12so sdc1
- 1:57:14has a total space of 117 gigabytes um
- 1:57:18and again we can what we can do here is
- 1:57:20uh we yeah
- 1:57:22that's perfectly fine so you have the um
- 1:57:24you have the current usage percentage
- 1:57:26which is 16 percent uh the amount point
- 1:57:28and then for my external drive
- 1:57:30you can see uh this is the total amount
- 1:57:32available uh the amount used the amount
- 1:57:35remaining and the usage percentage and
- 1:57:38where it's mounted on which is the media
- 1:57:40because it's an external drive
- 1:57:42all right so
- 1:57:43that is essentially how to use the df
- 1:57:46tool now we can specify
- 1:57:48additional options to uh to to actually
- 1:57:51only display
- 1:57:52results that we're looking for in
- 1:57:53regards to um to actually file file
- 1:57:56system formats so if you're looking for
- 1:57:58xt for ntfs what we can do is we can say
- 1:58:02uh we can say df h t right so t will
- 1:58:05specify the the file system for format
- 1:58:08so again we can say xt4 and we hit enter
- 1:58:10and that's going to only it's going to
- 1:58:12it's only going to display linux file
- 1:58:14systems and i'm going to enter and you
- 1:58:15can see it tells us sdc1
- 1:58:17and it gives us all the relevant
- 1:58:19information regarding the the size used
- 1:58:22uh used uh data the amount available and
- 1:58:24the usage percentage which is currently
- 1:58:26at 16
- 1:58:27so again that is how to analyze your
- 1:58:29disks uh your disk usage on linux and uh
- 1:58:32how to you know actually deduce how much
- 1:58:35disk space you're using how much is left
- 1:58:37the usage amount of where your various
- 1:58:39disks are mounted on etc etc
- 1:58:45uh in this video going to be talking
- 1:58:46about creating archives so you know
- 1:58:48creating tar files dart or gzip files
- 1:58:51and then extracting them so just how to
- 1:58:53manage and maintain the various archives
- 1:58:55you will be creating now there are many
- 1:58:57reasons to create archives on linux of
- 1:58:58course one of the reasons is it saves
- 1:59:01space uh you can if you're taking
- 1:59:03backups of particular directories uh
- 1:59:05it's great to have an autumn an
- 1:59:07automated script to to actually automate
- 1:59:10the process of archiving the files uh
- 1:59:12that's something that you can take a
- 1:59:13look at with my shell scripting series
- 1:59:16uh the link to that will be in the
- 1:59:17description section if you're interested
- 1:59:19in learning some shell scripting
- 1:59:21uh but let's get started with this video
- 1:59:23so uh the tool we're gonna be using is
- 1:59:25the tar tool now tar is an archiving
- 1:59:27utility as you can see here and again if
- 1:59:30we if we take a look at the man pages
- 1:59:32for this particular tool uh it gives you
- 1:59:34the various options that you can use you
- 1:59:36know in regards to creating uh archives
- 1:59:38comparing them deleting them etc so
- 1:59:41there's a lot of stuff in here
- 1:59:42the purpose of this video is to show you
- 1:59:44uh or to and to explain to you how to
- 1:59:46create uh how to create archives uh how
- 1:59:49they differ in terms of the extension
- 1:59:51and of course how to extract the various
- 1:59:53archives that i
- 1:59:54that you'll come across
- 1:59:56all right so uh on my desktop what i've
- 1:59:59done is um i've created a simple
- 2:00:02directory here uh let me just uh remove
- 2:00:04this uh
- 2:00:06this directory right over here um there
- 2:00:09we are and um so i created a directory
- 2:00:12called file
- 2:00:13and within this directory uh you can see
- 2:00:16that i've created a
- 2:00:18a test.txt file that contains uh the
- 2:00:21contents of the password file so just a
- 2:00:23random file that you know you may want
- 2:00:25to uh you may want to archive or random
- 2:00:28directory that you you may want to
- 2:00:29archive so if i wanted to create a tar
- 2:00:32archive of this file directory what i
- 2:00:34would do is i would say tar and then i
- 2:00:36would specify
- 2:00:38you know some arguments here
- 2:00:40in in regards to what i want star to do
- 2:00:43so first of all i would want dart to
- 2:00:44compress the file
- 2:00:46um and then of course i want uh i wanted
- 2:00:49to compress
- 2:00:50this file so we're specifying the file
- 2:00:52um now after this we specify the name of
- 2:00:55the archive that we want to give it so
- 2:00:57we'll just call it file dot dar this is
- 2:01:00different than a dar.gz
- 2:01:02archive and i'll explain how that
- 2:01:04differs shortly so then we specify the
- 2:01:08the directory that we want to actually
- 2:01:10archive and we hit enter
- 2:01:12and there you are so you can see it
- 2:01:14created uh the tar file for us and of
- 2:01:16course if we type in um file and
- 2:01:19file.tar you can see it tells you that
- 2:01:21this is a tar archive gnut or archive
- 2:01:24here so that means it was it worked
- 2:01:26correctly now um
- 2:01:28let me remove this uh the star archive
- 2:01:30here and if we run the same command that
- 2:01:33we did
- 2:01:34sorry about that let me just um let me
- 2:01:36let's do it one more time so you can say
- 2:01:38tar
- 2:01:39we can also use the uh the v command and
- 2:01:42that will give us some verbose output in
- 2:01:44regards to what files are currently
- 2:01:46being processed uh you know in the
- 2:01:48overall archiving uh process so again we
- 2:01:51can say tar cvf
- 2:01:53and then we say dar we can just say
- 2:01:55file.um
- 2:01:58file.tar and then we specify the
- 2:02:00directory and we hit enter and you can
- 2:02:02see it then gives you a the post output
- 2:02:05and we get the dar the file.tar archive
- 2:02:07here so
- 2:02:09if we want to extract a tar archive
- 2:02:12that's a very very simple thing to do
- 2:02:14all we need to do is we say tar
- 2:02:17guitar
- 2:02:19and now that we want to extract it we
- 2:02:21use the x command uh by the way you can
- 2:02:23you can negate or not use the iphone
- 2:02:26here but i personally like using the
- 2:02:28iphone just so that i understand where
- 2:02:30my syntax is going so i can say extract
- 2:02:33and we can verbose you know we can have
- 2:02:35some verbose output
- 2:02:37and we say extract
- 2:02:39the file and then we specify the file so
- 2:02:42we say file.tar and then we can provide
- 2:02:46an output for it or you can just hit
- 2:02:47enter and it you know it extracts it for
- 2:02:50us and because we already have the file
- 2:02:52here uh it will essentially overwrite
- 2:02:54the
- 2:02:55uh the newer files if the if there are
- 2:02:57any new changes etc so we can uh
- 2:03:00we can remove this directory and do that
- 2:03:02one more time here so we can say star
- 2:03:06xvf
- 2:03:07file dot r and we hit enter now if we
- 2:03:10list this you can see that we have the
- 2:03:12file directory here all right excellent
- 2:03:15so that's uh working with star files and
- 2:03:17that's you know a standard tar
- 2:03:20a guitar file here uh now let's talk
- 2:03:22about gzip files so if i say what is
- 2:03:26gzip and uh you can do this with star
- 2:03:28again uh it's a very very simple you
- 2:03:31that's the preferred way of doing it so
- 2:03:33uh let's take the um
- 2:03:36the same or we can just remove the file
- 2:03:38dot our here so let's take the same
- 2:03:41file directory here and if we want to
- 2:03:44now use the or compress it
- 2:03:47into a third or gzip file
- 2:03:50using gzip of course then we would say
- 2:03:53tar
- 2:03:55uh now we are compressing it so we say c
- 2:03:57z uh f or c z c v z f or c z v f
- 2:04:02whatever you want to use in our case we
- 2:04:04we don't want to work or we want to
- 2:04:06display uh you know some the verbose
- 2:04:09output so we can just use the czf
- 2:04:12and then we specify um
- 2:04:14we specify the name so we're going to
- 2:04:16say file.tar
- 2:04:18register and then we specify the
- 2:04:20directory that we want to archive or
- 2:04:22compress and we hit enter
- 2:04:24and you can now see that we created the
- 2:04:27gz file here so if we type in file and
- 2:04:29then you know just to find out what
- 2:04:31we're dealing with the ui tells you
- 2:04:33we're dealing with a gzip compressed
- 2:04:35data
- 2:04:37so again we can extract it really simply
- 2:04:39by saying dar
- 2:04:41um dar x z f
- 2:04:44x z f and then we say file
- 2:04:46dot r g z but uh before we do this uh
- 2:04:49let's remove uh let's remove the actual
- 2:04:54file directory here so we say term
- 2:04:57x zf and then we say
- 2:04:59file.gz and we hit enter and it'll then
- 2:05:03give us the file directory which is
- 2:05:05right over here so again we can cut the
- 2:05:06contents just to show you that it's
- 2:05:08worked just fine
- 2:05:10um
- 2:05:11you can see that it's the entire content
- 2:05:13of the password file so that's pretty
- 2:05:15much how to work with archives i'm not
- 2:05:17going to be covering the various other
- 2:05:18utilities that you can use so for
- 2:05:20example bc2 which is again very simple
- 2:05:23use uh in regards to using bzip2 for
- 2:05:26compression i wanted to show you how to
- 2:05:28use the tar uh guitar utility for
- 2:05:31archiving files archiving them and then
- 2:05:33of course extracting them so it's the
- 2:05:34most reliable and consistent way of
- 2:05:37working with archives on linux and it's
- 2:05:39great for you know taking backups and
- 2:05:41with the help of a shell script you can
- 2:05:43easily automate the process
- 2:05:48in this video i'm going to be talking
- 2:05:50about uh you know adding managing users
- 2:05:52and groups and then in the follow up
- 2:05:54videos we'll be talking about user
- 2:05:56security and sort of securing the
- 2:05:58authentication uh section or area of of
- 2:06:01linux so let's get started now i just
- 2:06:03want to give you a bit of a premise
- 2:06:05i'm currently running a um currently
- 2:06:07logged in by ssh onto one of my uh linux
- 2:06:10servers and the reason being is as we
- 2:06:12move on into this series to to the end
- 2:06:14or to the completion uh i'll be covering
- 2:06:16security uh you know various security
- 2:06:19aspects that we will require a lot of
- 2:06:20testing so again uh that's primarily the
- 2:06:22reason so let's get started now by
- 2:06:24default
- 2:06:25uh you can see that i've created another
- 2:06:27user called admin
- 2:06:29and i'm currently running ubuntu server
- 2:06:31so
- 2:06:32what's going to happen is uh it is
- 2:06:34recommended never to only be using the
- 2:06:36root user and that you need to have
- 2:06:38another user in which you can then uh
- 2:06:40start you know applying various
- 2:06:42permissions to so by default on ubuntu
- 2:06:45uh when working with users again is a
- 2:06:48very very simple syntax in regards to
- 2:06:50adding them so what we're going to do is
- 2:06:51we're just going to create a user here
- 2:06:53we're just going to say user add and you
- 2:06:55can take a look at all the uh the
- 2:06:57various options you can use when
- 2:06:59specifying a user
- 2:07:00so if i just say uh user add and i hit
- 2:07:04enter you can see it doesn't give me any
- 2:07:06prompt but if i say user add alexis and
- 2:07:09i hit enter it will give me
- 2:07:11an error with the um
- 2:07:13it will give me an error with with a
- 2:07:15lack of permissions now i did this uh
- 2:07:17you know deliberately so that i can
- 2:07:19demonstrate uh how to use groups before
- 2:07:21we actually take a look at that so i'll
- 2:07:23just switch i'll just switch into the
- 2:07:25root user here
- 2:07:26and we'll go into my home directory and
- 2:07:28we'll just say v sudo here uh so we'll
- 2:07:31say v sudo and
- 2:07:33what we want to do now
- 2:07:35is we have the user admin uh but we want
- 2:07:38to
- 2:07:39we want to actually have this user
- 2:07:42[Music]
- 2:07:43we want to add this user admin into the
- 2:07:45sudo group which will essentially allow
- 2:07:48members of the group to execute any
- 2:07:49command now i can do that or i can also
- 2:07:51add them to the admin to the admin group
- 2:07:54which which would be better
- 2:07:56um so again we can sort of customize the
- 2:07:59various uh the various commands that we
- 2:08:01can specify and i'll get to this in a
- 2:08:02second so
- 2:08:03uh what we want to do now is i'll just
- 2:08:06exit and i'll say user mod
- 2:08:08and i'll say user mod a
- 2:08:11g
- 2:08:12ad group and then we say
- 2:08:14admin and the user admin and we hit
- 2:08:17enter and that's going to add the user
- 2:08:19admin into the group admin so you
- 2:08:21specify the group first and then the
- 2:08:22user there that might might seem a bit
- 2:08:25confusing but if i just say groups uh
- 2:08:27groups admin you can see that it tells
- 2:08:30me that the user admin is in the group
- 2:08:32admin all right so if we go back into
- 2:08:33the user admin here
- 2:08:35you can see it tells you to run a
- 2:08:36command as administrator use
- 2:08:39user root use the sudo command so again
- 2:08:41we now have permissions to do whatever
- 2:08:42we want so if we go back here
- 2:08:45we can say sudo user add
- 2:08:48user add and
- 2:08:49again that will give us the same option
- 2:08:51so if we say user ad alexis
- 2:08:53uh it's going to add the user now the
- 2:08:55problem with this if i display the
- 2:08:57password file
- 2:08:58you can see that the user alexis by
- 2:09:00default will be given a home directory
- 2:09:02that's perfectly fine and the diff the
- 2:09:04default shell will be set to the bond
- 2:09:06shell so what i want to do is let me
- 2:09:08show you how to remove a user so to
- 2:09:10remove a user we say user dell and then
- 2:09:12if we want to remove their home
- 2:09:13directory
- 2:09:14we say uh r or we use the recursive
- 2:09:17command and then we specify the user so
- 2:09:19we can say alexis
- 2:09:20and again we need to use um
- 2:09:24the
- 2:09:24we need to use the sudo command here
- 2:09:26because we require root privileges so
- 2:09:28it's going to remove
- 2:09:31it's going to remove the user so if we
- 2:09:32just display the
- 2:09:34uh the contents of the home directory we
- 2:09:36can see that the only user directories
- 2:09:37we have are for the user admin all right
- 2:09:39so now that i've explained that let me
- 2:09:40show you the correct syntax for adding a
- 2:09:43user here so again i can just say user
- 2:09:45ad now
- 2:09:47uh in regards to the actual commands you
- 2:09:49can use you can take a look at the man
- 2:09:51pages uh sorry um
- 2:09:53user ad and you can take a look at all
- 2:09:56of these options and there's a quite
- 2:09:58extensive options you can use in regards
- 2:10:00to creating user but in our case we want
- 2:10:03to say user ad and um
- 2:10:05the first thing we want to do is we want
- 2:10:07to make sure that this user has a home
- 2:10:09directory with its username appended so
- 2:10:12we can say m
- 2:10:13and then we can add a comment so again
- 2:10:15this can describe uh you know something
- 2:10:17about the account and what it's used for
- 2:10:19we can just say alexis and we can then
- 2:10:21specify the shell this is very important
- 2:10:23if you want a uh
- 2:10:25if you want the user account to to use a
- 2:10:27custom shell
- 2:10:29in our case we'll just say bin bash and
- 2:10:31then we specify the name of the user
- 2:10:33account or the username and we hit enter
- 2:10:35all right so again it tells us we need
- 2:10:36sudo privileges so let's add that and
- 2:10:39i'll just hit enter and the the user is
- 2:10:41added now this user doesn't have a
- 2:10:43password yet so to add a password for a
- 2:10:46user we can say we can use the password
- 2:10:48command all right and again it requires
- 2:10:50root
- 2:10:50privileges
- 2:10:52so if i wanted to change the password
- 2:10:54for the admin account or for the current
- 2:10:56account that i'm using i simply type in
- 2:10:57password and it'll say changing password
- 2:11:00for admin and it'll ask me for my
- 2:11:01current password
- 2:11:02i'll enter a new password here
- 2:11:05and the password isn't changed so i just
- 2:11:07wanted to demonstrate this so again i
- 2:11:09can just say let me just change the
- 2:11:11password here
- 2:11:12and i'll just change it to something
- 2:11:15different and there we are so the
- 2:11:16password for the admin user has been
- 2:11:18updated successfully
- 2:11:20if i wanted to change the password for
- 2:11:22another user i would say password alexis
- 2:11:24and hit enter
- 2:11:26so again we we can use the sudo
- 2:11:28privileges because we're now modifying
- 2:11:34and
- 2:11:36sorry about this let's just add um
- 2:11:40and there we are so now we've added the
- 2:11:42password for the user lexis so i can
- 2:11:44directly switch uh into this user
- 2:11:47account and i'll show you something
- 2:11:49interesting here so i can say sudo
- 2:11:51alexis
- 2:11:52um and i switch into it and um
- 2:11:56there we are so now if i try and do
- 2:11:57something like sudo apt update here
- 2:12:00uh it'll ask me for the user for the
- 2:12:02password and um well i think i entered
- 2:12:04the correct the incorrect password here
- 2:12:06so if i enter the correct password you
- 2:12:08can see it's going to tell us that
- 2:12:09alexis is not in the sudoes file this
- 2:12:11incident will be reported all right so
- 2:12:14that's um that's essentially telling us
- 2:12:16we don't have adequate adequate
- 2:12:18permission so if we go back into the
- 2:12:19admin account
- 2:12:20um
- 2:12:22we can now play around with the sudoers
- 2:12:25file so again we'll say sudo vsudo and
- 2:12:28we'll hit enter and let's talk about now
- 2:12:30adding permissions and before we
- 2:12:32actually take a look at groups
- 2:12:34right so typically with ubuntu uh you
- 2:12:37can see that it gives you all of these
- 2:12:38various groups you know right out of the
- 2:12:40bat and you you can specify specific
- 2:12:43user privileges
- 2:12:45under this right over here so you can
- 2:12:46see for the root user um
- 2:12:49it can run it from all uh sessions
- 2:12:51irregardless of whether it's a tty uh or
- 2:12:54a remote session
- 2:12:55uh and then you know for all users in
- 2:12:58all groups and it can run all commands
- 2:12:59so again again just say alexis and let's
- 2:13:02say all or you know i can just simply
- 2:13:04say
- 2:13:05uh all sorry that's always going to be
- 2:13:07equal to all and so that's pretty much
- 2:13:10uh all users um
- 2:13:13and then in regards to the command
- 2:13:15specification which you specify here so
- 2:13:17this user can actually run all
- 2:13:20permissions or i can limit it to you
- 2:13:22know certain permissions if i want to
- 2:13:24right now again
- 2:13:26this will pretty much
- 2:13:29this this will pretty much allow me to
- 2:13:32to actually run uh specific commands so
- 2:13:35for example if i wanted to only allow
- 2:13:37this user to say for example user bin
- 2:13:40apt
- 2:13:41get
- 2:13:42for example um so what i'll do is i'll
- 2:13:44just save this file and we'll go back
- 2:13:46into the user lexis here
- 2:13:48um and we'll say
- 2:13:51and then we say sudo apt get and many of
- 2:13:54you might be catching on and you'll see
- 2:13:56what happens here
- 2:13:58so you can see that that works now and
- 2:14:01we're able to run only that command with
- 2:14:02root privileges
- 2:14:04so we'll just wait for this to actually
- 2:14:06update the repositories
- 2:14:08let's try and run another command with
- 2:14:10root privileges and i'll show you what
- 2:14:11will happen here so
- 2:14:13again my apologies my internet is
- 2:14:16really not that quick um so we'll just
- 2:14:18wait for this to complete
- 2:14:21and um
- 2:14:22so there we are
- 2:14:23got the repos and you know i can pretty
- 2:14:25much install software and i can use the
- 2:14:28app to get a utility so if i say sudo
- 2:14:31um let's say vim
- 2:14:33hc
- 2:14:34ssh sshd config if we open this you can
- 2:14:38see we're not allowed to do this so if
- 2:14:40we go back into the admin user
- 2:14:42you can see now this is a great way of
- 2:14:45you know specifying um specifying
- 2:14:48permissions for users so
- 2:14:50additionally what i can do is i can use
- 2:14:52groups right now
- 2:14:54i have the user alexis here and let me
- 2:14:56just comment this if i say all commands
- 2:14:59uh that means it can run all commands
- 2:15:01here without any uh without any
- 2:15:03restrictions so we then have groups
- 2:15:05right now groups
- 2:15:06allow
- 2:15:08groups essentially allow users to allows
- 2:15:10you to group users you know based on
- 2:15:12their particular role or
- 2:15:14responsibilities now in this case we
- 2:15:15have two groups we have admin and sudo
- 2:15:18and they essentially allow users to
- 2:15:19execute all commands with root
- 2:15:21privileges here
- 2:15:23um so
- 2:15:24uh what we can do is uh we can create
- 2:15:27another group here so uh
- 2:15:30we can just exit out of this uh well
- 2:15:32actually no
- 2:15:33we can just modify this one more time
- 2:15:36because uh i want to actually comment
- 2:15:38this in regards to the permissions here
- 2:15:40so we'll just exit and let's talk about
- 2:15:42groups all right so let's talk about
- 2:15:44groups in linux now groups are a great
- 2:15:47way of sort of collectively applying
- 2:15:49permissions to you know groups of users
- 2:15:52that you know you may want to have uh
- 2:15:54you know the same privileges uh or
- 2:15:57permissions uh and you know it's a great
- 2:15:59way of
- 2:16:00blanketing
- 2:16:01various permissions on different users
- 2:16:03and a great way of of course segregating
- 2:16:05roles and duties within a system so it's
- 2:16:08a great way of actually actively
- 2:16:11uh
- 2:16:12actively approaching uh the whole idea
- 2:16:15of segregation of roles and duties so
- 2:16:18let's talk about uh creating groups uh
- 2:16:20deleting groups and of course working
- 2:16:22with permissions with groups so we're
- 2:16:24going to follow this the same scenario
- 2:16:26we have the admin user uh and of course
- 2:16:29we then have the user alexis here so the
- 2:16:31user lexis currently is not part of any
- 2:16:34any any particular group so again it's a
- 2:16:36standard user account that doesn't have
- 2:16:38root privileges and is simply just
- 2:16:40allowed to operate within those
- 2:16:42constraints now if i wanted to add a
- 2:16:44group here i would say group add right
- 2:16:47and then i'll specify the name of the
- 2:16:48group so let's say we want to add the
- 2:16:51the user alexis to a group called
- 2:16:54developers
- 2:16:55right so we're going to say group add
- 2:16:57developers let me just prepend this with
- 2:16:59sudo because we do need root privileges
- 2:17:02to create new groups and we're going to
- 2:17:03hit enter all right so now we have the
- 2:17:06group created so if we want to display
- 2:17:08groups for a particular user or the
- 2:17:10groups that a user is in again we use
- 2:17:12groups and then the name of the user
- 2:17:15and you it tells you that alexis
- 2:17:16currently is is in its own group we can
- 2:17:19view all the groups on the system by
- 2:17:21visiting the or cutting or displaying
- 2:17:24the contents of the group a file if we
- 2:17:27hit enter you can see that we have the
- 2:17:29various groups and you can see we have
- 2:17:31all the system accounts as well as
- 2:17:33pretty much they're going to be in their
- 2:17:34own group unless
- 2:17:36uh specified otherwise
- 2:17:40um so let's uh let what we're gonna do
- 2:17:43is we're going to add the user alexis
- 2:17:46into this developers group and then i'll
- 2:17:47show you how permissions can sort of be
- 2:17:50uh be manipulated that way so we're
- 2:17:52gonna say user mod and we're gonna say
- 2:17:54we're gonna append append
- 2:17:56the user lexis and we're going to say
- 2:17:58the group by the way you can use a
- 2:18:00lowercase g here the lowercase g
- 2:18:02primarily means you need to specify the
- 2:18:04group ids in our case we'll just use the
- 2:18:07capital g because we know the names of
- 2:18:09head
- 2:18:10so we'll say developers and we want to
- 2:18:12add the user alexis to the group
- 2:18:14developers
- 2:18:16i believe we need root privileges for
- 2:18:18this so i'm going to enter and that
- 2:18:20should do it all right so now if i say
- 2:18:21groups alexis you can see that alex is
- 2:18:24going to be part of its own group and
- 2:18:26uh
- 2:18:27and the developers group now when we
- 2:18:29talk about having its own group that
- 2:18:31simply refers to you know user specific
- 2:18:33privilege specifications so again if we
- 2:18:35visit the uh the v sudo uh utility uh to
- 2:18:39modify the sudoes file
- 2:18:42you can see that we talked about user
- 2:18:44user privilege specification and we had
- 2:18:46actually added a uh you know some
- 2:18:49privileged specifications for the user
- 2:18:52alexis where
- 2:18:54you know we can access it from all hosts
- 2:18:56and we've specified all users however
- 2:18:58not all groups so this essentially will
- 2:19:01restrict
- 2:19:03uh this will restrict
- 2:19:05the user alexis uh
- 2:19:07and it will essentially allow him to run
- 2:19:09uh you know the apt-get utility with
- 2:19:12root privileges here
- 2:19:14however
- 2:19:16that's one way of doing it so if if i
- 2:19:18use this if i use this this same syntax
- 2:19:22uh then i can also you know allow it to
- 2:19:24run all commands
- 2:19:26and you know i can also specify the uh
- 2:19:28the exp explicitly to refuse
- 2:19:32to refuse it to use the root uh to
- 2:19:35actually have pseudo privileges so it
- 2:19:37will only run this command
- 2:19:39uh and and you know so on and so forth
- 2:19:41so i can do that actively if i wanted to
- 2:19:43however i don't want to so what we'll do
- 2:19:45is let's just test this out to see that
- 2:19:47it works and of course you can change
- 2:19:49this to whatever
- 2:19:50whatever command that will require you
- 2:19:52know root privileges so we can just use
- 2:19:54app to get here and i'll save this now v
- 2:19:57sudo when saving and exec
- 2:19:59and exiting if you do have a syntax
- 2:20:01error it will tell you so again if we go
- 2:20:03here and we say
- 2:20:05let's uh let let's actually mess around
- 2:20:07with the syntax here so again i can just
- 2:20:09say add a few uh commas there you can
- 2:20:13see that it tells us uh in the etsy
- 2:20:15pseudo as well as syntax error near line
- 2:20:1721 and we can use the e command to edit
- 2:20:20it so again that's a great uh that's the
- 2:20:22great uh reason for using these the uh
- 2:20:26the v sudo utility it actually points
- 2:20:28out logical and uh and syntax errors
- 2:20:32so we'll save this now and we'll exit
- 2:20:35and what we'll do is we'll now switch
- 2:20:37into the user lexis and um
- 2:20:40i'll go here and you can see that now if
- 2:20:42i type in apt-get update you can see
- 2:20:44that we can run this command but it
- 2:20:46still requires administrative privileges
- 2:20:48or root privileges so if we pre-pend it
- 2:20:51with root or sorry sudo
- 2:20:54if we say sudo and we hit up and we just
- 2:20:56enter the password you can see that
- 2:20:58we're able to run the command however if
- 2:21:01we wanted to display the um we say cat
- 2:21:04etsy shadow
- 2:21:06uh
- 2:21:08cat etsy shadow is going to tell you
- 2:21:10these alexis is not allowed to execute
- 2:21:12cat etsy shadow with you know root
- 2:21:15privileges so again we can say cat
- 2:21:17hc password here that works because it
- 2:21:20doesn't require root privileges and we
- 2:21:22are pretty much allowed to view the
- 2:21:24contents of this file
- 2:21:26all right so that's how to apply
- 2:21:27permissions based on a user all right
- 2:21:30now i can also change this up and we can
- 2:21:32use the the example of the group here so
- 2:21:35we can just go back into the user admin
- 2:21:38and
- 2:21:38just enter the password here and again
- 2:21:40we'll say sudo
- 2:21:42vsudo and we'll get into this so we'll
- 2:21:45comment this uh you know user privilege
- 2:21:47specification entry and we can enter our
- 2:21:49group anywhere here we can just add a
- 2:21:51comment if we wanted to
- 2:21:56specification
- 2:21:58um developer group
- 2:22:00we can just say developer group and then
- 2:22:02we say
- 2:22:03when adding a group we prepend it with
- 2:22:05the the modulus sign and then we say we
- 2:22:09specify the name of the group so we say
- 2:22:11developers and then after this we
- 2:22:13specify the permissions here so again we
- 2:22:15can say all
- 2:22:16all hosts and then we'll say all users
- 2:22:20of all groups that's because we need a
- 2:22:23sudo that's very important we need the
- 2:22:26ability to access all the groups so
- 2:22:28again we can all we can always limit it
- 2:22:30to
- 2:22:31uh all users and then the admin group if
- 2:22:34we wanted to but again we say all
- 2:22:38and then instead of all commands we say
- 2:22:40user bin
- 2:22:43we can say apt user pin
- 2:22:46sorry user bin apt get update uh sorry
- 2:22:49apt-get sorry not update
- 2:22:52um so we can save this and if we exit
- 2:22:54you can see we have no syntax errors so
- 2:22:56again back to alexis here
- 2:22:59and i will enter the password
- 2:23:01and uh yeah so now we can say sudo apt
- 2:23:05uh
- 2:23:06get update and that works fine uh for
- 2:23:09some reason
- 2:23:11uh not allowed to execute uh let me just
- 2:23:14check this right now uh yeah it's part
- 2:23:16of the developers group uh let me just
- 2:23:19go back into the admin group here oh
- 2:23:21sorry into the admin user
- 2:23:23and uh let's see what the issue is
- 2:23:26what's the issue is with the
- 2:23:27specification of uh
- 2:23:30of permissions here um
- 2:23:33so
- 2:23:35what i'll do is um let's see what can be
- 2:23:39this shouldn't be causing any issues uh
- 2:23:42let's try apt and let's just see whether
- 2:23:44this works i'll just say
- 2:23:54i have to update that that works fine
- 2:23:57um i believe you need to add yeah you
- 2:23:59need to separate the commands and it
- 2:24:02would be wise to use command command
- 2:24:04aliases so yeah i i simply forgot about
- 2:24:06that sorry about that guys um so so that
- 2:24:08will work fine so again if we say sudo
- 2:24:11cat etsy shadow
- 2:24:13for example
- 2:24:14yeah because we wanted to view it you
- 2:24:16can see it again it restricts us to
- 2:24:18running uh only the apt update utility
- 2:24:20or running the app utility here so that
- 2:24:23is how to you know sort of segregate
- 2:24:25permissions based on a user whether you
- 2:24:26want to specify the permissions you know
- 2:24:28on a user to use a basis
- 2:24:30or how to specify the permissions on a
- 2:24:32you know in in regards to adding users
- 2:24:35to a group and then applying them that
- 2:24:36way sort of blanketing the users that
- 2:24:39way so again it's all about
- 2:24:41you know what philosophy you are you
- 2:24:42adapt to and if you're a system
- 2:24:44administrator it'll also depend on the
- 2:24:46use case and the use you usage scenario
- 2:24:49in which your server is being deployed
- 2:24:52in
- 2:24:56we're going to be talking about
- 2:24:57networking uh in the command line all
- 2:24:59right so let's get started now
- 2:25:01um if you pretty much watched any of my
- 2:25:04older videos where we were working with
- 2:25:06networking within the linux terminal you
- 2:25:08know that i would typically use the
- 2:25:10ifconfig utility however
- 2:25:13you know the standard has changed now
- 2:25:15and what we have to use or what is the
- 2:25:17preferred method of getting information
- 2:25:20and interacting with various network
- 2:25:22interfaces is by using the ip command
- 2:25:24right so the ip
- 2:25:26utility allows you to you know show
- 2:25:28manipulate routing network devices
- 2:25:30interfaces and tunnels etc
- 2:25:32all right so let's get started by first
- 2:25:35of all um understanding how to display
- 2:25:37your current uh routing table so again
- 2:25:39we can do that by typing in ip route
- 2:25:42show and that's very simple so ip route
- 2:25:44show and this will show you your current
- 2:25:46uh routing table so you can see this is
- 2:25:48my uh this is uh this is currently my
- 2:25:51router's ip address or my gateway uh
- 2:25:53this is my interface name here and this
- 2:25:56is the source ip which is my ip address
- 2:25:58so that gives you an idea of uh of your
- 2:26:00ip routing table uh currently
- 2:26:03now again you can take a look at uh we
- 2:26:06can grip route here and uh in the man
- 2:26:09pages and you can take a look at all the
- 2:26:10options you have available for you um so
- 2:26:13you can pretty much change the route if
- 2:26:15you want to do but of course that's
- 2:26:16beyond the scope of this tutorial i'm
- 2:26:18simply showing you how to find
- 2:26:20information that's very useful if you
- 2:26:21want to display your current ip address
- 2:26:23we type in
- 2:26:25ipaddr and we hit enter and this gives
- 2:26:28you your two interfaces so we have local
- 2:26:31this is a loop back so this is you know
- 2:26:33for your local host
- 2:26:35uh and you then have your ethernet in my
- 2:26:37case my ethernet adapter which has the
- 2:26:39interface name enp2so
- 2:26:42you can see that it has an ip of
- 2:26:45192.168.1.1
- 2:26:48and you have the uh the entire uh
- 2:26:51the entire network range there
- 2:26:53um you also have your your ipv6 ip
- 2:26:56address here that is required and of
- 2:26:58course you have your mac address so very
- 2:27:00similar to ifconfig um so if we
- 2:27:03if we take a look at ifconfig which is a
- 2:27:06perfectly great uh tool that you can use
- 2:27:08and so you know you can use it if i type
- 2:27:10in i have config
- 2:27:12we can take a look at the man pages here
- 2:27:14just so i can show you the flexibility
- 2:27:16so again uh you can play around with all
- 2:27:18the options that are available but
- 2:27:20pretty much the simple way of going
- 2:27:22about it would be to simply display your
- 2:27:24current um so if i say ifconfig
- 2:27:28and i'm only looking for my
- 2:27:30i can say inets if i'm only looking for
- 2:27:32my ipv4 address or my inet addresses you
- 2:27:35can see that i can easily just print
- 2:27:37them out and i also have my net mask so
- 2:27:39a very organized way of taking a look at
- 2:27:42your your interfaces and your ip
- 2:27:44addresses as well
- 2:27:46right now i'm still to make a video on
- 2:27:48on managing services
- 2:27:51and processes with linux but uh
- 2:27:53essentially working with your network
- 2:27:55manager we can also take a look at dhcp
- 2:27:58because that would be quite important so
- 2:28:00if you are running this on wi-fi or you
- 2:28:02are using a wireless adapter or even an
- 2:28:04ethernet where you don't have static ip
- 2:28:08distribution
- 2:28:10or resolution what we can do is if we
- 2:28:12say what is dhclient um and we can just
- 2:28:15hit enter you can see that uh if we type
- 2:28:17in dh client and we hit enter you can
- 2:28:19see that it doesn't give us any
- 2:28:22any options here so if we take a look at
- 2:28:23the options that we available to use we
- 2:28:26can pretty much um
- 2:28:28let's take a look at the man pages
- 2:28:29because this is a bit better way of
- 2:28:32actually utilizing it so again we can
- 2:28:34use the dhcp v4 protocol to obtain
- 2:28:38a new ipv4 address but in my case i i
- 2:28:41have my ip statically uh assigned here
- 2:28:43so that would not be a wise thing to do
- 2:28:46but if i wanted to restart my network
- 2:28:47manager uh again i'll be making a an
- 2:28:50individual video on this so you don't
- 2:28:52have to worry so you can use sudo
- 2:28:53service
- 2:28:54network
- 2:28:57network manager
- 2:28:58um
- 2:29:00restart and i can hit enter or i can use
- 2:29:02system d so i can say sudo system
- 2:29:05control
- 2:29:06uh we can say restart we say network
- 2:29:09let me just see network we're looking
- 2:29:11for the network manager here so if i let
- 2:29:13me just tab and see what we have we're
- 2:29:16looking for the network manager.service
- 2:29:18which is right over here so i can
- 2:29:20execute this and that will essentially
- 2:29:21restart it now again as i said if you're
- 2:29:23not familiar with processes don't worry
- 2:29:25we'll be covering it in the next set of
- 2:29:27videos as we wind up this series
- 2:29:29but that's pretty much how to restart
- 2:29:32your network adapter if you're having
- 2:29:33any issues and you can sort of work with
- 2:29:35that now let's talk about netstat
- 2:29:38because again that's quite an important
- 2:29:40tool and i haven't i have a an
- 2:29:42independent video on how to use netstat
- 2:29:44if you are interested in it so again we
- 2:29:46can say netstat and we hit enter say
- 2:29:49print network connections routing tables
- 2:29:51uh et cetera et cetera so i'll just go
- 2:29:53i'll just go over the most common
- 2:29:55options you can use and this essentially
- 2:29:56allows you to understand what uh what
- 2:29:59services ports uh you have running
- 2:30:01listening and are you are connected to
- 2:30:03so for example
- 2:30:04if i wanted to display the route i would
- 2:30:06say net stat and i would say r and that
- 2:30:09gives me my routing table so we have the
- 2:30:11destination uh the gateway the gen mask
- 2:30:14flags and the interface here
- 2:30:17so in all cases we're working with my uh
- 2:30:18with my ethernet interface here so you
- 2:30:21can see that
- 2:30:23for the default gateway uh we have it
- 2:30:25right over here the destination and of
- 2:30:27course the gen mask so again you can get
- 2:30:29very good information from this now if
- 2:30:31we wanted to take a look at all the tcp
- 2:30:33connections that we have we can say net
- 2:30:36stat and we use t and that gives us all
- 2:30:39the tcp connections on uh that we are
- 2:30:41currently connected to or listening
- 2:30:43for on our system so you can see that uh
- 2:30:47we have the protocol which is very
- 2:30:48important this is this is uh uniquely
- 2:30:51going to be tcp
- 2:30:52uh the local address the foreign address
- 2:30:54the port it gives you and the state
- 2:30:56which i'll get to in a second
- 2:30:58um so you can pretty you can also grab
- 2:31:00information from this so again you can
- 2:31:02say grip and if i had the ssh
- 2:31:04uh port open uh i would hit i'll say
- 2:31:07grep 22 for example and uh you pretty
- 2:31:10much gives you results based on
- 2:31:12the actual string of characters in this
- 2:31:14case it's not giving us anything new but
- 2:31:16if all to say
- 2:31:17um let's say
- 2:31:19sudo
- 2:31:21sudo
- 2:31:22service ssh
- 2:31:24start now hit enter
- 2:31:27and if we try and grip this now uh we
- 2:31:29don't get anything so let's uh let's
- 2:31:31take a look at how to find a listening
- 2:31:33ports so or listening socket so we can
- 2:31:36say netstat
- 2:31:38l and we hit enter and you can see
- 2:31:40there's quite a bit of listening uh of
- 2:31:42stock of sockets that are currently
- 2:31:44listening for
- 2:31:46uh
- 2:31:46for actual connection so in our case you
- 2:31:49can see we have the ssh port here
- 2:31:51and we can pretty much grip
- 2:31:54with these particular services um and
- 2:31:56you can sort of work with that if you
- 2:31:58want to
- 2:31:59uh talking about udp only we can again
- 2:32:02that's very simple so that's that if i
- 2:32:04wanted listening tcp connections i would
- 2:32:07say um for example lt and hit enter and
- 2:32:10that will only display the listening tcp
- 2:32:12connections if i wanted listening udp
- 2:32:14connections i would
- 2:32:16type in lu and again that gives us all
- 2:32:18the listening udp connections
- 2:32:21um if we want to display the the actual
- 2:32:24processor processes and the process ids
- 2:32:27we can say netstat
- 2:32:29p and we hit enter
- 2:32:31and what we can do is we can say ltp
- 2:32:34so ltp and we're looking for grip ssh
- 2:32:38and we hit enter it again tells you uh
- 2:32:40that we have ssh running in or you can
- 2:32:42go through this all over again so let me
- 2:32:44just clear this out
- 2:32:46so if we display the results here um you
- 2:32:48can see that
- 2:32:50it gives you all the information that
- 2:32:52you're looking for uh so if we get rid
- 2:32:55of this and we also have p it gives you
- 2:32:57the various process ids
- 2:32:59uh so if we let's just take a look at
- 2:33:01the table right at the top here that
- 2:33:03pretty much prints it all
- 2:33:05uh you can see we have the pid right
- 2:33:07over here and we can sort of grip
- 2:33:09through that if we wanted to
- 2:33:12so that's uh using um netdiscover
- 2:33:15netstat uh we're not talking about net
- 2:33:17discover yet but again you can check out
- 2:33:19our independent video on that and allows
- 2:33:22you to check various connections that
- 2:33:23you have open and you know running
- 2:33:25either established or listening on your
- 2:33:27system they could be for both a tcp and
- 2:33:29udp
- 2:33:30now let's talk about net discover now
- 2:33:33net discover does not come pre-installed
- 2:33:35with any linux distribution as far as
- 2:33:37i'm concerned apart from the pen testing
- 2:33:39uh or offensive distribution so again we
- 2:33:42can simply just say what is netstat
- 2:33:45and you can pretty much um well no not
- 2:33:47nets that net discover
- 2:33:51um i believe this is uh its cover like
- 2:33:54so and we hit enter and it's an active
- 2:33:56passive uh erp reconnaissance tool
- 2:34:00and so what this means is it allows you
- 2:34:02to essentially scan your network for uh
- 2:34:04for other devices or hosts that are
- 2:34:06currently connected to your network
- 2:34:08whether they be uh wi-fi enabled devices
- 2:34:10or connected to your uh to your network
- 2:34:13via ethernet or to your switch um so
- 2:34:15again to install it you can use any of
- 2:34:17the package managers you're comfortable
- 2:34:19with and we simply type in net discover
- 2:34:22and we hit enter so do have to get
- 2:34:24installed sorry
- 2:34:26and we hit enter and you can see already
- 2:34:28have it installed so using it requires
- 2:34:30root privileges so we say sudo
- 2:34:34net discover
- 2:34:36and then we specify the interface that
- 2:34:38we want to use so we can see enp2s0
- 2:34:42and hit enter and as you can see it will
- 2:34:44start scanning and it's doing this
- 2:34:45through arp or the address resolution
- 2:34:47protocol so arp
- 2:34:50request and response packets so again
- 2:34:52it's sending various arp requests
- 2:34:54to you know all ips on the network and
- 2:34:56then the responses give us the results
- 2:34:58that uh that actually prove that whether
- 2:35:01we have a device or not so you can see
- 2:35:04i currently have the my router which is
- 2:35:06running uh this is the default gateway
- 2:35:09and then i also have another device
- 2:35:11running here
- 2:35:12let's see if we have any other devices
- 2:35:15and we'll just wait for it to continue
- 2:35:16scanning
- 2:35:18so i'll just wait for this to continue
- 2:35:20scanning i think i have multiple other
- 2:35:22devices this is pretty much going to be
- 2:35:24my windows device if i bring up
- 2:35:27a mobile device here let's see if that
- 2:35:29actually
- 2:35:30comes up
- 2:35:32and i'll try and load up a website here
- 2:35:34i actually don't have my phone on me but
- 2:35:36in any case this essentially gives you
- 2:35:39all
- 2:35:40it essentially gives you all devices on
- 2:35:42your network and that's a great way of
- 2:35:44monitoring your network and viewing what
- 2:35:46devices you have so again it gives you
- 2:35:48the ip their mac address and their mac
- 2:35:50vendor so again it gives you an
- 2:35:52information about what device you're
- 2:35:53dealing with so in this case tp-link and
- 2:35:56then hot high precision which is pretty
- 2:35:58much a network adapter and once you're
- 2:36:00done you just hit ctrl c and that will
- 2:36:02terminate the process right over there
- 2:36:05all right now to end up at or to end
- 2:36:07this video
- 2:36:08let's talk about a dns which a lot of
- 2:36:10people actually ask me about so your dns
- 2:36:12information
- 2:36:14or your name servers rather are going to
- 2:36:16be stored in your resolve.com file so
- 2:36:18again sudo
- 2:36:20uh sudo and we'll use vim etsy and we're
- 2:36:24looking for the resolve uh
- 2:36:26resolve dot com file and we hit enter
- 2:36:29you can see that this uh this file is
- 2:36:30managed uh by the system they resolved
- 2:36:33uh and we can i'll actually show you how
- 2:36:35to use that utility shortly um
- 2:36:38so this is a dynamic result or
- 2:36:40configuration file for connecting local
- 2:36:42clients to the internal dns stub
- 2:36:44resolver of systemd so again it tells
- 2:36:46you that this is going through systemd
- 2:36:48and this is more of a dynamic uh of a
- 2:36:51dynamic file that is generated
- 2:36:53dynamically
- 2:36:54and again it is just for connecting
- 2:36:56local clients to the internal dns dns
- 2:36:59resolver with systemd resolved um and
- 2:37:02i'll be talking about services as i said
- 2:37:04later on but many people edit this which
- 2:37:06will work temporarily uh however if you
- 2:37:09do want to take a look at systemd
- 2:37:10resolve that's extremely simple so
- 2:37:13what you could do if you want to use
- 2:37:14this manually is uh we would actually
- 2:37:16just add another one here so i can say
- 2:37:19name server and then i'll say for
- 2:37:21example go the google name server eight
- 2:37:23eight eight eight
- 2:37:24and uh i can use that if i want to but
- 2:37:26in our case we're not gonna we're not
- 2:37:28gonna have any changes here so we'll
- 2:37:30just exit so
- 2:37:32you can actually check the status of
- 2:37:34system d resolve so we can say uh system
- 2:37:38b
- 2:37:39uh resolve sorry resolve and we say
- 2:37:42status
- 2:37:43and we hit enter and again that gives
- 2:37:45you uh the various dns information that
- 2:37:48you're looking for so we can print out
- 2:37:50so you can see the dns servers that we
- 2:37:52currently have set
- 2:37:54are going to be the google dns server
- 2:37:56and this is going through your uh your
- 2:37:58actual your router or your main gateway
- 2:38:01so it would be advisable to switch uh
- 2:38:04you know to any dns server that you want
- 2:38:06to do or that you want to use on your
- 2:38:08main router
- 2:38:09so you can see that it uses the default
- 2:38:12one that is your default gateway ip here
- 2:38:15and the google
- 2:38:17the google dns server that i have set
- 2:38:19here and that was simply for the
- 2:38:20demonstration purposes in this video so
- 2:38:23that's how to system they resolve
- 2:38:25um now when talking about your hosts
- 2:38:27file this essentially allows you to
- 2:38:29manage your various hosts and you can
- 2:38:31use this uh you know for ad blocking
- 2:38:33uh or yeah you can use it for ad
- 2:38:35blocking if you want to so for example
- 2:38:37uh we can say sudo
- 2:38:40vim and we say etsy and we say host and
- 2:38:43we hit enter and you can see uh for
- 2:38:45example where we have uh defined uh the
- 2:38:48local host or the loopback
- 2:38:50uh you know
- 2:38:52127.0.0.1 is our localhost and then the
- 2:38:55current host here which is alexis
- 2:38:57workstation is
- 2:38:59127.0.1.1 so i could also change that to
- 2:39:01any other ipa i want
- 2:39:03so if you're going to block an ad what
- 2:39:05you typically do is you put an invalid
- 2:39:07ip address here so i could say zero zero
- 2:39:09zero zero
- 2:39:10uh and i could sort of block a website
- 2:39:13here like for example
- 2:39:15i could say google.com
- 2:39:18which is not a smart thing to do but in
- 2:39:20any case uh we can write those changes
- 2:39:22and exit and then if i say sudo system
- 2:39:25control
- 2:39:26we say restart network
- 2:39:29manager i believe
- 2:39:31network manager dot service
- 2:39:33um so we will just let me just try and
- 2:39:35complete this for some reason it isn't
- 2:39:38displaying this system
- 2:39:41system control
- 2:39:46network manager.service
- 2:39:49and we want to use this so we want to
- 2:39:51restart the network manager and i'll
- 2:39:53actually show you this to you right now
- 2:39:55um so if we try and open up a firefox
- 2:39:58instance here and we say google.com and
- 2:40:01we hit enter you can see
- 2:40:03uh it pretty much redirects us to the
- 2:40:05local host and
- 2:40:07that's essentially how to use the hosts
- 2:40:09file now i can change the ip to
- 2:40:10something i do something else completely
- 2:40:12but again many of you have been asking
- 2:40:14me how to use the hosts file so that's
- 2:40:16pretty much how to use it
- 2:40:19and we can get rid of that right now
- 2:40:21because i don't want that to be the case
- 2:40:23and we can just restart the network
- 2:40:24manager one more time
- 2:40:26and there we are so we should be good
- 2:40:28there all right so that's pretty much
- 2:40:30all i wanted to cover in regards to
- 2:40:31networking and all that is important as
- 2:40:34i said we'll be taking a look at
- 2:40:35services i will also be taking a look at
- 2:40:37ssh and if you are interested in in
- 2:40:40exploring tools like netstat and net
- 2:40:43discover you can check my independent
- 2:40:45videos
- 2:40:50in this video we're going to be talking
- 2:40:51about how to use store and proxy gains
- 2:40:53in conjunction to anonymize your traffic
- 2:40:56uh you know through the use of any tool
- 2:40:57that you want so both of these tools
- 2:40:59don't come pre-installed on you know
- 2:41:01standard distributions but you can
- 2:41:03pretty much find them on pen testing and
- 2:41:05offensive distributions so again what we
- 2:41:08need to do is install the tor service
- 2:41:10first not the tor browser but the actual
- 2:41:13tor service and then secondly we need to
- 2:41:15install the proxy chains tool so again
- 2:41:17to install the tour service all we need
- 2:41:19to do is say sudo
- 2:41:21sudo apt you can use whatever package
- 2:41:22manager using sudo apt-get install and
- 2:41:25it's pretty much going to be just store
- 2:41:27that will be the name of the service and
- 2:41:28i already have it installed so
- 2:41:31again if you just want to check what it
- 2:41:33is so you can say what is store and this
- 2:41:34is referring to the actual
- 2:41:37um due to the actual service so you can
- 2:41:39see that what is a second generation
- 2:41:41onion router
- 2:41:43so if we say man
- 2:41:44tor and we hit enter you can see that
- 2:41:46door
- 2:41:47uh is a connection oriented anonymizing
- 2:41:49communication service users i choose a
- 2:41:51source routed path through a set of
- 2:41:53nodes
- 2:41:54uh and negotiate a virtual circuit
- 2:41:56through the to the network i think i've
- 2:41:58pretty much explained this before in
- 2:41:59previous video as to how the tor how tor
- 2:42:02works um so we'll be using tor now uh to
- 2:42:04start the tour service we can use
- 2:42:07systemd or you can also use a service
- 2:42:10um so we can say sudo system control and
- 2:42:13we say uh we can say start and then we
- 2:42:16are looking for tor uh
- 2:42:19i think where it is the tor service here
- 2:42:22uh i'm not too sure what it is what it's
- 2:42:25called so if we say tor
- 2:42:27let's check the status here
- 2:42:29status store
- 2:42:31and you can see that we currently have
- 2:42:32it loaded and active so again the tor
- 2:42:36service is an anonymizing overlay
- 2:42:38network for tcp so if we use netstat
- 2:42:41here so we can say netstat
- 2:42:43and we can look for listening tcp
- 2:42:46connections and we grip for the port
- 2:42:48that the door service connects through
- 2:42:49which is 1950 and we hit enter you can
- 2:42:52see we now have uh you know we are
- 2:42:53listening on port 9050 and this is
- 2:42:56localhost so that's perfect we can use
- 2:42:58this with proxychains all right so now
- 2:43:00let's talk about proxychain so again uh
- 2:43:02installing proxychains is very simple so
- 2:43:04you do upgrade install proxychains uh
- 2:43:07sorry um
- 2:43:09proxy chains and we enter and i already
- 2:43:11have it installed uh before we actually
- 2:43:13use it we now need to uh we need to play
- 2:43:16around with the configuration file so
- 2:43:18that we can tweak the the configuration
- 2:43:20to what we want it to be and how we want
- 2:43:22it to work so we can say sudo vim hc
- 2:43:26proxychains.conf and we hit enter
- 2:43:29so again
- 2:43:30pretty much i'll go through the settings
- 2:43:32that i use so again
- 2:43:34we can use http x4 sox5
- 2:43:37uh and again we this allows you to
- 2:43:39tunnel um or proxy you can you can
- 2:43:42essentially tunnel your connections
- 2:43:43through a series of proxies and in our
- 2:43:46case the proxies are going to be is
- 2:43:47going to be tor so with dns that's the
- 2:43:50great thing so
- 2:43:51uh the options below identify how the
- 2:43:54proxy list is treated only one option
- 2:43:56should be common uncommented at a time
- 2:43:58so
- 2:43:59dynamic chains where each connection
- 2:44:02will be done via chained proxies all
- 2:44:03proxy chained in order as they appear in
- 2:44:05the list at least one proxy must be
- 2:44:07online to play in the chain i i pretty
- 2:44:09much like using the random chain
- 2:44:12so you can see that each connection will
- 2:44:14be done via random proxy or proxy chain
- 2:44:17from the list this option is good to
- 2:44:18test your intrusion detection system
- 2:44:20because it's constantly changing uh you
- 2:44:23know through random proxies but if again
- 2:44:25if you want a dynamic chain that's
- 2:44:26perfect
- 2:44:27uh you can also use the strict chain
- 2:44:29this will ensure that uh all connection
- 2:44:32are going to be done through a chain
- 2:44:33proxy or all proxies will be chained in
- 2:44:35the order as they appear in the list so
- 2:44:38i like using a random chain so you want
- 2:44:40to uncomment this or it will be
- 2:44:42commented here so
- 2:44:44if i just hit insert here and it'll
- 2:44:46pretty much be commented like so and you
- 2:44:48want to uncomment this
- 2:44:50we then want to take a look at the proxy
- 2:44:52dns request so again this will prevent
- 2:44:55no leak for dns data this is very
- 2:44:57important you want to make sure that's
- 2:44:59uncommented and then we want to take a
- 2:45:02look at the proxy list format so this
- 2:45:03gives you an idea of how to use your
- 2:45:05proxy list if you are interested in
- 2:45:07using other proxies apart from tor
- 2:45:10you can see that we have socks 5 http
- 2:45:12sox4 you know in our case the defaults
- 2:45:15will be set to door and we want to add
- 2:45:17socks 5 as well here so we say socks 5
- 2:45:20and we can we remember it's running on
- 2:45:22our local host uh sorry 127.0.0.1
- 2:45:26uh 1950 and that's of course going to be
- 2:45:28um that's going to be socks 5 all right
- 2:45:31so we can add any of the other proxies
- 2:45:33we want here so again if you're not keen
- 2:45:35on using tor you can change this and
- 2:45:37we'll write changes and quit from here
- 2:45:40so now when using proxy chains you want
- 2:45:42to ensure that you have the toss service
- 2:45:43started and it's currently running and
- 2:45:45then i use the syntax is very simple so
- 2:45:47we say proxy chains
- 2:45:50and then we specify the tool that we
- 2:45:52want to use um so for example
- 2:45:55i can say proxy chains are firefox uh or
- 2:45:58i can use another tool like ssh or
- 2:46:01telnet
- 2:46:02or i could use a tool uh maybe let's try
- 2:46:05firefox because it's the easiest way to
- 2:46:07test this so i say firefox
- 2:46:09and then i open this website dns
- 2:46:11leaktest.com
- 2:46:13and we hit enter and that's going to
- 2:46:15start proxy chains for us now given that
- 2:46:17it's using door the connection is going
- 2:46:19to be much slower than you know a
- 2:46:21standard proxy uh of course depending on
- 2:46:23what proxy you end up using so we'll
- 2:46:25just wait for this to load up and the
- 2:46:26dns lictest.com
- 2:46:28will tell us what our ip is and secondly
- 2:46:31it will tell us
- 2:46:33what our dns is so you can see
- 2:46:36it gives us information regarding our ip
- 2:46:38um for some reason isn't telling us what
- 2:46:40country it is so again we can just hit a
- 2:46:42standard test this will test our dns to
- 2:46:44see if we
- 2:46:45are leaking any dns information and of
- 2:46:48course dns information is very important
- 2:46:49as it can leak your geographical
- 2:46:51information so again you can just go
- 2:46:54through the test and this will display
- 2:46:56whether or not what dns servers you're
- 2:46:58currently been using so let's wait for
- 2:47:01this and see what results we get there's
- 2:47:03a progress bar right over here so you
- 2:47:05can see that all are going through um
- 2:47:08dns servers in germany and of course you
- 2:47:11have their host names and their various
- 2:47:13ips so again that's a great because it
- 2:47:15was a we were we didn't leak any of our
- 2:47:18personal dns information that or the dns
- 2:47:20servers we went through but of course
- 2:47:22that is also dependent on on you know
- 2:47:25dns security something that's out of the
- 2:47:26scope of this video
- 2:47:32in this video we're going to be talking
- 2:47:33about uh process and service management
- 2:47:36uh so we're going to be talking about
- 2:47:37lots of tools that you can use to uh to
- 2:47:39manage processes
- 2:47:41and also manage services right so these
- 2:47:44this is a very important video pretty
- 2:47:45much i think one of the most important
- 2:47:47videos in this series because of of the
- 2:47:50power that that comes with it so uh
- 2:47:52first of all let's let's take a look at
- 2:47:55some of the utilities that you can use
- 2:47:57uh to to manage system resources and to
- 2:48:00view the current processes and you know
- 2:48:02just view resource consumption in
- 2:48:04regards to the processes that are
- 2:48:06consuming the most and consuming the
- 2:48:07least
- 2:48:08now by default all linux systems come
- 2:48:10with a utility called top right and you
- 2:48:13can pretty much get some information
- 2:48:15about it by using uh the what is command
- 2:48:17so again it tells us that top displays
- 2:48:19linux processes so you can hit top and
- 2:48:21again as you can see this gives you
- 2:48:23information regarding uh your your
- 2:48:25system resources the consumption and the
- 2:48:28various processes that are running the
- 2:48:30the owner of the processes in terms of
- 2:48:32the user so you have your process id
- 2:48:34very important there that can be used to
- 2:48:36manage the process either to kill it
- 2:48:38uh or to stop it you then have the user
- 2:48:41here that it belongs to
- 2:48:43you then have the cpu and memory
- 2:48:45consumption
- 2:48:46uh the time
- 2:48:47and the command itself so again you can
- 2:48:50essentially use this to manage all your
- 2:48:52processes however the a better utility
- 2:48:55custom utility that you can install by
- 2:48:57with with whatever the package manager
- 2:48:59using
- 2:49:00and that is the h-top utility so again
- 2:49:02we can install it we can install it here
- 2:49:04i already have it installed so again we
- 2:49:07can clear this and say what is h-top you
- 2:49:09can see that this is an interactive
- 2:49:11process viewer so if we open up htop uh
- 2:49:14you can see that first of all it gives
- 2:49:15you your processor usage
- 2:49:17in regards to how many cores you have so
- 2:49:19i have six scores here and it gives you
- 2:49:21the utilization in terms of percentage
- 2:49:24you then have your memory usage so it
- 2:49:25gives you a total usage i have about 16
- 2:49:28gigs here and i'm currently using six
- 2:49:30gig
- 2:49:30uh it also tells you your swap usage uh
- 2:49:33so i have a swap uh set to about two
- 2:49:36gigs uh don't get angry at me and a lot
- 2:49:37of people are against swap nowadays
- 2:49:40it gives you the amount of tasks
- 2:49:43the amount running the load average and
- 2:49:45the uptime of your system so very useful
- 2:49:47information it also sorts it out it
- 2:49:50sorts the information out uh you know
- 2:49:52similar to what we add so we have the
- 2:49:53process id and you can sort that out uh
- 2:49:56chronologically so you can say you can
- 2:49:58just click on it and it loads it up from
- 2:49:59the first process with the process id of
- 2:50:02one you then have the user so you can
- 2:50:04again switch from all the user uh the
- 2:50:06user accounts that uh that these
- 2:50:08processes are running under
- 2:50:11you then have your cpu usage so if i
- 2:50:12click on cpu that displays uh the the
- 2:50:15process that is currently using the most
- 2:50:18uh cpu usage uh again i can click on
- 2:50:20memory and it tells us that google
- 2:50:22chrome is using the most memory that's
- 2:50:24that's not a surprise
- 2:50:26and of course we can just go back to cpu
- 2:50:28usage and you can see that obs is
- 2:50:30currently running right now which makes
- 2:50:31sense as that is using the most cpu
- 2:50:34right so uh this is a utility that you
- 2:50:37can use to pretty much manage your
- 2:50:39processes now before we take a look at
- 2:50:40how to use it because this simplifies
- 2:50:42the process
- 2:50:43let's take a look at uh you know how you
- 2:50:46would actually view these uh the
- 2:50:48resource consumption like ram usage for
- 2:50:50example to v ram ram usage we would
- 2:50:53simply type in free
- 2:50:54and that again tells you uh if we that
- 2:50:57you know we just use the man pages here
- 2:50:59you can see that free uh displays
- 2:51:02the amount of free and used memory in
- 2:51:04the system so again you can display this
- 2:51:06uh in regards to uh to to to the output
- 2:51:09you want so if we say three h that
- 2:51:11prints it out in human uh readable
- 2:51:14format so you can see we have total used
- 2:51:16free shared
- 2:51:17the cash and available and of course
- 2:51:19also for your swap so that's uh one of
- 2:51:21the quick ways you can view how much ram
- 2:51:23you're using
- 2:51:24now let's talk about processes right so
- 2:51:26processes uh need to be understood as
- 2:51:29you need to separate them between you
- 2:51:31need to separate processes and services
- 2:51:33right so processes
- 2:51:35uh are viewed with the ps tool so again
- 2:51:38uh ps uh gives you a report uh it gives
- 2:51:40you a report of this uh or it
- 2:51:42essentially gives you a snapshot of your
- 2:51:43current processes that you have running
- 2:51:46all right so if i just say ps
- 2:51:48this is weird because many users
- 2:51:50actually i've pointed this out so why
- 2:51:53does it only give you two processes well
- 2:51:55you haven't specified any arguments in
- 2:51:57regards to what processes you want to
- 2:51:58see so what it's going to give you is
- 2:52:00it's simply going to display processes
- 2:52:02that are in your current shell and you
- 2:52:04can see that the tool that it has is the
- 2:52:06bash
- 2:52:07and the the actual command that you run
- 2:52:09so that makes sense now if we want to
- 2:52:11display all processes we would simply
- 2:52:13say psa ux
- 2:52:15and you can view all of this syntax
- 2:52:18from the man page which is actually
- 2:52:20recommended here i'm using the psd style
- 2:52:22or the bsd syntax so again
- 2:52:25to see every process on the system using
- 2:52:28standard syntax you can use that i'm
- 2:52:29using as you can see right over here bst
- 2:52:32syntax so i'll continue with that so i
- 2:52:34can say ps aux
- 2:52:36and i can hit enter alright so this is a
- 2:52:38lot of information here this is
- 2:52:40essentially giving you a snapshot of all
- 2:52:42the processes that you have running on
- 2:52:44your system so we can scroll all the way
- 2:52:46to the top and again the it's sorted out
- 2:52:48into a table with various columns so
- 2:52:50again you have the user the process id
- 2:52:52and it starts chronologically
- 2:52:54but the great thing about tools like
- 2:52:55h-stop is it gives you a dynamic view of
- 2:52:58of the processors how much they're
- 2:53:00consuming on a second by second basis uh
- 2:53:03cpu usage memory etc but this is a
- 2:53:05snapshot remember so again this can give
- 2:53:07you an idea of all the processes that
- 2:53:09are currently active however if you want
- 2:53:11a dynamic idea of the current system
- 2:53:14resource consumption use a utility like
- 2:53:16top or h-top this just gives you a
- 2:53:18snapshot all right the key thing we're
- 2:53:20looking for here is the pid because we
- 2:53:23won't talk about managing processes
- 2:53:25right so
- 2:53:26let's say um i want to start a service
- 2:53:29here
- 2:53:30so i say sudo system
- 2:53:32control
- 2:53:35system control i'm going to say start
- 2:53:38and i'll say tor i want to start the tor
- 2:53:40service here and then i say ps aux i can
- 2:53:42also grab the output here and i can say
- 2:53:44i'm looking for tor uh so give me all
- 2:53:47processes with door right now of course
- 2:53:49it's going to give us you know various
- 2:53:51other false positives with the the
- 2:53:53string of characters t o r and you can
- 2:53:56see the inclusion of that within storage
- 2:53:58but if we just go to the bottom here uh
- 2:54:00you can see we have um
- 2:54:03we have the user bin tour uh binary
- 2:54:06being used here so that looks
- 2:54:07interesting
- 2:54:08and yeah so if we take a look at the
- 2:54:10process id we can see it has a process
- 2:54:12id of 7604 so if we say uh sudo
- 2:54:16system
- 2:54:17control we say status status store and
- 2:54:21we enter um sorry about this guy system
- 2:54:25control and we hit we take a look at the
- 2:54:27status of the
- 2:54:28of the service you can see that it's
- 2:54:30active it's loaded and active so if we
- 2:54:32want to kill this process all we need to
- 2:54:34do is get the process id in this case
- 2:54:36it's going to be 7604
- 2:54:39and all we need to do is say
- 2:54:41we just say kill
- 2:54:43and you may want to prepend this with
- 2:54:45root privileges or the pseudo command so
- 2:54:47we say sudo kill
- 2:54:48uh seven six zero four seven six zero
- 2:54:51four and we enter and now if we take a
- 2:54:53look at the the the tour service you can
- 2:54:55see it's still running now the reason i
- 2:54:57did this is because you need to
- 2:54:59differentiate between a service and a
- 2:55:02process because the service will re
- 2:55:04reinitiate or re-initialize itself right
- 2:55:07so let's take a look at
- 2:55:09the let's take a look at all the
- 2:55:11processes here and we can take a look at
- 2:55:12more realistic options available to us
- 2:55:15right so i'll give you an example here
- 2:55:17um so let's grip for ssh and we'll say
- 2:55:22grep ssh
- 2:55:24let's see we have the ssh daemon here
- 2:55:27[Music]
- 2:55:29which is running as a process id
- 2:55:32of
- 2:55:345687 right and
- 2:55:36we also have the uh yeah that's pretty
- 2:55:39much the one we're looking for we also
- 2:55:40have the ssh agent here
- 2:55:42so what we can do is we can say um
- 2:55:45pseudo here
- 2:55:46one nine six nine
- 2:55:48and we can also say pseudo kill 56 87
- 2:55:51right so we can say 56 87 you kill that
- 2:55:55and then we say system
- 2:55:57system
- 2:55:58control and say
- 2:56:00status ssh and we hit enter you can see
- 2:56:03that ssh
- 2:56:05is currently loaded but inactive dead
- 2:56:08right so that's just a simple way of
- 2:56:10managing processes now we can do the
- 2:56:11same thing
- 2:56:12uh with h-stop and i'll show you how to
- 2:56:14do this many people actually skip this
- 2:56:16but each stop is has a much easier way
- 2:56:18of doing this so when you launch h-stop
- 2:56:21uh you can pretty much filter through
- 2:56:22the results but a great way of searching
- 2:56:24for services by their name instead of
- 2:56:25using grep is by using the f3 key
- 2:56:28after which it will bring up this little
- 2:56:30search bar and i can search for things
- 2:56:31like door
- 2:56:32uh and if i use a space
- 2:56:34it pretty much should give me all the
- 2:56:36results so let me just do that one more
- 2:56:38time so i say tor
- 2:56:40and
- 2:56:41we can see that the process was closed
- 2:56:44but the the service is still running so
- 2:56:46let's try another another process here
- 2:56:49let's see if we have um
- 2:56:52let's see let's actually work with
- 2:56:53h-stop i just want to show you this so
- 2:56:54if we click on h-stop and it's
- 2:56:56highlighted yellow we can actually kill
- 2:56:58it by using f9 so if we hit f9 we can
- 2:57:01send various signals to this process so
- 2:57:04we can say signal quit signal kill so if
- 2:57:06we say signal kill that's option nine
- 2:57:09and we hit enter
- 2:57:10you can see that that will pretty much
- 2:57:12kill the process and you can see that it
- 2:57:15actually points that up right over here
- 2:57:17and
- 2:57:17you can see that the output is messed up
- 2:57:19and i shouldn't have probably done that
- 2:57:21but i wanted to demonstrate the power of
- 2:57:22h stop here so if i go into h stop one
- 2:57:25more time and now again it's giving us
- 2:57:27our dynamic results so we can pretty
- 2:57:29much use that same
- 2:57:30syntax to manage our services really
- 2:57:32easy and many people go over this it's
- 2:57:34not just a system resource uh
- 2:57:37usage
- 2:57:38utility to actually display how much uh
- 2:57:40you know resources you're consuming it
- 2:57:42can actually allow you to interact with
- 2:57:44your services or your processors quite
- 2:57:46well so
- 2:57:48again i can search for any process right
- 2:57:50over here with name or i can
- 2:57:52again i can work with the the resource
- 2:57:55consumption so again i can highlight
- 2:57:56resource consumption here uh memory
- 2:57:58consumption et cetera et cetera right
- 2:58:00now let's talk about service management
- 2:58:02with system d right because i also want
- 2:58:05to cover uh system v as well system v
- 2:58:07service management but
- 2:58:09now the norm is increasingly becoming
- 2:58:12system d so it's great to to actually
- 2:58:14know how to use this so
- 2:58:16if we say man system
- 2:58:18control this is the utility that allows
- 2:58:20us to control um
- 2:58:22so you can see control the systemd
- 2:58:24system and service manager so i'll show
- 2:58:26you how to use it so if we want to list
- 2:58:28all the active services which are going
- 2:58:30to be a lot we can say system
- 2:58:32uh control and we hit enter and you can
- 2:58:35see that we can you know we can move
- 2:58:36down with the uh your your directional
- 2:58:39keys
- 2:58:40and this gives you an idea of all the
- 2:58:41services that you have running and once
- 2:58:43you have once you're done we have about
- 2:58:45uh 230 lines here and they keep on going
- 2:58:47as as the more you you actually go down
- 2:58:50so uh 269 loaded units um it gives you
- 2:58:54all information regards to all the
- 2:58:55services you have running so if we quit
- 2:58:58we can also prep so if we grep here we
- 2:59:01say grab
- 2:59:02ssh and we hit enter so we have no ssh
- 2:59:05service running so if we if we want to
- 2:59:08start a service like the ssh service
- 2:59:09what i can do is i can say
- 2:59:11system control
- 2:59:13system control i say start and then i
- 2:59:17i can you know then play around with
- 2:59:19with what i want to do so i can say
- 2:59:21um i can say
- 2:59:24start and then the name of the service
- 2:59:25so i can say ssh and then i can use the
- 2:59:27tab auto completion here so again you
- 2:59:29can see that we have the ssh socket and
- 2:59:31the ssh service so if i wanted to start
- 2:59:34the ssh service uh just give it a few
- 2:59:36seconds it does take a while to load
- 2:59:37this if i use tab auto completion too
- 2:59:39much so if i say
- 2:59:41system control uh start ssh service and
- 2:59:43i hit enter it's gonna ask me for my uh
- 2:59:45for my password and it's gonna this
- 2:59:47because it requires root privileges
- 2:59:49so uh that has started the ssh service
- 2:59:51now we can again uh confirm this uh with
- 2:59:54you know we can say uh lt here and uh
- 2:59:57you can see we have ssh running
- 2:59:59right over here so again we can check
- 3:00:01the status of the pros of this actual
- 3:00:03service by running uh sudo system
- 3:00:06control and we can say status
- 3:00:09ssh dot service here and we enter
- 3:00:12and there we are so you can see it tells
- 3:00:14us that the ssh service this is using
- 3:00:16open ssh so it tells us it's loaded and
- 3:00:18active which means it you can actually
- 3:00:20use it and it gives you information
- 3:00:22about it so the log of events so again
- 3:00:25started uh ssh listening on port 22
- 3:00:29listening on localhost port 22 starting
- 3:00:31the openssh openbsd secure shell server
- 3:00:35and it gives you the various timestamps
- 3:00:37right so
- 3:00:38that's how to pretty much interact uh to
- 3:00:41how to start and monitor the status of a
- 3:00:43service if you're having issues with it
- 3:00:45right now if i wanted to disable it or
- 3:00:47to stop it i could say um i could just
- 3:00:51i can say stop
- 3:00:53uh and i can say ssh dot service and i
- 3:00:57hit enter and that will stop the
- 3:00:59sorry let me just enter my password here
- 3:01:01that will stop the service
- 3:01:03if i check the status you can see that
- 3:01:05it's loaded but inactive and dead now a
- 3:01:07lot of people ask me how do i run
- 3:01:10particular services on system startup
- 3:01:12and you can easily do that with systemd
- 3:01:15so i can say sudo system let's say i
- 3:01:18wanted to enable the ssh service every
- 3:01:19time i boot up which is useful
- 3:01:22so i can say system control
- 3:01:25[Music]
- 3:01:26and then i would say enable but first i
- 3:01:28need to check if it's already enabled so
- 3:01:30i can say is enabled
- 3:01:32and then say ssh dot service and that
- 3:01:35will tell me if uh it is currently
- 3:01:37enabled to
- 3:01:38do to be run on system startup you can
- 3:01:40see tells us that it's currently
- 3:01:41disabled which is great
- 3:01:43uh if i check the synergy service i just
- 3:01:46want to give you an example a robust
- 3:01:47example or hit enter you can see that on
- 3:01:50startup yes this service is enabled
- 3:01:52that's because i use the synergy service
- 3:01:54to you know for my mouse sharing my
- 3:01:56mouse and keyboard sharing
- 3:01:58system so again that tells me that okay
- 3:02:00that's enabled so if we want to enable
- 3:02:02ssh what we would say is a pseudosystem
- 3:02:05control and we would say enable and say
- 3:02:07ssh.service
- 3:02:10all right and i hit enter and you can
- 3:02:12see it's created the sim link
- 3:02:14for us uh in the system d uh directory
- 3:02:17here so
- 3:02:19uh if you're using um
- 3:02:22if you're using system v then you nee
- 3:02:24you need to play around with the initial
- 3:02:26uh the init scripts uh
- 3:02:28and you then need to create a sim link
- 3:02:30but this does it automatically for you
- 3:02:31so now if we check the uh is enabled if
- 3:02:34we check if it's enabled you can see
- 3:02:35that now it's enabled if i want to
- 3:02:37disable it from running on startup i
- 3:02:39would simply say disable
- 3:02:42because i don't want ssh running this is
- 3:02:44not a server so
- 3:02:45i can check it now and we can see it's
- 3:02:47disabled all right so
- 3:02:49that's pretty much how to manage uh you
- 3:02:51know services with system d so that's
- 3:02:54how to start stop uh if i want to
- 3:02:55restart a service again i can simply say
- 3:02:58restart so let me do that right now so
- 3:03:00if i say sudo system control i say tor
- 3:03:03sorry start
- 3:03:04tor i can hit enter that will start the
- 3:03:06tour services i want to reload it i can
- 3:03:08say reload
- 3:03:10all right now i can also um
- 3:03:14i can also reload will reload the uh the
- 3:03:17configuration if i say restart that will
- 3:03:19simply restart the service with the
- 3:03:21current configuration so that's a quick
- 3:03:23tidbit for you if you you can use reload
- 3:03:25here then that will essentially restart
- 3:03:28it with the newer configuration so in
- 3:03:30case you're wondering so i'll just stop
- 3:03:31this service
- 3:03:32and i'll just hit enter
- 3:03:34and there we are all right so
- 3:03:36that is how to manage services now if
- 3:03:38you want to uh if we want to reload the
- 3:03:41entire the system d daemon what we can
- 3:03:43say is sudo system control
- 3:03:46uh we're looking for the daemon and we
- 3:03:49can say reload and we just hit enter and
- 3:03:51that will reload the daemon completely
- 3:03:53that's if you're having any issues and
- 3:03:55you wanted to reconfigure particular
- 3:03:56services
- 3:03:58all right
- 3:03:59now
- 3:04:00let's talk about system v service
- 3:04:02management which many of you are
- 3:04:03familiar with a system v is essentially
- 3:04:05where you say service
- 3:04:07the name of the service which could be
- 3:04:08door and then we say start
- 3:04:10we can say stop
- 3:04:12and we can say restart right very very
- 3:04:14simple and we can also check the status
- 3:04:16so again say service store start
- 3:04:18that will ask you know ask me for my
- 3:04:21administrator privileges i can say
- 3:04:23service store
- 3:04:25status hit enter you can see it tells us
- 3:04:27active loaded
- 3:04:29um and then we can say system a service
- 3:04:32store we can say stop and we can hit
- 3:04:34enter and that will stop these the door
- 3:04:36service and we can also
- 3:04:38say restart and again that will simply
- 3:04:40restart the tour service there and we
- 3:04:42can then stop it one more time so that's
- 3:04:44how to use system v very very simple but
- 3:04:46in my opinion system d
- 3:04:48uh is is the much better alternative to
- 3:04:51learn now and it's extremely robust and
- 3:04:53very very powerful tool to actually
- 3:04:56learn how to use or do low utility
- 3:05:02in this video we're going to be talking
- 3:05:03about ssh uh how to configure it
- 3:05:05securely
- 3:05:06uh and then of course we'll talk about
- 3:05:08you know how to uh how to securely
- 3:05:10transfer files with ssh so let's get
- 3:05:12started um first of all with
- 3:05:14establishing what ssh client and server
- 3:05:17we're going to be using so in our case
- 3:05:19we want to be uh we want to be using
- 3:05:21openssh which is pretty much the go to
- 3:05:23uh the the go to ssh client in server
- 3:05:26solution it's completely open source and
- 3:05:28it's uh it's one of these uh you know
- 3:05:30great services so again that was uh
- 3:05:32developed by the bsd team
- 3:05:34so um again uh we must first of all
- 3:05:38understand the uh the connection type or
- 3:05:40the connection model uh with ssh so ssh
- 3:05:43is primarily a client server connection
- 3:05:46model so that means you need the client
- 3:05:48software to
- 3:05:49connect to the to the server software in
- 3:05:51our case we need to install the openssh
- 3:05:54client service or the client package
- 3:05:57on our client and of course the openssh
- 3:05:59server package on r7 i'll show you that
- 3:06:01right now so i'm currently on my client
- 3:06:02here which is going to be ubuntu our
- 3:06:04remote server is going to be one of my
- 3:06:05ubuntu servers uh running on my
- 3:06:07virtualization server so
- 3:06:09what i'll do is i'll say sudo apt
- 3:06:13get install and we say open ssh and we
- 3:06:16we're looking for the openssh if we
- 3:06:18double tap we can see we're looking for
- 3:06:19the openssh client right so i'm gonna
- 3:06:21hit enter and uh i already have this
- 3:06:24installed right now the openssh client
- 3:06:27configuration file is found so if i say
- 3:06:29cat hc ssh sorry ssh and this is found
- 3:06:33under
- 3:06:33it is the ssh config the sshd config
- 3:06:36file is for the open ssh server
- 3:06:39so you can see i also have my uh my my
- 3:06:42public and private keys here as well but
- 3:06:44i'll get into that in a second they we
- 3:06:46don't need to complicate this right now
- 3:06:47so if i take a look at me at my config
- 3:06:50file here this is the client config
- 3:06:53you can see that um
- 3:06:55the options are quite uh straightforward
- 3:06:58in regards to what you can enable and
- 3:06:59disable so you can specify the port
- 3:07:02uh the protocol um
- 3:07:04and uh various other bits of
- 3:07:06you know configurations here but that's
- 3:07:08not the the in within the scope of the
- 3:07:11video but i just wanted to get to that
- 3:07:13so
- 3:07:13uh my remote server is running on um
- 3:07:16it's currently running on an ip of
- 3:07:20192.168.1.113 so
- 3:07:22we already have an admin user on that
- 3:07:23system so we'll just say admin and we'll
- 3:07:25say 192.168.1.113
- 3:07:28all right and i will just enter the
- 3:07:31password here for the admin user and
- 3:07:33there we are so you can see i'm
- 3:07:34currently logged in as the admin user so
- 3:07:38the first thing we want to do is we need
- 3:07:39to install uh the openssh server so you
- 3:07:42say oh apt-get install open ssh
- 3:07:44server and the reason i'm doing this
- 3:07:46even though i have it installed already
- 3:07:48just to show you how one would go about
- 3:07:49doing it right
- 3:07:51um so hit install already installed
- 3:07:53there excellent all right all right all
- 3:07:55right now that we have this uh both the
- 3:07:57pieces of software installed on the
- 3:07:59client and the server
- 3:08:00we can talk about uh configuring uh you
- 3:08:03know ssh right so pretty much when
- 3:08:06dealing with the remote server and
- 3:08:08remote authentication the first thing
- 3:08:10you need to do is you need to disable
- 3:08:12root logins
- 3:08:14uh because the root the root user
- 3:08:16account is extremely powerful because it
- 3:08:18really has no restrictions in regards to
- 3:08:19what it can do so that's our first order
- 3:08:21of business here and this can be done by
- 3:08:24modifying
- 3:08:25this can be done by modifying the
- 3:08:26openssh
- 3:08:28the openssh
- 3:08:30configuration file the opensh server
- 3:08:32configuration file so if i say sudo vim
- 3:08:35hc ssh and we're looking for sshd
- 3:08:39uh sshd and we say
- 3:08:42sshdconfig and we hit enter so you can
- 3:08:44see this is the openbsd openssh
- 3:08:46sshdconfig file
- 3:08:48and it does you it tells you here this
- 3:08:50is a sshd server systemwide
- 3:08:53configuration file so the first thing we
- 3:08:54want to do is we let's take a look at
- 3:08:56some of the various uh configurations
- 3:08:58you can set here so you can change the
- 3:09:00default port this is great for those of
- 3:09:02you who are who want to set up a
- 3:09:03honeypot on that exact port like por 22
- 3:09:06and then have ssh run on another port
- 3:09:08like 2 2 2 0
- 3:09:10you can do that as well
- 3:09:12you can also change the listen address
- 3:09:14if you want to uh the host key names uh
- 3:09:17let's talk about uh let's just go down
- 3:09:20into logging you can play around with
- 3:09:22logging here
- 3:09:23uh and i'll talk about logs probably in
- 3:09:25another video and here we are we have uh
- 3:09:28we have authentication all right so
- 3:09:29within authentication you can see we
- 3:09:31have an option called permit root login
- 3:09:34right and we want to change this to no
- 3:09:36right so from yes to no
- 3:09:39uh and we we can also play around with
- 3:09:41the grace the login grace time so we can
- 3:09:44increase this or decrease it based on
- 3:09:46the on the time you want to provide
- 3:09:48uh we can keep strict modes to yes uh in
- 3:09:52regards to the max authentication tries
- 3:09:55we can change this to four although i'll
- 3:09:57be making a separate video where i'll be
- 3:09:59showing you how to set up ssh brute
- 3:10:01force protection the max sessions i want
- 3:10:04are going to be three public key
- 3:10:06authentication
- 3:10:08uh yes uh let's go all the way down now
- 3:10:11um
- 3:10:12and we are primarily looking for
- 3:10:14password authentication so we'll talk
- 3:10:16about this when we're going to be
- 3:10:17setting up ssh keys so for now we've
- 3:10:20we've essentially disabled uh where
- 3:10:22we've disabled the root logins so if i
- 3:10:24just save the the files here now when
- 3:10:27whenever you've made changes to the uh
- 3:10:29to the open sh server configuration file
- 3:10:32we need to restart uh the open ssh
- 3:10:35server so to do this again we'll use
- 3:10:37systemd so say system
- 3:10:40and we say
- 3:10:42restart
- 3:10:44sshd sshd service remember this is the
- 3:10:47sshd daemon or the openssh server and we
- 3:10:49hit enter
- 3:10:50all right so now pretty much if we just
- 3:10:53open up a new tab on my client and i try
- 3:10:55and log into the root user account i
- 3:10:57would say ssh root and i would say 192
- 3:11:00168.1.113
- 3:11:03and hit enter right and i enter the
- 3:11:04password for the root user
- 3:11:07and
- 3:11:08you'll see pretty much that we will not
- 3:11:10be able to do it so
- 3:11:12uh that is pretty much uh going to block
- 3:11:14any logins to this uh to this particular
- 3:11:17account now the other thing we we want
- 3:11:19to do is we want to disable or we want
- 3:11:21to lock
- 3:11:22the password for the
- 3:11:25we want to lock the password for the
- 3:11:26root account this will ensure that
- 3:11:28even though
- 3:11:30a person or an attacker may have
- 3:11:33the password the legitimate password
- 3:11:35they can get through it through another
- 3:11:36user account because remember remember
- 3:11:39if if a user gets access to the admin
- 3:11:42account via ssh they can easily switch
- 3:11:45to the root user account so we also have
- 3:11:47to disable you know the password login
- 3:11:50here and this will pretty much lock the
- 3:11:52account unless we have the privileges to
- 3:11:54actually change the password manually
- 3:11:56and to unlock it but it's a great way of
- 3:11:58of you know
- 3:12:00protecting yourself from script kiddies
- 3:12:01so
- 3:12:02what we can do is we can say um we can
- 3:12:05use the password command and say
- 3:12:06password uh l and we specify the account
- 3:12:09we or
- 3:12:10the the account whose password we want
- 3:12:11to lock and we hit enter uh we need uh
- 3:12:14pseudo privileges here so you say sudo
- 3:12:16hit enter and the password expiry
- 3:12:18information has changed so you can say
- 3:12:19sudo
- 3:12:20password and then status
- 3:12:23i believe it's status what options can
- 3:12:25we specify here
- 3:12:27root uh
- 3:12:28wait enter no we do not want to enter a
- 3:12:30new password so we can just do this one
- 3:12:33more time here so you can see that i can
- 3:12:34actually change the password but let me
- 3:12:36lock it
- 3:12:37um
- 3:12:39root where is the status how do we check
- 3:12:42the status oh yeah there is a capital s
- 3:12:44so if we hit enter you can see that the
- 3:12:46password is now going to be locked now
- 3:12:48uh the second step would be to disable
- 3:12:51password authentication and to use ssh
- 3:12:54keys which is exactly what i'm going to
- 3:12:56show you right now
- 3:12:57so that will pretty much ensure that
- 3:13:00you're protected from brute force
- 3:13:01attacks because you're pretty much
- 3:13:03ensuring that you cannot log into this
- 3:13:05ssh server
- 3:13:06without an ssh key right so
- 3:13:10uh what we'll do is we will create a new
- 3:13:12ssh key here and this is very this is
- 3:13:15very easy to do so uh first of all uh we
- 3:13:18need to uh we need to establish
- 3:13:21uh what user account we're going to be
- 3:13:24you know pretty much be using we've
- 3:13:26already locked out the root account
- 3:13:28and once we set up the ssh keys we'll be
- 3:13:30pretty much logging into the admin user
- 3:13:32account and the asset the ssh keys
- 3:13:35or the ssh key based authentication will
- 3:13:37only allow us to to access the admin
- 3:13:39account
- 3:13:40after which we will we will modify the
- 3:13:43uh the openssh server configuration file
- 3:13:45to disable
- 3:13:46uh password authentication so what we'll
- 3:13:48do is we'll say um
- 3:13:51ssh keygen
- 3:13:53um
- 3:13:54there we are t rsa and we hit enter and
- 3:13:57it's going to ask us for
- 3:14:00uh it's going to say generating public
- 3:14:02private
- 3:14:03rsa key pair enter the file in which to
- 3:14:06save the key so we'll say
- 3:14:09home oil just leave it in this directory
- 3:14:10hit enter we can enter a passphrase
- 3:14:12that's always recommended i'll enter
- 3:14:14password is here that will also add an
- 3:14:16additional level of security to your ssh
- 3:14:18key because remember the ssh private key
- 3:14:21has to be kept secret so
- 3:14:23we can see that the keys have been
- 3:14:25copied into a home alexis and ssh
- 3:14:27directory here so
- 3:14:29pretty much what we can do now
- 3:14:31is uh if we change our directory into
- 3:14:33the ssh directory here you can see that
- 3:14:36we have the public and private keys
- 3:14:38right over here so what we need to do
- 3:14:40now is we need to copy the uh the public
- 3:14:43key onto the server so let me just
- 3:14:44explain how ssh works really quickly how
- 3:14:47the authentication works
- 3:14:48so you store your public key on your on
- 3:14:51the server and you have your private key
- 3:14:53uh with you and the private key is the
- 3:14:55most important as it's the
- 3:14:57it's pretty much the key that will allow
- 3:14:59you to authenticate successfully with
- 3:15:01the server so you need to keep it secure
- 3:15:03and backed up in the event you lose it
- 3:15:05you lose access to the server that's
- 3:15:07very important right
- 3:15:08so essentially what what's going to
- 3:15:10happen here
- 3:15:12is your private key is used for
- 3:15:13encryption right so your server the ssh
- 3:15:15server will use your it will send a
- 3:15:18random string of data to you the ssh
- 3:15:20client uh after which the ssh client
- 3:15:23will encrypt that a random string of
- 3:15:25data with the private key and send the
- 3:15:27encrypted data
- 3:15:28uh to the server the server will then
- 3:15:30use your public key to decrypt it and if
- 3:15:33it then matches and you know so on and
- 3:15:35so forth i'll explain that in a second
- 3:15:37so
- 3:15:37what we can do now is we need to copy
- 3:15:39this uh so we say ssh
- 3:15:41copy
- 3:15:42id and we specify uh the the server so
- 3:15:46we say
- 3:15:48192.168.1.113 and we hit enter
- 3:15:50it's going to ask you you can see it's
- 3:15:52asking for the user alexis but we don't
- 3:15:55want to do this remember because we want
- 3:15:57to use the uh the user admin so we're
- 3:15:59going to say admin and we're gonna hit
- 3:16:01enter it's gonna ask for admins password
- 3:16:04like so and uh
- 3:16:06you can see after we've entered the
- 3:16:07password it's gonna ask us for the it's
- 3:16:09gonna tell us the number of keys added
- 3:16:10is one
- 3:16:11and we can now try try login to the
- 3:16:13machine with ssh admin and we will
- 3:16:16essentially not have uh we will not need
- 3:16:18to use passwords but before we do that
- 3:16:21we need to disable password
- 3:16:22authentication with ssh so to do this
- 3:16:24again we say sudo vim and i'm back on
- 3:16:26the server now ssh
- 3:16:29and we say sshd config and we hit enter
- 3:16:32and
- 3:16:33we'll go all the way to the bottom here
- 3:16:36uh am i in the right configuration file
- 3:16:38i believe so
- 3:16:41yes we are i believe uh your possible
- 3:16:44authentication right over here
- 3:16:46and we will change this to no so this
- 3:16:49will
- 3:16:49essentially disable the ability for you
- 3:16:52to log in to this or to this remote
- 3:16:55server via ssh with passwords so the
- 3:16:57only way you can login
- 3:16:59is going to be through ssh keys so now i
- 3:17:02can
- 3:17:03write changes and exits here and we'll
- 3:17:06restart the
- 3:17:07ssh server
- 3:17:09service or the sshd service we enter and
- 3:17:12that's going to restart it for us orange
- 3:17:14so now if we exit
- 3:17:16we can essentially say ssh
- 3:17:18admin
- 3:17:20at 182
- 3:17:23168.1.113.8 enter and it's going to ask
- 3:17:25me for the passphrase for the for the
- 3:17:27private key and we're going to unlock
- 3:17:29and there we are we now have access
- 3:17:31right now some of you might be saying
- 3:17:33well uh you have the private key what if
- 3:17:36the location is different so let me just
- 3:17:37show you this right now so i'll go into
- 3:17:39my ssh directory here
- 3:17:42and uh
- 3:17:44just list all the files and i'll say
- 3:17:46i'll move the um
- 3:17:48this is sorry sorry about that let me
- 3:17:50just go to my local directory here or i
- 3:17:51can actually just log out
- 3:17:53so cd ssh
- 3:17:55and what i'll do is i'll move the
- 3:17:57private key so i'll say move id
- 3:18:00rsa to uh
- 3:18:02sorry to my desktop and i'll hit enter
- 3:18:05and now if i try and log in so i say ssh
- 3:18:08uh admin
- 3:18:10sorry uh
- 3:18:12states
- 3:18:14enter you can see it logs in just fine
- 3:18:16however if if i didn't know the location
- 3:18:18what i would say is for example let me
- 3:18:21just exit i would say for example if i
- 3:18:23was logged in on another computer
- 3:18:25i would then say uh so again let me just
- 3:18:28go on to my desktop here
- 3:18:31if i wanted to specify a private key for
- 3:18:33logging in i would say ssh i and then i
- 3:18:36would say id rsa and then i say admin at
- 3:18:42192.168.1.1138 enter and typically what
- 3:18:45you want to do is you want to ensure
- 3:18:46that your private key has permissions
- 3:18:49you want to ensure that it can only be
- 3:18:51read
- 3:18:52by the current user and not by the group
- 3:18:54or all other users on the system so a
- 3:18:57great precaution or a great way of doing
- 3:18:59this is saying chmod 400
- 3:19:02id rsa and that will essentially protect
- 3:19:04your private key right so that is
- 3:19:07essentially how to you know set up ssh
- 3:19:10uh and how to copy your how to set up
- 3:19:13key based authentication how to copy
- 3:19:15your ssh keys onto the server
- 3:19:17and we cannot talk about you know
- 3:19:19copying remote files or copying you know
- 3:19:21files remotely with ssh so again to do
- 3:19:24this is very simple what i'll do is i'll
- 3:19:26just create a file let's say touch test
- 3:19:28dot ext and i'll cat fc uh password into
- 3:19:34the test.txt file here and what let's
- 3:19:37say i wanted to copy this test.txt file
- 3:19:40into the ssh server uh what i would do
- 3:19:43is i would use the scp utility so the
- 3:19:45scp is again secure copy so i would say
- 3:19:48scp and then i would specify the file so
- 3:19:51i'll say touch
- 3:19:52uh sorry test test.txt and then i would
- 3:19:55spare out specify the credentials so it
- 3:19:57say admin 192.168.1.11
- 3:20:00and then i'll specify the location i
- 3:20:02want to save it in so i say home admin
- 3:20:05uh this is on the remote server by the
- 3:20:07way so home uh i can't seem to write
- 3:20:09admin today for some reason and i'll
- 3:20:12essentially hit enter and you can see
- 3:20:14that it actually copied quite quickly so
- 3:20:17now if we try and log in so we say ssh
- 3:20:23one one three uh
- 3:20:24three and eight enter and we list the
- 3:20:27files within the home directory for
- 3:20:28admin you can see that we have the
- 3:20:30test.txt file and if i catch the content
- 3:20:33here it's the
- 3:20:34it's the password information for the uh
- 3:20:37for my client uh right over here which
- 3:20:39is running ubuntu and you can see my
- 3:20:41user accounts
- 3:20:42there so that is pretty much how to use
- 3:20:45ssh how to set it up how to set up
- 3:20:47authentication how to protect uh your
- 3:20:49root user account how to copy files
- 3:20:51securely how to set up key based
- 3:20:53authentication so i hope that was
- 3:20:54comprehensive enough
- 3:21:00so this video is going to be focused on
- 3:21:01essentially getting you to fully learn
- 3:21:04and of course utilize curl to its
- 3:21:07maximum potential and i'm going to be
- 3:21:09covering as many commands as i possibly
- 3:21:10can now that being said curl has a lot
- 3:21:13of functionality that you need to
- 3:21:15explore on your own as well but i'll be
- 3:21:17covering some of the most important bits
- 3:21:19of functionality that it does offer to a
- 3:21:21normal user or a power user as well
- 3:21:24so uh without any further ado let's get
- 3:21:26started so for those of you who have
- 3:21:28never heard of curl curl is essentially
- 3:21:30a utility that allows you to transfer
- 3:21:32data to or from a network server using
- 3:21:35one of the supported protocols now the
- 3:21:37protocols that it does support are http
- 3:21:40https ftp
- 3:21:42ftps you also have your sftp you have
- 3:21:46tftp telnet et cetera et cetera now
- 3:21:48there are various other
- 3:21:49protocols that it does support in
- 3:21:51addition to the ones i've just mentioned
- 3:21:53uh but i will get into that later
- 3:21:55now the great thing about curl is that
- 3:21:57it is a multi-platform tool which means
- 3:22:00uh it works on linux uh mac os and
- 3:22:02windows now i'm gonna be covering how to
- 3:22:04use it on linux but of course the
- 3:22:06commands are pretty much the same now in
- 3:22:08regards to installing uh installing curl
- 3:22:10it as far as i know it comes
- 3:22:12pre-installed with most akia linux
- 3:22:14distributions uh but if you want to
- 3:22:16install it whether or not using the
- 3:22:18aptitude package manager you can use the
- 3:22:20sudo apt-get install curl command and if
- 3:22:23you are if you're using an archbase
- 3:22:25distribution you can use the pacman s
- 3:22:28command to install it and the the name
- 3:22:30of the package is curl all right if you
- 3:22:32are using a mac os installation or mac
- 3:22:35os as your operating system you can use
- 3:22:37the brew install command so that is brew
- 3:22:40install and curl all right and that's
- 3:22:43pretty much uh simple right over there
- 3:22:44with windows you need to download an
- 3:22:46executable or a bin file if i'm not
- 3:22:48wrong and you need to save it in your
- 3:22:49windows directory and of course from
- 3:22:51that you can directly launch it from
- 3:22:53your command prompt
- 3:22:55that being said let's get started now
- 3:22:57curl as i mentioned comes pre-installed
- 3:22:59with most linux distributions so let me
- 3:23:01just clear the terminal here and i'll
- 3:23:03maximize it so we can see what's going
- 3:23:05on
- 3:23:06all right so the basic syntax is as
- 3:23:08follows but before we do that let's open
- 3:23:10up the help menu you can explore the
- 3:23:12help menu if you are if you're really
- 3:23:14looking for a bit more functionality or
- 3:23:16you're looking for specific functions as
- 3:23:19you can see it's a very comprehensive
- 3:23:20tool and i'm primarily going to be
- 3:23:22covering uh the basic commands that you
- 3:23:24that allow you to utilize it quite well
- 3:23:27uh that being said many people ask me
- 3:23:29how i personally learn about a command
- 3:23:31that or a tool that i'm not familiar
- 3:23:33with i personally use the man or the
- 3:23:36manual for each of these tools so the
- 3:23:38manual contains a very very good
- 3:23:40description of of all the bits of
- 3:23:42functionality in regards to a tool uh
- 3:23:45and all linux tools pretty much uh come
- 3:23:47with a manual and the manual is
- 3:23:49extremely useful so if you you want to
- 3:23:51check them out go ahead and do it i
- 3:23:53really really recommend it when learning
- 3:23:55how to uh how to use a tool
- 3:23:57all right so let's talk about the basic
- 3:23:59queries you can perform with curl all
- 3:24:01right so when i talk about interacting
- 3:24:02with the various protocols this
- 3:24:04particular video is going to be focused
- 3:24:06on http and https i know there is
- 3:24:09ftp functionality but i'm not going to
- 3:24:11be getting into that because that's more
- 3:24:13that's where things sort of get a bit
- 3:24:15different but for now let's focus on
- 3:24:17those two protocols all right so when
- 3:24:19performing a basic query of a url uh you
- 3:24:22essentially type in curl and then the
- 3:24:24url so for example if i type in
- 3:24:27hsploit.com here
- 3:24:29and hit enter what will happen is this
- 3:24:31will essentially fetch the content of
- 3:24:33the specified url so for example i've
- 3:24:36hit curl https hsplugged.com and it will
- 3:24:38essentially return to me the content of
- 3:24:41the entire web page now you might be
- 3:24:42wondering well how can we verify this
- 3:24:45and that's where we get into essentially
- 3:24:47saving your output into a file or
- 3:24:49downloading files so i can say for
- 3:24:51example curl and if i want to output the
- 3:24:54uh the output of this command or the
- 3:24:55contents of this query i can say i can
- 3:24:57use the lowercase o and i can then say i
- 3:25:00specify the directory i want to save it
- 3:25:02in so home alexis desktop
- 3:25:04and i'll just uh sorry that is desk that
- 3:25:07is desktop and i'll just call it uh
- 3:25:09hsploit
- 3:25:12dot html and after that i'll type in
- 3:25:14hsflight.com
- 3:25:16right over here that is the url now it's
- 3:25:18very important to specify
- 3:25:20uh the protocol that you're using so for
- 3:25:22example if a website is http you won't
- 3:25:24need to specify to get it if it is using
- 3:25:27the https protocol it is very important
- 3:25:29but i'll get into redirection in a
- 3:25:31second so
- 3:25:33https.com and we hit enter and it's
- 3:25:35going to give you this little status
- 3:25:37right over here essentially giving you
- 3:25:39an update as to what is the current
- 3:25:41status of the entire process here now
- 3:25:43for some reason it's taking quite a
- 3:25:44while now
- 3:25:45but we'll wait for it to complete and
- 3:25:47there we are so
- 3:25:48let me explain a bit of the uh the the
- 3:25:51structure of this little status menu or
- 3:25:54table here so for example you have the
- 3:25:55total amount to be downloaded uh the
- 3:25:58amount received the average download
- 3:26:00speed the upload speed the the total
- 3:26:03time are the time spent and the time
- 3:26:05left and uh right now if we cat
- 3:26:07uh the the hs flight dot um well
- 3:26:10actually if we need to go into our
- 3:26:12desktop here uh so if we capped
- 3:26:14hsploit.html here you can see the entire
- 3:26:16contents now if we open that up here if
- 3:26:19i open that up with uh with chrome for
- 3:26:21example let me just open this up where
- 3:26:23is google chrome
- 3:26:24um
- 3:26:26where is google chrome here there we are
- 3:26:28google chrome if i just open that up
- 3:26:30here in a web page you can see that
- 3:26:31pretty much it has all the content of my
- 3:26:34website so each exploit.com and it's
- 3:26:36pretty cool that it does save the entire
- 3:26:38contents of the html file here now of
- 3:26:40course this is going to um this is going
- 3:26:42to leave out
- 3:26:44extra bits of files in regards to the
- 3:26:46the web page but this is a great way of
- 3:26:48saving the contents of a query now that
- 3:26:50could be for any other protocol it not
- 3:26:52it does not necessarily need to be for
- 3:26:54the http or the https protocols all
- 3:26:57right now when we talk about downloading
- 3:26:59files
- 3:27:00that is pretty much how it goes for a
- 3:27:02web page or for a query so let me just
- 3:27:05remove the hsp.html mind you i could
- 3:27:07have saved it as a txt file i simply i'm
- 3:27:10saving it so that i can use it at a
- 3:27:12later time now you can also use curl to
- 3:27:15download files from the web which is
- 3:27:17really really awesome and that's
- 3:27:18primarily why i have the ubuntu page
- 3:27:20open here because i want an example to
- 3:27:22use so for example if i wanted to
- 3:27:23download the ubuntu iso
- 3:27:26i go to the download page and i select
- 3:27:27the air version 18.4
- 3:27:2918.04 lts
- 3:27:32and it's going to start the download so
- 3:27:33if i just going to show all downloads
- 3:27:35here and let me just copy the link here
- 3:27:37the download link so i can go into curl
- 3:27:40and i can say for example
- 3:27:42i can give the file name a new name or i
- 3:27:44can just download it directly so let me
- 3:27:46explain the two ways of doing it so for
- 3:27:48example i can say curl
- 3:27:50i can output the uh i cannot i can say
- 3:27:53download this file as ubuntu
- 3:27:56iso
- 3:27:57dot iso sorry iso and then i i paste in
- 3:28:01the the download link and what that is
- 3:28:03going to do is that it's going to
- 3:28:04download the file and save it as ubuntu
- 3:28:07iso dot iso now the extension is very
- 3:28:09important because if you get that wrong
- 3:28:11it's going to save it as a different
- 3:28:12file type all right so if i enter you
- 3:28:14can see it's going to start the download
- 3:28:16and there we are we can see that the
- 3:28:18total amount to be downloaded is one uh
- 3:28:19194 megabytes which is about 1.9
- 3:28:22gigabytes and you have the received the
- 3:28:24download speed the average download
- 3:28:26speed and the current download speed
- 3:28:27right over here the time left etc etc
- 3:28:30now you can see that my internet speed
- 3:28:32is pretty bad right now but that's
- 3:28:33primarily because i am updating one of
- 3:28:35my systems so i do apologize for that so
- 3:28:38if we check the desktop you can see we
- 3:28:39have the ubuntu iso over here which does
- 3:28:42prove that it does work all right now
- 3:28:44the other way of doing it
- 3:28:46let me just remove the ubuntu iso.iso
- 3:28:48file there the other way of doing it is
- 3:28:50by downloading it with its original file
- 3:28:52name which is specified on the on the
- 3:28:54web server so
- 3:28:56to do that i simply type in curl and i
- 3:28:58use the capital o and i paste in the
- 3:29:00download link and hit enter and that is
- 3:29:03going to download the file with its
- 3:29:04original download name so you can see
- 3:29:06ubuntu 18.04.2
- 3:29:08uh desktop amd 64-bit dot iso or md64
- 3:29:13dot iso all right so that is
- 3:29:15pretty much how to download files and
- 3:29:17now that i've explained that
- 3:29:19we cannot talk about redirects because
- 3:29:20redirects are extremely important so
- 3:29:23if i just get rid of ubuntu here so if a
- 3:29:26website is redirecting to another url
- 3:29:29it's very important that you know how to
- 3:29:31specify this to curl and why is that
- 3:29:33important so in many cases redirects may
- 3:29:36be set up and of course that is
- 3:29:37specified by the http
- 3:29:39300 request or the it could be any 300
- 3:29:42requests mostly theo one or three or
- 3:29:44three
- 3:29:44and it's very important that you know
- 3:29:47how to specify this with call now the hd
- 3:29:49the http protocol syntax is very
- 3:29:51important in curl and you can do this by
- 3:29:53using the l command or the capital l
- 3:29:55command sorry so for example
- 3:29:58if my website was uh if the
- 3:30:00urlhsflight.com
- 3:30:02was uh so if i say
- 3:30:04hsplug.com
- 3:30:06was redirecting to another url to
- 3:30:09another url and i wanted to specify this
- 3:30:11to curl i would use the l command now i
- 3:30:13know that my website is not and a great
- 3:30:16way of demonstrating this is by using uh
- 3:30:18the so for example if i say curl
- 3:30:21http
- 3:30:23hslight.com
- 3:30:26right over here and hit enter and we'll
- 3:30:28give that a few seconds here and i'll
- 3:30:30explain what's happening in a second so
- 3:30:32that you can see the importance of
- 3:30:33specifying uh the l parameter if there
- 3:30:36is a redirect so you can see i got no
- 3:30:38result and that's because curl is going
- 3:30:40to http and that's the importance of
- 3:30:43protocols with curl you need to specify
- 3:30:44the correct protocol irregardless of
- 3:30:46whether or not you're using ftp
- 3:30:48http https so my website is https now my
- 3:30:53website by default will redirect however
- 3:30:55you need to specify that with curl i do
- 3:30:57apologize for that and let me just clear
- 3:30:59the notifications here
- 3:31:01so again i i as i mentioned you need to
- 3:31:03specify this with girls so i can say
- 3:31:05curl and i use the l command over here
- 3:31:08and then i specify http
- 3:31:11uh and then i say hsplight.com here
- 3:31:13right over here and hit enter
- 3:31:15and that will essentially redirect me to
- 3:31:17the appropriate webpage and
- 3:31:19as you can see right over here we get
- 3:31:21the entire contents of the
- 3:31:23hsp.com website or html file rather so
- 3:31:26that is how to do essentially how to
- 3:31:29work around um how to work around
- 3:31:31redirects
- 3:31:32all right now another bit of important
- 3:31:35another important command sorry is the
- 3:31:37querying response headers so you can
- 3:31:39also view and analyze the response
- 3:31:42headers being sent by a particular web
- 3:31:43server
- 3:31:44and this can help in web assessment so
- 3:31:46for example if i wanted to query the
- 3:31:48response uh the response headers i'm
- 3:31:49being sent back by the web server i can
- 3:31:52say curl
- 3:31:53capital i and i can say
- 3:31:55https
- 3:31:58hs plate.com
- 3:32:01and i can just hit enter and what's
- 3:32:03going to happen here is it will give it
- 3:32:05a few seconds this is going to depend on
- 3:32:07uh varyingly depending on your on your
- 3:32:10particular web server so you can see it
- 3:32:11gives us the protocol we have cookies
- 3:32:13here uh we have the php version so we're
- 3:32:16getting important information now uh
- 3:32:18looks like we have some wordpress json
- 3:32:21files here if i delivered by the cdn or
- 3:32:23the content delivery network
- 3:32:25uh let's look at some important cookies
- 3:32:28here that might give us a bit of
- 3:32:29information in regards to the website so
- 3:32:30an important bit of information here and
- 3:32:32of course i'm using this as an example
- 3:32:35is the dwqa
- 3:32:37and this is my question and answer
- 3:32:39plugin that i use and you can see that
- 3:32:41it has an anonymous cookie that's being
- 3:32:42set here and that can give you
- 3:32:44information as to a bit more of how the
- 3:32:46web application is working so that is
- 3:32:48how to query the response that is being
- 3:32:50sent by the server and of course you can
- 3:32:51see right over here this is a cloudflare
- 3:32:53server and we have the cfra which is the
- 3:32:56cloudflare array
- 3:32:57that essentially uh uh
- 3:32:59is telling cloudflare uh what uh it's
- 3:33:02giving information to cloudflare about
- 3:33:04the particular client that is accessing
- 3:33:06the web server all right now that is
- 3:33:08very interesting however it really gets
- 3:33:10interesting because girl can also do a
- 3:33:12really cool thing it can also allow you
- 3:33:14to view the request headers and the
- 3:33:16connection details so you can view the
- 3:33:17tls handshake et cetera et cetera so if
- 3:33:20i say curl
- 3:33:21v and i say curl v
- 3:33:24https
- 3:33:25and they say exploit.com here and hit
- 3:33:27enter you can see that we can view the
- 3:33:29entire tls and shake which is really
- 3:33:32really unique and awesome so
- 3:33:34let me just see if i can figure uh which
- 3:33:37is wait which is right over here so
- 3:33:39there we are we can see the the initial
- 3:33:40connection here
- 3:33:42uh we i'm particularly looking for the
- 3:33:44tls uncheck and right over here we can
- 3:33:46see the tls handshake taking place so
- 3:33:48you can see that it is successful and
- 3:33:50this is a great way of identifying um
- 3:33:53problems with the tls uncheck if the
- 3:33:54certificate has an issue so for example
- 3:33:57we have the client hello the server
- 3:33:58hello we then have the encrypted
- 3:34:00extensions being exchanged the
- 3:34:02certificate is being exchanged and then
- 3:34:04verified and then finally the tls
- 3:34:06uncheck is completed you can see that we
- 3:34:08have the version tls version 1.3 and the
- 3:34:11ciphers that are being used or the
- 3:34:13encryption being used
- 3:34:14all right so you also have information
- 3:34:15about these certificates uh expiry date
- 3:34:18uh when it was actually registered uh
- 3:34:20the issuer all that good stuff so if you
- 3:34:22do want to view
- 3:34:24uh if you do want to view the connection
- 3:34:26details and a bit of an advanced
- 3:34:28information or additional information in
- 3:34:30regards to the connection you can go
- 3:34:32ahead and use the uh the v command
- 3:34:35now the last thing that i want to cover
- 3:34:37in regards to the http and http hts
- 3:34:40protocols is the fact that you can cross
- 3:34:42post requests and many people have seen
- 3:34:44me using this in ctfs particularly when
- 3:34:47i'm essentially brute forcing um
- 3:34:50login pages so
- 3:34:52uh i can give you an example so if i
- 3:34:54wanted to essentially test credentials
- 3:34:56on a website and this can really be in
- 3:34:58any uh i can be using any parameters i
- 3:35:01could be spoofing various cookies all
- 3:35:03that good stuff so for example i can say
- 3:35:05if i wanted to log in to wordpress site
- 3:35:08and i wanted to essentially test various
- 3:35:10credentials i can say for example
- 3:35:12curl
- 3:35:13data and that is the sorry the data that
- 3:35:16we're specifying and then in here i
- 3:35:17would specify log and this is the
- 3:35:19particular syntax for wordpress and the
- 3:35:21password would be equal to i can say
- 3:35:24password here and then i close the uh
- 3:35:27the uh the quotation marks and then i
- 3:35:29specify uh the wordpress page here so i
- 3:35:31can say
- 3:35:33https and you can say
- 3:35:36wordpress.com and i can say wordpress
- 3:35:39login dot php and that is the login page
- 3:35:43right over here and if i hit enter
- 3:35:45and i know this you can see that admin
- 3:35:47is not a valid username or wordpress.com
- 3:35:49etc you get the response so this is a
- 3:35:50great way of testing various pieces of
- 3:35:52data so you can also play around with
- 3:35:54cookies all that good stuff and in this
- 3:35:56case we're simply playing around with
- 3:35:57the login and the password parameters
- 3:35:59here and we specified our own values
- 3:36:02now if you do need to to encode the
- 3:36:04particular parameters you can also use
- 3:36:06burp suite for that so for example
- 3:36:09um let's see if i wanted to go um let me
- 3:36:12just uh turn intercept on here
- 3:36:15if i just went into hsploy.com here so i
- 3:36:18just say it it's exploit.com and it's a
- 3:36:20wordpress login.php
- 3:36:24sorry.php here and i just hit enter and
- 3:36:27uh for some reason we're getting stack
- 3:36:29uh stack
- 3:36:30we're just getting a stack protect here
- 3:36:32in any case uh the what i was getting to
- 3:36:34if you do want to encrypt your url or
- 3:36:36any other parameters you can use the
- 3:36:38control plus u key
- 3:36:43in this video we're going to be looking
- 3:36:45at how to use the uncomplicated firewall
- 3:36:48or as it is commonly known as ufw on
- 3:36:51linux alright so you might be asking
- 3:36:53what exactly is ufw or what is the
- 3:36:56uncomplicated firewall if it isn't
- 3:36:58already self-explanatory well
- 3:37:01ufw or the uncomplicated firewall acts
- 3:37:04as an interface to ip tables and is
- 3:37:06designed to simplify the process of
- 3:37:09configuring a firewall now you also
- 3:37:11might be asking well what exactly is
- 3:37:13iptables well iptables is an extremely
- 3:37:16flexible firewall utility that was built
- 3:37:19for linux operating systems now you also
- 3:37:21might be asking well why aren't we using
- 3:37:24ip tables why are we using ufw as
- 3:37:26opposed to ip tables well iptables is a
- 3:37:29great tool that offers great
- 3:37:30functionality when it comes down to
- 3:37:32configuring firewalls however it can be
- 3:37:34difficult for beginners to learn how to
- 3:37:36use it properly when configuring a
- 3:37:38firewall as a result ufw is well suited
- 3:37:42for beginners and as a result they can
- 3:37:44use they can learn how to use a firewall
- 3:37:46or to configure a firewall really really
- 3:37:48easily and they can learn about rules
- 3:37:50etc they get the the general idea behind
- 3:37:53a firewall all right so ufw is a is a
- 3:37:57great firewall that is designed to be
- 3:37:59run on hosts or servers uh but it's only
- 3:38:02doubtful in the extent is in the extent
- 3:38:04uh it offers in in terms or in regards
- 3:38:07to functionality what i mean by this it
- 3:38:10it only goes so far as uh
- 3:38:13as allowing you to block or allow
- 3:38:15connections to and from uh to and from
- 3:38:17the server so incoming and outgoing and
- 3:38:19you can also block ip addresses ports
- 3:38:21etc and entire an entire subnet
- 3:38:24which i'll get into in a second
- 3:38:26all right
- 3:38:28so the purpose of this video the purpose
- 3:38:30of this video is to teach you how to use
- 3:38:31ufw and all the comments that you need
- 3:38:33to know to get started and to fully
- 3:38:35utilize it to its uh due to your
- 3:38:38advantage really so this will include
- 3:38:39commands such as allowing and blocking
- 3:38:41various services by port uh and their
- 3:38:44source ip addresses and this video
- 3:38:46should be used as a reference so if this
- 3:38:48is your first time with ufw you can
- 3:38:50definitely find something that you
- 3:38:51haven't you that you didn't know in this
- 3:38:53video if this is your if you're already
- 3:38:55an experienced use of ufw hopefully you
- 3:38:57can find something in this video that
- 3:38:59you didn't know already alright so
- 3:39:01without any further ado let's get
- 3:39:03started
- 3:39:04so
- 3:39:05uh installing ufw is very very simple
- 3:39:08now if you are using an ubuntu server or
- 3:39:10you're running ubuntu ufw should be
- 3:39:12pre-installed on it if it isn't getting
- 3:39:14installed on any other distribution is
- 3:39:16very very simple use your aptitude
- 3:39:18package manager so sudo apt-get install
- 3:39:22ufw i already have mine installed so
- 3:39:24it'll check for an update if there isn't
- 3:39:26an update it's not going to update it
- 3:39:28and it's going to give me the results
- 3:39:29here all right so once it is installed
- 3:39:31we are ready to begin
- 3:39:33now the important bits of using ufw are
- 3:39:36always knowing its state or its status
- 3:39:38all right so currently i have ufw
- 3:39:41disabled it is not running and if i
- 3:39:43wanted to know that i would simply type
- 3:39:45in
- 3:39:46sudo
- 3:39:47ufw status now it is very important to
- 3:39:50precede the ufw command with sudo if
- 3:39:53you're not using a root user in my case
- 3:39:55i'm using the root user so i don't need
- 3:39:58to use the sudo command but in any case
- 3:40:00i will use it so that it becomes a good
- 3:40:02practice with you and i don't recommend
- 3:40:05running efw from the root user but this
- 3:40:07is a simple video for demonstration all
- 3:40:10right so i'm going to hit enter it's
- 3:40:11going to tell you the status of the ufw
- 3:40:14or the uncomplicated firewall is
- 3:40:16inactive which is great all right now i
- 3:40:19can also check an additional i can get
- 3:40:21more information from the status command
- 3:40:23by typing in verbose which will give me
- 3:40:25more information in regards to the rules
- 3:40:27that are currently active now as you
- 3:40:29guessed it will not display anything
- 3:40:31because we haven't set any particular
- 3:40:33rules and the if the firewall is
- 3:40:35currently not active so nothing really
- 3:40:38special there and the last status
- 3:40:40command that is very very popular is to
- 3:40:42is to show the status the numbered
- 3:40:44status so that you have an idea of what
- 3:40:46uh what rules are currently running and
- 3:40:48their number so that you can terminate
- 3:40:50or delete them all right so that's what
- 3:40:52what it's there for now of course these
- 3:40:54don't make any sense right now because
- 3:40:56the the current status of the firewall
- 3:40:58is inactive once we activate it or once
- 3:41:01it is active we will be able to get a
- 3:41:03whole lot more information from them all
- 3:41:05right so i'm going to enter again you'll
- 3:41:06see it's going to tell you that it is
- 3:41:08inactive and that is fine
- 3:41:10all right
- 3:41:11so let's talk about enabling disabling
- 3:41:14and resetting ufw so enabling ufw is
- 3:41:16very simple sudo ufw and enable and that
- 3:41:20will enable the firewall and it'll give
- 3:41:22you the little status over here the
- 3:41:24firewall is active and is enabled on
- 3:41:27system startup which is excellent so
- 3:41:28that it is always active and if you are
- 3:41:30running a server that is huge for you
- 3:41:33all right so disabling it is very very
- 3:41:35simple we simply type in
- 3:41:37disable and we hit enter
- 3:41:40all right and that will tell you that
- 3:41:41the firewall is stopped and disabled on
- 3:41:43on system startup
- 3:41:45now when i talk about resetting the the
- 3:41:47ufw or the uncomplicated firewall this
- 3:41:50is in regards to the rules that you
- 3:41:51might have set now please do use caution
- 3:41:54with the reset command the reset command
- 3:41:56is there to to help you out if you have
- 3:41:58made a mistake in configuring your
- 3:42:00firewall now if you already have a
- 3:42:01working firewall and you only want to
- 3:42:03delete a particular rule do not use the
- 3:42:05reset command because that will reset
- 3:42:08your firewall to the default uh to the
- 3:42:10default configuration that it came with
- 3:42:12pre-installed or installed or the the
- 3:42:14configuration it came with installed all
- 3:42:16right so if i type in sudo ufw
- 3:42:20uh ufw reset that will reset it and
- 3:42:22it'll tell you that which is very good
- 3:42:24resetting all the rules to the installed
- 3:42:26defaults proceed with operation
- 3:42:29y or n for yes or no hit yes to reset it
- 3:42:33and there you are so there is a small
- 3:42:35fyi if in case you wanted to know that
- 3:42:37and you've messed up
- 3:42:38in this video and you want to reset it
- 3:42:40there you are
- 3:42:41all right so what we're going to do is
- 3:42:42we're going to start off we
- 3:42:44understanding the default policies uh
- 3:42:46for the ufw or the uncomplicated
- 3:42:49firewall
- 3:42:50all right so
- 3:42:52uh the default policies uh for ufw are
- 3:42:56as follows uh now before we do that let
- 3:42:59me explain something so ufw
- 3:43:01uh by default will it will deny all
- 3:43:04incoming connections but will allow all
- 3:43:06outgoing connections so what is
- 3:43:08happening here is sudo ufw
- 3:43:11and you can you can always use this to
- 3:43:13to restore it to its default policies so
- 3:43:16sudo ufw
- 3:43:18default
- 3:43:20deny
- 3:43:21incoming
- 3:43:23all right so that is the default uh that
- 3:43:25is the default connection for incoming
- 3:43:27or the default connection status for all
- 3:43:29incoming connections so by default ufw
- 3:43:32will deny all incoming connections and
- 3:43:34it will
- 3:43:35it will allow
- 3:43:37all outgoing connections
- 3:43:41so it will allow all default outgoing
- 3:43:43connections and of course you can change
- 3:43:45this to whatever you want if you want
- 3:43:47incoming connections to be allowed while
- 3:43:49the firewall is active then you can also
- 3:43:51do that as well so i can say default
- 3:43:53allow
- 3:43:54incoming all right which is not the
- 3:43:57smartest thing to do if you're running
- 3:43:58this on a server you want to manage what
- 3:44:01connections are incoming
- 3:44:02in case your your server is being
- 3:44:04attacked but that is a very very
- 3:44:05different story and hopefully i'll make
- 3:44:08a video on that later on in configuring
- 3:44:10a server for security
- 3:44:12in this case we'll just leave them to
- 3:44:14its defaults all right which are are
- 3:44:16going to be set by default you don't
- 3:44:17need to set them i'm simply explaining
- 3:44:19to you how to do it and how to change
- 3:44:21them if you want to change them all
- 3:44:22right so this gate is great for normal
- 3:44:24systems uh but when it comes down to
- 3:44:27servers it becomes a little bit
- 3:44:28different and you want to be able to
- 3:44:30manage the incoming connections in
- 3:44:33regards to services and ports and the ip
- 3:44:35addresses that are going to be allowed
- 3:44:37to connect to your computer or your
- 3:44:39server
- 3:44:40all right
- 3:44:41so what i want to do is
- 3:44:43the first thing i want to do is i'm
- 3:44:44going to talk to talk about services and
- 3:44:46ips all right so if i want to allow an
- 3:44:49incoming ssh connection uh how do i do
- 3:44:52that well it's very simple so sudo ufw
- 3:44:56allow ssh all right and this is going to
- 3:44:58allow all ssh connections it's going to
- 3:45:00allow in incoming ssh connections all
- 3:45:03right which is okay if
- 3:45:05as long as you have a private key and
- 3:45:07you've properly secured the ssh
- 3:45:09connection and and the authentication
- 3:45:12all right so i'm going to hit enter it's
- 3:45:13going to tell me rule is updated
- 3:45:15fantastic you can also do this by typing
- 3:45:17in the port so i can say sudo ufw allow
- 3:45:2122 and it's going to update uh the rules
- 3:45:24accordingly now if i want to if i want
- 3:45:26to disable you ssh incoming ssh i can
- 3:45:29say sudo ufw deny
- 3:45:32ssh all right and i'm going to hit enter
- 3:45:34it's going to tell me the rule is
- 3:45:35updated which is which is also very very
- 3:45:37good and of course you can do that
- 3:45:39with the port as well but with services
- 3:45:42these are the particular services the
- 3:45:44services by the name in which they are
- 3:45:46sorted so ssh is going to be known as
- 3:45:48ssh and it knows that ssh uses port 22.
- 3:45:52all right let's talk about uh working
- 3:45:53with port 80 or http connections
- 3:45:56so that is what uh unencrypted web
- 3:45:59servers use and the connections can be
- 3:46:01allowed with the following command so
- 3:46:03you can type in sudo ufw
- 3:46:05uh allow
- 3:46:07allow http and we hit enter it's going
- 3:46:10to update the rules and you can also do
- 3:46:12it with using uh you can also do it
- 3:46:14using the port which is port 80 hit
- 3:46:16enter and there you are in my case i'm
- 3:46:18going to deny this so i'm going to say
- 3:46:20deny http hit enter and we're good again
- 3:46:23all right so what i'm going to do is
- 3:46:26before we actually continue i'm going to
- 3:46:27leave some services running so that when
- 3:46:29i enable the firewall you'll be able to
- 3:46:31see them when i when i essentially check
- 3:46:33the status
- 3:46:34all right so i'm going to say
- 3:46:37ufw
- 3:46:38enable or sorry allow
- 3:46:41allow ssh because i want to allow ssh
- 3:46:44connections
- 3:46:45sorry about that my typing is pretty bad
- 3:46:47right now allow ssh there we are
- 3:46:49fantastic and we can move on to the next
- 3:46:51protocols and services
- 3:46:53now talking about https or port 443 that
- 3:46:56is again uh what encrypted web servers
- 3:46:58use and can be allowed with the
- 3:46:59following command so you can type in
- 3:47:01sudo
- 3:47:03allow https and hit enter and that's
- 3:47:06going to allow https connections again
- 3:47:08that can be replicated or duplicated
- 3:47:10with the port 443 in this case i'm just
- 3:47:13going to deny the connection so i'm just
- 3:47:16going to https and there we are so the
- 3:47:18rules are going to be updated
- 3:47:19successfully for ipv4 and ipv6 as well
- 3:47:22that is why you have rules updated for
- 3:47:24both the protocols over here
- 3:47:26all right now if you want to allow both
- 3:47:28uh http and https you can do that in
- 3:47:32you can do it in one command and that is
- 3:47:33done by typing sudo ufw allow and you
- 3:47:37can also deny it as well so proto the
- 3:47:39protocol is going to be tcp
- 3:47:42proto is tcp you can also change that
- 3:47:44depending on what protocol you're using
- 3:47:45so from any
- 3:47:47from any target or you can also use the
- 3:47:50ip so from this particular target but
- 3:47:53i'll get to that in a second so we're
- 3:47:54going to say from any any computer we
- 3:47:56are simply going to allow the connection
- 3:47:59from any
- 3:48:00to any
- 3:48:02port
- 3:48:03uh to any port and we specify the port
- 3:48:06support 80 and 443 hit enter the rules
- 3:48:09updated so we can also deny it as well
- 3:48:11which is what i'm gonna do because i
- 3:48:12don't want that running so deny and
- 3:48:15voila all right so that is how to run it
- 3:48:17in one command and the the key words
- 3:48:19here are going to be the allow and deny
- 3:48:22that is the most important bit here all
- 3:48:24right if you're talking about ftp that
- 3:48:26is again uftp uh sorry um
- 3:48:28uh ufw nor am i talking ufw
- 3:48:32uh ufw allow ftp or port 21
- 3:48:36and that can also be denoted by port 21
- 3:48:39tcp hit enter and it's going to uh
- 3:48:42because it already exists we can then
- 3:48:44say deny
- 3:48:46and you need to specify with ftp that
- 3:48:48we're using it in tcp so deny rules
- 3:48:51updated successfully and that is how to
- 3:48:53configure or enable and disable ftp
- 3:48:55connections
- 3:48:56all right now let's move on to ip
- 3:48:58addresses now before we actually move on
- 3:49:01to ip addresses four services this is
- 3:49:03all done through the port and also
- 3:49:05through the name so if you're running
- 3:49:06pop3 a pop3 mail server you can also do
- 3:49:09it as well if you're running mysql i can
- 3:49:11say ufw
- 3:49:12allow
- 3:49:143306 that is a mysql a database and i'm
- 3:49:17just going to deny it or i'll leave that
- 3:49:19running so that we can also check the
- 3:49:20status i don't have a mysql server
- 3:49:23running on this computer but that's how
- 3:49:25you one would do it so uh in most cases
- 3:49:27you want to deny connections to your ad
- 3:49:30to your
- 3:49:31to your mysql database so in this case
- 3:49:33i'm going to say 3306 deny any
- 3:49:35connections to that particular port and
- 3:49:37of course i can specify the eyepiece
- 3:49:39with my previous command that i showed
- 3:49:41you right over here so i can say ufw
- 3:49:43deny protocol tcp
- 3:49:45from any to uh
- 3:49:47from any to any port and then specify
- 3:49:493306 here hit enter the rules are going
- 3:49:52to be updated so we can deny all
- 3:49:54connections to our sql database which is
- 3:49:57hugely important that's why you have
- 3:49:59open databases running and available to
- 3:50:01be accessed publicly on show then they
- 3:50:04can simply be exposed so this is one of
- 3:50:05the things you must do on your firewall
- 3:50:08all right so getting back to ip
- 3:50:10addresses again it's very very simple so
- 3:50:12if i want to allow incoming connections
- 3:50:13from a particular ip address i can
- 3:50:15simply type in ufw
- 3:50:17allow and i type in uh the ips so allow
- 3:50:20from
- 3:50:22192.168.1.1 which is my gateway or
- 3:50:24access point iep address which is
- 3:50:26important because if i don't allow
- 3:50:27incoming connections from it
- 3:50:30i essentially won't be able to to get
- 3:50:32any internet access so i'm going to hit
- 3:50:33allow which is important
- 3:50:37and and that's very very important as i
- 3:50:39mentioned when your firewall is active
- 3:50:41because if you want to allow incoming
- 3:50:42connections you need to specify what ip
- 3:50:44or what ip subnet they may belonging to
- 3:50:47so uh what an example i can give you
- 3:50:50here is if you want to specify a
- 3:50:51particular port uh for a particular ip
- 3:50:54address for example i i only want the ip
- 3:50:58address
- 3:50:59192.168.1.103 to access ssh i can type
- 3:51:02in the following so i say sudo ufw
- 3:51:06allow from 192.168.1.103
- 3:51:10to any port
- 3:51:12to any port 22. so this will only allow
- 3:51:15uh this particular ip address to access
- 3:51:18the as this the ssh service i'm going to
- 3:51:20enter it's going to say rules are
- 3:51:22updated now if you're wondering what uh
- 3:51:24the ip address 192.168.1.103
- 3:51:27is my windows operating system and i
- 3:51:30usually connect to my cali operating
- 3:51:31system to it remotely via uh via putty
- 3:51:35all right so that is a good rule to have
- 3:51:38uh when talking about subnets it's very
- 3:51:39very simple again so sudo ufw uh allow
- 3:51:44from and we specify the subnet range
- 3:51:46here 182.968.1.1
- 3:51:49uh and 24 but i don't want to do that
- 3:51:51because i only want particular ip
- 3:51:53addresses
- 3:51:54uh to essentially uh to be allowed in
- 3:51:57regards to incoming connections so i'm
- 3:51:58gonna i'm not gonna hit enter but that
- 3:52:00is how to specify a particular subnet
- 3:52:03you can also disable or deny a
- 3:52:05particular connections
- 3:52:06all right so
- 3:52:08we have already talked about denying uh
- 3:52:10access and again it is all in regards to
- 3:52:13what you want to do in regards to the ip
- 3:52:15so what i can say for example if i
- 3:52:17wanted to allow a particular subnet
- 3:52:19to access the mysql database i can say
- 3:52:22for example
- 3:52:24sudo
- 3:52:25ufw
- 3:52:26allow
- 3:52:28from
- 3:52:29192.68.1.1.1
- 3:52:33and 24 and to any
- 3:52:37any port
- 3:52:39i can say any port
- 3:52:413306 of course that is a very stupid
- 3:52:44thing to do so i'll just keep it to port
- 3:52:4622 with this which is ssh so all of my
- 3:52:48computers in my subnet should be able to
- 3:52:50access this computer via the ssh port
- 3:52:53only i'm going to hit enter and it's
- 3:52:55going to tell me rule change after
- 3:52:56normalization because we already had it
- 3:52:58active so it is changed and updated the
- 3:53:01rule
- 3:53:02all right so let's talk about deleting
- 3:53:03rules because that is essentially as far
- 3:53:05as it will go in regards to allowing in
- 3:53:07denying rules to uh incoming and
- 3:53:10outgoing connections
- 3:53:11to and from your firewall so we've
- 3:53:13looked at allowing and denying ports
- 3:53:15services and ip addresses let's talk
- 3:53:17about deleting particular rules so now
- 3:53:19that we've set our rules we can
- 3:53:21essentially enable the firewall now so
- 3:53:23i'm going to say sudo
- 3:53:25sorry about that sudo
- 3:53:28sudo enable and we type in uh sudo ufw
- 3:53:32enable sorry about that
- 3:53:33ufw enable i was getting a bit confused
- 3:53:36there with ip tables you have w enable
- 3:53:38and that's going to enable the firewall
- 3:53:41excellent so now we can check the status
- 3:53:43all right so the status as i mentioned
- 3:53:44is very very simple to check uh which by
- 3:53:47the way is going to include the number
- 3:53:48status so the default status is sudo ufw
- 3:53:53status
- 3:53:54gonna hit enter and it's gonna give you
- 3:53:56the current status of the firewall all
- 3:53:58right so
- 3:53:59tcp
- 3:54:00is going to be allowed which is port 22
- 3:54:02which is as it is going to be allowed
- 3:54:05which is incoming
- 3:54:07it's going to allow
- 3:54:08tcp our weight we have port 80 deny
- 3:54:11allow for for it again so incoming
- 3:54:14outgoing uh the same goes for what we
- 3:54:17had set for um
- 3:54:20the rule set for both
- 3:54:22uh http and https we had set our ftp
- 3:54:25rule set here we'd set our mysql
- 3:54:28database rule set here to deny
- 3:54:31again we had set it
- 3:54:33via tcp remember it's very important to
- 3:54:35specify the protocol
- 3:54:37uh we then have again we set the rules
- 3:54:39to now a particular iep address remember
- 3:54:42from here they were all from anywhere or
- 3:54:44any particular source
- 3:54:45so allow all connections coming from
- 3:54:48my access point uh allow all ssh
- 3:54:51connections in coming from this
- 3:54:53particular ip
- 3:54:54allow any incoming ssh connections from
- 3:54:57any particular ip in this subnet which i
- 3:54:59set incorrectly it should have been one
- 3:55:01not zero that's my primary
- 3:55:03uh access point that is sitting outside
- 3:55:05of my office
- 3:55:07and then we have all the all these
- 3:55:09settings for uh for the ipv
- 3:55:12ipv6 protocol so that is how to check
- 3:55:14the status now you want to display a bit
- 3:55:16more information we use the verbose
- 3:55:17command
- 3:55:18verbose over here and i'll give you a
- 3:55:20bit more information and this is
- 3:55:22primarily what i like using
- 3:55:24so this is the status that i like using
- 3:55:27the verbose status because it tells you
- 3:55:29the status is active logging is on on
- 3:55:31low
- 3:55:32the default policies are to deny
- 3:55:34incoming and allow outgoing as i
- 3:55:36mentioned
- 3:55:37and now we have for
- 3:55:39for port 22 under the protocol tcp we
- 3:55:42want to allow incoming connections we
- 3:55:44want to allow incoming connections there
- 3:55:46which we is not clever but anyway we had
- 3:55:49set it to any computer on this subnet so
- 3:55:51that makes sense
- 3:55:52we want to deny incoming http
- 3:55:54connections we want to allow then
- 3:55:56incoming http connection and that's
- 3:55:58because i was actually showing you that
- 3:55:59we can actually disable it so
- 3:56:01i can say ufw
- 3:56:04we can say d9
- 3:56:06for 80
- 3:56:07and it's going to update it and we hit
- 3:56:09enter and there we are so now it's it's
- 3:56:11where we're simply denying the rules
- 3:56:12here which is great all right so deny
- 3:56:15deny for both port 80 which is http uh
- 3:56:18for https we are also denying and that's
- 3:56:21simply giving you the the action so
- 3:56:23we're denying or allowing in connections
- 3:56:26and the only ones being allowed inside
- 3:56:28are going to be for the ssh port right
- 3:56:31over here and right over here which are
- 3:56:34going to simply be allowing particular
- 3:56:36ip addresses
- 3:56:38and the entire subnet and all ip
- 3:56:40addresses from the connection now you
- 3:56:41might want to change this if you want to
- 3:56:43only specify a particular subnet
- 3:56:46but that's simply how to check the
- 3:56:48verbose status now if you want to look
- 3:56:50at the numbered status which is
- 3:56:51important because you might want to
- 3:56:52delete a particular rule you do that by
- 3:56:55typing sudo ufw status numbered
- 3:56:57[Applause]
- 3:56:59status numbered
- 3:57:01like so and we hit enter and that is
- 3:57:03going to number all of the rules that
- 3:57:05you had set which is very important if
- 3:57:06you want to delete a particular rule all
- 3:57:08right so let's take a look at how to
- 3:57:10delete a particular rule so if i wanted
- 3:57:12to delete um
- 3:57:14i want to delete
- 3:57:16rule 1 and 2 i can do that so i can type
- 3:57:18in sudo ufw delete
- 3:57:22and i simply type in one for example and
- 3:57:24that is going to ask me do i want to
- 3:57:25delete this particular rule i'm going to
- 3:57:27hit yes and then i'm going to i want to
- 3:57:29delete rule 2 as well and yes and if we
- 3:57:32check the these these status the verbose
- 3:57:35status here we can see yes now we are
- 3:57:38talking now we have uh we we have
- 3:57:40correctly set up our our firewall here
- 3:57:42so it's going to allow
- 3:57:44uh allow in connections we can also get
- 3:57:46rid of that one as well so we're going
- 3:57:48to simply display the status here the
- 3:57:50number status so let's get rid of 1 as
- 3:57:52well
- 3:57:541 here yes we want to get rid of that
- 3:57:57and we showed the status once more
- 3:58:00we can see that yes we are denying all
- 3:58:02connections all http connections all
- 3:58:05https connections and we also set this
- 3:58:08rule which is a duplicate rule of both
- 3:58:09these two so i'm showing you how to do
- 3:58:11it really shortly uh we are denying ftp
- 3:58:13we are denying uh mysql access
- 3:58:17via tcp and also the the port whether it
- 3:58:19be on tcp or udp irregardless the only
- 3:58:22ones we're allowing inside are going to
- 3:58:24be connections coming from this
- 3:58:26particular ip which is the access point
- 3:58:29and this particular ip which is my
- 3:58:30windows operating system and that is
- 3:58:32going to be going to be allowed on port
- 3:58:3322
- 3:58:35uh and the entire subnet is going to be
- 3:58:37allowed on port 22 which is really
- 3:58:39redundant because i should have just
- 3:58:40gotten rid of this one right over here
- 3:58:42but regardless that is how to delete uh
- 3:58:45the particular rules and if you want to
- 3:58:46reset it again resetting it is very very
- 3:58:48simple to take it back to the defaults
- 3:58:50that if is if you have messed up your
- 3:58:53rule set and you want to just start over
- 3:58:55fresh so sudo
- 3:58:57ufw
- 3:58:59reset and we hit enter it's going to ask
- 3:59:01you yes
- 3:59:02and remember the firewall is still
- 3:59:04active so if i just check the status
- 3:59:06it's going to tell us that it is
- 3:59:08inactive that's because we reset it so
- 3:59:10uh if we we uh we enable it so ufw
- 3:59:14enable
- 3:59:16and uh we'll then check the status right
- 3:59:19now we have or we don't have any rule
- 3:59:21set so that is how to use ufw or the
- 3:59:24uncomplicated firewall to allow incoming
- 3:59:26and outgoing connections to ports
- 3:59:29from ip addresses particular ip
- 3:59:30addresses their services how to delete
- 3:59:33particular rules and how to monitor the
- 3:59:35current rules that you have set up so
- 3:59:37that is pretty much all you need to know
- 3:59:38in regards to getting started and and
- 3:59:40fully utilizing ufw you know in in
- 3:59:43regards to configuring a particular
- 3:59:44operating system or a server if that's
- 3:59:46what you're working with so
- 3:59:52in this video i'll be showing you how to
- 3:59:53clear your tracks on linux operating
- 3:59:55systems with a variety of tools all
- 3:59:58right so why is this important now if
- 4:00:00you're a penetration tester you probably
- 4:00:02already know why this is important well
- 4:00:04covering tracks or clearing your tracks
- 4:00:06is the final stage of penetration of the
- 4:00:08penetration testing process so just
- 4:00:10before you start report writing and that
- 4:00:12video is on its way by the way so do
- 4:00:15stay tuned for that so clearing your
- 4:00:17tracks essentially involves clearing or
- 4:00:19wiping all the activity of an attacker
- 4:00:21or you being the attacker that is so as
- 4:00:24to avoid any detection by incident
- 4:00:26response teams or forensic teams all
- 4:00:29right so it is vitally important in the
- 4:00:31penetration testing life cycle
- 4:00:33and of course if you look at it from a
- 4:00:35defensive point of view it can really
- 4:00:37test incident handlers and the blue team
- 4:00:39in their ability to discover an attacker
- 4:00:42in in the system whether they do have an
- 4:00:45intrusion detection detection system or
- 4:00:47not and of course from the perspective
- 4:00:49of the forensics teams it can also test
- 4:00:52them in uh sort of analyzing their skill
- 4:00:54and finding what the attack the attacker
- 4:00:56may have left behind in regards to logs
- 4:00:59uh files or backdoors that they may have
- 4:01:01left running any user accounts that they
- 4:01:03were using etc so this is usually or
- 4:01:06commonly the biggest mistake vector that
- 4:01:08an attacker makes all right or that is
- 4:01:10associated with with attackers and it's
- 4:01:12something that has been ignored over the
- 4:01:14years which is really really weird
- 4:01:15because if you read or pick up any
- 4:01:16penetration testing book
- 4:01:18when they essentially explain the
- 4:01:20penetration testing
- 4:01:22cycle or the stages of penetration
- 4:01:24testing uh clearing your tracks is one
- 4:01:26of them just before you actually write
- 4:01:28up your report and of course if you're
- 4:01:30an attacker this is the final stage of
- 4:01:33uh of your attack and of course leaving
- 4:01:34some persistence behind but that's
- 4:01:36another video for another time
- 4:01:39so
- 4:01:39it's it's very very sad to see that this
- 4:01:41is not taken into consideration i'm not
- 4:01:43talking about this from an attacker's
- 4:01:45perspective but also from a blue team
- 4:01:47perspective where uh this is something
- 4:01:49that is very easy for them because
- 4:01:51attackers are very very sloppy they they
- 4:01:53haven't taken it into consideration so
- 4:01:56it's really good to essentially
- 4:01:57understand how this is done and how it
- 4:01:59can be
- 4:02:00and how it can be analyzed from both
- 4:02:02perspectives from a red team and a blue
- 4:02:04team perspective so
- 4:02:05uh this is usually as i've said the
- 4:02:07biggest mistake of an attacker and this
- 4:02:09is where the professional attackers are
- 4:02:11sorted out from the amateurs so if you
- 4:02:13take a look at most of the biggest hacks
- 4:02:15in the world over the last two years
- 4:02:17most of the the detection has been made
- 4:02:19really really easily from the malware
- 4:02:21that they have left behind which they
- 4:02:23didn't clear they should have cleared
- 4:02:24but of course they were setting it up
- 4:02:26for persistence as i said that's a video
- 4:02:29for another time but again also masking
- 4:02:31malware or backdoors is also a vital or
- 4:02:34an important piece of uh of the forensic
- 4:02:37or well not the forensic the post
- 4:02:38exploitation
- 4:02:40all right now when we talk about uh the
- 4:02:42attacker's perspective uh he or she
- 4:02:45usually needs to
- 4:02:46evade detection if there is an intrusion
- 4:02:48detection system therefore preventing
- 4:02:50any incident response and then he or she
- 4:02:53needs to clear the logs or back doors
- 4:02:55that can be discovered by the forensics
- 4:02:57team all right so what an attacker is
- 4:02:59looking to do and should do is first of
- 4:03:02all clear logs modify registries or
- 4:03:05clear any of the registries that they
- 4:03:07did create and lastly remove any files
- 4:03:10or user accounts that they might have
- 4:03:11been using all right now as i've said
- 4:03:14for this particular video we'll be
- 4:03:15focusing on linux i also want to make an
- 4:03:17independent video for windows because it
- 4:03:19is vitally important to understand how
- 4:03:21to do so on both these operating systems
- 4:03:24and also probably take a look at mac os
- 4:03:27as that is also getting quite uh quite
- 4:03:29popular especially for penetration
- 4:03:31testers
- 4:03:32so i'm going to be covering the
- 4:03:33fundamentals and you can do a lot of
- 4:03:35your own research i'll be covering the
- 4:03:36tools that i've personally used before
- 4:03:40and
- 4:03:41really uh the last piece that i want to
- 4:03:43actually tell you is clearing your
- 4:03:44tracks will also depend on the
- 4:03:46privileges that you have on the system
- 4:03:49and whether or not you're remotely
- 4:03:50attacking the system but for linux it is
- 4:03:52quite universal
- 4:03:54all right now i also have a little or a
- 4:03:56quick tool that i'll be sharing with you
- 4:03:57at the end of the video that is an a
- 4:03:59forensics tool or an anti-forensics tool
- 4:04:01for windows so you can definitely check
- 4:04:03that out
- 4:04:04i'll probably make another video of it
- 4:04:05but for now let's focus on linux all
- 4:04:07right so let's talk about the linux log
- 4:04:10files which are the most important
- 4:04:11aspects
- 4:04:12uh of uh of persistence or activity that
- 4:04:15is being logged on the linux operating
- 4:04:17system or the linux kernel
- 4:04:19all right so your the log files on any
- 4:04:21linux system can be found on in the var
- 4:04:25well actually let me just change
- 4:04:26directory into that so cd var and it is
- 4:04:29stored in the log directory right over
- 4:04:31here so now that i'm in the directory i
- 4:04:33can list all the files in here
- 4:04:35and these are all the log files that
- 4:04:37currently exist and of course if you
- 4:04:39just read their name they're pretty
- 4:04:40self-explanatory they have all they they
- 4:04:43have they're all they all have their
- 4:04:45various use cases and what data they are
- 4:04:48essentially logging all right so for
- 4:04:50example when talking about uh the
- 4:04:52auth.log file this stores authentication
- 4:04:55logs uh let's see if
- 4:04:57let's see if we can find the kernel if
- 4:04:59we can find yet there we are the
- 4:05:00kernel.log file which essentially stores
- 4:05:03all the kernel logs you then have the
- 4:05:05mail server logs which is of course uh i
- 4:05:08don't think we have a mail server here
- 4:05:09but if we did you'd have the mail server
- 4:05:12logs as well you then have the system
- 4:05:14bootlog which is your boot your boot log
- 4:05:16which again we don't have here for some
- 4:05:18reason
- 4:05:20we then have um
- 4:05:22you have your http the httpd log which
- 4:05:25essentially has logs for your web server
- 4:05:27if you do have a web server
- 4:05:29or a web server that being the apache
- 4:05:31web server so again there are a lot of
- 4:05:33log files here we're going to be
- 4:05:34focusing on the auth log right of you
- 4:05:37which essentially contains the
- 4:05:38authentication logs and then we'll take
- 4:05:40a look at the bash history file which is
- 4:05:43very important as well we'll also take a
- 4:05:44look at the shred file as well so
- 4:05:47let's talk about the shred file and the
- 4:05:50the the auth dot log file
- 4:05:52all right so if i'm just to open up the
- 4:05:54auth.log file here this essentially
- 4:05:56stores all the uh the authentication
- 4:05:59logs which are very very important for
- 4:06:01to a forensics team uh to essentially
- 4:06:03analyze what was happening to the system
- 4:06:05what activities were carried out etc etc
- 4:06:09all right so you can go ahead and
- 4:06:10analyze all all of the files right over
- 4:06:13here and get an idea of of essentially
- 4:06:16uh what was going on and of course that
- 4:06:18is uh
- 4:06:19that deserves its own video in its own
- 4:06:22right because that is more of a
- 4:06:23forensics type of video
- 4:06:25but for now we're looking to get rid of
- 4:06:27this because remember if you're an
- 4:06:28attacker you want to get rid of all of
- 4:06:30these files so that uh they really
- 4:06:32cannot build an idea of what was going
- 4:06:34on on the system all right so let me
- 4:06:37just exit out of this and as i said the
- 4:06:40tool that is most recommended for any of
- 4:06:42this getting erasing files erasing hard
- 4:06:45drives is shred now if you haven't heard
- 4:06:47of shred shred is essentially a tool
- 4:06:49that allows you to delete uh or erase a
- 4:06:52file permanently so it allows you to
- 4:06:54delete files data permanently now many
- 4:06:57of you might be confused with saying wow
- 4:06:58why can't you just delete it well if you
- 4:07:00delete a file
- 4:07:02it can be recovered and i'll explain
- 4:07:03this in a second so shred allows you to
- 4:07:06delete files and data permanently and
- 4:07:07prevents the recovery of that data
- 4:07:10it does this because it over it
- 4:07:12overwrites the file multiple times with
- 4:07:14ones and zeros now when you
- 4:07:16traditionally delete a file with your
- 4:07:19graphical user interface or you simply
- 4:07:21hit the delete a key on your keyboard
- 4:07:23what's happening here
- 4:07:25is your file isn't being deleted it is
- 4:07:27simply marked as a space in which data
- 4:07:30can be written to or data can be written
- 4:07:32on top of therefore replacing the
- 4:07:34previous data and of course this is
- 4:07:35going to be dependent on how you use the
- 4:07:37computer and that's why when you you see
- 4:07:39these real amateurs are doing
- 4:07:41questionable things on their computer
- 4:07:43you know doing illegal stuff on the
- 4:07:44computer
- 4:07:46just delete the file without even
- 4:07:48realizing that you aren't deleting it is
- 4:07:50deleted for you the user but uh in the
- 4:07:53back end the file still exists it's
- 4:07:55simply marked that the sector is simply
- 4:07:57marked as a as a space that should be
- 4:08:01written onto us and when it's written
- 4:08:03onto then the files are lost but you can
- 4:08:05still perform a lot of data recovery
- 4:08:07that's why you have an industry
- 4:08:09dedicated to data recovery because of
- 4:08:11how operating systems are and how they
- 4:08:13uh they essentially mark spaces or data
- 4:08:16that you won't delete it there's spaces
- 4:08:17that can be overwritten all right so
- 4:08:19that is the difference between keeping
- 4:08:21files and maintaining uh the fact that
- 4:08:23they cannot be written to
- 4:08:25or overwritten that is
- 4:08:27by other files and and
- 4:08:29when you actually hit delete so when we
- 4:08:32talk about a tool like shred shred is a
- 4:08:34tool that i've used a lot of times
- 4:08:36before for wiping or erasing hard drives
- 4:08:39when i'm when i'm done with them when
- 4:08:41i'm disposing them or when i'm selling
- 4:08:42drives which is very very rare never
- 4:08:45sell your drives
- 4:08:47all right so shred comes pre-installed
- 4:08:49in kali linux and i'm guessing in pretty
- 4:08:50much all the other distributions so i'm
- 4:08:53just going to clear this out and what
- 4:08:54we're going to do is we're just going to
- 4:08:56open up shred here with the help command
- 4:08:59and the shred tool is quite
- 4:09:01comprehensive and i'll try and explain
- 4:09:03all the commands
- 4:09:04all right so the shred command
- 4:09:06essentially when you when you're writing
- 4:09:08to a file or a particular drive it uh
- 4:09:11it essentially overwrites the specified
- 4:09:14files repeatedly and therefore making it
- 4:09:16difficult or impossible for uh you know
- 4:09:19hardware software or software recovery
- 4:09:21to to get the data back all right so the
- 4:09:24options or the parameters that you can
- 4:09:25specify
- 4:09:26with the shred tool are as follows you
- 4:09:28have the f the f command which
- 4:09:30essentially allows you to change
- 4:09:32permissions to allow writing if needed
- 4:09:34you have the n command which is the
- 4:09:35iterations or essentially this allows
- 4:09:38you to overwrite the amount of times you
- 4:09:40want which is which is good the default
- 4:09:42amount of times is three which is okay
- 4:09:44but if you're really paranoid about you
- 4:09:46know about your files and you really
- 4:09:48want to get rid of them you can increase
- 4:09:50the amount of times all the iterations
- 4:09:52then have the size uh the size of the
- 4:09:54number of bytes to shred you then have
- 4:09:56the u command which is essentially
- 4:09:58allows you to
- 4:09:59uh to truncate uh it essentially
- 4:10:01truncates and remove the files after
- 4:10:03overwriting you then have the v command
- 4:10:05over here which shows your progress over
- 4:10:07both uh shows verbose information about
- 4:10:09the progress you then have the x command
- 4:10:12right over here which essentially
- 4:10:14uh this what this does is again is it's
- 4:10:17self-explanatory but this does not round
- 4:10:19the files up to the next full block
- 4:10:22uh we then have the z command which adds
- 4:10:24the final overwrite with zeros to hide
- 4:10:26shredding so it uh usually with uh
- 4:10:29with software recovery tools they can
- 4:10:31actually detect if there was shredding
- 4:10:33done and this prevents that and you have
- 4:10:35u the u command which essentially
- 4:10:37removes the file after threading which
- 4:10:39is what we're going to be taking a look
- 4:10:40at as well
- 4:10:42all right so let's take a look at the
- 4:10:43command that we'll be using and i'll
- 4:10:45explain what's going on
- 4:10:47all right so we'll be using the vfzu
- 4:10:49command which if we just look at the
- 4:10:51arguments here we are going to be using
- 4:10:53the v so verbose v
- 4:10:55f z u so f we're going to force to
- 4:10:58change the permissions if they exist so
- 4:11:00if you don't have read and write
- 4:11:01permissions is going to force it
- 4:11:03uh so uh there we are so z uh we're
- 4:11:06going to use the v f z u so then z is
- 4:11:09going to be essentially add a final
- 4:11:10override with zeros to hide the
- 4:11:12shredding process which is good and we
- 4:11:14are going to remove the file uh after or
- 4:11:17after the overwriting process all right
- 4:11:19so that is what is going on here so to
- 4:11:21do that we simply type in shred
- 4:11:24and after shred we type in our commands
- 4:11:26or the combination of commands so
- 4:11:28vfzu and the file which is auth.log and
- 4:11:32i'm going to hit enter and there we are
- 4:11:34all right so shred it's going to start
- 4:11:36the shredding process right over here
- 4:11:37and you can see shred uh authored logo
- 4:11:40was renamed to zero zero zero et cetera
- 4:11:42renamed renamed renamed all the way to
- 4:11:44uh to the fact that the file was removed
- 4:11:47or destroyed all right so that gets rid
- 4:11:49of the auth.log file which essentially
- 4:11:52gets rid of the authentication logs very
- 4:11:54very simple you can take a look at all
- 4:11:56the other logs and of course you might
- 4:11:58want to get rid of all the other logs
- 4:12:00that
- 4:12:00that might have existed before or in the
- 4:12:03fact in in regards to the services that
- 4:12:05you might have used so for example if
- 4:12:07you used mac changer which is quite rare
- 4:12:09you might want to get rid of that log
- 4:12:11file the kernel log file which is right
- 4:12:13over here so
- 4:12:14if we open it up
- 4:12:16kernel.log
- 4:12:18and there we are these are all the log
- 4:12:19files in regards to the to the kernel so
- 4:12:22again this is a file that you might want
- 4:12:23to get rid of or you can simply edit
- 4:12:25what you don't want in any of these log
- 4:12:27files so as to to to sort of throw off
- 4:12:31the forensic themes or off of your back
- 4:12:33to essentially make it look really
- 4:12:35really traditional all right so that is
- 4:12:37how to clear your log files of course
- 4:12:39you can use shred for deleting any other
- 4:12:42file this is a video not it's not
- 4:12:43designed to be uh to be about shred but
- 4:12:46there you go you can use shred to erase
- 4:12:48files uh permanently all right so do be
- 4:12:51careful with it as well now let's talk
- 4:12:53about bash history which is a video that
- 4:12:55most of you guys requested me to to talk
- 4:12:58about now bash history essentially keeps
- 4:13:00a record of all the commands that were
- 4:13:02executed by a user on the linux command
- 4:13:05line
- 4:13:06now this is very very important because
- 4:13:09the uh the bash history is a is a file
- 4:13:11that is kept uh
- 4:13:13usually separated for each individual
- 4:13:15user on the linux system so if you are
- 4:13:18the root user you have your own bash
- 4:13:19history file if there was a user called
- 4:13:22alexis he will also have his own bash
- 4:13:24history file you get the idea so
- 4:13:27the directory in which it is stored in
- 4:13:29is in the home user the user that being
- 4:13:32the user that you are using
- 4:13:34and the file is the dot bash history
- 4:13:37file
- 4:13:38all right so i'll get to that in a
- 4:13:39second so if there was a user
- 4:13:42let me just go back into the root
- 4:13:43directory and this is where it is stored
- 4:13:45so if you do have a user it is stored in
- 4:13:47the
- 4:13:48home and the username so this is where
- 4:13:50you put in the username and it is stored
- 4:13:52under the bash history file right over
- 4:13:54here
- 4:13:55all right
- 4:13:56so that is if you are using a particular
- 4:13:59use on the system which is quite obvious
- 4:14:01but if you do have root privileges then
- 4:14:03it's also important but you essentially
- 4:14:04want to get rid of all the bash history
- 4:14:06because this will essentially give
- 4:14:08forensics teams a list of all of what
- 4:14:11you did on that system
- 4:14:13all right so let me actually show you
- 4:14:15how this can be analyzed so i'm just
- 4:14:17going to open up nano here and since i'm
- 4:14:19in the root directory i think i should
- 4:14:20have the there we are the bash history
- 4:14:22file
- 4:14:24uh now i personally have a lot of
- 4:14:26important information in there so i'm
- 4:14:28going to simply show you how to get to
- 4:14:31wipe it all right now wiping it you can
- 4:14:33also use shred if you want to but i
- 4:14:35don't recommend doing that because again
- 4:14:37you're really starting to
- 4:14:39you're helping the forensic team build
- 4:14:42uh an idea of what type of attacker
- 4:14:44they're dealing with so i would
- 4:14:45recommend keeping things as normal as
- 4:14:47possible
- 4:14:48all right so if you you can also use the
- 4:14:50null redirect to clear the file which is
- 4:14:52what i'm going to do so you can
- 4:14:53essentially use the null redirect as
- 4:14:55follows so
- 4:14:56bash history
- 4:14:58and uh as on once i hit enter it will
- 4:15:00essentially clear the file because i'm
- 4:15:02using null redirect so it's essentially
- 4:15:04clearing the entire file so
- 4:15:06bash history let me open up the file
- 4:15:08sorry
- 4:15:09nano
- 4:15:10uh and um
- 4:15:13bash
- 4:15:14history as follows and there we are so
- 4:15:15it's empty now you might be wondering
- 4:15:17well it is empty but did it contain
- 4:15:19anything well if we start using the
- 4:15:21terminal here which uh am i currently
- 4:15:23using this so i'm using terminator
- 4:15:25uh yeah there we are so i was using a
- 4:15:27material session i was just working on a
- 4:15:29few hack the box videos which will also
- 4:15:31be coming out so don't worry about that
- 4:15:33so if i was to do your sudo apt get
- 4:15:36update
- 4:15:38there is a command that i did run and we
- 4:15:40try and open up the bash history file
- 4:15:42right over here and we'll let we let
- 4:15:44that running and that is in my uh
- 4:15:47terminator session all right so let's
- 4:15:48open it up one more time and uh for some
- 4:15:51reason it isn't showing up well we have
- 4:15:52to wait for the command to execute so
- 4:15:54uh let me just wait for that to execute
- 4:15:56so i'll get back to you when this is
- 4:15:58done
- 4:16:00alrighty i'm back i've essentially just
- 4:16:02ran a few commands i was just doing a
- 4:16:04bit of metasploit work i was using
- 4:16:07messer venom all that good stuff because
- 4:16:09i really wanted to show you how much
- 4:16:10information the bash history file can
- 4:16:13uh can actually reveal so let me just
- 4:16:15open it up one more time here
- 4:16:17and my terminal always lags out when i
- 4:16:20resume a video which is really weird
- 4:16:21something to do with my processor let me
- 4:16:23know if you guys know what's going on
- 4:16:25here alright so bash
- 4:16:28bash history like so when we hit enter
- 4:16:30and there you are so you can see that i
- 4:16:32was doing uh some very interesting
- 4:16:34things here
- 4:16:35so i went to my desktop i created a
- 4:16:38payload the message venom i copied the
- 4:16:42uh the payload to my apache directory i
- 4:16:45restarted apache
- 4:16:47uh looks like i removed a motility
- 4:16:50installation i also removed an
- 4:16:52index.html file
- 4:16:54uh well i cleared the terminal i'm
- 4:16:58actually missed i misspelled so yeah
- 4:17:00this reveals a lot of information about
- 4:17:02what the attacker was doing or what a
- 4:17:04particular user was doing on the system
- 4:17:06so
- 4:17:07so there you go and it'll also tell you
- 4:17:09that your attacker has really bad typing
- 4:17:12skills and really makes a lot of
- 4:17:13spelling mistakes so yeah you can pretty
- 4:17:15much get an idea of what exactly is
- 4:17:18going on here
- 4:17:19all right so that's pretty much going to
- 4:17:21be it for this video guys thank you so
- 4:17:23much for watching
- 4:17:24if you have any questions or suggestions
- 4:17:26let me know in the comment section on my
- 4:17:28social networks on my website and i'll
- 4:17:30be seeing you in the next video peace
- 4:17:32guys
- 4:17:36[Music]
- 4:17:47hey guys in this video we're going to be
- 4:17:49taking a look at ssh brute force
- 4:17:51protection with fail to ban now before
- 4:17:53we actually get started with setting it
- 4:17:55up let's get a bit of an understanding
- 4:17:57as to what this tool is and how we can
- 4:17:58use it
- 4:18:00for ssh brute force protection all right
- 4:18:02so what is fail to ban filter ban is an
- 4:18:04intrusion prevention framework that's
- 4:18:06written in python
- 4:18:08and that protects linux systems and
- 4:18:09servers from brute force attacks now
- 4:18:11these are not limited to ssh but the
- 4:18:13scope of this video is going to be based
- 4:18:15around ssh as the primary service that
- 4:18:18is going to be protected uh you know
- 4:18:19from brute force attacks
- 4:18:21all right so it allows you to monitor
- 4:18:23the strength and the frequency of
- 4:18:24attacks and then from that you can sort
- 4:18:26of create various jails that you can use
- 4:18:29and you can sort of customize your the
- 4:18:32strength of the defense you want to set
- 4:18:34up based on the attacks you're getting
- 4:18:36and of course fail to ban can be set up
- 4:18:38to block ip addresses automatically
- 4:18:40based on specific parameters more of
- 4:18:42which i'll explain as we move along all
- 4:18:44right so the great thing about fail the
- 4:18:46ban is that it automates the process of
- 4:18:48protecting your server
- 4:18:50or your ssh from brute force attacks
- 4:18:52alright so
- 4:18:53let's get started all right now that we
- 4:18:56have an understanding of what fail to
- 4:18:57ban is and how we can use it to protect
- 4:19:00our servers you know from brute force
- 4:19:02attacks on ssh
- 4:19:04let's take a look at the infrastructure
- 4:19:05we'll be using in this video
- 4:19:07so for the purpose of this video i've
- 4:19:08just set up a quick
- 4:19:10a quick server here with linux and i'll
- 4:19:12just copy the ip address it's just a
- 4:19:14simple ubuntu server and they'll
- 4:19:16demonstrate how powerful filthban
- 4:19:18actually is so i'll just open up a
- 4:19:20terminal here and we can try and log
- 4:19:22into this server right now i haven't set
- 4:19:24any any other user account so we'll be
- 4:19:26logging as the root user
- 4:19:27and let me just enter the password here
- 4:19:30and that should log us in immediately so
- 4:19:32the first thing i want to do is i want
- 4:19:34to update
- 4:19:35the packages because we do need to
- 4:19:36install fail to ban all right so i'm
- 4:19:38just going to say upgrade update here
- 4:19:40and we do need to run sudo there because
- 4:19:43we're already using the root user but in
- 4:19:45any case
- 4:19:46let's just update the packages here or
- 4:19:48the repositories sorry not our packages
- 4:19:52now filter ban is completely free to use
- 4:19:55and you know you can install it through
- 4:19:56most of your popular package managers in
- 4:19:58our case we're just going to use the
- 4:19:59aptitude package manager so as a apt-get
- 4:20:03install and we're going to say fail to
- 4:20:05pan and we hit enter
- 4:20:07and that is going to prompt us to
- 4:20:09download about 18.7 megabytes and we're
- 4:20:12just gonna let that install
- 4:20:13uh this shouldn't take uh too much time
- 4:20:16and we can see we do have a sim link
- 4:20:18created here that's very important for
- 4:20:19the filter band service so one of the
- 4:20:22first things we need to do is we need to
- 4:20:23ensure that we have enabled fail to ban
- 4:20:25to run on on system startup so in the
- 4:20:27event you do reboot your server uh you
- 4:20:30need to make sure that filter ban you
- 4:20:31know runs
- 4:20:32directly on the startup or during the
- 4:20:34startup so to do this we'll use a
- 4:20:36systemd so system control and we'll say
- 4:20:39um enable
- 4:20:41uh of course we're gonna say fill to ban
- 4:20:44and the service is actually called fail
- 4:20:46to ban dot service so we're gonna hit
- 4:20:48enter
- 4:20:48and as you can see it's gonna say
- 4:20:50synchronizing the state of the
- 4:20:51filterband service with the csv
- 4:20:54service script uh so irregardless of
- 4:20:56whether we used systemd
- 4:20:59so
- 4:21:00what we can do now is we can start
- 4:21:02taking a look at the configuration files
- 4:21:04right now the configuration files
- 4:21:07for failed ban are going to be found in
- 4:21:09the etsy uh they're in the etsy
- 4:21:11directory so we can say um let's just
- 4:21:13list all the files etsy
- 4:21:15fail to ban and we hit enter and let's
- 4:21:17take a look at these configuration files
- 4:21:19so the most important one that you want
- 4:21:21you want to be familiar with is are
- 4:21:23going to be the jail dot conf file and
- 4:21:25the filterband.com file or the
- 4:21:27filterband.com file is a file we'll not
- 4:21:29be taking a look at
- 4:21:30uh in this video but we're taking a look
- 4:21:32at the actual jail.configuration file
- 4:21:34now uh uh if a fairly frequent or common
- 4:21:38term that you'll be hearing uh you know
- 4:21:40that will hear being mentioned when
- 4:21:41talking about fail the ban is the use of
- 4:21:43jails all right so what is a jail in
- 4:21:46filter ban well a jail is essentially a
- 4:21:48configuration file
- 4:21:50that you know contains filters or
- 4:21:52arguments that protect your system or a
- 4:21:54particular service now by default all
- 4:21:57your jails for particular services are
- 4:22:00going to be in the jail.conf file
- 4:22:02alright so if i just get the contents or
- 4:22:04let's actually view the entire file we
- 4:22:06can say um
- 4:22:08let me move into the directory so it's
- 4:22:10much easier for us to work there
- 4:22:12so we can say less and we say
- 4:22:15jail
- 4:22:17jl.conf and we hit enter uh you can
- 4:22:20pretty much see that first of all it
- 4:22:21tells you that uh this is not the uh the
- 4:22:24appropriate way of actually creating or
- 4:22:27modifying the already preset jails the
- 4:22:29reason being is this we should actually
- 4:22:31create another jail.configuration file
- 4:22:34uh with the local extension so you can
- 4:22:36see in most of the cases you should not
- 4:22:38modify this file but provide
- 4:22:39customizations in the jail.loc of the
- 4:22:42gel.local file or you can create
- 4:22:45separate.con files under the jl.d
- 4:22:47directory something we're not going to
- 4:22:48be doing because the gel.local file is
- 4:22:50pretty much the best way of going about
- 4:22:52it so what you can do is you can copy
- 4:22:54this file and you know you can make a
- 4:22:55copy of it however the second copy is
- 4:22:57going to be called jail.local
- 4:22:59in within this uh it has various jails
- 4:23:02that protect various services now the
- 4:23:04first one you can see
- 4:23:06is uh going to be the sshd or the
- 4:23:08openssh server service and it's going to
- 4:23:10be enabled so a jail has already become
- 4:23:13uh has already been configured for this
- 4:23:15but you can see that there aren't any
- 4:23:17protection uh configuration options that
- 4:23:19have been set here
- 4:23:21so for example the band time the default
- 4:23:24band time for all jails on all services
- 4:23:26irregardless of whether it's ssh or ftp
- 4:23:28has been set to one hour now we can
- 4:23:31pretty much customize this for uh
- 4:23:32particular services which is what we
- 4:23:34want to do so you can use this uh this
- 4:23:37same configuration file uh and you can
- 4:23:39copy it you know and use the local
- 4:23:41extension and this will essentially set
- 4:23:43up protection for all of those services
- 4:23:45however in our case i want to
- 4:23:47i want to actually create a new
- 4:23:49jail.local file and the only service
- 4:23:51that i'm going to be protecting or we're
- 4:23:52going to be configuring is the
- 4:23:54the the openssh server this sshd service
- 4:23:57so again all we'll do is we will say um
- 4:24:00we'll use them here and we'll say
- 4:24:02jl.local
- 4:24:04and we're going to hit enter now as you
- 4:24:06already saw within the gel.configuration
- 4:24:09file
- 4:24:10we can essentially
- 4:24:12we we can start working with these
- 4:24:14services that we want to protect so
- 4:24:16again we do this by specifying their
- 4:24:18name so in our case the openssh server
- 4:24:20is defined by the ssh daemon here so
- 4:24:23we're going to say ssh daemon and then
- 4:24:25after this we're going to start
- 4:24:27providing the syntax now the first
- 4:24:29important bit of syntax here is going to
- 4:24:31be the enabled configuration or the
- 4:24:33enabled option
- 4:24:35this essentially you know
- 4:24:37means whether this essentially controls
- 4:24:39whether the jail is enabled uh or
- 4:24:41disabled and the option here we can
- 4:24:43specify is either true or false right
- 4:24:46and of course that is self-explanatory
- 4:24:49enabled means that the uh the jail or
- 4:24:52the protection will be enabled or this
- 4:24:54these particular configurations will be
- 4:24:56enabled so for now let's just keep it at
- 4:24:58false because i want to show you uh you
- 4:25:01know a test brute force attack on the
- 4:25:02server
- 4:25:03uh before and after so what we'll do is
- 4:25:06we'll just say false
- 4:25:08and uh
- 4:25:09after this we can then get started with
- 4:25:11our configurations now let me just talk
- 4:25:12about the various configurations that
- 4:25:14exist here
- 4:25:16uh so we pretty much need to specify the
- 4:25:18service the port and the filter and the
- 4:25:21log file that we'll be using now let me
- 4:25:23explain that sounds like a mouthful but
- 4:25:24it's really very simple to understand
- 4:25:27all right so the first thing i want to
- 4:25:28do is i want to say what's the pot the
- 4:25:30port is going to be the ssh port right
- 4:25:33so the ssh port here
- 4:25:35and
- 4:25:36after this we specify the filter that
- 4:25:38we're looking for now the filter is
- 4:25:40something very important right so let me
- 4:25:42just open up a uh
- 4:25:43i'll open up a new tab here and we can
- 4:25:46try and authenticate to this server one
- 4:25:48more time so i'll just say ssh root and
- 4:25:51we'll just authenticate to this server
- 4:25:53and the reason being is i want to show
- 4:25:55you the log the log file that we're
- 4:25:57talking about this is the auth.log file
- 4:25:59now the auth.log file uh pretty much
- 4:26:02stores all the authentication attempts
- 4:26:04made to the server whether they they
- 4:26:05were successful or whether they failed
- 4:26:08and pretty much you can find this within
- 4:26:11the let's just get the contents of the
- 4:26:13file so you can find this within the log
- 4:26:15directory under etsy and it's called the
- 4:26:17author log file now when i talk about a
- 4:26:19filter again a filter is very simple to
- 4:26:22understand uh we'll just hit enter for
- 4:26:24some reason we don't have
- 4:26:27this file we're looking sorry this is in
- 4:26:29the var directory my apologies i'm just
- 4:26:32getting confused with the etsy directory
- 4:26:33there so you can see that this gives you
- 4:26:35um
- 4:26:36it gives you a log here of all the
- 4:26:38authentication attempts
- 4:26:40and when i was talking about the actual
- 4:26:42filter so if i say filter
- 4:26:44this will essentially mean this is
- 4:26:47essentially where you say fail to ban i
- 4:26:49want you to look for this particular
- 4:26:52filter in our case we're looking for the
- 4:26:53ssh daemon or the sshd service here so
- 4:26:56you can see
- 4:26:57that for example if we take a look at
- 4:26:59the first ssh
- 4:27:01demon
- 4:27:02log here we can see that this is the the
- 4:27:04ssh server listening on port 22 and then
- 4:27:07if we take a look at some authentication
- 4:27:09attempts you can see we have an
- 4:27:10authentication attempt here
- 4:27:12that tells us accepted password for the
- 4:27:14root user and the particular ip address
- 4:27:17here
- 4:27:18and this was made through ssh not a tty
- 4:27:21session so if it can also tell you
- 4:27:23whether the authentication is done
- 4:27:25locally or remotely so that is the
- 4:27:27filter we're looking for so we only want
- 4:27:29to filter for ssh daemon or sshd
- 4:27:32logs there so we then need to specify
- 4:27:35the the location of the log file that
- 4:27:37we're going to be using so say log path
- 4:27:39is going to be equal to and we specify
- 4:27:41the relative directory here so we're
- 4:27:42going to say var
- 4:27:44log
- 4:27:45and auth.log here
- 4:27:48and after this we can just hit enter and
- 4:27:50we can now talk about the security
- 4:27:52options right so the security options
- 4:27:54are very simple the first or the first
- 4:27:56of with of which is the most important
- 4:27:59this is the max retry option and this is
- 4:28:01where you specify the number of attempts
- 4:28:03to be made before an ip address or a
- 4:28:06user is banned all right so to do this
- 4:28:08we say max retry
- 4:28:10max retry and that's going to be equal
- 4:28:12to in our case we'll just say three so
- 4:28:14the number of uh so we say the number of
- 4:28:16attempts to be made before a band is
- 4:28:18going to be equal to three so if you
- 4:28:20enter
- 4:28:21you know an incorrect password three
- 4:28:22times that's that you're going to be
- 4:28:24banned right
- 4:28:25now we then have the band time right so
- 4:28:27the band time
- 4:28:29is again self explanatory this is the
- 4:28:31number of seconds an ip address will be
- 4:28:33banned for now typically you can set it
- 4:28:35to an hour which is uh is primarily
- 4:28:38going to be uh you know 3600 seconds or
- 4:28:41you can uh you can specify a day which
- 4:28:44is a very good option that many system
- 4:28:47administrators set so again
- 4:28:49we can just calculate this so 60 times
- 4:28:5260 um that pretty much gives us what
- 4:28:54we're looking for that's 3600 multiplied
- 4:28:57by 24 hours that's going to be 86 400 so
- 4:29:01we can say 86
- 4:29:04400 and that's typically going to block
- 4:29:06uh any ip addresses that have incorrect
- 4:29:10authentications more than three or uh
- 4:29:12three incorrect authentications for
- 4:29:14entire day
- 4:29:15right so what we can do is we'll just
- 4:29:17set it to 3600 or we can set it to 60
- 4:29:20seconds whatever you feel is appropriate
- 4:29:22for your server based on the attacks
- 4:29:24you've been getting or you can set a
- 4:29:25generic one if you're monitoring your
- 4:29:27server and seeing how many attacks
- 4:29:29you're typically getting which i'll show
- 4:29:31you how to monitor
- 4:29:32you can then ignore ip addresses so you
- 4:29:35can whitelist ip addresses
- 4:29:37so again that's done by specifying
- 4:29:39ignore ip and then within this you can
- 4:29:42then specify any ip addresses that you
- 4:29:44may want to white if you're a system
- 4:29:45administrator it may be wise to enter
- 4:29:47your ip address here
- 4:29:49um so you can do that and i think
- 4:29:52we can also specify uh i've specified
- 4:29:55band time what about find time so the
- 4:29:57amount of time between failed uh login
- 4:30:00attempts
- 4:30:01we can you can just say find time
- 4:30:05or we can actually leave that out
- 4:30:06because we really don't need that uh
- 4:30:08these are these options are pretty
- 4:30:10pretty good um so we can save
- 4:30:13this file
- 4:30:15and we
- 4:30:16we
- 4:30:17ensured that this jail was disabled and
- 4:30:19the reason being is i want to show you
- 4:30:22what you know typical field
- 4:30:23authentication looks like
- 4:30:25so what i'll do is um let me just exit
- 4:30:28from here and i'll just
- 4:30:31ssh into this and i'll enter incorrect
- 4:30:33passwords now typically the the
- 4:30:36the max amount of times you're allowed
- 4:30:37to authenticate incorrectly is three
- 4:30:39times that's the default one but i'll
- 4:30:41explain something interesting here so
- 4:30:43for example
- 4:30:44uh actually before i do this because i
- 4:30:46do want to block my ip address because
- 4:30:48it is going to connect to it remotely
- 4:30:51let's see if we can actually use proxy
- 4:30:53chains here so let me just open up this
- 4:30:55in part os and i'll expand this
- 4:30:59uh or we can actually use anon surf so
- 4:31:01let me just use anon surf instead of
- 4:31:02using proxy chain so we'll just start
- 4:31:04this
- 4:31:05yes go ahead
- 4:31:07and the reason being is i don't want to
- 4:31:09actually expose my real ip address here
- 4:31:11because when i'll be showing you the ip
- 4:31:13addresses that were blocked uh this will
- 4:31:15come into play so what i'll do is i'll
- 4:31:17just wait for announcers and on surf to
- 4:31:19start before we authenticate to the
- 4:31:21server and i'll show you what happens
- 4:31:24here
- 4:31:24so remember the jail has is currently
- 4:31:26disabled and ssh protection is is
- 4:31:29currently not active with fail to ban
- 4:31:31all right so we are currently uh
- 4:31:34anonymized here so what we'll do is
- 4:31:35we'll say ssh
- 4:31:37root at
- 4:31:38and we'll hit enter
- 4:31:40and we'll say yes we want to accept the
- 4:31:42fingerprint and we'll enter incorrect
- 4:31:44password so i can just say password
- 4:31:47and again that will be incorrect
- 4:31:49permission denied
- 4:31:50password will hit enter
- 4:31:53another incorrect password attempt for
- 4:31:56authentication attempt hit enter one
- 4:31:58more time
- 4:32:00and there we are you can see so it gives
- 4:32:02you three attempts by default and then
- 4:32:04after which you're told permission
- 4:32:05denied let's try this one more time so
- 4:32:08we're we're sort of exceeding the amount
- 4:32:10of attempts but remember we haven't
- 4:32:11enabled the fail to ban jail so we can
- 4:32:14still try authenticating incorrectly
- 4:32:16say password
- 4:32:19and
- 4:32:20password let's try it a few more times
- 4:32:22and there we are we can still see that
- 4:32:24after three unsuccessful attempts
- 4:32:27uh it uh it it essentially disconnects
- 4:32:29the the connection what i'll do is we'll
- 4:32:32just wait for we'll just close this and
- 4:32:34uh let's restart the service before we
- 4:32:36actually get started so again uh before
- 4:32:38after writing any changes to your uh to
- 4:32:41your jail configuration file
- 4:32:43uh you essentially need to restart the
- 4:32:45the filterband service so we say system
- 4:32:48control
- 4:32:49sorry system
- 4:32:50system control and we say restart
- 4:32:53uh we'll say fill a two band service and
- 4:32:57we
- 4:32:58hit enter and that's going to restart it
- 4:33:00so now that we've tested that this uh
- 4:33:02that we you know we currently do not
- 4:33:04have any brute force protection here uh
- 4:33:07what we can do is we can modify this
- 4:33:09file and we can say uh set this to true
- 4:33:12so now we're going to activate the
- 4:33:13protection so we're gonna say true
- 4:33:16and we're going to write changes and
- 4:33:18exit and we'll restart the filter band
- 4:33:20service and let me just check the status
- 4:33:22here
- 4:33:24[Music]
- 4:33:27sorry that is incorrect
- 4:33:29we'll just change this to status and we
- 4:33:31can see it's active and running this is
- 4:33:33very important because
- 4:33:36if you do want to actually check if
- 4:33:38you're having any issues with your
- 4:33:39syntax or any of the filters you've set
- 4:33:42up for your particular jail in the jail
- 4:33:44configuration file
- 4:33:46this is where you can actually check if
- 4:33:47there are any issues and you also have
- 4:33:49the log here so you can see stopped
- 4:33:50start started and we're ready again so
- 4:33:54we can now get started and we can test
- 4:33:56it one more time so what i'll do is i'll
- 4:33:58use the same ip address here
- 4:34:00and what we'll do is we'll just say ssh
- 4:34:03root act
- 4:34:04and for some reason we're being told the
- 4:34:06connection was closed by remote host
- 4:34:09so let's try a different ip here so uh
- 4:34:12let's see if we can let's check the
- 4:34:15um
- 4:34:16the status of of the tor service
- 4:34:19and we remember we need uh
- 4:34:22do we have tor running we currently have
- 4:34:24door running i believe but i think we
- 4:34:26still need to disable the anon surf here
- 4:34:29we can just stop it
- 4:34:32uh so we'll say stop and we'll wait for
- 4:34:34this to stop
- 4:34:36and i think we can just use proxy chains
- 4:34:38now that would be much better
- 4:34:40uh instead of using anon surf
- 4:34:43although i should have done that before
- 4:34:45but i just wanted to explain a point
- 4:34:46here so
- 4:34:48all anonymous mode has been stopped and
- 4:34:52we'll just start store
- 4:34:55uh actually yeah we can we can do we'll
- 4:34:57start it and uh now let's use proxy
- 4:34:59chains i'll say proxy chains
- 4:35:02ssh um i'll say root at and we'll paste
- 4:35:06the ip in here
- 4:35:08all right so it'll ask us for the
- 4:35:10password and i'll just enter an
- 4:35:11incorrect password late enter
- 4:35:14and uh lend an incorrect password again
- 4:35:17remember we have said we have set the
- 4:35:18options in the gel configuration file to
- 4:35:20three so again it will just uh it will
- 4:35:22block the user for the first three
- 4:35:23attempts obviously
- 4:35:25uh we aren't getting a response we can
- 4:35:27also try brute forcing with hydra
- 4:35:30which is also another option so let's
- 4:35:32try this out so we'll say
- 4:35:34hydra
- 4:35:35uh l uh we'll say root
- 4:35:39and the password list is gonna be user
- 4:35:42uh share
- 4:35:44and we're gonna say word lists and we'll
- 4:35:46use some of the meta split word lists
- 4:35:48here
- 4:35:48uh let's see which ones we have
- 4:35:51do we have any ssh ones
- 4:35:53nothing much
- 4:35:57we can use the common roots let's try
- 4:35:59that we can just use any the the bottom
- 4:36:01line is i just want to show you
- 4:36:03what this would look like
- 4:36:05so we're looking for ssh
- 4:36:07and we specify the ip address here
- 4:36:09let's get rid of any other sessions that
- 4:36:11i had and let's have some verbose output
- 4:36:14and let enter
- 4:36:15and you can see it tells us that could
- 4:36:16not connect to
- 4:36:18to this particular ip
- 4:36:20connection refused what i'll do is uh we
- 4:36:23can you can see that after the third
- 4:36:25failed attempt
- 4:36:27we can see that we get no response and
- 4:36:28that actually proves that it's working
- 4:36:30however i'll i'll actually show you how
- 4:36:32you can check this so if we just
- 4:36:34terminate this and we go back in on to
- 4:36:37our server we can view the logs and the
- 4:36:39failed authentication attempts and the
- 4:36:41blocked ips
- 4:36:42uh by taking a look at the filter ban
- 4:36:44client here so i can hit enter and then
- 4:36:47after this we want to display the status
- 4:36:49right so if i hit status and we hit
- 4:36:51enter this will give you the number of
- 4:36:53jails that you have and as you can see
- 4:36:54we have only one gel and that is the ssh
- 4:36:57daemon so we want to check the status of
- 4:36:59the ssh
- 4:37:01daemon or this is ssh server as the
- 4:37:03openssh server
- 4:37:05uh jail and we hit enter all right and
- 4:37:08you can see that the status for the jail
- 4:37:10is as follows so the filter is
- 4:37:12the currently failed is zero the total
- 4:37:15amount of failed authentication attempts
- 4:37:17is six
- 4:37:18uh you then have the file list which is
- 4:37:20uh the authentication log that is going
- 4:37:22through uh it's banned three ip
- 4:37:24addresses so the total amount of band
- 4:37:26ips is three you have the band ips that
- 4:37:29i think we used with unknown surf
- 4:37:31and also with store and my ip address
- 4:37:33here which for some reason it blocked i
- 4:37:35think that's because i disabled
- 4:37:37um i think i disabled announcers and
- 4:37:40pareto's using my ip in any case
- 4:37:43so what we can do now is we can go back
- 4:37:45into parrot and um
- 4:37:48if we take a look at hydra we can see
- 4:37:50that we have a few issues here so let's
- 4:37:52test this one more time by running anal
- 4:37:54surf
- 4:37:55again and then we'll try and run hydra
- 4:37:57with that so that we have a new ip we
- 4:37:58can work with
- 4:38:00because it looked through the filter
- 4:38:01bank line that it did work um
- 4:38:04so and when i'd run
- 4:38:07i'd run proxy chains with hydra here
- 4:38:10uh because actually didn't run proxy
- 4:38:12chains directly so if i try and do that
- 4:38:14right now we can actually do it here so
- 4:38:16we can save proxy chains
- 4:38:18um
- 4:38:20we'll wait for this to connect first so
- 4:38:21we're currently on the announcer tunnel
- 4:38:24so we can just run it through this so we
- 4:38:26hit enter
- 4:38:27there's going to test if possible
- 4:38:28authentication is supported and you can
- 4:38:30see it is working and
- 4:38:33immediately we're getting a few
- 4:38:34connection errors so
- 4:38:36it's going to try connecting again but
- 4:38:39what we can do is um
- 4:38:41[Music]
- 4:38:42we can say sudo
- 4:38:44we'll say
- 4:38:46proxy chains and we'll run this with
- 4:38:49hydra right and i'll enter my password
- 4:38:51here
- 4:38:52so we can see that it's currently
- 4:38:54supported
- 4:38:56and
- 4:38:57immediately we get uh authentication
- 4:38:59errors to the server so that's working
- 4:39:01fine let's take a look at the filter
- 4:39:03bank client one more time so again i'll
- 4:39:06just clear that out and we can run the
- 4:39:09fill to burn client and check the number
- 4:39:11of failed authentication attempts again
- 4:39:14and now you can see that again the
- 4:39:16amount of failed authentication attempts
- 4:39:18has moved up to 38
- 4:39:20and the currently the the total amount
- 4:39:22of band ip addresses are as follows so
- 4:39:25we have various ones that we had uh that
- 4:39:27we have uh that we got with anon surf
- 4:39:30and proxy chains to uh
- 4:39:32to a certain extent so
- 4:39:34uh that's pretty much how to view
- 4:39:37um
- 4:39:38this is pretty much how to view all the
- 4:39:39failed authentication attempts and the
- 4:39:42blocked ips which you can then use to
- 4:39:43build a geographical model of where most
- 4:39:46of the attacks are coming from even
- 4:39:47though they may be coming from a botnet
- 4:39:49uh so again that's how to use feldeban
- 4:39:51uh so again if you want to disable a
- 4:39:53particular jail uh we can just check
- 4:39:55this out here
- 4:39:57uh fill the ban and you can then modify
- 4:39:59the local configuration file so we can
- 4:40:02use fim and we say jail dot local
- 4:40:05and we enter so if i'm working with the
- 4:40:07ssh daemon i can just disable this
- 4:40:10to false here and that will disable the
- 4:40:12protection
- 4:40:13and if i just run and exit and we can
- 4:40:16try and restart this service so i can
- 4:40:18say
- 4:40:20system control
- 4:40:23we can say restart
- 4:40:25oops sorry
- 4:40:26restart let me just reduce the font size
- 4:40:28here and we'll say fill to ban
- 4:40:31service and we'll hit enter
- 4:40:34and there we are
- 4:40:35all right uh let's take a look at
- 4:40:38whether we can actually log in now
- 4:40:41so i'll say exit
- 4:40:42and this is through my local ip i'm not
- 4:40:44going to use proxy chains
- 4:40:46um so i'll say
- 4:40:48ssh will actually just ssh without proxy
- 4:40:50change ssh
- 4:40:52root at this particular ip and you can
- 4:40:55see it now works perfectly fine so if i
- 4:40:57hit another
- 4:40:58uh you know some other incorrect
- 4:41:00passwords we are now able to
- 4:41:03at least get authentication attempts
- 4:41:05across the line uh but yeah that's
- 4:41:08pretty much all that i wanted to show
- 4:41:09you guys how to do um you know with
- 4:41:11failed by how to use fill the band you
- 4:41:13know to protect to protect your server
- 4:41:15from uh ssh brute forces uh let me know
- 4:41:17if you have any questions or suggestions
- 4:41:19and i'll be seeing you in the next video
About this transcript
This page contains the full transcript of Linux Essentials for Ethical Hackers - Full InfoSec Course by freeCodeCamp.org, generated from the public captions YouTube serves with the video. The transcript has 53,297 words across 7,749 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.