Class: Msf::Plugin::SessionTagger

Inherits:
Msf::Plugin show all
Includes:
SessionEvent
Defined in:
plugins/session_tagger.rb

Overview

This class hooks all session creation events and allows automated interaction This is only an example of what you can do with plugins

Instance Attribute Summary

Attributes inherited from Msf::Plugin

#opts

Attributes included from Framework::Offspring

#framework

Instance Method Summary collapse

Methods included from SessionEvent

#on_session_command, #on_session_download, #on_session_filedelete, #on_session_interact, #on_session_output, #on_session_upload

Methods inherited from Msf::Plugin

#add_console_dispatcher, create, #flush, #input, #output, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #remove_console_dispatcher

Constructor Details

#initialize(framework, opts) ⇒ SessionTagger

Returns a new instance of SessionTagger.


39
40
41
42
# File 'plugins/session_tagger.rb', line 39

def initialize(framework, opts)
  super
  self.framework.events.add_session_subscriber(self)
end

Instance Method Details

#cleanupObject


44
45
46
# File 'plugins/session_tagger.rb', line 44

def cleanup
  self.framework.events.remove_session_subscriber(self)
end

#descObject


52
53
54
# File 'plugins/session_tagger.rb', line 52

def desc
  "Automatically interacts with new sessions"
end

#nameObject


48
49
50
# File 'plugins/session_tagger.rb', line 48

def name
  "session_tagger"
end

#on_session_close(session, reason = '') ⇒ Object


35
36
37
# File 'plugins/session_tagger.rb', line 35

def on_session_close(session,reason='')
  print_status("Hooked session #{session.sid} is shutting down")
end

#on_session_open(session) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'plugins/session_tagger.rb', line 20

def on_session_open(session)
  print_status("Hooked session #{session.sid} / #{session.session_host}")

  # XXX: Determine what type of session this is before writing to it

  if (session.interactive?)
    session.shell_write("MKDIR C:\\TaggedBy#{ENV['USER']}\n")
    session.shell_write("mkdir /tmp/TaggedBy#{ENV['USER']}\n")
  end

  #
  # Read output with session.shell_read()
  #
end