# -*- coding: binary -*-

module Msf
  class Exploit
    class Remote
      module HTTP
        # This module provides a way of interacting with wordpress installations
        module Wordpress
          require 'msf/core/exploit/http/wordpress/admin'
          require 'msf/core/exploit/http/wordpress/base'
          require 'msf/core/exploit/http/wordpress/helpers'
          require 'msf/core/exploit/http/wordpress/login'
          require 'msf/core/exploit/http/wordpress/posts'
          require 'msf/core/exploit/http/wordpress/uris'
          require 'msf/core/exploit/http/wordpress/users'
          require 'msf/core/exploit/http/wordpress/version'
          require 'msf/core/exploit/http/wordpress/xml_rpc'

          include Msf::Exploit::Remote::HttpClient
          include Msf::Exploit::Remote::HTTP::Wordpress::Admin
          include Msf::Exploit::Remote::HTTP::Wordpress::Base
          include Msf::Exploit::Remote::HTTP::Wordpress::Helpers
          include Msf::Exploit::Remote::HTTP::Wordpress::Login
          include Msf::Exploit::Remote::HTTP::Wordpress::Posts
          include Msf::Exploit::Remote::HTTP::Wordpress::URIs
          include Msf::Exploit::Remote::HTTP::Wordpress::Users
          include Msf::Exploit::Remote::HTTP::Wordpress::Version
          include Msf::Exploit::Remote::HTTP::Wordpress::XmlRpc

          def initialize(info = {})
            super

            register_options(
              [
                Msf::OptString.new('TARGETURI', [true, 'The base path to the wordpress application', '/'])
              ], Msf::Exploit::Remote::HTTP::Wordpress
            )

            register_advanced_options(
              [
                Msf::OptString.new('WPCONTENTDIR', [true, 'The name of the wp-content directory', 'wp-content'])
              ], Msf::Exploit::Remote::HTTP::Wordpress
            )
          end

          def wp_content_dir
            datastore['WPCONTENTDIR']
          end
        end
      end
    end
  end
end
