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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/lib/metasploit-payloads.rb +50 -44
- data/lib/metasploit-payloads/version.rb +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeb9d8ba70aa72a36da299fe1d658085e0dddec
|
4
|
+
data.tar.gz: 57b098cfe5fb611538d9cc3a944534fed31a4191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a28cfb11b5282103343ddf0d52e9d29ee7b96140f2295dfe7fdd661029151f52b53053ffca033bfa315e8641000544dc52b0f53b0c621952ec751645e22ab3b0
|
7
|
+
data.tar.gz: dad251c87dc4412f96011019507fd71790b57225623d4dc41b3df045beb7917cb62cbc2249d7333a390f142477fcd3286960fcbf670ed391cc0979a9611298a1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
|$�3�<Qaa&e#Bn�hs��YʱvO�M媞P����u"k�)�d0g��A�o3��>�RޒZ�m75�G?��[���p�[1~��P-��^r��3��f&&C�hO��%���.���B~��Q
|
data/lib/metasploit-payloads.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# -*- coding:binary -*-
|
2
2
|
|
3
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
67
|
+
fail RuntimeError, "#{full_path} not found", caller
|
65
68
|
end
|
66
69
|
|
67
|
-
::File.
|
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
|
-
|
85
|
+
root_dirs.each do |dir|
|
84
86
|
# Merge in any that don't already exist in the collection.
|
85
|
-
meterpreter_enum_ext(
|
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
|
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
|
-
|
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
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|