Skip to content

Commit 1ada483

Browse files
committed
Land rapid7#3293, module deprecation constants
2 parents de49241 + ec1f7d6 commit 1ada483

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

lib/msf/core/module/deprecated.rb

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,50 @@ def deprecation_date; @deprecation_date; end
3333
end
3434

3535
# (see ClassMethods#replacement_module)
36-
def replacement_module; self.class.replacement_module; end
36+
def replacement_module
37+
if self.class.instance_variable_defined?(:@replacement_module)
38+
return self.class.replacement_module
39+
elsif self.class.const_defined?(:DEPRECATION_REPLACEMENT)
40+
return self.class.const_get(:DEPRECATION_REPLACEMENT)
41+
end
42+
end
43+
3744
# (see ClassMethods#deprecation_date)
38-
def deprecation_date; self.class.deprecation_date; end
45+
def deprecation_date
46+
if self.class.instance_variable_defined?(:@deprecation_date)
47+
return self.class.deprecation_date
48+
elsif self.class.const_defined?(:DEPRECATION_DATE)
49+
return self.class.const_get(:DEPRECATION_DATE)
50+
end
51+
end
3952

4053
# Extends with {ClassMethods}
4154
def self.included(base)
4255
base.extend(ClassMethods)
4356
end
4457

45-
def setup
58+
# Print the module deprecation information
59+
#
60+
# @return [void]
61+
def print_deprecation_warning
4662
print_warning("*"*72)
47-
print_warning("*%red"+"This module is deprecated!".center(70)+"%clr*")
63+
print_warning("*%red"+"The module #{refname} is deprecated!".center(70)+"%clr*")
4864
if deprecation_date
4965
print_warning("*"+"It will be removed on or about #{deprecation_date}".center(70)+"*")
5066
end
5167
if replacement_module
5268
print_warning("*"+"Use #{replacement_module} instead".center(70)+"*")
5369
end
5470
print_warning("*"*72)
71+
end
72+
73+
def generate
74+
print_deprecation_warning
75+
super
76+
end
77+
78+
def setup
79+
print_deprecation_warning
5580
super
5681
end
5782

modules/payloads/stagers/windows/reverse_ipv6_http.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66

77
require 'msf/core'
88
require 'msf/core/handler/reverse_ipv6_http'
9-
9+
require 'msf/core/module/deprecated'
1010

1111
module Metasploit3
1212

1313
include Msf::Payload::Stager
1414
include Msf::Payload::Windows
15+
include Msf::Module::Deprecated
16+
17+
DEPRECATION_DATE = Date.new(2014, 7, 30)
18+
DEPRECATION_REPLACEMENT = 'windows/meterpreter/reverse_https'
1519

1620
def initialize(info = {})
1721
super(merge_info(info,

modules/payloads/stagers/windows/reverse_ipv6_https.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
55

6+
67
require 'msf/core'
78
require 'msf/core/handler/reverse_ipv6_https'
9+
require 'msf/core/module/deprecated'
810

911
module Metasploit3
1012

1113
include Msf::Payload::Stager
1214
include Msf::Payload::Windows
15+
include Msf::Module::Deprecated
16+
17+
DEPRECATION_DATE = Date.new(2014, 7, 30)
18+
DEPRECATION_REPLACEMENT = 'windows/meterpreter/reverse_https'
1319

1420
def initialize(info = {})
1521
super(merge_info(info,

0 commit comments

Comments
 (0)