Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/notifications/channels/slack_workspace.rb
1154 views
1
#
2
# Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
require 'slack-notifier'
7
8
module BeEF
9
module Extension
10
module Notifications
11
module Channels
12
class SlackWorkspace
13
def initialize(message)
14
@config = BeEF::Core::Configuration.instance
15
16
# Configure the Slack Client
17
webhook_url = @config.get('beef.extension.notifications.slack.webhook_url')
18
channel = @config.get('beef.extension.notifications.slack.channel')
19
username = @config.get('beef.extension.notifications.slack.username')
20
21
if webhook_url.include?('your_webhook_url') || !webhook_url.start_with?('https://hooks.slack.com/services/')
22
print_error('[Notifications] Invalid Slack WebHook URL')
23
return
24
end
25
26
notifier = Slack::Notifier.new(
27
webhook_url,
28
channel: channel,
29
username: username,
30
http_options: { open_timeout: 10 }
31
)
32
33
notifier.ping message
34
35
print_debug("[Notifications] Established Slack notification channel: #{webhook_url}")
36
rescue StandardError => e
37
print_error "[Notifications] Slack notification initialization failed: #{e.message}"
38
end
39
end
40
end
41
end
42
end
43
end
44
45