WEBVTT

00:00:00.000 --> 00:00:10.220 align:middle line:90%


00:00:10.220 --> 00:00:12.770 align:middle line:90%
Clearing your tracks on Linux.

00:00:12.770 --> 00:00:16.070 align:middle line:84%
In this video, we will be
exploring the process of how

00:00:16.070 --> 00:00:18.150 align:middle line:90%
to clear your tracks on Linux.

00:00:18.150 --> 00:00:21.260 align:middle line:84%
So again, we're going to be
following the same methodology

00:00:21.260 --> 00:00:25.430 align:middle line:84%
that we used during the clearing
your tracks on Windows video.

00:00:25.430 --> 00:00:28.460 align:middle line:84%
The main objective here is
to, again, follow the best

00:00:28.460 --> 00:00:30.500 align:middle line:84%
practices that I
outlined in that video

00:00:30.500 --> 00:00:34.220 align:middle line:84%
whereby if you are transferring
files onto a Linux target

00:00:34.220 --> 00:00:37.130 align:middle line:84%
system, transfer them
into the temp directory.

00:00:37.130 --> 00:00:40.580 align:middle line:84%
Furthermore, if you are
utilizing the Metasploit

00:00:40.580 --> 00:00:45.030 align:middle line:84%
framework for exploitation
and post-exploitation,

00:00:45.030 --> 00:00:48.920 align:middle line:84%
do actually keep your eye
on the actual artifacts that

00:00:48.920 --> 00:00:52.340 align:middle line:84%
are generated by those
modules and identify where

00:00:52.340 --> 00:00:53.990 align:middle line:90%
those artifacts are stored.

00:00:53.990 --> 00:00:57.050 align:middle line:84%
In the event that a
Metasploit exploitation

00:00:57.050 --> 00:00:59.180 align:middle line:84%
module or
post-exploitation module

00:00:59.180 --> 00:01:02.300 align:middle line:84%
provides you with a
clean-up resource script,

00:01:02.300 --> 00:01:06.590 align:middle line:84%
do keep or essentially note down
where that resource script is

00:01:06.590 --> 00:01:09.620 align:middle line:84%
stored so that when you
approach the final phase

00:01:09.620 --> 00:01:12.680 align:middle line:84%
of post-exploitation, you
know where it's located.

00:01:12.680 --> 00:01:15.320 align:middle line:84%
And you can use it and run
it on the target system

00:01:15.320 --> 00:01:17.960 align:middle line:84%
in order to undo what
you did or to undo

00:01:17.960 --> 00:01:20.180 align:middle line:84%
what that particular
post-exploitation

00:01:20.180 --> 00:01:22.190 align:middle line:90%
or exploitation module did.

00:01:22.190 --> 00:01:24.950 align:middle line:84%
So again, we're just going to be
following the same methodology.

00:01:24.950 --> 00:01:30.530 align:middle line:84%
And I'll be highlighting
a few important techniques

00:01:30.530 --> 00:01:33.620 align:middle line:84%
that you can run or that you
should be performing on a Linux

00:01:33.620 --> 00:01:34.250 align:middle line:90%
system.

00:01:34.250 --> 00:01:38.150 align:middle line:84%
But as I said, do keep in
mind or do consider the rules

00:01:38.150 --> 00:01:42.380 align:middle line:84%
of engagement and the
actual stipulations that are

00:01:42.380 --> 00:01:46.040 align:middle line:84%
highlighted within it in regards
to what you can and cannot do

00:01:46.040 --> 00:01:49.620 align:middle line:84%
on a target system irregardless
of the operating system.

00:01:49.620 --> 00:01:52.290 align:middle line:84%
So this video has a lab
environment attached to it.

00:01:52.290 --> 00:01:54.780 align:middle line:84%
We're going to be exploiting
the target system.

00:01:54.780 --> 00:01:57.350 align:middle line:84%
And then we can explore
a few techniques

00:01:57.350 --> 00:02:00.800 align:middle line:84%
pertinent to Linux that are very
useful in clearing your tracks.

00:02:00.800 --> 00:02:06.160 align:middle line:84%
With that being said, I'll see
you in the lab environment.

00:02:06.160 --> 00:02:08.289 align:middle line:84%
All right, so I'm back
within the lab environment.

00:02:08.289 --> 00:02:11.110 align:middle line:84%
And the first step is to gain
access to the target system.

00:02:11.110 --> 00:02:13.270 align:middle line:84%
We can identify the
target's IP address

00:02:13.270 --> 00:02:16.150 align:middle line:84%
by typing in ifconfig
and taking a look

00:02:16.150 --> 00:02:17.920 align:middle line:90%
at the interface ethernet 1.

00:02:17.920 --> 00:02:20.050 align:middle line:90%
So this is the Kali Linux IP.

00:02:20.050 --> 00:02:21.820 align:middle line:84%
The Kali Linux system
is always going

