WEBVTT

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


00:00:03.339 --> 00:00:06.678 align:middle line:90%
[MUSIC PLAYING]

00:00:06.678 --> 00:00:10.020 align:middle line:90%


00:00:10.020 --> 00:00:14.910 align:middle line:84%
Netcat fundamentals-- welcome
to the bind and reverse shells

00:00:14.910 --> 00:00:16.500 align:middle line:90%
section of this course.

00:00:16.500 --> 00:00:18.480 align:middle line:84%
And within this
section, we're going

00:00:18.480 --> 00:00:22.020 align:middle line:84%
to be taking a look at
how to set up bind shells

00:00:22.020 --> 00:00:23.430 align:middle line:90%
and reverse shells.

00:00:23.430 --> 00:00:25.140 align:middle line:84%
However, before we
do that, we need

00:00:25.140 --> 00:00:29.340 align:middle line:84%
to get an understanding of a
very, very important tool that

00:00:29.340 --> 00:00:32.280 align:middle line:84%
will essentially be
pivotal within this process

00:00:32.280 --> 00:00:34.800 align:middle line:84%
of establishing
either a bind shell

00:00:34.800 --> 00:00:38.130 align:middle line:84%
or reverse shell, and
that, of course, is Netcat.

00:00:38.130 --> 00:00:40.560 align:middle line:84%
All right, so this
is pretty much

00:00:40.560 --> 00:00:42.360 align:middle line:84%
where things start
getting interesting.

00:00:42.360 --> 00:00:46.890 align:middle line:84%
And from a penetration
testers point of view,

00:00:46.890 --> 00:00:51.060 align:middle line:84%
Netcat is seen as an
absolute must-have in regards

00:00:51.060 --> 00:00:53.940 align:middle line:84%
to your arsenal of tools
that you'll typically

00:00:53.940 --> 00:00:57.810 align:middle line:84%
be utilizing on a day-to-day
basis as a penetration tester.

00:00:57.810 --> 00:01:00.840 align:middle line:84%
So let's get an understanding
of how to utilize Netcat.

00:01:00.840 --> 00:01:03.090 align:middle line:84%
Now, before we do that,
let's get an understanding

00:01:03.090 --> 00:01:07.020 align:middle line:84%
of how or what Netcat is
and how it can be used

00:01:07.020 --> 00:01:08.850 align:middle line:90%
or what it can be used to do.

00:01:08.850 --> 00:01:13.650 align:middle line:84%
All right, so Netcat, also known
as the TCP/IP Swiss Army knife,

00:01:13.650 --> 00:01:15.870 align:middle line:84%
is a networking
utility that's used

00:01:15.870 --> 00:01:18.720 align:middle line:84%
to read and write data
to network connections

00:01:18.720 --> 00:01:21.390 align:middle line:90%
using TCP or UDP.

00:01:21.390 --> 00:01:25.650 align:middle line:84%
The great thing about Netcat
is it's available for both NIX

00:01:25.650 --> 00:01:27.240 align:middle line:90%
and Windows operating systems.

00:01:27.240 --> 00:01:30.870 align:middle line:84%
And by NIX I mean
Unix, Linux, et cetera.

00:01:30.870 --> 00:01:33.660 align:middle line:84%
And this essentially
makes it extremely

00:01:33.660 --> 00:01:35.980 align:middle line:84%
useful for cross-platform
engagement.

00:01:35.980 --> 00:01:38.890 align:middle line:84%
So, again, it is completely
platform agnostic,

00:01:38.890 --> 00:01:41.820 align:middle line:84%
which means you can essentially
obtain a reverse shell

00:01:41.820 --> 00:01:45.990 align:middle line:84%
on a Windows system, even if
you are running a Linux system

00:01:45.990 --> 00:01:48.220 align:middle line:90%
and vise versa.

00:01:48.220 --> 00:01:50.100 align:middle line:84%
Now, in order to
understand how Netcat

00:01:50.100 --> 00:01:54.480 align:middle line:84%
works and its relationship
to setting up or facilitating

00:01:54.480 --> 00:01:56.880 align:middle line:84%
reverse shells or
bind shells, we

00:01:56.880 --> 00:01:59.890 align:middle line:84%
need to get an understanding
of its communication model,

00:01:59.890 --> 00:02:00.390 align:middle line:90%
all right?

00:02:00.390 --> 00:02:03.750 align:middle line:84%
So Netcat utilizes a
client-server communication

00:02:03.750 --> 00:02:06.570 align:middle line:84%
architecture or model
with two modes--

00:02:06.570 --> 00:02:09.180 align:middle line:84%
that is your client mode and
your server mode, all right?

00:02:09.180 --> 00:02:11.400 align:middle line:84%
So in the client
mode, Netcat can

00:02:11.400 --> 00:02:14.850 align:middle line:84%
be used to connect
to any TCP or UDP

00:02:14.850 --> 00:02:18.060 align:middle line:84%
port as well as a Netcat
listener, also known

00:02:18.060 --> 00:02:19.660 align:middle line:90%
as the server.

00:02:19.660 --> 00:02:21.300 align:middle line:90%
So what is the server mode?

00:02:21.300 --> 00:02:26.670 align:middle line:84%
Netcat can be used to listen
for connections from clients

00:02:26.670 --> 00:02:28.060 align:middle line:90%
on a specific port.

00:02:28.060 --> 00:02:31.080 align:middle line:84%
Now, this really will not
make much sense to you

00:02:31.080 --> 00:02:34.500 align:middle line:84%
right now until we move on into
the practical demonstration

00:02:34.500 --> 00:02:38.640 align:middle line:84%
and once we start exploring
bind shells and reverse shells.

00:02:38.640 --> 00:02:41.310 align:middle line:84%
What this means is
that in client mode,

00:02:41.310 --> 00:02:44.930 align:middle line:84%
you use that mode to
connect to ports--

00:02:44.930 --> 00:02:48.060 align:middle line:84%
any TCP or UDP port-- or,
more specifically, you

00:02:48.060 --> 00:02:51.090 align:middle line:84%
can use it to connect
to a Netcat listener,

00:02:51.090 --> 00:02:53.820 align:middle line:84%
also known as the
Netcat server mode.

00:02:53.820 --> 00:02:56.040 align:middle line:84%
Now, the server mode
allows you to listen

00:02:56.040 --> 00:03:00.190 align:middle line:84%
for connections on a
specific port on your system.

00:03:00.190 --> 00:03:03.300 align:middle line:84%
So with that, you're essentially
setting up a listener,

00:03:03.300 --> 00:03:05.680 align:middle line:84%
and then other clients
can connect to you.

00:03:05.680 --> 00:03:07.470 align:middle line:84%
So you're starting to
get an understanding

00:03:07.470 --> 00:03:10.200 align:middle line:90%
of how powerful Netcat is.

00:03:10.200 --> 00:03:13.740 align:middle line:84%
So in terms of what Netcat can
be used to do from the context

00:03:13.740 --> 00:03:16.350 align:middle line:84%
or from the point of view
of a penetration tester,

00:03:16.350 --> 00:03:19.120 align:middle line:84%
as we've already explored
previously in this course,

00:03:19.120 --> 00:03:21.930 align:middle line:84%
we can perform banner
grabbing with Netcat.

00:03:21.930 --> 00:03:24.930 align:middle line:84%
We can also perform port
scanning, transferring

00:03:24.930 --> 00:03:28.290 align:middle line:84%
of files, and, of course,
the facilitation or the setup

00:03:28.290 --> 00:03:30.500 align:middle line:90%
of bind and reverse shells.

00:03:30.500 --> 00:03:33.180 align:middle line:84%
Right, so now that we have an
understanding of what Netcat

00:03:33.180 --> 00:03:37.680 align:middle line:84%
is, let's actually get started
with the practical section,

00:03:37.680 --> 00:03:41.310 align:middle line:84%
and we will be able to get
an understanding of how

00:03:41.310 --> 00:03:42.600 align:middle line:90%
this can all be done.

00:03:42.600 --> 00:03:46.470 align:middle line:84%
So this video has a lab
environment attached to it.

