forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_tagger.rb
58 lines (42 loc) · 1.06 KB
/
session_tagger.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# $Id$
# $Revision$
#
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.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
def on_session_close(session,reason='')
print_status("Hooked session #{session.sid} is shutting down")
end
def initialize(framework, opts)
super
self.framework.events.add_session_subscriber(self)
end
def cleanup
self.framework.events.remove_session_subscriber(self)
end
def name
"session_tagger"
end
def desc
"Automatically interacts with new sessions"
end
end
end