Skip to content

Commit 0c59c88

Browse files
committed
Fix metsrv.dll name issue
As mentioned here https://community.rapid7.com/thread/3788 the metsvc script was still looking for the old file name for metsrv.dll, which was causing the script to fail. This commit fixes this issue. A hash is used to indicate local and remote file names so that the remote can continue to use metsrv.dll, but it is correctly located on disk locally.
1 parent 77b036c commit 0c59c88

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)