Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/console/banners.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
module BeEF
7
module Core
8
module Console
9
module Banners
10
class << self
11
attr_accessor :interfaces
12
13
#
14
# Prints BeEF's ascii art
15
#
16
def print_ascii_art
17
if File.exist?('core/main/console/beef.ascii')
18
File.open('core/main/console/beef.ascii', 'r') do |f|
19
while line = f.gets
20
puts line
21
end
22
end
23
end
24
end
25
26
#
27
# Prints BeEF's welcome message
28
#
29
def print_welcome_msg
30
config = BeEF::Core::Configuration.instance
31
version = config.get('beef.version')
32
print_info "Browser Exploitation Framework (BeEF) #{version}"
33
data = "Twit: @beefproject\n"
34
data += "Site: https://beefproject.com\n"
35
# data += "Blog: http://blog.beefproject.com\n"
36
data += "Wiki: https://github.com/beefproject/beef/wiki\n"
37
print_more data
38
print_info 'Project Creator: ' + 'Wade Alcorn'.red + ' (@WadeAlcorn)'
39
end
40
41
#
42
# Prints the number of network interfaces beef is operating on.
43
# Looks like that:
44
#
45
# [14:06:48][*] 5 network interfaces were detected.
46
#
47
def print_network_interfaces_count
48
# get the configuration information
49
configuration = BeEF::Core::Configuration.instance
50
# local host
51
beef_host = configuration.local_host
52
53
# create an array of the interfaces the framework is listening on
54
if beef_host == '0.0.0.0' # the framework will listen on all interfaces
55
interfaces = Socket.ip_address_list.map { |x| x.ip_address if x.ipv4? }
56
interfaces.delete_if { |x| x.nil? } # remove if the entry is nill
57
else # the framework will listen on only one interface
58
interfaces = [beef_host]
59
end
60
61
self.interfaces = interfaces
62
63
# output the banner to the console
64
print_info "#{interfaces.count} network interfaces were detected."
65
end
66
67
#
68
# Prints the route to the network interfaces beef has been deployed on.
69
# Looks like that:
70
#
71
# [14:06:48][+] running on network interface: 192.168.255.1
72
# [14:06:48] | Hook URL: http://192.168.255.1:3000/hook.js
73
# [14:06:48] | UI URL: http://192.168.255.1:3000/ui/panel
74
# [14:06:48][+] running on network interface: 127.0.0.1
75
# [14:06:48] | Hook URL: http://127.0.0.1:3000/hook.js
76
# [14:06:48] | UI URL: http://127.0.0.1:3000/ui/panel
77
#
78
def print_network_interfaces_routes
79
configuration = BeEF::Core::Configuration.instance
80
# local config settings
81
proto = configuration.local_proto
82
hook_file = configuration.hook_file_path
83
admin_ui = configuration.get('beef.extension.admin_ui.enable') ? true : false
84
admin_ui_path = configuration.get('beef.extension.admin_ui.base_path')
85
86
# display the hook URL and Admin UI URL on each interface from the interfaces array
87
interfaces.map do |host|
88
print_info "running on network interface: #{host}"
89
port = configuration.local_port
90
data = "Hook URL: #{proto}://#{host}:#{port}#{hook_file}\n"
91
data += "UI URL: #{proto}://#{host}:#{port}#{admin_ui_path}/panel\n" if admin_ui
92
print_more data
93
end
94
95
# display the public hook URL and Admin UI URL
96
if configuration.public_enabled?
97
print_info 'Public:'
98
data = "Hook URL: #{configuration.hook_url}\n"
99
data += "UI URL: #{configuration.beef_url_str}#{admin_ui_path}/panel\n" if admin_ui
100
print_more data
101
end
102
end
103
104
#
105
# Print loaded extensions
106
#
107
def print_loaded_extensions
108
extensions = BeEF::Extensions.get_loaded
109
print_info "#{extensions.size} extensions enabled:"
110
output = ''
111
112
extensions.each do |_key, ext|
113
output << "#{ext['name']}\n"
114
end
115
116
print_more output
117
end
118
119
#
120
# Print loaded modules
121
#
122
def print_loaded_modules
123
print_info "#{BeEF::Modules.get_enabled.count} modules enabled."
124
end
125
126
#
127
# Print WebSocket servers
128
#
129
def print_websocket_servers
130
config = BeEF::Core::Configuration.instance
131
ws_poll_timeout = config.get('beef.http.websocket.ws_poll_timeout')
132
print_info "Starting WebSocket server ws://#{config.beef_host}:#{config.get('beef.http.websocket.port').to_i} [timer: #{ws_poll_timeout}]"
133
if config.get('beef.http.websocket.secure')
134
print_info "Starting WebSocketSecure server on wss://[#{config.beef_host}:#{config.get('beef.http.websocket.secure_port').to_i} [timer: #{ws_poll_timeout}]"
135
end
136
end
137
138
# Print WebSocket servers
139
#
140
def print_http_proxy
141
config = BeEF::Core::Configuration.instance
142
print_info "HTTP Proxy: http://#{config.get('beef.extension.proxy.address')}:#{config.get('beef.extension.proxy.port')}"
143
end
144
145
def print_dns
146
address = nil
147
port = nil
148
protocol = nil
149
150
# TODO: fix the following reference - extensions/dns/api.rb
151
# servers, interfaces, address, port, protocol, upstream_servers = get_dns_config # get the DNS configuration
152
153
# Print the DNS server information
154
unless address.nil? || port.nil? || protocol.nil?
155
print_info "DNS Server: #{address}:#{port} (#{protocol})"
156
print_more upstream_servers unless upstream_servers.empty?
157
end
158
end
159
160
end
161
end
162
end
163
end
164
end
165
166