Method: Rex::Encoding::Xor::DwordAdditive._encode_mutate_key

Defined in:
lib/rex/encoding/xor/dword_additive.rb

._encode_mutate_key(buf, key, pos, len) ⇒ Object

hook in the key mutation routine of encode for the additive feedback



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rex/encoding/xor/dword_additive.rb', line 34

def DwordAdditive._encode_mutate_key(buf, key, pos, len)
  if (pos + 1) % len == 0
    # add the last len bytes (in this case 4) with the key,
    # dropping off any overflow
    key = pack_key(
      unpack_key(key) + unpack_key(buf[pos - (len - 1), len]) &
        (1 << (len << 3)) - 1
    )
  end

  return key
end