WEBVTT

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


00:00:03.388 --> 00:00:05.808 align:middle line:90%
[MUSIC PLAYING]

00:00:05.808 --> 00:00:10.170 align:middle line:90%


00:00:10.170 --> 00:00:13.110 align:middle line:84%
Automating Metasploit
with resource scripts.

00:00:13.110 --> 00:00:15.990 align:middle line:84%
In the previous sections,
we have explored the process

00:00:15.990 --> 00:00:19.170 align:middle line:84%
of utilizing the Metasploit
framework for a wide variety

00:00:19.170 --> 00:00:21.270 align:middle line:84%
of tasks like
information gathering,

00:00:21.270 --> 00:00:25.290 align:middle line:84%
port scanning, enumeration, as
well as vulnerability scanning,

00:00:25.290 --> 00:00:27.000 align:middle line:90%
and now client side attacks.

00:00:27.000 --> 00:00:30.030 align:middle line:84%
And through that process
or through that time,

00:00:30.030 --> 00:00:33.240 align:middle line:84%
you pretty much should
have been able to identify

00:00:33.240 --> 00:00:36.600 align:middle line:84%
or been able to notice that
there are a few commands that

00:00:36.600 --> 00:00:40.230 align:middle line:84%
can be quite repetitive,
for example, like setting up

00:00:40.230 --> 00:00:42.480 align:middle line:84%
a multi handler
for your payloads,

00:00:42.480 --> 00:00:45.780 align:middle line:84%
and that's where resource
scripts come into play.

00:00:45.780 --> 00:00:47.490 align:middle line:84%
All right, so
Metasploit essentially

00:00:47.490 --> 00:00:49.860 align:middle line:84%
provides you with
the ability to set up

00:00:49.860 --> 00:00:53.940 align:middle line:84%
resource scripts to automate
repetitive tasks and commands.

00:00:53.940 --> 00:00:55.690 align:middle line:84%
An example of this
would be, again,

00:00:55.690 --> 00:00:57.690 align:middle line:84%
the process of setting
up a multi handler

00:00:57.690 --> 00:00:58.770 align:middle line:90%
for your payloads.

00:00:58.770 --> 00:01:00.870 align:middle line:84%
And the process can
be quite cumbersome,

00:01:00.870 --> 00:01:03.570 align:middle line:84%
because first and foremost, you
need to start up the Metasploit

00:01:03.570 --> 00:01:05.099 align:middle line:90%
framework console.

00:01:05.099 --> 00:01:07.230 align:middle line:84%
You then need to
set the payload,

00:01:07.230 --> 00:01:09.420 align:middle line:84%
or essentially
specify that you want

00:01:09.420 --> 00:01:12.330 align:middle line:84%
to utilize the multi handler,
then set the payload,

00:01:12.330 --> 00:01:15.000 align:middle line:84%
set the various options
associated with the payload,

00:01:15.000 --> 00:01:16.560 align:middle line:90%
and then hit Run.

00:01:16.560 --> 00:01:20.520 align:middle line:84%
So we can automate this process
by creating a resource script.

00:01:20.520 --> 00:01:23.820 align:middle line:84%
Now, resource scripts,
in regards to the way

00:01:23.820 --> 00:01:27.060 align:middle line:84%
they operate, operate very
closely or very similarly

00:01:27.060 --> 00:01:28.270 align:middle line:90%
to batch scripts.

00:01:28.270 --> 00:01:31.320 align:middle line:84%
So if you have ever utilized
batch scripts on Windows,

00:01:31.320 --> 00:01:35.370 align:middle line:84%
you know that all you need to
do is create the batch script,

00:01:35.370 --> 00:01:37.410 align:middle line:84%
and then within the
script, you just specify

00:01:37.410 --> 00:01:40.350 align:middle line:84%
the commands that you'd
like to run sequentially.

00:01:40.350 --> 00:01:42.120 align:middle line:84%
And then when you
want to automate

00:01:42.120 --> 00:01:44.610 align:middle line:84%
or when you want to run all
of these commands at once,

00:01:44.610 --> 00:01:46.140 align:middle line:84%
you just run the
script and it'll

00:01:46.140 --> 00:01:48.420 align:middle line:84%
execute all of the
commands that you

00:01:48.420 --> 00:01:51.180 align:middle line:84%
specified within the file
sequentially, from the top

00:01:51.180 --> 00:01:52.270 align:middle line:90%
to the bottom.

00:01:52.270 --> 00:01:55.780 align:middle line:84%
So resource scripts work
essentially in the same way.

00:01:55.780 --> 00:01:59.310 align:middle line:84%
Now, we can load the resource
script with MSF console

00:01:59.310 --> 00:02:01.590 align:middle line:84%
and furthermore,
or consequently,

00:02:01.590 --> 00:02:04.710 align:middle line:84%
execute or automate the
execution of the commands

00:02:04.710 --> 00:02:06.960 align:middle line:84%
that we have specified
within the resource script.

00:02:06.960 --> 00:02:09.030 align:middle line:84%
So we can utilize
resource scripts

00:02:09.030 --> 00:02:11.850 align:middle line:84%
to automate a wide
variety of tasks,

00:02:11.850 --> 00:02:14.400 align:middle line:84%
like setting up a multi
handler, as well as

00:02:14.400 --> 00:02:16.020 align:middle line:90%
loading and executing payloads.

00:02:16.020 --> 00:02:18.210 align:middle line:84%
You can pretty much
automate every command

00:02:18.210 --> 00:02:20.760 align:middle line:84%
that you can run within the
Metasploit framework console,

00:02:20.760 --> 00:02:25.290 align:middle line:84%
from checking the status of the
database to loading a module,

00:02:25.290 --> 00:02:27.480 align:middle line:84%
loading an exploit,
running an exploit,

00:02:27.480 --> 00:02:30.970 align:middle line:84%
specifying the module options or
the payload options, et cetera,

00:02:30.970 --> 00:02:31.470 align:middle line:90%
et cetera.

00:02:31.470 --> 00:02:35.670 align:middle line:84%
You really can automate almost
every aspect of the Metasploit

00:02:35.670 --> 00:02:38.260 align:middle line:84%
framework console through
a resource script.

00:02:38.260 --> 00:02:40.320 align:middle line:84%
So let's actually see
how we can utilize

00:02:40.320 --> 00:02:42.840 align:middle line:84%
them to automate repetitive
tasks like setting up

00:02:42.840 --> 00:02:43.920 align:middle line:90%
a multi handler.

00:02:43.920 --> 00:02:49.700 align:middle line:84%
So I'll switch back onto my
Kali VM, and I will get started.

00:02:49.700 --> 00:02:52.000 align:middle line:84%
All right, so I'm
back on my Kali VM

00:02:52.000 --> 00:02:54.910 align:middle line:84%
and we can get started with
creating a resource script.

00:02:54.910 --> 00:02:57.730 align:middle line:84%
However, before we
do that, we also

00:02:57.730 --> 00:03:00.340 align:middle line:84%
have a series or a collection
of resource scripts

00:03:00.340 --> 00:03:03.610 align:middle line:84%
that actually come
pre-packaged with Kali Linux,

00:03:03.610 --> 00:03:05.950 align:middle line:84%
so you can actually
view them by listing out

00:03:05.950 --> 00:03:09.580 align:middle line:84%
the contents of the directory
user share Metasploit

00:03:09.580 --> 00:03:12.970 align:middle line:84%
framework, after which you
can head over into the scripts

00:03:12.970 --> 00:03:17.440 align:middle line:84%
directory and then specify
the resource directory here.

00:03:17.440 --> 00:03:20.290 align:middle line:84%
And this is the list
of resource scripts

00:03:20.290 --> 00:03:24.040 align:middle line:84%
that come pre-packaged with
the Metasploit framework

00:03:24.040 --> 00:03:24.910 align:middle line:90%
on Kali Linux.

00:03:24.910 --> 00:03:28.810 align:middle line:84%
As you can see, the actual
file structure and extension

00:03:28.810 --> 00:03:30.085 align:middle line:90%
is very simple to understand.

00:03:30.085 --> 00:03:32.380 align:middle line:84%
You have the name of the
resource script, which

00:03:32.380 --> 00:03:34.100 align:middle line:90%
you can call whatever you want.

00:03:34.100 --> 00:03:35.650 align:middle line:84%
However, I would
recommend giving it

00:03:35.650 --> 00:03:39.590 align:middle line:84%
a name that essentially provides
it or essentially provides you

00:03:39.590 --> 00:03:42.130 align:middle line:84%
with the description of what
the resource script does,

00:03:42.130 --> 00:03:44.380 align:middle line:84%
and then you provide
the extension, RC.

00:03:44.380 --> 00:03:47.390 align:middle line:84%
So if we just open one
of these files here,

00:03:47.390 --> 00:03:50.020 align:middle line:84%
so I'm just going to, again,
modify the actual command here,

00:03:50.020 --> 00:03:52.437 align:middle line:84%
and we're just going to open
one of these resource scripts

00:03:52.437 --> 00:03:53.170 align:middle line:90%
with Vim.

00:03:53.170 --> 00:03:54.430 align:middle line:90%
Vim is a text editor.

00:03:54.430 --> 00:03:59.080 align:middle line:84%
You can use whatever other
terminal or graphical text

00:03:59.080 --> 00:04:00.650 align:middle line:84%
editor that you are
comfortable with.

00:04:00.650 --> 00:04:01.850 align:middle line:90%
We can check one of them.

