Merge branch 'master' of https://github.com/rapid7/metasploit-framework
commit
0b4b754136
|
@ -503,19 +503,22 @@ protected
|
||||||
|
|
||||||
#
|
#
|
||||||
# If the payload has assembly that needs to be compiled, do so now.
|
# If the payload has assembly that needs to be compiled, do so now.
|
||||||
# This method takes the raw payload (p), the assembly text (asm), and the
|
|
||||||
# offsets hash for variables that need to be substituted (off). The suffix
|
|
||||||
# is used to localize the way the generated payload is cached (whether the
|
|
||||||
# blob is part of a single, stager, or stage, for example).
|
|
||||||
#
|
#
|
||||||
def build(x, asm, off, suffix = '')
|
# Blobs will be cached in the framework's PayloadSet
|
||||||
# If there is no assembly to be compiled, then we return a duplicated
|
#
|
||||||
# copy of the raw payload blob
|
# @see PayloadSet#check_blob_cache
|
||||||
|
# @param asm [String] Assembly code to be assembled into a raw payload
|
||||||
|
# @return [String] The final, assembled payload
|
||||||
|
# @raise ArgumentError if +asm+ is blank
|
||||||
|
def build(asm, off={})
|
||||||
if(asm.nil? or asm.empty?)
|
if(asm.nil? or asm.empty?)
|
||||||
return x.dup
|
raise ArgumentError, "Assembly must not be empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
cache_key = refname + suffix
|
# Use the refname so blobs can be flushed when the module gets
|
||||||
|
# reloaded and use the hash value to ensure that we're actually
|
||||||
|
# getting the right blob for the given assembly.
|
||||||
|
cache_key = refname + asm.hash.to_s
|
||||||
cache_entry = framework.payloads.check_blob_cache(cache_key)
|
cache_entry = framework.payloads.check_blob_cache(cache_key)
|
||||||
|
|
||||||
off.each_pair { |option, val|
|
off.each_pair { |option, val|
|
||||||
|
@ -573,7 +576,11 @@ protected
|
||||||
def internal_generate
|
def internal_generate
|
||||||
# Build the payload, either by using the raw payload blob defined in the
|
# Build the payload, either by using the raw payload blob defined in the
|
||||||
# module or by actually assembling it
|
# module or by actually assembling it
|
||||||
raw = build(payload, assembly, offsets, '-stg0')
|
if assembly and !assembly.empty?
|
||||||
|
raw = build(assembly, offsets)
|
||||||
|
else
|
||||||
|
raw = payload.dup
|
||||||
|
end
|
||||||
|
|
||||||
# If the payload is generated and there are offsets to substitute,
|
# If the payload is generated and there are offsets to substitute,
|
||||||
# do that now.
|
# do that now.
|
||||||
|
|
|
@ -107,13 +107,19 @@ module Msf::Payload::Stager
|
||||||
#
|
#
|
||||||
# @return [String] The generated payload stage, as a string.
|
# @return [String] The generated payload stage, as a string.
|
||||||
def generate_stage
|
def generate_stage
|
||||||
|
# XXX: This is nearly identical to Payload#internal_generate
|
||||||
|
|
||||||
# Compile the stage as necessary
|
# Compile the stage as necessary
|
||||||
p = build(stage_payload, stage_assembly, stage_offsets, '-stg1')
|
if stage_assembly and !stage_assembly.empty?
|
||||||
|
raw = build(stage_assembly, stage_offsets)
|
||||||
|
else
|
||||||
|
raw = stage_payload.dup
|
||||||
|
end
|
||||||
|
|
||||||
# Substitute variables in the stage
|
# Substitute variables in the stage
|
||||||
substitute_vars(p, stage_offsets) if (stage_offsets)
|
substitute_vars(raw, stage_offsets) if (stage_offsets)
|
||||||
|
|
||||||
return p
|
return raw
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -343,8 +343,11 @@ class PayloadSet < ModuleSet
|
||||||
# it must be removed (if one exists)
|
# it must be removed (if one exists)
|
||||||
#
|
#
|
||||||
def on_module_reload(mod)
|
def on_module_reload(mod)
|
||||||
@blob_cache.delete(mod.refname + "-stg0")
|
@blob_cache.each_key do |key|
|
||||||
@blob_cache.delete(mod.refname + "-stg1")
|
if key.start_with? mod.refname
|
||||||
|
@blob_cache.delete(key)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -111,6 +111,9 @@ class ClientRequest
|
||||||
end
|
end
|
||||||
|
|
||||||
opts['vars_get'].each_pair do |var,val|
|
opts['vars_get'].each_pair do |var,val|
|
||||||
|
var = var.to_s
|
||||||
|
val = val.to_s
|
||||||
|
|
||||||
qstr << '&' if qstr.length > 0
|
qstr << '&' if qstr.length > 0
|
||||||
qstr << (opts['encode_params'] ? set_encode_uri(var) : var)
|
qstr << (opts['encode_params'] ? set_encode_uri(var) : var)
|
||||||
qstr << '='
|
qstr << '='
|
||||||
|
@ -129,6 +132,9 @@ class ClientRequest
|
||||||
end
|
end
|
||||||
|
|
||||||
opts['vars_post'].each_pair do |var,val|
|
opts['vars_post'].each_pair do |var,val|
|
||||||
|
var = var.to_s
|
||||||
|
val = val.to_s
|
||||||
|
|
||||||
pstr << '&' if pstr.length > 0
|
pstr << '&' if pstr.length > 0
|
||||||
pstr << (opts['encode_params'] ? set_encode_uri(var) : var)
|
pstr << (opts['encode_params'] ? set_encode_uri(var) : var)
|
||||||
pstr << '='
|
pstr << '='
|
||||||
|
@ -220,7 +226,7 @@ class ClientRequest
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_encode_uri(str)
|
def set_encode_uri(str)
|
||||||
a = str.dup
|
a = str.to_s.dup
|
||||||
opts['uri_encode_count'].times {
|
opts['uri_encode_count'].times {
|
||||||
a = Rex::Text.uri_encode(a, opts['uri_encode_mode'])
|
a = Rex::Text.uri_encode(a, opts['uri_encode_mode'])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue