Files
metasploit-gs/lib/msf/core/encoder/xor.rb
T
Matt Miller 9fe92b5347 added another encoder, fixed up some encoding stuff
git-svn-id: file:///home/svn/incoming/trunk@2713 4d416f70-5f16-0410-b530-b9f4589650da
2005-07-10 20:49:13 +00:00

37 lines
706 B
Ruby

require 'msf/core'
###
#
# Xor
# ---
#
# This class provides basic XOR encoding of buffers.
#
###
class Msf::Encoder::Xor < Msf::Encoder
def encode_block(state, block)
return Rex::Encoding::Xor::Dword.encode(block, [ state.key ].pack(state.decoder_key_pack))[0]
end
def find_bad_keys(buf, badchars)
bad_keys = [ {}, {}, {}, {} ]
byte_idx = 0
# Scan through all the badchars and build out the bad_keys array
# based on the XOR'd combinations that can occur at certain bytes
# to produce bad characters
badchars.each_byte { |badchar|
buf.each_byte { |byte|
bad_keys[byte_idx % decoder_key_size][byte ^ badchar] = true
byte_idx += 1
}
}
return bad_keys
end
end