WEBVTT

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


00:00:03.374 --> 00:00:08.194 align:middle line:90%
[LOGO WHOOSHING]

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


00:00:10.140 --> 00:00:12.900 align:middle line:84%
Generating Payloads
With Msfvenom.

00:00:12.900 --> 00:00:17.320 align:middle line:84%
So welcome to the client-side
attack section of this course.

00:00:17.320 --> 00:00:19.170 align:middle line:84%
Now that you've
essentially explored

00:00:19.170 --> 00:00:22.200 align:middle line:84%
the process of performing
information gathering

00:00:22.200 --> 00:00:24.780 align:middle line:84%
enumeration, as well as
vulnerability scanning,

00:00:24.780 --> 00:00:27.540 align:middle line:84%
we can begin exploring
exploitation.

00:00:27.540 --> 00:00:29.520 align:middle line:84%
And the first type
of exploitation

00:00:29.520 --> 00:00:32.729 align:middle line:84%
or the first attack vector
that we will be exploring

00:00:32.729 --> 00:00:34.350 align:middle line:90%
our client-side attacks.

00:00:34.350 --> 00:00:36.840 align:middle line:84%
And in order to perform
a client-side attack,

00:00:36.840 --> 00:00:39.690 align:middle line:84%
we will need to know how
to generate the Metasploit

00:00:39.690 --> 00:00:41.250 align:middle line:90%
framework payloads.

00:00:41.250 --> 00:00:43.050 align:middle line:84%
And in order to
generate these payloads,

00:00:43.050 --> 00:00:46.590 align:middle line:84%
we will be utilizing a
utility called msfvenom.

00:00:46.590 --> 00:00:48.780 align:middle line:84%
So let's get started
first and foremost

00:00:48.780 --> 00:00:51.750 align:middle line:84%
by understanding what
client-side attacks are

00:00:51.750 --> 00:00:54.270 align:middle line:84%
and how they differ
from host-based attacks

00:00:54.270 --> 00:00:56.460 align:middle line:90%
or service-based attacks.

00:00:56.460 --> 00:00:58.860 align:middle line:84%
So a client-side attack
is an attack vector

00:00:58.860 --> 00:01:02.700 align:middle line:84%
that involves coercing a client
to execute a malicious payload

00:01:02.700 --> 00:01:05.040 align:middle line:84%
on their system that
consequently connects back

00:01:05.040 --> 00:01:07.450 align:middle line:90%
to the attacker when executed.

00:01:07.450 --> 00:01:09.360 align:middle line:84%
Now, client-side
attacks will typically

00:01:09.360 --> 00:01:11.640 align:middle line:84%
utilize various social
engineering techniques

00:01:11.640 --> 00:01:13.740 align:middle line:84%
like generating
malicious documents

00:01:13.740 --> 00:01:16.080 align:middle line:84%
or malicious
portable executables

00:01:16.080 --> 00:01:19.890 align:middle line:84%
in the case of Windows
and, in some cases,

00:01:19.890 --> 00:01:22.680 align:middle line:84%
in the form of a Debian
package for Linux.

00:01:22.680 --> 00:01:24.660 align:middle line:84%
Now, client-side
attacks, and this

00:01:24.660 --> 00:01:26.580 align:middle line:84%
is where the difference
comes into play,

00:01:26.580 --> 00:01:29.190 align:middle line:84%
take advantage of
human vulnerabilities

00:01:29.190 --> 00:01:31.290 align:middle line:84%
as opposed to
vulnerabilities in services

00:01:31.290 --> 00:01:33.910 align:middle line:84%
or software that's running
on the target system.

00:01:33.910 --> 00:01:37.290 align:middle line:84%
So depending on the way
the target operating

00:01:37.290 --> 00:01:39.630 align:middle line:84%
system or the target
system has been configured,

00:01:39.630 --> 00:01:42.750 align:middle line:84%
you'll need to, again, structure
or coordinate your attack

00:01:42.750 --> 00:01:43.480 align:middle line:90%
accordingly.

00:01:43.480 --> 00:01:46.090 align:middle line:84%
So I'll give you
an example here.

00:01:46.090 --> 00:01:48.660 align:middle line:84%
If the target system that
you're trying to attack

00:01:48.660 --> 00:01:50.430 align:middle line:84%
or you're trying
to gain access to

00:01:50.430 --> 00:01:53.100 align:middle line:84%
has been configured as a
server, so, for example,

00:01:53.100 --> 00:01:54.840 align:middle line:84%
it's running Windows
Server, and it's

00:01:54.840 --> 00:01:58.950 align:middle line:84%
used to host business-critical
applications or web server,

00:01:58.950 --> 00:02:01.620 align:middle line:84%
for example, then
our attack vector

00:02:01.620 --> 00:02:04.950 align:middle line:84%
would be a host-based attack
or a service-based attack,

00:02:04.950 --> 00:02:07.680 align:middle line:84%
whereby we will be trying
to find vulnerabilities

00:02:07.680 --> 00:02:11.620 align:middle line:84%
within the services that
are running on that system.

00:02:11.620 --> 00:02:15.090 align:middle line:84%
Now, if the target system
that you're trying to attack

00:02:15.090 --> 00:02:18.100 align:middle line:84%
has been configured to run as
an end-user operating system,

00:02:18.100 --> 00:02:20.790 align:middle line:84%
so let's say you're trying
to target an employee

00:02:20.790 --> 00:02:23.040 align:middle line:84%
laptop or an
employee workstation,

00:02:23.040 --> 00:02:25.470 align:middle line:84%
then you'll need to
change your attack vector

00:02:25.470 --> 00:02:28.410 align:middle line:84%
to a client-side attack,
where your job will be to,

00:02:28.410 --> 00:02:32.010 align:middle line:84%
first and foremost, generate
a malicious payload either

00:02:32.010 --> 00:02:33.300 align:middle line:90%
for Windows or Linux.

00:02:33.300 --> 00:02:36.360 align:middle line:84%
And then secondly, you can
utilize social engineering

00:02:36.360 --> 00:02:38.940 align:middle line:84%
techniques like,
again, essentially

00:02:38.940 --> 00:02:44.190 align:middle line:84%
generating malicious documents
or making the payloads look

00:02:44.190 --> 00:02:47.760 align:middle line:84%
as enticing as possible so
that you are essentially

00:02:47.760 --> 00:02:52.200 align:middle line:84%
trying to convince the client
or the target employee,

00:02:52.200 --> 00:02:54.550 align:middle line:84%
in this case, to actually
click on that payload.

00:02:54.550 --> 00:02:57.370 align:middle line:84%
So this is where social
engineering comes into play.

00:02:57.370 --> 00:02:59.220 align:middle line:84%
Now, we are not
going to be covering

00:02:59.220 --> 00:03:01.890 align:middle line:84%
the various social engineering
techniques within this course,

00:03:01.890 --> 00:03:04.240 align:middle line:84%
as that is beyond the
scope of this course.

00:03:04.240 --> 00:03:06.780 align:middle line:84%
But a simple example
or a scenario

00:03:06.780 --> 00:03:11.742 align:middle line:84%
would be that we generate a
Windows payload with msfvenom.

00:03:11.742 --> 00:03:13.200 align:middle line:84%
Once we have
generated the payload,

00:03:13.200 --> 00:03:17.190 align:middle line:84%
we can then inject the payload
into another legitimate Windows

00:03:17.190 --> 00:03:20.130 align:middle line:84%
executable, therefore,
making it look legitimate.

00:03:20.130 --> 00:03:23.850 align:middle line:84%
And then we can distribute this
to the client or the target

00:03:23.850 --> 00:03:26.190 align:middle line:84%
employee either
through email or maybe

00:03:26.190 --> 00:03:28.660 align:middle line:84%
through another type of
communication channel.

00:03:28.660 --> 00:03:31.690 align:middle line:84%
And once it's on their
system, they will click on it

00:03:31.690 --> 00:03:33.850 align:middle line:84%
and consequently
execute the payload.

00:03:33.850 --> 00:03:35.400 align:middle line:84%
Now, when they
execute the payload,

00:03:35.400 --> 00:03:38.430 align:middle line:84%
we need to be ready with
a handler or a listener

00:03:38.430 --> 00:03:40.680 align:middle line:84%
rather that will
essentially receive

00:03:40.680 --> 00:03:42.220 align:middle line:90%
the incoming connection.

00:03:42.220 --> 00:03:45.978 align:middle line:84%
And once they, again, execute
it on their target system

00:03:45.978 --> 00:03:47.520 align:middle line:84%
and once we have
the listener set up,

00:03:47.520 --> 00:03:51.000 align:middle line:84%
we should be able to receive
the reconnection back

00:03:51.000 --> 00:03:54.060 align:middle line:84%
from the target system, and
consequently, gain access

00:03:54.060 --> 00:03:55.440 align:middle line:90%
to the target system.

00:03:55.440 --> 00:03:57.300 align:middle line:84%
Now, one thing to
keep in mind is