00:03:46.470 --> 00:03:48.420 align:middle line:84%
And all you need to
do is just fire it up,

00:03:48.420 --> 00:03:51.090 align:middle line:84%
and you can follow along
with the demonstrations

00:03:51.090 --> 00:03:52.560 align:middle line:90%
that I will be performing.

00:03:52.560 --> 00:03:54.930 align:middle line:84%
So I'll switch over
to my lab environment,

00:03:54.930 --> 00:03:57.960 align:middle line:90%
and I'll see you there.

00:03:57.960 --> 00:04:01.392 align:middle line:84%
All right, so I'm back
within the lab environment.

00:04:01.392 --> 00:04:02.850 align:middle line:84%
Within this lab
environment, you'll

00:04:02.850 --> 00:04:07.410 align:middle line:84%
be provided with a unique target
IP address in a notepad or text

00:04:07.410 --> 00:04:08.310 align:middle line:90%
file.

00:04:08.310 --> 00:04:11.290 align:middle line:84%
Do keep this open as
it is quite important.

00:04:11.290 --> 00:04:13.320 align:middle line:84%
If you do end up closing
it, you can access it

00:04:13.320 --> 00:04:15.660 align:middle line:84%
by opening the target
file on your desktop.

00:04:15.660 --> 00:04:18.000 align:middle line:84%
It will contain the
target IP address.

00:04:18.000 --> 00:04:19.950 align:middle line:84%
And one additional
feature that you

00:04:19.950 --> 00:04:22.050 align:middle line:84%
have been provided
with in this lab

00:04:22.050 --> 00:04:25.680 align:middle line:84%
is access to the target system
that is running Windows.

00:04:25.680 --> 00:04:28.200 align:middle line:84%
Now, for the purpose
of this video

00:04:28.200 --> 00:04:30.520 align:middle line:84%
and other videos
within this section,

00:04:30.520 --> 00:04:33.210 align:middle line:84%
I want you to disregard
the service that's

00:04:33.210 --> 00:04:37.080 align:middle line:84%
running on the target system
as the only reason why you have

00:04:37.080 --> 00:04:40.560 align:middle line:84%
access to the Windows system
is to demonstrate how Netcat

00:04:40.560 --> 00:04:44.790 align:middle line:84%
can be used on both platforms--
so both Linux and Windows.

00:04:44.790 --> 00:04:49.030 align:middle line:84%
So I'll just switch over
to my Kali Linux system.

00:04:49.030 --> 00:04:51.930 align:middle line:84%
So again, the tabs are
named in a way for you

00:04:51.930 --> 00:04:53.310 align:middle line:84%
that you can
actually understand.

00:04:53.310 --> 00:04:55.230 align:middle line:84%
You have attack machine
and target machine.

00:04:55.230 --> 00:04:57.180 align:middle line:90%
The target is running Windows.

00:04:57.180 --> 00:05:00.480 align:middle line:84%
The target is running
Windows Server 2012.

00:05:00.480 --> 00:05:04.740 align:middle line:84%
So again, it's fairly
modern, and it'll

00:05:04.740 --> 00:05:06.780 align:middle line:84%
be very, very helpful
in demonstrating

00:05:06.780 --> 00:05:08.620 align:middle line:90%
how Netcat can be used.

00:05:08.620 --> 00:05:11.310 align:middle line:84%
So let's get an understanding
of what Netcat is

00:05:11.310 --> 00:05:13.890 align:middle line:84%
and how it can be used by
opening up our terminal.

00:05:13.890 --> 00:05:15.540 align:middle line:84%
And I'm just going
to zoom in so you

00:05:15.540 --> 00:05:17.350 align:middle line:90%
can see what's going on here.

00:05:17.350 --> 00:05:20.820 align:middle line:84%
And in order to use Netcat on
Kali Linux, all you need to do

00:05:20.820 --> 00:05:23.310 align:middle line:90%
is type in NC for Netcat.

00:05:23.310 --> 00:05:25.890 align:middle line:84%
And we've used this
in the past before.

00:05:25.890 --> 00:05:28.440 align:middle line:84%
The great thing with Kali
Linux is Netcat already

00:05:28.440 --> 00:05:31.380 align:middle line:84%
comes preinstalled, so we
can just type in Netcat

00:05:31.380 --> 00:05:33.990 align:middle line:90%
and open up the Help menu.

00:05:33.990 --> 00:05:38.010 align:middle line:84%
And I'll just say
minus minus help.

00:05:38.010 --> 00:05:41.980 align:middle line:84%
And this is all the
documentation afforded to you.

00:05:41.980 --> 00:05:44.100 align:middle line:84%
So again, I would recommend
going through this

00:05:44.100 --> 00:05:46.770 align:middle line:84%
to get an understanding of
what the various options are.

00:05:46.770 --> 00:05:49.290 align:middle line:84%
I'll be going through some
of the most important ones.

00:05:49.290 --> 00:05:52.680 align:middle line:84%
If you want in-depth
documentation or a guide

00:05:52.680 --> 00:05:55.650 align:middle line:84%
on how to use Netcat, you
can open up the man pages

00:05:55.650 --> 00:05:57.210 align:middle line:90%
for the Netcat tool.

00:05:57.210 --> 00:06:01.170 align:middle line:84%
So that can be done by
typing in man and NC.

00:06:01.170 --> 00:06:03.960 align:middle line:84%
And the man pages
are extremely useful.

00:06:03.960 --> 00:06:06.420 align:middle line:84%
In this case, it'll give you
a description of the tool

00:06:06.420 --> 00:06:10.740 align:middle line:84%
and highlight the various modes
that Netcat can operate in.

00:06:10.740 --> 00:06:13.308 align:middle line:84%
And in terms of the
official nomenclature,

00:06:13.308 --> 00:06:14.850 align:middle line:84%
you can see that
you have the Connect

00:06:14.850 --> 00:06:17.700 align:middle line:84%
mode, which is the
client mode as we

00:06:17.700 --> 00:06:19.050 align:middle line:90%
highlighted in the slides.

00:06:19.050 --> 00:06:22.000 align:middle line:84%
And then, you have your listen
mode, which is the server mode,

00:06:22.000 --> 00:06:22.500 align:middle line:90%
right?

00:06:22.500 --> 00:06:25.980 align:middle line:84%
So again, this is fairly
simple to understand.

00:06:25.980 --> 00:06:29.460 align:middle line:84%
Now, before we get
started with using Netcat

00:06:29.460 --> 00:06:32.400 align:middle line:84%
to connect to a particular
port or to set up a listener,

00:06:32.400 --> 00:06:35.010 align:middle line:84%
let's explore a few
important options

00:06:35.010 --> 00:06:36.480 align:middle line:90%
that you need to be aware of.

00:06:36.480 --> 00:06:39.060 align:middle line:84%
So I'll open up the
Help menu again here.

00:06:39.060 --> 00:06:42.870 align:middle line:84%
And let's get started, firstly,
with the V option, which

00:06:42.870 --> 00:06:44.600 align:middle line:90%
is for verbose output.

00:06:44.600 --> 00:06:48.630 align:middle line:84%
So that is used to provide you
with additional information

00:06:48.630 --> 00:06:50.490 align:middle line:84%
whenever you connect
to a particular port

00:06:50.490 --> 00:06:53.400 align:middle line:84%
or whenever you've
set up a listener.

00:06:53.400 --> 00:06:56.250 align:middle line:84%
And you can see right over here,
set the verbosity level can

00:06:56.250 --> 00:06:58.020 align:middle line:84%
be used several
times to increase

00:06:58.020 --> 00:06:59.670 align:middle line:90%
the level of verbosity.

00:06:59.670 --> 00:07:02.940 align:middle line:84%
So I can say minus VV
for double verbosity,

00:07:02.940 --> 00:07:04.540 align:middle line:90%
et cetera, et cetera.

00:07:04.540 --> 00:07:07.620 align:middle line:84%
The other option here
is the UDP option.

00:07:07.620 --> 00:07:11.970 align:middle line:84%
Now by default, Netcat
will essentially

00:07:11.970 --> 00:07:13.890 align:middle line:90%
connect to a TCP port, right?

