Hands-On Ethical Hacking and Network Security

Download Report

Transcript Hands-On Ethical Hacking and Network Security

TCP/IP Concepts (Part 2)
January 21, 2010
MIS 4600 - MBA 5880 © Abdou Illia
Objectives
 Explain the basic concepts of IP addressing
 Explain the binary, octal, and hexadecimal
numbering systems
2
IP Addressing
 The decimal system (base 10) uses 10 digits (0-9)
 The binary system (base 2) uses 2 digits (0 and 1) to
represent numbers. These 0s and 1s are called bits
 A group of 8 bits is called a byte (or an octet)
 An IP address consists of four bytes (or four octets)
 An IP address is a set of 32 bits (4 x 8 bytes)
 Example: 10000000 00001010 0000010 00000001
 For easy reading, IP addresses are represented as 4
decimal numbers separated by dots (e.g. 120.1.2.1)
3
IP addressing (cont.)
10.
133.12.56
139.67. 122.56
An IP address has two components 192.67.122. 56
Network address
Network
Host
Legend:
Host address
address
address
 IP addresses classified:
 Class A addresses
 Class B addresses
 Class C addresses
4
Class
Leftmos
t bits
Network
add. length
Address range
Number of networks
Number of hosts per
network
A
0xxx
8 bits
0.x.x.x – 127.x.x.x
~ 128
~ 16 million (255^3)
B
10xx
16 bits
128.x.x.x – 191.255.x.x
~ 16000 (64 x 255)
~ 65000 (255^2)
C
110x
24 bits
192.x.x.x – 223.255.255.x
~ 2 million (32 x 255 x 255
~ 254
IP Addressing (continued)
 Class A
Limited number of Class A networks
Reserved for large corporations and governments
Format:
network.node.node.node
 Class B
Supports more than 65,000 host computers
Assigned to large corporations and ISPs
Format:
network.network.node.node
 Class C
Supports up to 254 host computers
Available for small business and home networks
5
Format:
network.network.network.node
Subnetting a TCP/IP network
 A technique for dividing a network into virtual
subnetworks
 Subnet masks are used to divide networks into virtual
subnetworks
 A subnet mask is a32 bit number, just like an IP
address, where all bits in the Network part are set to 1,
and all bits in the Host part are set to 0. Examples:
1111111 11111111 11111111 00000000
(or 255.255.255.0 in decimal notation)
192.168.1.130
255.255.255.128
192.168.1.1
255.255.255.128
192.168.1.2
255.255.255.128
192.168.1.3
255.255.255.128
6
1111111 11111111 11111111 10000000
(or 255.255.255.128 in decimal notation)
192.168.1.131
255.255.255.128
Switch
192.168.1.132
255.255.255.128
Subnetting a TCP/IP network (cont)
 IP addresses cannot contain all 0s or all 1s
 Accessing entities and services on other networks:
 Each computer needs IP address of gateway (or router)
 TCP/IP uses subnet mask to determine destination computer’s
network
 If destination computer is on a different network, sender relays packet
to gateway/router
 Gateway/router forwards packet to its next destination
7
Subnetting Exercise
 Do Subnetting Exercise posted to the course web site
8
Studying Binary, Octal, Hex
Numbering Systems
 Why study binary, octal, and hex numbering
systems?
 Computer systems operate using binary
 Some attack codes are written in Hex
 *NIX (UNIX, Linux) file permissions are
represented with bits
 0 means removing the permission
 1 means granting the permission
 111 (rwx) means read, write, execute permission are
granted
9
Binary Numbering System
 Uses the number 2 as its base
 Binary digits (bits): 0 and 1
 Byte
Group of 8 bits (example: 00001011)
Can represent 28 = 256 different values (from
0 to 255)
128 64 32 16 8
4
2
1
27 26 25 24 23 22 21 20
128 + 64 + 32 5 16 + 8 + 4 + 2 + 1 = 255
10
Binary to Decimal
 32-bit IP address and its Decimal version
IP addresses are really strings of 32 bits (1s
and 0s)
 10000000101010100001000100001101
To convert this to decimal notation, first,
divide them into four bytes (also called octets)
 10000000 10101010 00010001 00001101
Convert each binary (Base 2) octet into decimal
(Base 10)
11
Conversion table
Position
(N)
Binary
10100011
=
Decimal
163
Note: Starts with 0
12
Place Value Bit
(2N)
Decimal
7
128
1
128
6
64
0
0
5
32
1
32
4
16
0
0
3
8
0
0
2
4
0
0
1
2
1
2
0
1
1
1
163
Understanding Nibbles
 A nibble is half a byte or four bits
 Helps with reading the number by separating the
byte: 1111 1010
 Components
High-order nibble (left side)
Low-order nibble (right side)
 Converting 1010 1010 to decimal
Low-order nibble 1010 = 10 (in base 10)
Rule: Odd decimals have last low-order bit turned on
(i.e. equal 1). Even decimals have low-order bit off
13
Example:1001 cannot be even. 1110 can’t be odd
The Octal Numbering System
 Uses 8 as its base
Supports decimal digits from 0 to 7
 Octal digits can be represented with three bits
because the largest decimal number is 7
 With three bits, there are 23 = 8 possible
occurrences: 000, 001, 010, 011, 100, 101, 110, 111
 Permissions on UNIX systems
Owner permissions (rwx)
Group permissions (rwx)
Other permissions (rwx)
Example: 111 101 001
 Octal representation 751
14
(rwxrwxrwx)
(rwxr-x--x)
4 1
4
2 1
2
1 1
1
 Question: In binary and octal how do you express granting read, write, execute
permissions to the Owner of a file, read and write to Group, and just read to Other?
7
Short Case
 Do Activity 2-4 “Working with binary and
Octal numbering” on page 34 of the course
textbook.
15
Hexadecimal Numbering System
 Uses 16 as its base
Support numbers from 0 to 15
 Hex number consists of two characters
Each character represents a nibble
Value contains alphabetic letters (A … F)
 A representing 10 and F representing 15
HEX
DECIMAL
0
0 = 0+0+0+0
BINARY
0000
1
1 = 0+0+0+1
0001
2
2 = 0+0+2+0
0010
3
3 = 0+0+2+1
0011
4
4 = 0+2+0+0
0100
5
5 = 0+4+0+1
0101
6
6 = 0+4+2+0
0110
7
7 = 0+4+2+1
0111
8
8 = 8+0+0+0
1000
9
9 = 8+0+0+1
1001
A
10 = 8+0+2+0
1010
B
11 = 8+0+0+1
1011
C
12 = 8+4+0+0
1100
13 = 8+4+0+1
1101
E
14 = 8+4+2+0
1110
F
15 = 8+4+2+1
1111
 Sometimes expressed with “0x” in front D
 Used for MAC address (e.g. 12-34-56-78-9A-BC)
 To convert hexadecimal F8 to binary, write
16
down the binary for F first, then the binary
for 8.
F
8
1111
1000