00:04:01.850 --> 00:04:05.290 align:middle line:84%
So let's check out the first
one, which is autobrute.rc.

00:04:05.290 --> 00:04:08.110 align:middle line:84%
So this is quite an
advanced resource script

00:04:08.110 --> 00:04:11.050 align:middle line:84%
in regards to the functionality
that it actually performs,

00:04:11.050 --> 00:04:14.620 align:middle line:84%
and you can see that you can
specify some documentation

00:04:14.620 --> 00:04:18.579 align:middle line:84%
and then you can also,
again, insert or call

00:04:18.579 --> 00:04:22.360 align:middle line:84%
upon Ruby or some Ruby
functionality, if you want.

00:04:22.360 --> 00:04:25.000 align:middle line:84%
And all you need to do is
just specify all the commands

00:04:25.000 --> 00:04:26.830 align:middle line:84%
that you want to
run sequentially,

00:04:26.830 --> 00:04:28.160 align:middle line:90%
and you'll be able to do that.

00:04:28.160 --> 00:04:29.660 align:middle line:84%
In our case, we are
not really going

00:04:29.660 --> 00:04:32.020 align:middle line:84%
to be creating an advanced
resource script like this.

00:04:32.020 --> 00:04:35.170 align:middle line:84%
We are going to try to automate
the process of setting up

00:04:35.170 --> 00:04:37.790 align:middle line:84%
a handler for the payloads
that we generated.

00:04:37.790 --> 00:04:41.590 align:middle line:84%
So again, if you remember, if I
navigate into Windows payloads,

00:04:41.590 --> 00:04:44.440 align:middle line:84%
we can automate the process
of setting up a multi handler

00:04:44.440 --> 00:04:46.550 align:middle line:90%
for any one of these payloads.

00:04:46.550 --> 00:04:50.510 align:middle line:84%
So the way we would do that,
if traditionally speaking,

00:04:50.510 --> 00:04:52.420 align:middle line:84%
we could set up a
handler here, and I'll

00:04:52.420 --> 00:04:53.810 align:middle line:90%
take you through that process.

00:04:53.810 --> 00:04:57.310 align:middle line:84%
So what you would typically do
manually is say MSF console,

00:04:57.310 --> 00:04:59.830 align:middle line:84%
and then you would wait for
MSF console to start up.

00:04:59.830 --> 00:05:01.630 align:middle line:90%
So again, that takes time.

00:05:01.630 --> 00:05:04.300 align:middle line:84%
And then once it
started up, you then

00:05:04.300 --> 00:05:08.270 align:middle line:84%
specify the actual multi
handler, set the payload.

00:05:08.270 --> 00:05:12.200 align:middle line:84%
So we would say
use multi handler

00:05:12.200 --> 00:05:17.830 align:middle line:84%
and then set the payload
to Windows Meterpreter,

00:05:17.830 --> 00:05:21.130 align:middle line:84%
reverse TCP, and
then you would set

00:05:21.130 --> 00:05:25.090 align:middle line:84%
the L host option to the
actual Kali Linux IP,

00:05:25.090 --> 00:05:27.610 align:middle line:84%
or the attacker's IP address,
And then set the L port

00:05:27.610 --> 00:05:30.670 align:middle line:84%
to the one you specified
when you were creating

00:05:30.670 --> 00:05:32.710 align:middle line:84%
the actual payload
with MS Venom,

00:05:32.710 --> 00:05:35.440 align:middle line:84%
and then you would hit Run,
or you could run it also

00:05:35.440 --> 00:05:37.157 align:middle line:90%
in the background as a job.

00:05:37.157 --> 00:05:39.490 align:middle line:84%
So we would hit Run, and that
will start up the handler.

00:05:39.490 --> 00:05:42.010 align:middle line:84%
So you can see that that
takes quite a lot of time.

00:05:42.010 --> 00:05:46.940 align:middle line:84%
What you can do in replacement
of this is set up an RC script.

00:05:46.940 --> 00:05:49.120 align:middle line:84%
So let me just exit
from MSF console,

00:05:49.120 --> 00:05:51.980 align:middle line:84%
and we'll head over
to the first tab here.

00:05:51.980 --> 00:05:54.730 align:middle line:84%
So if I wanted to set
up a handler resource

00:05:54.730 --> 00:05:58.030 align:middle line:84%
script to essentially set up a
multi handler for the Windows

00:05:58.030 --> 00:05:59.960 align:middle line:84%
payloads, I would
again create one.

00:05:59.960 --> 00:06:01.720 align:middle line:84%
So you can utilize
a text editor.

00:06:01.720 --> 00:06:05.410 align:middle line:84%
In my case, I'll use Vim,
so I'll call it handler.rc.

00:06:05.410 --> 00:06:08.320 align:middle line:84%
And within it, I can
then specify the commands

