Class: Msf::Sessions::Pingback

Inherits:
Object
  • Object
show all
Includes:
Msf::Session, Msf::Session::Basic
Defined in:
lib/msf/base/sessions/pingback.rb

Overview

This class provides the ability to receive a pingback UUID

Instance Attribute Summary collapse

Attributes included from Msf::Session::Interactive

#rstream

Attributes included from Rex::Ui::Interactive

#completed, #interacting, #next_session, #on_command_proc, #on_print_proc, #on_run_command_error_proc, #orig_suspend, #orig_usr1, #orig_winch

Attributes included from Rex::Ui::Subscriber::Input

#user_input

Attributes included from Rex::Ui::Subscriber::Output

#user_output

Attributes included from Msf::Session

#alive, #db_record, #exploit, #exploit_datastore, #exploit_task, #exploit_uuid, #framework, #info, #machine_id, #payload_uuid, #routes, #sid, #sname, #target_host, #target_port, #username, #uuid, #via, #workspace

Attributes included from Framework::Offspring

#framework

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Msf::Session::Basic

#_interact

Methods included from Msf::Session::Interactive

#_interact, #_interact_complete, #_interrupt, #_suspend, #_usr1, #abort_foreground, #abort_foreground_supported, #comm_channel, #interactive?, #kill, #run_cmd, #tunnel_local, #tunnel_peer, #user_want_abort?

Methods included from Rex::Ui::Interactive

#_interact, #_interact_complete, #_interrupt, #_local_fd, #_remote_fd, #_stream_read_local_write_remote, #_stream_read_remote_write_local, #_suspend, #_winch, #detach, #handle_suspend, #handle_usr1, #handle_winch, #interact, #interact_stream, #prompt, #prompt_yesno, #restore_suspend, #restore_usr1, #restore_winch

Methods included from Rex::Ui::Subscriber

#copy_ui, #init_ui, #reset_ui

Methods included from Rex::Ui::Subscriber::Input

#gets

Methods included from Rex::Ui::Subscriber::Output

#flush, #print, #print_blank_line, #print_error, #print_good, #print_line, #print_status, #print_warning

Methods included from Msf::Session

#alive?, #comm_channel, #dead?, #inspect, #interactive?, #kill, #log_file_name, #log_source, #name, #name=, #register?, #session_host, #session_host=, #session_port, #session_port=, #session_type, #set_from_exploit, #set_via, #tunnel_local, #tunnel_peer, #tunnel_to_s, #via_exploit, #via_payload

Constructor Details

#initialize(rstream, opts = {}) ⇒ Pingback

Returns a new instance of Pingback.



30
31
32
33
34
35
# File 'lib/msf/base/sessions/pingback.rb', line 30

def initialize(rstream, opts = {})
  super
  self.platform ||= ""
  self.arch     ||= ""
  datastore = opts[:datastore]
end

Instance Attribute Details

#archObject

Returns the value of attribute arch.



19
20
21
# File 'lib/msf/base/sessions/pingback.rb', line 19

def arch
  @arch
end

#platformObject

Returns the value of attribute platform.



20
21
22
# File 'lib/msf/base/sessions/pingback.rb', line 20

def platform
  @platform
end

#uuid_stringObject

Returns the value of attribute uuid_string.



21
22
23
# File 'lib/msf/base/sessions/pingback.rb', line 21

def uuid_string
  @uuid_string
end

Class Method Details

.can_cleanup_filesObject



86
87
88
# File 'lib/msf/base/sessions/pingback.rb', line 86

def self.can_cleanup_files
  false
end

.create_session(rstream, opts = {}) ⇒ Object



37
38
39
# File 'lib/msf/base/sessions/pingback.rb', line 37

def self.create_session(rstream, opts = {})
  Msf::Sessions::Pingback.new(rstream, opts)
end

.typeObject

Returns the type of session.



26
27
28
# File 'lib/msf/base/sessions/pingback.rb', line 26

def self.type
  "pingback"
end

Instance Method Details

#cleanupObject



46
47
48
49
50
51
52
# File 'lib/msf/base/sessions/pingback.rb', line 46

def cleanup
  if rstream
    # this is also a best-effort
    rstream.close rescue nil
    rstream = nil
  end
end

#descObject

Returns the session description.



82
83
84
# File 'lib/msf/base/sessions/pingback.rb', line 82

def desc
  "Pingback"
end

#process_autoruns(datastore) ⇒ Object



41
42
43
44
# File 'lib/msf/base/sessions/pingback.rb', line 41

def process_autoruns(datastore)
  uuid_read
  cleanup
end

#typeObject

Calls the class method



93
94
95
# File 'lib/msf/base/sessions/pingback.rb', line 93

def type
  self.class.type
end

#uuid_readObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/msf/base/sessions/pingback.rb', line 54

def uuid_read
  uuid_raw = rstream.get_once(16, 1)
  return nil unless uuid_raw
  self.uuid_string = uuid_raw.each_byte.map { |b| "%02x" % b.to_i() }.join
  print_status("Incoming UUID = #{uuid_string}")
  if framework.db.active
    begin
      payload = framework.db.payloads(uuid: uuid_string).first
      if payload.nil?
        print_warning("Provided UUID (#{uuid_string}) was not found in database!")
      else
        print_good("UUID identified (#{uuid_string})")
      end
    rescue ActiveRecord::ConnectionNotEstablished
      print_status("WARNING: UUID verification and logging is not available, because the database is not active.")
    rescue => e
      # TODO: Can we have a more specific exception handler?
      # Test: what if we send no bytes back?  What if we send less than 16 bytes?  Or more than?
      elog('Can\'t get original UUID', error: e)
    end
  else
    print_warning("WARNING: UUID verification and logging is not available, because the database is not active.")
  end
end