WEBVTT

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


00:00:03.479 --> 00:00:05.467 align:middle line:90%
[ELECTRONIC NOISES]

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


00:00:10.180 --> 00:00:13.637 align:middle line:84%
Exploiting a vulnerable
SMTP server-- in this video,

00:00:13.637 --> 00:00:15.220 align:middle line:84%
we're going to be
taking a look at how

00:00:15.220 --> 00:00:19.203 align:middle line:84%
to exploit a vulnerable SMTP
server running on a Linux host.

00:00:19.203 --> 00:00:20.620 align:middle line:84%
And of course,
this is going to be

00:00:20.620 --> 00:00:23.710 align:middle line:84%
facilitated through the use
of a Metasploit framework

00:00:23.710 --> 00:00:24.980 align:middle line:90%
exploit module.

00:00:24.980 --> 00:00:28.510 align:middle line:84%
Now, we already explored
SMTP as a protocol

00:00:28.510 --> 00:00:30.110 align:middle line:90%
in the enumeration section.

00:00:30.110 --> 00:00:32.500 align:middle line:84%
However, I'll give you
a brief introduction

00:00:32.500 --> 00:00:35.000 align:middle line:84%
if you're not familiar
with SMTP yet.

00:00:35.000 --> 00:00:39.650 align:middle line:84%
So SMTP stands for the Simple
Mail Transfer Protocol.

00:00:39.650 --> 00:00:41.800 align:middle line:84%
It is a communication
protocol that

00:00:41.800 --> 00:00:43.710 align:middle line:84%
is used for the
transmission of emails,

00:00:43.710 --> 00:00:45.320 align:middle line:90%
so for the sending of emails.

00:00:45.320 --> 00:00:49.520 align:middle line:84%
Now, SMTP utilizes TCP
port 25 by default.

00:00:49.520 --> 00:00:52.840 align:middle line:84%
However, it can also be
configured to run on TCP port

00:00:52.840 --> 00:00:55.030 align:middle line:90%
465 and 587.

00:00:55.030 --> 00:00:58.030 align:middle line:84%
So you may come across SMTP
servers that are running

00:00:58.030 --> 00:01:01.690 align:middle line:90%
on both port 465 or 587.

00:01:01.690 --> 00:01:03.490 align:middle line:84%
So you need to be
cognizant of that,

00:01:03.490 --> 00:01:05.890 align:middle line:84%
that you may again
run across or come

00:01:05.890 --> 00:01:08.590 align:middle line:84%
across SMTP servers
configured to run

00:01:08.590 --> 00:01:13.120 align:middle line:84%
on the other ports,
namely 465 and 587.

00:01:13.120 --> 00:01:17.590 align:middle line:84%
However, in most cases SMTP is
going to be running on port 25.

00:01:17.590 --> 00:01:19.780 align:middle line:84%
Now in this video,
we are going to be

00:01:19.780 --> 00:01:24.130 align:middle line:84%
taking a look at how to
exploit the Haraka SMTP server.

00:01:24.130 --> 00:01:28.930 align:middle line:84%
"Haraka" is a Kiswahili word
that essentially means "fast."

00:01:28.930 --> 00:01:31.600 align:middle line:84%
And in this case, it
actually makes a lot of sense

00:01:31.600 --> 00:01:34.240 align:middle line:84%
because Haraka is an
open-source, high-performance

00:01:34.240 --> 00:01:38.440 align:middle line:84%
SMTP server that's
developed in Node.js.

00:01:38.440 --> 00:01:42.220 align:middle line:84%
Now the Haraka SMTP server comes
with a plug-in for processing

00:01:42.220 --> 00:01:46.720 align:middle line:84%
attachments, and the Haraka
versions prior to 4.8.9

00:01:46.720 --> 00:01:48.820 align:middle line:84%
are vulnerable to
command injection.

00:01:48.820 --> 00:01:51.490 align:middle line:84%
So we can utilize a
Metasploit framework

00:01:51.490 --> 00:01:54.460 align:middle line:84%
exploit module to take
advantage of this vulnerability.

00:01:54.460 --> 00:01:56.740 align:middle line:84%
And of course, in
this case, the target

00:01:56.740 --> 00:02:01.450 align:middle line:84%
needs to be running Haraka SMTP,
more specifically the version

00:02:01.450 --> 00:02:04.780 align:middle line:84%
or any version prior
to version 2.8.9.

00:02:04.780 --> 00:02:07.360 align:middle line:84%
So let's take a look at how
this can be done within the lab

