WEBVTT

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


00:00:10.140 --> 00:00:13.272 align:middle line:84%
Vulnerability scanning
with Nmap scripts--

00:00:13.272 --> 00:00:15.480 align:middle line:84%
in this video, we're going
to be taking a look at how

00:00:15.480 --> 00:00:19.410 align:middle line:84%
to utilize the Nmap Scripting
Engine to perform vulnerability

00:00:19.410 --> 00:00:23.160 align:middle line:84%
scans on a specific service
that is running on a target

00:00:23.160 --> 00:00:26.610 align:middle line:84%
in order to identify or in
order to verify whether or not

00:00:26.610 --> 00:00:29.520 align:middle line:84%
it is vulnerable to
a particular exploit.

00:00:29.520 --> 00:00:31.860 align:middle line:84%
And of course, this
will all be automated,

00:00:31.860 --> 00:00:34.800 align:middle line:84%
and it is really one of
the great features of Nmap.

00:00:34.800 --> 00:00:38.440 align:middle line:84%
And again, as you'll see during
the practical demonstration,

00:00:38.440 --> 00:00:40.540 align:middle line:90%
it is quite, quite powerful.

00:00:40.540 --> 00:00:43.650 align:middle line:84%
Now, before we get started with
the practical demonstration,

00:00:43.650 --> 00:00:47.010 align:middle line:84%
I just want to take you to a
quick, really, really awesome

00:00:47.010 --> 00:00:49.890 align:middle line:84%
resource on the Nmap
Scripting Engine

00:00:49.890 --> 00:00:52.050 align:middle line:84%
that, again, you can take
a look at if you want

00:00:52.050 --> 00:00:54.270 align:middle line:84%
to learn more
about Nmap scripts,

00:00:54.270 --> 00:00:56.890 align:middle line:84%
not just pertinent to
vulnerability scanning

00:00:56.890 --> 00:01:01.650 align:middle line:84%
but also, to automating a wide
variety of networking tasks

00:01:01.650 --> 00:01:02.754 align:middle line:90%
and reconnaissance.

00:01:02.754 --> 00:01:05.129 align:middle line:84%
All right, so I'm just going
to switch over to my browser

00:01:05.129 --> 00:01:06.730 align:middle line:90%
really quickly.

00:01:06.730 --> 00:01:08.770 align:middle line:84%
All right, so I'm
currently on my browser,

00:01:08.770 --> 00:01:09.850 align:middle line:90%
and this is the page.

00:01:09.850 --> 00:01:12.210 align:middle line:84%
This is the official
Nmap website.

00:01:12.210 --> 00:01:17.550 align:middle line:84%
And the Nmap project already
has a free book available online

00:01:17.550 --> 00:01:19.650 align:middle line:84%
that you can read to learn
more about how to use

00:01:19.650 --> 00:01:22.200 align:middle line:90%
Nmap that really is awesome.

00:01:22.200 --> 00:01:24.930 align:middle line:84%
And of course, I will be
posting this link as a resource.

00:01:24.930 --> 00:01:31.560 align:middle line:84%
You can access it by going
to nmap.org/book/nse.html

00:01:31.560 --> 00:01:34.110 align:middle line:84%
because we are talking about
the Nmap Scripting Engine.

00:01:34.110 --> 00:01:36.570 align:middle line:84%
All right, so let's learn
more about the Nmap Scripting

00:01:36.570 --> 00:01:37.110 align:middle line:90%
Engine.

00:01:37.110 --> 00:01:40.230 align:middle line:84%
So as it's stated here,
the Nmap Scripting Engine,

00:01:40.230 --> 00:01:43.350 align:middle line:84%
also known as NSE,
is one of Nmap's most

00:01:43.350 --> 00:01:45.150 align:middle line:90%
powerful and flexible features.

00:01:45.150 --> 00:01:47.100 align:middle line:84%
It allows users
to write and share

00:01:47.100 --> 00:01:50.640 align:middle line:84%
simple scripts to automate
a wide variety of networking

00:01:50.640 --> 00:01:51.360 align:middle line:90%
tasks.

00:01:51.360 --> 00:01:54.000 align:middle line:84%
Those scripts are then
executed in parallel

00:01:54.000 --> 00:01:57.330 align:middle line:84%
with the speed and efficiency
you expect from Nmap.

00:01:57.330 --> 00:02:00.900 align:middle line:84%
Users can rely on the growing
and diverse set of scripts

00:02:00.900 --> 00:02:04.780 align:middle line:84%
distributed with Nmap or write
their own to meet custom needs.

00:02:04.780 --> 00:02:09.330 align:middle line:84%
All right, now, the
Nmap Scripting Engine

00:02:09.330 --> 00:02:11.880 align:middle line:84%
can be used to perform
the following types

00:02:11.880 --> 00:02:14.850 align:middle line:84%
of functionality or can be used
to automate the following types

00:02:14.850 --> 00:02:16.540 align:middle line:90%
of functionality.

00:02:16.540 --> 00:02:19.590 align:middle line:84%
So you can find
various Nmap scripts

00:02:19.590 --> 00:02:22.140 align:middle line:90%
to automate network discovery.

00:02:22.140 --> 00:02:25.020 align:middle line:84%
Again, as you can see here,
you can utilize Nmap scripts

00:02:25.020 --> 00:02:29.070 align:middle line:84%
for more sophisticated version
detection or service version

00:02:29.070 --> 00:02:29.910 align:middle line:90%
detection.

00:02:29.910 --> 00:02:32.310 align:middle line:84%
What we are primarily
interested in here

00:02:32.310 --> 00:02:34.830 align:middle line:90%
is vulnerability detection.

00:02:34.830 --> 00:02:38.260 align:middle line:84%
And of course, you also have
the vulnerability exploitation

00:02:38.260 --> 00:02:38.760 align:middle line:90%
scripts.

00:02:38.760 --> 00:02:41.310 align:middle line:84%
However, these are
considered intrusive.

