Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/plugins/rssfeed.rb
Views: 11705
module Msf1###2#3# This class hooks all session events and puts it into an RSS feed4#5###67class Plugin::EventRSS < Msf::Plugin89attr_accessor :items, :queue, :queue_thread1011include Msf::SessionEvent1213def add_event(event)14queue.push(event)15end1617def generate_feed(newitem)18items.unshift(newitem)19feed = RSS::Maker.make('atom') do |maker|20maker.channel.author = 'msfconsole'21maker.channel.updated = Time.new.to_s22maker.channel.about = 'https://metasploit.com'23maker.channel.title = 'msfconsole rss feed'2425items.each do |rssitem|26maker.items.new_item do |item|27item.link = rssitem[:link]28item.title = rssitem[:title]29item.updated = rssitem[:date]30item.summary = rssitem[:content]31end32end33end34File.open('feed.rss', 'w') { |f| f.write(feed) }35end3637def create_session_item(session, status)38if status == 'created'39select(nil, nil, nil, 25)40end41title = "#{session.type} session - #{session.sid} #{status}."42content = ''43if session.workspace44content << "Workspace:\t#{session.workspace}\n"45end46content << "Session Information: #{session.info}"47add_event({ title: title, date: Time.now.to_s, link: 'https://metasploit.com', content: content })48end4950def on_session_open(session)51create_session_item(session, 'created')52end5354def on_session_close(session, _reason = '')55create_session_item(session, 'closed')56end5758def on_session_fail(reason = ''); end5960def on_plugin_load61add_event({ title: 'RSS Plugin Loaded', date: Time.now.to_s, link: 'https://metasploit.com/', content: 'N/A' })62end6364def on_plugin_unload65generate_feed({ title: 'RSS Plugin Unloaded', date: Time.now.to_s, link: 'https:/metasploit.com/', content: 'N/A' })66end6768def start_event_queue69self.queue_thread = Rex::ThreadFactory.spawn('rss_plugin', false) do70loop do71while (event = queue.shift)72generate_feed(event)73end74select(nil, nil, nil, 0.25)75end76rescue ::Exception => e77print_status("RSS plugin: fatal error #{e} #{e.backtrace}")78end79end8081def stop_event_queue82queue_thread.kill if queue_thread83self.queue_thread = nil84queue.clear85end8687def initialize(framework, opts)88require 'rss'89super9091@items = []92self.queue = Queue.new93self.framework.events.add_session_subscriber(self)94start_event_queue9596on_plugin_load97end9899def cleanup100on_plugin_unload101framework.events.remove_session_subscriber(self)102stop_event_queue103end104105def name106'rss'107end108109def desc110'Create an RSS feed of events'111end112113end114end115116117