Skip to content

Commit 9be030b

Browse files
committed
Fix nil in executable generation
1 parent 60444c2 commit 9be030b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/msf/core/exploit/cmdstager.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,21 @@ def execute_cmdstager(opts = {})
108108
# @option opts :decoder [Symbol] The decoder stub to use.
109109
# @param pl [String] String containing the payload to execute
110110
# @return [Array] The list of commands to execute
111-
# @raise [ArgumentError] raised if the cmd stub cannot be generated
111+
# @raise [ArgumentError] raised if the exe or cmd stub cannot be generated
112112
def generate_cmdstager(opts = {}, pl = nil)
113113
select_cmdstager(opts)
114114

115115
self.exe = generate_payload_exe(:code => pl)
116116

117+
if exe.nil?
118+
raise ArgumentError, 'The executable could not be generated'
119+
end
120+
117121
self.stager_instance = create_stager
118122
cmd_list = stager_instance.generate(opts_with_decoder(opts))
119123

120-
if (cmd_list.nil? || cmd_list.length < 1)
121-
print_error("The command stager could not be generated")
122-
raise ArgumentError
124+
if cmd_list.nil? || cmd_list.length.zero?
125+
raise ArgumentError, 'The command stager could not be generated'
123126
end
124127

125128
cmd_list

0 commit comments

Comments
 (0)