This example shows how to automatically interact with sesssions

git-svn-id: file:///home/svn/framework3/trunk@4439 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-02-18 22:51:59 +00:00
parent 6df72d9f41
commit 497ca2d3f5
1 changed files with 54 additions and 0 deletions

54
plugins/session_tagger.rb Normal file
View File

@ -0,0 +1,54 @@
module Msf
###
#
# This class hooks all session creation events and allows automated interaction
# This is only an example of what you can do with plugins
#
###
class Plugin::SessionTagger < Msf::Plugin
include Msf::SessionEvent
def on_session_open(session)
print_status("Hooked session #{session.sid} / #{session.tunnel_peer}")
# XXX: Determine what type of session this is before writing to it
if (session.interactive?)
session.write_shell("MKDIR C:\\TaggedBy#{ENV['USER']}\n")
session.write_shell("mkdir /tmp/TaggedBy#{ENV['USER']}\n")
end
#
# Read output with session.read_shell()
#
end
def on_session_close(session)
print_status("Hooked session #{session.sid} is shutting down")
end
def initialize(framework, opts)
super
@framework = framework
@framework.events.add_session_subscriber(self)
end
def cleanup
@framework.events.remove_session_subscriber(self)
end
def name
"session_tagger"
end
def desc
"Automatically interacts with new sessions"
end
end
end