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
|
# framework that an encoder must be explicitly defined as the
|
||||||
# encoder of choice for an exploit.
|
# encoder of choice for an exploit.
|
||||||
if ((reqs['EncoderType'].nil?) and
|
if ((reqs['EncoderType'].nil?) and
|
||||||
|
(reqs['Encoder'].nil?) and
|
||||||
(self.encoder.rank == ManualRanking))
|
(self.encoder.rank == ManualRanking))
|
||||||
wlog("#{pinst.refname}: Encoder #{encoder.refname} is manual ranked and was not defined as a preferred encoder.",
|
wlog("#{pinst.refname}: Encoder #{encoder.refname} is manual ranked and was not defined as a preferred encoder.",
|
||||||
'core', LEV_1)
|
'core', LEV_1)
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Encoder
|
||||||
module Alpha2
|
module Alpha2
|
||||||
|
|
||||||
class AlphaUpper < Generic
|
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)
|
def self.gen_decoder_prefix(reg, offset)
|
||||||
if (offset > 20)
|
if (offset > 20)
|
||||||
|
|
|
@ -7,7 +7,8 @@ module Encoder
|
||||||
module Alpha2
|
module Alpha2
|
||||||
|
|
||||||
class Generic
|
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)
|
def Generic.gen_decoder_prefix(reg, offset)
|
||||||
# Should never happen - have to pick a specifc
|
# Should never happen - have to pick a specifc
|
||||||
|
@ -35,24 +36,26 @@ class Generic
|
||||||
end
|
end
|
||||||
|
|
||||||
def Generic.encode_byte(block, badchars)
|
def Generic.encode_byte(block, badchars)
|
||||||
first = 0
|
accepted_chars = @@default_accepted_chars.dup
|
||||||
second = 1
|
|
||||||
randbase = 0
|
|
||||||
|
|
||||||
# Remove bad chars from the accepted_chars list. Sadly 'A' must be
|
# 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
|
# an accepted char or we'll certainly fail at this point. This could
|
||||||
# be fixed later maybe with some recalculation of the encoder stubs...
|
# be fixed later maybe with some recalculation of the encoder stubs...
|
||||||
# - Puss
|
# - 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|
|
gen_base_set(block).each do |randbase|
|
||||||
second = gen_second(block, randbase)
|
second = gen_second(block, randbase)
|
||||||
next if second < 0
|
next if second < 0
|
||||||
break if @@accepted_chars.include?(second.chr)
|
break if accepted_chars.include?(second.chr)
|
||||||
end
|
end
|
||||||
|
|
||||||
raise RuntimeError, "Negative" if second < 0
|
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)
|
if (randbase > 0xa0)
|
||||||
# first num must be 4
|
# first num must be 4
|
||||||
|
@ -74,13 +77,13 @@ class Generic
|
||||||
first.to_i.chr + second.chr
|
first.to_i.chr + second.chr
|
||||||
end
|
end
|
||||||
|
|
||||||
def Generic.encode(buf, reg, offset)
|
def Generic.encode(buf, reg, offset, badchars = '')
|
||||||
encoded = gen_decoder(reg, offset)
|
encoded = gen_decoder(reg, offset)
|
||||||
|
|
||||||
buf.each_byte {
|
buf.each_byte {
|
||||||
|block|
|
|block|
|
||||||
|
|
||||||
encoded += encode_byte(block)
|
encoded += encode_byte(block, badchars)
|
||||||
}
|
}
|
||||||
|
|
||||||
encoded += add_terminator()
|
encoded += add_terminator()
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Encoder
|
||||||
module Alpha2
|
module Alpha2
|
||||||
|
|
||||||
class UnicodeUpper < Generic
|
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)
|
def self.gen_base_set(max)
|
||||||
Rex::Text.shuffle_a(
|
Rex::Text.shuffle_a(
|
||||||
|
|
Loading…
Reference in New Issue