WEBVTT

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


00:00:03.388 --> 00:00:04.840 align:middle line:90%
[ELECTRONIC NOISES]

00:00:04.840 --> 00:00:10.180 align:middle line:90%


00:00:10.180 --> 00:00:13.270 align:middle line:84%
Upgrading command shells
to Meterpreter shells--

00:00:13.270 --> 00:00:16.870 align:middle line:84%
in this video, we are going to
be exploring the process of how

00:00:16.870 --> 00:00:18.790 align:middle line:84%
you can upgrade a
standard command

00:00:18.790 --> 00:00:21.370 align:middle line:90%
shell into a Meterpreter shell.

00:00:21.370 --> 00:00:23.230 align:middle line:84%
And of course, we've
already explored

00:00:23.230 --> 00:00:26.620 align:middle line:84%
how to do this very briefly
during the Windows and Linux

00:00:26.620 --> 00:00:30.490 align:middle line:84%
exploitation section, where we
essentially obtained or gained

00:00:30.490 --> 00:00:34.430 align:middle line:84%
access to the target system
via a typical command shell.

00:00:34.430 --> 00:00:38.980 align:middle line:84%
And we then upgraded our command
into a Meterpreter session

00:00:38.980 --> 00:00:42.400 align:middle line:84%
or shell through the use of
a post-exploitation module.

00:00:42.400 --> 00:00:45.670 align:middle line:84%
In this particular video, we'll
be going over that process,

00:00:45.670 --> 00:00:49.090 align:middle line:84%
and we'll also be exploring
an easier way or an easier

00:00:49.090 --> 00:00:51.460 align:middle line:84%
technique that can
essentially allow

00:00:51.460 --> 00:00:53.770 align:middle line:84%
us to upgrade our
standard command

00:00:53.770 --> 00:00:56.740 align:middle line:84%
shell into a Meterpreter
session or a Meterpreter shell,

00:00:56.740 --> 00:00:59.170 align:middle line:90%
depending on what you call it.

00:00:59.170 --> 00:01:01.240 align:middle line:84%
So in this particular
case, we are

00:01:01.240 --> 00:01:04.480 align:middle line:84%
going to be utilizing the
same lab environment that we

00:01:04.480 --> 00:01:07.510 align:middle line:84%
utilized in the Linux
exploitation section

00:01:07.510 --> 00:01:12.520 align:middle line:84%
where we were exploiting a
SAMBA or a SMB server on Linux.

00:01:12.520 --> 00:01:15.190 align:middle line:84%
So I'm just going to switch
over to the lab environment,

00:01:15.190 --> 00:01:16.735 align:middle line:84%
and we can go
through this process.

00:01:16.735 --> 00:01:19.540 align:middle line:90%


00:01:19.540 --> 00:01:21.682 align:middle line:84%
So I'm back in the
lab environment.

00:01:21.682 --> 00:01:23.140 align:middle line:84%
And the first step,
of course, will

00:01:23.140 --> 00:01:26.200 align:middle line:84%
involve getting the target IP
address, which we can actually

00:01:26.200 --> 00:01:28.300 align:middle line:90%
do by typing in ifconfig.

00:01:28.300 --> 00:01:30.880 align:middle line:84%
We can get the target IP
address by heading over

00:01:30.880 --> 00:01:32.560 align:middle line:90%
to the ethernet 1 interface.

00:01:32.560 --> 00:01:36.640 align:middle line:84%
And right over here, this is our
current Kali Linux IP address.

00:01:36.640 --> 00:01:39.400 align:middle line:84%
And the IP address,
or the target,

00:01:39.400 --> 00:01:42.190 align:middle line:84%
is going to be on the next
IP address within the subnet.

00:01:42.190 --> 00:01:43.990 align:middle line:84%
And of course, in
your case, the subnet

00:01:43.990 --> 00:01:45.790 align:middle line:90%
is going to be different.

00:01:45.790 --> 00:01:47.440 align:middle line:84%
And the target IP
is essentially going

00:01:47.440 --> 00:01:50.000 align:middle line:84%
to be on the third IP
address within this subnet.

00:01:50.000 --> 00:01:52.820 align:middle line:84%
So we just need to replace
the 2 with a 3 here.

00:01:52.820 --> 00:01:54.220 align:middle line:90%
So I'm just going to copy that.

00:01:54.220 --> 00:01:56.920 align:middle line:84%
We then need to again start
up the PostgreSQL Database

00:01:56.920 --> 00:01:58.300 align:middle line:90%
Service.

00:01:58.300 --> 00:02:00.370 align:middle line:84%
So I'm going to say
service postgresql start.