00:06:08.320 --> 00:06:10.750 align:middle line:84%
that I would typically run
when setting up a handler.

00:06:10.750 --> 00:06:14.770 align:middle line:84%
So I would say use, and then
I would say multi handler,

00:06:14.770 --> 00:06:19.090 align:middle line:84%
so multi handler, and then I
would set the payload option

00:06:19.090 --> 00:06:21.490 align:middle line:84%
and make sure that
PAYLOAD is in all caps,

00:06:21.490 --> 00:06:29.090 align:middle line:84%
and I would say Windows
Meterpreter reverse TCP,

00:06:29.090 --> 00:06:31.340 align:middle line:84%
and then I would set to
the actual payload options,

00:06:31.340 --> 00:06:34.700 align:middle line:84%
like the L host
value, so 10.10.10.5,

00:06:34.700 --> 00:06:40.920 align:middle line:84%
and then set L port to 1234, and
then I typically would hit Run,

00:06:40.920 --> 00:06:41.420 align:middle line:90%
all right?

00:06:41.420 --> 00:06:43.250 align:middle line:84%
Now, the important
thing to note here

00:06:43.250 --> 00:06:46.010 align:middle line:84%
is that you need to specify
the commands sequentially,

00:06:46.010 --> 00:06:49.160 align:middle line:84%
from the first command all
the way to the last command,

00:06:49.160 --> 00:06:51.500 align:middle line:84%
with the first command
being at the topmost

00:06:51.500 --> 00:06:55.140 align:middle line:84%
and the last command being at
the end of the actual script.

00:06:55.140 --> 00:06:57.570 align:middle line:84%
So once you're done, you
can just save the script.

00:06:57.570 --> 00:07:00.950 align:middle line:84%
So I'm going to write and quit,
and we have the Handler script

00:07:00.950 --> 00:07:01.950 align:middle line:90%
right over here.

00:07:01.950 --> 00:07:05.270 align:middle line:84%
So in order to load it and
actually see how this works,

00:07:05.270 --> 00:07:08.780 align:middle line:84%
we need to type in MSF console
and then use the R option,

00:07:08.780 --> 00:07:11.540 align:middle line:84%
and then specify the
actual script or the path

00:07:11.540 --> 00:07:12.240 align:middle line:90%
to the script.

00:07:12.240 --> 00:07:17.030 align:middle line:84%
So if we say MSF console,
our handler.rc, we hit Enter,

00:07:17.030 --> 00:07:19.443 align:middle line:84%
it is now going to automate
that entire process.

00:07:19.443 --> 00:07:21.860 align:middle line:84%
So it's firstly going to start
up the Metasploit framework

00:07:21.860 --> 00:07:23.780 align:middle line:90%
console.

00:07:23.780 --> 00:07:27.788 align:middle line:84%
So again, we're going to
give that a few seconds.

00:07:27.788 --> 00:07:28.330 align:middle line:90%
There we are.

00:07:28.330 --> 00:07:30.550 align:middle line:84%
As you can see, it's
handled or has essentially

00:07:30.550 --> 00:07:32.600 align:middle line:90%
automated that entire process.

00:07:32.600 --> 00:07:34.900 align:middle line:84%
So first and foremost,
as you can see here,

00:07:34.900 --> 00:07:37.510 align:middle line:84%
it knows that this
is a resource script.

00:07:37.510 --> 00:07:39.670 align:middle line:84%
So it starts
executing the commands

00:07:39.670 --> 00:07:42.340 align:middle line:84%
from the topmost all the way to
the end of the resource script.

00:07:42.340 --> 00:07:45.370 align:middle line:84%
So firstly, we say
use multi handler.

00:07:45.370 --> 00:07:48.190 align:middle line:84%
It then sets the payload to
Windows Meterpreter reverse

00:07:48.190 --> 00:07:49.090 align:middle line:90%
TCP.

00:07:49.090 --> 00:07:53.110 align:middle line:84%
It then sets the L host value,
as well as the L port value,

00:07:53.110 --> 00:07:56.050 align:middle line:84%
and then it also executes
the Run command, which then

00:07:56.050 --> 00:07:58.240 align:middle line:90%
starts the reverse TCP handler.

00:07:58.240 --> 00:08:00.490 align:middle line:84%
So you can see how
useful this can be.

00:08:00.490 --> 00:08:03.790 align:middle line:84%
And this is just one example
of what a resource script can

00:08:03.790 --> 00:08:04.990 align:middle line:90%
actually help you automate.

00:08:04.990 --> 00:08:09.550 align:middle line:84%
So if we terminate that and
we then exit from MSF console,

00:08:09.550 --> 00:08:12.530 align:middle line:84%
we can take a look at another
one, or another example.

00:08:12.530 --> 00:08:14.920 align:middle line:84%
So I can create
another one called--