00:03:57.300 --> 00:04:01.890 align:middle line:84%
that given that the client-side
attack vector involves

00:04:01.890 --> 00:04:05.190 align:middle line:84%
the transfer and storage
of a malicious payload

00:04:05.190 --> 00:04:09.810 align:middle line:84%
on the client system,
primarily being on their disk,

00:04:09.810 --> 00:04:12.930 align:middle line:84%
we also need to be cognizant
of antivirus detection.

00:04:12.930 --> 00:04:15.810 align:middle line:84%
So, again, because
we're essentially

00:04:15.810 --> 00:04:20.310 align:middle line:84%
trying to send a payload or
trying to get a target employee

00:04:20.310 --> 00:04:23.430 align:middle line:84%
or individual to download
a malicious payload

00:04:23.430 --> 00:04:25.770 align:middle line:84%
and then execute
it on their system,

00:04:25.770 --> 00:04:28.770 align:middle line:84%
we need to be aware of the
fact that their system could

00:04:28.770 --> 00:04:31.410 align:middle line:84%
have an antivirus
solution installed

00:04:31.410 --> 00:04:33.510 align:middle line:84%
that could consequently
detect or find

00:04:33.510 --> 00:04:35.640 align:middle line:84%
that this particular
payload is malicious

00:04:35.640 --> 00:04:39.980 align:middle line:84%
and prevent the target
individual from executing it.

00:04:39.980 --> 00:04:43.590 align:middle line:84%
So we'll also be exploring the
process of encoding payloads

00:04:43.590 --> 00:04:44.850 align:middle line:90%
with msfvenom.

00:04:44.850 --> 00:04:47.190 align:middle line:84%
And then finally, to
wrap up this section,

00:04:47.190 --> 00:04:50.760 align:middle line:84%
we'll be exploring the process
of essentially generating

00:04:50.760 --> 00:04:54.600 align:middle line:84%
or injecting our payloads
into a legitimate executable

00:04:54.600 --> 00:04:57.840 align:middle line:84%
to make it look as
enticing as possible.

00:04:57.840 --> 00:05:01.350 align:middle line:84%
So we've talked a little
bit about what msfvenom is,

00:05:01.350 --> 00:05:02.202 align:middle line:90%
or rather we've--

00:05:02.202 --> 00:05:03.660 align:middle line:84%
I've given you a
basic description.

00:05:03.660 --> 00:05:07.420 align:middle line:84%
But really, it's a very
simple tool to understand.

00:05:07.420 --> 00:05:09.930 align:middle line:84%
msfvenom is a
command-line utility

00:05:09.930 --> 00:05:13.110 align:middle line:84%
that can be used to generate
and encode Metasploit Framework

00:05:13.110 --> 00:05:15.390 align:middle line:84%
payloads for various
operating systems,

00:05:15.390 --> 00:05:17.070 align:middle line:90%
as well as web servers.

00:05:17.070 --> 00:05:20.070 align:middle line:84%
Now, if you've used the
Metasploit Framework for,

00:05:20.070 --> 00:05:23.350 align:middle line:84%
probably, I would say,
before the last five years,

00:05:23.350 --> 00:05:26.310 align:middle line:84%
then you would know
that msfvenom is really

00:05:26.310 --> 00:05:28.380 align:middle line:84%
a new utility and
is a combination

00:05:28.380 --> 00:05:33.540 align:middle line:84%
of two previous utilities known
as msfpayload and msfencode.

00:05:33.540 --> 00:05:36.480 align:middle line:84%
So msfpayload was used
to generate payloads,

00:05:36.480 --> 00:05:39.030 align:middle line:84%
and then msfencode was
used to encode payloads.

00:05:39.030 --> 00:05:40.690 align:middle line:84%
They were two
separate utilities,

00:05:40.690 --> 00:05:44.550 align:middle line:84%
but now they actually joined
into one called msfvenom.

00:05:44.550 --> 00:05:47.470 align:middle line:84%
And msfvenom is part of
the Metasploit Framework.

00:05:47.470 --> 00:05:49.080 align:middle line:84%
It's a Metasploit
Framework utility,

00:05:49.080 --> 00:05:51.630 align:middle line:84%
and it comes pre-packaged
with Kali Linux,

00:05:51.630 --> 00:05:53.940 align:middle line:84%
so you don't have to actually
download it or install it

00:05:53.940 --> 00:05:54.900 align:middle line:90%
manually.

00:05:54.900 --> 00:05:57.240 align:middle line:84%
Now, we can-- in this
particular scenario,

00:05:57.240 --> 00:05:58.590 align:middle line:90%
we can utilize the MSF--

00:05:58.590 --> 00:06:01.890 align:middle line:84%
we can utilize
msfvenom to generate

00:06:01.890 --> 00:06:04.740 align:middle line:84%
a malicious meterpreter payload
that can then be transferred

00:06:04.740 --> 00:06:06.510 align:middle line:90%
onto the client target system.

00:06:06.510 --> 00:06:09.780 align:middle line:84%
Once executed, it will connect
back to our payload handler

00:06:09.780 --> 00:06:12.630 align:middle line:84%
and provide us with remote
access to the target system.

00:06:12.630 --> 00:06:16.110 align:middle line:84%
And I'll also be explaining
what a handler is

00:06:16.110 --> 00:06:18.850 align:middle line:84%
in the context of a
meterpreter payload.

00:06:18.850 --> 00:06:21.270 align:middle line:84%
So now that we have an
understanding of what

00:06:21.270 --> 00:06:24.330 align:middle line:84%
we are going to be doing
and what we are essentially

00:06:24.330 --> 00:06:27.510 align:middle line:84%
going to be covering within
this section, let's get

00:06:27.510 --> 00:06:29.830 align:middle line:84%
started with the first
practical section,

00:06:29.830 --> 00:06:32.880 align:middle line:84%
which is how to generate
payloads with msfvenom.

00:06:32.880 --> 00:06:35.830 align:middle line:90%


00:06:35.830 --> 00:06:38.440 align:middle line:84%
All right, so I'm back
on my Kali Linux VM.

00:06:38.440 --> 00:06:40.600 align:middle line:84%
In this case, you don't
need a lab environment

00:06:40.600 --> 00:06:42.100 align:middle line:84%
to follow along
with the techniques.

00:06:42.100 --> 00:06:44.830 align:middle line:84%
As I said, this is a
client-side attack,

00:06:44.830 --> 00:06:46.780 align:middle line:84%
so we essentially
just taking a look

00:06:46.780 --> 00:06:48.500 align:middle line:90%
at how to generate payloads.

00:06:48.500 --> 00:06:51.220 align:middle line:84%
So, in terms of
running msfvenom,

00:06:51.220 --> 00:06:54.280 align:middle line:84%
it's fairly simple to
understand or rather to use.

00:06:54.280 --> 00:06:57.250 align:middle line:84%
We can just type in
msf and then venom.

00:06:57.250 --> 00:06:59.197 align:middle line:90%
Hit Enter.

00:06:59.197 --> 00:07:01.530 align:middle line:84%
And as you can see, that will
open up the documentation,

00:07:01.530 --> 00:07:03.540 align:middle line:84%
and it gives you an idea
of what this tool is

00:07:03.540 --> 00:07:06.050 align:middle line:90%
and what it's used for.

00:07:06.050 --> 00:07:08.530 align:middle line:84%
So, as you can see,
it says msfvenom

00:07:08.530 --> 00:07:12.040 align:middle line:84%
is a Metasploit standalone
payload generator.

00:07:12.040 --> 00:07:16.600 align:middle line:84%
And it's also a replacement
for msfpayload and msfencode.

00:07:16.600 --> 00:07:19.270 align:middle line:84%
So it gives you some
usage examples here,

00:07:19.270 --> 00:07:21.760 align:middle line:84%
and you can take a look at
all of the options here.

00:07:21.760 --> 00:07:23.320 align:middle line:84%
Now, I'm going to
be explaining some

00:07:23.320 --> 00:07:26.740 align:middle line:84%
of the key elements of msfvenom
that you need to understand.

00:07:26.740 --> 00:07:29.800 align:middle line:84%
As you know previously,
during the earlier section

00:07:29.800 --> 00:07:32.170 align:middle line:84%
or the introduction
section of this course,

00:07:32.170 --> 00:07:36.430 align:middle line:84%
I briefly explained the two
types of Metasploit Framework

00:07:36.430 --> 00:07:37.850 align:middle line:90%
modules available.

00:07:37.850 --> 00:07:40.060 align:middle line:84%
One of which was
a staged payload,

00:07:40.060 --> 00:07:42.970 align:middle line:84%
where the payload would
essentially be sent into parts.

00:07:42.970 --> 00:07:46.660 align:middle line:84%
And then you have the
non-staged or inline payloads,

00:07:46.660 --> 00:07:48.730 align:middle line:84%
where the payload is
essentially sent along

00:07:48.730 --> 00:07:50.530 align:middle line:90%
with the exploit as a whole.

