Skip to content

Commit 1f3ec46

Browse files
committed
Heartbleed - Add autodetection of XMPP hostname (round 2)
Add the ability to scrape the hostname from the XMPP error message when connecting to an XMPP (Jabber) server. This allows the connection to get far enough to negotiate a TLS tunnel with STARTTLS. The manually specified domain, if present, will be used first and then the hostname autodetection will kick in if that fails. This version addresses issues that FireFart (Thanks!) brought up about code quality and connection reliability.
1 parent 0360d11 commit 1f3ec46

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

modules/auxiliary/scanner/ssl/openssl_heartbleed.rb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,29 +192,28 @@ def tls_pop3
192192
end
193193
res
194194
end
195-
196-
def tls_jabber
195+
196+
def jabber_connect_msg(hostname)
197197
# http://xmpp.org/extensions/xep-0035.html
198198
msg = "<stream:stream xmlns='jabber:client' "
199199
msg << "xmlns:stream='http://etherx.jabber.org/streams' "
200200
msg << "version='1.0' "
201-
msg << "to='#{datastore['XMPPDOMAIN']}'>"
202-
sock.put(msg)
201+
msg << "to='#{hostname}'>"
202+
end
203+
204+
def tls_jabber
205+
sock.put( jabber_connect_msg(datastore['XMPPDOMAIN']) )
203206
res = sock.get
204-
if res && res =~ /host-unknown/
207+
if res && res =~ /host-unknown/
205208
jabber_host = res.match(/ from='([\w.]*)' /)
206-
if jabber_host
209+
if jabber_host && jabber_host[1]
210+
disconnect
207211
connect
208212
vprint_status("#{peer} - Connecting with autodetected remote XMPP hostname: #{jabber_host[1]}...")
209-
msg = "<stream:stream xmlns='jabber:client' "
210-
msg << "xmlns:stream='http://etherx.jabber.org/streams' "
211-
msg << "version='1.0' "
212-
msg << "to='#{jabber_host[1]}'>"
213-
sock.put(msg)
213+
sock.put( jabber_connect_msg(jabber_host[1]) )
214214
res = sock.get
215215
end
216216
end
217-
218217
if res.nil? || res =~ /stream:error/ || res !~ /<starttls xmlns=['"]urn:ietf:params:xml:ns:xmpp-tls['"]/
219218
vprint_error("#{peer} - Jabber host unknown. Please try changing the XMPPDOMAIN option.") if res && res =~ /<host-unknown/
220219
return nil
@@ -226,6 +225,8 @@ def tls_jabber
226225
res
227226
end
228227

228+
229+
229230
def tls_ftp
230231
# http://tools.ietf.org/html/rfc4217
231232
res = sock.get

0 commit comments

Comments
 (0)