00:02:41.310 --> 00:02:44.700 align:middle line:84%
And as a penetration tester,
you should never run an exploit

00:02:44.700 --> 00:02:47.970 align:middle line:84%
on a target unless you
verify that it is indeed

00:02:47.970 --> 00:02:49.620 align:middle line:84%
vulnerable to a
particular exploit.

00:02:49.620 --> 00:02:53.450 align:middle line:84%
So under vulnerability
detection,

00:02:53.450 --> 00:02:55.720 align:middle line:84%
let me just go through the
description really quickly.

00:02:55.720 --> 00:02:57.610 align:middle line:84%
When a new vulnerability
is discovered,

00:02:57.610 --> 00:02:59.320 align:middle line:84%
you often want to
scan your networks

00:02:59.320 --> 00:03:03.250 align:middle line:84%
to quickly identify vulnerable
systems before the bad guys do.

00:03:03.250 --> 00:03:06.640 align:middle line:84%
While Nmap isn't a comprehensive
vulnerability scanner,

00:03:06.640 --> 00:03:08.950 align:middle line:84%
the Nmap Scripting
Engine is powerful enough

00:03:08.950 --> 00:03:11.680 align:middle line:84%
to handle even demanding
vulnerability checks.

00:03:11.680 --> 00:03:14.680 align:middle line:84%
When the Heartbleed bug
affected hundreds of thousands

00:03:14.680 --> 00:03:17.290 align:middle line:84%
of systems worldwide,
Nmap's developers

00:03:17.290 --> 00:03:20.350 align:middle line:84%
responded with the SSL
Heartbleed detection script

00:03:20.350 --> 00:03:21.460 align:middle line:90%
within two days.

00:03:21.460 --> 00:03:24.500 align:middle line:84%
Many vulnerability detection
scripts are already available,

00:03:24.500 --> 00:03:27.940 align:middle line:84%
and we plan to distribute
more as they're written.

00:03:27.940 --> 00:03:29.440 align:middle line:84%
All right, so we
are primarily going

00:03:29.440 --> 00:03:31.660 align:middle line:84%
to be focused on the
vulnerability detection

00:03:31.660 --> 00:03:32.450 align:middle line:90%
scripts.

00:03:32.450 --> 00:03:35.080 align:middle line:84%
And these are already
available once you

00:03:35.080 --> 00:03:36.820 align:middle line:90%
install Nmap on your system.

00:03:36.820 --> 00:03:39.220 align:middle line:84%
And of course, Nmap comes
pre-packaged on most

00:03:39.220 --> 00:03:41.960 align:middle line:84%
penetration testing
distributions.

00:03:41.960 --> 00:03:45.100 align:middle line:84%
Now that we have an idea of what
the Nmap Scripting Engine is

00:03:45.100 --> 00:03:48.910 align:middle line:84%
and what Nmap scripts can
be used to do, furthermore,

00:03:48.910 --> 00:03:50.950 align:middle line:84%
the various categories
of Nmap scripts,

00:03:50.950 --> 00:03:54.430 align:middle line:84%
we can actually get started
with the practical demonstration

00:03:54.430 --> 00:03:56.020 align:middle line:84%
side of this video
that will highlight

00:03:56.020 --> 00:03:58.840 align:middle line:84%
how to utilize these
vulnerability detection

00:03:58.840 --> 00:04:00.580 align:middle line:84%
scripts to identify
whether or not

00:04:00.580 --> 00:04:03.250 align:middle line:84%
a target or a service
that's running on a target

00:04:03.250 --> 00:04:05.980 align:middle line:84%
is indeed vulnerable to
a particular exploit.

00:04:05.980 --> 00:04:09.340 align:middle line:84%
All right, so I'm just going to
switch over back to my slides,

00:04:09.340 --> 00:04:12.600 align:middle line:84%
and we can get started
with the lab environment.

00:04:12.600 --> 00:04:16.230 align:middle line:84%
All right, so this video
already has a lab environment

00:04:16.230 --> 00:04:19.050 align:middle line:84%
attached to it that will
allow you to essentially

00:04:19.050 --> 00:04:22.680 align:middle line:84%
perform or to actually follow
along with the techniques

00:04:22.680 --> 00:04:24.840 align:middle line:84%
that I'll be demonstrating
during the practical

00:04:24.840 --> 00:04:25.660 align:middle line:90%
demonstration.

00:04:25.660 --> 00:04:28.410 align:middle line:84%
So all you need to do is just
fire up the lab environment,

00:04:28.410 --> 00:04:32.910 align:middle line:84%
and I'll see you within
the lab environment.

00:04:32.910 --> 00:04:35.400 align:middle line:84%
All right, so I'm currently
within the lab environment,

00:04:35.400 --> 00:04:38.495 align:middle line:84%
and the first step will involve
identifying the target IP

00:04:38.495 --> 00:04:39.870 align:middle line:84%
address, which of
course, you can

00:04:39.870 --> 00:04:42.360 align:middle line:90%
do by opening up your terminal.

00:04:42.360 --> 00:04:45.730 align:middle line:84%
And I'll just zoom in so
you can see what's going on.

00:04:45.730 --> 00:04:48.630 align:middle line:84%
And I can type in
ifconfig and take a look

00:04:48.630 --> 00:04:50.638 align:middle line:90%
at the interface ethernet one.

00:04:50.638 --> 00:04:52.180 align:middle line:84%
Your subnet is going
to be different.

00:04:52.180 --> 00:04:55.170 align:middle line:84%
So the target IP is always going
to be on the third IP address

00:04:55.170 --> 00:04:57.550 align:middle line:90%
within your specific subnet.

00:04:57.550 --> 00:05:00.510 align:middle line:84%
So just copy this and make
sure to change the 2 to a 3,

00:05:00.510 --> 00:05:02.460 align:middle line:90%
and that's the target IP.

00:05:02.460 --> 00:05:05.590 align:middle line:84%
All right, so we're approaching
this as a penetration tester

00:05:05.590 --> 00:05:07.240 align:middle line:84%
so the first step
will, of course,

