Module: Msf::DBManager::Route

Included in:
Msf::DBManager
Defined in:
lib/msf/core/db_manager/route.rb

Instance Method Summary collapse

Instance Method Details

#report_session_route(opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/msf/core/db_manager/route.rb', line 4

def report_session_route(opts)
  return if not active
  session = opts[:session]
  route = opts[:route]
  if session.respond_to? :db_record
    s = session.db_record
  elsif session.is_a?(Hash) && session.key?(:id)
    s = Mdm::Session.find(session[:id])
  else
    s = session
  end
  unless s.respond_to?(:routes)
    raise ArgumentError.new("Invalid :session, expected Session object got #{session.class}")
  end

::ApplicationRecord.connection_pool.with_connection {

  subnet, netmask = route.split("/")
  s.routes.create(:subnet => subnet, :netmask => netmask)
}
end

#report_session_route_remove(opts) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/msf/core/db_manager/route.rb', line 26

def report_session_route_remove(opts)
  return if not active
  session = opts[:session]
  route = opts[:route]
  if session.respond_to? :db_record
    s = session.db_record
  elsif session.is_a?(Hash) && session.key?(:id)
    s = Mdm::Session.find(session[:id])
  else
    s = session
  end
  unless s.respond_to?(:routes)
    raise ArgumentError.new("Invalid :session, expected Session object got #{session.class}")
  end

::ApplicationRecord.connection_pool.with_connection {
  subnet, netmask = route.split("/")
  r = s.routes.find_by_subnet_and_netmask(subnet, netmask)
  r.destroy if r
}
end