WEBVTT

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


00:00:03.493 --> 00:00:09.990 align:middle line:90%
[MUSIC LOGO]

00:00:09.990 --> 00:00:12.270 align:middle line:90%
Cross-compiling exploits.

00:00:12.270 --> 00:00:14.370 align:middle line:84%
In this video, we
will be taking a look

00:00:14.370 --> 00:00:18.300 align:middle line:84%
at the process of compiling
exploits, Linux exploits,

00:00:18.300 --> 00:00:23.560 align:middle line:84%
as well as cross-compiling
Windows exploits on Linux.

00:00:23.560 --> 00:00:28.050 align:middle line:84%
So in certain cases, exploit
code will be developed in C,

00:00:28.050 --> 00:00:30.120 align:middle line:90%
C++ or C#.

00:00:30.120 --> 00:00:33.360 align:middle line:84%
And as a result, you will need
to compile the exploit code

00:00:33.360 --> 00:00:36.720 align:middle line:84%
into a portable executable
in the case of Windows

00:00:36.720 --> 00:00:40.230 align:middle line:84%
or into a binary in
the case of Linux.

00:00:40.230 --> 00:00:44.380 align:middle line:84%
Now, it's very important to
note that in the previous video,

00:00:44.380 --> 00:00:47.610 align:middle line:84%
we covered the process
of modifying and running

00:00:47.610 --> 00:00:51.660 align:middle line:84%
an exploit that was
developed in Python.

00:00:51.660 --> 00:00:53.520 align:middle line:84%
One of the cool
things with Python

00:00:53.520 --> 00:00:57.360 align:middle line:84%
is that I don't need to compile
a Python code into a binary

00:00:57.360 --> 00:01:00.130 align:middle line:84%
or executable in
order to run it.

00:01:00.130 --> 00:01:04.019 align:middle line:84%
However, in the case
of C or C++ or C#,

00:01:04.019 --> 00:01:07.020 align:middle line:84%
I actually need to compile
it into a portable executable

00:01:07.020 --> 00:01:09.360 align:middle line:90%
or binary in order to run it.

00:01:09.360 --> 00:01:11.290 align:middle line:84%
Now, you might be
asking yourself, well,

00:01:11.290 --> 00:01:14.070 align:middle line:84%
what's compilation and
what's cross-compilation?

00:01:14.070 --> 00:01:16.770 align:middle line:84%
Cross-compilation is
the process of compiling

00:01:16.770 --> 00:01:19.710 align:middle line:84%
code for a platform other
than the one performing

00:01:19.710 --> 00:01:20.820 align:middle line:90%
the compilation.

00:01:20.820 --> 00:01:24.120 align:middle line:84%
Now, typically, during
a penetration test,

00:01:24.120 --> 00:01:26.310 align:middle line:84%
you're primarily going to
be working from a Linux

00:01:26.310 --> 00:01:28.950 align:middle line:84%
system, more
specifically, Kali Linux

00:01:28.950 --> 00:01:31.750 align:middle line:84%
or any other penetration-testing
distribution.

00:01:31.750 --> 00:01:34.260 align:middle line:84%
As a result, you
will be in situations

00:01:34.260 --> 00:01:37.950 align:middle line:84%
where you will need to compile
Windows exploits on a Linux

00:01:37.950 --> 00:01:39.900 align:middle line:84%
system, and that is
why this process is

00:01:39.900 --> 00:01:43.740 align:middle line:84%
referred to as cross-compiling
or cross-compilation.

00:01:43.740 --> 00:01:46.170 align:middle line:84%
If you're just compiling
a Linux exploit

00:01:46.170 --> 00:01:48.600 align:middle line:84%
on Kali Linux or a
Linux system, then that

00:01:48.600 --> 00:01:54.790 align:middle line:90%
is known simply as compiling.

00:01:54.790 --> 00:01:56.250 align:middle line:84%
So as a penetration
tester, you'll

00:01:56.250 --> 00:01:58.770 align:middle line:84%
need to have the skills
necessary to compile exploit

00:01:58.770 --> 00:02:02.490 align:middle line:84%
code developed in C. There is
no way of getting around it.

00:02:02.490 --> 00:02:04.260 align:middle line:84%
And again, it
really doesn't have

00:02:04.260 --> 00:02:07.950 align:middle line:84%
to be pertinent to an
exploit that will essentially

00:02:07.950 --> 00:02:10.740 align:middle line:84%
provide you with initial
access to a target system.