00:02:07.360 --> 00:02:08.270 align:middle line:90%
environment.

00:02:08.270 --> 00:02:10.160 align:middle line:84%
So you can spin up
the lab environment.

00:02:10.160 --> 00:02:11.860 align:middle line:84%
And, again, we'll
be able to take

00:02:11.860 --> 00:02:15.710 align:middle line:84%
a look at how we can go about
exploiting a vulnerable SMTP

00:02:15.710 --> 00:02:16.210 align:middle line:90%
server.

00:02:16.210 --> 00:02:18.160 align:middle line:84%
So I'll spin up my
lab environment,

00:02:18.160 --> 00:02:22.520 align:middle line:84%
and I'll see you within
the lab environment.

00:02:22.520 --> 00:02:24.870 align:middle line:84%
So I'm currently within
the lab environment.

00:02:24.870 --> 00:02:26.690 align:middle line:84%
And the first step,
of course, will

00:02:26.690 --> 00:02:29.960 align:middle line:84%
involve identifying the
target IP address or the IP

00:02:29.960 --> 00:02:31.680 align:middle line:90%
address of the target server.

00:02:31.680 --> 00:02:34.460 align:middle line:84%
So you can do you can
identify the target IP

00:02:34.460 --> 00:02:37.580 align:middle line:84%
address by typing in ifconfig
and then heading over

00:02:37.580 --> 00:02:39.110 align:middle line:90%
to the interface ethernet 1.

00:02:39.110 --> 00:02:41.150 align:middle line:84%
And of course,
right over here we

00:02:41.150 --> 00:02:43.770 align:middle line:84%
get our current Kali
Linux IP address.

00:02:43.770 --> 00:02:48.330 align:middle line:84%
So the target IP address is
going to be on the same subnet.

00:02:48.330 --> 00:02:50.450 align:middle line:84%
And instead of 2,
it's going to be 3.

00:02:50.450 --> 00:02:53.920 align:middle line:84%
So in your case, the subnet
is going to be different.

00:02:53.920 --> 00:02:57.020 align:middle line:84%
However, all you need to do
is just change the 2 to a 3.

00:02:57.020 --> 00:02:59.510 align:middle line:84%
And that's the IP address
that the target server

00:02:59.510 --> 00:03:01.370 align:middle line:90%
is going to be running on.

00:03:01.370 --> 00:03:02.640 align:middle line:90%
So we're going to copy that.

00:03:02.640 --> 00:03:06.140 align:middle line:84%
And then we want to make sure
that the PostgreSQL Database

00:03:06.140 --> 00:03:09.140 align:middle line:84%
Service and server
is started so that we

00:03:09.140 --> 00:03:11.610 align:middle line:84%
can interact with the
Metasploit framework database.

00:03:11.610 --> 00:03:13.185 align:middle line:90%
So we're going to start that up.

00:03:13.185 --> 00:03:15.560 align:middle line:84%
And then we're going to start
up the Metasploit framework

00:03:15.560 --> 00:03:16.255 align:middle line:90%
console.

00:03:16.255 --> 00:03:18.005 align:middle line:84%
So we're going to give
that a few seconds.

00:03:18.005 --> 00:03:24.000 align:middle line:90%


00:03:24.000 --> 00:03:24.750 align:middle line:90%
That started up.

00:03:24.750 --> 00:03:26.760 align:middle line:84%
We can now create
a new workspace.

00:03:26.760 --> 00:03:31.610 align:middle line:84%
And we are just going
to call it "haraka"

00:03:31.610 --> 00:03:34.470 align:middle line:84%
because we're targeting
the Haraka SMTP server.

00:03:34.470 --> 00:03:35.960 align:middle line:90%
So we're going to Enter.

00:03:35.960 --> 00:03:38.180 align:middle line:84%
I'm now going to set
up the global variables

00:03:38.180 --> 00:03:40.290 align:middle line:90%
for the rhost option.

00:03:40.290 --> 00:03:42.300 align:middle line:84%
So I'm going to set
that to the target IP.

00:03:42.300 --> 00:03:44.150 align:middle line:90%
So we'll switch the 2 to a 3.

00:03:44.150 --> 00:03:49.770 align:middle line:84%
And we'll also set the global
variable for the rhost option.

00:03:49.770 --> 00:03:53.720 align:middle line:84%
So we're going to say rhost,
paste in the IP address

00:03:53.720 --> 00:03:57.080 align:middle line:84%
and, of course, change
that to a 3, hit Enter.