00:02:00.370 --> 00:02:02.350 align:middle line:84%
And we can also run
a second command

00:02:02.350 --> 00:02:06.490 align:middle line:84%
using the two of the
ampersand symbols

00:02:06.490 --> 00:02:08.949 align:middle line:84%
and saying msfconsole
to essentially run

00:02:08.949 --> 00:02:11.140 align:middle line:84%
both of these commands
together to save us

00:02:11.140 --> 00:02:13.293 align:middle line:90%
a little bit of time.

00:02:13.293 --> 00:02:13.960 align:middle line:90%
So there we are.

00:02:13.960 --> 00:02:17.350 align:middle line:84%
It's going to start PostgreSQL
or, rather, the PostgreSQL

00:02:17.350 --> 00:02:18.280 align:middle line:90%
database server.

00:02:18.280 --> 00:02:20.800 align:middle line:84%
And it's also going to start
up the Metasploit framework

00:02:20.800 --> 00:02:21.880 align:middle line:90%
console.

00:02:21.880 --> 00:02:22.600 align:middle line:90%
So there we are.

00:02:22.600 --> 00:02:24.590 align:middle line:84%
The Metasploit framework
console is started up.

00:02:24.590 --> 00:02:28.570 align:middle line:90%
We can then create a workspace.

00:02:28.570 --> 00:02:34.840 align:middle line:84%
We're just going to call
it upgrading_shells.

00:02:34.840 --> 00:02:36.130 align:middle line:90%
There we are.

00:02:36.130 --> 00:02:37.990 align:middle line:84%
We're then going to
set the global variable

00:02:37.990 --> 00:02:40.870 align:middle line:84%
for the rhosts option
to the target IP, which

00:02:40.870 --> 00:02:44.020 align:middle line:84%
will essentially save us from
having to type in the target IP

00:02:44.020 --> 00:02:46.900 align:middle line:84%
whenever we load in a module
as the variable is going

00:02:46.900 --> 00:02:48.200 align:middle line:90%
to be set globally.

00:02:48.200 --> 00:02:50.710 align:middle line:90%
So we'll change the 2 to 3.

00:02:50.710 --> 00:02:52.480 align:middle line:90%
There we are, fantastic.

00:02:52.480 --> 00:02:54.950 align:middle line:84%
We now need to gain access
to the target system.

00:02:54.950 --> 00:02:57.730 align:middle line:84%
So the first step will involve
performing an Nmap scan

00:02:57.730 --> 00:02:58.930 align:middle line:90%
on the target system.

00:02:58.930 --> 00:03:02.110 align:middle line:84%
And we will utilize
the db_nmap command

00:03:02.110 --> 00:03:05.200 align:middle line:84%
to perform the Nmap scan from
within MSF console, which

00:03:05.200 --> 00:03:07.960 align:middle line:84%
will again consequently
save the Nmap scan

00:03:07.960 --> 00:03:10.580 align:middle line:84%
results into the Metasploit
framework database.

00:03:10.580 --> 00:03:13.600 align:middle line:84%
So I'll perform some service
detection on the target.

00:03:13.600 --> 00:03:16.270 align:middle line:84%
And we will specify
the target IP.

00:03:16.270 --> 00:03:18.010 align:middle line:90%
So change the 2 to a 3.

00:03:18.010 --> 00:03:19.000 align:middle line:90%
Hit Enter.

00:03:19.000 --> 00:03:22.950 align:middle line:84%
And I'm just going to wait
for this scan to complete.

00:03:22.950 --> 00:03:26.160 align:middle line:84%
So as we explored during the
Linux exploitation section,

00:03:26.160 --> 00:03:31.110 align:middle line:84%
this is running a SAMBA
version 3, both on 139 and 445.

00:03:31.110 --> 00:03:34.080 align:middle line:84%
So we can search for the
exploit module by saying search.

00:03:34.080 --> 00:03:36.480 align:middle line:84%
And in the type, we will
limit it to exploit.

00:03:36.480 --> 00:03:38.370 align:middle line:90%
And then we can just say samba.

00:03:38.370 --> 00:03:42.030 align:middle line:84%
And we are going to be utilizing
the samba is_known_pipename

00:03:42.030 --> 00:03:45.420 align:middle line:84%
exploit module right over
here, which will essentially

00:03:45.420 --> 00:03:50.610 align:middle line:84%
allow us to upload an actual
shared object or a shared

00:03:50.610 --> 00:03:52.150 align:middle line:90%
library.

00:03:52.150 --> 00:03:57.510 align:middle line:84%
So we are going to
say use, show options.

