Class: TurboRex::Fuzzer::COMFuzzer::TargetBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/turborex/fuzzer.rb

Instance Method Summary collapse

Constructor Details

#initializeTargetBuilder

Returns a new instance of TargetBuilder.



80
81
82
# File 'lib/turborex/fuzzer.rb', line 80

def initialize
  @params = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/turborex/fuzzer.rb', line 107

def method_missing(m, *args, &block)
  if m.to_s.start_with?('param_')
    name = m.to_s.split('param_')[-1]

    index = @method.type.args.index {|a| a.name == name}
    raise "No such parameter #{name}" unless index
    arg = @method.type.args[index]
    raise "The THIS pointer can't be specified." if index == 0
    @params[index-1] = Docile.dsl_eval(ParamBuilder.new(index-1, @method.type.args), &block).build
  else
    super(m, *args, &block)
  end
end

Instance Method Details

#buildObject



103
104
105
# File 'lib/turborex/fuzzer.rb', line 103

def build
  Target.new(@clsid, @interface, @method, @params, @context)
end

#clsid(clsid) ⇒ Object



88
89
90
# File 'lib/turborex/fuzzer.rb', line 88

def clsid(clsid)
  @clsid = clsid
end

#context(context) ⇒ Object



92
93
94
# File 'lib/turborex/fuzzer.rb', line 92

def context(context)
  @context = context
end

#interface(iface) ⇒ Object



84
85
86
# File 'lib/turborex/fuzzer.rb', line 84

def interface(iface)
  @interface = iface
end

#method(name) ⇒ Object



96
97
98
99
100
101
# File 'lib/turborex/fuzzer.rb', line 96

def method(name)
  method = @interface.methods.find {|m| m.name == name.to_s}
  raise "No such method #{name}" unless method

  @method = method
end