Skip to content

Commit 71a650f

Browse files
committed
Land rapid7#3259, XMPP Hostname autodetect by @TomSellers
2 parents 54346f3 + 1f452aa commit 71a650f

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

modules/auxiliary/scanner/ssl/openssl_heartbleed.rb

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def initialize
102102
'Christian Mehlmauer', # Msf module
103103
'wvu', # Msf module
104104
'juan vazquez', # Msf module
105-
'Sebastiano Di Paola' # Msf module
105+
'Sebastiano Di Paola', # Msf module
106+
'Tom Sellers' # Msf module
106107
],
107108
'References' =>
108109
[
@@ -193,22 +194,35 @@ def tls_pop3
193194
res
194195
end
195196

196-
def tls_jabber
197+
def jabber_connect_msg(hostname)
197198
# http://xmpp.org/extensions/xep-0035.html
198199
msg = "<stream:stream xmlns='jabber:client' "
199200
msg << "xmlns:stream='http://etherx.jabber.org/streams' "
200201
msg << "version='1.0' "
201-
msg << "to='#{datastore['XMPPDOMAIN']}'>"
202-
sock.put(msg)
202+
msg << "to='#{hostname}'>"
203+
end
204+
205+
def tls_jabber
206+
sock.put(jabber_connect_msg(datastore['XMPPDOMAIN']))
203207
res = sock.get
204-
if res.nil? || res =~ /stream:error/ || res !~ /<starttls xmlns=['"]urn:ietf:params:xml:ns:xmpp-tls['"]/
205-
vprint_error("#{peer} - Jabber host unknown. Please try changing the XMPPDOMAIN option.") if res && res =~ /<host-unknown/
208+
if res && res.include?('host-unknown')
209+
jabber_host = res.match(/ from='([\w.]*)' /)
210+
if jabber_host && jabber_host[1]
211+
disconnect
212+
connect
213+
vprint_status("#{peer} - Connecting with autodetected remote XMPP hostname: #{jabber_host[1]}...")
214+
sock.put(jabber_connect_msg(jabber_host[1]))
215+
res = sock.get
216+
end
217+
end
218+
if res.nil? || res.include?('stream:error') || res !~ /<starttls xmlns=['"]urn:ietf:params:xml:ns:xmpp-tls['"]/
219+
vprint_error("#{peer} - Jabber host unknown. Please try changing the XMPPDOMAIN option.") if res && res.include?('host-unknown')
206220
return nil
207221
end
208222
msg = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
209223
sock.put(msg)
210224
res = sock.get
211-
return nil if res.nil? || res !~ /<proceed/
225+
return nil if res.nil? || !res.include?('<proceed')
212226
res
213227
end
214228

0 commit comments

Comments
 (0)