Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

session_tagger.rb 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # $Id$
  3. # $Revision$
  4. #
  5. module Msf
  6. ###
  7. #
  8. # This class hooks all session creation events and allows automated interaction
  9. # This is only an example of what you can do with plugins
  10. #
  11. ###
  12. class Plugin::SessionTagger < Msf::Plugin
  13. include Msf::SessionEvent
  14. def on_session_open(session)
  15. print_status("Hooked session #{session.sid} / #{session.session_host}")
  16. # XXX: Determine what type of session this is before writing to it
  17. if (session.interactive?)
  18. session.shell_write("MKDIR C:\\TaggedBy#{ENV['USER']}\n")
  19. session.shell_write("mkdir /tmp/TaggedBy#{ENV['USER']}\n")
  20. end
  21. #
  22. # Read output with session.shell_read()
  23. #
  24. end
  25. def on_session_close(session,reason='')
  26. print_status("Hooked session #{session.sid} is shutting down")
  27. end
  28. def initialize(framework, opts)
  29. super
  30. self.framework.events.add_session_subscriber(self)
  31. end
  32. def cleanup
  33. self.framework.events.remove_session_subscriber(self)
  34. end
  35. def name
  36. "session_tagger"
  37. end
  38. def desc
  39. "Automatically interacts with new sessions"
  40. end
  41. end
  42. end