WEBVTT

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


00:00:04.840 --> 00:00:07.744 align:middle line:90%
[MUSIC PLAYING]

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


00:00:10.170 --> 00:00:12.990 align:middle line:84%
Port scanning and
enumeration with Nmap.

00:00:12.990 --> 00:00:15.420 align:middle line:84%
Now that we've been able
to install and configure

00:00:15.420 --> 00:00:19.380 align:middle line:84%
the Metasploit framework as well
as understand or get familiar

00:00:19.380 --> 00:00:22.440 align:middle line:84%
with the fundamentals of
interacting with the Metasploit

00:00:22.440 --> 00:00:24.600 align:middle line:84%
framework console,
we can now begin

00:00:24.600 --> 00:00:26.490 align:middle line:84%
with our first
practical section which

00:00:26.490 --> 00:00:29.460 align:middle line:84%
involves information
gathering and enumeration

00:00:29.460 --> 00:00:30.960 align:middle line:90%
with the Metasploit framework.

00:00:30.960 --> 00:00:32.619 align:middle line:84%
So you might be
asking yourself, well,

00:00:32.619 --> 00:00:35.520 align:middle line:84%
why exactly are we
starting off with Nmap

00:00:35.520 --> 00:00:37.290 align:middle line:90%
or why are we utilizing Nmap?

00:00:37.290 --> 00:00:39.480 align:middle line:84%
Well, I can answer
that in two parts.

00:00:39.480 --> 00:00:42.810 align:middle line:84%
Well, firstly, Nmap is a
really, really powerful tool

00:00:42.810 --> 00:00:45.810 align:middle line:84%
when it comes down to port
scanning and enumeration.

00:00:45.810 --> 00:00:47.910 align:middle line:84%
And secondly, the
Metasploit framework

00:00:47.910 --> 00:00:51.480 align:middle line:84%
allows us to integrate
third party tools like Nmap

00:00:51.480 --> 00:00:54.180 align:middle line:84%
or rather, import the
results from third party

00:00:54.180 --> 00:00:57.630 align:middle line:84%
tools like Nmap into the
Metasploit framework database

00:00:57.630 --> 00:00:59.610 align:middle line:84%
through the Metasploit
framework console.

00:00:59.610 --> 00:01:02.070 align:middle line:84%
So we will begin this
section by taking

00:01:02.070 --> 00:01:04.019 align:middle line:84%
a look at how to
perform port scanning

00:01:04.019 --> 00:01:05.670 align:middle line:90%
and enumeration with Nmap.

00:01:05.670 --> 00:01:08.520 align:middle line:84%
We will also take a look at
how to output our scan results

00:01:08.520 --> 00:01:10.710 align:middle line:84%
into an output
file that will then

00:01:10.710 --> 00:01:14.610 align:middle line:84%
be imported into the Metasploit
framework database via the MSF

00:01:14.610 --> 00:01:15.270 align:middle line:90%
console.

00:01:15.270 --> 00:01:17.770 align:middle line:84%
And we will explore
that importation process

00:01:17.770 --> 00:01:18.600 align:middle line:90%
in the next video.

00:01:18.600 --> 00:01:21.630 align:middle line:84%
However, in this video, we
are focused on port scanning

00:01:21.630 --> 00:01:23.610 align:middle line:90%
and enumeration with Nmap.

00:01:23.610 --> 00:01:25.720 align:middle line:90%
So let's get started.

00:01:25.720 --> 00:01:27.750 align:middle line:84%
If you have never
heard of Nmap, Nmap

00:01:27.750 --> 00:01:30.300 align:middle line:84%
is essentially a free and
open source network scanner

00:01:30.300 --> 00:01:32.670 align:middle line:84%
that can be used to discover
hosts on the network

00:01:32.670 --> 00:01:34.950 align:middle line:84%
as well as scan
targets for open ports.

00:01:34.950 --> 00:01:38.820 align:middle line:84%
Now it can do much more
than that and this is really

00:01:38.820 --> 00:01:41.790 align:middle line:84%
what makes the Nmap
port scanner so powerful

00:01:41.790 --> 00:01:45.000 align:middle line:84%
is, it can also be used
to perform enumeration.

00:01:45.000 --> 00:01:46.330 align:middle line:90%
What do I mean by this?

00:01:46.330 --> 00:01:48.030 align:middle line:90%
What do I mean by enumeration?

00:01:48.030 --> 00:01:51.870 align:middle line:84%
Enumeration essentially
entails gathering or extracting

00:01:51.870 --> 00:01:55.510 align:middle line:84%
as much information as
possible from a target system.

