Files
metasploit-gs/plugins/session_tagger.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.2 KiB
Ruby
Raw Normal View History

2010-05-03 17:13:09 +00:00
#
# $Id$
# $Revision$
#
module Msf
2023-01-30 12:25:46 +11:00
###
#
# This class hooks all session creation events and allows automated interaction
# This is only an example of what you can do with plugins
#
###
2023-01-30 12:25:46 +11:00
class Plugin::SessionTagger < Msf::Plugin
2023-01-30 12:25:46 +11:00
include Msf::SessionEvent
2023-01-30 12:25:46 +11:00
def on_session_open(session)
print_status("Hooked session #{session.sid} / #{session.session_host}")
2023-01-30 12:25:46 +11:00
# XXX: Determine what type of session this is before writing to it
2023-01-30 12:25:46 +11:00
if session.interactive?
session.shell_write("MKDIR C:\\TaggedBy#{ENV['USER']}\n")
session.shell_write("mkdir /tmp/TaggedBy#{ENV['USER']}\n")
end
2023-01-30 12:25:46 +11:00
#
# Read output with session.shell_read()
#
2013-09-30 13:47:53 -05:00
end
2023-01-30 12:25:46 +11:00
def on_session_close(session, _reason = '')
print_status("Hooked session #{session.sid} is shutting down")
end
2023-01-30 12:25:46 +11:00
def initialize(framework, opts)
super
self.framework.events.add_session_subscriber(self)
end
2023-01-30 12:25:46 +11:00
def cleanup
framework.events.remove_session_subscriber(self)
end
2023-01-30 12:25:46 +11:00
def name
'session_tagger'
end
2023-01-30 12:25:46 +11:00
def desc
'Automatically interacts with new sessions to create a new remote TaggedByUser file'
2023-01-30 12:25:46 +11:00
end
2013-09-30 13:47:53 -05:00
end
end