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(session, route) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/msf/core/db_manager/route.rb', line 2

def report_session_route(session, route)
  return if not active
  if session.respond_to? :db_record
    s = session.db_record
  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(session, route) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/msf/core/db_manager/route.rb', line 20

def report_session_route_remove(session, route)
  return if not active
  if session.respond_to? :db_record
    s = session.db_record
  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