00:08:14.920 --> 00:08:17.860 align:middle line:84%
let's see, we can
say or we can utilize

00:08:17.860 --> 00:08:22.070 align:middle line:90%
one called maybe portscan.rc.

00:08:22.070 --> 00:08:23.750 align:middle line:84%
And within this,
we are simply going

00:08:23.750 --> 00:08:26.435 align:middle line:84%
to say we want to use
a particular module.

00:08:26.435 --> 00:08:27.810 align:middle line:84%
So to get the name
of the module,

00:08:27.810 --> 00:08:29.720 align:middle line:84%
we're just going to
open up MSF console just

00:08:29.720 --> 00:08:32.299 align:middle line:84%
to make sure that we
actually have the module name

00:08:32.299 --> 00:08:33.720 align:middle line:90%
or have it set correctly.

00:08:33.720 --> 00:08:36.268 align:middle line:84%
So we'll open up
MSF console here,

00:08:36.268 --> 00:08:37.685 align:middle line:84%
and we'll give
that a few seconds.

00:08:37.685 --> 00:08:41.419 align:middle line:90%


00:08:41.419 --> 00:08:43.890 align:middle line:84%
All right, so I'm going to
search for the port scan module

00:08:43.890 --> 00:08:46.350 align:middle line:90%
that I want to use.

00:08:46.350 --> 00:08:48.690 align:middle line:84%
And we'll use the
TCP port scan module,

00:08:48.690 --> 00:08:50.428 align:middle line:90%
so I'm just going to say use.

00:08:50.428 --> 00:08:50.970 align:middle line:90%
There we are.

00:08:50.970 --> 00:08:54.120 align:middle line:84%
And if we show the options here,
the only option we need to set

00:08:54.120 --> 00:08:56.820 align:middle line:84%
is the R hosts option and
maybe the ports range,

00:08:56.820 --> 00:08:58.180 align:middle line:90%
if you want to customize that.

00:08:58.180 --> 00:09:01.380 align:middle line:84%
So we can automate
this process by firstly

00:09:01.380 --> 00:09:03.370 align:middle line:90%
adding the actual module here.

00:09:03.370 --> 00:09:05.700 align:middle line:84%
So we're going to say
use and specify that.

00:09:05.700 --> 00:09:10.020 align:middle line:84%
We're then going to say set R
hosts to maybe the target IP,

00:09:10.020 --> 00:09:12.720 align:middle line:84%
which in this case
will be 10.10.10.7.

00:09:12.720 --> 00:09:14.790 align:middle line:84%
And then we can
probably hit Run,

00:09:14.790 --> 00:09:16.920 align:middle line:84%
and this process will
essentially automate

00:09:16.920 --> 00:09:18.570 align:middle line:90%
the port scanning process.

00:09:18.570 --> 00:09:21.060 align:middle line:84%
And of course, you can
customize the R host's value

00:09:21.060 --> 00:09:22.300 align:middle line:90%
to whatever you want.

00:09:22.300 --> 00:09:24.990 align:middle line:84%
So if I write type
in write and quit

00:09:24.990 --> 00:09:27.900 align:middle line:84%
and let me exit from this
particular session here,

00:09:27.900 --> 00:09:33.840 align:middle line:84%
we can then say MSF console,
R for resource script,

00:09:33.840 --> 00:09:36.870 align:middle line:84%
and then we can say
port scan and hit Enter.

00:09:36.870 --> 00:09:39.660 align:middle line:84%
Again, that's going to start
the Metasploit framework console

00:09:39.660 --> 00:09:42.450 align:middle line:84%
and it's then going to run all
of those commands sequentially.

00:09:42.450 --> 00:09:44.130 align:middle line:84%
And this again is
another example

00:09:44.130 --> 00:09:47.980 align:middle line:84%
of how you can automate
somehow repetitive commands.

00:09:47.980 --> 00:09:48.900 align:middle line:90%
So there we are.

00:09:48.900 --> 00:09:50.460 align:middle line:84%
As you can see, it's
going to perform

00:09:50.460 --> 00:09:52.110 align:middle line:84%
the port scan on
the target system

00:09:52.110 --> 00:09:53.980 align:middle line:84%
and it'll then display
the results here.

00:09:53.980 --> 00:09:57.000 align:middle line:84%
So let's see if there are
any open ports of the target.

00:09:57.000 --> 00:10:00.480 align:middle line:84%
In this case, the target is
the Windows 7 virtual machine,

00:10:00.480 --> 00:10:03.390 align:middle line:84%
and I don't expect there to be
any open ports at this point.

00:10:03.390 --> 00:10:06.900 align:middle line:84%
So we only have NetBIOS
and SMB currently

00:10:06.900 --> 00:10:10.313 align:middle line:84%
enabled, so yeah, that's the
process you can go through.

00:10:10.313 --> 00:10:11.730 align:middle line:84%
And as I said, you
can pretty much