00:05:07.240 --> 00:05:11.940 align:middle line:84%
involve performing an Nmap scan
to identify what services are

00:05:11.940 --> 00:05:16.620 align:middle line:84%
running on the target system as
well as identify the operating

00:05:16.620 --> 00:05:17.940 align:middle line:90%
system if we can.

00:05:17.940 --> 00:05:20.430 align:middle line:84%
All right, so to do this,
I'm just going to say Nmap,

00:05:20.430 --> 00:05:23.130 align:middle line:84%
and we'll perform a service
version detection scan.

00:05:23.130 --> 00:05:26.910 align:middle line:84%
We can also perform an
operating system detection scan,

00:05:26.910 --> 00:05:29.310 align:middle line:84%
and we can paste
in the target IP.

00:05:29.310 --> 00:05:32.850 align:middle line:84%
Make sure to change the 2
to a 3, and I'll hit Enter.

00:05:32.850 --> 00:05:34.575 align:middle line:84%
And we'll give this
a couple of seconds.

00:05:34.575 --> 00:05:37.840 align:middle line:90%


00:05:37.840 --> 00:05:40.550 align:middle line:84%
All right, so the
Nmap scan is complete.

00:05:40.550 --> 00:05:43.660 align:middle line:84%
And as you can see, the target
is only running one port

00:05:43.660 --> 00:05:45.760 align:middle line:90%
or only has one port open.

00:05:45.760 --> 00:05:49.540 align:middle line:84%
That is port 80, which is
used to host a web server.

00:05:49.540 --> 00:05:52.900 align:middle line:84%
And you can see that the
actual service itself is Apache

00:05:52.900 --> 00:05:55.150 align:middle line:84%
so we know that the target
is running an Apache web

00:05:55.150 --> 00:05:57.760 align:middle line:90%
server, version 2.4.6.

00:05:57.760 --> 00:06:00.080 align:middle line:84%
In terms of the
operating system,

00:06:00.080 --> 00:06:02.410 align:middle line:84%
it tells us Unix,
which pretty much means

00:06:02.410 --> 00:06:06.910 align:middle line:84%
we can guess that it is running
Linux or a version of Unix,

00:06:06.910 --> 00:06:09.280 align:middle line:90%
maybe a variant like BSD.

00:06:09.280 --> 00:06:11.330 align:middle line:84%
But we'll need to
investigate this further.

00:06:11.330 --> 00:06:14.660 align:middle line:84%
So what we can do is we can
try and access the web server.

00:06:14.660 --> 00:06:17.200 align:middle line:84%
So I'll open up
Firefox here, and we

00:06:17.200 --> 00:06:19.030 align:middle line:90%
can paste in the target IP--

00:06:19.030 --> 00:06:21.010 align:middle line:90%
there we are-- and hit Enter.

00:06:21.010 --> 00:06:24.670 align:middle line:84%
And you can see that it
is hosting a web server.

00:06:24.670 --> 00:06:27.880 align:middle line:84%
It's actually hosting a website
that's under construction.

00:06:27.880 --> 00:06:30.400 align:middle line:84%
And that pretty much
tells us that, yes,

00:06:30.400 --> 00:06:32.560 align:middle line:84%
indeed, Apache is
running on port 80,

00:06:32.560 --> 00:06:37.210 align:middle line:84%
and it's being used to
host a particular website.

00:06:37.210 --> 00:06:39.340 align:middle line:84%
And this website is
under construction.

00:06:39.340 --> 00:06:42.460 align:middle line:84%
Now, as a penetration
tester, given the fact

00:06:42.460 --> 00:06:45.520 align:middle line:84%
that this is the only
service that is currently

00:06:45.520 --> 00:06:48.220 align:middle line:84%
running on an open
port on the target,

00:06:48.220 --> 00:06:51.790 align:middle line:84%
we can pretty much utilize the
Nmap Scripting Engine or Nmap

00:06:51.790 --> 00:06:55.360 align:middle line:84%
scripts to perform vulnerability
scans or vulnerability

00:06:55.360 --> 00:07:00.850 align:middle line:84%
detection scans on web servers,
or rather, just port 80.

00:07:00.850 --> 00:07:02.000 align:middle line:90%
Now, how do we do this?

00:07:02.000 --> 00:07:04.760 align:middle line:84%
Well, firstly we need to have
an understanding as to where

00:07:04.760 --> 00:07:06.130 align:middle line:90%
Nmap scripts are stored.

00:07:06.130 --> 00:07:08.170 align:middle line:84%
Now, as I said, the
default directory

00:07:08.170 --> 00:07:13.400 align:middle line:84%
is under user
share Nmap scripts.

00:07:13.400 --> 00:07:15.630 align:middle line:84%
And if we list all the
contents of this directory,

00:07:15.630 --> 00:07:19.370 align:middle line:84%
you can see that Nmap has
a plethora of Nmap scripts

00:07:19.370 --> 00:07:23.000 align:middle line:84%
that can be used to automate
a wide variety of scans

00:07:23.000 --> 00:07:27.470 align:middle line:84%
or functionality from network
scanning to service version

00:07:27.470 --> 00:07:30.020 align:middle line:84%
detection, vulnerability
detection, vulnerability

00:07:30.020 --> 00:07:32.430 align:middle line:84%
exploitation, so
on and so forth.

00:07:32.430 --> 00:07:34.740 align:middle line:84%
And you can go through
them manually like this.

00:07:34.740 --> 00:07:37.130 align:middle line:84%
However, as
penetration testers, we

00:07:37.130 --> 00:07:38.580 align:middle line:90%
need to be much more efficient.

00:07:38.580 --> 00:07:42.050 align:middle line:84%
So given the fact that we know
what's running on the target,

00:07:42.050 --> 00:07:44.750 align:middle line:84%
we know it's a web server,
we can limit the results

00:07:44.750 --> 00:07:49.890 align:middle line:84%
by piping the output and using
grep to only display HTTP Nmap

