Add ntfy extension

This commit is contained in:
Federico Videla
2023-09-22 10:40:14 -03:00
parent a154c1dbc1
commit a7862fa524
3 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
require 'net/http'
require 'uri'
module BeEF
module Extension
module Notifications
module Channels
class Ntfy
# Constructor
def initialize(message)
@config = BeEF::Core::Configuration.instance
# Endpoint URL
uri = URI.parse(@config.get('beef.extension.notifications.ntfy.endpoint_url'))
# Create client
http = Net::HTTP.new(uri.host, uri.port)
# Create Request
req = Net::HTTP::Post.new(uri.path)
# Add authentication if configured
if @config.get('beef.extension.notifications.ntfy.username') || @config.get('beef.extension.notifications.ntfy.password')
req.basic_auth @config.get('beef.extension.notifications.ntfy.username'), @config.get('beef.extension.notifications.ntfy.password')
end
# Set headers and body
req.content_type = 'text/plain'
req['Title'] = 'BeEF Notification'
req.body = message
# Use SSL if the URI scheme is 'https'
http.use_ssl = (uri.scheme == 'https')
# Send request
http.request(req)
end
end
end
end
end
end

View File

@@ -26,3 +26,9 @@ beef:
webhook_url: "your_webhook_url"
channel: "#beef" # Slack channel
username: "notifier" # Username can be anything
ntfy:
enable: false
endpoint_url: "https://ntfy.sh/beef"
username: "" # Leave blank if not needed
password: "" # Leave blank if not needed

View File

@@ -7,6 +7,8 @@
require 'extensions/notifications/channels/email'
require 'extensions/notifications/channels/pushover'
require 'extensions/notifications/channels/slack_workspace'
require 'extensions/notifications/channels/ntfy'
module BeEF
module Extension
@@ -34,6 +36,9 @@ module BeEF
BeEF::Extension::Notifications::Channels::Pushover.new(message) if @config.get('beef.extension.notifications.pushover.enable') == true
BeEF::Extension::Notifications::Channels::SlackWorkspace.new(message) if @config.get('beef.extension.notifications.slack.enable') == true
BeEF::Extension::Notifications::Channels::Ntfy.new(message) if @config.get('beef.extension.notifications.ntfy.enable') == true
end
end
end