00:02:21.820 --> 00:02:24.200 align:middle line:84%
to be on the second
IP within the subnet.

00:02:24.200 --> 00:02:26.710 align:middle line:84%
So all you need to do is
just copy this value here.

00:02:26.710 --> 00:02:28.570 align:middle line:84%
In your case, it's
going to be different.

00:02:28.570 --> 00:02:31.420 align:middle line:84%
But just copy the value
and change the 2 to a 3.

00:02:31.420 --> 00:02:33.920 align:middle line:84%
And that's the
target IP address.

00:02:33.920 --> 00:02:34.420 align:middle line:90%
All right?

00:02:34.420 --> 00:02:36.760 align:middle line:90%
So let me just copy that there.

00:02:36.760 --> 00:02:39.100 align:middle line:84%
And in this case,
the target system

00:02:39.100 --> 00:02:41.740 align:middle line:84%
is running a vulnerable
version of samba.

00:02:41.740 --> 00:02:46.300 align:middle line:84%
So we can actually confirm that
by running an Nmap scan on 445.

00:02:46.300 --> 00:02:48.160 align:middle line:90%
And I'll paste in the target IP.

00:02:48.160 --> 00:02:50.590 align:middle line:84%
I'll change the 2
to 3 and hit Enter.

00:02:50.590 --> 00:02:54.370 align:middle line:84%
And you should see that it's
running samba version 3.

00:02:54.370 --> 00:02:57.068 align:middle line:84%
So we'll give this
a couple of seconds.

00:02:57.068 --> 00:02:57.610 align:middle line:90%
There we are.

00:02:57.610 --> 00:02:59.740 align:middle line:84%
You can see that samba
is indeed running.

00:02:59.740 --> 00:03:02.650 align:middle line:84%
So we can fire up the
Metasploit framework console

00:03:02.650 --> 00:03:05.140 align:middle line:84%
and load the appropriate
exploit module that

00:03:05.140 --> 00:03:08.080 align:middle line:84%
will provide us with a command
shell session on the target

00:03:08.080 --> 00:03:09.050 align:middle line:90%
system.

00:03:09.050 --> 00:03:10.990 align:middle line:84%
So I'll give this a
couple of seconds.

00:03:10.990 --> 00:03:14.860 align:middle line:84%
I'll firstly set the global
variable for the RHOSTS option

00:03:14.860 --> 00:03:18.700 align:middle line:84%
to the target IP address so
that whenever we load a module,

00:03:18.700 --> 00:03:23.440 align:middle line:84%
the RHOSTS option or value is
specified for us so that we

00:03:23.440 --> 00:03:27.160 align:middle line:84%
don't have to specify the target
IP whenever we load a module.

00:03:27.160 --> 00:03:31.630 align:middle line:84%
So I'll just launch a search
for all samba-related modules.

00:03:31.630 --> 00:03:33.970 align:middle line:84%
And the exploit module that
we are going to be using

00:03:33.970 --> 00:03:35.240 align:middle line:90%
is this one right over here.

00:03:35.240 --> 00:03:38.320 align:middle line:84%
So that's the is_known_pipename
exploit module.

00:03:38.320 --> 00:03:39.430 align:middle line:90%
So I'll say use.

00:03:39.430 --> 00:03:40.870 align:middle line:90%
Paste that in there.

00:03:40.870 --> 00:03:43.360 align:middle line:84%
And if I show the
options, you can

00:03:43.360 --> 00:03:46.780 align:middle line:84%
see that the target IP is
already specified for us.

00:03:46.780 --> 00:03:49.810 align:middle line:84%
The target port or RPORT
is specified correctly

00:03:49.810 --> 00:03:51.310 align:middle line:90%
as port 445.

00:03:51.310 --> 00:03:53.800 align:middle line:84%
We don't need to
specify the SMB_FOLDER

00:03:53.800 --> 00:03:55.360 align:middle line:90%
or the SMB_SHARE_NAME.

00:03:55.360 --> 00:03:58.300 align:middle line:84%
We can type in exploit,
and this should provide us

00:03:58.300 --> 00:04:00.100 align:middle line:84%
with a non-interactive
command shell

00:04:00.100 --> 00:04:01.600 align:middle line:84%
session, which we
can then upgrade

00:04:01.600 --> 00:04:05.080 align:middle line:84%
to a semi-interactive
bash session.

00:04:05.080 --> 00:04:06.860 align:middle line:84%
As you can see,
that is the case.

00:04:06.860 --> 00:04:08.860 align:middle line:90%
So I'll say bin bash -i.

00:04:08.860 --> 00:04:11.440 align:middle line:84%
And in this case, we gain
access to the target system

00:04:11.440 --> 00:04:13.420 align:middle line:84%
with root privileges,
which means we do not

00:04:13.420 --> 00:04:15.470 align:middle line:90%
need to elevate our privileges.