00:07:49.890 --> 00:07:50.390 align:middle line:90%
scripts.

00:07:50.390 --> 00:07:54.170 align:middle line:84%
So we can say HTTP, hit
Enter, and this will give us

00:07:54.170 --> 00:07:58.280 align:middle line:84%
a set of scripts that,
again, essentially automate

00:07:58.280 --> 00:08:00.350 align:middle line:84%
a wide variety of
tasks for performing,

00:08:00.350 --> 00:08:04.670 align:middle line:84%
for example, a web application
firewall detection, web

00:08:04.670 --> 00:08:06.800 align:middle line:90%
application fingerprinting.

00:08:06.800 --> 00:08:09.620 align:middle line:84%
And then of course, there's
these really interesting ones

00:08:09.620 --> 00:08:11.670 align:middle line:84%
here that I'll get
to in a second.

00:08:11.670 --> 00:08:14.210 align:middle line:84%
So we can go through
the list of them all.

00:08:14.210 --> 00:08:16.100 align:middle line:84%
You can see there
are quite a lot.

00:08:16.100 --> 00:08:20.420 align:middle line:84%
And from this point
onwards, an attacker

00:08:20.420 --> 00:08:22.550 align:middle line:84%
could typically
utilize one of them

00:08:22.550 --> 00:08:25.190 align:middle line:84%
to identify more
information regarding

00:08:25.190 --> 00:08:28.570 align:middle line:84%
the web server and consequently
the web application.

00:08:28.570 --> 00:08:33.710 align:middle line:84%
So for example, they could
utilize a script like HTTP enum

00:08:33.710 --> 00:08:36.000 align:middle line:90%
to enumerate more information.

00:08:36.000 --> 00:08:39.679 align:middle line:84%
And again, this can typically
be done by running an Nmap scan,

00:08:39.679 --> 00:08:43.190 align:middle line:84%
and we can then specify
the script as HTTP enum.

00:08:43.190 --> 00:08:44.520 align:middle line:90%
So we can say script.

00:08:44.520 --> 00:08:48.330 align:middle line:84%
The syntax for loading or using
a script is fairly simple.

00:08:48.330 --> 00:08:50.090 align:middle line:84%
You just say script
and then paste

00:08:50.090 --> 00:08:51.283 align:middle line:90%
the name of the script here.

00:08:51.283 --> 00:08:52.700 align:middle line:84%
You don't need to
provide the path

00:08:52.700 --> 00:08:55.010 align:middle line:84%
to the script or
the actual extension

00:08:55.010 --> 00:08:57.680 align:middle line:84%
unless you're trying to
utilize a script that you've

00:08:57.680 --> 00:08:59.510 align:middle line:90%
developed yourself.

00:08:59.510 --> 00:09:00.990 align:middle line:84%
And I'll get to
that in a second.

00:09:00.990 --> 00:09:04.460 align:middle line:84%
So we can say http
enum, hit Enter,

00:09:04.460 --> 00:09:06.950 align:middle line:84%
and you can also
probably specify

00:09:06.950 --> 00:09:09.750 align:middle line:90%
the port to be more specific.

00:09:09.750 --> 00:09:13.100 align:middle line:84%
So for example, I can limit
this scan to only port 80

00:09:13.100 --> 00:09:14.610 align:middle line:84%
as that is what
we're interested in.

00:09:14.610 --> 00:09:17.900 align:middle line:84%
So I can say port 80,
hit Enter, and we'll

00:09:17.900 --> 00:09:19.200 align:middle line:90%
give this a couple of seconds.

00:09:19.200 --> 00:09:21.283 align:middle line:84%
And let's see what the
script is able to bring up.

00:09:21.283 --> 00:09:24.350 align:middle line:84%
Now, this really isn't a
vulnerability detection script

00:09:24.350 --> 00:09:28.580 align:middle line:84%
so it'll only provide us with
information that we've already

00:09:28.580 --> 00:09:32.090 align:middle line:84%
been able to obtain like the
actual header, which tells us

00:09:32.090 --> 00:09:34.040 align:middle line:90%
the exact version of Apache.

00:09:34.040 --> 00:09:35.780 align:middle line:84%
Now, as a penetration
tester, you

00:09:35.780 --> 00:09:38.420 align:middle line:84%
can really start
off from this point

00:09:38.420 --> 00:09:43.400 align:middle line:84%
and utilize searchsploit
and say Apache 2.4.6

00:09:43.400 --> 00:09:46.400 align:middle line:84%
and try and identify
vulnerabilities or exploits.

00:09:46.400 --> 00:09:51.200 align:middle line:84%
And of course, this really
isn't comprehensive.

00:09:51.200 --> 00:09:53.780 align:middle line:84%
And of course, I'll take you
through the process of using

00:09:53.780 --> 00:09:55.370 align:middle line:90%
searchsploit when we get there.

00:09:55.370 --> 00:09:57.950 align:middle line:84%
However, going back
to the Nmap scripts

00:09:57.950 --> 00:10:00.710 align:middle line:84%
under the scripts
directory here,

00:10:00.710 --> 00:10:02.780 align:middle line:84%
the Nmap scripts
are developed or can

00:10:02.780 --> 00:10:05.820 align:middle line:84%
be created using the Lua
programming language.

00:10:05.820 --> 00:10:08.720 align:middle line:84%
So I'll just use a
simple example here using

00:10:08.720 --> 00:10:09.830 align:middle line:90%
the nano text editor.

00:10:09.830 --> 00:10:14.990 align:middle line:84%
So for example, if I wanted to
take a look at the actual HTTP

00:10:14.990 --> 00:10:17.120 align:middle line:84%
enum script that
we just used, so I

00:10:17.120 --> 00:10:22.580 align:middle line:84%
can say user share Nmap
scripts http enum.nse,

00:10:22.580 --> 00:10:23.750 align:middle line:90%
we can hit Enter.

00:10:23.750 --> 00:10:26.810 align:middle line:84%
It'll actually show
you what is being

