Class: Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Base
- Inherits:
-
Object
- Object
- Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Base
- Defined in:
- lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb
Direct Known Subclasses
GetTickCount, If, IntAssignments, Malloc, OutputDebugString, Printf, StringAssignments, Switch, UninitVariables
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#dep ⇒ Object
readonly
Returns the value of attribute dep.
Instance Method Summary collapse
-
#good_dep?(parser) ⇒ Boolean
Checks whether this class is suitable for the code.
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #normalized_stub ⇒ Object
-
#stub ⇒ Object
Override this method when you inherit this class.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
13 14 15 16 |
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb', line 13 def initialize @dep = [] @code = normalized_stub end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
11 12 13 |
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb', line 11 def code @code end |
#dep ⇒ Object (readonly)
Returns the value of attribute dep.
10 11 12 |
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb', line 10 def dep @dep end |
Instance Method Details
#good_dep?(parser) ⇒ Boolean
Checks whether this class is suitable for the code.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb', line 37 def good_dep?(parser) # The difference between @dep and parser.toplevel.symbol.keys # is the list of functions not being supported by the original code. ready_function_names = parser.toplevel.symbol.keys delta = dep - ready_function_names if delta.empty? true else false end end |
#normalized_stub ⇒ Object
49 50 51 52 |
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb', line 49 def normalized_stub stub_parser = Metasploit::Framework::Obfuscation::CRandomizer::Utility.parse(stub) stub_parser.toplevel.statements.last.var.initializer.statements end |
#stub ⇒ Object
Override this method when you inherit this class. The method should return the source of the stub you’re trying to create, as a C function. For example: %Q| void printf(const char*); void stub()
printf("hello world\n");
| Notice if you are using a function like the above, you must declare/define that beforehand. The function declaration will not be used in the final source code.
29 30 31 |
# File 'lib/metasploit/framework/obfuscation/crandomizer/code_factory/base.rb', line 29 def stub raise NotImplementedError end |