00:04:15.470 --> 00:04:15.970 align:middle line:90%
All right?

00:04:15.970 --> 00:04:18.579 align:middle line:84%
So now that that is
done, we can actually

00:04:18.579 --> 00:04:21.709 align:middle line:84%
explore the first
guideline or best practice.

00:04:21.709 --> 00:04:25.810 align:middle line:84%
And that is whenever you
are transferring files

00:04:25.810 --> 00:04:28.210 align:middle line:84%
onto a Linux system,
always store them

00:04:28.210 --> 00:04:30.010 align:middle line:90%
within a centralized directory.

00:04:30.010 --> 00:04:32.180 align:middle line:84%
And as I mentioned in
the previous video,

00:04:32.180 --> 00:04:35.350 align:middle line:84%
the best directory is
always the temp directory.

00:04:35.350 --> 00:04:40.720 align:middle line:84%
In the case of Linux, the
temp directory is called temp.

00:04:40.720 --> 00:04:42.340 align:middle line:84%
In the case of
Linux, if I navigate

00:04:42.340 --> 00:04:45.550 align:middle line:84%
to the root of the file system,
the name of the temp directory

00:04:45.550 --> 00:04:46.660 align:middle line:90%
is called tmp.

00:04:46.660 --> 00:04:48.580 align:middle line:84%
And in most cases,
a Linux system

00:04:48.580 --> 00:04:51.350 align:middle line:84%
will always have the
tmp directory available.

00:04:51.350 --> 00:04:55.208 align:middle line:84%
So I'll navigate to the tmp
directory, and there you are.

00:04:55.208 --> 00:04:57.250 align:middle line:84%
And you can see, it doesn't
have any files in it.

00:04:57.250 --> 00:05:00.670 align:middle line:84%
Now, do keep in mind that
the tmp directory is exactly

00:05:00.670 --> 00:05:02.890 align:middle line:90%
that on both Windows and Linux.

00:05:02.890 --> 00:05:05.530 align:middle line:84%
And that once the
system is restarted,

00:05:05.530 --> 00:05:08.330 align:middle line:84%
all files within the temp
directory will be deleted.

00:05:08.330 --> 00:05:10.660 align:middle line:84%
So while I do encourage
you to transfer files

00:05:10.660 --> 00:05:13.360 align:middle line:84%
to the tmp directory,
be aware of the fact

00:05:13.360 --> 00:05:16.270 align:middle line:84%
that if you are performing a
penetration test over a couple

00:05:16.270 --> 00:05:18.560 align:middle line:90%
of days to a couple of weeks.

00:05:18.560 --> 00:05:20.230 align:middle line:84%
Then whatever files
you have transferred

00:05:20.230 --> 00:05:22.480 align:middle line:84%
into the temp directory
will be deleted

00:05:22.480 --> 00:05:24.100 align:middle line:90%
once the system is rebooted.

00:05:24.100 --> 00:05:25.450 align:middle line:90%
So do keep that in mind.

00:05:25.450 --> 00:05:27.100 align:middle line:84%
And that's also
another good thing

00:05:27.100 --> 00:05:31.030 align:middle line:84%
because no traces or artifacts
that you have utilized

00:05:31.030 --> 00:05:34.390 align:middle line:84%
or you have transferred over to
the target system can be found.

00:05:34.390 --> 00:05:36.580 align:middle line:84%
So again, as I
said, if we wanted

00:05:36.580 --> 00:05:38.230 align:middle line:84%
to upload a file
to this directory,

00:05:38.230 --> 00:05:41.350 align:middle line:84%
we could either through the
manual technique of setting up

00:05:41.350 --> 00:05:44.770 align:middle line:84%
a web server and utilizing
the wget utility,

00:05:44.770 --> 00:05:47.890 align:middle line:84%
or we can utilize or upgrade
this command shell session

00:05:47.890 --> 00:05:50.890 align:middle line:84%
into a Meterpreter
session and upload files

00:05:50.890 --> 00:05:54.880 align:middle line:84%
directly using the upload
command that Meterpreter

00:05:54.880 --> 00:05:56.380 align:middle line:90%
provides to us.

00:05:56.380 --> 00:05:59.170 align:middle line:84%
The next-- and this
is a very important,

00:05:59.170 --> 00:06:01.420 align:middle line:84%
which I will not be showcasing
because it's not really

00:06:01.420 --> 00:06:02.560 align:middle line:90%
relevant now--

00:06:02.560 --> 00:06:05.260 align:middle line:84%
is going to be the
Metasploit framework

00:06:05.260 --> 00:06:08.260 align:middle line:84%
exploit in post-exploitation
modules and the artifacts

00:06:08.260 --> 00:06:09.370 align:middle line:90%
that they generate.

00:06:09.370 --> 00:06:11.080 align:middle line:84%
Given the fact that
I've already explored

