Skip to content

Commit c26dfa2

Browse files
committed
Ensure IP addresses are explicitly converted to strings
MSP-12113
1 parent 38ded90 commit c26dfa2

File tree

26 files changed

+149
-149
lines changed

26 files changed

+149
-149
lines changed

lib/msf/core/auxiliary/report.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def report_auth_info(opts={})
205205
port = opts[:service].port
206206
proto = opts[:service].proto
207207
service_name = opts[:service].name
208-
host = opts[:service].host.address
208+
host = opts[:service].host.address.to_s
209209
else
210210
port = opts.fetch(:port)
211211
service_name = opts.fetch(:sname, nil)

lib/msf/core/db_export.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def extract_web_site_info(report_file)
482482
end
483483

484484
site = e
485-
el = create_xml_element("host", site.service.host.address)
485+
el = create_xml_element("host", site.service.host.address.to_s)
486486
report_file.write(" #{el}\n")
487487

488488
el = create_xml_element("port", site.service.port)
@@ -509,7 +509,7 @@ def extract_web_info(report_file, tag, entries)
509509
el = create_xml_element("vhost", site.vhost)
510510
report_file.write(" #{el}\n")
511511

512-
el = create_xml_element("host", site.service.host.address)
512+
el = create_xml_element("host", site.service.host.address.to_s)
513513
report_file.write(" #{el}\n")
514514

515515
el = create_xml_element("port", site.service.port)

lib/msf/core/db_manager/service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def report_service(opts)
6565

6666
if addr.kind_of? ::Mdm::Host
6767
host = addr
68-
addr = host.address
68+
addr = host.address.to_s
6969
else
7070
host = report_host(hopts)
7171
end
7272

7373
if opts[:port].to_i.zero?
74-
dlog("Skipping port zero for service '%s' on host '%s'" % [opts[:name],host.address])
74+
dlog("Skipping port zero for service '%s' on host '%s'" % [opts[:name],host.address.to_s])
7575
return nil
7676
end
7777

lib/msf/core/db_manager/session.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def report_session(opts)
137137

138138
s = ::Mdm::Session.new(sess_data)
139139
s.save!
140-
140+
141141
if session and session.exploit_task and session.exploit_task.record
142142
session_task = session.exploit_task.record
143143
if session_task.class == Mdm::Task
@@ -163,7 +163,7 @@ def report_session(opts)
163163
end
164164

