Linux Security (Spoofing) 네트워크 실험실 김

Download Report

Transcript Linux Security (Spoofing) 네트워크 실험실 김

Linux Security
(Spoofing)
네트워크 실험실
김 윤 수
1
Computer Network Lab.
목차(1)
 Spoofing 정의
 TCP/IP packet 구조
– IP Header의 구조
– TCP Header의 구조
 TCP Connection
– 3-way handshake
 Connect with IP Spoofing
 스푸핑 종류
2
Computer Network Lab.
2
목차(2)
 IP 스푸핑
– Non Blind IP Spoofing
– Blind IP Spoofing
– Sequence Number Guessing
– IP Spoofing 방어
 ARP 스푸핑
 DNS 스푸핑
 Other Utilities
 Reference
 결론
3
Computer Network Lab.
3
Spoofing 정의
 TCP/IP의 구조적인 허점을 이용한 공격
 패킷을 신뢰된 호스트에서 보낸 것처럼, 자신의
IP를 위조해서 다른 시스템에서 인증을 얻는 방법
 IP로 인증하는 서비스를 무력화 시킬 수 있음 (ex.
rlogind, rshd )
 1985년 Morris가 IP Spoofing공격의 가능성에 대
해 예견
 1995년 Kevin Mitnick이 처음으로 IP Spoofing공
격을 시도
4
Computer Network Lab.
4
TCP/IP Packet의 구조
IP datagram
TCP segment
IP Header
20 bytes
TCP Header
TCP Data
20 bytes
Encapsulation of TCP data in an IP datagram
5
Computer Network Lab.
5
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 */
};
Alzza Linux 6.1의 /usr/include/netinet/ip.h
6
Computer Network Lab.
6
IP Header의 구조(2)
 ip_hl
– IP Header의 길이를 double word단위로 나
타낸다. 보통 5를 사용.
 ip_v
– IP의 Version이다. 보통 4를 사용.
 ip_tos
– service의 type.
7
Computer Network Lab.
7
IP Header의 구조(3)
 ip_len
– 현재 packet의 전체 크기.
 ip_id
– 각각의 packet을 구분할 때 사용하는 id이다.
– 보통 packet을 하나 보낼 때 마다 1씩 증가.
 ip_off
– fragment offset field.
8
Computer Network Lab.
8
IP Header의 구조(4)
 ip_ttl
– time to live.
– packet이 router를 최대 몇 개까지 거칠 수
있는지 한계를 설정.
 ip_p
– protocol을 나타낸다.
– TCP를 사용하는 경우에는 IPPROTO_TCP를
사용.
9
Computer Network Lab.
9
IP Header의 구조(5)
 ip_sum
– IP Header의 checksum 값.
 ip_src, ip_dst
– source IP
– destination IP
10
Computer Network Lab.
10
IP Header의 구조(6)
11
Computer Network Lab.
11
TCP Header의 구조(1)
struct tcphdr
{
u_int16_t th_sport;
u_int16_t th_dport;
tcp_seq th_seq;
tcp_seq th_ack;
u_int8_t th_x2:4;
u_int8_t th_off:4;
u_int8_t th_flags;
u_int16_t th_win;
u_int16_t th_sum;
u_int16_t th_urp;
};
/*
/*
/*
/*
/*
/*
source port */
destination port */
sequence number */
acknowledgement number */
(unused) */
data offset */
/* window */
/* checksum */
/* urgent pointer */
Alzza Linux 6.1의 /usr/include/netinet/tcp.h
12
Computer Network Lab.
12
TCP Header의 구조(2)
 th_sport, th_dport
– source port
– destination port.
 th_seq
– 전송하는 packet의 순서를 나타내는 번호.
 th_ack
– 다음에 받을 것으로 예상되는 packet의 번호.
13
Computer Network Lab.
13
TCP Header의 구조(3)
 th_off
– TCP Header의 길이를 double word단위로
나타낸다. 보통 5를 사용.
 th_flags
– 현재 packet의 flag들을 나타낸다.
– URG, ACK, PSH, RST, SYN, FIN 플래그
 th_win