00:06:11.080 --> 00:06:13.248 align:middle line:84%
how to utilize the
clean-up resource scripts,

00:06:13.248 --> 00:06:14.290 align:middle line:90%
I'll not go through that.

00:06:14.290 --> 00:06:16.480 align:middle line:84%
But again, what I
wanted to point out

00:06:16.480 --> 00:06:18.940 align:middle line:84%
is that most of
these modules will

00:06:18.940 --> 00:06:22.000 align:middle line:90%
generate quite a few artifacts.

00:06:22.000 --> 00:06:23.500 align:middle line:84%
And in the case of
Linux, there may

00:06:23.500 --> 00:06:25.090 align:middle line:84%
be an issue with
cleaning them up,

00:06:25.090 --> 00:06:28.300 align:middle line:84%
so you may need to
clean them up manually

00:06:28.300 --> 00:06:31.850 align:middle line:84%
instead of relying on
the resource scripts.

00:06:31.850 --> 00:06:35.314 align:middle line:84%
Now, let's talk about
Linux-specific techniques,

00:06:35.314 --> 00:06:36.140 align:middle line:90%
right?

00:06:36.140 --> 00:06:38.510 align:middle line:84%
So one of the cool
things with Linux--

00:06:38.510 --> 00:06:43.220 align:middle line:84%
and let me just navigate to
the home directory of the root

00:06:43.220 --> 00:06:44.030 align:middle line:90%
user.

00:06:44.030 --> 00:06:49.190 align:middle line:84%
If I list all the contents of
the root user's home directory,

00:06:49.190 --> 00:06:51.010 align:middle line:84%
you will see that
in this case, we

00:06:51.010 --> 00:06:54.430 align:middle line:84%
have the bashrc, which is
the bashrc file, which is

00:06:54.430 --> 00:06:56.350 align:middle line:90%
a configuration file for bash.

00:06:56.350 --> 00:07:00.250 align:middle line:84%
It essentially stipulates
how bash should work.

00:07:00.250 --> 00:07:05.590 align:middle line:84%
And then of course, you have a
few other dot files and folders

00:07:05.590 --> 00:07:07.420 align:middle line:84%
for the configuration
of services,

00:07:07.420 --> 00:07:10.990 align:middle line:84%
like the ssh directory,
which we already explored.

00:07:10.990 --> 00:07:15.550 align:middle line:84%
Now, in this particular system
that we have just exploited,

00:07:15.550 --> 00:07:20.140 align:middle line:84%
the bash history file is
not configured, right?

00:07:20.140 --> 00:07:24.010 align:middle line:84%
This particular version of
bash on this target system

00:07:24.010 --> 00:07:28.030 align:middle line:84%
has been configured to not
store a history of commands

00:07:28.030 --> 00:07:29.620 align:middle line:90%
in the bash history file.

00:07:29.620 --> 00:07:32.650 align:middle line:84%
Now, on most Linux
systems, you will typically

00:07:32.650 --> 00:07:34.430 align:middle line:90%
find a bash history file.

00:07:34.430 --> 00:07:38.020 align:middle line:84%
So the file will be dot
bash underscore history.

00:07:38.020 --> 00:07:41.020 align:middle line:84%
And that file stores a
history of all commands

00:07:41.020 --> 00:07:45.430 align:middle line:84%
that you have typed into bash
from whenever the system was

00:07:45.430 --> 00:07:46.510 align:middle line:90%
installed, right?

00:07:46.510 --> 00:07:49.390 align:middle line:84%
And again, this can be
limited or customized

00:07:49.390 --> 00:07:52.900 align:middle line:84%
to only display the commands
that were written or typed

00:07:52.900 --> 00:07:57.040 align:middle line:84%
in over the last one week
or one month, et cetera.

00:07:57.040 --> 00:07:59.560 align:middle line:84%
And this is typically used
by system administrators

00:07:59.560 --> 00:08:03.250 align:middle line:84%
as a security mechanism to see
what users have been doing.

00:08:03.250 --> 00:08:06.160 align:middle line:84%
So every user account
within the home directory

00:08:06.160 --> 00:08:07.780 align:middle line:90%
has a bash history file.

00:08:07.780 --> 00:08:11.410 align:middle line:84%
Now, as I said, in
this particular case,

00:08:11.410 --> 00:08:13.510 align:middle line:84%
the way bash has been
configured on this system

00:08:13.510 --> 00:08:17.950 align:middle line:84%
is that whenever a user
logs in and logs out,

00:08:17.950 --> 00:08:21.010 align:middle line:84%
the bash history file or
the history for that session

00:08:21.010 --> 00:08:21.800 align:middle line:90%
is deleted.

00:08:21.800 --> 00:08:23.470 align:middle line:84%
So I'll give you
an example here.

00:08:23.470 --> 00:08:26.760 align:middle line:84%
Let me type in a
few commands, right?

