metasploit-payloads 0.0.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5847d5771527a93ff4a51e6d7ed58210b55c45ed
4
- data.tar.gz: 2cdd046533026017f94950c506ac0ddca3bb368b
3
+ metadata.gz: 5aeb9d8ba70aa72a36da299fe1d658085e0dddec
4
+ data.tar.gz: 57b098cfe5fb611538d9cc3a944534fed31a4191
5
5
  SHA512:
6
- metadata.gz: 84b3c53c004c26946e5acde214945acba450f24d501c9a31f842a33e2d03242ad8b0e82246faddcaa2424a7ae1db494a7d6185f4d2ab0a05b9199dfca15b8119
7
- data.tar.gz: a8ddf4086bd8c0317c08c776b37b0be3ac7ffaa95557c5221cf4d0dce34c4f5c95b8b79d6cafa2ff02e077cdafa7bccdd77cb5377d7ecfc7394c92da3f0cbfee
6
+ metadata.gz: a28cfb11b5282103343ddf0d52e9d29ee7b96140f2295dfe7fdd661029151f52b53053ffca033bfa315e8641000544dc52b0f53b0c621952ec751645e22ab3b0
7
+ data.tar.gz: dad251c87dc4412f96011019507fd71790b57225623d4dc41b3df045beb7917cb62cbc2249d7333a390f142477fcd3286960fcbf670ed391cc0979a9611298a1
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- '��K'�ןK�&(.l-�L��#�cgm|h����J����TQ⊸kݲl��~��\ZJrs�%�hv��E��s��A�� ���2��ns}bjdj#>̽����U�e��)j�i��3��>&�eq_�%~=j'M��/��D�?'�B\?�>�yX:���j0dN3��b� �`v{�<�z��?K>0�K�h@��� %z�-�:���xм����Qy���!�:'.�V��]��(Uݙ�X%�~��4�9� ԝ��
1
+ |$�3�<Qaa&e#Bn�hs��YʱvO�M媞P����u"k�)�d0g��A�o3��>�RޒZ�m75G?��[���p[1~��P-��^r��3��f&&ChO��%���.���B~��Q
@@ -1,9 +1,13 @@
1
1
  # -*- coding:binary -*-
2
2
 
3
- require 'metasploit-payloads/version' unless defined? MetasploitPayloads::VERSION
3
+ unless defined? MetasploitPayloads::VERSION
4
+ require 'metasploit-payloads/version'
5
+ end
4
6
 
7
+ #
8
+ # This module dispenses Metasploit payload binary files
9
+ #
5
10
  module MetasploitPayloads
6
-
7
11
  EXTENSION_PREFIX = 'ext_server_'
8
12
  METERPRETER_SUBFOLDER = 'meterpreter'
9
13
 
@@ -14,44 +18,43 @@ module MetasploitPayloads
14
18
  path("#{EXTENSION_PREFIX}#{ext_name}", binary_suffix)
15
19
  end
16
20
 
21
+ def self.readable_path(gem_path, msf_path)
22
+ # Try the MSF path first to see if the file exists, allowing the MSF data
23
+ # folder to override what is in the gem. This is very helpful for
24
+ # testing/development without having to move the binaries to the gem folder
25
+ # each time. We only do this is MSF is installed.
26
+ if ::File.readable? msf_path
27
+ warn_local_path(msf_path) if ::File.readable? gem_path
28
+ return msf_path
29
+
30
+ elsif ::File.readable? gem_path
31
+ return gem_path
32
+ end
33
+
34
+ nil
35
+ end
36
+
17
37
  #
18
38
  # Get the path to a meterpreter binary by full name.
19
39
  #
20
40
  def self.meterpreter_path(name, binary_suffix)
21
41
  file_name = "#{name}.#{binary_suffix}".downcase
22
- root_dirs = [local_meterpreter_dir]
23
-
24
- # Try the data folder first to see if the extension exists, as this
25
- # allows for the MSF data/meterpreter folder to override what is
26
- # in the gem. This is very helpful for testing/development without
27
- # having to move the binaries to the gem folder each time. We only
28
- # do this is MSF is installed.
29
- root_dirs.unshift(msf_meterpreter_dir) if metasploit_installed?
30
-
31
- until root_dirs.length.zero?
32
- file_path = expand(root_dirs.shift, file_name)
33
- return file_path if ::File.readable?(file_path)
42
+ gem_path = expand(local_meterpreter_dir, file_name)
43
+ if metasploit_installed?
44
+ msf_path = expand(msf_meterpreter_dir, file_name)
34
45
  end
35
-
36
- nil
46
+ readable_path(gem_path, msf_path)
37
47
  end
38
48
 
39
49
  #
40
50
  # Get the full path to any file packaged in this gem by local path and name.
41
51
  #
42
52
  def self.path(*path_parts)
43
- root_dirs = [data_directory]
44
-
45
- # Same as above, we try the data folder first, the fall back to the local
46
- # meterpreter folder
47
- root_dirs.unshift(Msf::Config.data_directory) if metasploit_installed?
48
-
49
- until root_dirs.length.zero?
50
- file_path = expand(root_dirs.shift, ::File.join(path_parts))
51
- return file_path if ::File.readable?(file_path)
53
+ gem_path = expand(data_directory, ::File.join(path_parts))
54
+ if metasploit_installed?
55
+ msf_path = expand(Msf::Config.data_directory, ::File.join(path_parts))
52
56
  end
53
-
54
- nil
57
+ readable_path(gem_path, msf_path)
55
58
  end
56
59
 
57
60
  #
@@ -61,12 +64,10 @@ module MetasploitPayloads
61
64
  file_path = path(path_parts)
62
65
  if file_path.nil?
63
66
  full_path = ::File.join(path_parts)
64
- raise RuntimeError, "#{full_path} not found", caller
67
+ fail RuntimeError, "#{full_path} not found", caller
65
68
  end
66
69
 
67
- ::File.open(file_path, "rb" ) { |f|
68
- f.read(f.stat.size)
69
- }
70
+ ::File.binread(file_path)
70
71
  end
71
72
 
72
73
  #
@@ -76,13 +77,14 @@ module MetasploitPayloads
76
77
  extensions = []
77
78
 
78
79
  root_dirs = [local_meterpreter_dir]
80
+
79
81
  # Find the valid extensions in the data folder first, if MSF
80
82
  # is installed.
81
83
  root_dirs.unshift(msf_meterpreter_dir) if metasploit_installed?
82
84
 
83
- until root_dirs.length.zero?
85
+ root_dirs.each do |dir|
84
86
  # Merge in any that don't already exist in the collection.
85
- meterpreter_enum_ext(root_dirs.shift, binary_suffix).each do |e|
87
+ meterpreter_enum_ext(dir, binary_suffix).each do |e|
86
88
  extensions.push(e) unless extensions.include?(e)
87
89
  end
88
90
  end
@@ -94,7 +96,7 @@ module MetasploitPayloads
94
96
  # Full path to the local gem folder containing the base data
95
97
  #
96
98
  def self.data_directory
97
- ::File.join(::File.dirname(__FILE__), '..', 'data')
99
+ ::File.realpath(::File.join(::File.dirname(__FILE__), '..', 'data'))
98
100
  end
99
101
 
100
102
  #
@@ -111,27 +113,21 @@ module MetasploitPayloads
111
113
  ::File.join(data_directory, METERPRETER_SUBFOLDER)
112
114
  end
113
115
 
114
- #
115
- # Full path to the MSF data folder which contains the binaries.
116
- #
117
- def self.msf_meterpreter_dir
118
- ::File.join(Msf::Config.data_directory, METERPRETER_SUBFOLDER)
119
- end
120
-
121
116
  #
122
117
  # Enumerate extensions in the given root folder based on the suffix.
123
118
  #
124
119
  def self.meterpreter_enum_ext(root_dir, binary_suffix)
125
120
  exts = []
126
121
  ::Dir.entries(root_dir).each do |f|
127
- if (::File.readable?(::File.join(root_dir, f)) && f =~ /#{EXTENSION_PREFIX}(.*)\.#{binary_suffix}/)
122
+ if ::File.readable?(::File.join(root_dir, f)) && \
123
+ f =~ /#{EXTENSION_PREFIX}(.*)\.#{binary_suffix}/
128
124
  exts.push($1)
129
125
  end
130
126
  end
131
127
  exts
132
128
  end
133
129
 
134
- private
130
+ private
135
131
 
136
132
  #
137
133
  # Determine if MSF has been installed and is being used.
@@ -147,5 +143,15 @@ private
147
143
  ::File.expand_path(::File.join(root_dir, file_name))
148
144
  end
149
145
 
150
- end
146
+ @local_paths = []
151
147
 
148
+ def self.warn_local_path(path)
149
+ unless @local_paths.include?(path)
150
+ STDERR.puts("WARNING: Local file #{path} is being used")
151
+ if @local_paths.empty?
152
+ STDERR.puts('WARNING: If you are not a developer, remove this file')
153
+ end
154
+ @local_paths << path
155
+ end
156
+ end
157
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- coding:binary -*-
2
2
  module MetasploitPayloads
3
- VERSION = '0.0.9'
3
+ VERSION = '1.0.0'
4
4
 
5
5
  def self.version
6
6
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit-payloads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OJ Reeves
metadata.gz.sig CHANGED
Binary file