00:07:13.890 --> 00:07:16.350 align:middle line:84%
Now, if you ever want
to connect to a UDP port

00:07:16.350 --> 00:07:18.900 align:middle line:84%
or set up a listener
on UDP, then you

00:07:18.900 --> 00:07:22.620 align:middle line:84%
can utilize the U
option to explicitly

00:07:22.620 --> 00:07:25.470 align:middle line:84%
have Netcat connect
to a UDP port

00:07:25.470 --> 00:07:29.380 align:middle line:84%
or to set up a listener on
a UDP port of your choice.

00:07:29.380 --> 00:07:31.710 align:middle line:84%
And we then have
the L option, which

00:07:31.710 --> 00:07:33.810 align:middle line:90%
is used to set up a listener.

00:07:33.810 --> 00:07:36.870 align:middle line:84%
So you can see bind and listen
for incoming connections.

00:07:36.870 --> 00:07:38.800 align:middle line:84%
This may not make
much sense right now,

00:07:38.800 --> 00:07:40.620 align:middle line:84%
but it will in a
couple of minutes.

00:07:40.620 --> 00:07:43.410 align:middle line:84%
You then have your
no DNS option that

00:07:43.410 --> 00:07:48.240 align:middle line:84%
is denoted by the N or hyphen
N. And that will essentially

00:07:48.240 --> 00:07:52.590 align:middle line:84%
disable the actual
DNS resolution of IPs

00:07:52.590 --> 00:07:55.080 align:middle line:90%
into host names and vise versa.

00:07:55.080 --> 00:07:57.330 align:middle line:84%
That's something that can
be quite helpful when you're

00:07:57.330 --> 00:07:58.747 align:middle line:84%
trying to connect
to an IP and you

00:07:58.747 --> 00:08:02.580 align:middle line:84%
want to prevent it from
automatically resolving the IP

00:08:02.580 --> 00:08:05.880 align:middle line:84%
address to a host name or
to a domain name via DNS.

00:08:05.880 --> 00:08:10.040 align:middle line:84%
So that's an option that we'll
also be using quite a bit.

00:08:10.040 --> 00:08:14.270 align:middle line:84%
All right, so those are the
three or four primary options

00:08:14.270 --> 00:08:16.310 align:middle line:90%
that are very, very important.

00:08:16.310 --> 00:08:19.010 align:middle line:84%
One additional
important option that we

00:08:19.010 --> 00:08:21.050 align:middle line:84%
will be exploring
in the next videos

00:08:21.050 --> 00:08:22.940 align:middle line:84%
is the E option,
which allows you

00:08:22.940 --> 00:08:25.400 align:middle line:90%
to execute a specific command.

00:08:25.400 --> 00:08:28.200 align:middle line:84%
And again, you really don't need
to understand this right now,

00:08:28.200 --> 00:08:31.250 align:middle line:84%
but it'll be very, very useful
when we'll be setting up

00:08:31.250 --> 00:08:33.470 align:middle line:90%
a bind shell or reverse shell.

00:08:33.470 --> 00:08:36.080 align:middle line:84%
OK, so now that we have
an understanding of how

00:08:36.080 --> 00:08:38.240 align:middle line:84%
all of this works,
we can get started

00:08:38.240 --> 00:08:42.230 align:middle line:84%
with the first technique or the
first piece of functionality

00:08:42.230 --> 00:08:44.059 align:middle line:90%
that we can perform with Netcat.

00:08:44.059 --> 00:08:46.400 align:middle line:84%
And that is the ability
to connect to ports.

00:08:46.400 --> 00:08:49.430 align:middle line:84%
So we've already explored this
during the banner grabbing

00:08:49.430 --> 00:08:50.190 align:middle line:90%
section.

00:08:50.190 --> 00:08:52.190 align:middle line:84%
And the reason we
were using Netcat

00:08:52.190 --> 00:08:55.670 align:middle line:84%
is, again, it allows us to
connect to a specific TCP

00:08:55.670 --> 00:08:57.530 align:middle line:90%
or UDP port on a target.

00:08:57.530 --> 00:09:00.830 align:middle line:84%
And the output of
that connection

00:09:00.830 --> 00:09:02.282 align:middle line:90%
might be a service banner.

00:09:02.282 --> 00:09:03.740 align:middle line:84%
And that service
banner can be very

00:09:03.740 --> 00:09:06.710 align:middle line:84%
helpful in identifying
vulnerabilities that affect

00:09:06.710 --> 00:09:08.390 align:middle line:90%
that specific service, right?

00:09:08.390 --> 00:09:12.440 align:middle line:84%
So again, in order to
connect to a particular port,

00:09:12.440 --> 00:09:14.750 align:middle line:84%
we can say Netcat and
then the target IP.

00:09:14.750 --> 00:09:18.180 align:middle line:84%
So let's run a test with
the target system here.

00:09:18.180 --> 00:09:21.055 align:middle line:84%
So we can say Netcat,
target IP, and the port

00:09:21.055 --> 00:09:22.430 align:middle line:84%
that we would like
to connect to.

00:09:22.430 --> 00:09:25.310 align:middle line:84%
So for example, we can
connect to port 80, which

00:09:25.310 --> 00:09:30.200 align:middle line:84%
is running a web server who is
used to essentially run or host

00:09:30.200 --> 00:09:31.520 align:middle line:90%
web service.

00:09:31.520 --> 00:09:33.900 align:middle line:90%
In this case, we'll hit Enter.

00:09:33.900 --> 00:09:36.480 align:middle line:84%
And we'll give this
a couple of seconds.

00:09:36.480 --> 00:09:38.580 align:middle line:84%
You can see that we
don't get any output.

00:09:38.580 --> 00:09:39.555 align:middle line:90%
Now, why is that?

00:09:39.555 --> 00:09:42.570 align:middle line:90%


00:09:42.570 --> 00:09:45.990 align:middle line:84%
We don't get the service
banner, and we really

00:09:45.990 --> 00:09:47.050 align:middle line:90%
don't get any output.

00:09:47.050 --> 00:09:49.020 align:middle line:84%
So this is where the
options that I mentioned

00:09:49.020 --> 00:09:50.290 align:middle line:90%
come into play.

00:09:50.290 --> 00:09:53.430 align:middle line:84%
So in order to
specify an option,

00:09:53.430 --> 00:09:55.080 align:middle line:84%
we need to use
the hyphen option.

00:09:55.080 --> 00:09:58.910 align:middle line:84%
And we can say, in this
case, let us perform

00:09:58.910 --> 00:10:00.650 align:middle line:90%
or disable DNS resolution.

00:10:00.650 --> 00:10:02.460 align:middle line:90%
So we can use the N option.

00:10:02.460 --> 00:10:04.940 align:middle line:84%
And if we want additional
information regarding what's

00:10:04.940 --> 00:10:07.910 align:middle line:84%
going on with the connection
we can use the verbose option

00:10:07.910 --> 00:10:10.230 align:middle line:84%
to display additional
information.

00:10:10.230 --> 00:10:13.190 align:middle line:84%
Now this is the typical way
you can list out the options

00:10:13.190 --> 00:10:17.630 align:middle line:84%
that you'd like to specify
or use with a Netcat command

00:10:17.630 --> 00:10:19.130 align:middle line:90%
or when running Netcat.

00:10:19.130 --> 00:10:23.960 align:middle line:84%
However, it is also recommended
to, essentially, combine

00:10:23.960 --> 00:10:28.610 align:middle line:84%
all the options that you'd
like to use when running Netcat

00:10:28.610 --> 00:10:32.090 align:middle line:84%
into one so you don't have to
specify the hyphen every time

00:10:32.090 --> 00:10:33.830 align:middle line:90%
or for each single option.

00:10:33.830 --> 00:10:36.450 align:middle line:84%
So I can say, for
example, in this case,

00:10:36.450 --> 00:10:42.230 align:middle line:84%
I can say Netcat and then hyphen
N and V for no DNS resolution

00:10:42.230 --> 00:10:43.980 align:middle line:90%
and verbose output.

00:10:43.980 --> 00:10:46.950 align:middle line:84%
So I can hit Enter, and
you'll see the difference.

