Module: Msf::Handler::FindTag

Includes:
FindPort
Defined in:
lib/msf/core/handler/find_tag.rb

Overview

This handlers implements tag-based findsock handling.

Constant Summary

Constants included from Msf::Handler

Claimed, Unused

Instance Attribute Summary

Attributes included from FindPort

#_handler_return_value

Attributes included from Msf::Handler

#exploit_config, #parent_payload, #pending_connections, #session_waiter_event, #sessions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FindPort

#_check_shell, #create_session, #handler

Methods included from Msf::Handler

#add_handler, #cleanup_handler, #create_session, #handle_connection, #handler, #handler_name, #interrupt_wait_for_session, #register_session, #setup_handler, #start_handler, #stop_handler, #wait_for_session, #wfs_delay

Class Method Details

.general_handler_typeObject

Returns the connection oriented general handler type, in this case ‘find’.



27
28
29
# File 'lib/msf/core/handler/find_tag.rb', line 27

def self.general_handler_type
  "find"
end

.handler_typeObject

Returns the string representation of the handler type, in this case ‘find_tag’.



19
20
21
# File 'lib/msf/core/handler/find_tag.rb', line 19

def self.handler_type
  return "find_tag"
end

Instance Method Details

#_find_prefix(sock) ⇒ Object (protected)

Prefix the stage with this.



57
58
59
60
61
62
63
# File 'lib/msf/core/handler/find_tag.rb', line 57

def _find_prefix(sock)
  if (self.respond_to?('stage_prefix') == true)
    self.stage_prefix = _find_tag
  else
    _find_tag
  end
end

#_find_tagObject (protected)

Returns the tag we’ll be using.



81
82
83
84
85
86
# File 'lib/msf/core/handler/find_tag.rb', line 81

def _find_tag
  tag  = (datastore['TAG'] || "msf!")
  tag << ("\x01" * (tag.length - 4))

  return tag[0, 4]
end

#_send_id(sock) ⇒ Object (protected)

Transmits the tag.



68
69
70
71
72
73
74
75
76
# File 'lib/msf/core/handler/find_tag.rb', line 68

def _send_id(sock)
  if (self.payload_type == Msf::Payload::Type::Single)
    sock.put(_find_tag)

    return _find_tag
  end

  return nil
end

#initialize(info = {}) ⇒ Object

Initializes the find tag handler with the option that is required for all find-tag based payloads, such as the TAG that will be searched for.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/msf/core/handler/find_tag.rb', line 35

def initialize(info = {})
  super

  register_advanced_options(
    [
      OptString.new('TAG',
        [
          true,
          "The four byte tag to signify the connection.",
          Rex::Text.rand_text_alphanumeric(4),
        ])
    ], Msf::Handler::FindTag)

  # Eliminate the CPORT option.
  options.remove_option('CPORT')
end