– window size.
14
Computer Network Lab.
14
TCP Header의 구조(4)
 th_sum
– 전송된 packet이 제대로 전송되었는지 알아
보기 위한 checksum 값이 저장.
 th_urp
– urgent pointer.
– 긴급한 데이터를 전송할 때 사용.
15
Computer Network Lab.
15
TCP Header의 구조(5)
16
Computer Network Lab.
16
TCP Connection
 TCP 3-way handshake
Host A
Host B
TIME
Computer
Network Lab.
TIME
17
17
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 guessed SYN, ACK Packet( src = Host A, dest = Host B )
Send data (mv .rhosts .r ; echo “+ +” > .rhosts )
Send RST Packet
18
Computer Network Lab.
18
Connect with IP Spoofing(2)
 Send guessed ACK, SYN Packet
– Host B가 Host A로 보낸 Packet의
sequence number를 알아야 Packet을 보낼
수 있다.
 Non-Blind Spoofing
– Host A와 Host B가 주고받는 Packet을 볼
수가 있다면 Sequence number를 쉽게 알
수 있다.
19
Computer Network Lab.
19
Spoofing의 종류
 IP 스푸핑
 ARP 스푸핑
 DNS 스푸핑
20
Computer Network Lab.
20
IP Spoofing의 종류(1)
 Non-Blind IP Spoofing
– Host A와 Host B가 주고받는 Packet을 볼
수 있는 상태이다.
– Sequence number를 알 수 있기 때문에 쉽
게 공격이 가능하다.
– Connection을 계속 유지할 수 있다.
21
Computer Network Lab.
21
IP Spoofing의 종류(2)
 Blind IP Spoofing
– Host A와 Host B가 주고받는 Packet을 볼
수 없는 상태이다.
– Sequence number를 추정해야 되기 때문에
공격이 어렵다.
– Connection을 계속 유지하기가 곤란하다.
22
Computer Network Lab.
22
Non-Blind IP Spoofing
 Connect가 되어 있는 상태를 살피고 있다
가 중간에 끼어 드는 Connection
Hijacking할 때 흔히 사용함
 Connection을 끊어 버리거나, 중간에 해
커가 원하는 명령을 수행하게 할 수 있음
 Hunt라는 프로그램을 사용해 쉽게 할 수
있음
23
Computer Network Lab.
23
hunt를 이용한 IP Spoofing(1)
24
Computer Network Lab.
24
hunt를 이용한 IP Spoofing(2)
25
Computer Network Lab.
25
hunt를 이용한 IP Spoofing(3)
 203.247.36.37에서 두 hjcho, dhkang가
서로 Talk 하고 있음
 현재 hunt를 이용해 203.247.39.68 
203.247.39.61을 hijack하려고 준비하고
있음
 203.247.39.61은 현재 dhkang가 사용하
고 있음
26
Computer Network Lab.
26
hunt를 이용한 IP Spoofing(4)
 dhkang는 이유없이 connection이 끊어짐
 hjcho는 dhkang가 이상한 말을 하는 것으
로 느낌
 dhkang가 한 이상한 말은 실제로 hacker가
connection을 hijacking 해서 입력한 것
27
Computer Network Lab.
27
Blind-IP Spoofing
 Sequence number가 추측이 가능한 경우
에만 공격이 가능.
 rsh, rlogin과 같은 IP를 가지고 인증하는
서비스를 공격할 때 사용.
 DoS 공격이 우선적으로 필요.
 mendax 프로그램을 사용해 rsh, rlogin의
인증을 쉽게 무력화.
28
Computer Network Lab.
28
mendax를 이용한 IP Spoofing(1)
 mendax의 사용 방법
Usage: mendax [OPTIONS] <source> <target> [<gateway>]
-p
-s
-l
-r
-c
-w
-d
-t
-L
-S
PORT
PORT
USERNAME
USERNAME
COMMAND
PORT
TERM
PORT
first port on localhost to occupy
server port on <source> to swamp
user on <source>
user on <target>
command to execute
wait for a TCP SYN packet on port PORT
read data from stdin and send it.
test whether attack might succeed
spoof rlogind instead of rshd.
port from which to sample seq numbers.
29
Computer Network Lab.
29
mendax를 이용한 IP Spoofing(2)
30
Computer Network Lab.
30
mendax를 이용한 IP Spoofing(3)
 143.248.1.4에 있는 plus사용자는
