Skip to content

Commit d9947a1

Browse files
committed
Add a mixin for marking deprecated modules
* This mixin standardizes the previously ad-hoc deprecation warnings on modules that have been moved. * Uses the mixin in 3 existing modules that already have (or should have had) deprecation warnings.
1 parent f7543e1 commit d9947a1

File tree

4 files changed

+72
-23
lines changed

4 files changed

+72
-23
lines changed

lib/msf/core/module/deprecated.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
module Msf::Module::Deprecated
3+
4+
# Additional class methods for deprecated modules
5+
module ClassMethods
6+
# Mark this module as deprecated
7+
#
8+
# Any time this module is run it will print warnings to that effect.
9+
#
10+
# @param deprecation_date [Date,#to_s] The date on which this module will
11+
# be removed
12+
# @param replacement_module [String] The name of a module that users
13+
# should be using instead of this deprecated one
14+
# @return [void]
15+
def deprecated(deprecation_date=nil, replacement_module=nil)
16+
# Yes, class instance variables.
17+
@replacement_module = replacement_module
18+
@deprecation_date = deprecation_date
19+
end
20+
21+
# The name of a module that users should be using instead of this
22+
# deprecated one
23+
#
24+
# @return [String,nil]
25+
# @see ClassMethods#deprecated
26+
def replacement_module; @replacement_module; end
27+
28+
# The date on which this module will be removed
29+
#
30+
# @return [Date,nil]
31+
# @see ClassMethods#deprecated
32+
def deprecation_date; @deprecation_date; end
33+
end
34+
35+
# (see ClassMethods#replacement_module)
36+
def replacement_module; self.class.replacement_module; end
37+
# (see ClassMethods#deprecation_date)
38+
def deprecation_date; self.class.deprecation_date; end
39+
40+
# Extends with {ClassMethods}
41+
def self.included(base)
42+
base.extend(ClassMethods)
43+
end
44+
45+
def setup
46+
print_warning("*"*72)
47+
print_warning("*%red"+"This module is deprecated!".center(70)+"%clr*")
48+
if deprecation_date
49+
print_warning("*"+"It will be removed on or about #{deprecation_date}".center(70)+"*")
50+
end
51+
if replacement_module
52+
print_warning("*"+"Use #{replacement_module} instead".center(70)+"*")
53+
end
54+
print_warning("*"*72)
55+
super
56+
end
57+
58+
end

modules/post/windows/escalate/bypassuac.rb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
##
2-
# $Id$
3-
##
4-
51
##
62
# This file is part of the Metasploit Framework and may be subject to
73
# redistribution and commercial restrictions. Please see the Metasploit
@@ -14,6 +10,10 @@
1410

1511
class Metasploit3 < Msf::Post
1612

13+
require 'msf/core/module/deprecated'
14+
include Msf::Module::Deprecated
15+
deprecated Date.new(2013,1,4), "exploit/windows/local/bypassuac"
16+
1717
def initialize(info={})
1818
super( update_info( info,
1919
'Name' => 'Windows Escalate UAC Protection Bypass',
@@ -24,7 +24,6 @@ def initialize(info={})
2424
},
2525
'License' => MSF_LICENSE,
2626
'Author' => [ 'David Kennedy "ReL1K" <kennedyd013[at]gmail.com>', 'mitnick' ],
27-
'Version' => '$Revision$',
2827
'Platform' => [ 'win' ],
2928
'SessionTypes' => [ 'meterpreter' ],
3029
'References' => [
@@ -41,12 +40,6 @@ def initialize(info={})
4140
end
4241

4342
def run
44-
print_error("***********************************************")
45-
print_error("* *")
46-
print_error("* Module will be depricated on Jan 4 2013 *")
47-
print_error("* Please use exploits/windows/local/bypassuac *")
48-
print_error("* *")
49-
print_error("***********************************************")
5043
vuln = false
5144
sysinfo = session.sys.config.sysinfo
5245
winver = sysinfo["OS"]

modules/post/windows/escalate/ms10_092_schelevator.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212

1313

1414
class Metasploit3 < Msf::Post
15+
16+
#require 'msf/core/module/deprecated'
17+
load 'lib/msf/core/module/deprecated.rb'
18+
include Msf::Module::Deprecated
19+
deprecated Date.new(2013,6,1), "exploit/windows/local/ms10_092_schelevator"
20+
1521
include Msf::Post::Common
1622

1723
def initialize(info={})

modules/post/windows/escalate/service_permissions.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
##
2-
# $Id$
3-
##
4-
51
##
62
# This file is part of the Metasploit Framework and may be subject to
73
# redistribution and commercial restrictions. Please see the Metasploit
@@ -12,10 +8,13 @@
128
require 'msf/core'
139
require 'msf/core/post/windows/services'
1410
require 'rex'
15-
require 'msf/core//post/windows/services'
1611

1712
class Metasploit3 < Msf::Post
1813

14+
require 'msf/core/module/deprecated'
15+
include Msf::Module::Deprecated
16+
deprecated Date.new(2013,1,10), "exploit/windows/local/service_permissions"
17+
1918
include ::Msf::Post::Windows::Services
2019
def initialize(info={})
2120
super( update_info( info,
@@ -32,7 +31,6 @@ def initialize(info={})
3231
},
3332
'License' => MSF_LICENSE,
3433
'Author' => [ 'scriptjunkie' ],
35-
'Version' => '$Revision$',
3634
'Platform' => [ 'win' ],
3735
'SessionTypes' => [ 'meterpreter' ]
3836
))
@@ -47,12 +45,6 @@ def initialize(info={})
4745
end
4846

4947
def run
50-
print_error("*********************************************************")
51-
print_error("* *")
52-
print_error("* Module will be depricated on Jan 10 2013 *")
53-
print_error("* Please use exploits/windows/local/service_permissions *")
54-
print_error("* *")
55-
print_error("*********************************************************")
5648
print_status("running")
5749

5850
lhost = datastore["LHOST"] || Rex::Socket.source_address

0 commit comments

Comments
 (0)