Files
metasploit-gs/plugins/auto_add_route.rb
T

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

41 lines
1.1 KiB
Ruby
Raw Normal View History

module Msf
2023-01-30 12:25:46 +11:00
class Plugin::AutoAddRoute < Msf::Plugin
include Msf::SessionEvent
def name
'auto_add_route'
end
2011-01-27 17:33:39 +00:00
2023-01-30 12:25:46 +11:00
def desc
'Adds routes for any new subnets whenever a session opens'
end
def on_session_open(session)
return if session.type != 'meterpreter'
session.load_stdapi
sb = Rex::Socket::SwitchBoard.instance
session.net.config.each_route do |route|
# Remove multicast and loopback interfaces
next if route.subnet =~ /^(224\.|127\.)/
next if route.subnet == '0.0.0.0'
next if route.netmask == '255.255.255.255'
2011-01-27 17:33:39 +00:00
2023-01-30 12:25:46 +11:00
if !sb.route_exists?(route.subnet, route.netmask)
print_status("AutoAddRoute: Routing new subnet #{route.subnet}/#{route.netmask} through session #{session.sid}")
sb.add_route(route.subnet, route.netmask, session)
end
2013-09-30 13:47:53 -05:00
end
2023-01-30 12:25:46 +11:00
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
end
end