00:02:10.740 --> 00:02:13.800 align:middle line:84%
It could be a privilege
escalation exploit.

00:02:13.800 --> 00:02:17.580 align:middle line:84%
Irregardless of all of that,
having a good understanding

00:02:17.580 --> 00:02:21.060 align:middle line:84%
of how to offer to compile
exploit code that's been

00:02:21.060 --> 00:02:25.750 align:middle line:84%
written in C, C++, or C#
is very, very important.

00:02:25.750 --> 00:02:30.090 align:middle line:84%
So this video doesn't have a
lab environment attached to it.

00:02:30.090 --> 00:02:33.840 align:middle line:84%
The reason for that, again, it
really comes down to the fact

00:02:33.840 --> 00:02:37.020 align:middle line:84%
that there's a lot of
variability when it comes down

00:02:37.020 --> 00:02:40.920 align:middle line:84%
to cross-compiling Windows
exploit code that's

00:02:40.920 --> 00:02:42.613 align:middle line:90%
been written on C, on Linux.

00:02:42.613 --> 00:02:45.030 align:middle line:84%
So I'm just going to be taking
you through a few examples,

00:02:45.030 --> 00:02:46.830 align:middle line:84%
and I'll be explaining
the tools required

00:02:46.830 --> 00:02:51.270 align:middle line:84%
to perform the compilation and
cross-compilation in the case

00:02:51.270 --> 00:02:54.240 align:middle line:90%
of Windows and Linux as well.

00:02:54.240 --> 00:02:56.460 align:middle line:84%
So I'll just switch over
to my Kali Linux VM,

00:02:56.460 --> 00:02:58.960 align:middle line:90%
and we can get started.

00:02:58.960 --> 00:03:02.860 align:middle line:84%
So I'm back on my Kali
Linux VM, and I've already

00:03:02.860 --> 00:03:04.690 align:middle line:84%
identified the
exploits that have

00:03:04.690 --> 00:03:08.530 align:middle line:84%
been written in C that I'm going
to compile and cross-compile.

00:03:08.530 --> 00:03:10.810 align:middle line:84%
In the case of the
Windows exploit,

00:03:10.810 --> 00:03:15.280 align:middle line:84%
I'm going to be compiling
a VLC Media Player exploit

00:03:15.280 --> 00:03:16.683 align:middle line:90%
that was written in C.

00:03:16.683 --> 00:03:18.350 align:middle line:84%
Again, we're not going
to be running it.

00:03:18.350 --> 00:03:21.140 align:middle line:84%
We're just going to be taking
a look at how to compile it.

00:03:21.140 --> 00:03:24.160 align:middle line:84%
And I already have the
exploit DP links opened.

00:03:24.160 --> 00:03:25.630 align:middle line:84%
In the case of
Linux, we're going

00:03:25.630 --> 00:03:28.510 align:middle line:84%
to be compiling a
very popular privilege

00:03:28.510 --> 00:03:32.050 align:middle line:84%
escalation exploit that, again,
takes advantage of the Linux

00:03:32.050 --> 00:03:33.070 align:middle line:90%
kernel.

00:03:33.070 --> 00:03:34.150 align:middle line:90%
It's called Dirty COW.

00:03:34.150 --> 00:03:36.490 align:middle line:84%
So I'll be covering
the compilation process

00:03:36.490 --> 00:03:38.630 align:middle line:90%
for both Windows and Linux.

00:03:38.630 --> 00:03:42.760 align:middle line:84%
Now, in the case of Windows
compilation on Linux

00:03:42.760 --> 00:03:46.390 align:middle line:84%
or cross-compiling a
Windows exploit on Linux,

00:03:46.390 --> 00:03:51.940 align:middle line:84%
you require a few tools,
one of which is mingw-w64,

00:03:51.940 --> 00:03:53.560 align:middle line:84%
which as it says
right over here,

00:03:53.560 --> 00:03:55.750 align:middle line:84%
is a free and open source
software development

00:03:55.750 --> 00:03:59.590 align:middle line:84%
environment to create Microsoft
Windows portable executable

00:03:59.590 --> 00:04:01.360 align:middle line:90%
applications on Linux.

00:04:01.360 --> 00:04:04.090 align:middle line:84%
And it can easily be
installed on Kali Linux

00:04:04.090 --> 00:04:05.720 align:middle line:84%
by running the
following commands.

00:04:05.720 --> 00:04:07.870 align:middle line:84%
So I'll just open
up my terminal here,

00:04:07.870 --> 00:04:12.490 align:middle line:84%
and we'll get it installed by
saying sudo apt-get install.

