Skip to content

Commit 227418b

Browse files
committed
Make AR a soft dependency again
Ensures that the absence of activerecord does not prevent msfconsole from loading. This returns us to the previous state of affairs where it is possible to use the framework entirely without a database. To test: 1. rm -rf lib/gemcache/ruby/1.9.1/gems/activerecord* 2. remove any locally installed versions of activerecord 3. msfconsole msfconsole should load up with a warning like so: [-] *** [-] * WARNING: No database support: LoadError cannot load such file -- active_record [-] *** ... and should still be functional.
1 parent 3888c52 commit 227418b

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lib/msf/core/db_manager.rb

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
# -*- coding: binary -*-
2-
require "active_record"
32

43
require 'msf/core'
54
require 'msf/core/db'
65
require 'msf/core/task_manager'
76
require 'fileutils'
87
require 'shellwords'
98

10-
# Provide access to ActiveRecord models shared w/ commercial versions
11-
require "metasploit_data_models"
12-
13-
# Patches issues with ActiveRecord
14-
require "msf/core/patches/active_record"
15-
16-
17-
189
module Msf
1910

2011
###
@@ -36,16 +27,6 @@ def self.warn_about_rubies
3627
end
3728
end
3829

39-
# Only include Mdm if we're not using Metasploit commercial versions
40-
# If Mdm::Host is defined, the dynamically created classes
41-
# are already in the object space
42-
begin
43-
include MetasploitDataModels unless defined? Mdm::Host
44-
rescue NameError => e
45-
warn_about_rubies
46-
raise e
47-
end
48-
4930
# Provides :framework and other accessors
5031
include Framework::Offspring
5132

@@ -117,6 +98,14 @@ def initialize_database_support
11798
# Database drivers can reset our KCODE, do not let them
11899
$KCODE = 'NONE' if RUBY_VERSION =~ /^1\.8\./
119100

101+
require "active_record"
102+
103+
# Provide access to ActiveRecord models shared w/ commercial versions
104+
require "metasploit_data_models"
105+
106+
# Patches issues with ActiveRecord
107+
require "msf/core/patches/active_record"
108+
120109
@usable = true
121110

122111
rescue ::Exception => e
@@ -125,6 +114,16 @@ def initialize_database_support
125114
return false
126115
end
127116

117+
# Only include Mdm if we're not using Metasploit commercial versions
118+
# If Mdm::Host is defined, the dynamically created classes
119+
# are already in the object space
120+
begin
121+
include MetasploitDataModels unless defined? Mdm::Host
122+
rescue NameError => e
123+
warn_about_rubies
124+
raise e
125+
end
126+
128127
#
129128
# Determine what drivers are available
130129
#

0 commit comments

Comments
 (0)