00:10:26.810 --> 00:10:30.360 align:middle line:90%
done at a very advanced level.

00:10:30.360 --> 00:10:31.880 align:middle line:84%
And as I said, you
really don't need

00:10:31.880 --> 00:10:34.230 align:middle line:84%
to understand what's
going on here.

00:10:34.230 --> 00:10:36.350 align:middle line:84%
But if you ever wanted
to learn how or what

00:10:36.350 --> 00:10:39.410 align:middle line:84%
an Nmap script is doing, this
is a great place to start.

00:10:39.410 --> 00:10:41.360 align:middle line:84%
And of course,
once you move along

00:10:41.360 --> 00:10:43.640 align:middle line:84%
or you progress in your
pen testing journey,

00:10:43.640 --> 00:10:46.040 align:middle line:84%
you learn how to create
your own Nmap scripts,

00:10:46.040 --> 00:10:52.550 align:middle line:84%
the Lua programming language
in the context of Nmap and Nmap

00:10:52.550 --> 00:10:54.840 align:middle line:84%
scripts is fairly
simple to understand.

00:10:54.840 --> 00:10:58.310 align:middle line:84%
So that is really how
to utilize an Nmap

00:10:58.310 --> 00:10:59.640 align:middle line:90%
script in terms of syntax.

00:10:59.640 --> 00:11:04.760 align:middle line:84%
Now let's try and
get an understanding

00:11:04.760 --> 00:11:08.400 align:middle line:84%
of how to utilize an Nmap
script for a particular service.

00:11:08.400 --> 00:11:10.640 align:middle line:84%
Now, as a penetration
tester, we know

00:11:10.640 --> 00:11:13.640 align:middle line:84%
that the target is running
a web server on port 80.

00:11:13.640 --> 00:11:16.160 align:middle line:84%
We could run various
HTTP scripts.

00:11:16.160 --> 00:11:22.520 align:middle line:84%
And what we could also do is try
and search for particular Nmap

00:11:22.520 --> 00:11:25.580 align:middle line:84%
scripts by listing out the
contents of the Nmap scripts

00:11:25.580 --> 00:11:26.390 align:middle line:90%
directory.

00:11:26.390 --> 00:11:30.620 align:middle line:84%
And then we can pipe out the
actual output and use grep,

00:11:30.620 --> 00:11:33.920 align:middle line:84%
and we can utilize
the keyword vuln.

00:11:33.920 --> 00:11:37.250 align:middle line:84%
So this will only display
scripts with the keyword vuln

00:11:37.250 --> 00:11:38.910 align:middle line:90%
or vulnerability within it.

00:11:38.910 --> 00:11:42.320 align:middle line:84%
And this will give you a list
of vulnerability detection

00:11:42.320 --> 00:11:43.100 align:middle line:90%
scripts.

00:11:43.100 --> 00:11:44.810 align:middle line:84%
Now, you can see
there's quite a few,

00:11:44.810 --> 00:11:47.900 align:middle line:84%
and you probably
need to research more

00:11:47.900 --> 00:11:50.570 align:middle line:84%
about what these scripts do in
regards to the vulnerabilities

00:11:50.570 --> 00:11:51.890 align:middle line:90%
that they're scanning for.

00:11:51.890 --> 00:11:53.490 align:middle line:84%
And in the context
of Windows, you

00:11:53.490 --> 00:11:56.150 align:middle line:84%
will typically see that it
has the Microsoft security

00:11:56.150 --> 00:12:00.140 align:middle line:90%
identifier code, so ms06-025.

00:12:00.140 --> 00:12:03.000 align:middle line:84%
And then in some cases,
you'll also have the cve code.

00:12:03.000 --> 00:12:06.560 align:middle line:84%
So in this case, we can see
this is an SMB vulnerability

00:12:06.560 --> 00:12:11.930 align:middle line:84%
detection scanning script for
the vulnerability cve2009-3103.

00:12:11.930 --> 00:12:14.600 align:middle line:84%
Now, given the fact that the
target is running a web server,

00:12:14.600 --> 00:12:18.230 align:middle line:84%
we can look for a very
interesting vulnerability

00:12:18.230 --> 00:12:22.160 align:middle line:84%
detection script, and that
is by the name of shellshock.

00:12:22.160 --> 00:12:25.190 align:middle line:84%
Now, I've already explored
the shellshock vulnerability

00:12:25.190 --> 00:12:27.500 align:middle line:84%
and explained how to
exploit it in the system

00:12:27.500 --> 00:12:29.780 align:middle line:84%
and host-based attacks
course, but just

00:12:29.780 --> 00:12:31.220 align:middle line:84%
for the purpose
of demonstration,

00:12:31.220 --> 00:12:33.380 align:middle line:84%
I can search for that
particular vulnerability

00:12:33.380 --> 00:12:36.530 align:middle line:84%
here by grepping
out and saying only

00:12:36.530 --> 00:12:38.630 align:middle line:84%
to limit the results
to shellshock.

00:12:38.630 --> 00:12:41.330 align:middle line:84%
And you can see
that, indeed, Nmap

00:12:41.330 --> 00:12:44.840 align:middle line:84%
has an Nmap script for the
shellshock vulnerability.

00:12:44.840 --> 00:12:46.580 align:middle line:84%
And this particular
script can be

00:12:46.580 --> 00:12:49.310 align:middle line:84%
used to identify or to
check whether or not

00:12:49.310 --> 00:12:51.530 align:middle line:84%
the target web server
or the web server that's

00:12:51.530 --> 00:12:53.870 align:middle line:84%
running on the target is
vulnerable to the shellshock

00:12:53.870 --> 00:12:55.070 align:middle line:90%
vulnerability.

00:12:55.070 --> 00:12:57.140 align:middle line:84%
All right, so we can
do this, and I'm just

00:12:57.140 --> 00:13:00.930 align:middle line:84%
going to load up my
previous Nmap script here.

00:13:00.930 --> 00:13:03.430 align:middle line:84%
And instead of using
the HTTP enum script,