00:10:46.950 --> 00:10:49.790 align:middle line:84%
So you can see in this case,
it displays the Netcat version

00:10:49.790 --> 00:10:50.360 align:middle line:90%
being used.

00:10:50.360 --> 00:10:53.180 align:middle line:84%
And indeed, the important
piece of information

00:10:53.180 --> 00:10:57.170 align:middle line:84%
that it provides us here is
the actual connection status.

00:10:57.170 --> 00:10:59.360 align:middle line:84%
So you can see it says,
connected to the target

00:10:59.360 --> 00:11:00.110 align:middle line:90%
on port 80.

00:11:00.110 --> 00:11:03.290 align:middle line:84%
Whereas, previously, we didn't
know what was happening.

00:11:03.290 --> 00:11:04.940 align:middle line:84%
Now, again, it
doesn't always have

00:11:04.940 --> 00:11:06.380 align:middle line:90%
to provide you with a banner.

00:11:06.380 --> 00:11:09.740 align:middle line:84%
As I said, that's just one of
the great features of Netcat

00:11:09.740 --> 00:11:12.290 align:middle line:84%
is that it can be used
for banner grabbing.

00:11:12.290 --> 00:11:14.450 align:middle line:84%
This particular feature
or functionality

00:11:14.450 --> 00:11:17.990 align:middle line:84%
will come into play when we'll
be setting up an actual Netcat

00:11:17.990 --> 00:11:19.310 align:middle line:90%
listener, right?

00:11:19.310 --> 00:11:23.940 align:middle line:84%
So you can connect to a
particular port this way.

00:11:23.940 --> 00:11:26.460 align:middle line:84%
And of course, you can connect
to any port that you want.

00:11:26.460 --> 00:11:29.630 align:middle line:84%
So for example, if we
try and target port--

00:11:29.630 --> 00:11:33.650 align:middle line:84%
let's see if we have an FTP
server running on the target.

00:11:33.650 --> 00:11:35.150 align:middle line:90%
You can see connection refused.

00:11:35.150 --> 00:11:37.460 align:middle line:84%
That tells us that
that port is closed.

00:11:37.460 --> 00:11:39.560 align:middle line:84%
And this is one of
the ways Netcat can be

00:11:39.560 --> 00:11:41.240 align:middle line:90%
used to perform port scanning.

00:11:41.240 --> 00:11:43.920 align:middle line:84%
And again, the results
are quite conclusive.

00:11:43.920 --> 00:11:46.190 align:middle line:84%
So for example, if
we wanted to check

00:11:46.190 --> 00:11:48.410 align:middle line:84%
whether SSH was
installed on the target,

00:11:48.410 --> 00:11:50.420 align:middle line:90%
we can change it to port 22.

00:11:50.420 --> 00:11:51.960 align:middle line:90%
You can see connection refused.

00:11:51.960 --> 00:11:55.580 align:middle line:84%
Now, that may not indicate
that a service may not

00:11:55.580 --> 00:11:57.230 align:middle line:90%
be running on that port.

00:11:57.230 --> 00:11:59.180 align:middle line:84%
There could be a
firewall in place

00:11:59.180 --> 00:12:02.300 align:middle line:84%
that's proxying or filtering
the actual request.

00:12:02.300 --> 00:12:05.000 align:middle line:84%
So do take that
into consideration.

00:12:05.000 --> 00:12:07.340 align:middle line:84%
If we want to connect
to a UDP port,

00:12:07.340 --> 00:12:10.010 align:middle line:84%
we can essentially
say or add that option

00:12:10.010 --> 00:12:14.720 align:middle line:84%
to our already existing list of
options, which is NVU for UDP.

00:12:14.720 --> 00:12:16.580 align:middle line:84%
And we can connect
to a UDP port.

00:12:16.580 --> 00:12:20.300 align:middle line:84%
Maybe let's try and
connect to, for example,

00:12:20.300 --> 00:12:22.700 align:middle line:90%
139, for example there.

00:12:22.700 --> 00:12:24.290 align:middle line:90%
And you can see that connects.

00:12:24.290 --> 00:12:29.030 align:middle line:84%
If we try and connect to port
445, you can see connected.

00:12:29.030 --> 00:12:32.782 align:middle line:84%
We can try and connect
to, maybe, 161.

00:12:32.782 --> 00:12:35.590 align:middle line:84%
Connected, and so on
and so forth, right?

00:12:35.590 --> 00:12:39.460 align:middle line:84%
So that is how to connect
to both TCP and UDP ports.

00:12:39.460 --> 00:12:42.550 align:middle line:84%
And as I said, this is currently
operating in the client mode.

00:12:42.550 --> 00:12:45.850 align:middle line:84%
Remember, we are
connecting to other ports.

00:12:45.850 --> 00:12:48.670 align:middle line:84%
And in this particular
scenario, we

00:12:48.670 --> 00:12:52.040 align:middle line:84%
have essentially been
operating in the client mode.

00:12:52.040 --> 00:12:55.240 align:middle line:84%
So that is how to
connect to ports.

00:12:55.240 --> 00:12:59.200 align:middle line:84%
As I said, you can connect
to both TCP and UDP ports.

00:12:59.200 --> 00:13:02.080 align:middle line:84%
Now let's move on to
the next technique

00:13:02.080 --> 00:13:03.760 align:middle line:90%
that I wanted to highlight here.

00:13:03.760 --> 00:13:06.400 align:middle line:84%
And that is the ability
to listen or to set up

00:13:06.400 --> 00:13:10.010 align:middle line:84%
a listener on a specific
TCP or UDP port.

00:13:10.010 --> 00:13:12.040 align:middle line:84%
Now, in order to
showcase this, we

00:13:12.040 --> 00:13:15.350 align:middle line:84%
are going to need a client
system and a service system.

00:13:15.350 --> 00:13:17.950 align:middle line:84%
So again, that's why we
have two systems here.

00:13:17.950 --> 00:13:20.540 align:middle line:84%
And we are going to be
utilizing both of them.

00:13:20.540 --> 00:13:24.730 align:middle line:84%
So what I need to do firstly is
transfer the Netcat executable

00:13:24.730 --> 00:13:26.830 align:middle line:84%
file onto the Windows
system because Windows

00:13:26.830 --> 00:13:28.900 align:middle line:90%
doesn't come preinstalled--

00:13:28.900 --> 00:13:30.610 align:middle line:84%
or Netcat doesn't
come preinstalled

00:13:30.610 --> 00:13:32.030 align:middle line:90%
on a Windows system.

00:13:32.030 --> 00:13:34.450 align:middle line:84%
So again, you might
be asking yourself,

00:13:34.450 --> 00:13:36.820 align:middle line:84%
the lab environment doesn't
have any internet access.

00:13:36.820 --> 00:13:39.610 align:middle line:84%
Where can I get the Netcat
executable for Windows?

00:13:39.610 --> 00:13:41.920 align:middle line:84%
Well, this is the great
thing about Kali Linux

00:13:41.920 --> 00:13:46.930 align:middle line:84%
is it's already available in a
folder under user share Windows

00:13:46.930 --> 00:13:49.170 align:middle line:90%
binaries.

00:13:49.170 --> 00:13:51.430 align:middle line:84%
And if I list all the
contents of this directory,

00:13:51.430 --> 00:13:53.520 align:middle line:90%
you can see we have Netcat.exe.

00:13:53.520 --> 00:13:54.300 align:middle line:90%
Fantastic.

00:13:54.300 --> 00:13:56.460 align:middle line:84%
So you might be
asking yourself again,

00:13:56.460 --> 00:13:59.490 align:middle line:84%
how do we transfer this
executable onto the target?

00:13:59.490 --> 00:14:00.630 align:middle line:90%
Well, there's two ways.

00:14:00.630 --> 00:14:05.490 align:middle line:84%
We can set up a web server to
host this particular executable

00:14:05.490 --> 00:14:08.380 align:middle line:84%
and then download it on the
target system via the browser,

00:14:08.380 --> 00:14:11.520 align:middle line:84%
or we can set up a web server
to host this executable

00:14:11.520 --> 00:14:13.590 align:middle line:84%
and then download it
via the command prompt.