00:03:57.510 --> 00:03:59.190 align:middle line:84%
And in this case,
the rhosts option

00:03:59.190 --> 00:04:02.820 align:middle line:84%
has already been specified for
us as well as the port option.

00:04:02.820 --> 00:04:05.440 align:middle line:84%
We do not need to set
any other options,

00:04:05.440 --> 00:04:08.040 align:middle line:90%
so we can just hit run.

00:04:08.040 --> 00:04:10.890 align:middle line:84%
This will give us access
to the target system

00:04:10.890 --> 00:04:13.710 align:middle line:84%
by a typical command
shell which, as we know,

00:04:13.710 --> 00:04:17.010 align:middle line:84%
is not an advanced
session or really is not

00:04:17.010 --> 00:04:18.450 align:middle line:90%
as advanced as Meterpreter.

00:04:18.450 --> 00:04:19.320 align:middle line:90%
So there we are.

00:04:19.320 --> 00:04:21.810 align:middle line:84%
So this is a typical
Linux command shell.

00:04:21.810 --> 00:04:22.713 align:middle line:90%
So I can hit ls.

00:04:22.713 --> 00:04:24.630 align:middle line:84%
And in this case, it
doesn't display anything,

00:04:24.630 --> 00:04:26.070 align:middle line:90%
so I can type in pwd.

00:04:26.070 --> 00:04:26.850 align:middle line:90%
There we are.

00:04:26.850 --> 00:04:29.310 align:middle line:90%
And I can then say /bin/bash -i.

00:04:29.310 --> 00:04:31.050 align:middle line:84%
And of course, as
I said, this is not

00:04:31.050 --> 00:04:33.390 align:middle line:84%
a reliable way of
accessing or interacting

00:04:33.390 --> 00:04:34.810 align:middle line:90%
with the target system.

00:04:34.810 --> 00:04:36.540 align:middle line:84%
So what we'll do
is we'll put this

00:04:36.540 --> 00:04:40.110 align:middle line:84%
in the background using
the Control and Z keyboard

00:04:40.110 --> 00:04:41.310 align:middle line:90%
combination.

00:04:41.310 --> 00:04:42.300 align:middle line:90%
There we are.

00:04:42.300 --> 00:04:44.010 align:middle line:84%
And of course, we've
already taken a look

00:04:44.010 --> 00:04:45.420 align:middle line:90%
at a session management.

00:04:45.420 --> 00:04:49.170 align:middle line:84%
So if I say sessions, you can
see we have session 1 there.

00:04:49.170 --> 00:04:51.900 align:middle line:84%
And this, you can see that
the type right over here

00:04:51.900 --> 00:04:53.700 align:middle line:84%
says that this is
a typical command

00:04:53.700 --> 00:04:56.100 align:middle line:90%
shell on Linux or on Unix.

00:04:56.100 --> 00:04:57.390 align:middle line:90%
There we are.

00:04:57.390 --> 00:05:00.420 align:middle line:84%
So we can upgrade this
particular command shell

00:05:00.420 --> 00:05:04.050 align:middle line:84%
session into a Meterpreter
shell through the use, firstly,

00:05:04.050 --> 00:05:06.630 align:middle line:90%
of a post-exploitation module.

00:05:06.630 --> 00:05:12.080 align:middle line:84%
And the name of this module is
called shell_to_meterpreter.

00:05:12.080 --> 00:05:13.315 align:middle line:90%
There we are.

00:05:13.315 --> 00:05:15.440 align:middle line:84%
I'm going to hit Enter,
and that's the module here.

00:05:15.440 --> 00:05:17.220 align:middle line:84%
And we've utilized
it previously.

00:05:17.220 --> 00:05:19.590 align:middle line:90%
So it's fairly simple to use.

00:05:19.590 --> 00:05:22.010 align:middle line:84%
So we'll say use,
paste it in there.

00:05:22.010 --> 00:05:23.630 align:middle line:84%
If we show the
options, because it

00:05:23.630 --> 00:05:28.020 align:middle line:84%
is a post-exploitation module,
we need to set the session ID.

00:05:28.020 --> 00:05:30.770 align:middle line:84%
So we're going to
say set session to 1.

00:05:30.770 --> 00:05:33.590 align:middle line:84%
And then we set the
lhost option as that

00:05:33.590 --> 00:05:37.430 align:middle line:84%
is the actual IP address
of the Kali Linux instance.

00:05:37.430 --> 00:05:40.595 align:middle line:84%
That is, again, right over
here, the IP address of the host

00:05:40.595 --> 00:05:41.970 align:middle line:84%
that will receive
the connection.