00:04:12.490 --> 00:04:18.430 align:middle line:84%
And we want to install
mingw, and that is w64.

00:04:18.430 --> 00:04:19.570 align:middle line:90%
And we'll hit Enter.

00:04:19.570 --> 00:04:21.130 align:middle line:84%
Now, I already
have it installed.

00:04:21.130 --> 00:04:23.080 align:middle line:84%
So I don't need to go
through that process.

00:04:23.080 --> 00:04:23.920 align:middle line:90%
There we are.

00:04:23.920 --> 00:04:28.480 align:middle line:84%
And in the case of compiling
C code or Linux exploits,

00:04:28.480 --> 00:04:31.850 align:middle line:84%
you need to have the new
C compiler installed,

00:04:31.850 --> 00:04:33.880 align:middle line:84%
which again, can easily
be installed by saying

00:04:33.880 --> 00:04:37.750 align:middle line:90%
sudo apt-get install GCC.

00:04:37.750 --> 00:04:38.620 align:middle line:90%
I'll hit Enter.

00:04:38.620 --> 00:04:40.222 align:middle line:90%
I already have GCC installed.

00:04:40.222 --> 00:04:41.680 align:middle line:84%
But it looks like
I have an update.

00:04:41.680 --> 00:04:44.870 align:middle line:84%
So I'm just going to update
my version of GCC here.

00:04:44.870 --> 00:04:48.720 align:middle line:84%
So I'll give this a couple
of seconds to complete.

00:04:48.720 --> 00:04:54.270 align:middle line:84%
So we have both mingw-w64
installed as well as

00:04:54.270 --> 00:04:55.480 align:middle line:90%
GCC installed.

00:04:55.480 --> 00:04:58.320 align:middle line:84%
So we can actually take
a look at how to compile

00:04:58.320 --> 00:05:00.030 align:middle line:90%
the Windows exploit first.

00:05:00.030 --> 00:05:02.640 align:middle line:84%
And I'll just clear
up my terminal here.

00:05:02.640 --> 00:05:04.740 align:middle line:84%
And I'm currently working
within my Desktop,

00:05:04.740 --> 00:05:07.500 align:middle line:84%
and I've created a
folder called Exploits.

00:05:07.500 --> 00:05:11.520 align:middle line:84%
So let's take a look at this
exploit right over here.

00:05:11.520 --> 00:05:14.100 align:middle line:84%
So we can see that
it's written in C.

00:05:14.100 --> 00:05:16.890 align:middle line:84%
And of course, that's
quite easy to tell.

00:05:16.890 --> 00:05:20.147 align:middle line:84%
Irregardless of what version
of Windows this is targeting,

00:05:20.147 --> 00:05:22.230 align:middle line:84%
we're just going to be
focused on the compilation.

00:05:22.230 --> 00:05:25.470 align:middle line:84%
So it's a relatively
simple exploit.

00:05:25.470 --> 00:05:28.320 align:middle line:84%
And in terms of
compilation, we can

00:05:28.320 --> 00:05:31.560 align:middle line:84%
compile either a 32-bit
version of the exploit

00:05:31.560 --> 00:05:33.720 align:middle line:90%
or a 64-bit version.

00:05:33.720 --> 00:05:37.890 align:middle line:84%
And I would typically recommend
compiling the 32-bit version

00:05:37.890 --> 00:05:41.760 align:middle line:84%
of the exploit, as it'll run
on both 32-bit systems as well

00:05:41.760 --> 00:05:43.290 align:middle line:90%
as 64-bit systems.

00:05:43.290 --> 00:05:45.430 align:middle line:84%
But of course, you have
the ability to change that.

00:05:45.430 --> 00:05:48.960 align:middle line:84%
So I can download it directly
from the ExploitDB website

00:05:48.960 --> 00:05:51.690 align:middle line:84%
or I can utilize
searchsploit to copy it over.

00:05:51.690 --> 00:05:53.560 align:middle line:90%
So I'll just do that instead.

00:05:53.560 --> 00:05:56.310 align:middle line:84%
So I'll just run the
searchsploit command.

00:05:56.310 --> 00:06:02.420 align:middle line:84%
And the name of the exploit
here is VideoLAN VLC.

00:06:02.420 --> 00:06:05.640 align:middle line:84%
So I'll just perform
a quick search for it.

00:06:05.640 --> 00:06:11.300 align:middle line:84%
So searchsploit VideoLAN,
and we can just hit Enter.