00:13:03.430 --> 00:13:06.510 align:middle line:90%
we'll say http shellshock.

00:13:06.510 --> 00:13:08.070 align:middle line:90%
And we'll give this--

00:13:08.070 --> 00:13:10.650 align:middle line:84%
yeah, that's all we need to
specify, and I'll hit Enter.

00:13:10.650 --> 00:13:12.450 align:middle line:84%
And let's see what
the results are.

00:13:12.450 --> 00:13:16.560 align:middle line:90%


00:13:16.560 --> 00:13:18.920 align:middle line:84%
All right, so we can see
that the script really

00:13:18.920 --> 00:13:22.010 align:middle line:84%
doesn't give us any
more information than we

00:13:22.010 --> 00:13:23.750 align:middle line:90%
were able to obtain previously.

00:13:23.750 --> 00:13:27.770 align:middle line:84%
And the reason for that is
because the http shellshock

00:13:27.770 --> 00:13:29.900 align:middle line:84%
script requires
additional arguments

00:13:29.900 --> 00:13:32.420 align:middle line:84%
pertinent to the
actual vulnerability

00:13:32.420 --> 00:13:34.650 align:middle line:84%
or to the service that's
running on the target.

00:13:34.650 --> 00:13:38.060 align:middle line:84%
So the shellshock
vulnerability without getting

00:13:38.060 --> 00:13:43.040 align:middle line:84%
too deep into it essentially
affects the ability for Apache

00:13:43.040 --> 00:13:45.380 align:middle line:84%
to essentially
execute CGI scripts.

00:13:45.380 --> 00:13:47.090 align:middle line:84%
Now, if we go back
to the website,

00:13:47.090 --> 00:13:49.770 align:middle line:84%
you can see that we have
a little timer here.

00:13:49.770 --> 00:13:51.200 align:middle line:84%
And this tells us
that the website

00:13:51.200 --> 00:13:55.080 align:middle line:84%
will be online in 0 days, 23
hours, et cetera, et cetera.

00:13:55.080 --> 00:13:58.220 align:middle line:84%
But this is really not
being rendered in HTML,

00:13:58.220 --> 00:14:00.080 align:middle line:84%
and it is a dynamic
counter, which

00:14:00.080 --> 00:14:03.530 align:middle line:84%
means that there is some
dynamic code execution going on

00:14:03.530 --> 00:14:05.520 align:middle line:90%
probably on the server side.

00:14:05.520 --> 00:14:08.640 align:middle line:84%
So if we view the actual
source of this page,

00:14:08.640 --> 00:14:10.905 align:middle line:84%
so I click on View
Selection Source here,

00:14:10.905 --> 00:14:12.530 align:middle line:84%
and let's take a look
at the code here,

00:14:12.530 --> 00:14:14.690 align:middle line:84%
and let's understand
what's going on.

00:14:14.690 --> 00:14:16.580 align:middle line:84%
You can see that
indeed, I was correct.

00:14:16.580 --> 00:14:19.520 align:middle line:84%
There is a script
being executed here.

00:14:19.520 --> 00:14:22.130 align:middle line:84%
And this is just your
typical JavaScript.

00:14:22.130 --> 00:14:25.970 align:middle line:84%
And if we take a look at the
xhttp.open function here,

00:14:25.970 --> 00:14:30.380 align:middle line:84%
we can see that it actually is
executing a CGI script called

00:14:30.380 --> 00:14:32.330 align:middle line:90%
gettime.cgi.

00:14:32.330 --> 00:14:36.740 align:middle line:84%
CGI scripts are essentially
used to execute system commands

00:14:36.740 --> 00:14:40.220 align:middle line:84%
or commands on the actual server
or the operating system that

00:14:40.220 --> 00:14:43.490 align:middle line:84%
is running or hosting this
web server and the website

00:14:43.490 --> 00:14:47.990 align:middle line:84%
and then redirect or display the
output onto the actual website

00:14:47.990 --> 00:14:48.810 align:middle line:90%
itself.

00:14:48.810 --> 00:14:52.460 align:middle line:84%
So again, the shellshock
vulnerability essentially

00:14:52.460 --> 00:14:54.600 align:middle line:90%
affects your CGI scripts.

00:14:54.600 --> 00:14:59.300 align:middle line:84%
So if we try and see if
we can access gettime.cgi

00:14:59.300 --> 00:15:03.380 align:middle line:84%
and hit Enter, this
is our CGI script,

00:15:03.380 --> 00:15:06.020 align:middle line:84%
and we can now check
as to whether or not

00:15:06.020 --> 00:15:08.330 align:middle line:84%
this particular CGI
script is indeed

00:15:08.330 --> 00:15:11.150 align:middle line:84%
vulnerable to the
shellshock vulnerability.

00:15:11.150 --> 00:15:15.260 align:middle line:84%
All right, so we can head
back over into our terminal,

00:15:15.260 --> 00:15:19.700 align:middle line:84%
and what we can do now is we
can use the previous Nmap scan.

00:15:19.700 --> 00:15:22.100 align:middle line:84%
However, the only
difference now is

00:15:22.100 --> 00:15:25.250 align:middle line:84%
we will need to specify
additional Nmap script

00:15:25.250 --> 00:15:28.640 align:middle line:84%
arguments, and this
can be done by simply

00:15:28.640 --> 00:15:32.980 align:middle line:90%
saying script arguments.

00:15:32.980 --> 00:15:36.550 align:middle line:84%
So that is script args, and let
me just get rid of the spaces

00:15:36.550 --> 00:15:37.180 align:middle line:90%
there.

00:15:37.180 --> 00:15:40.180 align:middle line:84%
And then for the arguments,
we are specifying arguments

00:15:40.180 --> 00:15:42.430 align:middle line:90%
for the HTTP shellshock script.

00:15:42.430 --> 00:15:47.900 align:middle line:84%
So we'll put that in quotation
marks, "http-shellshock."