143.248.1.102의 yskim사용자를 신뢰함
 공격 방법
– mendax -l yskim -r yskim -c “echo
+ + >> .rhosts” 143.248.1.102
143.248.1.4
 .rhosts에 + +를 추가해서 누구나 로그인을 할
수 있게 된다.
31
Computer Network Lab.
31
Sequence Number Guessing(1)
 Blind IP Spoofing공격은 sequence
number를 얼마나 정확히 추정하느냐에 따
라 공격의 성공 여부가 결정됨
 대부분의 OS가 sequence number를 너무
간단한 규칙하에 발생시킴
32
Computer Network Lab.
32
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
33
Computer Network Lab.
33
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
34
Computer Network Lab.
34
Sequence Number Guessing(4)
 Random
– sequence number의 규칙을 알 수 없다.
– 비교적 안전하다.
 AIX 4 and after
 Linux 2.x and after
35
Computer Network Lab.
35
TCP와 IP 스푸핑 도구들(1)
 Spoofit.h
–
–
–
–
–
만든이 : 브레치 클래헛(Brecht Claerhout)
사용언어: C
필요조건: C, net 인클루드 파일들
http://www.firosoft.com/security/philez/utilities/iptools/spoofit.h
IP 스푸핑 기능을 프로그램에 포함할 수 있도록 한 라이브러리
 Seq_number.c
–
–
–
–
–
만든이 : 마이크 뉴먼(Mike Neuman)
사용언어: C
필요조건: C, net 인클루드 파일들
http://sunshine.sunshine.ro/FUN/New/hacking/seq_number
스푸핑에서 사용하기 위한 TCP 시퀀스 번호의 이용방법.
36
Computer Network Lab.
36
TCP와 IP 스푸핑 도구들(2)
 ipspoof
–
–
–
–
–
만든이 : 모름
사용언어: C
필요조건: C, net 인클루드 파일들
http://www.ryanspc.com/spoof/ipspoof.c
IP와 TCP의 스푸핑 유틸리티
 1664