00:01:55.510 --> 00:01:57.900 align:middle line:84%
And in this case, we are going
to be taking a look at how

00:01:57.900 --> 00:02:01.620 align:middle line:84%
to extract or enumerate
information from the open ports

00:02:01.620 --> 00:02:02.820 align:middle line:90%
on the target system.

00:02:02.820 --> 00:02:05.160 align:middle line:84%
And the type of information
we're interested in

00:02:05.160 --> 00:02:08.280 align:middle line:84%
is the service versions that
are running on the open ports.

00:02:08.280 --> 00:02:12.030 align:middle line:84%
Furthermore, we can also use
Nmap to discover the operating

00:02:12.030 --> 00:02:13.840 align:middle line:90%
system of the target system.

00:02:13.840 --> 00:02:17.790 align:middle line:84%
So all of this information can
then be outputted or exported

00:02:17.790 --> 00:02:21.030 align:middle line:84%
into a file that can then be
imported into the Metasploit

00:02:21.030 --> 00:02:22.260 align:middle line:90%
framework.

00:02:22.260 --> 00:02:25.680 align:middle line:84%
Again, consequently to be used
for vulnerability detection

00:02:25.680 --> 00:02:26.890 align:middle line:90%
and exploitation.

00:02:26.890 --> 00:02:29.100 align:middle line:84%
So again, this is
really fantastic

00:02:29.100 --> 00:02:31.800 align:middle line:84%
and let's get started
with the practical section

00:02:31.800 --> 00:02:32.710 align:middle line:90%
of this video.

00:02:32.710 --> 00:02:34.860 align:middle line:84%
So we are going to
be utilizing the lab

00:02:34.860 --> 00:02:37.510 align:middle line:84%
environment for the practical
section of this video.

00:02:37.510 --> 00:02:39.570 align:middle line:84%
So you can actually start
up the lab environment

00:02:39.570 --> 00:02:40.440 align:middle line:90%
and follow along.

00:02:40.440 --> 00:02:43.020 align:middle line:84%
The techniques will be
applicable irregardless

00:02:43.020 --> 00:02:45.390 align:middle line:84%
of whether you are using
the lab environment

00:02:45.390 --> 00:02:47.520 align:middle line:84%
or whether you have
your own target,

00:02:47.520 --> 00:02:49.800 align:middle line:84%
you can replicate
whatever we're doing here

00:02:49.800 --> 00:02:51.220 align:middle line:90%
within your own environment.

00:02:51.220 --> 00:02:56.260 align:middle line:84%
So I'll see you within
the lab environment.

00:02:56.260 --> 00:02:56.760 align:middle line:90%
All right.

00:02:56.760 --> 00:02:58.750 align:middle line:84%
So I'm currently on
the lab environment

00:02:58.750 --> 00:03:00.400 align:middle line:90%
and this is a Kali VM here.

00:03:00.400 --> 00:03:01.950 align:middle line:84%
And as you can
see, it provides us

00:03:01.950 --> 00:03:03.700 align:middle line:84%
with the target
IP, which is great,

00:03:03.700 --> 00:03:05.730 align:middle line:90%
we can begin almost immediately.

00:03:05.730 --> 00:03:09.250 align:middle line:84%
Now that we have the target IP,
we can open up a terminal here,

00:03:09.250 --> 00:03:10.570 align:middle line:90%
which is what I'm going to do.

00:03:10.570 --> 00:03:13.560 align:middle line:84%
And let me just expand
that so we can actually

00:03:13.560 --> 00:03:14.560 align:middle line:90%
see what's going on.

00:03:14.560 --> 00:03:16.570 align:middle line:84%
And I'm just going to
maximize the font here

00:03:16.570 --> 00:03:19.270 align:middle line:84%
so you have a good idea
of what's being typed in.

00:03:19.270 --> 00:03:22.710 align:middle line:84%
So in order to run Nmap, all
we need to do is type in Nmap

00:03:22.710 --> 00:03:24.750 align:middle line:84%
and then provide the
target IP and that is going

00:03:24.750 --> 00:03:26.370 align:middle line:90%
to perform a default scan.

00:03:26.370 --> 00:03:28.080 align:middle line:84%
If we hit Nmap,
that is just going

00:03:28.080 --> 00:03:30.060 align:middle line:84%
to provide us with the
documentation which

00:03:30.060 --> 00:03:32.070 align:middle line:84%
I recommend you go
through if you're not

00:03:32.070 --> 00:03:34.210 align:middle line:90%
familiar with using Nmap.

00:03:34.210 --> 00:03:34.710 align:middle line:90%
Right.

00:03:34.710 --> 00:03:36.210 align:middle line:84%
So the first thing
we're going to do