00:03:57.080 --> 00:03:59.570 align:middle line:84%
And now we need to
actually perform

00:03:59.570 --> 00:04:01.880 align:middle line:84%
an Nmap scan on
the target server

00:04:01.880 --> 00:04:05.150 align:middle line:84%
to identify where the
SMTP is currently running.

00:04:05.150 --> 00:04:07.640 align:middle line:84%
And consequently, we
also need to verify

00:04:07.640 --> 00:04:11.090 align:middle line:84%
that the correct version or the
vulnerable version of Haraka

00:04:11.090 --> 00:04:13.440 align:middle line:84%
SMTP is running on
the target server.

00:04:13.440 --> 00:04:15.560 align:middle line:84%
So we'll do this
by running an Nmap

00:04:15.560 --> 00:04:18.390 align:middle line:84%
scan from within the
Metasploit framework console.

00:04:18.390 --> 00:04:22.410 align:middle line:84%
This can be facilitated through
the use of the DB Nmap command.

00:04:22.410 --> 00:04:24.260 align:middle line:84%
And, again, in this
case, we are just

00:04:24.260 --> 00:04:27.200 align:middle line:84%
going to perform a service
detection scan as well

00:04:27.200 --> 00:04:29.420 align:middle line:84%
as an operating
system detection scan.

00:04:29.420 --> 00:04:32.810 align:middle line:84%
We paste in the target
IP, change that to a 3,

00:04:32.810 --> 00:04:34.220 align:middle line:90%
and we hit Enter.

00:04:34.220 --> 00:04:37.640 align:middle line:84%
And the DB Nmap scan
or the DB Nmap command

00:04:37.640 --> 00:04:40.730 align:middle line:84%
will essentially save all
of the Nmap scan results

00:04:40.730 --> 00:04:43.640 align:middle line:84%
into the Metasploit
framework database, which

00:04:43.640 --> 00:04:48.080 align:middle line:84%
again will allow us to analyze
the scan results whenever

00:04:48.080 --> 00:04:48.650 align:middle line:90%
we want to.

00:04:48.650 --> 00:04:54.080 align:middle line:84%
So as you can see, the target
is running SMTP on port 252.

00:04:54.080 --> 00:05:01.370 align:middle line:84%
And the actual service
version is Haraka SMTPD 2.8.8,

00:05:01.370 --> 00:05:04.460 align:middle line:84%
which as we falls
within the parameters

00:05:04.460 --> 00:05:06.450 align:middle line:84%
that we specified
earlier in the slide.

00:05:06.450 --> 00:05:10.730 align:middle line:84%
So anything prior to
2.8.9 is vulnerable.

00:05:10.730 --> 00:05:13.370 align:middle line:84%
So now that we've identified
that we can actually clear out

00:05:13.370 --> 00:05:17.300 align:middle line:84%
the terminal, and we can search
for the exploit module that

00:05:17.300 --> 00:05:21.680 align:middle line:84%
can allow us to take advantage
of the vulnerability.

00:05:21.680 --> 00:05:24.810 align:middle line:84%
So we are going to search
for the Haraka module.

00:05:24.810 --> 00:05:27.260 align:middle line:84%
And in this case, we're
going to again specify

00:05:27.260 --> 00:05:28.820 align:middle line:90%
the type as exploit.

00:05:28.820 --> 00:05:30.620 align:middle line:90%
And then the name can be haraka.

00:05:30.620 --> 00:05:33.420 align:middle line:90%


00:05:33.420 --> 00:05:34.060 align:middle line:90%
There we are.

00:05:34.060 --> 00:05:36.360 align:middle line:84%
That's the actual
exploit module there.

00:05:36.360 --> 00:05:38.310 align:middle line:84%
As you can see, the
rank is excellent,

00:05:38.310 --> 00:05:39.990 align:middle line:84%
and the description
tells us that this

00:05:39.990 --> 00:05:43.288 align:middle line:84%
is the Haraka SMTP command
injection exploit module.

00:05:43.288 --> 00:05:44.955 align:middle line:84%
So we're going to
copy that and say use.

00:05:44.955 --> 00:05:47.480 align:middle line:90%


00:05:47.480 --> 00:05:50.860 align:middle line:84%
We now want to show
the options here.

00:05:50.860 --> 00:05:55.240 align:middle line:84%
As for the options, we need to
specify a few important options

00:05:55.240 --> 00:05:58.390 align:middle line:84%
like the server host
and the server port

00:05:58.390 --> 00:06:00.550 align:middle line:90%
as well as the email too.

