Skip to content

Commit 6ea6e8d

Browse files
author
Stephen
committed
Merge branch 'bump-gems' into dependabot/bundler/rack-2.2.9
2 parents eb9011e + 473e4c1 commit 6ea6e8d

31 files changed

+560
-228
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050
# DNS extension
5151
group :ext_dns do
5252
gem 'async-dns', '~> 1.3'
53-
gem 'async', '~> 1.31'
53+
gem 'async', '~> 1.32'
5454
end
5555

5656
# QRcode extension

Gemfile.lock

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GEM
2323
archive-zip (0.12.0)
2424
io-like (~> 0.3.0)
2525
ast (2.4.2)
26-
async (1.31.0)
26+
async (1.32.0)
2727
console (~> 1.10)
2828
nio4r (~> 2.3)
2929
timers (~> 4.1)
@@ -47,9 +47,10 @@ GEM
4747
coderay (1.1.3)
4848
concurrent-ruby (1.2.2)
4949
connection_pool (2.4.1)
50-
console (1.23.3)
50+
console (1.23.6)
5151
fiber-annotation
5252
fiber-local
53+
json
5354
curb (1.0.5)
5455
daemons (1.4.1)
5556
diff-lcs (1.5.1)
@@ -101,10 +102,10 @@ GEM
101102
mutex_m (0.2.0)
102103
net-protocol (0.2.2)
103104
timeout
104-
net-smtp (0.4.0.1)
105+
net-smtp (0.5.0)
105106
net-protocol
106107
netrc (0.11.0)
107-
nio4r (2.7.0)
108+
nio4r (2.7.1)
108109
nokogiri (1.16.2-arm64-darwin)
109110
racc (~> 1.4)
110111
nokogiri (1.16.2-x86_64-linux)
@@ -139,7 +140,7 @@ GEM
139140
rack (>= 1.3)
140141
rainbow (3.1.1)
141142
rake (13.1.0)
142-
rdoc (6.6.2)
143+
rdoc (6.6.3.1)
143144
psych (>= 4.0.0)
144145
regexp_parser (2.9.0)
145146
reline (0.4.3)
@@ -249,7 +250,7 @@ PLATFORMS
249250

250251
DEPENDENCIES
251252
ansi (~> 1.5)
252-
async (~> 1.31)
253+
async (~> 1.32)
253254
async-dns (~> 1.3)
254255
browserstack-local (~> 1.4)
255256
capybara (~> 3.40)

beef

+2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ BeEF::Core::Console::Banners.print_loaded_extensions
243243
BeEF::Core::Console::Banners.print_loaded_modules
244244
BeEF::Core::Console::Banners.print_network_interfaces_count
245245
BeEF::Core::Console::Banners.print_network_interfaces_routes
246+
BeEF::Core::Console::Banners.print_http_proxy
247+
BeEF::Core::Console::Banners.print_dns
246248

247249
#
248250
# @note Prints the API key needed to use the RESTful API

core/main/configuration.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def initialize(config)
2626
begin
2727
# open base config
2828
@config = load(config)
29-
# set default value if key? does not exist
3029
@config.default = nil
3130
@@config = config
3231
rescue StandardError => e
@@ -156,7 +155,7 @@ def beef_url_str
156155
"#{beef_proto}://#{beef_host}:#{beef_port}"
157156
end
158157

159-
# Returns the hool path value stored in the config file
158+
# Returns the hook path value stored in the config file
160159
#
161160
# @return [String] hook file path
162161
def hook_file_path

core/main/console/banners.rb

+23
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,29 @@ def print_websocket_servers
134134
print_info "Starting WebSocketSecure server on wss://[#{config.beef_host}:#{config.get('beef.http.websocket.secure_port').to_i} [timer: #{ws_poll_timeout}]"
135135
end
136136
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+
137160
end
138161
end
139162
end

extensions/dns/api.rb