00:08:26.760 --> 00:08:29.710 align:middle line:90%
We can say cat /etc/passwd.

00:08:29.710 --> 00:08:32.218 align:middle line:84%
And I can type in
uname -r, for example.

00:08:32.218 --> 00:08:32.760 align:middle line:90%
There we are.

00:08:32.760 --> 00:08:35.460 align:middle line:84%
So we have typed in
a series of commands.

00:08:35.460 --> 00:08:37.289 align:middle line:84%
Now, from an
attacker's perspective,

00:08:37.289 --> 00:08:39.000 align:middle line:84%
you might be
thinking to yourself,

00:08:39.000 --> 00:08:40.919 align:middle line:84%
does anyone know
what I'm typing in?

00:08:40.919 --> 00:08:44.159 align:middle line:84%
Can this information be
identified at any time?

00:08:44.159 --> 00:08:47.280 align:middle line:84%
After we've compromised
the system, or when

00:08:47.280 --> 00:08:50.730 align:middle line:84%
an administrator is or an
incident responder is trying

00:08:50.730 --> 00:08:53.850 align:middle line:84%
to identify what was done on
the system, the answer to that

00:08:53.850 --> 00:08:55.260 align:middle line:90%
is yes, they can.

00:08:55.260 --> 00:08:57.180 align:middle line:84%
They can easily
identify the commands

00:08:57.180 --> 00:09:00.420 align:middle line:84%
that have been inputted
or essentially keyed

00:09:00.420 --> 00:09:04.500 align:middle line:84%
into the system via bash by
taking a look at the bash

00:09:04.500 --> 00:09:05.370 align:middle line:90%
history file.

00:09:05.370 --> 00:09:07.350 align:middle line:84%
Now, as I said in
this case, we do not

00:09:07.350 --> 00:09:10.230 align:middle line:84%
have a bash history file,
which works to our advantage.

00:09:10.230 --> 00:09:13.200 align:middle line:84%
However, on most Linux
systems that you compromise,

00:09:13.200 --> 00:09:15.250 align:middle line:84%
you will find a
bash history file.

00:09:15.250 --> 00:09:15.750 align:middle line:90%
All right?

00:09:15.750 --> 00:09:19.128 align:middle line:84%
Now, you can access
or essentially

00:09:19.128 --> 00:09:20.670 align:middle line:84%
view the history of
commands that you

00:09:20.670 --> 00:09:24.540 align:middle line:84%
have typed in for the root user
within your current session

00:09:24.540 --> 00:09:26.010 align:middle line:90%
by typing in history--

00:09:26.010 --> 00:09:27.060 align:middle line:90%
the root history.

00:09:27.060 --> 00:09:29.280 align:middle line:84%
You can see that it
displays a list of commands

00:09:29.280 --> 00:09:31.860 align:middle line:84%
that I've entered
chronologically

00:09:31.860 --> 00:09:33.160 align:middle line:90%
from the time I logged in.

00:09:33.160 --> 00:09:36.000 align:middle line:84%
You can see I navigated to
the home directory of the root

00:09:36.000 --> 00:09:36.720 align:middle line:90%
user.

00:09:36.720 --> 00:09:38.490 align:middle line:90%
I run the /etc/passwd command.

00:09:38.490 --> 00:09:42.870 align:middle line:84%
I listed out the contents of a
few directories here and there,

00:09:42.870 --> 00:09:44.280 align:middle line:90%
et cetera, et cetera.

00:09:44.280 --> 00:09:48.090 align:middle line:84%
And if I ever exit or log
out from this session,

00:09:48.090 --> 00:09:51.490 align:middle line:84%
in this particular case,
this history will be deleted.

00:09:51.490 --> 00:09:54.990 align:middle line:84%
Now, on most Linux systems,
this will not be deleted.

00:09:54.990 --> 00:09:58.900 align:middle line:84%
This information will be stored
as is in the bash history file.

00:09:58.900 --> 00:09:59.400 align:middle line:90%
All right?

00:09:59.400 --> 00:10:02.340 align:middle line:84%
So what you typically find
is within the user's home

00:10:02.340 --> 00:10:04.920 align:middle line:84%
directory, there will be a
file called bash history.

00:10:04.920 --> 00:10:09.510 align:middle line:84%
And a good measure or
rather technique to use--

00:10:09.510 --> 00:10:12.600 align:middle line:84%
and this is not really important
in the context of a pen test--

00:10:12.600 --> 00:10:15.960 align:middle line:84%
is to delete the specific
commands from the bash history

00:10:15.960 --> 00:10:18.840 align:middle line:84%
file that you typed
in or that may

00:10:18.840 --> 00:10:21.150 align:middle line:84%
indicate to an administrator
that the system has

00:10:21.150 --> 00:10:22.170 align:middle line:90%
been compromised.