00:07:50.530 --> 00:07:53.860 align:middle line:84%
And with msfvenom,
you can generate both

00:07:53.860 --> 00:07:55.450 align:middle line:90%
of these types of payloads.

00:07:55.450 --> 00:07:57.700 align:middle line:84%
But before we do
that, if you want

00:07:57.700 --> 00:07:59.380 align:middle line:84%
to list out the
available payloads,

00:07:59.380 --> 00:08:01.270 align:middle line:90%
you can generate with msfvenom.

00:08:01.270 --> 00:08:05.390 align:middle line:84%
You can type in msfvenom and
then list out the payloads.

00:08:05.390 --> 00:08:07.060 align:middle line:90%
So I can say list payloads.

00:08:07.060 --> 00:08:10.040 align:middle line:84%
Give that a few seconds, as
there are quite a few payloads

00:08:10.040 --> 00:08:10.540 align:middle line:90%
here.

00:08:10.540 --> 00:08:17.950 align:middle line:90%


00:08:17.950 --> 00:08:19.870 align:middle line:84%
So, as you can see,
this will provide you

00:08:19.870 --> 00:08:21.730 align:middle line:84%
with a list of all
available payloads

00:08:21.730 --> 00:08:24.250 align:middle line:84%
that you can generate
with msfvenom.

00:08:24.250 --> 00:08:26.570 align:middle line:84%
And as you can see,
there are quite a lot.

00:08:26.570 --> 00:08:28.550 align:middle line:84%
However, in this course
and in this case,

00:08:28.550 --> 00:08:30.580 align:middle line:84%
we're going to be
focusing primarily

00:08:30.580 --> 00:08:31.900 align:middle line:90%
on the meterpreter payload.

00:08:31.900 --> 00:08:35.230 align:middle line:84%
And as we already know,
the meterpreter payload

00:08:35.230 --> 00:08:38.110 align:middle line:84%
also allows you to specify
the target architecture

00:08:38.110 --> 00:08:40.250 align:middle line:90%
of the target operating system.

00:08:40.250 --> 00:08:43.010 align:middle line:84%
So you can generate
a x64 payload,

00:08:43.010 --> 00:08:44.770 align:middle line:90%
which is a 64-bit payload.

00:08:44.770 --> 00:08:47.200 align:middle line:84%
You can also generate
a 32-bit payload,

00:08:47.200 --> 00:08:50.200 align:middle line:84%
where, again, if I can actually
identify this or actually

00:08:50.200 --> 00:08:52.250 align:middle line:84%
find it here, I should
be able to show you that.

00:08:52.250 --> 00:08:54.250 align:middle line:84%
And then, of course, I'll
explain the difference

00:08:54.250 --> 00:08:56.530 align:middle line:84%
between a staged
meterpreter payload

00:08:56.530 --> 00:08:58.900 align:middle line:90%
and a non-staged payload.

00:08:58.900 --> 00:09:00.880 align:middle line:84%
So, again, if
hopefully, I can find

00:09:00.880 --> 00:09:03.130 align:middle line:84%
the Windows meterpreter
payload here.

00:09:03.130 --> 00:09:06.730 align:middle line:84%
This is the one, so this is
a standard 32-bit payload.

00:09:06.730 --> 00:09:10.000 align:middle line:84%
And msfvenom allows you to
specify the target operating

00:09:10.000 --> 00:09:12.260 align:middle line:84%
system architecture when
generating a payload.

00:09:12.260 --> 00:09:15.580 align:middle line:84%
So now, let's explore or
understand the difference

00:09:15.580 --> 00:09:19.180 align:middle line:84%
between a staged payload
and a non-staged payload

00:09:19.180 --> 00:09:22.300 align:middle line:84%
in the context of how they
differ in terms of their name

00:09:22.300 --> 00:09:24.640 align:middle line:84%
because, again, when
generating a payload,

00:09:24.640 --> 00:09:27.310 align:middle line:84%
you need to specify the
exact type of payload

00:09:27.310 --> 00:09:28.640 align:middle line:90%
that you want to generate.

00:09:28.640 --> 00:09:31.220 align:middle line:84%
So if we take a look at
a quick example here.

00:09:31.220 --> 00:09:33.220 align:middle line:84%
I'm just going to scroll
down a little bit here,

00:09:33.220 --> 00:09:36.310 align:middle line:84%
and hopefully, I can find an
example that will actually work

00:09:36.310 --> 00:09:38.860 align:middle line:90%
or that will make sense.

00:09:38.860 --> 00:09:40.910 align:middle line:84%
So let's take a look
at this one here.

00:09:40.910 --> 00:09:44.060 align:middle line:84%
So, as you can see, this
is a meterpreter payload.

00:09:44.060 --> 00:09:46.580 align:middle line:84%
So let's start off with the
target operating system.

00:09:46.580 --> 00:09:48.460 align:middle line:84%
So whenever you're
specifying a payload,

00:09:48.460 --> 00:09:52.000 align:middle line:84%
you start off by specifying the
operating system with which,

00:09:52.000 --> 00:09:53.050 align:middle line:90%
in this case, is Windows.

00:09:53.050 --> 00:09:55.750 align:middle line:84%
Now, Linux also has its
own meterpreter payloads,

00:09:55.750 --> 00:09:57.410 align:middle line:84%
and I'll get to
them in a second.

00:09:57.410 --> 00:10:01.300 align:middle line:84%
And then you specify the target
operating system architecture

00:10:01.300 --> 00:10:06.610 align:middle line:84%
or the actual architecture,
or rather the type of payload

00:10:06.610 --> 00:10:09.460 align:middle line:84%
you're trying to generate in
regards to the target operating

00:10:09.460 --> 00:10:10.730 align:middle line:90%
system architecture.

00:10:10.730 --> 00:10:13.120 align:middle line:84%
So if I generate
a 64-bit payload,

00:10:13.120 --> 00:10:16.820 align:middle line:84%
I cannot run the payload on
my 32-bit operating system.

00:10:16.820 --> 00:10:19.420 align:middle line:84%
So you need to be very
cognizant of that.

00:10:19.420 --> 00:10:21.970 align:middle line:84%
And then, after that, we
specify the payload type.

00:10:21.970 --> 00:10:25.300 align:middle line:84%
In this case, as you can see,
this is a meterpreter payload.

00:10:25.300 --> 00:10:27.910 align:middle line:84%
And then, after this,
you specify the protocol

00:10:27.910 --> 00:10:31.450 align:middle line:84%
that you want to use to actually
connect back to the attacker

00:10:31.450 --> 00:10:32.510 align:middle line:90%
operating system.

00:10:32.510 --> 00:10:35.620 align:middle line:84%
So this will, again,
depend on your own use

00:10:35.620 --> 00:10:37.990 align:middle line:84%
case and the target
environment that you

00:10:37.990 --> 00:10:40.100 align:middle line:84%
are going to be deploying
your payloads on.

00:10:40.100 --> 00:10:42.910 align:middle line:84%
So a good example
of this is whenever

00:10:42.910 --> 00:10:46.090 align:middle line:84%
you're trying to, again,
utilize the reverse HTTP

00:10:46.090 --> 00:10:48.022 align:middle line:90%
or HTTPS payload.

00:10:48.022 --> 00:10:49.480 align:middle line:84%
This is very good
if you are trying

00:10:49.480 --> 00:10:52.300 align:middle line:84%
to mask the connection as
legitimate because, remember,

00:10:52.300 --> 00:10:54.400 align:middle line:84%
this is a reverse
connection, which means,

00:10:54.400 --> 00:10:59.350 align:middle line:84%
once this payload is executed
on the target system,

00:10:59.350 --> 00:11:01.850 align:middle line:84%
it will connect back
to the attacker system.

00:11:01.850 --> 00:11:06.700 align:middle line:84%
And in this case, it will go
through an HTTP or an HTTPS

00:11:06.700 --> 00:11:08.830 align:middle line:84%
port, which, again,
will help mask

00:11:08.830 --> 00:11:13.480 align:middle line:84%
the activity as a connection
to another port on an attacker

00:11:13.480 --> 00:11:15.940 align:middle line:84%
system will be
extremely suspicious.

00:11:15.940 --> 00:11:18.920 align:middle line:84%
So that's, again, in
the context of TCP.

00:11:18.920 --> 00:11:21.580 align:middle line:84%
So, again, the type of
protocol we will use

00:11:21.580 --> 00:11:24.700 align:middle line:84%
will depend on what
your requirements are.

00:11:24.700 --> 00:11:27.550 align:middle line:90%
Now, this is a staged payload.

00:11:27.550 --> 00:11:29.320 align:middle line:84%
And the way you can
tell the difference

00:11:29.320 --> 00:11:32.050 align:middle line:84%
is because you're
specifying meterpreter,

00:11:32.050 --> 00:11:33.640 align:middle line:84%
and then there's
a forward slash,

