Sha256: 9147d527b566cbd792396a043cdc8cf307e024a11f1c14601c1a6b88faba8edd

Contents?: true

Size: 1.34 KB

Versions: 41

Compression:

Stored size: 1.34 KB

Contents

module Rex
module Proto
module SMB
class Evasions

require 'rex/text'

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

	# Add bogus filler at the end of the SMB packet and before the data
	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

	# Obscures a named pipe pathname via leading and trailing slashes
	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

	# Obscures the TransactNamedPipe \PIPE\ string
	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

end
end
end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/proto/smb/evasions.rb
librex-0.0.63 lib/rex/proto/smb/evasions.rb
librex-0.0.54 lib/rex/proto/smb/evasions.rb
librex-0.0.53 lib/rex/proto/smb/evasions.rb
librex-0.0.52 lib/rex/proto/smb/evasions.rb
librex-0.0.51 lib/rex/proto/smb/evasions.rb
librex-0.0.50 lib/rex/proto/smb/evasions.rb
librex-0.0.49 lib/rex/proto/smb/evasions.rb
librex-0.0.48 lib/rex/proto/smb/evasions.rb
librex-0.0.47 lib/rex/proto/smb/evasions.rb
librex-0.0.46 lib/rex/proto/smb/evasions.rb
librex-0.0.44 lib/rex/proto/smb/evasions.rb
librex-0.0.43 lib/rex/proto/smb/evasions.rb
librex-0.0.42 lib/rex/proto/smb/evasions.rb
librex-0.0.41 lib/rex/proto/smb/evasions.rb
librex-0.0.40 lib/rex/proto/smb/evasions.rb
librex-0.0.39 lib/rex/proto/smb/evasions.rb
librex-0.0.38 lib/rex/proto/smb/evasions.rb
librex-0.0.37 lib/rex/proto/smb/evasions.rb
librex-0.0.36 lib/rex/proto/smb/evasions.rb