1 / 53

IP Spoofing 공격

IP Spoofing 공격. 포항공과대학교 PLUS 오태호 (PLUS015) ohhara@postech.ac.kr. 목차 (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

Télécharger la présentation

IP Spoofing 공격

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IP Spoofing공격 포항공과대학교 PLUS 오태호 (PLUS015) ohhara@postech.ac.kr

  2. 목차(1) • IP Spoofing이란? • TCP/IP Packet의 구조 • IP Header의 구조 • TCP Header의 구조 • TCP Connection • Connect with IP Spoofing

  3. 목차(2) • IP Spoofing의 종류 • Non Blind IP Spoofing • hunt를 이용한 IP Spoofing • Blind IP Spoofing • mendax를 이용한 IP Spoofing • mendax의 IP Spoofing과정 • Sequence Number Guessing • IP Spoofing을 막기 위한 대책

  4. IP Spoofing이란? • TCP/IP의 구조적인 허점을 이용한 공격 • 자신의 IP를 속여서 접속하는 공격 • IP로 인증하는 서비스를 무력화 시킬 수 있음 ( ex. rlogind, rshd ) • 1985년 Morris가 IP Spoofing공격의 가능성에 대해 예견 • 1995년 Kevin Mitnick이 처음으로 IP Spoofing공격을 시도

  5. IP Header TCP Header Application Data 20 bytes 20 bytes TCP/IP Packet의 구조

  6. 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 address */ }; * Redhat Linux 5.1의 /usr/include/netinet/ip.h에서 발췌 ( endian과 ip_off관련 내용은 생략 )

  7. IP Header의 구조(2) • ip_hl • IP Header의 길이를 double word단위로 나타낸다. 보통 5를 사용한다. • ip_v • IP의 Version이다. 보통 IPVERSION을 사용한다. • ip_tos • service의 type을 나타낸다.

  8. IP Header의 구조(3) • ip_len • 현재 packet의 전체 크기를 나타낸다. • ip_id • 각각의 packet을 구분할 때 사용하는 id이다. 보통 packet을 하나 보낼 때 마다 1씩 증가한다. • ip_off • fragment offset field이다.

  9. IP Header의 구조(4) • ip_ttl • time to live를 나타낸다. packet이 router를 최대 몇 개까지 거칠 수 있는지 한계를 설정한다. • ip_p • protocol을 나타낸다. TCP를 사용하는 경우에는 IPPROTO_TCP를 사용한다.

  10. IP Header의 구조(5) • ip_sum • IP Header의 checksum값이다. • ip_src, ip_dst • source IP와 destination IP이다.

  11. 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관련 내용은 생략 )

  12. TCP Header의 구조(2) • th_sport, th_dport • source port와 destination port이다. • th_seq • 전송하는 packet의 순서를 나타내는 번호이다. • th_ack • 다음에 받을 것으로 예상되는 packet의 번호이다.

  13. 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이다.

  14. TCP Header의 구조(4) • th_sum • 전송된 packet이 제대로 전송되었는지 알아보기 위한 checksum값이 저장된다. • th_urp • urgent pointer이다. 긴급한 데이터를 전송할 때 사용된다.

  15. TCP Connection • TCP 3 way handshake Host A Host B SYN(1000) SYN(4000) , ACK(1001) ACK(4001) Connection Established

  16. Connect with IP Spoofing(1) • Connect to Host B with IP Spoofing Hacker Host A Host B Denial of Service attack Send 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

  17. 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를 쉽게 알 수 있다.

  18. IP Spoofing의 종류(1) • Non Blind IP Spoofing • Host A와 Host B가 주고받는 Packet을 볼 수 있는 상태이다. • Sequence number를 알 수 있기 때문에 쉽게 공격이 가능하다. • Connection을 계속 유지할 수 있다.

  19. IP Spoofing의 종류(2) • Blind IP Spoofing • Host A와 Host B가 주고받는 Packet을 볼 수 없는 상태이다. • Sequence number를 추정해야 되기 때문에 공격이 어렵다. • Connection을 계속 유지하기가 곤란하다.

  20. Non Blind IP Spoofing • Connect가 되어 있는 상태를 살피고 있다가 중간에 끼어 드는 Connection Hijacking할 때 흔히 사용함 • Connection을 끊어 버리거나 중간에 해커가 원하는 명령을 수행하게 할 수 있음 • One time password를 무력화 시킬 수 있음 • Hunt라는 프로그램을 사용해 쉽게 할 수 있음

  21. hunt를 이용한 IP Spoofing(1)

  22. hunt를 이용한 IP Spoofing(2)

  23. hunt를 이용한 IP Spoofing(3)

  24. 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가 사용하고 있음

  25. hunt를 이용한 IP Spoofing(5)

  26. hunt를 이용한 IP Spoofing(6)

  27. hunt를 이용한 IP Spoofing(7)

  28. hunt를 이용한 IP Spoofing(8) • guest는 이유없이 connection이 끊어짐 • ohhara는 guest가 이상한 말을 하는 것으로 느낌 • guest가 한 이상한 말은 실은 hacker가 connection을 hijacking 해서 입력한 것

  29. Blind IP Spoofing • Sequence number가 추측이 가능한 경우에만 공격이 가능하다. • rsh, rlogin과 같은 IP를 가지고 인증하는 서비스를 공격할 때 사용한다. • Denial of Service공격이 우선적으로 필요하다. • mendax 프로그램을 사용해 rsh, rlogin의 인증을 쉽게 무력화 시킬 수 있다.

  30. 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.

  31. mendax를 이용한 IP Spoofing(2)

  32. 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에 + +를 추가해서 누구나 로그인을 할 수 있게 된다.

  33. mendax의 IP Spoofing과정(1) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) ip_id = 0 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = 143.209.4.3 /* this host must not exist */ ip_dst = 141.223.163.23 ip_sum = checksum of ip header th_sport = 200 th_dport = 513 th_off = 5 th_win = 0 th_seq = 343289783 th_ack = 0 th_flags = TH_SYN th_sum = checksum of packet

  34. mendax의 IP Spoofing과정(2) • 위와 같은 packet을 20개 보냄 • ip_id를 packet마다 1을 더한다. • th_seq를 packet마다 64000을 더한다. • th_sport를 packet마다 1을 더한다. • 143.209.4.3에서 응답이 없으므로 141.223.163.23은 일시적으로 서비스 불능상태가 된다. • 흔히 SYN Flooding이라 불린다.

  35. mendax의 IP Spoofing과정(3) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) ip_id = 0x4189 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = hacker’s ip ip_dst = 141.223.94.22 ip_sum = checksum of ip header th_sport = 7843 th_dport = 514 th_off = 5 th_win = 0 th_seq = 0 th_ack = 0 th_flags = TH_SYN th_sum = checksum of packet

  36. mendax의 IP Spoofing과정(4) • 위와 같은 packet을 4개 보냄 • ip_id를 packet마다 1을 더한다. • th_sport를 packet마다 1을 더한다. • th_seq를 packet마다 64000을 더한다. • 돌아오는 packet의 sequence number를 분석해 어떤 규칙이 있는지 알아낸다.

  37. mendax의 IP Spoofing과정(5) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) ip_id = 0x4189 + 4 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = 141.223.163.23 ip_dst = 141.223.94.22 ip_sum = checksum of ip header th_sport = 513 th_dport = 514 th_off = 5 th_win = 0 th_seq = 0 th_ack = 0 th_flags = TH_SYN th_sum = checksum of packet

  38. mendax의 IP Spoofing과정(6) • 위와 같은 packet을 보냄 • 141.223.94.22는 위의 packet을 받고 141.223.163.23으로 packet을 보내지만 서비스 불능상태이기 때문에 응답이 없다. • 여기서 141.223.94.22가 보낸 packet의 sequence number를 방금 전의 분석을 토대로 추정한다.

  39. mendax의 IP Spoofing과정(7) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) ip_id = 0x4189 + 5 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = 141.223.163.23 ip_dst = 141.223.94.22 ip_sum = checksum of ip header th_sport = 513 th_dport = 514 th_off = 5 th_win = 0 th_seq = 0 th_ack = 660224001 /* gussed number */ th_flags = TH_SYN | TH_ACK th_sum = checksum of packet

  40. mendax의 IP Spoofing과정(8) • 위와 같은 packet을 보냄 • sequence number의 예측 값이 정확하다면 connection이 성공적으로 이루어진다.

  41. mendax의 IP Spoofing과정(9) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) + data ip_id = 64 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = 141.223.163.23 ip_dst = 141.223.94.22 ip_sum = checksum of ip header th_sport = 513 th_dport = 514 th_off = 5 th_win = 0 th_seq = 0 th_ack = 660224001 /* gussed number */ th_flags = TH_ACK | TH_PUSH th_sum = checksum of packet data = “ohhara plus echo + + >> .rhosts”

  42. mendax의 IP Spoofing과정(10) • 위와 같은 packet을 보냄 • echo + + >> .rhosts 의 명령이 수행된다.

  43. mendax의 IP Spoofing과정(11) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) ip_id = 128 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = 141.223.163.23 ip_dst = 141.223.94.22 ip_sum = checksum of ip header th_sport = 513 th_dport = 514 th_off = 5 th_win = 0 th_seq = 0 th_ack = 660224001 /* gussed number */ th_flags = TH_RST th_sum = checksum of packet

  44. mendax의 IP Spoofing과정(12) • 위와 같은 packet을 보냄 • 141.223.163.23과 141.223.94.22의 connection을 RST packet을 보내서 끊는다.

  45. mendax의 IP Spoofing과정(13) ip_hl = 5 ip_v = IPVERSION ip_tos = 0x2b ip_len = sizeof(struct ip) + sizeof(struct tcphdr) ip_id = 0 ip_ttl = 0x60 ip_off = 0 ip_p = IPPROTO_TCP ip_src = 143.209.4.3 /* this host must not exist */ ip_dst = 141.223.163.23 ip_sum = checksum of ip header th_sport = 200 + 20 th_dport = 513 th_off = 5 th_win = 0 th_seq = 34328983 th_ack = 0 th_flags = TH_RST th_sum = checksum of packet

  46. 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은 서비스 불능상태에서 서비스 가능상태로 바뀐다.

  47. Sequence Number Guessing(1) • Blind IP Spoofing공격은 sequence number를 얼마나 정확히 추정하느냐에 따라 공격의 성공여부가 결정됨 • 대부분의 OS가 sequence number를 너무 간단한 규칙하에 발생시킴

  48. 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

  49. 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

  50. Sequence Number Guessing(4) • Random • sequence number의 규칙을 알 수 없다. 비교적 안전하다. • AIX 4 and after • Linux 2.x and after

More Related