2014-10-03 11:34:39 -07:00
Metasploit has a very specific way to deprecate a module. To do so, you must be using the [Msf::Module::Deprecated ](https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/module/deprecated.rb ) mixin. The reason you must be using this mixin is because two things:
2014-10-03 12:02:42 -07:00
1. You are required to set a deprecation date. That way we know when to remove it, which is done manually.
2020-05-11 09:26:09 -05:00
2. You are optionally allowed to set a replacement of the module you wish to deprecate.
2014-10-03 11:34:39 -07:00
## Usage
To use the ```Msf::Module::Deprecated` ``, here's how:
2019-06-27 22:34:33 -05:00
1 - Under ` ``class MetasploitModule` `` of your module, include the following:
2014-10-03 11:34:39 -07:00
` ``ruby
include Msf::Module::Deprecated
` ``
2021-02-04 10:03:57 -05:00
2a - When moving a module, use the ` ``moved_from` `` method in the new module to add an alias to the old module name:
` ``ruby
moved_from 'auxiliary/analyze/jtr_windows_fast'
` ``
2b - Use the ` ``deprecated` `` method to assign a deprecation date and replacement module:
2014-10-03 11:34:39 -07:00
` ``ruby
2015-02-11 13:21:40 -06:00
deprecated(Date.new(2014, 9, 21), 'exploit/linux/http/dlink_upnp_exec_noauth')
2014-10-03 11:34:39 -07:00
` ``
2021-02-04 10:03:57 -05:00
2c - Alternatively, define the ` ``DEPRECATION_DATE` `` and ` ``DEPRECATION_REPLACEMENT` `` constants:
2014-10-03 11:34:39 -07:00
` ``ruby
2015-02-11 13:21:40 -06:00
DEPRECATION_DATE = Date.new(2014, 9, 21) # Sep 21
# The new module is exploit/linux/http/dlink_upnp_exec_noauth
DEPRECATION_REPLACEMENT = 'exploit/linux/http/dlink_upnp_exec_noauth'
2014-10-03 11:59:37 -07:00
` ``
When the user loads that module, they should see a warning like this:
2023-01-28 14:09:00 +00:00
` ``msf
2014-10-03 11:59:37 -07:00
msf > use exploit/windows/misc/test
[!] ************************************************************************
[!] * The module windows/misc/test is deprecated! *
[!] * It will be removed on or about 2014-09-21 *
2015-02-11 13:21:40 -06:00
[!] * Use exploit/linux/http/dlink_upnp_exec_noauth instead *
2014-10-03 11:59:37 -07:00
[!] ************************************************************************
` ``
## Code example
` ``ruby
2016-03-14 10:19:41 -05:00
class MetasploitModule < Msf::Exploit::Remote
2014-10-03 11:59:37 -07:00
Rank = ExcellentRanking
include Msf::Module::Deprecated
2015-02-11 13:21:40 -06:00
deprecated(Date.new(2014, 9, 21), 'exploit/linux/http/dlink_upnp_exec_noauth')
2014-10-03 11:59:37 -07:00
def initialize(info = {})
2023-02-03 13:31:49 +00:00
super(
update_info(
info,
'Name' => 'Msf::Module::Deprecated Example',
'Description' => %q{
This shows how to use Msf::Module::Deprecated.
},
'Author' => [ 'sinn3r' ],
'License' => MSF_LICENSE,
'References' => [ [ 'URL', 'http://metasploit.com' ] ],
'DisclosureDate' => '2014-04-01',
'Targets' => [ [ 'Automatic', {} ] ],
'DefaultTarget' => 0
)
)
2014-10-03 11:59:37 -07:00
end
def exploit
2023-02-03 13:31:49 +00:00
print_debug('Code example')
2014-10-03 11:59:37 -07:00
end
end
2023-01-28 14:09:00 +00:00
` ``