00:15:47.900 --> 00:15:51.500 align:middle line:84%
However, the actual argument
that we want to provide

00:15:51.500 --> 00:15:54.770 align:middle line:90%
is the shellshock.uri.

00:15:54.770 --> 00:16:00.880 align:middle line:84%
So what we can do now is
just say http-shellshock.uri,

00:16:00.880 --> 00:16:04.870 align:middle line:84%
and the uri is going to
be the actual CGI script.

00:16:04.870 --> 00:16:07.090 align:middle line:84%
So we will specify
the CGI script.

00:16:07.090 --> 00:16:10.990 align:middle line:84%
So we'll say that is
equal to gettime.cgi,

00:16:10.990 --> 00:16:14.050 align:middle line:84%
really just providing its
relative location on the web

00:16:14.050 --> 00:16:14.950 align:middle line:90%
server.

00:16:14.950 --> 00:16:17.110 align:middle line:84%
And we can then hit
Enter, and let's see

00:16:17.110 --> 00:16:18.970 align:middle line:90%
what Nmap tells us this time.

00:16:18.970 --> 00:16:21.780 align:middle line:90%


00:16:21.780 --> 00:16:24.730 align:middle line:84%
All right, so the Nmap
script scan is done,

00:16:24.730 --> 00:16:28.020 align:middle line:84%
and as you can see, we actually
get really useful output

00:16:28.020 --> 00:16:32.160 align:middle line:84%
from the context of
exploitation or from the context

00:16:32.160 --> 00:16:33.670 align:middle line:90%
of the penetration tester.

00:16:33.670 --> 00:16:36.330 align:middle line:84%
So you can see it performs
its default service version

00:16:36.330 --> 00:16:40.260 align:middle line:84%
detection scan, and we get the
output from the HTTP shellshock

00:16:40.260 --> 00:16:41.130 align:middle line:90%
script now.

00:16:41.130 --> 00:16:44.010 align:middle line:84%
So you can see that it tells
us that the target is indeed

00:16:44.010 --> 00:16:44.820 align:middle line:90%
vulnerable.

00:16:44.820 --> 00:16:48.540 align:middle line:84%
And then under the HTTP
shellshock vulnerability,

00:16:48.540 --> 00:16:51.720 align:middle line:84%
it provides you with the state,
the IDs, the disclosure date,

00:16:51.720 --> 00:16:52.570 align:middle line:90%
and references.

00:16:52.570 --> 00:16:55.510 align:middle line:84%
So as a penetration tester,
this is the most important.

00:16:55.510 --> 00:16:58.410 align:middle line:84%
So it tells you that, indeed,
the target is vulnerable,

00:16:58.410 --> 00:17:03.300 align:middle line:84%
or the particular
Apache HTTP web

00:17:03.300 --> 00:17:05.500 align:middle line:90%
server is indeed vulnerable.

00:17:05.500 --> 00:17:09.089 align:middle line:84%
And again, that is in
relation to the CGI script.

00:17:09.089 --> 00:17:13.550 align:middle line:84%
And then it provides you with
the relative cve identifier.

00:17:13.550 --> 00:17:17.640 align:middle line:84%
And the cve codes, or
rather the CV identifier

00:17:17.640 --> 00:17:20.660 align:middle line:84%
is something that's very
important to actually know

00:17:20.660 --> 00:17:21.750 align:middle line:90%
as a penetration tester.

00:17:21.750 --> 00:17:25.260 align:middle line:84%
And we'll get into that in the
next section of this course.

00:17:25.260 --> 00:17:27.900 align:middle line:84%
But it gives you a description
of this vulnerability.

00:17:27.900 --> 00:17:29.420 align:middle line:84%
So it says, "this
web application

00:17:29.420 --> 00:17:31.610 align:middle line:84%
might be affected by
the vulnerability known

00:17:31.610 --> 00:17:32.630 align:middle line:90%
as shellshock.

00:17:32.630 --> 00:17:35.690 align:middle line:84%
It seems the server is
executing commands injected

00:17:35.690 --> 00:17:38.270 align:middle line:90%
via malicious HTTP headers."

00:17:38.270 --> 00:17:39.650 align:middle line:84%
All right, so
again, I've already

00:17:39.650 --> 00:17:42.680 align:middle line:84%
explained how to exploit this
vulnerability so I will not

00:17:42.680 --> 00:17:43.850 align:middle line:90%
be going into that.

00:17:43.850 --> 00:17:46.220 align:middle line:84%
I'm simply covering the
process of utilizing

00:17:46.220 --> 00:17:49.430 align:middle line:84%
Nmap scripts to identify
or to essentially perform

00:17:49.430 --> 00:17:51.620 align:middle line:84%
vulnerability
scanning or detection

00:17:51.620 --> 00:17:54.590 align:middle line:84%
on a particular service
that is running on a target.

00:17:54.590 --> 00:17:58.140 align:middle line:84%
So again, just at
a very high level,

00:17:58.140 --> 00:17:59.840 align:middle line:84%
this vulnerability
essentially allows

00:17:59.840 --> 00:18:02.690 align:middle line:84%
attackers to pass in
malicious HTTP headers

00:18:02.690 --> 00:18:06.590 align:middle line:84%
when making a get request
to a particular CGI script.

00:18:06.590 --> 00:18:09.710 align:middle line:84%
Those malicious HTTP
headers will essentially

00:18:09.710 --> 00:18:13.310 align:middle line:84%
include system or command or
rather just operating system

00:18:13.310 --> 00:18:15.560 align:middle line:84%
code, arbitrary
code, that will then

00:18:15.560 --> 00:18:18.860 align:middle line:84%
be processed by the actual
CGI script or the execution

00:18:18.860 --> 00:18:20.220 align:middle line:90%
of the CGI script.

00:18:20.220 --> 00:18:23.370 align:middle line:84%
And if that code is
malicious, then, of course,

00:18:23.370 --> 00:18:26.330 align:middle line:84%
it'll be executed on the
target, and it could potentially