00:06:11.300 --> 00:06:12.830 align:middle line:84%
And you can see we
have quite a few.

00:06:12.830 --> 00:06:17.960 align:middle line:84%
So let me just further
filter out the results here.

00:06:17.960 --> 00:06:20.390 align:middle line:90%
And I'll also say VideoLAN VLC.

00:06:20.390 --> 00:06:21.800 align:middle line:90%
This is SMB.

00:06:21.800 --> 00:06:25.610 align:middle line:84%
And the one that we're looking
for here is the C exploit.

00:06:25.610 --> 00:06:28.490 align:middle line:90%
So that's 9303.c.

00:06:28.490 --> 00:06:30.480 align:middle line:90%
I believe that is the case here.

00:06:30.480 --> 00:06:33.560 align:middle line:84%
If we take a look at
the EDB ID, that's 9303,

00:06:33.560 --> 00:06:35.990 align:middle line:90%
and it is EDB verified.

00:06:35.990 --> 00:06:38.420 align:middle line:84%
So what I can do now
is, again, just copy it

00:06:38.420 --> 00:06:40.980 align:middle line:84%
with searchsploit to my
current working directory.

00:06:40.980 --> 00:06:47.570 align:middle line:84%
So I'll say searchsploit
-m, and 9303 is the EDB ID.

00:06:47.570 --> 00:06:48.590 align:middle line:90%
And hit Enter.

00:06:48.590 --> 00:06:51.510 align:middle line:84%
And that's copied
the incorrect one.

00:06:51.510 --> 00:06:54.260 align:middle line:84%
So let me just get rid of the
one it just copied right now

00:06:54.260 --> 00:06:57.890 align:middle line:90%
because I typed it incorrectly.

00:06:57.890 --> 00:07:01.340 align:middle line:84%
So the one we want
to copy is 9303.

00:07:01.340 --> 00:07:05.180 align:middle line:84%
There we are and it looks
like we already have it there.

00:07:05.180 --> 00:07:08.340 align:middle line:84%
So yes, I'm just
going to overwrite it.

00:07:08.340 --> 00:07:09.660 align:middle line:90%
So there's the C file.

00:07:09.660 --> 00:07:12.860 align:middle line:84%
So again, if we inspect
the C file-- now,

00:07:12.860 --> 00:07:15.920 align:middle line:84%
I just want to highlight
something very important here.

00:07:15.920 --> 00:07:19.910 align:middle line:84%
In the case of exploits
that have been written in C,

00:07:19.910 --> 00:07:22.820 align:middle line:84%
if the exploits have
been well-documented,

00:07:22.820 --> 00:07:25.460 align:middle line:84%
they might contain
information regarding

00:07:25.460 --> 00:07:33.050 align:middle line:84%
how to compile this specific
exploit in regards to the mingw

00:07:33.050 --> 00:07:35.000 align:middle line:84%
compilation instructions
and arguments

00:07:35.000 --> 00:07:36.960 align:middle line:90%
that you need to provide.

00:07:36.960 --> 00:07:39.290 align:middle line:84%
However, in this
case, this exploit

00:07:39.290 --> 00:07:41.150 align:middle line:84%
doesn't have any
information regarding

00:07:41.150 --> 00:07:44.090 align:middle line:84%
how to compile this
particular exploit.

00:07:44.090 --> 00:07:47.360 align:middle line:84%
So we will need to use
the default compilation

00:07:47.360 --> 00:07:50.780 align:middle line:84%
options or the default
compilation syntax.

00:07:50.780 --> 00:07:56.330 align:middle line:84%
And in order to compile
this exploit written in C,

00:07:56.330 --> 00:08:00.620 align:middle line:84%
we will start off by compiling
the 64-bit version first.

00:08:00.620 --> 00:08:01.650 align:middle line:90%
So I can highlight that.

00:08:01.650 --> 00:08:06.050 align:middle line:90%
So we'll use the i686 min.

00:08:06.050 --> 00:08:10.040 align:middle line:84%
We'll actually use w64 because
we're compiling 64-bit.

00:08:10.040 --> 00:08:15.590 align:middle line:84%
mingw-w32 GCC, and yeah,
that's the one we want to use.

00:08:15.590 --> 00:08:19.170 align:middle line:84%
And we then specify
the C code itself.

00:08:19.170 --> 00:08:20.750 align:middle line:90%
So 9303.c.

00:08:20.750 --> 00:08:26.660 align:middle line:84%
And then we can then output
it into another file.

