Class: Msf::Plugin::AutoAddRoute

Inherits:
Msf::Plugin show all
Includes:
SessionEvent
Defined in:
plugins/auto_add_route.rb

Instance Attribute Summary

Attributes inherited from Msf::Plugin

#opts

Attributes included from Framework::Offspring

#framework

Instance Method Summary collapse

Methods included from SessionEvent

#on_session_close, #on_session_command, #on_session_download, #on_session_filedelete, #on_session_interact, #on_session_output, #on_session_upload

Methods inherited from Msf::Plugin

#add_console_dispatcher, create, #flush, #input, #output, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #remove_console_dispatcher

Constructor Details

#initialize(framework, opts) ⇒ AutoAddRoute

Returns a new instance of AutoAddRoute.


31
32
33
34
# File 'plugins/auto_add_route.rb', line 31

def initialize(framework, opts)
  super
  self.framework.events.add_session_subscriber(self)
end

Instance Method Details

#cleanupObject


36
37
38
# File 'plugins/auto_add_route.rb', line 36

def cleanup
  self.framework.events.remove_session_subscriber(self)
end

#descObject


11
12
13
# File 'plugins/auto_add_route.rb', line 11

def desc
  "Adds routes for any new subnets whenever a session opens"
end

#nameObject


9
# File 'plugins/auto_add_route.rb', line 9

def name; 'auto_add_route'; end

#on_session_open(session) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'plugins/auto_add_route.rb', line 15

def on_session_open(session)
  return if not session.type == 'meterpreter'
  session.load_stdapi
  sb = Rex::Socket::SwitchBoard.instance
  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 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
  }
end