Class: Rex::Proto::SMB::Evasions

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/smb/evasions.rb

Constant Summary collapse

EVASION_NONE =
0
EVASION_LOW =
1
EVASION_HIGH =
2
EVASION_MAX =
3

Class Method Summary collapse

Class Method Details

.make_named_pipe_path(level, pipe) ⇒ Object

Obscures a named pipe pathname via leading and trailing slashes


38
39
40
41
42
43
44
45
46
47
# File 'lib/rex/proto/smb/evasions.rb', line 38

def self.make_named_pipe_path(level, pipe)
  case level.to_i
    when EVASION_LOW
      return ('\\' * (1024 + rand(512))) + pipe
    when EVASION_HIGH, EVASION_MAX
      return ('\\' * (1024 + rand(512))) + pipe + ('\\' * (1024 + rand(512)))
    else
      return '\\' + pipe
  end
end

.make_offset_filler(level, max_size = 60000, min_size = 512) ⇒ Object

Add bogus filler at the end of the SMB packet and before the data


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rex/proto/smb/evasions.rb', line 15

def self.make_offset_filler(level, max_size = 60000, min_size = 512)

  if (max_size < 0)
    max_size = 4096
  end

  if (min_size < max_size)
    min_size = max_size - 1
  end

  case level.to_i
    when EVASION_LOW
      Rex::Text.rand_text(32)
    when EVASION_HIGH
      Rex::Text.rand_text( rand(max_size - min_size) + min_size )
    when EVASION_MAX
      Rex::Text.rand_text( rand(max_size) )
    else EVASION_NONE
      return ''
  end
end

.make_trans_named_pipe_name(level) ⇒ Object

Obscures the TransactNamedPipe PIPE\ string


50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rex/proto/smb/evasions.rb', line 50

def self.make_trans_named_pipe_name(level)
  case level.to_i
    when EVASION_LOW
      return ('\\' * (256 - rand(64)) + 'PIPE\\')
    when EVASION_HIGH
      return Rex::Text.rand_text(512 - rand(128))
    when EVASION_MAX
      return Rex::Text.rand_text(1024 - rand(256))
    else
      return '\\PIPE\\'
  end
end