00:10:22.170 --> 00:10:24.690 align:middle line:84%
For example, if they
see a command whereby

00:10:24.690 --> 00:10:26.670 align:middle line:84%
we are utilizing
wget to download

00:10:26.670 --> 00:10:30.300 align:middle line:84%
an exploit from a server, then
that's something that could

00:10:30.300 --> 00:10:35.532 align:middle line:84%
essentially set the
alarm bells, essentially

00:10:35.532 --> 00:10:37.110 align:middle line:90%
light them up on fire.

00:10:37.110 --> 00:10:39.690 align:middle line:84%
And that is an
indicator of compromise.

00:10:39.690 --> 00:10:42.720 align:middle line:84%
So instead of deleting the
contents of the bash history

00:10:42.720 --> 00:10:45.630 align:middle line:84%
file, I would always
recommend that you

00:10:45.630 --> 00:10:49.770 align:middle line:84%
delete the specific commands
you know that you typed in.

00:10:49.770 --> 00:10:52.320 align:middle line:84%
That way, it looks
or actually, it

00:10:52.320 --> 00:10:54.720 align:middle line:84%
doesn't look like someone
is actually cleared it up.

00:10:54.720 --> 00:10:56.940 align:middle line:84%
So an example of
this would be-- and I

00:10:56.940 --> 00:10:59.740 align:middle line:84%
don't think that we have a text
editor on the target system.

00:10:59.740 --> 00:11:03.370 align:middle line:84%
So if I type in nano
and vim, for example,

00:11:03.370 --> 00:11:04.870 align:middle line:84%
you can see that
it's not installed.

00:11:04.870 --> 00:11:08.260 align:middle line:84%
But what I could do is I
can just create the file.

00:11:08.260 --> 00:11:09.120 align:middle line:90%
So I'll say touch.

00:11:09.120 --> 00:11:10.680 align:middle line:84%
And this is how the
file would look.

00:11:10.680 --> 00:11:13.940 align:middle line:90%
So bash history.

00:11:13.940 --> 00:11:17.110 align:middle line:84%
And as I said, if I list all the
contents of the home directory,

00:11:17.110 --> 00:11:18.460 align:middle line:90%
this is how the file would look.

00:11:18.460 --> 00:11:21.380 align:middle line:84%
You can see, it doesn't
have any data within it.

00:11:21.380 --> 00:11:24.880 align:middle line:84%
And if I echo, for
example, I can just

00:11:24.880 --> 00:11:26.600 align:middle line:90%
specify a test command here.

00:11:26.600 --> 00:11:30.790 align:middle line:90%
So let me just type in history.

00:11:30.790 --> 00:11:31.780 align:middle line:90%
And I can say echo.

00:11:31.780 --> 00:11:34.240 align:middle line:84%
Let me just try and show you
what this would look like.

00:11:34.240 --> 00:11:38.470 align:middle line:90%
I can say 1 and cd, for example.

00:11:38.470 --> 00:11:41.620 align:middle line:84%
Let's say someone navigated
to the tmp directory.

00:11:41.620 --> 00:11:46.110 align:middle line:84%
And I'll say I want to output
that into the bash history

00:11:46.110 --> 00:11:46.610 align:middle line:90%
file.

00:11:46.610 --> 00:11:50.100 align:middle line:90%


00:11:50.100 --> 00:11:52.110 align:middle line:84%
So what an administrator
will typically

00:11:52.110 --> 00:11:56.550 align:middle line:84%
do is if they kept the contents
of the bash history file,

00:11:56.550 --> 00:12:00.525 align:middle line:84%
they'll be able to see a
series of all commands,

00:12:00.525 --> 00:12:02.790 align:middle line:84%
a list of all commands
that have been typed in.

00:12:02.790 --> 00:12:05.310 align:middle line:84%
And in this case, they'll
be able to see the commands

00:12:05.310 --> 00:12:06.280 align:middle line:90%
that you have typed in.

00:12:06.280 --> 00:12:09.150 align:middle line:84%
So there's two ways of
clearing the bash history.

00:12:09.150 --> 00:12:12.660 align:middle line:84%
As I said, you can go in
and delete individual lines

00:12:12.660 --> 00:12:15.510 align:middle line:84%
or commands that
you typed in, or you

00:12:15.510 --> 00:12:21.370 align:middle line:84%
can type in the history hyphen
C command to clear the history.

00:12:21.370 --> 00:12:23.940 align:middle line:84%
So when I type in
history now, you

00:12:23.940 --> 00:12:26.748 align:middle line:84%
can see that it's only
displaying the history command.

00:12:26.748 --> 00:12:28.290 align:middle line:84%
So this is something
that I recommend

00:12:28.290 --> 00:12:32.940 align:middle line:84%
that you do after you're
essentially done on the Linux

00:12:32.940 --> 00:12:33.780 align:middle line:90%
target system.