00:06:00.550 --> 00:06:04.360 align:middle line:84%
So, again, this is just going
to be a sample or a test email

00:06:04.360 --> 00:06:05.320 align:middle line:90%
to send to.

00:06:05.320 --> 00:06:08.980 align:middle line:84%
And we need to specify the
actual test email send address.

00:06:08.980 --> 00:06:11.680 align:middle line:84%
And of course, this must
be accepted by the server.

00:06:11.680 --> 00:06:13.570 align:middle line:84%
In our case, we
already have one,

00:06:13.570 --> 00:06:16.510 align:middle line:84%
and I'm going to, again,
tell you what it is.

00:06:16.510 --> 00:06:19.300 align:middle line:84%
You can see that the rhost
option is specified here

00:06:19.300 --> 00:06:21.280 align:middle line:84%
because we set the
global variable.

00:06:21.280 --> 00:06:24.040 align:middle line:84%
And the rport option is
also specified correctly

00:06:24.040 --> 00:06:28.360 align:middle line:84%
as the default SMTP
port, which is port 25.

00:06:28.360 --> 00:06:30.400 align:middle line:84%
We now need to
set a few options.

00:06:30.400 --> 00:06:31.900 align:middle line:84%
The first option
that we want to set

00:06:31.900 --> 00:06:36.922 align:middle line:84%
is the server port, which
we will set to port 9898

00:06:36.922 --> 00:06:40.190 align:middle line:84%
because, again, we are
going to need that port.

00:06:40.190 --> 00:06:42.250 align:middle line:84%
So we're going to
say set, and we're

00:06:42.250 --> 00:06:47.590 align:middle line:84%
going to set the server
port to port 9898.

00:06:47.590 --> 00:06:50.620 align:middle line:84%
Once that is done, we want
to set the email_to value

00:06:50.620 --> 00:06:52.540 align:middle line:90%
or the email_to option.

00:06:52.540 --> 00:06:55.030 align:middle line:84%
And the email that you
want to use in this case

00:06:55.030 --> 00:06:56.740 align:middle line:90%
is root@attackdefense.test.

00:06:56.740 --> 00:07:00.640 align:middle line:90%


00:07:00.640 --> 00:07:02.170 align:middle line:90%
We hit Enter.

00:07:02.170 --> 00:07:05.020 align:middle line:84%
We then want to set the
payload that we want to utilize

00:07:05.020 --> 00:07:07.900 align:middle line:84%
or the payload
that we essentially

00:07:07.900 --> 00:07:11.960 align:middle line:84%
want executed on the target
system once the exploit is run.

00:07:11.960 --> 00:07:14.680 align:middle line:84%
And in this case because
the target system is a Linux

00:07:14.680 --> 00:07:17.080 align:middle line:84%
target, we are going
to utilize the payload

00:07:17.080 --> 00:07:18.960 align:middle line:90%
linux/x64/meterpreter.

00:07:18.960 --> 00:07:22.910 align:middle line:90%


00:07:22.910 --> 00:07:24.980 align:middle line:84%
And instead of using
a staged payload,

00:07:24.980 --> 00:07:27.710 align:middle line:84%
we are going to be utilizing
a non-staged payload.

00:07:27.710 --> 00:07:31.550 align:middle line:84%
So we're going to say reverse,
and we can use the reverse_http

00:07:31.550 --> 00:07:32.990 align:middle line:90%
payload.

00:07:32.990 --> 00:07:36.740 align:middle line:84%
We then need to set up
the rhost option, which

00:07:36.740 --> 00:07:38.360 align:middle line:90%
we have done already.

00:07:38.360 --> 00:07:41.720 align:middle line:84%
And we then need to, of course,
set the LHOST option, which

00:07:41.720 --> 00:07:43.100 align:middle line:90%
is going to be our IP.

00:07:43.100 --> 00:07:46.720 align:middle line:84%
So if I say show
options, the payload

00:07:46.720 --> 00:07:48.920 align:middle line:90%
requires the LHOST option.

00:07:48.920 --> 00:07:52.630 align:middle line:84%
And the reason we changed
the server port to 9898

00:07:52.630 --> 00:07:56.680 align:middle line:84%
is because this payload
will require the port 8080.

00:07:56.680 --> 00:07:59.770 align:middle line:84%
So we'll set the
LHOST IP address here

00:07:59.770 --> 00:08:03.170 align:middle line:84%
to the ethernet 1 interface
IP, which we've done.

00:08:03.170 --> 00:08:03.790 align:middle line:90%
There we are.

