WEBVTT

00:00.199 --> 00:04.530
>> Welcome to the Nmap
lesson on IP/TCP,

00:04.530 --> 00:06.765
UDP, and ICMP headers.

00:06.765 --> 00:09.090
This lesson is simply
a brief overview of

00:09.090 --> 00:11.580
the most important TCP/IP
protocols you need to

00:11.580 --> 00:14.549
understand when
composing Nmap scans.

00:14.549 --> 00:16.170
My main objective will

00:16.170 --> 00:18.030
be to help you to
understand the difference

00:18.030 --> 00:20.150
between their headers and

00:20.150 --> 00:23.365
what important features about
each you need to grasp.

00:23.365 --> 00:26.495
If you walk away from it
with an understanding of

00:26.495 --> 00:29.645
the TCP three-way
handshake, encapsulation,

00:29.645 --> 00:32.435
source and destination
addresses and ports,

00:32.435 --> 00:36.130
flags and ICMP types and
codes, I've done my job.

00:36.130 --> 00:37.610
I'll also provide you with

00:37.610 --> 00:39.800
some good reference
videos in case you want

00:39.800 --> 00:42.585
to dive deeper.
Let's get started.

00:42.585 --> 00:45.890
In this lesson, we'll talk
about two important concepts

00:45.890 --> 00:48.335
in TCP/IP: Encapsulation

00:48.335 --> 00:50.750
and the TCP three-way handshake.

00:50.750 --> 00:55.375
We'll then go on to discuss
TCP and examine its header,

00:55.375 --> 00:59.240
then we'll talk about UDP
and its header, next,

00:59.240 --> 01:02.000
we'll take a look at
the IP header and we'll

01:02.000 --> 01:05.270
finish up with the discussion
on ICMP and its header.

01:05.270 --> 01:06.845
In each of these slides,

01:06.845 --> 01:08.270
I'll provide you
with some additional

01:08.270 --> 01:10.070
reference material
and we'll try to

01:10.070 --> 01:11.870
focus on why and how

01:11.870 --> 01:14.525
this information is
relevant to using Nmap.

01:14.525 --> 01:16.655
The more you
understand this stuff,

01:16.655 --> 01:18.130
the better you will be in

01:18.130 --> 01:21.029
>> constructing
great Nmap scans.

01:21.029 --> 01:23.705
>> Let's talk about
two important concepts

01:23.705 --> 01:26.300
in normal TCP/IP communication.

01:26.300 --> 01:29.195
Some of you may be asking
why encapsulation and

01:29.195 --> 01:32.150
a TCP three-way handshake
are on the same slide.

01:32.150 --> 01:34.640
Well, I have no good
explanation except

01:34.640 --> 01:36.980
for the fact that
these two concepts are

01:36.980 --> 01:39.170
high level mechanisms that
must be understood to

01:39.170 --> 01:40.895
conceptualize what is happening

01:40.895 --> 01:43.220
when Nmap scans are executed.

01:43.220 --> 01:45.845
But the fact is encapsulation

01:45.845 --> 01:48.830
and the TCP three-way
handshake are not necessarily

01:48.830 --> 01:50.750
related other than
they're both part of

01:50.750 --> 01:55.550
the traditional TCP/IP
stack and both fundamental.

01:55.550 --> 01:58.070
Encapsulation is the process of

01:58.070 --> 02:00.470
adding headers and
trailers to data.

02:00.470 --> 02:03.350
Many people talk about
it in terms of wrappers,

02:03.350 --> 02:04.550
as in candy wrappers,

02:04.550 --> 02:06.455
not like Jay-Z or Eminem.

02:06.455 --> 02:10.760
The idea is that lower layers
tack on headers and in

02:10.760 --> 02:11.840
some case trailers to

02:11.840 --> 02:13.280
higher layer packets in

02:13.280 --> 02:15.890
such a way that they
are wrapped in them.

02:15.890 --> 02:17.870
The picture on this slide shows

02:17.870 --> 02:19.655
the two most important OSI

02:19.655 --> 02:22.640
or TCP/IP model
layers on the left,

02:22.640 --> 02:24.710
as far as Nmap is concerned:

02:24.710 --> 02:27.475
the transport and
the network layers.

02:27.475 --> 02:29.570
On the right, it shows which

02:29.570 --> 02:31.745
protocols exist in those layers,

02:31.745 --> 02:34.885
as well as what datagrams
are called in each layer.

02:34.885 --> 02:36.340
At the transport layer,

02:36.340 --> 02:38.595
layer 4 of the OSI model,

02:38.595 --> 02:40.505
a datagram is called a segment,

02:40.505 --> 02:43.445
and it can either be TCP or UDP.

