Linux Security Spoofing 1 Computer Network Lab 1
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 – Sequence Number Guessing – IP Spoofing 방어 | ARP 스푸핑 | DNS 스푸핑 | Other Utilities | Reference | 결론 3 Computer Network Lab. 3
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_int 8_t ip_hl: 4; /* header length */ u_int 8_t ip_v: 4; /* version */ u_int 8_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_int 8_t ip_ttl; /* time to live */ u_int 8_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의 구조(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_int 16_t th_sport; u_int 16_t th_dport; tcp_seq th_seq; tcp_seq th_ack; u_int 8_t th_x 2: 4; u_int 8_t th_off: 4; u_int 8_t th_flags; u_int 16_t th_win; u_int 16_t th_sum; u_int 16_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의 구조(5) 16 Computer Network Lab. 16
TCP Connection | TCP 3 -way handshake Host A Host B Segment 1 : S YN Seq: 1200, ack : -- +ACK N Y S : 2 t n Segme 1201 : k c a , 0 0 8 4 Seq: Segment 3 : Seq: 1201, a ACK ck: 4801 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
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
mendax를 이용한 IP Spoofing(1) | mendax의 사용 방법 Usage: mendax [OPTIONS] <source> <target> [<gateway>] -p -s -l -r -c -w -d -t -L -S PORT 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) | 64 K Rule – SYN packet을 하나 받을 때마다, sequence number를 64000씩 증가 시킴 HP-UX all versions IRIX 5. 3 and before OSF 3. 2 and before Sun. OS 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 Sun. OS 5. 5 and after Microsoft Windows all versions Linux 1. x and before Free. BSD 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
IP Spoofing 방어(1) | Router에서 source routing을 허용하지 않음 – 내부 사용자끼리의 IP Spoofing은 막을 수 없 다. | Sequence number를 Random하게 발생 – Sequence number를 sniff할 수 있는 경우에는 막을 수 없다. 39 Computer Network Lab. 39
DNS Spoofing(2) - Utilities | ERECT – http: //www. geocities. com/Silicon. Valley/P eaks/7837/explo/any-erect. txt | Snoof – http: //www. c 0 p. org/security/feb/snoof. tgz | Jizz – http: //bob. urs 2. net/computer_security/15 2 cscripts/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 | ICQ File transfer spoofer v. 0001 – 만든이 : 에릭 핸슨(Eric Hanson) 등 – 사용언어: C++ – 필요조건: C++(g++), net 인클루드 파일들 – http: //www. webstore. fr/~tahiti/icqspoof 2. 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 | RIP spoof. c – 만든이 : 키트 녹스(Kit Knox) – 사용언어: C – 필요조건: C, net 인클루드 파일들 – http: //www 2. 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)을 속이기 위한 프로그램, | sirc 4 – – – 만든이 : 조한(Johan) 사용언어: C 필요조건: C, net 인클루드 파일들 http: /www. firosoft. com/security/philez/utilities/c/sirc 4_tar. tar IRC와 텔넷 스푸핑 유틸리티 51 Computer Network Lab. 51
Reference | “A Simple TCP Spoofing Attack” 시큐어 네트워크 사. | | | http: //www. tao. ca/fire/bos/old/1/o 344. html “A Weakness in the 4. 2 BSD 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 1948. 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: //solaris 1. 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/v 01/01/local/spoof. html | “IP-spoofing Demystified Trust-Relationship Exploitation”, 마이클 쉬프만(Michael Schiffman, route@infonexus. com). http: //www. fc. phrack/files/p 48 -14. html | “Hyperlink Spoofing: An Attack on SSL Server Authentication: , 프랭 크오드와이어(Frank O’Dwyer). SSL 인증 방법에 대한 공격 방법을 설명. http: //www. brd. ie/papers/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
- Slides: 54