Class: Metasploit::Framework::Obfuscation::CRandomizer::RandomStatements

Inherits:
Object
  • Object
show all
Defined in:
lib/metasploit/framework/obfuscation/crandomizer/random_statements.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p, fake_functions, s = nil) ⇒ RandomStatements

Initializes the RandomStatements class.

Parameters:



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/metasploit/framework/obfuscation/crandomizer/random_statements.rb', line 18

def initialize(p, fake_functions, s=nil)
  @parser = p
  @fake_function_collection = fake_functions
  @statements = [ Proc.new { get_random_statements } ]

  # Only generate fake function calls when the function we are modifying isn't
  # from one of those fake functions (to avoid a recursion).
  if s && fake_function_collection && !fake_function_collection.has_function_name?(s.var.name)
    @statements << Proc.new { get_random_function_call }
  end
end

Instance Attribute Details

#fake_function_collectionObject (readonly)

Returns the value of attribute fake_function_collection.



11
12
13
# File 'lib/metasploit/framework/obfuscation/crandomizer/random_statements.rb', line 11

def fake_function_collection
  @fake_function_collection
end

#parserObject (readonly)

Returns the value of attribute parser.



10
11
12
# File 'lib/metasploit/framework/obfuscation/crandomizer/random_statements.rb', line 10

def parser
  @parser
end

#statementsObject (readonly)

Returns the value of attribute statements.



12
13
14
# File 'lib/metasploit/framework/obfuscation/crandomizer/random_statements.rb', line 12

def statements
  @statements
end

Instance Method Details

#getArray<Metasm::C::CExpression>, Array<Metasm::C::Declaration>

Returns a random statement.

Returns:

  • (Array<Metasm::C::CExpression>)
  • (Array<Metasm::C::Declaration>)


34
35
36
# File 'lib/metasploit/framework/obfuscation/crandomizer/random_statements.rb', line 34

def get
  statements.sample.call
end