02:43.445 --> 02:46.220
At the network layer or layer 3,

02:46.220 --> 02:48.320
a datagram is called a packet.

02:48.320 --> 02:50.560
I wanted to start with
this because we're going

02:50.560 --> 02:52.460
to do further
analysis of ways that

02:52.460 --> 02:54.770
Nmap uses each of
these layers as it

02:54.770 --> 02:58.235
generates its scans by
manipulating those headers.

02:58.235 --> 03:02.600
The second concept here is
the TCP three-way handshake.

03:02.600 --> 03:04.580
Some of you may be
wondering why there is

03:04.580 --> 03:06.760
no UDP handshake on this slide.

03:06.760 --> 03:09.500
The reason is that
there is no such thing.

03:09.500 --> 03:11.645
As we discussed in
the previous lesson,

03:11.645 --> 03:14.270
UDP does not provide
connection-oriented,

03:14.270 --> 03:17.180
aka reliable, end to
end communication.

03:17.180 --> 03:19.190
It only provides best effort or

03:19.190 --> 03:21.715
connectionless communication
between hosts.

03:21.715 --> 03:24.575
The TCP three-way handshake,
on the other hand,

03:24.575 --> 03:26.300
is what makes
connection-oriented

03:26.300 --> 03:27.829
>> communication possible.

03:27.829 --> 03:29.525
>> As the picture shows,

03:29.525 --> 03:32.390
user A's computer initiates
communication with

03:32.390 --> 03:36.370
server B with a SYN flag
set in the TCP segment.

03:36.370 --> 03:41.835
Server B responds with
both SYN and ACK flag set,

03:41.835 --> 03:45.110
then user A's computer
responds with an ACK.

03:45.110 --> 03:46.940
The connection is
established and

03:46.940 --> 03:48.865
communication continues.

03:48.865 --> 03:51.495
This is an important
concept in Nmap,

03:51.495 --> 03:53.840
because Nmap and its
users, such as you,

03:53.840 --> 03:55.939
can generate scans
that manipulate

03:55.939 --> 03:58.280
the TCP flags in different
ways in order to

03:58.280 --> 04:00.650
solicit various responses so

04:00.650 --> 04:02.915
you can critically
evaluate the results.

04:02.915 --> 04:04.970
This capability is built into

04:04.970 --> 04:08.425
Nmap as a part of its packet
crafter called Nping.

04:08.425 --> 04:10.040
If you want to learn more about

04:10.040 --> 04:12.830
encapsulation and the
TCP three-way handshake,

04:12.830 --> 04:16.780
I've provided some links
to some good videos.

04:16.780 --> 04:19.625
Let's talk about two
important concepts

04:19.625 --> 04:22.145
in normal TCP/IP communication.

04:22.145 --> 04:24.350
On the right, I've put a graphic

04:24.350 --> 04:26.725
that lays out the
TCP header for you.

04:26.725 --> 04:28.500
TCP is a transport layer,

04:28.500 --> 04:29.900
layer 4 protocol that offers

04:29.900 --> 04:32.120
reliable connection-oriented
communication

04:32.120 --> 04:34.970
and is passed down and
encapsulated by IP.

04:34.970 --> 04:38.240
From Nmap's perspective, the
most important things you

04:38.240 --> 04:41.495
need to understand about the
header is its source port,

04:41.495 --> 04:44.675
the destination port,
and the TCP flags.

04:44.675 --> 04:47.795
Other things can be altered
with Nmap through Nping but

04:47.795 --> 04:49.250
these are the ones
you'll spend most

04:49.250 --> 04:51.280
of your time working
with in Nmap.

04:51.280 --> 04:53.160
In a regular Nmap scan,

04:53.160 --> 04:54.905
the source port is ephemeral,

04:54.905 --> 04:57.230
meaning your scanning
station will automatically

04:57.230 --> 04:59.660
determine the port it opens for

04:59.660 --> 05:02.270
communication and will be

05:02.270 --> 05:04.520
an upper level and
non well-known port.

05:04.520 --> 05:07.840
In other words,
higher than 1024.

05:07.840 --> 05:11.390
However, the destination port
will either be defined by

05:11.390 --> 05:15.145
you and your scan statement
or will be chosen by Nmap.

05:15.145 --> 05:17.749
A regular Nmap
scan, for instance,

05:17.749 --> 05:20.630
will scan 1,000
popular ports and

05:20.630 --> 05:24.895
a fast Nmap scan will scan
100 of the most popular.

05:24.895 --> 05:27.200
A fast scan is built by using

05:27.200 --> 05:30.080
the -F command line switch

05:30.080 --> 05:32.435
or you can literally