00:10:11.730 --> 00:10:14.550 align:middle line:84%
run any command that you
would like to automate.

00:10:14.550 --> 00:10:17.670 align:middle line:84%
So we can create
another example or take

00:10:17.670 --> 00:10:19.290 align:middle line:84%
a look at another
example here, so we

00:10:19.290 --> 00:10:22.830 align:middle line:84%
can say maybe MSF
console, or rather, let's

00:10:22.830 --> 00:10:26.070 align:middle line:84%
create a new handler or
a new resource script,

00:10:26.070 --> 00:10:30.510 align:middle line:84%
and I'm just going to call
this probably we can say--

00:10:30.510 --> 00:10:34.737 align:middle line:84%
we can actually just
call it db status, right?

00:10:34.737 --> 00:10:37.320 align:middle line:84%
And this will probably check the
status of the database, which

00:10:37.320 --> 00:10:39.690 align:middle line:84%
again, I know this
is a menial task,

00:10:39.690 --> 00:10:42.700 align:middle line:84%
but we can run other
commands as well.

00:10:42.700 --> 00:10:45.270 align:middle line:84%
So we'll just call
it dbstatus.rc,

00:10:45.270 --> 00:10:48.390 align:middle line:84%
and within this, we can then
type in the db status command

00:10:48.390 --> 00:10:51.660 align:middle line:84%
and we can probably list
of the current workspaces

00:10:51.660 --> 00:10:52.230 align:middle line:90%
that we have.

00:10:52.230 --> 00:10:54.300 align:middle line:84%
So we can say
workspace, and then we

00:10:54.300 --> 00:10:57.240 align:middle line:84%
can switch 2 a particular
workspace if we want or create

00:10:57.240 --> 00:10:58.020 align:middle line:90%
another workspace.

00:10:58.020 --> 00:11:01.110 align:middle line:84%
So we can say
workspace and we can

00:11:01.110 --> 00:11:04.920 align:middle line:84%
create another one called maybe
we can just call this test,

00:11:04.920 --> 00:11:06.990 align:middle line:84%
and we can then save
and quit and say

00:11:06.990 --> 00:11:11.470 align:middle line:90%
MSF console, R, dbstatus.rc.

00:11:11.470 --> 00:11:14.470 align:middle line:84%
That'll start up MSF console
and execute the commands,

00:11:14.470 --> 00:11:17.013 align:middle line:84%
and it should create
the workspace for us.

00:11:17.013 --> 00:11:18.430 align:middle line:84%
So again, give
that a few seconds.

00:11:18.430 --> 00:11:22.880 align:middle line:90%


00:11:22.880 --> 00:11:23.880 align:middle line:90%
All right, there we are.

00:11:23.880 --> 00:11:25.800 align:middle line:84%
As you can see, it
executes the command.

00:11:25.800 --> 00:11:28.050 align:middle line:84%
It checks the database
status, and it tells us

00:11:28.050 --> 00:11:31.230 align:middle line:84%
we are connected to MSF
and the type is PostgreSQL.

00:11:31.230 --> 00:11:33.510 align:middle line:84%
It lists out the
workspaces that we have.

00:11:33.510 --> 00:11:36.240 align:middle line:84%
In this case, you can see
we have a few workspaces.

00:11:36.240 --> 00:11:39.180 align:middle line:84%
And then of course, it creates
the new workspace here.

00:11:39.180 --> 00:11:41.430 align:middle line:84%
And of course, we can then
just delete that workspace.

00:11:41.430 --> 00:11:43.810 align:middle line:84%
And you can probably also
add this command, as well,

00:11:43.810 --> 00:11:49.090 align:middle line:84%
if you'd like to do that,
the point being, again,

00:11:49.090 --> 00:11:50.760 align:middle line:84%
the point being to
actually demonstrate

00:11:50.760 --> 00:11:54.160 align:middle line:84%
the functionality and the
power of a resource script

00:11:54.160 --> 00:11:56.630 align:middle line:90%
and what it can be used for.

00:11:56.630 --> 00:11:59.650 align:middle line:84%
You can also load
up resource scripts

00:11:59.650 --> 00:12:01.630 align:middle line:84%
from within the Metasploit
framework console.

00:12:01.630 --> 00:12:05.050 align:middle line:84%
So let's say I'm already
working within MSF console.

00:12:05.050 --> 00:12:06.670 align:middle line:84%
I can just open
this up, and I'll

00:12:06.670 --> 00:12:10.030 align:middle line:84%
show you how to load up the
resource scripts directly

00:12:10.030 --> 00:12:11.380 align:middle line:90%
from within MSF console.

00:12:11.380 --> 00:12:16.350 align:middle line:90%


00:12:16.350 --> 00:12:19.130 align:middle line:84%
So if I wanted to load up a new
resource script from within,

