Skip to content

Commit 1ba57af

Browse files
committed
Merge branch 'master' into bug/windows-pro-modules
2 parents 2d1fd1c + 4fa3631 commit 1ba57af

33 files changed

+373
-153
lines changed

documentation/samples/modules/auxiliary/sample.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
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
8-
# Framework web site for more information on licensing and terms of use.
9-
# http://metasploit.com/framework/
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
106
##
117

128
require 'msf/core'
139

14-
module Msf
15-
1610
###
1711
#
1812
# This sample auxiliary module simply displays the selected action and
1913
# registers a custom command that will show up when the module is used.
2014
#
2115
###
22-
class Auxiliary::Sample < Msf::Auxiliary
16+
class Metasploit4 < Msf::Auxiliary
2317

2418
def initialize
2519
super(
@@ -50,5 +44,3 @@ def cmd_aux_extra_command(*args)
5044
end
5145

5246
end
53-
54-
end

documentation/samples/modules/encoders/sample.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
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
8-
# Framework web site for more information on licensing and terms of use.
9-
# http://metasploit.com/framework/
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
106
##
117

12-
module Msf
13-
module Encoders
14-
158
###
169
#
1710
# This sample illustrates a very basic encoder that simply returns the block
1811
# that it's passed.
1912
#
2013
###
21-
class Sample < Msf::Encoder
14+
class Metasploit4 < Msf::Encoder
2215

2316
def initialize
2417
super(
@@ -40,6 +33,3 @@ def encode_block(state, buf)
4033
end
4134

4235
end
43-
44-
end
45-
end

documentation/samples/modules/exploits/sample.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
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
8-
# Framework web site for more information on licensing and terms of use.
9-
# http://metasploit.com/framework/
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
106
##
117

128
require 'msf/core'
139

14-
module Msf
15-
1610
###
1711
#
1812
# This exploit sample shows how an exploit module could be written to exploit
1913
# a bug in an arbitrary TCP server.
2014
#
2115
###
22-
class Exploits::Sample < Msf::Exploit::Remote
16+
class Metasploit4 < Msf::Exploit::Remote
2317

2418
#
2519
# This exploit affects TCP servers, so we use the TCP client mixin.
@@ -88,4 +82,3 @@ def exploit
8882

8983
end
9084

91-
end
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
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
8-
# Framework web site for more information on licensing and terms of use.
9-
# http://metasploit.com/framework/
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
106
##
117

128
require 'msf/core'
139

14-
module Msf
15-
module Nops
16-
1710
###
1811
#
1912
# This class implements a very basic NOP sled generator that just returns a
2013
# string of 0x90's.
2114
#
2215
###
23-
class Sample < Msf::Nop
16+
class Metasploit4 < Msf::Nop
2417

2518
def initialize
2619
super(
@@ -39,6 +32,3 @@ def generate_sled(length, opts)
3932
end
4033

4134
end
42-
43-
end
44-
end
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
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
8-
# Framework web site for more information on licensing and terms of use.
9-
# http://metasploit.com/framework/
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
106
##
117

128
require 'msf/core'
139

14-
module Msf
15-
module Payloads
16-
module Singles
17-
1810
###
1911
#
2012
# This sample payload is designed to trigger a debugger exception via int3.
2113
#
2214
###
23-
module Sample
15+
module Metasploit4
2416

2517
include Msf::Payload::Single
2618

@@ -40,7 +32,3 @@ def initialize(info = {})
4032
end
4133

4234
end
43-
44-
end
45-
end
46-
end

lib/msf/core/modules/loader/base.rb

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def load_module(parent_path, type, module_reference_name, options={})
113113
metasploit_class = nil
114114
module_path = self.module_path(parent_path, type, module_reference_name)
115115

116-
loaded = namespace_module_transaction(module_reference_name, :reload => reload) { |namespace_module|
116+
loaded = namespace_module_transaction(type + "/" + module_reference_name, :reload => reload) { |namespace_module|
117117
# set the parent_path so that the module can be reloaded with #load_module
118118
namespace_module.parent_path = parent_path
119119

@@ -301,7 +301,7 @@ def reload_module(original_metasploit_class_or_instance)
301301
reloaded_module_instance.datastore.update(original_metasploit_instance.datastore)
302302
end
303303
else
304-
elog("Failed to create instance of #{refname} after reload.", 'core')
304+
elog("Failed to create instance of #{original_metasploit_class_or_instance.refname} after reload.", 'core')
305305

306306
# Return the old module instance to avoid an strace trace
307307
return original_metasploit_class_or_instance
@@ -370,13 +370,14 @@ def create_namespace_module(namespace_module_names)
370370
# @return [Module] module that wraps the previously loaded content from {#read_module_content}.
371371
# @return [nil] if any module name along the chain does not exist.
372372
def current_module(module_names)
373-
# don't look at ancestors for constant
374-
inherit = false
375-
376373
# Don't want to trigger ActiveSupport's const_missing, so can't use constantize.
377374
named_module = module_names.inject(Object) { |parent, module_name|
378-
if parent.const_defined?(module_name, inherit)
379-
parent.const_get(module_name, inherit)
375+
# Since we're searching parent namespaces first anyway, this is
376+
# semantically equivalent to providing false for the 1.9-only
377+
# "inherit" parameter to const_defined?. If we ever drop 1.8
378+
# support, we can save a few cycles here by adding it back.
379+
if parent.const_defined?(module_name)
380+
parent.const_get(module_name)
380381
else
381382
break
382383
end
@@ -429,7 +430,7 @@ def module_path?(path)
429430

430431
extension = File.extname(path)
431432

432-
unless (path.starts_with?('.') or
433+
unless (path[0,1] == "." or
433434
extension != MODULE_EXTENSION or
434435
path =~ UNIT_TEST_REGEX)
435436
module_path = true
@@ -454,8 +455,8 @@ def module_reference_name_from_path(path)
454455
#
455456
# @see MODULE_SEPARATOR
456457
# @see #namespace_module_names
457-
def namespace_module_name(module_reference_name)
458-
namespace_module_names = self.namespace_module_names(module_reference_name)
458+
def namespace_module_name(uniq_module_reference_name)
459+
namespace_module_names = self.namespace_module_names(uniq_module_reference_name)
459460
namespace_module_name = namespace_module_names.join(MODULE_SEPARATOR)
460461

461462
namespace_module_name
@@ -465,40 +466,19 @@ def namespace_module_name(module_reference_name)
465466
# doesn't overwrite other (metasploit) module's classes. Invalid module name characters are escaped by using 'H*'
466467
# unpacking and prefixing each code with X so the code remains a valid module name when it starts with a digit.
467468
#
468-
# @param [String] module_reference_name The canonical name for the module.
469+
# @param [String] uniq_module_reference_name The unique canonical name for the module including type.
469470
# @return [Array<String>] {NAMESPACE_MODULE_NAMES} + <derived-constant-safe names>
470471
#
471472
# @see namespace_module
472-
def namespace_module_names(module_reference_name)
473-
relative_module_name = module_reference_name.camelize
474-
475-
module_names = relative_module_name.split(MODULE_SEPARATOR)
476-
477-
# The module_reference_name is path-like, so it can include characters that are invalid in module names
478-
valid_module_names = module_names.collect { |module_name|
479-
valid_module_name = module_name.gsub(/^[0-9]|[^A-Za-z0-9]/) { |invalid_constant_name_character|
480-
unpacked = invalid_constant_name_character.unpack('H*')
481-
# unpack always returns an array, so get first value to get character's encoding
482-
hex_code = unpacked[0]
483-
484-
# as a convention start each hex-code with X so that it'll make a valid constant name since constants can't
485-
# start with digits.
486-
"X#{hex_code}"
487-
}
488-
489-
valid_module_name
490-
}
491-
492-
namespace_module_names = NAMESPACE_MODULE_NAMES + valid_module_names
493-
494-
namespace_module_names
473+
def namespace_module_names(uniq_module_reference_name)
474+
NAMESPACE_MODULE_NAMES + [ "Mod" + uniq_module_reference_name.unpack("H*").first.downcase ]
495475
end
496476

497-
def namespace_module_transaction(module_reference_name, options={}, &block)
477+
def namespace_module_transaction(uniq_module_reference_name, options={}, &block)
498478
options.assert_valid_keys(:reload)
499479

500480
reload = options[:reload] || false
501-
namespace_module_names = self.namespace_module_names(module_reference_name)
481+
namespace_module_names = self.namespace_module_names(uniq_module_reference_name)
502482

503483
previous_namespace_module = current_module(namespace_module_names)
504484

@@ -617,4 +597,5 @@ def usable?(metasploit_class)
617597

618598
usable
619599
end
620-
end
600+
end
601+

lib/msf/core/modules/namespace.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ module Msf::Modules::Namespace
1111
def metasploit_class
1212
metasploit_class = nil
1313
# don't search ancestors for the metasploit_class
14-
inherit = false
14+
#inherit = false
1515

1616
::Msf::Framework::Major.downto(1) do |major|
17-
if const_defined?("Metasploit#{major}", inherit)
17+
# Since we really only care about the deepest namespace, we don't
18+
# need to look for parents' constants. However, the "inherit"
19+
# parameter for const_defined? only exists after 1.9. If we ever
20+
# drop 1.8 support, we can save a few cycles here by passing false
21+
# here.
22+
if const_defined?("Metasploit#{major}")
1823
metasploit_class = const_get("Metasploit#{major}")
1924

2025
break
@@ -52,4 +57,5 @@ def version_compatible!(module_path, module_reference_name)
5257
end
5358
end
5459
end
55-
end
60+
end
61+

lib/rex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module Rex
9191

9292
# Overload the Kernel.sleep() function to be thread-safe
9393
Kernel.class_eval("
94-
def sleep(seconds)
94+
def sleep(seconds=nil)
9595
Rex::ThreadSafe.sleep(seconds)
9696
end
9797
")

lib/rex/sync/thread_safe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def self.select(rfd = nil, wfd = nil, efd = nil, t = nil)
7272
# Simulates a sleep operation by selecting on nil until a timeout period
7373
# expires.
7474
#
75-
def self.sleep(seconds)
75+
def self.sleep(seconds=nil)
7676
self.select(nil, nil, nil, seconds)
7777

7878
seconds

modules/auxiliary/scanner/http/ssl.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def run_host(ip)
5757
caissuer = (/CA Issuers - URI:(.*?),/i).match(cert.extensions.to_s)
5858

5959
if caissuer.to_s.empty?
60-
print_good("Certificate contains no CA Issuers extension... possible self signed certificate")
60+
print_good("#{ip}:#{rport} Certificate contains no CA Issuers extension... possible self signed certificate")
6161
else
6262
print_status("#{ip}:#{rport} " +caissuer.to_s[0..-2])
6363
end
6464

6565
if cert.issuer.to_s == cert.subject.to_s
66-
print_good("Certificate Subject and Issuer match... possible self signed certificate")
66+
print_good("#{ip}:#{rport} Certificate Subject and Issuer match... possible self signed certificate")
6767
end
6868

6969
alg = cert.signature_algorithm

0 commit comments

Comments
 (0)