00:08:26.660 --> 00:08:29.060 align:middle line:84%
This is going to be the
portable executable.

00:08:29.060 --> 00:08:31.520 align:middle line:84%
And in this case, we
can just call it exploit

00:08:31.520 --> 00:08:33.169 align:middle line:90%
or something very basic.

00:08:33.169 --> 00:08:34.669 align:middle line:90%
So I'll just hit Enter.

00:08:34.669 --> 00:08:37.940 align:middle line:84%
And if it doesn't give
you any error messages,

00:08:37.940 --> 00:08:39.690 align:middle line:90%
the compilation was successful.

00:08:39.690 --> 00:08:42.020 align:middle line:84%
So if I list out the
contents of the directory,

00:08:42.020 --> 00:08:45.290 align:middle line:84%
you can see that that exploit
was compiled successfully.

00:08:45.290 --> 00:08:47.930 align:middle line:84%
And we now have exploit.exe,
which we can then

00:08:47.930 --> 00:08:49.500 align:middle line:90%
run against the target.

00:08:49.500 --> 00:08:53.000 align:middle line:84%
So that is how to perform
Windows cross-compilation

00:08:53.000 --> 00:08:54.020 align:middle line:90%
on Linux.

00:08:54.020 --> 00:08:55.680 align:middle line:90%
And it really is very simple.

00:08:55.680 --> 00:08:59.060 align:middle line:84%
Now, as I said, in some cases,
you may find a few errors.

00:08:59.060 --> 00:09:02.330 align:middle line:84%
And that will come down to the
actual compilation arguments

00:09:02.330 --> 00:09:03.620 align:middle line:90%
that you need to provide.

00:09:03.620 --> 00:09:06.680 align:middle line:84%
Now, if you want to compile
it for 32-bit systems,

00:09:06.680 --> 00:09:10.700 align:middle line:84%
you can just go ahead and type
in the following command--

00:09:10.700 --> 00:09:13.790 align:middle line:84%
I'll get rid of that
there, and we can then

00:09:13.790 --> 00:09:16.820 align:middle line:84%
run the following
command-- so i686.

00:09:16.820 --> 00:09:23.630 align:middle line:84%
And we're going to be using
w64 mingw-w32, essentially

00:09:23.630 --> 00:09:28.300 align:middle line:84%
the same compiler but
with one difference.

00:09:28.300 --> 00:09:31.160 align:middle line:84%
So let me just type
that in correctly there.

00:09:31.160 --> 00:09:35.700 align:middle line:84%
mingw-w32, and that
is we're using GCC.

00:09:35.700 --> 00:09:39.010 align:middle line:84%
And we then specify the
actual exploit itself.

00:09:39.010 --> 00:09:43.450 align:middle line:84%
And then we can output this into
a file called exploit again.

00:09:43.450 --> 00:09:45.270 align:middle line:84%
And we now need to
specify that this

00:09:45.270 --> 00:09:48.870 align:middle line:84%
is for 32-bit systems or
32-bit versions of Windows.

00:09:48.870 --> 00:09:50.805 align:middle line:84%
So that can be done
by saying lws2-32.

00:09:50.805 --> 00:09:54.090 align:middle line:90%


00:09:54.090 --> 00:09:56.670 align:middle line:84%
And we hit Enter,
and that compiles it.

00:09:56.670 --> 00:09:58.960 align:middle line:90%
It compiles the 32-bit exploit.

00:09:58.960 --> 00:10:01.540 align:middle line:84%
So if I list out the
contents of this directory,

00:10:01.540 --> 00:10:03.540 align:middle line:90%
you can see we have exploit.exe.

00:10:03.540 --> 00:10:05.760 align:middle line:84%
So we have been
able to compile both

00:10:05.760 --> 00:10:08.550 align:middle line:84%
the 64-bit portable
executable and

00:10:08.550 --> 00:10:10.590 align:middle line:90%
the 32-bit portable executable.

00:10:10.590 --> 00:10:13.620 align:middle line:84%
So I'll just get rid of the
compiled executable there.

00:10:13.620 --> 00:10:18.480 align:middle line:84%
And we can take a look at how
to compile Linux exploits that

00:10:18.480 --> 00:10:20.670 align:middle line:90%
have been written in C.

00:10:20.670 --> 00:10:22.740 align:middle line:84%
So I'll just navigate
to my browser here.

00:10:22.740 --> 00:10:25.110 align:middle line:84%
And we'll take a look at
the Dirty COW exploit.

