Class: Rex::Exploitation::OpcodeDb::Client
- Inherits:
-
Object
- Object
- Rex::Exploitation::OpcodeDb::Client
- 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
-
#last_xml ⇒ Object
readonly
Retrieves the last raw XML response to be processed.
-
#server_host ⇒ Object
These attributes convey information about the remote server and can be changed in order to point it to a locate copy as necessary.
-
#server_port ⇒ Object
These attributes convey information about the remote server and can be changed in order to point it to a locate copy as necessary.
-
#server_uri ⇒ Object
These attributes convey information about the remote server and can be changed in order to point it to a locate copy as necessary.
Instance Method Summary collapse
-
#disable_parse ⇒ Object
Disables response parsing.
-
#enable_parse ⇒ Object
Enables response parsing.
-
#groups ⇒ Object
Returns an array of Group instances.
-
#initialize(host = DefaultServerHost, port = DefaultServerPort, uri = DefaultServerUri) ⇒ Client
constructor
Returns an instance of an initialized client that will use the supplied server values.
-
#locales ⇒ Object
Returns an array of Locale instances that are supported by the server.
-
#meta_types ⇒ Object
Returns an array of MetaType instances.
-
#modules(filter = {}) ⇒ Object
Returns an array of ImageModule instances.
-
#platforms(filter = {}) ⇒ Object
Returns an array of OsVersion instances.
-
#search(filter = {}) ⇒ Object
Returns an array of Opcode instances that match the filter limitations specified in the supplied filter hash.
-
#statistics ⇒ Object
Returns an instance of the Statistics class that holds information about the server’s database stats.
-
#types(filter = {}) ⇒ Object
Returns an array of Type instances.
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_xml ⇒ Object (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_host ⇒ Object
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_port ⇒ Object
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_uri ⇒ Object
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_parse ⇒ Object
Disables response parsing.
539 540 541 |
# File 'lib/rex/exploitation/opcodedb.rb', line 539 def disable_parse @disable_parse = true end |
#enable_parse ⇒ Object
Enables response parsing.
546 547 548 |
# File 'lib/rex/exploitation/opcodedb.rb', line 546 def enable_parse @disable_parse = false end |
#groups ⇒ Object
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 |
#locales ⇒ Object
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_types ⇒ Object
Returns an array of MetaType instances.
553 554 555 |
# File 'lib/rex/exploitation/opcodedb.rb', line 553 def 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 |
#statistics ⇒ Object
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 |