Add new code template
parent
a39539f8ef
commit
e72f705298
|
@ -31,6 +31,7 @@ class Metasploit3 < Msf::Encoder::Alphanum
|
||||||
# being encoded.
|
# being encoded.
|
||||||
#
|
#
|
||||||
def decoder_stub(state)
|
def decoder_stub(state)
|
||||||
|
modified_registers = []
|
||||||
reg = datastore['BufferRegister']
|
reg = datastore['BufferRegister']
|
||||||
off = (datastore['BufferOffset'] || 0).to_i
|
off = (datastore['BufferOffset'] || 0).to_i
|
||||||
buf = ''
|
buf = ''
|
||||||
|
@ -52,7 +53,14 @@ class Metasploit3 < Msf::Encoder::Alphanum
|
||||||
reg.upcase!
|
reg.upcase!
|
||||||
end
|
end
|
||||||
|
|
||||||
buf + Rex::Encoder::Alpha2::AlphaMixed::gen_decoder(reg, off)
|
stub = buf + Rex::Encoder::Alpha2::AlphaMixed::gen_decoder(reg, off)
|
||||||
|
|
||||||
|
# Sanity check that saved_registers doesn't overlap with modified_registers
|
||||||
|
if (modified_registers & saved_registers).length > 0
|
||||||
|
raise BadGenerateError
|
||||||
|
end
|
||||||
|
|
||||||
|
stub
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -69,4 +77,14 @@ class Metasploit3 < Msf::Encoder::Alphanum
|
||||||
def encode_end(state)
|
def encode_end(state)
|
||||||
state.encoded += Rex::Encoder::Alpha2::AlphaMixed::add_terminator()
|
state.encoded += Rex::Encoder::Alpha2::AlphaMixed::add_terminator()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Indicate that this module can preserve some registers
|
||||||
|
def can_preserve_registers?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Convert the SaveRegisters to an array of x86 register constants
|
||||||
|
def saved_registers
|
||||||
|
Rex::Arch::X86.register_names_to_ids(datastore['SaveRegisters'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue