Files
metasploit-gs/lib/msf/core/encoding/xor.rb
T
Ramon de C Valle f124597a56 Code cleanups
git-svn-id: file:///home/svn/framework3/trunk@5773 4d416f70-5f16-0410-b530-b9f4589650da
2008-10-19 21:03:39 +00:00

30 lines
460 B
Ruby

module Msf
module Encoding
###
#
# This class provides basic XOR encoding facilities and is used
# by XOR encoders.
#
###
class Xor
#
# Encodes a block using XOR.
#
def Xor.encode_block(key, block, block_size = 4, block_pack = 'V')
offset = 0
oblock = ''
while (offset < block.length)
cblock = block[offset, block_size].unpack(block_pack)[0]
cblock ^= key
oblock += [ cblock ].pack(block_pack)
end
return oblock
end
end
end end