module BeEF
module Core
class Logger
include Singleton
def initialize
@logs = BeEF::Core::Models::Log
@config = BeEF::Core::Configuration.instance
notifications_enabled = @config.get('beef.extension.notifications.enable')
@notifications = BeEF::Extension::Notifications::Notifications unless notifications_enabled == false or notifications_enabled.nil?
end
def register(from, event, hb = 0)
hb = hb.to_i
time_now = Time.now
raise TypeError, "'from' is #{from.class}; expected String" unless from.is_a?(String)
raise TypeError, "'event' is #{event.class}; expected String" unless event.is_a?(String)
raise TypeError, "'hb' hooked browser ID is #{hb.class}; expected Integer" unless hb.is_a?(Integer)
@logs.create(logtype: from.to_s, event: event.to_s, date: time_now, hooked_browser_id: hb).save!
print_debug "Event: #{event}"
@notifications.new(from, event, time_now, hb) if @notifications
true
end
@logs
end
end
end