Skip to content

Commit de1a29c

Browse files
committed
Land rapid7#2707 - Fix metsrv.dll name issue in metsvc script
[FixRM rapid7#8707]
2 parents 6fe9e89 + 0c59c88 commit de1a29c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

scripts/meterpreter/metsvc.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,21 @@ def m_exec(session, cmd)
7070
print_status("Creating a temporary installation directory #{tempdir}...")
7171
client.fs.dir.mkdir(tempdir)
7272

73-
%W{ metsrv.dll metsvc-server.exe metsvc.exe }.each do |bin|
74-
next if (bin != "metsvc.exe" and remove)
75-
print_status(" >> Uploading #{bin}...")
76-
fd = client.fs.file.new(tempdir + "\\" + bin, "wb")
77-
fd.write(::File.read(File.join(based, bin), ::File.size(::File.join(based, bin))))
73+
# Use an array of `from -> to` associations so that things
74+
# such as metsrv can be copied from the appropriate location
75+
# but named correctly on the target.
76+
bins = {
77+
'metsrv.x86.dll' => 'metsrv.dll',
78+
'metsvc-server.exe' => nil,
79+
'metsvc.exe' => nil
80+
}
81+
82+
bins.each do |from, to|
83+
next if (from != "metsvc.exe" and remove)
84+
to ||= from
85+
print_status(" >> Uploading #{from}...")
86+
fd = client.fs.file.new(tempdir + "\\" + to, "wb")
87+
fd.write(::File.read(File.join(based, from), ::File.size(::File.join(based, from))))
7888
fd.close
7989
end
8090

0 commit comments

Comments
 (0)