Class: Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::FakeFunctionCollection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_functions) ⇒ Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::FakeFunctionCollection

Initializes a Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::FakeFunctionCollection instance.

Parameters:

  • max_functions (Integer)

    Max number of fake functions to generate.



17
18
19
20
21
22
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function_collection.rb', line 17

def initialize(max_functions)
  @functions = []
  @max_functions = max_functions
  populate
  self
end

Instance Attribute Details

#functionsObject

Returns the value of attribute functions.



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

def functions
  @functions
end

#max_functionsObject (readonly)

Returns the value of attribute max_functions.



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

def max_functions
  @max_functions
end

Instance Method Details

#eachObject

Yields a list of fake functions available.



25
26
27
28
29
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function_collection.rb', line 25

def each
  functions.each do |f|
    yield f
  end
end

#empty?Boolean

Checks if the collection is empty or not.

Returns:

  • (Boolean)


58
59
60
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function_collection.rb', line 58

def empty?
  functions.empty?
end

#has_function_name?(name) ⇒ Boolean

Asks the FakeFunctionCollection if a function is available.

Parameters:

  • name (String)

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function_collection.rb', line 47

def has_function_name?(name)
  functions.each do |f|
    if f.var.name == name
      return true
    end
  end

  false
end

#sampleMetasm::C::Declaration

Returns a fake Metasm::C::Declaration from the FakeFunctionCollection object.

Returns:

  • (Metasm::C::Declaration)


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

def sample
  functions.sample
end

#to_sObject

Returns a string that joins the fake functions



39
40
41
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function_collection.rb', line 39

def to_s
  functions.join("\n")
end