00:03:36.210 --> 00:03:39.930 align:middle line:84%
is just perform a simple default
Nmap scan and all we need to do

00:03:39.930 --> 00:03:43.350 align:middle line:84%
is type in Nmap and the
target IP, which I will do.

00:03:43.350 --> 00:03:45.472 align:middle line:84%
As you can see, it's
going to start the scan

00:03:45.472 --> 00:03:47.430 align:middle line:84%
and then it's going to
tell us right over here,

00:03:47.430 --> 00:03:50.430 align:middle line:84%
we get a message telling us
that the host seems down.

00:03:50.430 --> 00:03:53.280 align:middle line:84%
If it is really up but
blocking our ping probes,

00:03:53.280 --> 00:03:55.090 align:middle line:90%
try the Pn option.

00:03:55.090 --> 00:03:55.590 align:middle line:90%
All right.

00:03:55.590 --> 00:03:59.460 align:middle line:84%
So what this means is that
the target might be up.

00:03:59.460 --> 00:04:03.780 align:middle line:84%
However, it is blocking the
ping probes being sent by Nmap.

00:04:03.780 --> 00:04:07.080 align:middle line:84%
Now this is very common when
you're dealing with a Windows

00:04:07.080 --> 00:04:10.950 align:middle line:84%
target as Windows targets
or Windows operating system

00:04:10.950 --> 00:04:13.560 align:middle line:90%
really prevents pinging.

00:04:13.560 --> 00:04:15.630 align:middle line:84%
Again, what that
means is that we

00:04:15.630 --> 00:04:18.269 align:middle line:84%
will need to use the Pn
option to prevent Nmap

00:04:18.269 --> 00:04:20.550 align:middle line:84%
from sending ping
probes and instead, just

00:04:20.550 --> 00:04:22.019 align:middle line:90%
perform the port scanning.

00:04:22.019 --> 00:04:24.810 align:middle line:84%
So we can do that by,
again, typing in Nmap

00:04:24.810 --> 00:04:28.860 align:middle line:84%
and then saying Pn, and then
of course, pasting in the IP

00:04:28.860 --> 00:04:30.735 align:middle line:84%
which again, I'll
just copy from here.

00:04:30.735 --> 00:04:31.470 align:middle line:90%
Here we are.

00:04:31.470 --> 00:04:34.540 align:middle line:84%
Just copy the target IP
and paste it in there.

00:04:34.540 --> 00:04:37.110 align:middle line:84%
And this is, again, going
to perform a default scan.

00:04:37.110 --> 00:04:39.600 align:middle line:84%
However in this case, we
are not going to be pinging

00:04:39.600 --> 00:04:41.070 align:middle line:90%
so we'll hit Enter.

00:04:41.070 --> 00:04:44.430 align:middle line:84%
And in this case, we should be
able to identify the open ports

00:04:44.430 --> 00:04:45.630 align:middle line:90%
on the target system.

00:04:45.630 --> 00:04:46.380 align:middle line:90%
There we are.

00:04:46.380 --> 00:04:48.240 align:middle line:84%
So we can see that
the host is up

00:04:48.240 --> 00:04:52.542 align:middle line:84%
and we are able to get the
various open ports that

00:04:52.542 --> 00:04:53.625 align:middle line:90%
are running on the target.

00:04:53.625 --> 00:04:57.330 align:middle line:84%
And these of course, TCP ports,
we'll take a look at the UDP

00:04:57.330 --> 00:04:58.900 align:middle line:90%
scans in a few seconds.

00:04:58.900 --> 00:05:01.980 align:middle line:84%
So we can see that the target
is running a web server on port

00:05:01.980 --> 00:05:04.590 align:middle line:90%
80, so the service is HTTP.

00:05:04.590 --> 00:05:08.910 align:middle line:84%
The target is also
running msrpc on port 135.

00:05:08.910 --> 00:05:12.930 align:middle line:84%
Also running netbios as well
as SMB on their default ports

00:05:12.930 --> 00:05:16.270 align:middle line:90%
of 139 and 445, respectively.

00:05:16.270 --> 00:05:19.110 align:middle line:84%
We also see that the
target is running RPC--

00:05:19.110 --> 00:05:22.140 align:middle line:84%
or rather, RDP on
port 3389, which

00:05:22.140 --> 00:05:26.250 align:middle line:84%
means we can pretty much try
and authenticate to it via RDP.

00:05:26.250 --> 00:05:28.350 align:middle line:84%
However, we don't
have the credentials

00:05:28.350 --> 00:05:30.330 align:middle line:84%
to do so which is
why we're taking

