Land #11339, Move command_exists? method to Msf::Post::Common
parent
c9dad4b457
commit
5d6fb3eff9
|
@ -235,6 +235,20 @@ module Msf::Post::Common
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
#
|
||||||
|
# Checks if the `cmd` is installed on the system
|
||||||
|
# @return [Boolean]
|
||||||
|
#
|
||||||
|
def command_exists?(cmd)
|
||||||
|
if session.platform == 'windows'
|
||||||
|
# https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/where_1
|
||||||
|
# https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/if
|
||||||
|
cmd_exec("cmd /c where /q #{cmd} & if not errorlevel 1 echo true").to_s.include? 'true'
|
||||||
|
else
|
||||||
|
cmd_exec("command -v #{cmd} && echo true").to_s.include? 'true'
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
raise "Unable to check if command `#{cmd}' exists"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -215,16 +215,6 @@ module System
|
||||||
raise 'Unable to check for gcc'
|
raise 'Unable to check for gcc'
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# Checks if the `cmd` is installed on the system
|
|
||||||
# @return [Boolean]
|
|
||||||
#
|
|
||||||
def command_exists?(cmd)
|
|
||||||
cmd_exec("command -v #{cmd} && echo true").to_s.include? 'true'
|
|
||||||
rescue
|
|
||||||
raise "Unable to check if command `#{cmd}` exists"
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Gets the process id(s) of `program`
|
# Gets the process id(s) of `program`
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
|
|
|
@ -118,16 +118,6 @@ module System
|
||||||
raise 'Unable to check for gcc'
|
raise 'Unable to check for gcc'
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# Checks if the `cmd` is installed on the system
|
|
||||||
# @return [Boolean]
|
|
||||||
#
|
|
||||||
def command_exists?(cmd)
|
|
||||||
cmd_exec("command -v #{cmd} && echo true").to_s.include? 'true'
|
|
||||||
rescue
|
|
||||||
raise "Unable to check if command `#{cmd}` exists"
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Gets the process id(s) of `program`
|
# Gets the process id(s) of `program`
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
|
|
Loading…
Reference in New Issue