00:12:19.130 --> 00:12:22.580 align:middle line:84%
I just say resource and
then specify the actual path

00:12:22.580 --> 00:12:23.750 align:middle line:90%
to the resource script.

00:12:23.750 --> 00:12:28.310 align:middle line:84%
So I can say resources in
desktop and maybe Windows

00:12:28.310 --> 00:12:31.190 align:middle line:84%
payloads, and then I
can say handler.rc,

00:12:31.190 --> 00:12:33.150 align:middle line:84%
and that'll again
start it up for us,

00:12:33.150 --> 00:12:37.070 align:middle line:84%
so you don't have to actually go
through the process of spawning

00:12:37.070 --> 00:12:40.160 align:middle line:84%
a new MSF console
session and then loading

00:12:40.160 --> 00:12:41.490 align:middle line:90%
the resource script that way.

00:12:41.490 --> 00:12:43.472 align:middle line:84%
So this is another
way you can do that.

00:12:43.472 --> 00:12:44.930 align:middle line:84%
So if I terminate
that, you can see

00:12:44.930 --> 00:12:49.410 align:middle line:84%
that's going to terminate or
stop the reverse TCP handler.

00:12:49.410 --> 00:12:52.290 align:middle line:84%
You can also create a
resource script automatically

00:12:52.290 --> 00:12:54.150 align:middle line:90%
from within MSF console.

00:12:54.150 --> 00:12:57.570 align:middle line:84%
And the way that works is if I
just exit from the current MSF

00:12:57.570 --> 00:13:00.750 align:middle line:84%
console session, and I can
open up a new MSF console

00:13:00.750 --> 00:13:03.510 align:middle line:84%
session here, I can essentially
type in the commands

00:13:03.510 --> 00:13:05.790 align:middle line:84%
that I want to be
in a resource script

00:13:05.790 --> 00:13:08.850 align:middle line:84%
and then export those commands
into a resource script.

00:13:08.850 --> 00:13:11.580 align:middle line:84%
So for example, as
we did previously,

00:13:11.580 --> 00:13:15.870 align:middle line:84%
if I wanted to say or
utilize the port scan module,

00:13:15.870 --> 00:13:18.420 align:middle line:84%
I can essentially,
again, search for it.

00:13:18.420 --> 00:13:21.180 align:middle line:84%
Or in this case,
for example, let

00:13:21.180 --> 00:13:24.130 align:middle line:84%
me just specify that this
is the module I want to use.

00:13:24.130 --> 00:13:28.200 align:middle line:84%
So if I say use the port scan
module and then set the R

00:13:28.200 --> 00:13:31.170 align:middle line:84%
host's value to the target
IP, which in this case is

00:13:31.170 --> 00:13:34.950 align:middle line:84%
10.10.10.7 and I hit
Enter and then hit Run,

00:13:34.950 --> 00:13:37.930 align:middle line:84%
I can essentially hit Run,
and that will perform the port

00:13:37.930 --> 00:13:38.430 align:middle line:90%
scan.

00:13:38.430 --> 00:13:41.010 align:middle line:84%
And then if I terminate
this, I can essentially

00:13:41.010 --> 00:13:43.800 align:middle line:84%
export all of the
commands that I typed in,

00:13:43.800 --> 00:13:45.480 align:middle line:84%
starting off from
the Use command

00:13:45.480 --> 00:13:48.060 align:middle line:84%
to the actual configuration
of the module,

00:13:48.060 --> 00:13:49.530 align:middle line:90%
as well as the Run command.

00:13:49.530 --> 00:13:52.380 align:middle line:84%
I can export all of these
into a resource script.

00:13:52.380 --> 00:13:54.480 align:middle line:84%
If I don't want to create
one and type out all

00:13:54.480 --> 00:13:58.320 align:middle line:84%
of the commands again, I can
just say make RC, and then

00:13:58.320 --> 00:14:01.208 align:middle line:84%
specify the path to
actually-- or the actual path

00:14:01.208 --> 00:14:03.000 align:middle line:84%
where you want to save
the resource script.

00:14:03.000 --> 00:14:08.400 align:middle line:84%
So you can say desktop, and
we can just call this test.rc,

00:14:08.400 --> 00:14:13.325 align:middle line:84%
or we can just call it
portscan.rc and hit Enter.

00:14:13.325 --> 00:14:14.700 align:middle line:84%
As you can see,
it's going to say

00:14:14.700 --> 00:14:18.630 align:middle line:84%
saving your last three commands
to desktop portscan.rc.

00:14:18.630 --> 00:14:20.370 align:middle line:84%
So it'll actually
save the commands

00:14:20.370 --> 00:14:22.650 align:middle line:84%
that you've typed in,
which can be much more

00:14:22.650 --> 00:14:26.545 align:middle line:84%
helpful if you already
have an idea of what