00:11:33.640 --> 00:11:36.470 align:middle line:84%
and then you specify the
protocol that you want to use.

00:11:36.470 --> 00:11:39.980 align:middle line:84%
Now, an example of a
non-staged payload is one here.

00:11:39.980 --> 00:11:43.060 align:middle line:84%
As you can see, this is where
you specify the operating

00:11:43.060 --> 00:11:43.670 align:middle line:90%
system--

00:11:43.670 --> 00:11:46.300 align:middle line:84%
the operating system
architecture, and then

00:11:46.300 --> 00:11:47.680 align:middle line:90%
you specify meterpreter.

00:11:47.680 --> 00:11:49.870 align:middle line:84%
However, instead of there
being a forward slash,

00:11:49.870 --> 00:11:54.740 align:middle line:84%
you can see that it says
right over here _reverse HTTP.

00:11:54.740 --> 00:11:58.340 align:middle line:84%
So this is, as you can
see, a non-staged payload.

00:11:58.340 --> 00:12:01.030 align:middle line:84%
And this over here
is a staged payload,

00:12:01.030 --> 00:12:05.560 align:middle line:84%
and it gives you an example of
what this payload is used for.

00:12:05.560 --> 00:12:08.860 align:middle line:84%
So you can see it says this will
inject the meterpreter server

00:12:08.860 --> 00:12:11.350 align:middle line:84%
DLL via Reflective
DLL Injection,

00:12:11.350 --> 00:12:12.970 align:middle line:90%
and this is staged, of course.

00:12:12.970 --> 00:12:14.978 align:middle line:90%
And this will require Windows.

00:12:14.978 --> 00:12:15.520 align:middle line:90%
There we are.

00:12:15.520 --> 00:12:19.480 align:middle line:84%
Windows XP service
pack 2 or newer.

00:12:19.480 --> 00:12:21.280 align:middle line:84%
So it'll give you
an idea of what

00:12:21.280 --> 00:12:23.260 align:middle line:84%
target operating systems
this will work on

00:12:23.260 --> 00:12:24.730 align:middle line:90%
in the context of Windows.

00:12:24.730 --> 00:12:28.540 align:middle line:84%
And this will tunnel the
communication over HTTP.

00:12:28.540 --> 00:12:31.840 align:middle line:84%
Now, in the case of TCP, and
I'll just, again, explain this

00:12:31.840 --> 00:12:34.240 align:middle line:84%
really quickly, you can
see it will connect back

00:12:34.240 --> 00:12:37.030 align:middle line:84%
to the attacker based on
whatever port we specify.

00:12:37.030 --> 00:12:39.190 align:middle line:84%
Now, we also have
Linux payloads,

00:12:39.190 --> 00:12:42.460 align:middle line:84%
and they look exactly the
same, except, of course,

00:12:42.460 --> 00:12:44.990 align:middle line:84%
the operating system is
specified differently.

00:12:44.990 --> 00:12:47.650 align:middle line:84%
So let me see if I can
find one through the list

00:12:47.650 --> 00:12:49.658 align:middle line:90%
here as that is quite important.

00:12:49.658 --> 00:12:50.200 align:middle line:90%
There we are.

00:12:50.200 --> 00:12:52.780 align:middle line:84%
So we have the
Linux payloads here,

00:12:52.780 --> 00:12:55.580 align:middle line:84%
and this is the 32-bit
meterpreter payload.

00:12:55.580 --> 00:12:58.180 align:middle line:84%
This is a staged payload,
as you can see here.

00:12:58.180 --> 00:13:02.610 align:middle line:84%
And then, of course, you have
your non-staged payloads.

00:13:02.610 --> 00:13:06.000 align:middle line:90%
Hopefully, I can find them here.

00:13:06.000 --> 00:13:07.553 align:middle line:90%
Your non-staged Linux payload.

00:13:07.553 --> 00:13:08.220 align:middle line:90%
So there we are.

00:13:08.220 --> 00:13:10.770 align:middle line:84%
You can see Linux
x64 meterpreter

00:13:10.770 --> 00:13:13.020 align:middle line:84%
that's a staged
payload, and then this

00:13:13.020 --> 00:13:14.250 align:middle line:90%
is the non-staged payload.

00:13:14.250 --> 00:13:16.330 align:middle line:90%
So they look very, very similar.

00:13:16.330 --> 00:13:19.590 align:middle line:84%
So let's get started, and
we'll explore a little bit

00:13:19.590 --> 00:13:20.820 align:middle line:90%
of the functionality.

00:13:20.820 --> 00:13:22.980 align:middle line:84%
So whenever you're trying
to generate a payload

00:13:22.980 --> 00:13:25.770 align:middle line:84%
with msfvenom, you
type in msfvenom,

00:13:25.770 --> 00:13:28.080 align:middle line:84%
and then you specify
the target architecture.

00:13:28.080 --> 00:13:31.200 align:middle line:84%
This is not always required,
but it is quite useful.

00:13:31.200 --> 00:13:34.050 align:middle line:84%
So if I want to generate
a 32-bit payload,

00:13:34.050 --> 00:13:36.690 align:middle line:90%
I can type in x86.

00:13:36.690 --> 00:13:39.360 align:middle line:84%
And then, after this, I
specify the actual payload

00:13:39.360 --> 00:13:40.710 align:middle line:90%
using a hyphen P.

00:13:40.710 --> 00:13:43.150 align:middle line:84%
So if I want to generate
a Windows payload,

00:13:43.150 --> 00:13:46.830 align:middle line:84%
let's start off with Windows,
I can say, again, Windows,

00:13:46.830 --> 00:13:49.380 align:middle line:84%
and then I can specify
the target architecture.

00:13:49.380 --> 00:13:51.750 align:middle line:84%
But in this case,
it's a 32-bit payload.

00:13:51.750 --> 00:13:58.120 align:middle line:84%
So I can say
windows/meterpreter/reverse_tcp

00:13:58.120 --> 00:14:01.780 align:middle line:84%
or HTTP or HTTPS, depending
on your own requirements.

00:14:01.780 --> 00:14:06.010 align:middle line:84%
I can also specify a
non-staged payload if I want.

00:14:06.010 --> 00:14:08.000 align:middle line:84%
So we are specifying
the payload.

00:14:08.000 --> 00:14:11.720 align:middle line:84%
Now, we need to specify
the attacker's information.

00:14:11.720 --> 00:14:14.440 align:middle line:84%
So what IP address will
this payload connect to?

00:14:14.440 --> 00:14:15.940 align:middle line:84%
So, in order to do
that, we're going

00:14:15.940 --> 00:14:18.310 align:middle line:84%
to say LHOST is
equal to-- and this

00:14:18.310 --> 00:14:22.300 align:middle line:84%
is where you specify your Kali
Linux VM IP or your Kali Linux

00:14:22.300 --> 00:14:22.840 align:middle line:90%
IP.

00:14:22.840 --> 00:14:25.390 align:middle line:84%
And in my case,
that is 10.10.10.5.

00:14:25.390 --> 00:14:30.370 align:middle line:84%
And in the case of TCP, we
can specify the actual port

00:14:30.370 --> 00:14:32.560 align:middle line:84%
to connect back to,
or rather the port

00:14:32.560 --> 00:14:34.150 align:middle line:84%
that the payload
will connect back to.

00:14:34.150 --> 00:14:36.910 align:middle line:84%
And in this case, I'm just
going to say 1234 just

00:14:36.910 --> 00:14:38.380 align:middle line:90%
to keep things simple.

00:14:38.380 --> 00:14:41.450 align:middle line:84%
Now, this is where the
important part comes into play,

00:14:41.450 --> 00:14:43.000 align:middle line:90%
and that is the output format.

00:14:43.000 --> 00:14:46.840 align:middle line:84%
So we can generate this
payload or essentially output,

00:14:46.840 --> 00:14:50.570 align:middle line:84%
or generate this payload and
output it into an exe file

00:14:50.570 --> 00:14:53.920 align:middle line:84%
so that it can directly be
executed on the target system.

00:14:53.920 --> 00:14:57.100 align:middle line:84%
In order to do this, we
specify the format option,

00:14:57.100 --> 00:14:58.750 align:middle line:90%
and then we say exe.

00:14:58.750 --> 00:15:01.750 align:middle line:84%
And then we can output it
and say we want to output

00:15:01.750 --> 00:15:03.800 align:middle line:90%
it onto my desktop.

00:15:03.800 --> 00:15:05.950 align:middle line:84%
So I'm going to say
home/kali/Desktop.

00:15:05.950 --> 00:15:09.160 align:middle line:84%
And in your case, you can change
the actual storage directory.

00:15:09.160 --> 00:15:10.960 align:middle line:84%
And I'm going to
store it into a folder

00:15:10.960 --> 00:15:13.150 align:middle line:84%
that I created called
Windows Payloads.

00:15:13.150 --> 00:15:15.320 align:middle line:84%
And then I need to
provide it with a name.

00:15:15.320 --> 00:15:16.970 align:middle line:84%
So I'm going to
call this payload--