00:10:25.110 --> 00:10:28.950 align:middle line:84%
So again, as you can see,
this exploit is written in C.

00:10:28.950 --> 00:10:31.530 align:middle line:84%
And one of the things I
want you to take note of

00:10:31.530 --> 00:10:35.730 align:middle line:84%
is that this particular exploit
has fantastic documentation,

00:10:35.730 --> 00:10:38.730 align:middle line:84%
in that it provides you with
compilation instructions

00:10:38.730 --> 00:10:41.760 align:middle line:84%
and the arguments that
you need to specify

00:10:41.760 --> 00:10:43.830 align:middle line:90%
during the actual compilation.

00:10:43.830 --> 00:10:47.190 align:middle line:84%
So you can see we have the
lcrypt option specified as well

00:10:47.190 --> 00:10:48.180 align:middle line:90%
as -pthread.

00:10:48.180 --> 00:10:52.860 align:middle line:84%
So again, if we would have just
run GCC and specified the C

00:10:52.860 --> 00:10:56.490 align:middle line:84%
file and output it
into a Linux binary,

00:10:56.490 --> 00:10:58.560 align:middle line:90%
we would have gotten an error.

00:10:58.560 --> 00:11:01.710 align:middle line:84%
And thanks to the author
of this particular exploit,

00:11:01.710 --> 00:11:05.760 align:middle line:84%
the actual compilation
instructions and arguments

00:11:05.760 --> 00:11:07.740 align:middle line:84%
required to compile
it successfully

00:11:07.740 --> 00:11:09.790 align:middle line:90%
have been provided to us.

00:11:09.790 --> 00:11:12.120 align:middle line:84%
The author also
provides information

00:11:12.120 --> 00:11:17.400 align:middle line:84%
regarding how to execute or how
to run this particular exploit.

00:11:17.400 --> 00:11:21.150 align:middle line:84%
So we can download it
directly or we can utilize

00:11:21.150 --> 00:11:24.480 align:middle line:90%
searchsploit to copy it over.

00:11:24.480 --> 00:11:27.340 align:middle line:84%
So I can just search for
the exploit manually.

00:11:27.340 --> 00:11:29.070 align:middle line:90%
So I'll say searchsploit.

00:11:29.070 --> 00:11:34.520 align:middle line:90%
And we can then say Dirty COW.

00:11:34.520 --> 00:11:36.870 align:middle line:84%
And it really doesn't
need to be case sensitive.

00:11:36.870 --> 00:11:38.720 align:middle line:84%
And the one that
we're looking for

00:11:38.720 --> 00:11:40.980 align:middle line:90%
is this one right over here.

00:11:40.980 --> 00:11:42.650 align:middle line:84%
That's the privilege
escalation exploit.

00:11:42.650 --> 00:11:45.320 align:middle line:90%
So that is 4839.c.

00:11:45.320 --> 00:11:54.380 align:middle line:84%
So I'll say searchsploit
-m, and that is 40839.c.

00:11:54.380 --> 00:11:56.300 align:middle line:84%
And we don't need to
specify the extension.

00:11:56.300 --> 00:11:58.010 align:middle line:90%
We just hit Enter.

00:11:58.010 --> 00:12:00.740 align:middle line:84%
And again, because the
compilation instructions

00:12:00.740 --> 00:12:04.550 align:middle line:84%
have been given to us, we can
go ahead with the compilation.

00:12:04.550 --> 00:12:06.650 align:middle line:84%
However, for this exploit,
you have the ability

00:12:06.650 --> 00:12:08.750 align:middle line:84%
to modify it based on
your own parameters,

00:12:08.750 --> 00:12:10.430 align:middle line:90%
as you can see here.

00:12:10.430 --> 00:12:11.930 align:middle line:84%
We have a few
variables that allow

00:12:11.930 --> 00:12:13.280 align:middle line:90%
you to change the username.

00:12:13.280 --> 00:12:16.080 align:middle line:84%
And of course, this is not
really relevant to this video.

00:12:16.080 --> 00:12:20.270 align:middle line:84%
I'm just showing you an example
of a really well-developed

00:12:20.270 --> 00:12:22.940 align:middle line:84%
exploit and the fact
that it contains

00:12:22.940 --> 00:12:25.190 align:middle line:90%
really good documentation.

00:12:25.190 --> 00:12:27.920 align:middle line:84%
Furthermore, C code
is actually quite easy

00:12:27.920 --> 00:12:30.780 align:middle line:84%
to read in terms of
understanding what's going on.