05:32.435 --> 05:35.285
specify exactly the
ports you want to scan.

05:35.285 --> 05:36.760
I'll show you this later.

05:36.760 --> 05:39.200
Another great feature
of Nmap is that you

05:39.200 --> 05:41.585
don't have to build a
full TCP connection,

05:41.585 --> 05:44.255
aka three way handshake
when running a scan.

05:44.255 --> 05:46.430
In fact, by default
Nmap generates

05:46.430 --> 05:48.890
a TCP SYN scan
against targets by

05:48.890 --> 05:53.955
setting the SYN flag but not
responding with a SYN-ACK.

05:53.955 --> 05:56.530
This is because the
response to SYN scans are

05:56.530 --> 05:59.140
just as reliable as
full connect scans,

05:59.140 --> 06:01.915
but are quieter and more polite.

06:01.915 --> 06:08.165
Nmap-sS initiates a SYN scan,

06:08.165 --> 06:12.735
Nmap-sA initiates an ACK scan

06:12.735 --> 06:18.165
and Nmap-sT initiates
a full connect scan.

06:18.165 --> 06:22.770
Other important TCP flags
to note are U for urgent,

06:22.770 --> 06:25.620
P for Push, R for reset,

06:25.620 --> 06:27.575
and F for finish.

06:27.575 --> 06:30.400
You can also
initiate a so-called

06:30.400 --> 06:32.170
>> Christmas tree scan or

06:32.170 --> 06:37.330
>> X-mas scan with a -sX,

06:37.330 --> 06:41.300
which sets all the TCP
flags and in doing so,

06:41.300 --> 06:44.135
lights up the TCP segment
like a Christmas tree.

06:44.135 --> 06:45.860
Sometimes the responses to

06:45.860 --> 06:47.675
this type of scanning
can be valuable,

06:47.675 --> 06:50.375
but they're
definitely not quiet.

06:50.375 --> 06:52.820
Some of the same
things that apply to

06:52.820 --> 06:55.205
TCP also apply to UDP.

06:55.205 --> 06:57.110
UDP itself is much

06:57.110 --> 06:59.660
simpler with less overhead
than TCP, though.

06:59.660 --> 07:01.220
The most important component of

07:01.220 --> 07:03.860
the UDP header is a
destination port,

07:03.860 --> 07:05.720
with the ephemeral source port

07:05.720 --> 07:07.625
being supplied by your computer.

07:07.625 --> 07:09.620
It's really important
to be familiar with

07:09.620 --> 07:11.735
constructing UDP scans though in

07:11.735 --> 07:14.090
Nmap because some really
important services

07:14.090 --> 07:16.085
use UDP for communication.

07:16.085 --> 07:19.550
For example, DNS
uses UDP port 53,

07:19.550 --> 07:22.165
NTP uses port 123,

07:22.165 --> 07:25.320
NetBIOS uses port 137,

07:25.320 --> 07:27.920
and LDAP uses 389.

07:27.920 --> 07:32.470
To initiate a UDP
scan use an Nmap-sU,

07:32.470 --> 07:35.325
followed by the ports
you want to scan

07:35.325 --> 07:37.595
with the -p switch.

07:37.595 --> 07:40.150
I'll show you some
examples of this later.

07:40.150 --> 07:43.520
The IPv4 header is tacked on to

07:43.520 --> 07:44.750
the TCP or UDP

07:44.750 --> 07:47.375
header through the
process of encapsulation.

07:47.375 --> 07:49.640
IP is connectionless
and operates

07:49.640 --> 07:51.905
at layer 3, with
the network layer.

07:51.905 --> 07:53.780
You'll notice that I have

07:53.780 --> 07:56.675
version circled in the
graphic to the right.

07:56.675 --> 07:58.790
The only reason why
I've circled it is

07:58.790 --> 08:01.220
because I don't want
you to get confused.

08:01.220 --> 08:03.575
In IPV4 communication,

08:03.575 --> 08:06.380
this value will always
be four however,

08:06.380 --> 08:07.850
that doesn't mean
that it changes to

08:07.850 --> 08:11.045
six if it is IPV6 communication.

08:11.045 --> 08:14.765
In fact, IPV6 has an
entirely different header.

08:14.765 --> 08:16.430
Beyond that, you don't have to

08:16.430 --> 08:18.640
concern yourself with
the version field.

08:18.640 --> 08:20.675
The protocol field defines

08:20.675 --> 08:21.920
the protocol that is used

08:21.920 --> 08:23.494
>> in the creation
of the packet.

08:23.494 --> 08:25.400
>> For the most part in Nmap,

08:25.400 --> 08:28.610
this will either be
TCP or protocol 6,