00:08:03.790 --> 00:08:06.460 align:middle line:84%
We specify ethernet 1,
and it sets the IP address

00:08:06.460 --> 00:08:08.150 align:middle line:90%
automatically for us.

00:08:08.150 --> 00:08:10.990 align:middle line:84%
And all we need to do
now is just type in run

00:08:10.990 --> 00:08:12.520 align:middle line:90%
and give that a few seconds.

00:08:12.520 --> 00:08:15.460 align:middle line:84%
As you can see the exploit,
completed successfully,

00:08:15.460 --> 00:08:17.980 align:middle line:84%
and we get a
Meterpreter session.

00:08:17.980 --> 00:08:20.650 align:middle line:84%
And of course, this is
a non-staged payload,

00:08:20.650 --> 00:08:22.610 align:middle line:90%
or a stateless payload.

00:08:22.610 --> 00:08:24.610 align:middle line:84%
So we should be able
to get the Meterpreter

00:08:24.610 --> 00:08:26.575 align:middle line:90%
session in a few seconds.

00:08:26.575 --> 00:08:29.250 align:middle line:90%


00:08:29.250 --> 00:08:31.650 align:middle line:84%
So we get the
Meterpreter session.

00:08:31.650 --> 00:08:34.784 align:middle line:84%
So we can type in sysinfo
and give that a few seconds.

00:08:34.784 --> 00:08:38.289 align:middle line:90%


00:08:38.289 --> 00:08:38.890 align:middle line:90%
There we are.

00:08:38.890 --> 00:08:43.030 align:middle line:84%
As you can see, this is an
Ubuntu 16.04 Linux system,

00:08:43.030 --> 00:08:46.450 align:middle line:90%
and the kernel version is 5.4.0.

00:08:46.450 --> 00:08:50.920 align:middle line:84%
We can get our current
privileges by typing in getuid,

00:08:50.920 --> 00:08:53.710 align:middle line:84%
and that will enumerate
our current permissions

00:08:53.710 --> 00:08:55.070 align:middle line:90%
on the target system.

00:08:55.070 --> 00:08:57.940 align:middle line:84%
And as you can see, we
get the user ID of 0.

00:08:57.940 --> 00:09:00.280 align:middle line:84%
Or the user ID value
is 0, which means

00:09:00.280 --> 00:09:04.510 align:middle line:84%
we have root access which
essentially means that we have

00:09:04.510 --> 00:09:07.750 align:middle line:84%
the highest privileges available
on the Linux target which

00:09:07.750 --> 00:09:11.050 align:middle line:84%
consequently means we do not
need to elevate our privileges

00:09:11.050 --> 00:09:13.630 align:middle line:90%
or perform privilege escalation.

00:09:13.630 --> 00:09:17.073 align:middle line:84%
So that is how to
exploit an SMTP server.

00:09:17.073 --> 00:09:18.490 align:middle line:84%
And in this case,
we have explored

00:09:18.490 --> 00:09:22.070 align:middle line:84%
the process of exploiting
the Haraka SMTP server.

00:09:22.070 --> 00:09:25.120 align:middle line:84%
So that is going to conclude
the practical section

00:09:25.120 --> 00:09:25.885 align:middle line:90%
of this video.

00:09:25.885 --> 00:09:28.520 align:middle line:90%


00:09:28.520 --> 00:09:32.930 align:middle line:84%
So as I said, that's how to
exploit a vulnerable SMTP

00:09:32.930 --> 00:09:33.740 align:middle line:90%
server.

00:09:33.740 --> 00:09:36.050 align:middle line:84%
We have now concluded
or completed

00:09:36.050 --> 00:09:38.490 align:middle line:84%
the exploitation
section of this course.

00:09:38.490 --> 00:09:41.810 align:middle line:84%
So we have explored the
process of exploiting services

00:09:41.810 --> 00:09:44.480 align:middle line:84%
on both Windows and
Linux and can now

00:09:44.480 --> 00:09:47.670 align:middle line:84%
move on to the
post-exploitation section.

00:09:47.670 --> 00:09:50.870 align:middle line:84%
We will be taking a look at
how to utilize Meterpreter

00:09:50.870 --> 00:09:54.860 align:middle line:84%
as well as exploring the various
post-exploitation techniques

00:09:54.860 --> 00:09:58.230 align:middle line:84%
that we can utilize on both
Windows and Linux systems.

00:09:58.230 --> 00:10:00.940 align:middle line:90%
So I'll see you there.

00:10:00.940 --> 00:10:02.000 align:middle line:90%