00:14:13.590 --> 00:14:16.330 align:middle line:84%
So I'll actually take you
through that process right now.

00:14:16.330 --> 00:14:19.680 align:middle line:84%
So what I'll do is I'll just
navigate to this directory

00:14:19.680 --> 00:14:20.680 align:middle line:90%
here.

00:14:20.680 --> 00:14:22.710 align:middle line:90%
And I'll just say CD.

00:14:22.710 --> 00:14:23.310 align:middle line:90%
There we are.

00:14:23.310 --> 00:14:26.550 align:middle line:84%
And I'll set up a web
server to host all the files

00:14:26.550 --> 00:14:27.870 align:middle line:90%
within this directory.

00:14:27.870 --> 00:14:29.700 align:middle line:84%
And in order to
do that, I'm going

00:14:29.700 --> 00:14:32.130 align:middle line:84%
to be using a
Python module called

00:14:32.130 --> 00:14:36.370 align:middle line:84%
simple HTTP server, which we
used in the previous section--

00:14:36.370 --> 00:14:39.000 align:middle line:90%
so simple HTTP server.

00:14:39.000 --> 00:14:41.890 align:middle line:84%
And we'll say we want
to host it on port 80.

00:14:41.890 --> 00:14:42.750 align:middle line:90%
So all it Enter.

00:14:42.750 --> 00:14:45.690 align:middle line:84%
It's now going to serve all the
files within user share Windows

00:14:45.690 --> 00:14:49.680 align:middle line:84%
binaries on port 80 on the
Kali Linux IP address, right?

00:14:49.680 --> 00:14:51.240 align:middle line:90%
So we've set up a web server.

00:14:51.240 --> 00:14:54.310 align:middle line:84%
We can now. download it
onto the target system.

00:14:54.310 --> 00:14:57.210 align:middle line:84%
But before we do that, we
need our Kali Linux IP.

00:14:57.210 --> 00:14:58.980 align:middle line:90%
So I can say ifconfig.

00:14:58.980 --> 00:15:01.957 align:middle line:84%
And my IP address is on
the interface ethernet 1.

00:15:01.957 --> 00:15:04.290 align:middle line:84%
And of course, in your case,
it's going to be different.

00:15:04.290 --> 00:15:09.278 align:middle line:84%
Just copy the value associated
to the Inet option there.

00:15:09.278 --> 00:15:10.820 align:middle line:84%
Let's head over to
the target system.

00:15:10.820 --> 00:15:12.320 align:middle line:84%
As I said, there
are two techniques.

00:15:12.320 --> 00:15:14.210 align:middle line:84%
We can open up
Firefox here and then

00:15:14.210 --> 00:15:16.700 align:middle line:84%
navigate to the Kali
Linux IP address

00:15:16.700 --> 00:15:18.750 align:middle line:84%
where the web server
is being hosted.

00:15:18.750 --> 00:15:21.470 align:middle line:84%
And we can then download
the file directly

00:15:21.470 --> 00:15:22.470 align:middle line:90%
through the browser.

00:15:22.470 --> 00:15:25.160 align:middle line:84%
So I'll just wait for
Firefox to open up.

00:15:25.160 --> 00:15:26.930 align:middle line:84%
As I said, this is
running in a VM,

00:15:26.930 --> 00:15:28.940 align:middle line:84%
so it may take a
couple of seconds.

00:15:28.940 --> 00:15:31.880 align:middle line:84%
Alternatively, what we could
do is open up a command

00:15:31.880 --> 00:15:32.660 align:middle line:90%
prompt session.

00:15:32.660 --> 00:15:35.370 align:middle line:90%
So I'll just type in CMD.

00:15:35.370 --> 00:15:38.460 align:middle line:90%
And I'll just open this up here.

00:15:38.460 --> 00:15:40.210 align:middle line:84%
And it looks like
Firefox is open,

00:15:40.210 --> 00:15:44.400 align:middle line:84%
so we'll take a look at how
to do it with Firefox first.

00:15:44.400 --> 00:15:47.040 align:middle line:84%
But it doesn't look like
the window has actually

00:15:47.040 --> 00:15:50.130 align:middle line:84%
been scaled correctly, so
we'll just close that up.

00:15:50.130 --> 00:15:52.360 align:middle line:84%
And we'll utilize the
command prompt technique.

00:15:52.360 --> 00:15:54.270 align:middle line:84%
So we'll click on
Properties here

00:15:54.270 --> 00:15:57.160 align:middle line:84%
because I want you to be
able to see what's going on.

00:15:57.160 --> 00:15:59.760 align:middle line:84%
So I'll increase
the size here to,

00:15:59.760 --> 00:16:02.550 align:middle line:84%
maybe, something-- the
highest size there.

00:16:02.550 --> 00:16:06.450 align:middle line:84%
And we can then change
the font to console us.

00:16:06.450 --> 00:16:10.080 align:middle line:84%
And in terms of the layout
and the actual color,

00:16:10.080 --> 00:16:12.408 align:middle line:84%
I'll change that to--
the screen background,

00:16:12.408 --> 00:16:14.700 align:middle line:84%
I'll change it to white so
you can see what's going on.

00:16:14.700 --> 00:16:18.600 align:middle line:84%
And the screen text, I'll
change that to black.

00:16:18.600 --> 00:16:21.630 align:middle line:84%
OK, and it doesn't look like
the font size has been changed.

00:16:21.630 --> 00:16:25.528 align:middle line:90%
So font-- there we are.

00:16:25.528 --> 00:16:26.820 align:middle line:90%
And we can click on that there.

00:16:26.820 --> 00:16:27.450 align:middle line:90%
Fantastic.

00:16:27.450 --> 00:16:29.910 align:middle line:84%
So you should be able to
see what's going on now.

00:16:29.910 --> 00:16:31.720 align:middle line:84%
And we have the
command prompt session.

00:16:31.720 --> 00:16:35.132 align:middle line:84%
So how do I download a file
from the Kali Linux system

00:16:35.132 --> 00:16:36.090 align:middle line:90%
through command prompt?

00:16:36.090 --> 00:16:37.560 align:middle line:84%
Well, I navigate
to the directory

00:16:37.560 --> 00:16:39.300 align:middle line:84%
where I would like
to save the file.

00:16:39.300 --> 00:16:40.890 align:middle line:90%
I'll do this on my desktop.

00:16:40.890 --> 00:16:43.800 align:middle line:84%
I can utilize a tool
that comes prepackaged

00:16:43.800 --> 00:16:48.240 align:middle line:84%
with pretty much all versions of
Windows and that is cert util.

00:16:48.240 --> 00:16:53.820 align:middle line:84%
And we'll say we want to use the
URL cache option and the file

00:16:53.820 --> 00:16:54.420 align:middle line:90%
option.

00:16:54.420 --> 00:16:57.400 align:middle line:84%
We then specify the
address of the web server--

00:16:57.400 --> 00:17:02.640 align:middle line:84%
so HTTP and then we paste in
the target IP address like so.

00:17:02.640 --> 00:17:06.270 align:middle line:84%
And we are downloading
the file called NC.exe.

00:17:06.270 --> 00:17:10.470 align:middle line:84%
And then, we are going to save
it as NC.exe on the desktop.

00:17:10.470 --> 00:17:11.918 align:middle line:90%
So I'll hit Enter.

00:17:11.918 --> 00:17:13.710 align:middle line:84%
And you can see, it'll
say right over here,

00:17:13.710 --> 00:17:17.010 align:middle line:84%
cert util URL cache command
completed successfully.

00:17:17.010 --> 00:17:19.349 align:middle line:84%
And Netcat has been
downloaded onto our desktop

00:17:19.349 --> 00:17:21.069 align:middle line:90%
as we can see right over here.

00:17:21.069 --> 00:17:25.770 align:middle line:84%
So we can test it out we
can say Netcat.exe and help.

00:17:25.770 --> 00:17:28.200 align:middle line:84%
And you can see Netcat
has been set up.

00:17:28.200 --> 00:17:29.100 align:middle line:90%
Fantastic.

00:17:29.100 --> 00:17:31.350 align:middle line:84%
All right, so now that
we have Netcat set up