00:05:41.970 --> 00:05:45.090 align:middle line:84%
So we're going to set
that to ethernet 1.

00:05:45.090 --> 00:05:47.240 align:middle line:84%
Specifying the interface
will automatically

00:05:47.240 --> 00:05:49.580 align:middle line:90%
set up the IP for us there.

00:05:49.580 --> 00:05:52.700 align:middle line:84%
And we then do not need
to specify the port

00:05:52.700 --> 00:05:55.160 align:middle line:90%
because the port is 4433.

00:05:55.160 --> 00:05:57.860 align:middle line:84%
And our current session
that we currently have

00:05:57.860 --> 00:06:00.830 align:middle line:90%
is using port 46451.

00:06:00.830 --> 00:06:05.850 align:middle line:84%
So we can run, and that will
upgrade the command shell

00:06:05.850 --> 00:06:08.670 align:middle line:84%
into a Meterpreter shell
or a Meterpreter session.

00:06:08.670 --> 00:06:10.080 align:middle line:84%
So we'll give that
a few seconds.

00:06:10.080 --> 00:06:14.980 align:middle line:90%


00:06:14.980 --> 00:06:18.760 align:middle line:84%
So once that is done, if
we list out our sessions

00:06:18.760 --> 00:06:22.090 align:middle line:84%
you'll be able to see that
we now have a Meterpreter

00:06:22.090 --> 00:06:25.390 align:middle line:84%
session on the target system
that we obtained by, again,

00:06:25.390 --> 00:06:27.220 align:middle line:90%
upgrading our command shell.

00:06:27.220 --> 00:06:30.368 align:middle line:84%
And we can then interact
with it by saying sessions 2.

00:06:30.368 --> 00:06:30.910 align:middle line:90%
There we are.

00:06:30.910 --> 00:06:34.070 align:middle line:84%
And we now have a Meterpreter
session on the target system.

00:06:34.070 --> 00:06:35.830 align:middle line:84%
So I'm just going
to exit or close

00:06:35.830 --> 00:06:37.720 align:middle line:84%
this particular
Meterpreter session

00:06:37.720 --> 00:06:40.570 align:middle line:84%
and show you how
we can shave off

00:06:40.570 --> 00:06:44.590 align:middle line:84%
that entire process of utilizing
a post-exploitation module.

00:06:44.590 --> 00:06:45.820 align:middle line:90%
So I'm going to say exit.

00:06:45.820 --> 00:06:48.040 align:middle line:84%
That will kill the
Meterpreter session.

00:06:48.040 --> 00:06:53.350 align:middle line:84%
And in order to upgrade the
actual command shell session

00:06:53.350 --> 00:06:56.260 align:middle line:84%
through a very,
really useful command,

00:06:56.260 --> 00:06:58.120 align:middle line:84%
we can say sessions
and then open up

00:06:58.120 --> 00:07:01.150 align:middle line:90%
the Help menu right over here.

00:07:01.150 --> 00:07:04.540 align:middle line:84%
And you can see that the
sessions command essentially

00:07:04.540 --> 00:07:07.840 align:middle line:84%
allows us to upgrade a
shell or a command shell

00:07:07.840 --> 00:07:11.320 align:middle line:84%
to a Meterpreter session
on quite a few platforms.

00:07:11.320 --> 00:07:13.580 align:middle line:84%
And in this case, it
will or should work.

00:07:13.580 --> 00:07:17.620 align:middle line:84%
So we can say sessions,
and then we say upgrade.

00:07:17.620 --> 00:07:20.480 align:middle line:84%
And then we can specify
the actual session ID.

00:07:20.480 --> 00:07:23.050 align:middle line:84%
So we hit 1, and that
is going to execute

00:07:23.050 --> 00:07:25.090 align:middle line:84%
that same
post-exploitation module.

00:07:25.090 --> 00:07:27.590 align:middle line:84%
But it's automating
that process for us.

00:07:27.590 --> 00:07:28.300 align:middle line:90%
So there we are.

00:07:28.300 --> 00:07:31.180 align:middle line:84%
You can see just by typing
in this one command, that

00:07:31.180 --> 00:07:33.850 align:middle line:84%
has been facilitated
and automated for us.

00:07:33.850 --> 00:07:36.280 align:middle line:84%
And we should get the
Meterpreter session

00:07:36.280 --> 00:07:39.508 align:middle line:90%
opened in a few seconds.

00:07:39.508 --> 00:07:40.050 align:middle line:90%
There we are.

00:07:40.050 --> 00:07:42.240 align:middle line:84%
So if we list out
our sessions, you

