Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/plugins/db_tracker.rb
Views: 11705
module Msf1###2#3# This class hooks all socket calls and updates the database with4# data gathered from the connection parameters5#6###78class Plugin::DB_Tracer < Msf::Plugin910###11#12# This class implements a socket communication tracker13#14###15class DBTracerEventHandler16include Rex::Socket::Comm::Events1718def on_before_socket_create(comm, param); end1920def on_socket_created(_comm, sock, param)21# Ignore local listening sockets22return if !sock.peerhost2324if ((sock.peerhost != '0.0.0.0') && sock.peerport)2526# Ignore sockets that didn't set up their context27# to hold the framework in 'Msf'28return if !param.context['Msf']2930host = param.context['Msf'].db.find_or_create_host(host: sock.peerhost, state: Msf::HostState::Alive)31return if !host3233param.context['Msf'].db.report_service(host: host, proto: param.proto, port: sock.peerport)34end35end36end3738def initialize(framework, opts)39super4041if !framework.db.active42raise PluginLoadError, 'The database backend has not been initialized'43end4445framework.plugins.each do |plugin|46if plugin.instance_of?(Msf::Plugin::DB_Tracer)47raise PluginLoadError, 'This plugin should not be loaded more than once'48end49end5051@eh = DBTracerEventHandler.new52Rex::Socket::Comm::Local.register_event_handler(@eh)53end5455def cleanup56Rex::Socket::Comm::Local.deregister_event_handler(@eh)57end5859def name60'db_tracker'61end6263def desc64'Monitors socket calls and updates the database backend'65end6667end68end697071