00:12:33.780 --> 00:12:37.290 align:middle line:84%
It's just a good security
measure to perform.

00:12:37.290 --> 00:12:40.410 align:middle line:84%
Now, as I said, in
the case of Linux,

00:12:40.410 --> 00:12:44.100 align:middle line:84%
the process essentially
mirrors the process on Windows.

00:12:44.100 --> 00:12:49.560 align:middle line:84%
The most important thing
to note or to keep in mind

00:12:49.560 --> 00:12:52.590 align:middle line:84%
is whether or not you're
using the Metasploit framework

00:12:52.590 --> 00:12:54.990 align:middle line:84%
for exploitation and
post exploitation.

00:12:54.990 --> 00:12:56.910 align:middle line:84%
Secondly, if you're
transferring files,

00:12:56.910 --> 00:13:00.120 align:middle line:84%
have a centralized location
for them, that in a directory

00:13:00.120 --> 00:13:01.800 align:middle line:90%
that is not frequently accessed.

00:13:01.800 --> 00:13:04.560 align:middle line:84%
And a good example of
that is the tmp directory.

00:13:04.560 --> 00:13:06.810 align:middle line:84%
And of course, when you're
done with the system,

00:13:06.810 --> 00:13:10.170 align:middle line:84%
make sure to essentially
get rid of any traces

00:13:10.170 --> 00:13:11.890 align:middle line:90%
that you were on the system.

00:13:11.890 --> 00:13:15.390 align:middle line:84%
So that involves modifying or
deleting the bash history file

00:13:15.390 --> 00:13:18.480 align:middle line:84%
or just clearing the
bash history itself.

00:13:18.480 --> 00:13:20.160 align:middle line:90%
As I said, in this case--

00:13:20.160 --> 00:13:22.020 align:middle line:84%
let me type in a
few commands here.

00:13:22.020 --> 00:13:28.560 align:middle line:84%
I'll just try, and I'll just
type in a few test commands.

00:13:28.560 --> 00:13:30.118 align:middle line:84%
And if I type in
history, you can see

00:13:30.118 --> 00:13:31.410 align:middle line:90%
that those commands are logged.

00:13:31.410 --> 00:13:33.060 align:middle line:90%
However, if I exit--

00:13:33.060 --> 00:13:35.440 align:middle line:84%
and let me just
terminate this session.

00:13:35.440 --> 00:13:37.860 align:middle line:84%
And let me try and gain
another command shell

00:13:37.860 --> 00:13:39.992 align:middle line:90%
session once again.

00:13:39.992 --> 00:13:42.450 align:middle line:84%
Let's see if it provides us
with the command shell session.

00:13:42.450 --> 00:13:42.992 align:middle line:90%
There we are.

00:13:42.992 --> 00:13:45.360 align:middle line:90%
So I'll say /bin/bash -i.

00:13:45.360 --> 00:13:48.520 align:middle line:84%
And if I type in
history, you can see

00:13:48.520 --> 00:13:51.520 align:middle line:90%
that data is still persisted.

00:13:51.520 --> 00:13:55.900 align:middle line:84%
And this is something that
can be very dangerous or very

00:13:55.900 --> 00:13:58.840 align:middle line:84%
detrimental during a pen
test, especially if there's

00:13:58.840 --> 00:14:00.970 align:middle line:84%
an active blue team
on the other side that

00:14:00.970 --> 00:14:04.610 align:middle line:84%
are trying to identify any
indicators of compromise.

00:14:04.610 --> 00:14:07.720 align:middle line:84%
So whenever you're done,
just clear out your history.

00:14:07.720 --> 00:14:10.210 align:middle line:90%
And if I now exit once again--

00:14:10.210 --> 00:14:12.100 align:middle line:90%
let me just exit.

00:14:12.100 --> 00:14:14.710 align:middle line:84%
I'm just going to run
the module once again.

00:14:14.710 --> 00:14:16.660 align:middle line:90%
I'll just say exploit.

00:14:16.660 --> 00:14:21.900 align:middle line:84%
And I'll just open up a
bash session once again--

00:14:21.900 --> 00:14:23.814 align:middle line:90%
/bin/bash -i.

00:14:23.814 --> 00:14:27.690 align:middle line:84%
If I type in history, you
can see that in this case,

00:14:27.690 --> 00:14:30.857 align:middle line:84%
for some reason, the
actual history file is not

00:14:30.857 --> 00:14:31.440 align:middle line:90%
being cleared.

00:14:31.440 --> 00:14:34.230 align:middle line:90%
But that is primarily because--

00:14:34.230 --> 00:14:37.880 align:middle line:84%
let me navigate to the
root of the C drive here.

00:14:37.880 --> 00:14:41.392 align:middle line:84%
If I take a look at the
bash history file now--

00:14:41.392 --> 00:14:43.100 align:middle line:84%
and this is something
that I didn't think

