Hello, everyone.
Today, we will talk about an essential command line skills for penetration testers.
First command is the history command.
As a penetration tester, it's very important to keep in mind that all the commands that we have been
using in our Besch are stored in a history file.
In order for us to view the previous commands, we can type history in our command line.
Let's try
in the penetration testing phase.
This command is very important since we might find valuable commands that has been entered by the user
or the admin.
Now, if we found of long command in our history, we can simply retype this command using its NO from
the history list.
Let's try our code DST IP Command, which is number seven or five in the list in order to repeat a command
using its number.
We need to add exclamation mark before the number.
Also, if we want to repeat the last command we typed, we can do that by typing double exclamation
marks.
Nice.
Now let's switch to common one, standard output and Kimelman standard error.
Remember that if you want to display the content of our directory or any other directory, we use the
Ellas command.
But what if we want to display the content and redirect its output to a file?
In order to do that, we have to use the greater than sine and then the name of the file you want the
output redirected to.
Let's take an example.
Let's use Ellis' in our current directory and redirect the output to a text file called output dot text.
Now, let's open the output that text file and see if we have the same output from our previous Ellas
command.
Let's verify the content with the ellos command without redirection.
Nice.
Now, if we want to use the same text file for other outputs as a log file, we have to use a double
greater than sign because one greater than sine will delete everything in the file and create the actual
file.
If it doesn't exist.
But since we want to keep the file and its content, then we have to use double greater than sine.
Let's try.
As you see it from the output we appended, the output of the second Ellas command to our current text
file.
We can also use Echo or CAD commands to redirect output to files.
Let's echo Hello World and append it to our file.
Nice.
Now let's use KAB Command, but this time we will redirect our output to a new text file.
Nice.
Now, let's switch to a standard here.
Sometimes when we create a best script, we don't want to see expected errors, or we might want to
save all errors in a log file for feature checking in order to redirect only errors to a text file.
We use the number two and greater than sign together.
Let's take an example and try to get a file which it doesn't exist and normally we should get an error.
Now let's use a standard air redirection.
As you see, there was no error because it was redirected to the er the log file.
Let's examine the file and check.
Nice, let's switch to something else now,
Peiping is extremely important when it comes to best reporting, which we will get into in later videos,
piping in turmoil means we take an output of one command and used as input for another command.
Let's take a practical example and try to filter the output of the eye of conflict command to display
our network interface information.
Now, let's pass the output of the eye of Conficker in to the grip command, using the vertical bar
or the pipe character and search for a keyword.
As you can see, we filtered the previous output and showed only anyone with the strength at zero nine.
Let's switch to some string manipulation using this said utility.
The set utility is very powerful when it comes with many functions, but we will only look at one of
them today.
Let's echo something to the screen and use that as input to our said utility, then replace one word.
Here we use the letter S to substitute the word Lennix for the word Unix.
Let's use the same set comen.
But this time we will take our input from a file.
But before we do that, let's open the file and display its content.
Let's replace the word Linux and all lines by adding the characters in our self-command
notice.
We replace the word Linux, but we did save it.
And if we had the same file again, we will notice that nothing had happened.
If we want to save, but we changed, we can redirect the output to a new file.
If we want to modify and save changes to our file, we can use the dashi argument, but we have to be
extremely careful since this argument will modify your file.
So it's better if you have a backup.
Now, let's check it out.
Changes were saved.
Nice, we had reached the end of this lesson, thank you and see you in the next room.