00:14:26.545 --> 00:14:27.420 align:middle line:90%
you want to automate.

00:14:27.420 --> 00:14:30.060 align:middle line:84%
So if I exit out of here,
and let me take a step back

00:14:30.060 --> 00:14:34.980 align:middle line:84%
onto my desktop and I cut out
the contents of portscan.rc,

00:14:34.980 --> 00:14:37.930 align:middle line:84%
we should be able to see
the actual file here.

00:14:37.930 --> 00:14:41.470 align:middle line:84%
So let me list out the
contents of my desktop.

00:14:41.470 --> 00:14:43.090 align:middle line:84%
You can see that
it's not saved here.

00:14:43.090 --> 00:14:46.780 align:middle line:84%
That's because MSF console
was started as a root user.

00:14:46.780 --> 00:14:50.670 align:middle line:84%
So if I say, let me switch
to my root user here,

00:14:50.670 --> 00:14:54.180 align:middle line:84%
and hopefully I'll be able to
do that, let me actually just

00:14:54.180 --> 00:14:55.980 align:middle line:90%
switch over to the root user.

00:14:55.980 --> 00:14:58.060 align:middle line:84%
All right, so I'm
currently the root user.

00:14:58.060 --> 00:15:00.870 align:middle line:84%
So if I check the contents
of the root directory

00:15:00.870 --> 00:15:03.810 align:middle line:84%
on the desktop, you
can see that we should

00:15:03.810 --> 00:15:05.760 align:middle line:90%
have the portscan.rc file.

00:15:05.760 --> 00:15:06.670 align:middle line:90%
There we are.

00:15:06.670 --> 00:15:10.020 align:middle line:84%
And the reason it output or
saved it within the root users

00:15:10.020 --> 00:15:12.240 align:middle line:84%
directory is because
we didn't actually

00:15:12.240 --> 00:15:14.590 align:middle line:90%
specify the entire path, right?

00:15:14.590 --> 00:15:17.430 align:middle line:84%
So we should have
specified the absolute path

00:15:17.430 --> 00:15:20.490 align:middle line:84%
or the relative path
to the actual directory

00:15:20.490 --> 00:15:21.640 align:middle line:90%
where we wanted to save it.

00:15:21.640 --> 00:15:24.690 align:middle line:84%
So we should have saved it
under home Kali desktop.

00:15:24.690 --> 00:15:27.900 align:middle line:84%
Because MSF console
requires root privileges

00:15:27.900 --> 00:15:30.120 align:middle line:84%
in certain scenarios,
it saved it

00:15:30.120 --> 00:15:31.860 align:middle line:90%
under the root user's desktop.

00:15:31.860 --> 00:15:33.100 align:middle line:90%
So again, we have it here.

00:15:33.100 --> 00:15:35.550 align:middle line:84%
And as you can
see, it's exactly--

00:15:35.550 --> 00:15:38.170 align:middle line:84%
it essentially has the
commands that we specified.

00:15:38.170 --> 00:15:42.900 align:middle line:84%
So that is the process
of creating Metasploit RC

00:15:42.900 --> 00:15:46.110 align:middle line:84%
scripts to essentially
automate repetitive tasks

00:15:46.110 --> 00:15:48.360 align:middle line:84%
or commands that you don't
want to keep on running.

00:15:48.360 --> 00:15:51.600 align:middle line:84%
And as I said, you can customize
them and utilize pretty much

00:15:51.600 --> 00:15:54.810 align:middle line:84%
all MSF console commands,
as long as they make sense

00:15:54.810 --> 00:15:55.770 align:middle line:90%
sequentially.

00:15:55.770 --> 00:16:00.410 align:middle line:84%
So that's going to be it for
the practical demonstration.

00:16:00.410 --> 00:16:02.780 align:middle line:84%
In the next section
of this course,

00:16:02.780 --> 00:16:07.010 align:middle line:84%
we'll begin exploring the
actual exploitation of Windows

00:16:07.010 --> 00:16:10.520 align:middle line:84%
and Linux services, as we
have now explored client side

00:16:10.520 --> 00:16:12.170 align:middle line:84%
attacks, so we can
now actually get

00:16:12.170 --> 00:16:14.510 align:middle line:84%
started with exploiting
the services that

00:16:14.510 --> 00:16:17.090 align:middle line:84%
are running on both Linux
and Windows systems,

00:16:17.090 --> 00:16:20.030 align:middle line:84%
and again, exploring how
they can be exploited

00:16:20.030 --> 00:16:22.890 align:middle line:84%
through the use of various
exploit Metasploit framework

00:16:22.890 --> 00:16:23.390 align:middle line:90%
modules.

00:16:23.390 --> 00:16:25.722 align:middle line:90%
So I'll see you there.

00:16:25.722 --> 00:16:26.222 align:middle line:90%