Class: Rex::Exploitation::OpcodeDb::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/exploitation/opcodedb.rb

Overview

This class implements a client interface to the Metasploit Opcode Database. It is intended to be used as a method of locating reliable return addresses given a set of executable files and a set of usable opcodes.

Constant Summary collapse

DefaultServerHost =
"www.metasploit.com"
DefaultServerPort =
80
DefaultServerUri =
"/users/opcode/msfopcode_server.cgi"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host = DefaultServerHost, port = DefaultServerPort, uri = DefaultServerUri) ⇒ Client

Returns an instance of an initialized client that will use the supplied server values.



530
531
532
533
534
# File 'lib/rex/exploitation/opcodedb.rb', line 530

def initialize(host = DefaultServerHost, port = DefaultServerPort, uri = DefaultServerUri)
	self.server_host = host
	self.server_port = port
	self.server_uri  = uri
end

Instance Attribute Details

#last_xmlObject (readonly)

Retrieves the last raw XML response to be processed.



709
710
711
# File 'lib/rex/exploitation/opcodedb.rb', line 709

def last_xml
  @last_xml
end

#server_hostObject

These attributes convey information about the remote server and can be changed in order to point it to a locate copy as necessary.



704
705
706
# File 'lib/rex/exploitation/opcodedb.rb', line 704

def server_host
  @server_host
end

#server_portObject

These attributes convey information about the remote server and can be changed in order to point it to a locate copy as necessary.



704
705
706
# File 'lib/rex/exploitation/opcodedb.rb', line 704

def server_port
  @server_port
end

#server_uriObject

These attributes convey information about the remote server and can be changed in order to point it to a locate copy as necessary.



704
705
706
# File 'lib/rex/exploitation/opcodedb.rb', line 704

def server_uri
  @server_uri
end

Instance Method Details

#disable_parseObject

Disables response parsing.



539
540
541
# File 'lib/rex/exploitation/opcodedb.rb', line 539

def disable_parse
	@disable_parse = true
end

#enable_parseObject

Enables response parsing.



546
547
548
# File 'lib/rex/exploitation/opcodedb.rb', line 546

def enable_parse
	@disable_parse = false
end

#groupsObject

Returns an array of Group instances.



560
561
562
# File 'lib/rex/exploitation/opcodedb.rb', line 560

def groups
	request('groups').map { |ent| Group.create(ent) }
end

#localesObject

Returns an array of Locale instances that are supported by the server.



641
642
643
# File 'lib/rex/exploitation/opcodedb.rb', line 641

def locales
	request('locales').map { |ent| Locale.create(ent) }
end

#meta_typesObject

Returns an array of MetaType instances.



553
554
555
# File 'lib/rex/exploitation/opcodedb.rb', line 553

def meta_types
	request('meta_types').map { |ent| MetaType.create(ent) }
end

#modules(filter = {}) ⇒ Object

Returns an array of ImageModule instances. Image modules are version-specific, locale-specific, and operating system version specific image files. Modules have opcodes, segments, imports and exports associated with them. Optionally, a filter hash can be specified to limit the number of results returned from the database. If no filter hash is supplied, all modules will be returned.

LocaleNames (Array)

This hash element limits results to one or more specific locale by name.

PlatformNames (Array)

This hash element limits results to one or more specific platform by name.

ModuleNames (Array)

This hash element limits results to one or more specific module by name.

Segments (Bool)

If this hash element is set to true, the segments associated with each resulting module will be returned by the server.

Imports (Bool)

If this hash element is set to true, the imports associated with each resulting module will be returned by the server.

Exports (Bool)

If this hash element is set to true, the exports associated with each resulting module will be returned by the server.



634
635
636
# File 'lib/rex/exploitation/opcodedb.rb', line 634

def modules(filter = {})
	request('modules', filter).map { |ent| ImageModule.create(ent) }
end

#platforms(filter = {}) ⇒ Object

Returns an array of OsVersion instances. OS versions are associated with a particular operating system release (including service packs). Optionally, a filter hash can be passed to limit the number of results returned. If no filter hash is supplied, all results are returned.

Names (Array)

If this hash element is specified, only the operating systems that contain one or more of the names specified will be returned.

Statistics (Bool)

If this hash element is set to true, the number of modules associated with this matched operating system versions will be returned.



594
595
596
# File 'lib/rex/exploitation/opcodedb.rb', line 594

def platforms(filter = {})
	request('platforms', filter).map { |ent| OsVersion.create(ent) }
end

#search(filter = {}) ⇒ Object

Returns an array of Opcode instances that match the filter limitations specified in the supplied filter hash. If no filter hash is specified, all opcodes will be returned (but are most likely going to be limited by the server). The filter hash limiters that can be specified are:

ModuleNames (Array)

This hash element limits results to one or more specific modules by name.

GroupNames (Array)

This hash element limits results to one or more specific opcode group by name.

TypeNames (Array)

This hash element limits results to one or more specific opcode type by name.

MetaTypeNames (Array)

This hash element limits results to one or more specific opcode meta type by name.

LocaleNames (Array)

Limits results to one or more specific locale by name.

PlatformNames (Array)

Limits reslts to one or more specific operating system version by name.

Addresses (Array)

Limits results to a specific set of addresses.

Portable (Bool)

If this hash element is true, opcode results will be limited to ones that span more than one operating system version.



688
689
690
# File 'lib/rex/exploitation/opcodedb.rb', line 688

def search(filter = {})
	request('search', filter).map { |ent| Opcode.new(ent) }
end

#statisticsObject

Returns an instance of the Statistics class that holds information about the server’s database stats.



696
697
698
# File 'lib/rex/exploitation/opcodedb.rb', line 696

def statistics
	Statistics.new(request('statistics'))
end

#types(filter = {}) ⇒ Object

Returns an array of Type instances. Opcode types are specific opcodes, such as a jmp esp. Optionally, a filter hash can be passed to include extra information in the results.

Statistics (Bool)

If this hash element is set to true, the number of opcodes currently in the database of this type will be returned.



574
575
576
# File 'lib/rex/exploitation/opcodedb.rb', line 574

def types(filter = {})
	request('types', filter).map { |ent| Type.create(ent) }
end