00:05:30.330 --> 00:05:33.750 align:middle line:90%
a look at how to use Nmap.

00:05:33.750 --> 00:05:36.060 align:middle line:84%
This information is
very useful and we

00:05:36.060 --> 00:05:38.010 align:middle line:84%
can import this
information directly

00:05:38.010 --> 00:05:39.300 align:middle line:90%
into the Metasploit framework.

00:05:39.300 --> 00:05:42.300 align:middle line:84%
However, this really
isn't enough to give us

00:05:42.300 --> 00:05:44.550 align:middle line:84%
an idea of what we're
dealing with in regards

00:05:44.550 --> 00:05:47.130 align:middle line:84%
to the versions of the
services that are running

00:05:47.130 --> 00:05:49.240 align:middle line:90%
and the target operating system.

00:05:49.240 --> 00:05:52.120 align:middle line:84%
So in order to enumerate
all of this information,

00:05:52.120 --> 00:05:55.530 align:middle line:84%
we can utilize some
additional flags with Nmap.

00:05:55.530 --> 00:05:58.230 align:middle line:90%
For example, we can say Nmap Pn.

00:05:58.230 --> 00:06:01.260 align:middle line:84%
And then if we want to
identify the service versions,

00:06:01.260 --> 00:06:04.050 align:middle line:84%
we can use the
hyphen, lowercase s,

00:06:04.050 --> 00:06:08.370 align:middle line:84%
and uppercase V, as
you can see there,

00:06:08.370 --> 00:06:11.040 align:middle line:84%
and that will enumerate
the service versions.

00:06:11.040 --> 00:06:13.740 align:middle line:84%
We can also enumerate the
operating system that's

00:06:13.740 --> 00:06:17.460 align:middle line:84%
running on the target by
using the hyphen, uppercase O.

00:06:17.460 --> 00:06:20.490 align:middle line:84%
And if we now hit Enter,
this should give us

00:06:20.490 --> 00:06:24.180 align:middle line:84%
the service versions as well
as the operating system that's

00:06:24.180 --> 00:06:25.120 align:middle line:90%
running on the target.

00:06:25.120 --> 00:06:26.340 align:middle line:90%
So I'm going to hit Enter.

00:06:26.340 --> 00:06:30.530 align:middle line:84%
And I'm just going to wait
for this scan to complete.

00:06:30.530 --> 00:06:31.030 align:middle line:90%
All right.

00:06:31.030 --> 00:06:32.630 align:middle line:90%
So the scan is complete.

00:06:32.630 --> 00:06:35.210 align:middle line:84%
And as you can see we get
much more information.

00:06:35.210 --> 00:06:38.050 align:middle line:84%
So for example, we get the
service versions as opposed

00:06:38.050 --> 00:06:39.380 align:middle line:90%
to just the service.

00:06:39.380 --> 00:06:42.580 align:middle line:84%
So for the service versions,
we can see that on port 80,

00:06:42.580 --> 00:06:46.220 align:middle line:84%
we have an HTTP file server
which is very interesting.

00:06:46.220 --> 00:06:49.300 align:middle line:84%
We also are able to
tell from the SMB port,

00:06:49.300 --> 00:06:51.400 align:middle line:90%
the version of SMB running.

00:06:51.400 --> 00:06:55.360 align:middle line:84%
We're able to get the banner of
the probable operating system

00:06:55.360 --> 00:06:56.890 align:middle line:84%
that the target
might be running.

00:06:56.890 --> 00:06:59.530 align:middle line:84%
In this case, we
pretty much can tell

00:06:59.530 --> 00:07:04.420 align:middle line:84%
that it is running Windows,
or rather Windows Server 2012.

00:07:04.420 --> 00:07:07.660 align:middle line:84%
However, we aren't able to
get the exact service pack

00:07:07.660 --> 00:07:11.320 align:middle line:84%
but this is still very,
very useful information.

00:07:11.320 --> 00:07:15.010 align:middle line:84%
So we have been able to identify
the service versions as well

00:07:15.010 --> 00:07:18.430 align:middle line:84%
as the operating system
version and what we can do now

00:07:18.430 --> 00:07:21.520 align:middle line:84%
is use the same scan
and essentially,

00:07:21.520 --> 00:07:25.960 align:middle line:84%
export these results into a
file that we will then import

00:07:25.960 --> 00:07:27.710 align:middle line:90%
into the Metasploit framework.

00:07:27.710 --> 00:07:29.500 align:middle line:84%
So to do this,
what we want to do

00:07:29.500 --> 00:07:32.870 align:middle line:84%
is if we just open up
the Nmap documentation,