00:15:16.970 --> 00:15:20.470 align:middle line:84%
I'm just going to
say payloadx86.exe.

00:15:20.470 --> 00:15:24.200 align:middle line:84%
It's very important that you
specify the extension here.

00:15:24.200 --> 00:15:26.730 align:middle line:90%
So I'm going to hit Enter.

00:15:26.730 --> 00:15:27.885 align:middle line:90%
Give that a few seconds.

00:15:27.885 --> 00:15:34.270 align:middle line:90%


00:15:34.270 --> 00:15:37.720 align:middle line:84%
As you can see, it's going to
say no platform was selected,

00:15:37.720 --> 00:15:39.500 align:middle line:90%
so we can specify the platform.

00:15:39.500 --> 00:15:42.670 align:middle line:84%
But in this case, because we
are highlighting the payload

00:15:42.670 --> 00:15:45.880 align:middle line:84%
that we want to use, which is a
Windows meterpreter reverse TCP

00:15:45.880 --> 00:15:47.590 align:middle line:90%
payload, it's going to say--

00:15:47.590 --> 00:15:50.470 align:middle line:84%
it's going to utilize
the platform specified

00:15:50.470 --> 00:15:51.610 align:middle line:90%
from the payload.

00:15:51.610 --> 00:15:54.040 align:middle line:84%
It's then going to say
no encoder specified

00:15:54.040 --> 00:15:55.870 align:middle line:90%
outputting the raw payload.

00:15:55.870 --> 00:16:00.280 align:middle line:84%
The payload size is 354
bytes, and the final size

00:16:00.280 --> 00:16:05.570 align:middle line:84%
of the portable executable
is 73,802 bytes.

00:16:05.570 --> 00:16:07.630 align:middle line:84%
So if I head over
onto my desktop

00:16:07.630 --> 00:16:09.880 align:middle line:84%
and under Windows
Payloads, you can

00:16:09.880 --> 00:16:13.330 align:middle line:84%
see that it generated
the payloadx86.exe.

00:16:13.330 --> 00:16:16.390 align:middle line:84%
So you can now transfer this
over to the target system,

00:16:16.390 --> 00:16:19.960 align:middle line:84%
or you can essentially set
this up in a social engineering

00:16:19.960 --> 00:16:24.310 align:middle line:84%
campaign and somehow get the
target employee or the person

00:16:24.310 --> 00:16:26.290 align:middle line:84%
you're targeting to
download it and then

00:16:26.290 --> 00:16:28.040 align:middle line:90%
execute it on this system.

00:16:28.040 --> 00:16:31.450 align:middle line:84%
However, before they execute it,
you need to set up a handler.

00:16:31.450 --> 00:16:34.840 align:middle line:84%
And before we actually get
into how to set up a handler,

00:16:34.840 --> 00:16:36.520 align:middle line:84%
let's take a look
at how to generate

00:16:36.520 --> 00:16:38.740 align:middle line:84%
another type of payload
or rather changing

00:16:38.740 --> 00:16:42.440 align:middle line:84%
the actual architecture of the
payload that we're generating.

00:16:42.440 --> 00:16:45.610 align:middle line:84%
So to generate a 64-bit
meterpreter payload,

00:16:45.610 --> 00:16:48.340 align:middle line:84%
I'm just going to head over
here into the previous command.

00:16:48.340 --> 00:16:51.400 align:middle line:84%
And we're going to change
the architecture to x64.

00:16:51.400 --> 00:16:53.980 align:middle line:84%
And then, as well
as in the payload,

00:16:53.980 --> 00:16:57.820 align:middle line:84%
we are also going to say this
is an x64 meterpreter payload.

00:16:57.820 --> 00:17:01.030 align:middle line:84%
We're going to leave the LHOST
and the LPORT options the same,

00:17:01.030 --> 00:17:04.180 align:middle line:84%
and we're going to output
it into the exe format

00:17:04.180 --> 00:17:07.420 align:middle line:90%
and save it as payloadx64.exe.

00:17:07.420 --> 00:17:10.480 align:middle line:84%
So it's really that simple
in regards to, again,

00:17:10.480 --> 00:17:12.589 align:middle line:90%
changing the architecture.

00:17:12.589 --> 00:17:14.140 align:middle line:90%
So I'm going to hit Enter.

00:17:14.140 --> 00:17:17.859 align:middle line:84%
That is, again, going
to take a few seconds.

00:17:17.859 --> 00:17:19.800 align:middle line:84%
All right, as you
can see, that again

00:17:19.800 --> 00:17:22.650 align:middle line:84%
generates a 64-bit
meterpreter payload,

00:17:22.650 --> 00:17:25.720 align:middle line:84%
and it outputs it into the
file name that we specified.

00:17:25.720 --> 00:17:27.390 align:middle line:84%
So, again, it gets
the actual platform

00:17:27.390 --> 00:17:31.530 align:middle line:84%
from the actual module or the
payload that we specified.

00:17:31.530 --> 00:17:37.450 align:middle line:84%
And then it says the final size
is 671 or rather 7,168 bytes.

00:17:37.450 --> 00:17:40.310 align:middle line:84%
So if we list out the contents
of the Windows payloads

00:17:40.310 --> 00:17:44.940 align:middle line:84%
directory, you can see that we
have the payloadx64.exe, which

00:17:44.940 --> 00:17:49.230 align:middle line:84%
is suitable for 64-bit
versions of Windows.

00:17:49.230 --> 00:17:51.870 align:middle line:84%
And the 32-bit
payload here can be

00:17:51.870 --> 00:17:54.690 align:middle line:84%
executed on both 32-bit
versions of Windows

00:17:54.690 --> 00:17:57.120 align:middle line:84%
as well as 64-bit
versions of Windows.

00:17:57.120 --> 00:17:59.160 align:middle line:84%
So it's entirely up
to you in regards

00:17:59.160 --> 00:18:02.850 align:middle line:84%
to what to actually
what type of payload

00:18:02.850 --> 00:18:06.090 align:middle line:84%
you want to generate in terms
of the architecture here.

00:18:06.090 --> 00:18:08.700 align:middle line:84%
Now, I've talked about
the output format,

00:18:08.700 --> 00:18:11.160 align:middle line:84%
but I didn't take you through
all of the output formats

00:18:11.160 --> 00:18:11.700 align:middle line:90%
available.

00:18:11.700 --> 00:18:13.380 align:middle line:84%
You can list out
the output formats

00:18:13.380 --> 00:18:16.230 align:middle line:90%
available by typing in msfvenom.

00:18:16.230 --> 00:18:22.010 align:middle line:84%
And then, if I say
list and say formats,

00:18:22.010 --> 00:18:24.230 align:middle line:84%
that will provide you
with a list of formats

00:18:24.230 --> 00:18:26.810 align:middle line:84%
that you can output
your payloads into,

00:18:26.810 --> 00:18:29.270 align:middle line:84%
and we'll give this
a few seconds here

00:18:29.270 --> 00:18:30.830 align:middle line:90%
because there are quite a few.

00:18:30.830 --> 00:18:34.260 align:middle line:84%
And they are sorted based
on executable format.

00:18:34.260 --> 00:18:36.950 align:middle line:84%
So these are the formats that
can be directly executed,

00:18:36.950 --> 00:18:41.060 align:middle line:84%
and they are sorted based on
the target operating system

00:18:41.060 --> 00:18:43.100 align:middle line:90%
and/or platform.

00:18:43.100 --> 00:18:45.020 align:middle line:84%
And in the bottom here,
you have the framework

00:18:45.020 --> 00:18:46.610 align:middle line:84%
transform formats,
which allow you

00:18:46.610 --> 00:18:51.710 align:middle line:84%
to output the payloads into
either a Python file, a Ruby

00:18:51.710 --> 00:18:54.860 align:middle line:84%
file that can then be
modified later, or even a hex

00:18:54.860 --> 00:18:56.070 align:middle line:90%
file if you want.

00:18:56.070 --> 00:18:59.830 align:middle line:84%
So you can output your payloads
into any of these other formats

00:18:59.830 --> 00:19:00.330 align:middle line:90%
here.

00:19:00.330 --> 00:19:03.180 align:middle line:84%
However, if you want
an executable file,

00:19:03.180 --> 00:19:05.490 align:middle line:84%
so you can output
it into an Asp file,

00:19:05.490 --> 00:19:09.680 align:middle line:84%
ASPX, ASPX-EXE, DLL
file for Windows.

00:19:09.680 --> 00:19:12.050 align:middle line:84%
So if you are trying to
generate a malicious DLL file,

00:19:12.050 --> 00:19:13.010 align:middle line:90%
you can do that.

00:19:13.010 --> 00:19:16.850 align:middle line:84%
If you're trying to generate
a malicious Linux binary,

00:19:16.850 --> 00:19:18.530 align:middle line:90%
you can use the ELF option.

