Add ntfy extension
This commit is contained in:
44
extensions/notifications/channels/ntfy.rb
Normal file
44
extensions/notifications/channels/ntfy.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user