mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
fixed a few issues with the alpha2 implementation
git-svn-id: file:///home/svn/framework3/trunk@4230 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
fb589f976d
commit
e1565e2af4
@ -130,6 +130,7 @@ class EncodedPayload
|
||||
# framework that an encoder must be explicitly defined as the
|
||||
# encoder of choice for an exploit.
|
||||
if ((reqs['EncoderType'].nil?) and
|
||||
(reqs['Encoder'].nil?) and
|
||||
(self.encoder.rank == ManualRanking))
|
||||
wlog("#{pinst.refname}: Encoder #{encoder.refname} is manual ranked and was not defined as a preferred encoder.",
|
||||
'core', LEV_1)
|
||||
|
@ -7,7 +7,7 @@ module Encoder
|
||||
module Alpha2
|
||||
|
||||
class AlphaUpper < Generic
|
||||
@@accepted_chars = ('B' .. 'Z').to_a + ('0' .. '9').to_a
|
||||
@@default_accepted_chars = ('B' .. 'Z').to_a + ('0' .. '9').to_a
|
||||
|
||||
def self.gen_decoder_prefix(reg, offset)
|
||||
if (offset > 20)
|
||||
|
@ -7,7 +7,8 @@ module Encoder
|
||||
module Alpha2
|
||||
|
||||
class Generic
|
||||
@@accepted_chars = ('a' .. 'z').to_a + ('B' .. 'Z').to_a + ('0' .. '9').to_a
|
||||
|
||||
@@default_accepted_chars = ('a' .. 'z').to_a + ('B' .. 'Z').to_a + ('0' .. '9').to_a
|
||||
|
||||
def Generic.gen_decoder_prefix(reg, offset)
|
||||
# Should never happen - have to pick a specifc
|
||||
@ -35,24 +36,26 @@ class Generic
|
||||
end
|
||||
|
||||
def Generic.encode_byte(block, badchars)
|
||||
first = 0
|
||||
second = 1
|
||||
randbase = 0
|
||||
accepted_chars = @@default_accepted_chars.dup
|
||||
|
||||
# Remove bad chars from the accepted_chars list. Sadly 'A' must be
|
||||
# an accepted char or we'll certainly fail at this point. This could
|
||||
# be fixed later maybe with some recalculation of the encoder stubs...
|
||||
# - Puss
|
||||
(badchars || '').split('').each { |c| @@accepted_chars.delete(c) }
|
||||
(badchars || '').split('').each { |c| accepted_chars.delete(c) }
|
||||
|
||||
first = 0
|
||||
second = 1
|
||||
randbase = 0
|
||||
|
||||
gen_base_set(block).each do |randbase|
|
||||
second = gen_second(block, randbase)
|
||||
next if second < 0
|
||||
break if @@accepted_chars.include?(second.chr)
|
||||
break if accepted_chars.include?(second.chr)
|
||||
end
|
||||
|
||||
raise RuntimeError, "Negative" if second < 0
|
||||
raise RuntimeError, "BadChar; #{block} to #{second}" if not @@accepted_chars.include?(second.chr)
|
||||
raise RuntimeError, "BadChar; #{block} to #{second}" if not accepted_chars.include?(second.chr)
|
||||
|
||||
if (randbase > 0xa0)
|
||||
# first num must be 4
|
||||
@ -74,13 +77,13 @@ class Generic
|
||||
first.to_i.chr + second.chr
|
||||
end
|
||||
|
||||
def Generic.encode(buf, reg, offset)
|
||||
def Generic.encode(buf, reg, offset, badchars = '')
|
||||
encoded = gen_decoder(reg, offset)
|
||||
|
||||
buf.each_byte {
|
||||
|block|
|
||||
|
||||
encoded += encode_byte(block)
|
||||
encoded += encode_byte(block, badchars)
|
||||
}
|
||||
|
||||
encoded += add_terminator()
|
||||
|
@ -7,7 +7,7 @@ module Encoder
|
||||
module Alpha2
|
||||
|
||||
class UnicodeUpper < Generic
|
||||
@@accepted_chars = ('B' .. 'Z').to_a + ('0' .. '9').to_a
|
||||
@@default_accepted_chars = ('B' .. 'Z').to_a + ('0' .. '9').to_a
|
||||
|
||||
def self.gen_base_set(max)
|
||||
Rex::Text.shuffle_a(
|
||||
|
Loading…
Reference in New Issue
Block a user