00:14:43.100 --> 00:14:46.910 align:middle line:84%
would work primarily
because it was disabled.

00:14:46.910 --> 00:14:49.730 align:middle line:84%
But you can see that once I
created the bash history file,

00:14:49.730 --> 00:14:52.520 align:middle line:84%
it's now storing
all of the commands

00:14:52.520 --> 00:14:53.930 align:middle line:90%
within the bash history file.

00:14:53.930 --> 00:14:58.460 align:middle line:84%
So as I said, if you want to
get rid of the history now,

00:14:58.460 --> 00:15:03.960 align:middle line:84%
what you can do is you
can say cat /dev/null.

00:15:03.960 --> 00:15:07.370 align:middle line:84%
And you can then clear
it out and specify

00:15:07.370 --> 00:15:11.150 align:middle line:84%
that you want to redirect
that to history or to the bash

00:15:11.150 --> 00:15:12.270 align:middle line:90%
history file.

00:15:12.270 --> 00:15:17.570 align:middle line:84%
So if I now say history,
it's still displaying that.

00:15:17.570 --> 00:15:20.500 align:middle line:90%
And if I say history clear--

00:15:20.500 --> 00:15:21.160 align:middle line:90%
let's see.

00:15:21.160 --> 00:15:22.328 align:middle line:90%
History once again.

00:15:22.328 --> 00:15:23.120 align:middle line:90%
Yeah, there we are.

00:15:23.120 --> 00:15:24.070 align:middle line:90%
So that's cleared now.

00:15:24.070 --> 00:15:26.800 align:middle line:90%
And cat bash history.

00:15:26.800 --> 00:15:29.953 align:middle line:84%
It should only be showing
the commands that I typed in.

00:15:29.953 --> 00:15:30.620 align:middle line:90%
So there we are.

00:15:30.620 --> 00:15:33.520 align:middle line:84%
So that is how to
clear the bash history.

00:15:33.520 --> 00:15:36.640 align:middle line:84%
As I said, in this case,
there was a bit of an issue

00:15:36.640 --> 00:15:40.090 align:middle line:84%
because I created the
bash history file.

00:15:40.090 --> 00:15:45.910 align:middle line:84%
And that consequently made
bash essentially use that file

00:15:45.910 --> 00:15:47.290 align:middle line:90%
for storing the history.

00:15:47.290 --> 00:15:49.540 align:middle line:84%
And once we cleared
the history then

00:15:49.540 --> 00:15:53.110 align:middle line:84%
and got rid of the content
within the bash history file,

00:15:53.110 --> 00:15:55.180 align:middle line:84%
the history was
essentially cleared.

00:15:55.180 --> 00:15:59.660 align:middle line:84%
So as I said, this was
an unorthodox example.

00:15:59.660 --> 00:16:02.230 align:middle line:84%
In most cases, the bash history
file will already exist.

00:16:02.230 --> 00:16:04.780 align:middle line:84%
In that case, you can
run the following command

00:16:04.780 --> 00:16:06.220 align:middle line:90%
to essentially clear it.

00:16:06.220 --> 00:16:10.160 align:middle line:84%
And you can then run the
history clear command as well.

00:16:10.160 --> 00:16:12.940 align:middle line:84%
So that is going to conclude
the practical demonstration

00:16:12.940 --> 00:16:15.130 align:middle line:90%
site of this video.

00:16:15.130 --> 00:16:18.480 align:middle line:84%
All right, so that concludes
the clearing your track section

00:16:18.480 --> 00:16:19.650 align:middle line:90%
of this course.

00:16:19.650 --> 00:16:23.107 align:middle line:84%
And that is the
final section that we

00:16:23.107 --> 00:16:24.940 align:middle line:84%
are going to be covering
within this course.

00:16:24.940 --> 00:16:27.660 align:middle line:84%
So now that we've essentially
gone through all the course

00:16:27.660 --> 00:16:29.970 align:middle line:84%
material and the
labs, we can move on

00:16:29.970 --> 00:16:31.890 align:middle line:84%
to the final video
within this course, which

00:16:31.890 --> 00:16:34.500 align:middle line:84%
is going to be the course
conclusion, where we'll

00:16:34.500 --> 00:16:37.530 align:middle line:84%
essentially be taking a look
at what we've learned so far

00:16:37.530 --> 00:16:42.690 align:middle line:84%
and essentially comparing our
learning objectives that we

00:16:42.690 --> 00:16:45.210 align:middle line:84%
highlighted in the
introduction to the course

00:16:45.210 --> 00:16:47.130 align:middle line:84%
and seeing whether
we have essentially

00:16:47.130 --> 00:16:48.600 align:middle line:90%
hit all of those marks.

00:16:48.600 --> 00:16:52.940 align:middle line:84%
With that being said, I'll be
seeing you in the final video.

00:16:52.940 --> 00:16:54.000 align:middle line:90%