Class: Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::FakeFunction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(func_name) ⇒ FakeFunction

Returns a new instance of FakeFunction.



15
16
17
18
19
20
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function.rb', line 15

def initialize(func_name)
  @attribute = ['', ' __attribute__((export))'].sample
  @return_type = ['int', 'char*', 'void', ].sample
  @args = ['int i', 'char* s', 'void'].sample
  @function_name = func_name
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
end

#attributeObject (readonly)

Returns the value of attribute attribute.



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

def attribute
  @attribute
end

#function_nameObject (readonly)

Returns the value of attribute function_name.



13
14
15
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function.rb', line 13

def function_name
  @function_name
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



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

def return_type
  @return_type
end

Instance Method Details

#generate_bodyObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/fake_function.rb', line 22

def generate_body
  case return_type
  when 'int'
    rand_return_val = Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int
    return_statement = %Q|return #{rand_return_val};|
  when 'char*'
    rand_return_str = Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_string
    return_statement = %Q|return "#{rand_return_str}";|
  else
    return_statement = ''
  end

  %Q|
  #{return_type} #{function_name}#{attribute}(#{args}) {
    #{return_statement}
  }|
end