00:17:31.350 --> 00:17:34.320 align:middle line:84%
on the Windows system,
what we need to do

00:17:34.320 --> 00:17:37.800 align:middle line:84%
is let's actually terminate
the web server there.

00:17:37.800 --> 00:17:41.440 align:middle line:84%
And I'll navigate to the
desktop on Kali Linux.

00:17:41.440 --> 00:17:45.210 align:middle line:84%
And we can get started
with setting up a listener.

00:17:45.210 --> 00:17:47.490 align:middle line:84%
So we can set up a
listener on both systems.

00:17:47.490 --> 00:17:49.500 align:middle line:84%
It doesn't really
matter what system

00:17:49.500 --> 00:17:51.070 align:middle line:90%
you set up a listener on.

00:17:51.070 --> 00:17:54.790 align:middle line:84%
So let's start off
with our first example.

00:17:54.790 --> 00:17:56.940 align:middle line:84%
We can set up the
listener on Kali Linux.

00:17:56.940 --> 00:17:58.200 align:middle line:90%
So I'll say Netcat.

00:17:58.200 --> 00:17:59.910 align:middle line:84%
And the option
that we want to use

00:17:59.910 --> 00:18:03.300 align:middle line:84%
is NV-- so no DNS
resolution, verbose output.

00:18:03.300 --> 00:18:08.730 align:middle line:84%
We want to listen on port
1234, for example, right?

00:18:08.730 --> 00:18:11.340 align:middle line:84%
And the L option, as I
said, is for listening.

00:18:11.340 --> 00:18:13.710 align:middle line:84%
And the P option allows
you to specify the port

00:18:13.710 --> 00:18:16.810 align:middle line:84%
that you'd like to listen
on the Kali Linux system.

00:18:16.810 --> 00:18:18.540 align:middle line:90%
So I'll hit Enter.

00:18:18.540 --> 00:18:20.220 align:middle line:84%
And you can see
right over here, it's

00:18:20.220 --> 00:18:23.130 align:middle line:84%
going to say Netcat is
listening on port 1234.

00:18:23.130 --> 00:18:26.670 align:middle line:84%
So that means we can now utilize
Netcat on the Windows system

00:18:26.670 --> 00:18:29.970 align:middle line:84%
to connect to the actual
listener on the Kali Linux

00:18:29.970 --> 00:18:30.550 align:middle line:90%
system.

00:18:30.550 --> 00:18:34.980 align:middle line:84%
So again, all I need really
is the actual Kali Linux IP.

00:18:34.980 --> 00:18:36.870 align:middle line:84%
So I'll head over
back to Windows,

00:18:36.870 --> 00:18:39.940 align:middle line:84%
and I'll just clear out
the command prompt here.

00:18:39.940 --> 00:18:41.910 align:middle line:90%
So we'll say Netcat.exe.

00:18:41.910 --> 00:18:45.030 align:middle line:84%
And in order to connect to a
listener as we've already done

00:18:45.030 --> 00:18:47.610 align:middle line:84%
or to any port for
that matter, we use NV.

00:18:47.610 --> 00:18:51.720 align:middle line:84%
We then specify the target IP,
which I'll paste in there--

00:18:51.720 --> 00:18:53.130 align:middle line:90%
this is the Kali Linux IP--

00:18:53.130 --> 00:18:55.350 align:middle line:84%
And then the port that we
would like to connect to,

00:18:55.350 --> 00:18:57.900 align:middle line:90%
which in this case is 1234.

00:18:57.900 --> 00:18:58.950 align:middle line:90%
Hit Enter.

00:18:58.950 --> 00:19:01.300 align:middle line:84%
And it's going to
say unknown here.

00:19:01.300 --> 00:19:03.750 align:middle line:84%
However, if we take a look
at the Kali Linux system,

00:19:03.750 --> 00:19:07.200 align:middle line:84%
you can see that we get a
connection from the Windows

00:19:07.200 --> 00:19:07.920 align:middle line:90%
system.

00:19:07.920 --> 00:19:10.230 align:middle line:84%
And that is how to
set up a listener

00:19:10.230 --> 00:19:12.473 align:middle line:84%
and how clients can
connect to a listener.

00:19:12.473 --> 00:19:14.140 align:middle line:84%
Now, you might be
asking yourself, well,

00:19:14.140 --> 00:19:16.260 align:middle line:90%
why is this important?

00:19:16.260 --> 00:19:18.690 align:middle line:84%
You know, I don't really see
what the point of this is.

00:19:18.690 --> 00:19:19.810 align:middle line:90%
What are we doing here?

00:19:19.810 --> 00:19:22.080 align:middle line:84%
Are we just connecting
two systems together?

00:19:22.080 --> 00:19:24.990 align:middle line:84%
Well, this will
make much more sense

00:19:24.990 --> 00:19:28.050 align:middle line:84%
when we'll actually be
exploring the process of how

00:19:28.050 --> 00:19:31.980 align:middle line:84%
to use Netcat to obtain a
bind shell or a reverse shell.

00:19:31.980 --> 00:19:35.160 align:middle line:84%
Now, what you can do to test
that this connection is active

00:19:35.160 --> 00:19:39.120 align:middle line:84%
is we can perform a really,
really fun exercise here.

00:19:39.120 --> 00:19:42.360 align:middle line:84%
When you have
connected a listener--

00:19:42.360 --> 00:19:47.100 align:middle line:84%
when you've connected the Netcat
client to a Netcat listener,

00:19:47.100 --> 00:19:50.170 align:middle line:84%
you can essentially send
messages across the connection.

00:19:50.170 --> 00:19:53.130 align:middle line:84%
So for example,
I can say, hello.

00:19:53.130 --> 00:19:54.690 align:middle line:84%
And if I go to
the target system,

00:19:54.690 --> 00:19:57.380 align:middle line:84%
you can see hello has been
transferred-- really, really

00:19:57.380 --> 00:19:57.880 align:middle line:90%
cool.

00:19:57.880 --> 00:20:01.110 align:middle line:84%
So I can also do this
from the window side.

00:20:01.110 --> 00:20:02.850 align:middle line:90%
So I can say--

00:20:02.850 --> 00:20:07.420 align:middle line:84%
we can say, for example,
Netcat is awesome.

00:20:07.420 --> 00:20:10.970 align:middle line:84%
Hit Enter, and you can see that
information is transferred.

00:20:10.970 --> 00:20:15.220 align:middle line:84%
So you might be getting an
idea of how useful Netcat is

00:20:15.220 --> 00:20:17.380 align:middle line:84%
and how useful the
Netcat listener

00:20:17.380 --> 00:20:21.310 align:middle line:84%
mode is in terms of
transferring files, transferring

00:20:21.310 --> 00:20:25.570 align:middle line:84%
messages, establishing remote
access to a target system, et

00:20:25.570 --> 00:20:26.830 align:middle line:90%
cetera, et cetera.

00:20:26.830 --> 00:20:28.330 align:middle line:84%
All right, so again,
I'm just going

00:20:28.330 --> 00:20:30.280 align:middle line:84%
to go through this
now and set up

00:20:30.280 --> 00:20:33.257 align:middle line:84%
the listener on the
actual Windows system.

00:20:33.257 --> 00:20:34.840 align:middle line:84%
So I'll terminate
that Netcat listener

00:20:34.840 --> 00:20:36.610 align:middle line:90%
on the Kali Linux system.

00:20:36.610 --> 00:20:39.150 align:middle line:84%
And you can see it's already
been terminated on the Windows

00:20:39.150 --> 00:20:39.650 align:middle line:90%
system.

00:20:39.650 --> 00:20:41.350 align:middle line:84%
So again, just
repeat the process.

00:20:41.350 --> 00:20:45.640 align:middle line:84%
We can say net
Netcat.exe NVLP 1234.

00:20:45.640 --> 00:20:49.700 align:middle line:84%
That'll set up the listener
on the Windows system.

00:20:49.700 --> 00:20:50.680 align:middle line:90%
So I'll hit Enter.

00:20:50.680 --> 00:20:53.560 align:middle line:84%
As you can see,
listening on port 1234.

