1
1
# -*- coding: binary -*-
2
- require "active_record"
3
2
4
3
require 'msf/core'
5
4
require 'msf/core/db'
6
5
require 'msf/core/task_manager'
7
6
require 'fileutils'
8
7
require 'shellwords'
9
8
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
-
18
9
module Msf
19
10
20
11
###
@@ -28,24 +19,14 @@ class DBManager
28
19
29
20
# Mainly, it's Ruby 1.9.1 that cause a lot of problems now, along with Ruby 1.8.6.
30
21
# Ruby 1.8.7 actually seems okay, but why tempt fate? Let's say 1.9.3 and beyond.
31
- def self . warn_about_rubies
22
+ def warn_about_rubies
32
23
if ::RUBY_VERSION =~ /^1\. 9\. [012]($|[^\d ])/
33
24
$stderr. puts "**************************************************************************************"
34
25
$stderr. puts "Metasploit requires at least Ruby 1.9.3. For an easy upgrade path, see https://rvm.io/"
35
26
$stderr. puts "**************************************************************************************"
36
27
end
37
28
end
38
29
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
-
49
30
# Provides :framework and other accessors
50
31
include Framework ::Offspring
51
32
@@ -117,6 +98,14 @@ def initialize_database_support
117
98
# Database drivers can reset our KCODE, do not let them
118
99
$KCODE = 'NONE' if RUBY_VERSION =~ /^1\. 8\. /
119
100
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
+
120
109
@usable = true
121
110
122
111
rescue ::Exception => e
@@ -125,6 +114,18 @@ def initialize_database_support
125
114
return false
126
115
end
127
116
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
+ unless defined? Mdm ::Host
122
+ self . class . send :include , MetasploitDataModels
123
+ end
124
+ rescue NameError => e
125
+ warn_about_rubies
126
+ raise e
127
+ end
128
+
128
129
#
129
130
# Determine what drivers are available
130
131
#
0 commit comments