00:18:26.330 --> 00:18:28.460 align:middle line:84%
provide an attacker
with remote access.

00:18:28.460 --> 00:18:32.570 align:middle line:84%
Or it could potentially
execute malicious code

00:18:32.570 --> 00:18:35.210 align:middle line:84%
that could be damaging
to the actual system.

00:18:35.210 --> 00:18:37.460 align:middle line:84%
All right, so it provides
you with the disclosure date

00:18:37.460 --> 00:18:38.720 align:middle line:90%
as well and references.

00:18:38.720 --> 00:18:41.180 align:middle line:84%
So you can learn more
about this vulnerability

00:18:41.180 --> 00:18:43.940 align:middle line:84%
and how to exploit it by taking
a look at the references.

00:18:43.940 --> 00:18:46.100 align:middle line:84%
And this is something
that's very important.

00:18:46.100 --> 00:18:48.200 align:middle line:84%
All right, so this is
really all that I wanted

00:18:48.200 --> 00:18:50.180 align:middle line:90%
to identify or to highlight.

00:18:50.180 --> 00:18:52.370 align:middle line:84%
And again, if you ever
want to learn more

00:18:52.370 --> 00:18:55.880 align:middle line:84%
about a particular Nmap script
that is, again, officially

00:18:55.880 --> 00:19:00.290 align:middle line:84%
developed and cataloged by the
Nmap team, all you need to do

00:19:00.290 --> 00:19:03.320 align:middle line:84%
is just search for the
actual Nmap script on Google,

00:19:03.320 --> 00:19:07.340 align:middle line:84%
and it'll actually provide
you with documentation

00:19:07.340 --> 00:19:09.920 align:middle line:84%
as to how you need to
specify the script arguments

00:19:09.920 --> 00:19:13.310 align:middle line:84%
and what information is needed
in order to successfully

00:19:13.310 --> 00:19:15.680 align:middle line:84%
perform the vulnerability
detection scan.

00:19:15.680 --> 00:19:17.450 align:middle line:84%
In this case, when
we ran the script

00:19:17.450 --> 00:19:21.530 align:middle line:84%
without providing any script
arguments, as you saw,

00:19:21.530 --> 00:19:24.830 align:middle line:84%
it did not provide us
with any important output,

00:19:24.830 --> 00:19:26.330 align:middle line:84%
and that's because
it didn't perform

00:19:26.330 --> 00:19:29.310 align:middle line:84%
the scan because it saw that
no script arguments were

00:19:29.310 --> 00:19:30.680 align:middle line:90%
specified.

00:19:30.680 --> 00:19:34.430 align:middle line:84%
And of course, in some
cases, you may be,

00:19:34.430 --> 00:19:37.610 align:middle line:84%
and of course, this is something
that you'll run across,

00:19:37.610 --> 00:19:40.910 align:middle line:84%
some Nmap vulnerability
detection scripts

00:19:40.910 --> 00:19:42.980 align:middle line:90%
do not require script arguments.

00:19:42.980 --> 00:19:45.890 align:middle line:84%
They can simply be ran
without providing arguments.

00:19:45.890 --> 00:19:48.560 align:middle line:84%
All you need to do
is learn how to look

00:19:48.560 --> 00:19:51.140 align:middle line:84%
for the particular script
based on the service

00:19:51.140 --> 00:19:52.190 align:middle line:90%
that you're targeting.

00:19:52.190 --> 00:19:54.620 align:middle line:84%
And that can easily be
done by, again, just

00:19:54.620 --> 00:19:57.470 align:middle line:84%
listing out the contents of
the Nmap scripts directory

00:19:57.470 --> 00:20:00.000 align:middle line:84%
and then grepping for
a particular service.

00:20:00.000 --> 00:20:02.780 align:middle line:84%
So for example, if
I was targeting FTP,

00:20:02.780 --> 00:20:05.330 align:middle line:84%
I can simply say
grep FTP, and you

00:20:05.330 --> 00:20:08.570 align:middle line:84%
can look for various FTP
vulnerability detection scripts

00:20:08.570 --> 00:20:11.720 align:middle line:84%
like this one here to
essentially identify or verify

00:20:11.720 --> 00:20:14.450 align:middle line:84%
whether that particular service
that's running on a target

00:20:14.450 --> 00:20:16.130 align:middle line:90%
is indeed vulnerable.

00:20:16.130 --> 00:20:17.930 align:middle line:84%
All right, so that
is going to conclude

00:20:17.930 --> 00:20:21.860 align:middle line:84%
the practical demonstration
side of this video.

00:20:21.860 --> 00:20:24.910 align:middle line:84%
All right, in the next video,
we will be taking a look

00:20:24.910 --> 00:20:28.300 align:middle line:84%
at how to perform vulnerability
scanning and detection

00:20:28.300 --> 00:20:29.907 align:middle line:90%
with the Metasploit framework.

00:20:29.907 --> 00:20:31.990 align:middle line:84%
And of course, this is
something that I've already

00:20:31.990 --> 00:20:34.720 align:middle line:84%
explored in its own
course, but we'll just

00:20:34.720 --> 00:20:38.560 align:middle line:84%
be touching upon some of the
important auxiliary modules

00:20:38.560 --> 00:20:41.110 align:middle line:84%
and how you can utilize the
Metasploit framework to,

00:20:41.110 --> 00:20:45.100 align:middle line:84%
again, perform what we were able
to do with the Nmap Scripting

00:20:45.100 --> 00:20:46.000 align:middle line:90%
Engine.

00:20:46.000 --> 00:20:49.600 align:middle line:84%
And that of course, is
just to identify or detect

00:20:49.600 --> 00:20:51.850 align:middle line:84%
vulnerabilities that
are running or that

00:20:51.850 --> 00:20:55.280 align:middle line:84%
affect a specific service that's
running on a target system.

00:20:55.280 --> 00:20:58.858 align:middle line:84%
So I'll see you
in the next video.

00:20:58.858 --> 00:20:59.358 align:middle line:90%