00:12:30.780 --> 00:12:34.100 align:middle line:84%
So again, we really
don't need anything else,

00:12:34.100 --> 00:12:37.130 align:middle line:84%
apart from the actual
compilation instructions.

00:12:37.130 --> 00:12:40.460 align:middle line:84%
So we need to specify
or utilize GCC.

00:12:40.460 --> 00:12:44.370 align:middle line:84%
We then specify -pthread,
the actual exploit itself.

00:12:44.370 --> 00:12:47.810 align:middle line:84%
We then output it into a
binary that we can essentially

00:12:47.810 --> 00:12:51.410 align:middle line:84%
specify whatever name
we want and then lcrypt.

00:12:51.410 --> 00:12:57.390 align:middle line:84%
So what we'll do is we will say
GCC -pthread, -pthread right

00:12:57.390 --> 00:12:59.740 align:middle line:84%
over here, and then the
actual exploit itself,

00:12:59.740 --> 00:13:05.310 align:middle line:84%
which is 40839.c, and then
we output this into exploit.

00:13:05.310 --> 00:13:09.060 align:middle line:84%
And again, this is going
to be an ELF binary, which

00:13:09.060 --> 00:13:12.930 align:middle line:84%
means it can only be executed
on a Linux or Unix system.

00:13:12.930 --> 00:13:16.660 align:middle line:84%
And then, we need to specify
the final argument here,

00:13:16.660 --> 00:13:19.050 align:middle line:90%
which in this case is lcrypt.

00:13:19.050 --> 00:13:21.630 align:middle line:90%
So we'll say lcrypt.

00:13:21.630 --> 00:13:23.550 align:middle line:90%
And we can then hit Enter.

00:13:23.550 --> 00:13:26.790 align:middle line:84%
And if we don't get any
errors, the compilation

00:13:26.790 --> 00:13:28.660 align:middle line:90%
is completed successfully.

00:13:28.660 --> 00:13:30.970 align:middle line:84%
And if we list out the
contents of this directory,

00:13:30.970 --> 00:13:33.810 align:middle line:84%
you can now see we have
the Linux binary or ELF

00:13:33.810 --> 00:13:37.410 align:middle line:84%
binary called exploit, which
we can execute on Kali Linux.

00:13:37.410 --> 00:13:41.610 align:middle line:84%
But again, it's not really
applicable to our distribution

00:13:41.610 --> 00:13:44.520 align:middle line:84%
because this is a
privileged escalation

00:13:44.520 --> 00:13:49.230 align:middle line:84%
exploit for Ubuntu primarily
and a few variants of Debian.

00:13:49.230 --> 00:13:50.610 align:middle line:90%
But extremely powerful.

00:13:50.610 --> 00:13:52.710 align:middle line:84%
I just wanted to highlight
it because of the fact

00:13:52.710 --> 00:13:55.660 align:middle line:84%
that it's one of the, at
least in my experience,

00:13:55.660 --> 00:14:00.090 align:middle line:84%
one of the most
well-developed and documented

00:14:00.090 --> 00:14:03.720 align:middle line:84%
exploits out there, especially
in the context of C.

00:14:03.720 --> 00:14:06.570 align:middle line:84%
And again, it's been made
so that you can actually

00:14:06.570 --> 00:14:10.230 align:middle line:84%
modify it and configure it
based on your own requirements

00:14:10.230 --> 00:14:12.400 align:middle line:84%
and the environment
that you're working on.

00:14:12.400 --> 00:14:14.970 align:middle line:84%
So yeah, that's
compiled successfully.

00:14:14.970 --> 00:14:17.250 align:middle line:84%
And we have successfully
taken a look

00:14:17.250 --> 00:14:20.820 align:middle line:84%
at how to cross-compile
Windows exploits that

00:14:20.820 --> 00:14:23.040 align:middle line:84%
have been developed
in C on Linux

00:14:23.040 --> 00:14:25.980 align:middle line:84%
as well as cross-compiling
Linux exploits that

00:14:25.980 --> 00:14:28.620 align:middle line:90%
have been developed in C.

00:14:28.620 --> 00:14:32.220 align:middle line:84%
Now, one additional resource
that I want to showcase

00:14:32.220 --> 00:14:36.270 align:middle line:84%
here is the GitHub repository
by Offensive Security

00:14:36.270 --> 00:14:39.100 align:middle line:90%
called ExploitDB bin-sploits.

00:14:39.100 --> 00:14:42.330 align:middle line:84%
This is a GitHub repository
that essentially contains

