Skip to content

Commit 2c8f27c

Browse files
committed
More general cleanup including is_local db check
1 parent 2d85ef7 commit 2c8f27c

File tree

13 files changed

+59
-131
lines changed

13 files changed

+59
-131
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ group :development do
2323
# module documentation
2424
gem 'octokit'
2525
# Metasploit::Aggregator external session proxy
26-
2726
# Disabled for now for crypttlv updates
2827
# gem 'metasploit-aggregator'
2928
end

Gemfile.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ GEM
110110
bindata (2.4.1)
111111
bit-struct (0.16)
112112
builder (3.2.3)
113-
coderay (1.1.1)
114113
coderay (1.1.2)
114+
daemons (1.2.4)
115115
diff-lcs (1.3)
116116
dnsruby (1.60.2)
117117
docile (1.1.5)
@@ -315,7 +315,6 @@ GEM
315315
rack (~> 1.5)
316316
rack-protection (~> 1.4)
317317
tilt (>= 1.3, < 3)
318-
slop (3.6.0)
319318
sqlite3 (1.3.13)
320319
sshkey (1.9.0)
321320
thin (1.7.1)

lib/metasploit/framework/data_service/proxy/core.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def error
2929
return "none"
3030
end
3131

32+
def is_local?
33+
if (@data_service)
34+
return (@data_service.name == 'local_db_service')
35+
end
36+
37+
return false
38+
end
39+
3240
#
3341
# Determines if the data service is active
3442
#
@@ -117,7 +125,7 @@ def print_data_services()
117125
# Used to bridge the local db
118126
#
119127
def method_missing(method, *args, &block)
120-
puts "Attempting to delegate method: #{method}"
128+
#puts "Attempting to delegate method: #{method}"
121129
unless @data_service.nil?
122130
@data_service.send(method, *args, &block)
123131
end

lib/metasploit/framework/data_service/remote/http/remote_session_data_service.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def report_session(opts)
1010
opts[:host] = opts[:host].address
1111
end
1212

13-
#TODO: Fix
1413
opts[:time_stamp] = Time.now.utc
1514
self.post_data_async(SESSION_API_PATH, opts)
1615
end
@@ -43,7 +42,7 @@ def parse_host_opts(msf_session)
4342
def parse_session_data(msf_session)
4443
hash = Hash.new()
4544
# TODO: what to do with this shiz
46-
# hash[:datastore] = msf_session.exploit_datastore.to_h
45+
hash[:datastore] = msf_session.exploit_datastore.to_h
4746
hash[:desc] = msf_session.info
4847
hash[:local_id] = msf_session.sid
4948
hash[:platform] = msf_session.session_type

lib/metasploit/framework/parsed_options/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def option_parser
137137
options.database.config = path
138138
end
139139

140-
option_parser.on('-dbrp', 'Run database as a remote process') do
140+
option_parser.on('-dbrp', 'Run database as a separate local process') do
141141
options.database.remote_process = true
142142
end
143143

lib/msf/core/auxiliary/scanner.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ def peer
6161
super.ljust(21)
6262
end
6363

64-
def formatted_duration (total_seconds)
65-
hours = total_seconds / (60 * 60)
66-
minutes = (total_seconds / 60) % 60
67-
seconds = total_seconds % 60
68-
69-
" #{ hours } h #{ minutes } m #{ seconds } s"
70-
end
71-
7264
#
7365
# The command handler when launched from the console
7466
#
@@ -121,8 +113,6 @@ def run
121113

122114
if (self.respond_to?('run_host'))
123115

124-
start_time = Time.now.to_i
125-
126116
loop do
127117
# Stop scanning if we hit a fatal error
128118
break if has_fatal_errors?
@@ -181,8 +171,6 @@ def run
181171
scanner_show_progress() if @show_progress
182172
end
183173

184-
puts "Time to scan hosts: #{formatted_duration(Time.now.to_i - start_time)}"
185-
186174
scanner_handle_fatal_errors
187175
return
188176
end

lib/msf/core/db_manager.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ def initialize(framework, opts = {})
131131
return
132132
end
133133

134-
init_success = initialize_database_support
135-
136-
return init_success
134+
return initialize_database_support
137135
end
138136

139137
#

lib/msf/core/db_manager.tar.gz

-64.1 KB
Binary file not shown.

lib/msf/core/framework.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def threads?
232232
def search(match, logger: nil)
233233
# Check if the database is usable
234234
use_db = true
235-
if self.db
235+
if self.db and self.db.is_local?
236236
if !(self.db.migrated && self.db.modules_cached)
237237
logger.print_warning("Module database cache not built yet, using slow search") if logger
238238
use_db = false
@@ -336,19 +336,19 @@ def on_module_error(instance, exception=nil)
336336

337337
include ::Msf::UiEventSubscriber
338338
##
339-
# :category: ::Msf::Uips -ef | EventSubscriber implementors
339+
# :category: ::Msf::UiEventSubscriber implementors
340340
def on_ui_command(command)
341-
# if framework.db.active
342-
# report_event(:name => "ui_command", :info => {:command => command})
343-
# end
341+
if (framework.db and framework.db.active)
342+
report_event(:name => "ui_command", :info => {:command => command})
343+
end
344344
end
345345

346346
##
347347
# :category: ::Msf::UiEventSubscriber implementors
348348
def on_ui_stop()
349-
# if framework.db.active
350-
# report_event(:name => "ui_stop")
351-
# end
349+
if (framework.db and framework.db.active)
350+
report_event(:name => "ui_stop")
351+
end
352352
end
353353

354354
##

lib/msf/core/module_manager/cache.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ def refresh_cache_from_database(allowed_paths=[""])
131131
# @return [true] if migrations have been run
132132
# @return [false] otherwise
133133
def framework_migrated?
134+
if (framework.db)
135+
if (framework.db.is_local?)
136+
return framework.db.migrated
137+
end
138+
end
139+
134140
return false
135-
#framework.db && framework.db.migrated
136141
end
137142

138143
# @!attribute [rw] module_info_by_path

0 commit comments

Comments
 (0)