Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/console/commandline.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
#
10
# This module parses the command line argument when running beef.
11
#
12
module CommandLine
13
@options = {}
14
@options[:verbose] = false
15
@options[:resetdb] = false
16
@options[:ascii_art] = false
17
@options[:ext_config] = ''
18
@options[:port] = ''
19
@options[:ws_port] = ''
20
@options[:interactive] = false
21
@options[:update_disabled] = false
22
@options[:update_auto] = false
23
24
@already_parsed = false
25
26
#
27
# Parses the command line arguments of the console.
28
# It also populates the 'options' hash.
29
#
30
def self.parse
31
return @options if @already_parsed
32
33
optparse = OptionParser.new do |opts|
34
opts.on('-x', '--reset', 'Reset the database') do
35
@options[:resetdb] = true
36
end
37
38
opts.on('-v', '--verbose', 'Display debug information') do
39
@options[:verbose] = true
40
end
41
42
opts.on('-a', '--ascii_art', 'Prints BeEF ascii art') do
43
@options[:ascii_art] = true
44
end
45
46
opts.on('-c', '--config FILE', "Load a different configuration file: if it's called custom-config.yaml, git automatically ignores it.") do |f|
47
@options[:ext_config] = f
48
end
49
50
opts.on('-p', '--port PORT', 'Change the default BeEF listening port') do |p|
51
@options[:port] = p
52
end
53
54
opts.on('-w', '--wsport WS_PORT', 'Change the default BeEF WebSocket listening port') do |ws_port|
55
@options[:ws_port] = ws_port
56
end
57
58
opts.on('-ud', '--update_disabled', 'Skips update') do
59
@options[:update_disabled] = true
60
end
61
62
opts.on('-ua', '--update_auto', 'Automatic update with no prompt') do
63
@options[:update_auto] = true
64
end
65
66
# opts.on('-i', '--interactive', 'Starts with the Console Shell activated') do
67
# @options[:interactive] = true
68
# end
69
end
70
71
optparse.parse!
72
@already_parsed = true
73
@options
74
rescue OptionParser::InvalidOption
75
puts 'Invalid command line option provided. Please run beef --help'
76
exit 1
77
end
78
end
79
end
80
end
81
end
82
83