165165
vuln_info = {
166-
:host => host.address,
166+
:host => host.address.to_s,
167167
:name => mod_name,
168168
:refs => mod.references,
169169
:workspace => wspace,

lib/msf/core/db_manager/web.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def report_web_site(opts)
242242
host.save!
243243
=end
244244

245-
vhost ||= host.address
245+
vhost ||= host.address.to_s
246246
site = ::Mdm::WebSite.where(vhost: vhost, service_id: serv[:id]).first_or_initialize
247247
site.options = opts[:options] if opts[:options]
248248

lib/msf/core/rpc/v10/rpc_db.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def rpc_create_credential(xopts)
128128
opts[:last_attempted_at] = opts[:last_attempted_at].to_datetime
129129
login = create_credential_login(opts)
130130

131-
ret[:host] = login.service.host.address,
131+
ret[:host] = login.service.host.address.to_s,
132132
ret[:sname] = login.service.name
133133
ret[:status] = login.status
134134
end
@@ -228,7 +228,7 @@ def rpc_services( xopts)
228228
wspace.services.includes(:host).where(conditions).offset(offset).limit(limit).each do |s|
229229
service = {}
230230
host = s.host
231-
service[:host] = host.address || "unknown"
231+
service[:host] = host.address.to_s || "unknown"
232232
service[:created_at] = s[:created_at].to_i
233233
service[:updated_at] = s[:updated_at].to_i
234234
service[:port] = s[:port]
@@ -267,7 +267,7 @@ def rpc_vulns(xopts)
267267
vuln[:proto] = nil
268268
end
269269
vuln[:time] = v.created_at.to_i
270-
vuln[:host] = v.host.address || nil
270+
vuln[:host] = v.host.address.to_s || nil
271271
vuln[:name] = v.name
272272
vuln[:refs] = reflist.join(',')
273273
ret[:vulns] << vuln
@@ -433,7 +433,7 @@ def rpc_get_service(xopts)
433433
services.each do |s|
434434
service = {}
435435
host = s.host
436-
service[:host] = host.address || "unknown"
436+
service[:host] = host.address.to_s || "unknown"
437437
service[:created_at] = s[:created_at].to_i
438438
service[:updated_at] = s[:updated_at].to_i
439439
service[:port] = s[:port]
@@ -482,7 +482,7 @@ def rpc_get_note(xopts)
482482
notes.each do |n|
483483
note = {}
484484
host = n.host
485-
note[:host] = host.address || "unknown"
485+
note[:host] = host.address.to_s || "unknown"
486486
if n.service
487487
note[:port] = n.service.port
488488
note[:proto] = n.service.proto
@@ -508,7 +508,7 @@ def rpc_get_client(xopts)
508508
if(c)
509509
client = {}
510510
host = c.host
511-
client[:host] = host.address
511+
client[:host] = host.address.to_s
512512
client[:created_at] = c.created_at.to_i
513513
client[:updated_at] = c.updated_at.to_i
514514
client[:ua_string] = c.ua_string.to_s
@@ -567,7 +567,7 @@ def rpc_notes(xopts)
567567
note[:time] = n.created_at.to_i
568568
note[:host] = ""
569569
note[:service] = ""
570-
note[:host] = n.host.address if(n.host)
570+
note[:host] = n.host.address.to_s if(n.host)
571571
note[:service] = n.service.name || n.service.port if(n.service)
572572
note[:type ] = n.ntype.to_s
573573
note[:data] = n.data.inspect
@@ -828,7 +828,7 @@ def rpc_events(xopts)
828828

829829
wspace.events.offset(offset).limit(limit).each do |e|
830830
event = {}
831-
event[:host] = e.host.address if(e.host)
831+
event[:host] = e.host.address.to_s if(e.host)
832832
event[:created_at] = e.created_at.to_i
833833
event[:updated_at] = e.updated_at.to_i
834834
event[:name] = e.name
@@ -873,7 +873,7 @@ def rpc_loots(xopts)
873873
ret[:loots] = []
874874
wspace.loots.offset(offset).limit(limit).each do |l|
875875
loot = {}
876-
loot[:host] = l.host.address if(l.host)
876+
loot[:host] = l.host.address.to_s if(l.host)
877877
loot[:service] = l.service.name || l.service.port if(l.service)
878878
loot[:ltype] = l.ltype
879879
loot[:ctype] = l.content_type
@@ -928,7 +928,7 @@ def rpc_get_vuln(xopts)
928928
vulns.each do |v|
929929
vuln= {}
930930
host= v.host
931-
vuln[:host] = host.address || "unknown"
931+
vuln[:host] = host.address.to_s || "unknown"
932932
if v.service
933933
vuln[:port] = v.service.port
934934
vuln[:proto] = v.service.proto

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def cmd_rename_job(*args)
806806
end
807807

808808
# This is not respecting the Protected access control, but this seems to be the only way
809-
# to rename a job. If you know a more appropriate way, patches accepted.
809+
# to rename a job. If you know a more appropriate way, patches accepted.
810810
framework.jobs[job_id].send(:name=, job_name)
811811
print_status("Job #{job_id} updated")
812812

@@ -3108,7 +3108,7 @@ def option_values_target_addrs
31083108
hosts = {}
31093109
framework.db.each_service(framework.db.workspace) do |service|
31103110
if (service.port == mport)
3111-
hosts[ service.host.address ] = true
3111+
hosts[ service.host.address.to_s ] = true
31123112
end
31133113
end
31143114

@@ -3119,7 +3119,7 @@ def option_values_target_addrs
31193119
# List all hosts in the database
31203120
else
31213121
framework.db.each_host(framework.db.workspace) do |host|
3122-
res << host.address
3122+
res << host.address.to_s
31233123
end
31243124
end
31253125

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def cmd_hosts(*args)
301301
host_ranges.each do |range|
302302
range.each do |address|
303303
host = framework.db.find_or_create_host(:host => address)
304-
print_status("Time: #{host.created_at} Host: host=#{host.address}")
304+
print_status("Time: #{host.created_at} Host: host=#{host.address.to_s}")
305305
end
306306
end
307307
return
@@ -338,7 +338,7 @@ def cmd_hosts(*args)
338338

339339
tbl << columns
340340
if set_rhosts
341-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
341+
addr = (host.scope ? host.address.to_s + '%' + host.scope : host.address.to_s )
342342
rhosts << addr
343343
end
344344
if mode == :delete
@@ -489,7 +489,7 @@ def cmd_services(*args)
489489
info[:name] = names.first.downcase if names and names.first
490490

491491
svc = framework.db.find_or_create_service(info)
492-
print_status("Time: #{svc.created_at} Service: host=#{svc.host.address} port=#{svc.port} proto=#{svc.proto} name=#{svc.name}")
492+
print_status("Time: #{svc.created_at} Service: host=#{svc.host.address.to_s} port=#{svc.port} proto=#{svc.proto} name=#{svc.name}")
493493
end
494494
end
495495
return
@@ -520,10 +520,10 @@ def cmd_services(*args)
520520
)
521521
end
522522

523-
columns = [host.address] + col_names.map { |n| service[n].to_s || "" }
523+
columns = [host.address.to_s] + col_names.map { |n| service[n].to_s || "" }
524524
tbl << columns
525525
if set_rhosts
526-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
526+
addr = (host.scope ? host.address.to_s + '%' + host.scope : host.address.to_s )
527527
rhosts << addr
528528
end
529529

@@ -638,12 +638,12 @@ def cmd_vulns(*args)
638638
next unless ports.empty? or ports.include? vuln.service.port
639639
# Same for service names
640640
next unless svcs.empty? or svcs.include?(vuln.service.name)
641-
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
641+
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address.to_s} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
642642

643643
else
644644
# This vuln has no service, so it can't match
645645
next unless ports.empty? and svcs.empty?
646-
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
646+
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address.to_s} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
647647
end
648648
end
649649
end
@@ -920,11 +920,11 @@ def creds_search(*args)
920920
# the user-supplied RangeWalker, then we don't have any reason to
921921
# print it out. However, we treat the absence of ranges as meaning
922922
# all hosts.
923-
if host_ranges.present? && !host_ranges.any? { |range| range.include?(login.service.host.address) }
923+
if host_ranges.present? && !host_ranges.any? { |range| range.include?(login.service.host.address.to_s) }
924924
next
925925
end
926-
row = [ login.service.host.address ]
927-
rhosts << login.service.host.address
926+
row = [ login.service.host.address.to_s ]
927+
rhosts << login.service.host.address.to_s
928928
if login.service.name.present?
929929
row << "#{login.service.port}/#{login.service.proto} (#{login.service.name})"
930930
else
@@ -1089,7 +1089,7 @@ def cmd_notes(*args)
10891089
break if not host
10901090
note = framework.db.find_or_create_note(:host => host, :type => type, :data => data)
10911091
break if not note
1092-
print_status("Time: #{note.created_at} Note: host=#{host.address} type=#{note.ntype} data=#{note.data}")
1092+
print_status("Time: #{note.created_at} Note: host=#{host.address.to_s} type=#{note.ntype} data=#{note.data}")
10931093
}
10941094
}
10951095
return
@@ -1156,9 +1156,9 @@ def cmd_notes(*args)
11561156
msg = "Time: #{note.created_at} Note:"
11571157
if (note.host)
11581158
host = note.host
1159-
msg << " host=#{note.host.address}"
1159+
msg << " host=#{note.host.address.to_s}"
11601160
if set_rhosts
1161-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
1161+
addr = (host.scope ? host.address.to_s + '%' + host.scope : host.address.to_s )
11621162
rhosts << addr
11631163
end
11641164
end
@@ -1314,7 +1314,7 @@ def cmd_loot(*args)
13141314
)
13151315
end
13161316
row = []
1317-
row.push( (loot.host ? loot.host.address : "") )
1317+
row.push( (loot.host ? loot.host.address.to_s : "") )
13181318
if (loot.service)
13191319
svc = (loot.service.name ? loot.service.name : "#{loot.service.port}/#{loot.service.proto}")
13201320
row.push svc

lib/rex/parser/burp_session_nokogiri.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def report_web_host_info
155155
return unless @state[:uri].kind_of? URI::HTTP
156156
return unless @state[:web_site].service.host.name.to_s.empty?
157157
host_info = {:workspace => @args[:wspace]}
158-
host_info[:address] = @state[:web_site].service.host.address
158+
host_info[:address] = @state[:web_site].service.host.address.to_s
159159
host_info[:name] = @state[:uri].host
160160
report_db(:host, host_info)
161161
end

modules/auxiliary/analyze/jtr_oracle_fast.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def crack(format)
5151
print_error("Unable to read #{myloot.path} \n #{e}")
5252
end
5353
oracle_array.each do |row|
54-
hashlist.write("#{row[0]}:#{row[1]}:#{myloot.host.address}:#{myloot.service.port}\n")
54+
hashlist.write("#{row[0]}:#{row[1]}:#{myloot.host.address.to_s}:#{myloot.service.port}\n")
5555
end
5656
end
5757
hashlist.close

0 commit comments

Comments
 (0)