From db6a30693bdd9999128b05a4860d4eab7daf644d Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Tue, 1 Nov 2005 00:02:51 +0000 Subject: [PATCH] foo git-svn-id: file:///home/svn/incoming/trunk@2996 4d416f70-5f16-0410-b530-b9f4589650da --- documentation/plan.txt | 6 +++-- lib/msf/core/constants.rb | 1 + lib/msf/core/encoder.rb | 47 ++++++++++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/documentation/plan.txt b/documentation/plan.txt index 3811169f87..fac5dae642 100644 --- a/documentation/plan.txt +++ b/documentation/plan.txt @@ -99,12 +99,14 @@ Things that would be useful to have completed, but not a requirement: - implement 'reliable' stagers with a higher rating so that if there is enough room, reliable stagers can be used - recon - - basic range/port scanner - - basic service identifier +X - basic range/port scanner +X - basic service identifier - basic OS fingerprinting - framework-core - handler sharing - exploits using the same payload/handler can share (ref count) + - plugin modules + - plugin modules can extend the framework and provide new features X - framework-base X - event correlation X - recon events correlations diff --git a/lib/msf/core/constants.rb b/lib/msf/core/constants.rb index f2a3676892..8512391ee2 100644 --- a/lib/msf/core/constants.rb +++ b/lib/msf/core/constants.rb @@ -22,6 +22,7 @@ ARCH_TYPES = ARCH_PPC, ARCH_SPARC ] +ARCH_ALL = ARCH_TYPES # # Module types diff --git a/lib/msf/core/encoder.rb b/lib/msf/core/encoder.rb index b9eda9ebe9..84458a99df 100644 --- a/lib/msf/core/encoder.rb +++ b/lib/msf/core/encoder.rb @@ -89,21 +89,21 @@ class Encoder < Module # Returns the decoder stub to use based on the supplied length. # def decoder_stub(state) - return module_info['Decoder']['Stub'] + return decoder_hash['Stub'] || '' end # # Returns the offset to the key associated with the decoder stub. # def decoder_key_offset - return module_info['Decoder']['KeyOffset'] + return decoder_hash['KeyOffset'] end # # Returns the size of the key, in bytes. # def decoder_key_size - return module_info['Decoder']['KeySize'] + return decoder_hash['KeySize'] end # @@ -111,7 +111,7 @@ class Encoder < Module # is typically the same as decoder_key_size. # def decoder_block_size - return module_info['Decoder']['BlockSize'] + return decoder_hash['BlockSize'] end # @@ -119,7 +119,14 @@ class Encoder < Module # the key. # def decoder_key_pack - return module_info['Decoder']['KeyPack'] || 'V' + return decoder_hash['KeyPack'] || 'V' + end + + # + # Returns the module's decoder hash or an empty hash. + # + def decoder_hash + module_info['Decoder'] || {} end ## @@ -186,22 +193,28 @@ class Encoder < Module # Copy the decoder stub since we may need to modify it stub = decoder_stub(state).dup - if (state.key != nil) + if (state.key != nil and decoder_key_offset) # Substitute the decoder key in the copy of the decoder stub with the # one that we found stub[state.decoder_key_offset,state.decoder_key_size] = [ state.key.to_i ].pack(state.decoder_key_pack) + else + stub = encode_finalize_stub(state, stub) end # Walk the buffer encoding each block along the way offset = 0 - while (offset < buf.length) - block = buf[offset, decoder_block_size] - - state.encoded += encode_block(state, - block + ("\x00" * (decoder_block_size - block.length))) - - offset += decoder_block_size + if (decoder_block_size) + while (offset < buf.length) + block = buf[offset, decoder_block_size] + + state.encoded += encode_block(state, + block + ("\x00" * (decoder_block_size - block.length))) + + offset += decoder_block_size + end + else + state.encoded = encode_block(state, buf) end # Prefix the decoder stub to the encoded buffer @@ -246,6 +259,14 @@ class Encoder < Module return nil end + # + # This callback allows a derived class to finalize a stub after a key have + # been selected. The finalized stub should be returned. + # + def encode_finalize_stub(state, stub) + stub + end + # # Called after encoding has completed. #