00:19:18.530 --> 00:19:22.460 align:middle line:84%
If you are trying to generate
a malicious Linux shared object

00:19:22.460 --> 00:19:25.460 align:middle line:84%
file, you can use the
Elf shared object option.

00:19:25.460 --> 00:19:27.860 align:middle line:84%
If you are trying to generate
a Windows executable,

00:19:27.860 --> 00:19:32.250 align:middle line:84%
you can say exe or exe-only,
exe-service, exe-small, et

00:19:32.250 --> 00:19:33.182 align:middle line:90%
cetera, et cetera.

00:19:33.182 --> 00:19:35.390 align:middle line:84%
And then, of course, you
have your other options here

00:19:35.390 --> 00:19:37.670 align:middle line:90%
for Java or Java web servers.

00:19:37.670 --> 00:19:40.410 align:middle line:84%
So you have your
JAR file, JSP file.

00:19:40.410 --> 00:19:43.460 align:middle line:84%
You can also generate
MSI files for Windows

00:19:43.460 --> 00:19:48.650 align:middle line:84%
as well as OSX or Mac OSX
app files for execution

00:19:48.650 --> 00:19:50.550 align:middle line:90%
on MacOS targets.

00:19:50.550 --> 00:19:52.730 align:middle line:84%
And you have various
other output formats

00:19:52.730 --> 00:19:53.970 align:middle line:90%
that are executable.

00:19:53.970 --> 00:19:55.850 align:middle line:84%
So now that we've
explored that, let's

00:19:55.850 --> 00:19:57.980 align:middle line:84%
try and take a look
at how to generate

00:19:57.980 --> 00:20:00.380 align:middle line:90%
Linux payloads with msfvenom.

00:20:00.380 --> 00:20:02.640 align:middle line:84%
And the process is,
again, exactly the same.

00:20:02.640 --> 00:20:05.870 align:middle line:84%
The only thing we're changing
is the target operating system,

00:20:05.870 --> 00:20:09.595 align:middle line:84%
and of course, the actual
meterpreter payload.

00:20:09.595 --> 00:20:10.970 align:middle line:84%
So, again, what
we're going to do

00:20:10.970 --> 00:20:12.680 align:middle line:84%
is I'm just going
to take a step back,

00:20:12.680 --> 00:20:16.820 align:middle line:84%
and I've also created a
folder on my desktop called

00:20:16.820 --> 00:20:17.750 align:middle line:90%
Linux Payloads.

00:20:17.750 --> 00:20:20.600 align:middle line:84%
That's where I'm going to be
storing the Linux payload.

00:20:20.600 --> 00:20:23.630 align:middle line:84%
So whenever you are
generating a Linux payload,

00:20:23.630 --> 00:20:25.190 align:middle line:84%
you have the
ability to output it

00:20:25.190 --> 00:20:28.370 align:middle line:84%
into a binary file or an
ELF file, which can both be

00:20:28.370 --> 00:20:30.420 align:middle line:90%
executed again immediately.

00:20:30.420 --> 00:20:33.110 align:middle line:84%
So, in order to generate
a Linux payload,

00:20:33.110 --> 00:20:35.180 align:middle line:84%
we're going to say
msfvenom, and then you

00:20:35.180 --> 00:20:37.170 align:middle line:84%
can specify the
architecture if you want.

00:20:37.170 --> 00:20:39.080 align:middle line:84%
Although, that's not
required because you're

00:20:39.080 --> 00:20:40.760 align:middle line:84%
going to be specifying
the architecture

00:20:40.760 --> 00:20:42.680 align:middle line:90%
within the actual payload type.

00:20:42.680 --> 00:20:46.250 align:middle line:84%
So if I'm generating a
32-bit Linux payload,

00:20:46.250 --> 00:20:48.920 align:middle line:90%
I say Linux and then x86.

00:20:48.920 --> 00:20:51.770 align:middle line:84%
And then I specify
the actual type

00:20:51.770 --> 00:20:54.290 align:middle line:84%
of payload, which, in
this case, is meterpreter.

00:20:54.290 --> 00:20:56.558 align:middle line:84%
And then I can
specify the protocol

00:20:56.558 --> 00:20:58.100 align:middle line:84%
to use, which, in
this case, is going

00:20:58.100 --> 00:21:00.260 align:middle line:90%
to be a reverse TCP connection.

00:21:00.260 --> 00:21:01.700 align:middle line:90%
And then the LHOST option.

00:21:01.700 --> 00:21:04.940 align:middle line:84%
This is where you specify the
attacker's IP address or the IP

00:21:04.940 --> 00:21:07.130 align:middle line:84%
that you want the payload
to connect back to.

00:21:07.130 --> 00:21:08.510 align:middle line:90%
So 10.10.10.5.

00:21:08.510 --> 00:21:10.790 align:middle line:84%
This is my Kali
Linux IP, and then

00:21:10.790 --> 00:21:12.740 align:middle line:84%
you specify the port
to connect back to.

00:21:12.740 --> 00:21:14.630 align:middle line:90%
So 1234, in this case.

00:21:14.630 --> 00:21:17.930 align:middle line:84%
And then you specify
the output format as ELF

00:21:17.930 --> 00:21:20.840 align:middle line:84%
because we're outputting this
into an extensible linking

00:21:20.840 --> 00:21:22.160 align:middle line:90%
format for Linux.

00:21:22.160 --> 00:21:23.780 align:middle line:84%
And then, in terms
of the output,

00:21:23.780 --> 00:21:27.920 align:middle line:84%
we're going to save this on my
desktop under Linux Payloads,

00:21:27.920 --> 00:21:29.730 align:middle line:84%
and we can then provide
it with the name.

00:21:29.730 --> 00:21:33.530 align:middle line:84%
So I'm going to say payloadx86,
and you can then provide it

00:21:33.530 --> 00:21:36.230 align:middle line:84%
with the ELF extension, or
you can output it directly

00:21:36.230 --> 00:21:37.070 align:middle line:90%
into a binary.

00:21:37.070 --> 00:21:38.195 align:middle line:90%
So I'm just going to--

00:21:38.195 --> 00:21:41.240 align:middle line:84%
I'm not going to provide any
extension because the binary

00:21:41.240 --> 00:21:43.080 align:middle line:90%
can directly be executed.

00:21:43.080 --> 00:21:44.630 align:middle line:90%
So I'm just going to hit Enter.

00:21:44.630 --> 00:21:48.800 align:middle line:84%
That is going to generate a
staged Linux 32-bit meterpreter

00:21:48.800 --> 00:21:52.220 align:middle line:84%
payload for us, and I will
give that a few seconds.

00:21:52.220 --> 00:21:55.148 align:middle line:90%


00:21:55.148 --> 00:21:55.690 align:middle line:90%
There we are.

00:21:55.690 --> 00:21:58.030 align:middle line:84%
As you can see, it gets
the actual architecture

00:21:58.030 --> 00:22:01.570 align:middle line:84%
from the payload here if we
don't specify it explicitly.

00:22:01.570 --> 00:22:03.940 align:middle line:84%
And it also gets the
platform from the payload.

00:22:03.940 --> 00:22:05.980 align:middle line:84%
So really, the most
important thing

00:22:05.980 --> 00:22:07.540 align:middle line:84%
that you'll need
to specify whenever

00:22:07.540 --> 00:22:11.260 align:middle line:84%
generating a malicious payload
is the actual payload type.

00:22:11.260 --> 00:22:12.820 align:middle line:84%
And within the
payload type, ensure

00:22:12.820 --> 00:22:15.910 align:middle line:84%
that you specify the target
operating system as well

00:22:15.910 --> 00:22:17.650 align:middle line:84%
as the architecture
if that's something

00:22:17.650 --> 00:22:19.690 align:middle line:90%
that is important to you.

00:22:19.690 --> 00:22:24.920 align:middle line:84%
So, as you can see, it outputs
the payload into an ELF file.

00:22:24.920 --> 00:22:27.640 align:middle line:84%
And if we head over into
the Linux payload directory,

00:22:27.640 --> 00:22:29.710 align:middle line:84%
you can see we have the
actual payload here.

00:22:29.710 --> 00:22:31.420 align:middle line:84%
And because we
are running this--

00:22:31.420 --> 00:22:32.770 align:middle line:90%
we are running Kali Linux.

00:22:32.770 --> 00:22:34.910 align:middle line:84%
We can actually
execute this directly.

00:22:34.910 --> 00:22:37.300 align:middle line:84%
So let me provide
the actual binary

00:22:37.300 --> 00:22:39.120 align:middle line:90%
with executable permission.

00:22:39.120 --> 00:22:42.790 align:middle line:84%
So I'm going to say chmod
plus x and then hit Enter.

00:22:42.790 --> 00:22:48.130 align:middle line:84%
And now, I can execute it by
providing the actual execution

00:22:48.130 --> 00:22:50.620 align:middle line:84%
option here within the
command line, which

00:22:50.620 --> 00:22:52.315 align:middle line:84%
is a full stop and
a forward slash.

