2005-09-23 03:43:04 +00:00
|
|
|
module Rex
|
|
|
|
module Proto
|
|
|
|
module SMB
|
|
|
|
class Evasions
|
|
|
|
|
|
|
|
require 'rex/text'
|
|
|
|
|
|
|
|
EVASION_NONE = 0
|
|
|
|
EVASION_LOW = 1
|
|
|
|
EVASION_HIGH = 2
|
|
|
|
EVASION_MAX = 3
|
|
|
|
|
2005-09-23 06:27:22 +00:00
|
|
|
# Add bogus filler at the end of the SMB packet and before the data
|
2010-07-05 13:38:39 +00:00
|
|
|
def self.make_offset_filler(level, max_size = 60000, min_size = 512)
|
2005-09-23 06:27:22 +00:00
|
|
|
|
|
|
|
if (max_size < 0)
|
|
|
|
max_size = 4096
|
|
|
|
end
|
2010-07-05 13:38:39 +00:00
|
|
|
|
2005-09-23 06:27:22 +00:00
|
|
|
if (min_size < max_size)
|
|
|
|
min_size = max_size - 1
|
|
|
|
end
|
2010-07-05 13:38:39 +00:00
|
|
|
|
|
|
|
case level.to_i
|
2005-09-23 06:27:22 +00:00
|
|
|
when EVASION_LOW
|
2006-04-30 19:49:27 +00:00
|
|
|
Rex::Text.rand_text(32)
|
2005-09-23 06:27:22 +00:00
|
|
|
when EVASION_HIGH
|
2006-04-30 19:49:27 +00:00
|
|
|
Rex::Text.rand_text( rand(max_size - min_size) + min_size )
|
2005-09-23 06:27:22 +00:00
|
|
|
when EVASION_MAX
|
|
|
|
Rex::Text.rand_text( rand(max_size) )
|
2010-07-05 13:38:39 +00:00
|
|
|
else EVASION_NONE
|
|
|
|
return ''
|
2005-09-23 06:27:22 +00:00
|
|
|
end
|
|
|
|
end
|
2010-07-05 13:38:39 +00:00
|
|
|
|
2005-09-23 03:43:04 +00:00
|
|
|
# Obscures a named pipe pathname via leading and trailing slashes
|
|
|
|
def self.make_named_pipe_path(level, pipe)
|
2010-07-05 13:38:39 +00:00
|
|
|
case level.to_i
|
2005-09-23 03:43:04 +00:00
|
|
|
when EVASION_LOW
|
|
|
|
return ('\\' * (1024 + rand(512))) + pipe
|
|
|
|
when EVASION_HIGH, EVASION_MAX
|
|
|
|
return ('\\' * (1024 + rand(512))) + pipe + ('\\' * (1024 + rand(512)))
|
2010-07-05 13:38:39 +00:00
|
|
|
else
|
|
|
|
return '\\' + pipe
|
|
|
|
end
|
2005-09-23 03:43:04 +00:00
|
|
|
end
|
2010-07-05 13:38:39 +00:00
|
|
|
|
2005-09-23 03:43:04 +00:00
|
|
|
# Obscures the TransactNamedPipe \PIPE\ string
|
|
|
|
def self.make_trans_named_pipe_name(level)
|
2010-07-05 13:38:39 +00:00
|
|
|
case level.to_i
|
2005-09-23 03:43:04 +00:00
|
|
|
when EVASION_LOW
|
2005-09-23 06:27:22 +00:00
|
|
|
return ('\\' * (256 - rand(64)) + 'PIPE\\')
|
2005-09-23 03:43:04 +00:00
|
|
|
when EVASION_HIGH
|
2005-09-23 06:27:22 +00:00
|
|
|
return Rex::Text.rand_text(512 - rand(128))
|
2005-09-23 03:43:04 +00:00
|
|
|
when EVASION_MAX
|
2005-09-23 06:27:22 +00:00
|
|
|
return Rex::Text.rand_text(1024 - rand(256))
|
2010-07-05 13:38:39 +00:00
|
|
|
else
|
|
|
|
return '\\PIPE\\'
|
2005-09-23 03:43:04 +00:00
|
|
|
end
|
2010-07-05 13:38:39 +00:00
|
|
|
end
|
2005-09-23 03:43:04 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-07-05 13:38:39 +00:00
|
|
|
end
|
|
|
|
|