+17-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,23 @@ module NameserverHandler
2424
#
2525
# @param http_hook_server [BeEF::Core::Server] HTTP server instance
2626
def self.pre_http_start(_http_hook_server)
27-
dns_config = BeEF::Core::Configuration.instance.get('beef.extension.dns')
27+
servers, interfaces, address, port, protocol, upstream_servers = get_dns_config # get the DNS configuration
28+
29+
# Start the DNS server
2830
dns = BeEF::Extension::Dns::Server.instance
31+
dns.run(upstream: servers, listen: interfaces)
32+
end
33+
34+
def self.print_dns_info
35+
servers, interfaces, address, port, protocol, upstream_servers = get_dns_config # get the DNS configuration
36+
37+
# Print the DNS server information
38+
print_info "DNS Server: #{address}:#{port} (#{protocol})"
39+
print_more upstream_servers unless upstream_servers.empty?
40+
end
41+
42+
def self.get_dns_config
43+
dns_config = BeEF::Core::Configuration.instance.get('beef.extension.dns')
2944

3045
protocol = begin
3146
dns_config['protocol'].to_sym
@@ -52,10 +67,7 @@ def self.pre_http_start(_http_hook_server)
5267
end
5368
end
5469

55-
dns.run(upstream: servers, listen: interfaces)
56-
57-
print_info "DNS Server: #{address}:#{port} (#{protocol})"
58-
print_more upstream_servers unless upstream_servers.empty?
70+
return servers, interfaces, address, port, protocol, upstream_servers
5971
end
6072

6173
# Mounts the handler for processing DNS RESTful API requests.

extensions/dns/dns.rb

+12
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class Server < Async::DNS::Server
1515

1616
def initialize
1717
super()
18+
logger.level = Logger::ERROR
1819
@lock = Mutex.new
1920
@database = BeEF::Core::Models::Dns::Rule
2021
@data_chunks = {}
22+
@server_started = false
2123
end
2224

2325
# Adds a new DNS rule. If the rule already exists, its current ID is returned.
@@ -118,6 +120,7 @@ def run(options = {})
118120
@lock.synchronize do
119121
Thread.new do
120122
EventMachine.next_tick do
123+
next if @server_started # Check if the server was already started
121124
upstream = options[:upstream] || nil
122125

123126
listen = options[:listen] || nil
@@ -132,6 +135,7 @@ def run(options = {})
132135
begin
133136
# super(:listen => listen)
134137
Thread.new { super() }
138+
@server_started = true # Set the server started flag
135139
rescue RuntimeError => e
136140
if e.message =~ /no datagram socket/ || e.message =~ /no acceptor/ # the port is in use
137141
print_error "[DNS] Another process is already listening on port #{options[:listen]}"
@@ -146,6 +150,14 @@ def run(options = {})
146150
end
147151
end
148152

153+
def stop
154+
return unless @server_started # Check if the server was started
155+
156+
# Logic to stop the Async::DNS server
157+
puts EventMachine.stop if EventMachine.reactor_running?
158+
@server_started = false # Reset the server started flag
159+
end
160+
149161
# Entry point for processing incoming DNS requests. Attempts to find a matching rule and
150162
# sends back its associated response.
151163
#

extensions/proxy/api.rb

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def self.pre_http_start(http_hook_server)
1818
BeEF::Extension::Proxy::Proxy.new
1919
end
2020
end
21-
print_info "HTTP Proxy: http://#{config.get('beef.extension.proxy.address')}:#{config.get('beef.extension.proxy.port')}"
2221
end
2322

2423
def self.mount_handler(beef_server)

extensions/qrcode/qrcode.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ def self.pre_http_start(_http_hook_server)
3232
# Retrieve the list of network interfaces from BeEF::Core::Console::Banners
3333
interfaces = BeEF::Core::Console::Banners.interfaces
3434

35-
# Check if the interfaces variable is nil, indicating that network interfaces are not available
36-
if interfaces.nil?
37-
print_error "[QR] Error: Network interfaces information is unavailable."
38-
print_error "[QR] Error: This will be acceptable during testing."
39-
else
35+
if not interfaces.nil? and not interfaces.empty? # If interfaces are available, iterate over each network interface
4036
# If interfaces are available, iterate over each network interface
4137
interfaces.each do |int|
4238
# Skip the loop iteration if the interface address is '0.0.0.0' (which generally represents all IPv4 addresses on the local machine)

0 commit comments

Comments
 (0)