00:22:52.315 --> 00:22:54.970 align:middle line:84%
And then I can specify
the actual payload here

00:22:54.970 --> 00:22:57.850 align:middle line:84%
and hit Enter, and that
is going to execute it.

00:22:57.850 --> 00:23:00.200 align:middle line:84%
As you can see, it
provides us with no output.

00:23:00.200 --> 00:23:02.050 align:middle line:84%
And the reason
nothing is happening

00:23:02.050 --> 00:23:05.800 align:middle line:84%
is because we haven't set
up a listener or a handler

00:23:05.800 --> 00:23:07.460 align:middle line:84%
to receive the
reverse connection.

00:23:07.460 --> 00:23:10.040 align:middle line:84%
So we'll actually explore
that in a few seconds.

00:23:10.040 --> 00:23:11.870 align:middle line:84%
So I'm just going
to terminate that.

00:23:11.870 --> 00:23:15.190 align:middle line:84%
And in terms of generating
a 64-bit Linux payload,

00:23:15.190 --> 00:23:17.660 align:middle line:84%
the process is, again,
very, very similar.

00:23:17.660 --> 00:23:21.730 align:middle line:84%
So I'm just going to change
the output file to payload x64.

00:23:21.730 --> 00:23:25.400 align:middle line:84%
And then, as for the actual
type of meterpreter module,

00:23:25.400 --> 00:23:30.100 align:middle line:84%
we are then going to change this
into x86-- oh, sorry, into x64,

00:23:30.100 --> 00:23:31.840 align:middle line:84%
and that's pretty
much it in regards

00:23:31.840 --> 00:23:35.440 align:middle line:84%
to changing the target or the
operating system architecture,

00:23:35.440 --> 00:23:37.670 align:middle line:84%
or rather the payload
architecture here.

00:23:37.670 --> 00:23:38.950 align:middle line:90%
So I can just hit Enter.

00:23:38.950 --> 00:23:48.340 align:middle line:90%


00:23:48.340 --> 00:23:50.110 align:middle line:84%
All right, as you can
see, that outputs it

00:23:50.110 --> 00:23:52.575 align:middle line:84%
into an ELF file or a
binary, in this case.

00:23:52.575 --> 00:23:53.950 align:middle line:84%
And if I list it
out, you can see

00:23:53.950 --> 00:23:57.610 align:middle line:84%
we also have payload
x64 right over there.

00:23:57.610 --> 00:23:59.380 align:middle line:84%
So we have generated
our payloads.

00:23:59.380 --> 00:24:01.900 align:middle line:84%
Now, in terms of transferring
them onto the target,

00:24:01.900 --> 00:24:03.970 align:middle line:84%
that is, again, going
to depend on the type

00:24:03.970 --> 00:24:08.170 align:middle line:84%
of social engineering technique
that you will utilize.

00:24:08.170 --> 00:24:10.900 align:middle line:84%
In my case, we are going to,
again, transfer the Windows

00:24:10.900 --> 00:24:14.260 align:middle line:84%
payload first to a
simple Windows 7 system

00:24:14.260 --> 00:24:16.370 align:middle line:84%
that I've set up to
demonstrate this.

00:24:16.370 --> 00:24:19.720 align:middle line:84%
So, in order to transfer
this Windows payloads

00:24:19.720 --> 00:24:22.480 align:middle line:84%
onto the actual target
Windows 7 system,

00:24:22.480 --> 00:24:25.540 align:middle line:84%
I'm going to navigate into the
Windows payloads directory,

00:24:25.540 --> 00:24:29.680 align:middle line:84%
and I'm going to set up a simple
web server within this folder

00:24:29.680 --> 00:24:31.840 align:middle line:84%
to serve these
two payload files.

00:24:31.840 --> 00:24:34.370 align:middle line:84%
And then I'll head over
onto my Windows 7 system

00:24:34.370 --> 00:24:37.480 align:middle line:84%
and then download the payloads
from the Kali Linux web server

00:24:37.480 --> 00:24:38.300 align:middle line:90%
that I'll set up.

00:24:38.300 --> 00:24:41.440 align:middle line:84%
So, in order to set up a simple
web server to host these files,

00:24:41.440 --> 00:24:43.870 align:middle line:90%
I'm going to say sudo python m.

00:24:43.870 --> 00:24:48.130 align:middle line:84%
So we're using a Python module
called SimpleHTTPServer,

00:24:48.130 --> 00:24:50.300 align:middle line:90%
and I'll host this on port 80.

00:24:50.300 --> 00:24:54.010 align:middle line:84%
So, once I hit Enter, I
will be able to access

00:24:54.010 --> 00:24:57.620 align:middle line:84%
all of these files on the
Kali Linux IP on port 80.

00:24:57.620 --> 00:25:00.220 align:middle line:84%
So, as you can see, it's
going to serve an HTTP web

00:25:00.220 --> 00:25:04.330 align:middle line:84%
server on the Kali
Linux IP on port 80.

00:25:04.330 --> 00:25:06.790 align:middle line:84%
However, we also need
to set up the handler

00:25:06.790 --> 00:25:08.920 align:middle line:84%
to receive the reverse
connection back

00:25:08.920 --> 00:25:10.750 align:middle line:90%
from the target system.

00:25:10.750 --> 00:25:13.460 align:middle line:84%
Now, this can be facilitated
within the Metasploit Framework

00:25:13.460 --> 00:25:13.960 align:middle line:90%
console.

00:25:13.960 --> 00:25:18.300 align:middle line:84%
So I'll open up a new tab here,
and I'll open up the Metasploit

00:25:18.300 --> 00:25:19.300 align:middle line:90%
Framework console there.

00:25:19.300 --> 00:25:23.710 align:middle line:84%
So I'll type in msfconsole
and give that a few seconds.

00:25:23.710 --> 00:25:26.260 align:middle line:84%
Now, the reason we're
utilizing the Metasploit

00:25:26.260 --> 00:25:29.230 align:middle line:84%
exploit/multi/handler
is because whenever

00:25:29.230 --> 00:25:32.110 align:middle line:84%
we're dealing with payloads that
are advanced like a meterpreter

00:25:32.110 --> 00:25:34.990 align:middle line:84%
payload, we need an
appropriate listener

00:25:34.990 --> 00:25:38.320 align:middle line:84%
to actually handle the reverse
connection or the connection

00:25:38.320 --> 00:25:40.640 align:middle line:84%
that we receive from
the target system.

00:25:40.640 --> 00:25:42.520 align:middle line:84%
So, in order to use
the multi/handler,

00:25:42.520 --> 00:25:45.910 align:middle line:84%
we're going to just say
use and then multi/handler.

00:25:45.910 --> 00:25:48.160 align:middle line:84%
And once we specify
the multi/handlers,

00:25:48.160 --> 00:25:50.800 align:middle line:84%
you can see it's going to say
using the configured payload.

00:25:50.800 --> 00:25:52.660 align:middle line:84%
We need to change
that because we

00:25:52.660 --> 00:25:55.883 align:middle line:84%
need to set up a listener
for the meterpreter payload.

00:25:55.883 --> 00:25:57.550 align:middle line:84%
And in this case, the
payload that we're

00:25:57.550 --> 00:25:59.590 align:middle line:84%
going to be using
first, or that we're

00:25:59.590 --> 00:26:02.140 align:middle line:84%
going to be awaiting
connection back from,

00:26:02.140 --> 00:26:06.080 align:middle line:84%
is the Windows x86
payload that we generated.

00:26:06.080 --> 00:26:08.020 align:middle line:84%
So this is where
you would specify

00:26:08.020 --> 00:26:10.990 align:middle line:84%
the actual payload option
that you had used to generate

00:26:10.990 --> 00:26:12.970 align:middle line:90%
your payload with msfvenom.

00:26:12.970 --> 00:26:16.600 align:middle line:84%
So if you are trying to wait
for a connection back from

00:26:16.600 --> 00:26:18.970 align:middle line:84%
a payload that you
generated, and in this case,

00:26:18.970 --> 00:26:25.550 align:middle line:84%
a Windows x86 payload, I
would say Windows and then

00:26:25.550 --> 00:26:29.648 align:middle line:90%
meterpreter/reverse_tcp.

00:26:29.648 --> 00:26:31.940 align:middle line:84%
And now, as you can see, it's
going to set the payload.

00:26:31.940 --> 00:26:34.060 align:middle line:84%
If I show the options
now, I now need

00:26:34.060 --> 00:26:37.360 align:middle line:84%
to set the LHOST option
or the IP address

00:26:37.360 --> 00:26:41.170 align:middle line:84%
that we configured to-- we
configured our msfvenom payload

00:26:41.170 --> 00:26:42.250 align:middle line:90%
to connect back to.

00:26:42.250 --> 00:26:46.030 align:middle line:84%
So we'll say set
LHOST to 10.10.10.5.

00:26:46.030 --> 00:26:48.520 align:middle line:84%
And then set the
LPORT that we had also