00:07:32.870 --> 00:07:34.390 align:middle line:90%
you can see that we can output.

00:07:34.390 --> 00:07:35.080 align:middle line:90%
There we are.

00:07:35.080 --> 00:07:36.940 align:middle line:84%
There's the output
documentation.

00:07:36.940 --> 00:07:40.630 align:middle line:84%
We can output the scan results
into various file formats.

00:07:40.630 --> 00:07:44.110 align:middle line:84%
Now in order to import the scan
results into the Metasploit

00:07:44.110 --> 00:07:46.540 align:middle line:84%
framework, we need
to output the scan

00:07:46.540 --> 00:07:51.310 align:middle line:84%
into XML, which can be done
by using the oX option here.

00:07:51.310 --> 00:07:55.780 align:middle line:84%
We then provide the output
file name with a file name

00:07:55.780 --> 00:07:57.760 align:middle line:84%
and then of course,
we just hit Enter

00:07:57.760 --> 00:07:59.650 align:middle line:84%
and the scan results
will be output

00:07:59.650 --> 00:08:01.100 align:middle line:90%
into that particular file.

00:08:01.100 --> 00:08:04.210 align:middle line:84%
So to do this, we'll
use the previous scan

00:08:04.210 --> 00:08:08.620 align:middle line:84%
and then we'll say, o which is
hyphen, lowercase o, and then

00:08:08.620 --> 00:08:12.220 align:middle line:90%
X to output it into an XML file.

00:08:12.220 --> 00:08:14.930 align:middle line:84%
And then we provide the
name of the output file.

00:08:14.930 --> 00:08:22.750 align:middle line:84%
In this case, we'll just
call it windows server 2012.

00:08:22.750 --> 00:08:24.610 align:middle line:84%
And then we'll
hit Enter and that

00:08:24.610 --> 00:08:27.490 align:middle line:84%
is going to run the scan and
then output all the results

00:08:27.490 --> 00:08:30.670 align:middle line:84%
into an XML file called
windows server 2012.

00:08:30.670 --> 00:08:33.039 align:middle line:84%
We will then import
this XML file

00:08:33.039 --> 00:08:35.590 align:middle line:84%
into the Metasploit
framework in the next video

00:08:35.590 --> 00:08:38.330 align:middle line:84%
and we'll take a look at the
results within the Metasploit

00:08:38.330 --> 00:08:38.830 align:middle line:90%
framework.

00:08:38.830 --> 00:08:41.110 align:middle line:84%
And then again, we can
use that information

00:08:41.110 --> 00:08:43.990 align:middle line:84%
to identify potential
vulnerabilities

00:08:43.990 --> 00:08:46.930 align:middle line:84%
as well as identify potential
exploit modules that we

00:08:46.930 --> 00:08:48.260 align:middle line:90%
can use to gain access.

00:08:48.260 --> 00:08:51.750 align:middle line:90%
So I'm going to let this run.

00:08:51.750 --> 00:08:52.250 align:middle line:90%
All right.

00:08:52.250 --> 00:08:54.890 align:middle line:84%
The scan is done
and it has output

00:08:54.890 --> 00:08:59.390 align:middle line:84%
the results of the
scan into an XML file

00:08:59.390 --> 00:09:02.540 align:middle line:84%
called windows server
2012 which is stored right

00:09:02.540 --> 00:09:03.860 align:middle line:90%
within this current directory.

00:09:03.860 --> 00:09:07.650 align:middle line:84%
You can also specify
another directory by again,

00:09:07.650 --> 00:09:10.490 align:middle line:84%
providing the path to that
directory and then the file

00:09:10.490 --> 00:09:11.010 align:middle line:90%
name.

00:09:11.010 --> 00:09:12.500 align:middle line:84%
In this case, we
can just cut out

00:09:12.500 --> 00:09:15.090 align:middle line:84%
the contents of the
windows server 2012 file.

00:09:15.090 --> 00:09:18.810 align:middle line:84%
And as you can see,
this is in XML format.

00:09:18.810 --> 00:09:19.310 align:middle line:90%
All right.

00:09:19.310 --> 00:09:21.300 align:middle line:84%
So we're pretty much
done on that end.

00:09:21.300 --> 00:09:22.953 align:middle line:84%
We'll now move on
to the next video

00:09:22.953 --> 00:09:24.620 align:middle line:84%
where we'll take a
look at how to import

00:09:24.620 --> 00:09:26.930 align:middle line:84%
the scan results
into the Metasploit

00:09:26.930 --> 00:09:29.180 align:middle line:90%
framework via the MSF console.

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

00:09:32.140 --> 00:09:33.000 align:middle line:90%