00:20:53.560 --> 00:20:57.700 align:middle line:84%
And then I can connect to the
target system with Netcat.

00:20:57.700 --> 00:20:59.980 align:middle line:90%
So I'll just copy the target IP.

00:20:59.980 --> 00:21:04.720 align:middle line:84%
I can then say NV target
IP and the port 1234.

00:21:04.720 --> 00:21:05.440 align:middle line:90%
Hit Enter.

00:21:05.440 --> 00:21:07.060 align:middle line:90%
As you can see, connected.

00:21:07.060 --> 00:21:09.220 align:middle line:84%
And on the Windows system,
it gets a connection

00:21:09.220 --> 00:21:10.790 align:middle line:90%
from the Kali Linux system.

00:21:10.790 --> 00:21:15.370 align:middle line:84%
So again, I can type
in a simple message.

00:21:15.370 --> 00:21:18.820 align:middle line:90%
Hello, how are you?

00:21:18.820 --> 00:21:20.120 align:middle line:90%
And there we are.

00:21:20.120 --> 00:21:22.310 align:middle line:90%
So that is really, really cool.

00:21:22.310 --> 00:21:24.160 align:middle line:84%
So again, as you can
see, it doesn't really

00:21:24.160 --> 00:21:26.170 align:middle line:84%
matter what operating
system you're working on.

00:21:26.170 --> 00:21:31.250 align:middle line:84%
Netcat works exactly the same,
which is very, very important.

00:21:31.250 --> 00:21:35.020 align:middle line:84%
So now that we've taken a look
at how to set up a listener,

00:21:35.020 --> 00:21:37.340 align:middle line:84%
we can move on to
the next example.

00:21:37.340 --> 00:21:40.090 align:middle line:84%
However, I also want to
cover one little caveat.

00:21:40.090 --> 00:21:43.480 align:middle line:84%
As I said, if you want to set
up a Netcat listener on a UDP

00:21:43.480 --> 00:21:45.560 align:middle line:90%
port, you can do that as well.

00:21:45.560 --> 00:21:49.620 align:middle line:84%
So let's take a look at
a simple example here.

00:21:49.620 --> 00:21:53.390 align:middle line:84%
So if we wanted to set up a
Netcat listener on a UDP port,

00:21:53.390 --> 00:21:55.230 align:middle line:90%
the process is exactly the same.

00:21:55.230 --> 00:21:57.920 align:middle line:84%
The only option you're
specifying is the U option.

00:21:57.920 --> 00:22:00.500 align:middle line:84%
So if we wanted to set up a
listener on the Kali Linux

00:22:00.500 --> 00:22:04.340 align:middle line:84%
system, we can
say Netcat NVL UP.

00:22:04.340 --> 00:22:06.410 align:middle line:84%
Make sure that the U
option is specified

00:22:06.410 --> 00:22:08.450 align:middle line:84%
before the port
option as that is

00:22:08.450 --> 00:22:10.430 align:middle line:84%
where we specify the
actual port that we

00:22:10.430 --> 00:22:11.430 align:middle line:90%
would like to listen on.

00:22:11.430 --> 00:22:14.660 align:middle line:84%
So in this case, I'm
saying, Netcat, I

00:22:14.660 --> 00:22:19.070 align:middle line:84%
want you to set up a
listener on UDP port 1234.

00:22:19.070 --> 00:22:22.640 align:middle line:84%
I hit Enter, and that has
set it up on port 1234.

00:22:22.640 --> 00:22:25.370 align:middle line:84%
Now, if we head over
to the Windows system--

00:22:25.370 --> 00:22:30.080 align:middle line:84%
and let's try and connect to
that particular port on TCP

00:22:30.080 --> 00:22:31.610 align:middle line:84%
to show you that
it doesn't work.

00:22:31.610 --> 00:22:38.910 align:middle line:84%
So Netcat.exe NV, and let's
get the Kali Linux IP here.

00:22:38.910 --> 00:22:41.720 align:middle line:84%
So let me just open up a
terminal really quickly.

00:22:41.720 --> 00:22:45.690 align:middle line:84%
Ifconfig, and I'll
copy that there,

00:22:45.690 --> 00:22:49.830 align:middle line:84%
and we can head back over in
here, paste that in there,

00:22:49.830 --> 00:22:51.160 align:middle line:90%
and 1234.

00:22:51.160 --> 00:22:53.940 align:middle line:84%
So remember, I've not specified
that we are connecting to a UDP

00:22:53.940 --> 00:22:56.250 align:middle line:84%
port, and Netcat is
going to assume that I

00:22:56.250 --> 00:22:58.240 align:middle line:90%
want to connect to a TCP port.

00:22:58.240 --> 00:23:02.650 align:middle line:84%
So I'll it Enter, and you
can see connection refused.

00:23:02.650 --> 00:23:05.500 align:middle line:84%
And that, again, shows you
that Netcat does indeed

00:23:05.500 --> 00:23:06.940 align:middle line:90%
follow your instructions.

00:23:06.940 --> 00:23:09.370 align:middle line:84%
So we can connect
to the UDP port

00:23:09.370 --> 00:23:14.960 align:middle line:84%
by saying Netcat NVU,
hit Enter, and we are now

00:23:14.960 --> 00:23:20.900 align:middle line:84%
able to connect to the actual
Netcat listener on the UDP port

00:23:20.900 --> 00:23:22.730 align:middle line:84%
that it is currently
listening on.

00:23:22.730 --> 00:23:25.820 align:middle line:84%
And again, the process
is exactly the same.

00:23:25.820 --> 00:23:29.090 align:middle line:84%
If I can actually
type that in there,

00:23:29.090 --> 00:23:30.800 align:middle line:84%
you can see that
indeed does work.

00:23:30.800 --> 00:23:34.150 align:middle line:84%
So we head over to
the target system.

00:23:34.150 --> 00:23:35.710 align:middle line:90%
We may not receive information.

00:23:35.710 --> 00:23:37.540 align:middle line:84%
And that comes
down to the fact--

00:23:37.540 --> 00:23:41.780 align:middle line:84%
or this really comes down to
the fact to how UDP works.

00:23:41.780 --> 00:23:44.620 align:middle line:84%
So again, that's
just in case you ever

00:23:44.620 --> 00:23:48.770 align:middle line:84%
wanted to set up a
listener on a UDP port.

00:23:48.770 --> 00:23:52.990 align:middle line:84%
So that is how to set up
a listener with Netcat

00:23:52.990 --> 00:23:55.720 align:middle line:90%
on both TCP and UDP.

00:23:55.720 --> 00:23:58.270 align:middle line:84%
And we've already taken a look
at how to transfer messages.

00:23:58.270 --> 00:24:00.700 align:middle line:84%
Let's end the
practical demonstration

00:24:00.700 --> 00:24:05.110 align:middle line:84%
by taking a look at a very,
very important feature

00:24:05.110 --> 00:24:08.350 align:middle line:84%
or a piece of functionality
that Netcat allows you to do.

00:24:08.350 --> 00:24:12.010 align:middle line:84%
And that will involves
setting up a listener

00:24:12.010 --> 00:24:13.900 align:middle line:84%
and then connecting
to that listener.

00:24:13.900 --> 00:24:17.560 align:middle line:84%
And that, of course, is how
to transfer files with Netcat.

00:24:17.560 --> 00:24:19.930 align:middle line:84%
Now, in order to transfer
files with Netcat,

00:24:19.930 --> 00:24:22.810 align:middle line:84%
you will need to use your
redirection symbols, which

00:24:22.810 --> 00:24:25.360 align:middle line:84%
are the greater than
and less than symbols.

00:24:25.360 --> 00:24:28.060 align:middle line:84%
I'm sure you're
aware of them, right?

00:24:28.060 --> 00:24:32.170 align:middle line:84%
And in order to transfer a file
from one system to the other,

00:24:32.170 --> 00:24:34.870 align:middle line:84%
you need to have a
listener that is going

00:24:34.870 --> 00:24:37.250 align:middle line:90%
to receive the actual file.

00:24:37.250 --> 00:24:39.760 align:middle line:84%
So remember, the
system that you want