–
–
–
–
–
만든이: 배심(vasim V.)
사용언어: C
필요조건: C, net 인클루드 파일들
http://www.insecure.org/sploits/ttcp.spoofing.problem.html
스푸핑에서 사용하기 위한 TCP 시퀀스 번호의 이용방법.
37
Computer Network Lab.
37
IP 스푸핑에 공격당하기 쉬운 서비스들
 RPC(원격 프로시저 호출 서비스
 IP 주소 인증 방법을 사용하는 모든 서비스
 X윈도우 시스템
 R서비스들
38
Computer Network Lab.
38
IP Spoofing 방어(1)
 Router에서 source routing을 허용하지 않음
– 내부 사용자끼리의 IP Spoofing은 막을 수 없
다.
 Sequence number를 Random하게 발생
– Sequence number를 sniff할 수 있는 경우에
는 막을 수 없다.
39
Computer Network Lab.
39
IP Spoofing 방어(2)
 Denial of Service가 발생하지 않도록 함
– IP Spoofing은 Denial of Service가 공격의 시
작이므로 Denial of Service를 막을 수 있다면
IP Spoofing공격을 막을 수 있다.
 IP로 인증하는 서비스는 사용하지 않음
– IP Spoofing은 막을 수 있지만 사용이 상당히
불편해 진다.
40
Computer Network Lab.
40
IP Spoofing 방어(3)
 암호화된 Protocol을 사용
– 암호화된 Protocol을 사용하면 IP Spoofing
공격을 상당히 차단할 수 있지만 속도가 느
려지고 사용이 아직 보편화되어 있지 않다.
41
Computer Network Lab.
41
ARP Spoofing(1)
 IP Spoofing와 비슷
00:00:E2:1F:20:5C
 6바이트 하드웨어 물리 주소를 사용
– 생산시 이더넷 어댑터에 새겨지는 유일한 값
– Ifconfig(리눅스), winipcfg(윈도우)
 ARP 캐시 공격
 공격 대상 호스트와 캐시에 가짜 매핑 정보를 전
송
 공격 대상 호스트가 보내는 패킷은 공격자의 하
드웨어 주소로 라우팅
 공격자를 신뢰
42
Computer Network Lab.
42
ARP Spoofing(2)
 ARP 스푸핑의 문제점
– 지능적인 하드웨어는 발신지 주소상의 세그먼트
와 다른 세그먼트에서 들어온 패킷을 무시
– 캐시 항목은 5분마다 폐기되므로, 공격자는 빠
른 시간 내에 다시 캐시를 갱신
 ARP 스푸핑 방어
– 주소 매핑 정보를 하드웨어에 기록
– ARPWATCH 사용(EMAIL, Log)
 ftp://ftp.su.se/pub/security/tools/au
dit/arpwatch-2.1a4.tar.gz
43
Computer Network Lab.
43
DNS Spoofing(1)
 DNS Server를 공격해서,
 (Host Name-IP Address) 테이블을 변경,
 Client가 lookup을 요청하면, fake 주소를 제공
 CIAC 권고안 - “DNS Vulnerabilities”
– 잘못된 DNS 정보가 미치는 영향에 대해 고려해
야 한다…침입자는 spoofed 데이터를 제공함으
로써 이 정보를 이용한 인증 방법을 사용하는 시
스템과 프로그램에 영향을 미친다.
44
Computer Network Lab.
44
DNS Spoofing(2) - Utilities
 ERECT
– http://www.geocities.com/SiliconValley/P
eaks/7837/explo/any-erect.txt
 Snoof
– http://www.c0p.org/security/feb/snoof.tg
z
 Jizz
– http://bob.urs2.net/computer_security/15
2cscripts/jizz.c
45
Computer Network Lab.
45
DNS Spoofing(3) - 방어
 다른 DNS 서버와 테이블 비교
 DOC(Domain Obscenity Control) 사용
– ftp://coast.cs.purdue.edu/pub/tools/unix/
doc.2.0.tar.Z
 Reverse DNS 방법
– Host name-IP와 IP-host name을 비교
– 문제점
 공격자가 양쪽 테이블을 모두 바꾼다면 해결책
이 없음.
46
Computer Network Lab.
46
Other Utilities
 Spoofscan
–
–
–
–
–
만든이 : 루트쉘(Rootshell)
사용언어: C
필요조건: C, net 인클루드 파일들
http://24.92.91.91/Members/pROcon/exploits/spoofscan.txt
발신지 주소를 속이는 방법을 이용하여 포트 스캔을 구현하였다.
 pmap_set/unset
–
–
–
–
–
만든이 : 패트릭 길버트(Patrick Gilbert)
사용언어: C
필요조건: C, net 인클루드 파일들
http://www.pgci.ca/rpc.html
rcpbind를 속이기 위한 리눅스 툴킷,
47
Computer Network Lab.
47
Other Utilities
 ICQ File transfer spoofer v.0001
– 만든이 : 에릭 핸슨(Eric Hanson) 등
– 사용언어: C++
– 필요조건: C++(g++), net 인클루드 파일들
– http://www.webstore.fr/~tahiti/icqspoof2.txt
– ICQ 스푸핑 유틸리티
 Syslog-poison.c
– 만든이 : 감마(Gamma)’98
– 사용언어: C
– 필요조건: C, net 인클루드 파일들
– http://www.jabukie.com/Unix_Sourcez/syslog-position.c.html
– 포트 514번을 통해 syslog를 속이는 유틸리티
48
Computer Network Lab.
48
Other Utilities
 ICQ Hijaak
–
–
–
–
만든이 : 울브즈베인(Wolvesbane)
사용언어: C
필요조건: C, net 인클루드 파일들
http://www.geocities.com/SiliconValley/Sector/8208/ICQHack.ht
m
– ICQ를 속여서 세션을 가로채고 사용자 패스워드를 변경하여
메시지를 속이도록 하는 유틸리티
 icqspoof.c
– 만든이 : 쎄쓰 맥관(Seth McGann)
– 사용언어: C
– 필요조건: C, net 인클루드 파일들
– http://www2.hotmanscave.com/file/icqspoof.c
– ICQ를 속이는 프로그램으로 임의의 사용자 ID 번호를 이용해
49
서 메시지를 보낼 수 있도록 한다.
49
Computer Network Lab.
Other Utilities
 RIP spoof.c
–
–
–
–
–
만든이 : 키트 녹스(Kit Knox)
사용언어: C
필요조건: C, net 인클루드 파일들
http://www2.mwis.net/~pacman/source/rip.c
라우팅 정보 프로토콜(RIP)을 속이는 프로그램
 syslog_deluxe
–
–
–
–
–
만든이 : 유리 볼로부에스키(Yuri Volobuev)
사용언어: C
필요조건: C, net 인클루드 파일들
http://www.martnet.com/~johnny/exploits/network/syslog_deluxe.c
syslog 메시지를 속이기 위한 도구
50
Computer Network Lab.
50
Other Utilities
 Spoofkey
–
–
–
–
–
만든이 : 그렉 밀러(Greg Miller)
사용언어: C++
필요조건: C++
http://www.fastlane.net/homepages/thegnome/faqs/netware/a~02.html
노벨 넷웨어의 바인더리 모드 로그인 프로토콜(bindery mode login
protocol)을 속이기 위한 프로그램,
 sirc4
–
–
–
–
–
만든이 : 조한(Johan)
사용언어: C
필요조건: C, net 인클루드 파일들
http:/www.firosoft.com/security/philez/utilities/c/sirc4_tar.tar
IRC와 텔넷 스푸핑 유틸리티
51
Computer Network Lab.
51
Reference
 “A Simple TCP Spoofing Attack” 시큐어 네트워크 사.





http://www.tao.ca/fire/bos/old/1/o344.html
“A Weakness in the 4.2BSD UNIZ TCP/IP Software”, AT&T 벨 연구
소의 로버트 모리스의 기술 보고서.
ftp://research.att.com/dist/internet_/117.ps.Z
“Sequence Number Attacks”, 릭 패로우(Rik Farrow).
http://www.mindrape.org/papers/sequence.attacks.txt
“Defending Against Sequence Number Attacks”, 벨로빈(S. Bellovin).
RFC 1948. http://nic.mil/fip/rfc/rfc1948.txt
“A Short Overview of IP Spoofing”, 브레치 클래헛(Brecht
Claerhout). http://sunshine.nextra.ro/FUN/New/hacking/IP-spoof.txt
“Internet Holes~Eliminating IP Address Forgery”,
http://solaris1.mysolution.com/~rezell/files/text/ipaddressforgery.txt
52
Computer Network Lab.
52
Reference
 “Ask Woody about Spoofing Attacks”, 조케일 엔지니어링 사의 빌
우드칵(Bill Woodcock).
http://www.netsurf.com/nsf/v01/01/local/spoof.html
 “IP-spoofing Demystified Trust-Relationship Exploitation”, 마이클
쉬프만(Michael Schiffman, [email protected]).
http://www.fc.phrack/files/p48/p48-14.html
 “Hyperlink Spoofing: An Attack on SSL Server Authentication:, 프랭
크오드와이어(Frank O’Dwyer). SSL 인증 방법에 대한 공격 방법을
설명. http://www.brd.ie/papers/sslpaper/sslpaper.html
 “Web Spoofing: An Internet Con Game”, 에드워드 펠튼(Edward W.
Felten), 더크 발팬즈(Dirk Balfanz), 드루 딘(Drew Dean). 댄 왈치(Dan S. Wallach), 프링스턴 대학의 기술 보고소서 540-96
(http://www.cs.princeton.edu/sip/pub/spoofing.doc)
53
Computer Network Lab.
53
결론
 스푸핑 공격은 발견하기 힘들다.
 R 명령어를 사용하지 않는다.
 암호화된 인증 방법 사용
 SSH(Secure Shell)
–
–
–
–
BlowFish
Triple DES
IDEA
RSA
54
Computer Network Lab.
54