00:07:42.240 --> 00:07:45.370 align:middle line:84%
can see that we have
sessions 3 here.

00:07:45.370 --> 00:07:48.250 align:middle line:84%
So I can say sessions
3, and there we are.

00:07:48.250 --> 00:07:50.910 align:middle line:84%
We have a Meterpreter
session on the target system.

00:07:50.910 --> 00:07:52.890 align:middle line:84%
If we type in
sysinfo, you can see

00:07:52.890 --> 00:07:55.260 align:middle line:90%
that is executed successfully.

00:07:55.260 --> 00:07:59.190 align:middle line:84%
We can say getuid, and we
also get the current user ID

00:07:59.190 --> 00:08:01.560 align:middle line:84%
that we currently
have access to.

00:08:01.560 --> 00:08:05.370 align:middle line:84%
So that is the process
of essentially upgrading

00:08:05.370 --> 00:08:08.220 align:middle line:84%
your command shell into
a Meterpreter session,

00:08:08.220 --> 00:08:09.600 align:middle line:90%
or a Meterpreter shell.

00:08:09.600 --> 00:08:11.280 align:middle line:84%
And the reason
this is important,

00:08:11.280 --> 00:08:15.750 align:middle line:84%
as we explored earlier during
the exploitation section,

00:08:15.750 --> 00:08:20.880 align:middle line:84%
is because some exploit
modules may actually not

00:08:20.880 --> 00:08:23.790 align:middle line:84%
have the support or may
not support the ability

00:08:23.790 --> 00:08:27.040 align:middle line:84%
to pair a Meterpreter
payload to begin with.

00:08:27.040 --> 00:08:29.520 align:middle line:84%
So the only way to
gain initial access

00:08:29.520 --> 00:08:30.990 align:middle line:90%
is through a command shell.

00:08:30.990 --> 00:08:32.940 align:middle line:84%
And then once you've
gained initial access

00:08:32.940 --> 00:08:34.950 align:middle line:84%
and established a
command shell session,

00:08:34.950 --> 00:08:38.159 align:middle line:84%
you can then upgrade it either
through manually loading

00:08:38.159 --> 00:08:42.480 align:middle line:84%
the post-exploitation module,
the shell_to_meterpreter

00:08:42.480 --> 00:08:45.870 align:middle line:84%
post-exploitation module, or
you can automate that process

00:08:45.870 --> 00:08:47.350 align:middle line:90%
through the sessions command.

00:08:47.350 --> 00:08:49.140 align:middle line:84%
And, again, it's
very simple to do.

00:08:49.140 --> 00:08:51.683 align:middle line:84%
And you can upgrade
as many sessions

00:08:51.683 --> 00:08:53.100 align:middle line:84%
that you currently
have, and that,

00:08:53.100 --> 00:08:56.010 align:middle line:84%
again, will help you
save time as you progress

00:08:56.010 --> 00:08:59.010 align:middle line:84%
or as you utilize the
Metasploit framework.

00:08:59.010 --> 00:09:02.880 align:middle line:84%
So that is going to conclude the
practical demonstration aspect

00:09:02.880 --> 00:09:06.170 align:middle line:90%
or side of this video.

00:09:06.170 --> 00:09:09.470 align:middle line:84%
So that concludes the
post-exploitation fundamental

00:09:09.470 --> 00:09:10.340 align:middle line:90%
section.

00:09:10.340 --> 00:09:14.060 align:middle line:84%
In the next video, we will begin
the post-exploitation process

00:09:14.060 --> 00:09:14.930 align:middle line:90%
on Windows.

00:09:14.930 --> 00:09:17.480 align:middle line:84%
So we will get started
by taking a look at some

00:09:17.480 --> 00:09:21.170 align:middle line:84%
of the various useful
post-exploitation modules

00:09:21.170 --> 00:09:23.000 align:middle line:90%
available for Windows.

00:09:23.000 --> 00:09:25.430 align:middle line:84%
And, again, we'll be
exploring the process

00:09:25.430 --> 00:09:27.620 align:middle line:84%
of utilizing them and,
of course, getting

00:09:27.620 --> 00:09:29.930 align:middle line:84%
an understanding
of what we can do

00:09:29.930 --> 00:09:32.600 align:middle line:84%
with the various
post-exploitation modules that

00:09:32.600 --> 00:09:35.000 align:middle line:84%
are currently
available for Windows.

00:09:35.000 --> 00:09:38.500 align:middle line:84%
So I'll see you
in the next video.

00:09:38.500 --> 00:09:39.000 align:middle line:90%