00:14:42.330 --> 00:14:46.530 align:middle line:84%
a list of precompiled
binaries, more specifically,

00:14:46.530 --> 00:14:50.770 align:middle line:84%
Windows binaries and a few
Linux binaries as well.

00:14:50.770 --> 00:14:53.130 align:middle line:84%
And again, the reason
this is provided

00:14:53.130 --> 00:14:55.770 align:middle line:84%
is primarily because
in certain cases

00:14:55.770 --> 00:14:58.470 align:middle line:84%
cross-compiling Windows
exploits on Linux

00:14:58.470 --> 00:15:02.170 align:middle line:84%
may actually enumerate
or may not be successful

00:15:02.170 --> 00:15:03.730 align:middle line:84%
and may bring up
a lot of errors.

00:15:03.730 --> 00:15:06.450 align:middle line:84%
So in that case,
again, you can always

00:15:06.450 --> 00:15:10.410 align:middle line:84%
rely on this vetted source in
terms of precompiled binaries,

00:15:10.410 --> 00:15:12.810 align:middle line:84%
in that you know that they
don't perform anything

00:15:12.810 --> 00:15:15.060 align:middle line:84%
else that they're not
supposed to do in terms

00:15:15.060 --> 00:15:16.870 align:middle line:90%
of their functionality.

00:15:16.870 --> 00:15:20.130 align:middle line:84%
So again, you can essentially
navigate or specify one

00:15:20.130 --> 00:15:23.580 align:middle line:90%
based on the actual EDB ID here.

00:15:23.580 --> 00:15:26.880 align:middle line:84%
So you can click on any of
them, and they're actually

00:15:26.880 --> 00:15:28.800 align:middle line:84%
archived so you can
just download them,

00:15:28.800 --> 00:15:31.410 align:middle line:84%
and you'll have the
precompiled binaries available.

00:15:31.410 --> 00:15:34.570 align:middle line:84%
And you don't have to go through
the cross-compilation process.

00:15:34.570 --> 00:15:37.410 align:middle line:84%
However, as I said,
it's very important

00:15:37.410 --> 00:15:40.410 align:middle line:84%
that you actually know how
to actually compile exploits,

00:15:40.410 --> 00:15:43.140 align:middle line:84%
both Linux exploits
and Windows exploits,

00:15:43.140 --> 00:15:46.200 align:middle line:84%
as that is something that you'll
actually run into quite a bit.

00:15:46.200 --> 00:15:52.230 align:middle line:84%
And once you start progressing
with your career in penetration

00:15:52.230 --> 00:15:54.570 align:middle line:84%
testing and you start
writing your own exploits,

00:15:54.570 --> 00:15:57.360 align:middle line:84%
you will need to have the
knowledge required to actually

00:15:57.360 --> 00:15:58.870 align:middle line:90%
compile your own exploit.

00:15:58.870 --> 00:16:02.262 align:middle line:84%
So again, this is something
that's quite important to know.

00:16:02.262 --> 00:16:03.720 align:middle line:84%
With that being
said, that is going

00:16:03.720 --> 00:16:05.760 align:middle line:84%
to conclude the
practical demonstration

00:16:05.760 --> 00:16:08.870 align:middle line:90%
side of this video.

00:16:08.870 --> 00:16:12.890 align:middle line:84%
So that concludes the fixing
exploit section of this course.

00:16:12.890 --> 00:16:16.610 align:middle line:84%
In the next section,
we'll actually take a look

00:16:16.610 --> 00:16:18.410 align:middle line:90%
at bind and reverse shells.

00:16:18.410 --> 00:16:20.270 align:middle line:84%
And we'll get an
understanding of what

00:16:20.270 --> 00:16:23.600 align:middle line:84%
a reverse shell is, what a bind
shell is, how to set them up.

00:16:23.600 --> 00:16:26.120 align:middle line:84%
And we'll also be
exploring Netcat in depth

00:16:26.120 --> 00:16:28.400 align:middle line:84%
and getting an understanding
of how it works

00:16:28.400 --> 00:16:32.000 align:middle line:84%
and why it's so powerful,
primarily because it is a tool

00:16:32.000 --> 00:16:34.940 align:middle line:84%
that you'll be using a
lot during penetration

00:16:34.940 --> 00:16:39.230 align:middle line:84%
tests and one that has stayed
a constant over the years.

00:16:39.230 --> 00:16:43.180 align:middle line:84%
With that being said, I'll
see you in the next section.

00:16:43.180 --> 00:16:44.000 align:middle line:90%