mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-10-16 01:21:15 +02:00
add a plugin to create new routes through previously-unknown subnets
git-svn-id: file:///home/svn/framework3/trunk@8409 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
0b6c44b2cb
commit
894664ef72
31
plugins/auto_add_route.rb
Normal file
31
plugins/auto_add_route.rb
Normal file
@ -0,0 +1,31 @@
|
||||
module Msf
|
||||
class Plugin::AutoAddRoute < Msf::Plugin
|
||||
include Msf::SessionEvent
|
||||
def name; 'auto_add_route'; end
|
||||
def on_session_open(session)
|
||||
return if not session.type == 'meterpreter'
|
||||
session.load_stdapi
|
||||
session.net.config.each_route { |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'
|
||||
if not Rex::Socket::SwitchBoard.route_exists?(route.subnet, route.netmask)
|
||||
print_status("AutoAddRoute: Routing new subnet #{route.subnet}/#{route.netmask} through session #{session.sid}")
|
||||
Rex::Socket::SwitchBoard.add_route(route.subnet, route.netmask, session)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def initialize(framework, opts)
|
||||
super
|
||||
self.framework.events.add_session_subscriber(self)
|
||||
end
|
||||
|
||||
def cleanup
|
||||
self.framework.events.remove_session_subscriber(self)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user