08:28.610 --> 08:31.535
UDP or protocol 17,

08:31.535 --> 08:34.445
or ICMP or protocol 1.

08:34.445 --> 08:38.255
The source address will
usually be your IP address,

08:38.255 --> 08:40.590
though this can be altered and

08:40.590 --> 08:43.770
the destination address is
the address of your target.

08:43.770 --> 08:48.020
Nmap-sO allows you to

08:48.020 --> 08:50.150
determine which IP protocols

08:50.150 --> 08:52.370
are supported by
target machines.

08:52.370 --> 08:54.590
By default Nmap will scan

08:54.590 --> 08:57.605
all 256 possible protocol values

08:57.605 --> 08:59.599
and provide you
with the results.

08:59.599 --> 09:01.940
As with the other
slides in this module,

09:01.940 --> 09:03.695
I've provided you with a video

09:03.695 --> 09:05.900
on a deeper look
into the IP header,

09:05.900 --> 09:07.850
should you wish to learn more.

09:07.850 --> 09:10.925
The Internet Control
Message Protocol

09:10.925 --> 09:12.590
is used all around the world by

09:12.590 --> 09:14.555
network analysts to determine

09:14.555 --> 09:16.850
if packets are
routing successfully,

09:16.850 --> 09:18.775
if hosts are up and running

09:18.775 --> 09:21.270
and for simple latency analysis.

09:21.270 --> 09:23.390
This is done using the ping or

09:23.390 --> 09:26.650
traceroute command in your
favorite operating system.

09:26.650 --> 09:29.675
ICMP is really a
supporting protocol

09:29.675 --> 09:31.760
and acts similar to
layer 4 protocols,

09:31.760 --> 09:34.915
but really exists in
layer 3 technically.

09:34.915 --> 09:37.100
As you'll notice in
the graphic though,

09:37.100 --> 09:38.840
ICMP must be attached to

09:38.840 --> 09:42.125
IP because it has no address
field in its header.

09:42.125 --> 09:44.120
The two most important fields in

09:44.120 --> 09:46.880
the ICMP header
are type and code.

09:46.880 --> 09:48.395
If you look at the graphic,

09:48.395 --> 09:50.300
you'll notice many
familiar responses

09:50.300 --> 09:52.285
with most of them being type 0,

09:52.285 --> 09:54.170
3, 8 or 11,

09:54.170 --> 09:57.985
like destination host
unreachable and TTL exceeded.

09:57.985 --> 10:00.410
The biggest thing I
want to point out is

10:00.410 --> 10:02.570
the fact that when
you read about

10:02.570 --> 10:04.850
ping scans in Nmap do not assume

10:04.850 --> 10:07.240
that this means
ICMP is being used.

10:07.240 --> 10:10.400
In fact, ICMP is
really only used as

10:10.400 --> 10:12.070
a helper utility to

10:12.070 --> 10:15.340
traditional TCP and
UDP scans in Nmap.

10:15.340 --> 10:19.205
In fact, in order to
initiate an ICMP scan,

10:19.205 --> 10:21.920
you have to run Nmap-sn-PE.

10:24.750 --> 10:30.070
Nmap can use ICMP in novel
ways though, for instance,

10:30.070 --> 10:33.160
you can construct small
ICMP packets that solicit

10:33.160 --> 10:36.775
responses from entire networks
very quickly in Nmap.

10:36.775 --> 10:39.490
This is much more effective
than simply running

10:39.490 --> 10:40.720
a ping command one at

10:40.720 --> 10:43.045
a time to every device
on the network.

10:43.045 --> 10:45.580
However, I think
you'll see that using

10:45.580 --> 10:48.100
TCP and UDP scans are much more

10:48.100 --> 10:50.740
effective and
allowing Nmap to use

10:50.740 --> 10:54.665
ICMP as a helper is
usually the best bet.

10:54.665 --> 10:57.240
In this lesson, we discussed

10:57.240 --> 10:59.280
two important
concepts in TCP/IP:

10:59.280 --> 11:03.379
>> encapsulation and the
TCP three-way handshake.

11:03.379 --> 11:07.160
>> We then discussed TCP
and examined its header,

11:07.160 --> 11:09.750
then we talked about
UDP and its header,

11:09.750 --> 11:13.070
next we took a look
at the IP header and

11:13.070 --> 11:14.510
we finished up with a discussion

11:14.510 --> 11:16.789
>> on ICMP and its header.

11:16.789 --> 11:20.480
>> I hope you found this
information very helpful.

11:20.480 --> 11:22.935
Thank you so much for
walking through it with me.

11:22.935 --> 11:25.650
I'll talk to you more
in the next lesson.