00:24:39.760 --> 00:24:42.070 align:middle line:84%
to transfer the file
to needs to have

00:24:42.070 --> 00:24:43.960 align:middle line:90%
the Netcat listener set up.

00:24:43.960 --> 00:24:47.140 align:middle line:84%
And the system that
is sending the file

00:24:47.140 --> 00:24:49.640 align:middle line:84%
will be connecting to
that Netcat listener.

00:24:49.640 --> 00:24:53.590 align:middle line:84%
So let's say I wanted to
transfer a file from the Kali

00:24:53.590 --> 00:24:56.660 align:middle line:84%
Linux system onto the Windows
system, how would I do that?

00:24:56.660 --> 00:24:58.550 align:middle line:84%
Well, first let's
create the file.

00:24:58.550 --> 00:25:01.090 align:middle line:84%
So I'll create a
text file with Vim.

00:25:01.090 --> 00:25:04.650 align:middle line:90%
So I'll say vimtest.txt.

00:25:04.650 --> 00:25:09.600 align:middle line:84%
And I'll say, hello,
this was sent over

00:25:09.600 --> 00:25:12.060 align:middle line:90%
with Netcat, all right?

00:25:12.060 --> 00:25:13.410 align:middle line:90%
Wrtie in quit.

00:25:13.410 --> 00:25:13.980 align:middle line:90%
There we are.

00:25:13.980 --> 00:25:15.750 align:middle line:84%
So if I wanted to
send it, I would

00:25:15.750 --> 00:25:19.530 align:middle line:84%
need to set up the actual
listener on Windows first

00:25:19.530 --> 00:25:20.320 align:middle line:90%
to receive it.

00:25:20.320 --> 00:25:22.050 align:middle line:90%
So I'm currently on my desktop.

00:25:22.050 --> 00:25:26.190 align:middle line:84%
In order to do this, I'll
say Netcat.exe, right?

00:25:26.190 --> 00:25:28.050 align:middle line:84%
And I would then
specify the port

00:25:28.050 --> 00:25:31.710 align:middle line:84%
that I would like to
listen on-- so NVLP 1234.

00:25:31.710 --> 00:25:34.530 align:middle line:84%
I then use my
redirection symbols.

00:25:34.530 --> 00:25:36.750 align:middle line:84%
And in this case, because
this is the system that's

00:25:36.750 --> 00:25:38.670 align:middle line:84%
receiving the
file, we are saving

00:25:38.670 --> 00:25:42.807 align:middle line:84%
anything that is sent
by a client into a file.

00:25:42.807 --> 00:25:44.640 align:middle line:84%
And in this case, we'll
just call the file--

00:25:44.640 --> 00:25:47.130 align:middle line:84%
or we'll just give the file
name the same that we did

00:25:47.130 --> 00:25:48.370 align:middle line:90%
on the Kali system--

00:25:48.370 --> 00:25:52.360 align:middle line:90%
so test.txt-- and we hit Enter.

00:25:52.360 --> 00:25:53.650 align:middle line:90%
So it's going to listen.

00:25:53.650 --> 00:25:57.350 align:middle line:84%
And now, in order to send
the contents of test.txt

00:25:57.350 --> 00:26:00.610 align:middle line:84%
onto the Windows system, we need
to connect to that listener.

00:26:00.610 --> 00:26:05.950 align:middle line:84%
So we say Netcat NV, and then
we need the actual Windows IP--

00:26:05.950 --> 00:26:08.710 align:middle line:90%
so I'll copy that there--

00:26:08.710 --> 00:26:10.370 align:middle line:90%
and the port.

00:26:10.370 --> 00:26:13.240 align:middle line:84%
Now, one thing remains,
and that is the file

00:26:13.240 --> 00:26:15.010 align:middle line:90%
that we would like to send over.

00:26:15.010 --> 00:26:19.960 align:middle line:84%
In order to specify the file,
we use the actual less than

00:26:19.960 --> 00:26:23.440 align:middle line:84%
symbol, and we
then say test.txt--

00:26:23.440 --> 00:26:24.820 align:middle line:90%
that's the file we created.

00:26:24.820 --> 00:26:27.520 align:middle line:84%
Hit Enter, and you can
see right over here,

00:26:27.520 --> 00:26:30.520 align:middle line:84%
it connects, and it'll
say 38 bytes sent.

00:26:30.520 --> 00:26:32.740 align:middle line:84%
And if we take a look
at the target system,

00:26:32.740 --> 00:26:35.020 align:middle line:84%
it does not give us any
information regarding

00:26:35.020 --> 00:26:38.440 align:middle line:84%
whether or not a file
was actually saved

00:26:38.440 --> 00:26:39.940 align:middle line:90%
or data was transferred.

00:26:39.940 --> 00:26:43.330 align:middle line:84%
But if we take a look at the
desktop, we'll have test.txt,

00:26:43.330 --> 00:26:45.820 align:middle line:84%
and the information
was transferred over.

00:26:45.820 --> 00:26:49.210 align:middle line:84%
Now, this is not just useful
for transferring text files.

00:26:49.210 --> 00:26:52.090 align:middle line:84%
It can also be used to
transfer executables.

00:26:52.090 --> 00:26:55.130 align:middle line:84%
And again, you can essentially
just replicate the process.

00:26:55.130 --> 00:26:56.620 align:middle line:90%
And it works vise versa.

00:26:56.620 --> 00:26:59.770 align:middle line:84%
If I wanted to transfer a
file from the Windows system

00:26:59.770 --> 00:27:01.630 align:middle line:84%
to the Linux system,
I would set up

00:27:01.630 --> 00:27:04.210 align:middle line:84%
the listener on the
Kali Linux system

00:27:04.210 --> 00:27:07.600 align:middle line:84%
and then specify the
output file where

00:27:07.600 --> 00:27:09.130 align:middle line:90%
I would like that data stored.

00:27:09.130 --> 00:27:11.020 align:middle line:84%
And then on the
Windows system, I

00:27:11.020 --> 00:27:15.190 align:middle line:84%
would connect to the listener
on the Kali Linux system

00:27:15.190 --> 00:27:18.200 align:middle line:84%
and specify the file that I
would like to transfer over,

00:27:18.200 --> 00:27:18.700 align:middle line:90%
all right?

00:27:18.700 --> 00:27:21.370 align:middle line:84%
So that is really
how to use Netcat

00:27:21.370 --> 00:27:23.470 align:middle line:84%
to perform a plethora
of functionality that

00:27:23.470 --> 00:27:25.100 align:middle line:90%
is very, very important.

00:27:25.100 --> 00:27:27.370 align:middle line:84%
Now that we have an
understanding of how Netcat

00:27:27.370 --> 00:27:29.830 align:middle line:84%
works in depth and we
understand the two modes--

00:27:29.830 --> 00:27:32.210 align:middle line:84%
the client mode and
the listen mode--

00:27:32.210 --> 00:27:34.220 align:middle line:84%
we can now move on
to the next step,

00:27:34.220 --> 00:27:37.090 align:middle line:84%
which is getting started
with bind and reverse shells.

00:27:37.090 --> 00:27:39.820 align:middle line:84%
So that is going to conclude
the practical demonstration

00:27:39.820 --> 00:27:42.720 align:middle line:90%
side of this video.

00:27:42.720 --> 00:27:45.490 align:middle line:84%
All right, so now that we have
an understanding of how Netcat

00:27:45.490 --> 00:27:49.100 align:middle line:84%
works, we can get started
with reverse shells or, more

00:27:49.100 --> 00:27:51.440 align:middle line:84%
specifically, bind
shields first,

00:27:51.440 --> 00:27:54.200 align:middle line:84%
because bind shells are
very important to understand

00:27:54.200 --> 00:27:56.780 align:middle line:84%
in the context of
shells in general

00:27:56.780 --> 00:28:00.410 align:middle line:84%
and obtaining remote
access to a target system.

00:28:00.410 --> 00:28:03.180 align:middle line:84%
And you'll be able to see the
differences between the two.

00:28:03.180 --> 00:28:07.270 align:middle line:84%
So in the next video, we'll
get started with bind shells.

00:28:07.270 --> 00:28:08.000 align:middle line:90%