00:26:48.520 --> 00:26:50.650 align:middle line:84%
configured with
msfvenom when generating

00:26:50.650 --> 00:26:53.380 align:middle line:84%
our Windows payload,
which was 1234,

00:26:53.380 --> 00:26:55.040 align:middle line:90%
in the case of all of them.

00:26:55.040 --> 00:26:57.820 align:middle line:84%
And then, once we are
ready, we just hit Run.

00:26:57.820 --> 00:27:00.040 align:middle line:84%
So now, as you can
see, it's going

00:27:00.040 --> 00:27:04.090 align:middle line:84%
to say started the reverse TCP
handler on our Kali Linux IP

00:27:04.090 --> 00:27:05.410 align:middle line:90%
on port 1234.

00:27:05.410 --> 00:27:08.410 align:middle line:84%
So now, it's listening for
a connection from the target

00:27:08.410 --> 00:27:11.120 align:middle line:84%
system whenever the
payload is executed.

00:27:11.120 --> 00:27:13.640 align:middle line:84%
So we can now head over
to the Windows system.

00:27:13.640 --> 00:27:17.200 align:middle line:84%
So I'm just going to switch
over to the Windows 7 system.

00:27:17.200 --> 00:27:19.490 align:middle line:84%
So I'm back on the
Windows 7 system,

00:27:19.490 --> 00:27:22.300 align:middle line:84%
and I've navigated to the
directory of the web server

00:27:22.300 --> 00:27:25.250 align:middle line:84%
that we hosted, which is on
the Kali Linux IP address,

00:27:25.250 --> 00:27:27.010 align:middle line:90%
which is 10.10.10.5.

00:27:27.010 --> 00:27:28.430 align:middle line:84%
And I have the
two payloads here.

00:27:28.430 --> 00:27:31.570 align:middle line:84%
So I'll download payload
x86 because we set up

00:27:31.570 --> 00:27:35.200 align:middle line:84%
the multi/handler for that
particular payload type.

00:27:35.200 --> 00:27:37.570 align:middle line:84%
So I'm going to click
on it and hit save.

00:27:37.570 --> 00:27:40.900 align:middle line:84%
And I'm going to save it within
the Downloads directory here.

00:27:40.900 --> 00:27:42.092 align:middle line:90%
And there we are.

00:27:42.092 --> 00:27:44.300 align:middle line:84%
As you can see, it's going
to say download completed.

00:27:44.300 --> 00:27:46.750 align:middle line:84%
And if we navigate to the
Downloads directory now,

00:27:46.750 --> 00:27:48.188 align:middle line:90%
we can execute it.

00:27:48.188 --> 00:27:48.730 align:middle line:90%
There we are.

00:27:48.730 --> 00:27:49.480 align:middle line:90%
Run.

00:27:49.480 --> 00:27:52.540 align:middle line:84%
And that's going to execute and
not provide us with any output,

00:27:52.540 --> 00:27:56.330 align:middle line:84%
and we should receive a reverse
connection on our handler now.

00:27:56.330 --> 00:27:58.780 align:middle line:84%
So I'm going to
switch back to Kali.

00:27:58.780 --> 00:28:00.130 align:middle line:90%
So I'm back on Kali.

00:28:00.130 --> 00:28:03.670 align:middle line:84%
And as you can see, I received
a reverse or a meterpreter

00:28:03.670 --> 00:28:05.950 align:middle line:90%
session from the target system.

00:28:05.950 --> 00:28:08.290 align:middle line:84%
As you can see, meterpreter
session one opened,

00:28:08.290 --> 00:28:11.710 align:middle line:84%
and we got a connection back
from the target Windows 7

00:28:11.710 --> 00:28:15.010 align:middle line:84%
system, which has
the IP 10.10.10.7,

00:28:15.010 --> 00:28:17.680 align:middle line:84%
and it connects
back to port 1234.

00:28:17.680 --> 00:28:20.210 align:middle line:84%
And we now have access
on the target system,

00:28:20.210 --> 00:28:22.750 align:middle line:84%
and this is what a
client-side attack looks like.

00:28:22.750 --> 00:28:25.090 align:middle line:84%
Now, again, we haven't
explored the process

00:28:25.090 --> 00:28:28.690 align:middle line:84%
of antivirus evasion
and, more specifically,

00:28:28.690 --> 00:28:29.950 align:middle line:90%
encoding our payloads.

00:28:29.950 --> 00:28:32.170 align:middle line:84%
We're going to be exploring
that in the next video.

00:28:32.170 --> 00:28:35.290 align:middle line:84%
And again, you can repeat this
process for the Linux payload

00:28:35.290 --> 00:28:36.110 align:middle line:90%
as well.

00:28:36.110 --> 00:28:39.520 align:middle line:84%
So, again, if I try and get a
reverse connection on the Kali

00:28:39.520 --> 00:28:42.490 align:middle line:84%
Linux system, which is kind
of funny because, again,

00:28:42.490 --> 00:28:44.380 align:middle line:84%
I already have
access to the system,

00:28:44.380 --> 00:28:47.890 align:middle line:84%
but I can terminate my
session by hitting--

00:28:47.890 --> 00:28:51.160 align:middle line:84%
by essentially, saying
Control+ C and/or exit.

00:28:51.160 --> 00:28:52.240 align:middle line:90%
So I just hit Exit.

00:28:52.240 --> 00:28:54.580 align:middle line:84%
That is going to shut
down that session.

00:28:54.580 --> 00:28:57.190 align:middle line:84%
And because we're still
utilizing the multi/handler,

00:28:57.190 --> 00:29:02.725 align:middle line:84%
I can set the payload to
Linux/x86/meterpreter/reverse

00:29:02.725 --> 00:29:13.580 align:middle line:90%
tcp, and then just hit Run.

00:29:13.580 --> 00:29:16.130 align:middle line:84%
And then I can execute
the Linux payload just

00:29:16.130 --> 00:29:19.730 align:middle line:84%
to show you that it does work,
there we are, Linux payloads,

00:29:19.730 --> 00:29:22.190 align:middle line:90%
and I can execute payload x86.

00:29:22.190 --> 00:29:23.330 align:middle line:90%
Hit Enter.

00:29:23.330 --> 00:29:25.830 align:middle line:84%
And as you can see, we
get a meterpreter session.

00:29:25.830 --> 00:29:28.820 align:middle line:84%
So, again, that's how to
generate payloads with msfvenom

00:29:28.820 --> 00:29:31.050 align:middle line:90%
for both Linux and Windows.

00:29:31.050 --> 00:29:34.460 align:middle line:84%
And now, in the context, or in
the case of transferring them

00:29:34.460 --> 00:29:36.470 align:middle line:84%
onto the target system,
that's something

00:29:36.470 --> 00:29:38.630 align:middle line:84%
that we can probably
explore in another course--

00:29:38.630 --> 00:29:40.530 align:middle line:90%
in a social engineering course.

00:29:40.530 --> 00:29:41.990 align:middle line:84%
However, in the
next video, we'll

00:29:41.990 --> 00:29:44.660 align:middle line:84%
be exploring the process
of encoding these payloads

00:29:44.660 --> 00:29:46.700 align:middle line:90%
to avoid antivirus detection.

00:29:46.700 --> 00:29:48.320 align:middle line:84%
And then, after
that, we'll also be

00:29:48.320 --> 00:29:50.300 align:middle line:84%
exploring the process
of how to inject

00:29:50.300 --> 00:29:53.870 align:middle line:84%
a payload into a legitimate
Windows executable, which

00:29:53.870 --> 00:29:56.750 align:middle line:84%
can also help with the
legitimacy aspect of things

00:29:56.750 --> 00:30:00.380 align:middle line:84%
to essentially trying to
make the actual executable

00:30:00.380 --> 00:30:03.410 align:middle line:84%
or the payload look as
realistic as possible

00:30:03.410 --> 00:30:09.240 align:middle line:84%
and avoid any detection in terms
of suspicion from the end-user.

00:30:09.240 --> 00:30:12.510 align:middle line:84%
So I'll switch back
over to the slides.

00:30:12.510 --> 00:30:14.420 align:middle line:84%
All right, so that
was the process

00:30:14.420 --> 00:30:18.980 align:middle line:84%
of generating Windows and
Linux payloads with msfvenom,

00:30:18.980 --> 00:30:22.820 align:middle line:84%
as well as utilizing or
setting up a handler in order

00:30:22.820 --> 00:30:23.990 align:middle line:90%
to receive the connection.

00:30:23.990 --> 00:30:25.760 align:middle line:84%
In the next video,
we'll be exploring

00:30:25.760 --> 00:30:28.460 align:middle line:84%
the process of encoding
Windows and Linux

00:30:28.460 --> 00:30:30.140 align:middle line:90%
payloads with msfvenom.

00:30:30.140 --> 00:30:32.500 align:middle line:90%
So I'll see you there.

00:30:32.500 --> 00:30:33.000 align:middle line:90%