Fixored
git-svn-id: file:///home/svn/incoming/trunk@3621 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
0f142d18e4
commit
d0b3483d41
|
@ -11,7 +11,7 @@ class Msf::Encoder::Xor < Msf::Encoder
|
||||||
# Encodes a block using the XOR encoder from the Rex library.
|
# Encodes a block using the XOR encoder from the Rex library.
|
||||||
#
|
#
|
||||||
def encode_block(state, block)
|
def encode_block(state, block)
|
||||||
return Rex::Encoding::Xor::Dword.encode(block, [ state.key ].pack(state.decoder_key_pack))[0]
|
Rex::Encoding::Xor::Dword.encode(block, [ state.key ].pack(state.decoder_key_pack))[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -24,15 +24,14 @@ class Msf::Encoder::Xor < Msf::Encoder
|
||||||
# Scan through all the badchars and build out the bad_keys array
|
# Scan through all the badchars and build out the bad_keys array
|
||||||
# based on the XOR'd combinations that can occur at certain bytes
|
# based on the XOR'd combinations that can occur at certain bytes
|
||||||
# to produce bad characters
|
# to produce bad characters
|
||||||
badchars.each_byte { |badchar|
|
|
||||||
|
|
||||||
buf.each_byte { |byte|
|
buf.each_byte { |byte|
|
||||||
|
badchars.each_byte { |badchar|
|
||||||
bad_keys[byte_idx % decoder_key_size][byte ^ badchar] = true
|
bad_keys[byte_idx % decoder_key_size][byte ^ badchar] = true
|
||||||
|
}
|
||||||
byte_idx += 1
|
byte_idx += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Assume our key itself is placed w/o encoding
|
badchars.each_byte { |badchar|
|
||||||
0.upto(decoder_key_size-1) { |i|
|
0.upto(decoder_key_size-1) { |i|
|
||||||
bad_keys[i][badchar] = true
|
bad_keys[i][badchar] = true
|
||||||
}
|
}
|
||||||
|
@ -41,27 +40,4 @@ class Msf::Encoder::Xor < Msf::Encoder
|
||||||
return bad_keys
|
return bad_keys
|
||||||
end
|
end
|
||||||
|
|
||||||
# Added for test purposes, remove once we resolve encoding issues...
|
|
||||||
def find_key_verify(buf, key_bytes, badchars)
|
|
||||||
ekey = key_bytes_to_buffer(key_bytes)
|
|
||||||
|
|
||||||
out = ''
|
|
||||||
idx = 0
|
|
||||||
while (idx < buf.length)
|
|
||||||
0.upto(ekey.length-1) do |i|
|
|
||||||
break if ! buf[idx+i]
|
|
||||||
out << (buf[idx+i]^ekey[i]).chr
|
|
||||||
end
|
|
||||||
|
|
||||||
idx += ekey.length
|
|
||||||
end
|
|
||||||
|
|
||||||
badchars.each do |c|
|
|
||||||
return false if out.index(c)
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue