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.
531 532 533 534 535 |
# File 'lib/rex/exploitation/opcodedb.rb', line 531 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.
710 711 712 |
# File 'lib/rex/exploitation/opcodedb.rb', line 710 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.
705 706 707 |
# File 'lib/rex/exploitation/opcodedb.rb', line 705 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.
705 706 707 |
# File 'lib/rex/exploitation/opcodedb.rb', line 705 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.
705 706 707 |
# File 'lib/rex/exploitation/opcodedb.rb', line 705 def server_uri @server_uri end |
Instance Method Details
#disable_parse ⇒ Object
Disables response parsing.
540 541 542 |
# File 'lib/rex/exploitation/opcodedb.rb', line 540 def disable_parse @disable_parse = true end |
#enable_parse ⇒ Object
Enables response parsing.
547 548 549 |
# File 'lib/rex/exploitation/opcodedb.rb', line 547 def enable_parse @disable_parse = false end |
#groups ⇒ Object
Returns an array of Group instances.
561 562 563 |
# File 'lib/rex/exploitation/opcodedb.rb', line 561 def groups request('groups').map { |ent| Group.create(ent) } end |
#locales ⇒ Object
Returns an array of Locale instances that are supported by the server.
642 643 644 |
# File 'lib/rex/exploitation/opcodedb.rb', line 642 def locales request('locales').map { |ent| Locale.create(ent) } end |
#meta_types ⇒ Object
Returns an array of MetaType instances.
554 555 556 |
# File 'lib/rex/exploitation/opcodedb.rb', line 554 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.
635 636 637 |
# File 'lib/rex/exploitation/opcodedb.rb', line 635 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.
595 596 597 |
# File 'lib/rex/exploitation/opcodedb.rb', line 595 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.
689 690 691 |
# File 'lib/rex/exploitation/opcodedb.rb', line 689 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.
697 698 699 |
# File 'lib/rex/exploitation/opcodedb.rb', line 697 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.
575 576 577 |
# File 'lib/rex/exploitation/opcodedb.rb', line 575 def types(filter = {}) request('types', filter).map { |ent| Type.create(ent) } end |