CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/common_engine.rb
Views: 11779
1
#
2
# Standard Library
3
#
4
5
require 'fileutils'
6
7
#
8
# Metasploit gem engines
9
#
10
11
require 'metasploit/model/engine'
12
require 'metasploit/concern/engine'
13
require 'metasploit/framework/require'
14
Metasploit::Framework::Require.optionally_require_metasploit_db_gem_engines
15
16
# `Rails::Engine` behavior common to both {Metasploit::Framework::Application} and {Metasploit::Framework::Engine}.
17
module Metasploit::Framework::CommonEngine
18
extend ActiveSupport::Concern
19
20
included do
21
#
22
# config
23
#
24
25
# Force binary encoding to remove necessity to set external and internal encoding when construct Strings from
26
# from files. Socket#read always returns a String in ASCII-8bit encoding
27
#
28
# @see http://rubydoc.info/stdlib/core/IO:read
29
config.before_initialize do
30
encoding = 'binary'
31
::Encoding.default_external = encoding
32
::Encoding.default_internal = encoding
33
end
34
35
config.root = Msf::Config::install_root
36
config.paths.add 'app/models', autoload: true
37
config.paths.add 'app/concerns', autoload: true
38
config.paths.add 'data/meterpreter', glob: '**/ext_*'
39
config.paths.add 'modules'
40
41
config.active_support.deprecation = :stderr
42
43
if ActiveRecord.respond_to?(:legacy_connection_handling=)
44
ActiveRecord.legacy_connection_handling = false
45
end
46
47
# @see https://github.com/rapid7/metasploit_data_models/blob/54a17149d5ccd0830db742d14c4987b48399ceb7/lib/metasploit_data_models/yaml.rb#L10
48
# @see https://github.com/rapid7/metasploit_data_models/blob/54a17149d5ccd0830db742d14c4987b48399ceb7/lib/metasploit_data_models/base64_serializer.rb#L28-L31
49
ActiveRecord.yaml_column_permitted_classes = (ActiveRecord.yaml_column_permitted_classes + MetasploitDataModels::YAML::PERMITTED_CLASSES).uniq
50
51
#
52
# `initializer`s
53
#
54
55
56
end
57
58
end
59
60