Skip to content
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

[WIP] Fixing CLI-handling #2747

Closed
wants to merge 1 commit into from
Closed

[WIP] Fixing CLI-handling #2747

wants to merge 1 commit into from

Conversation

nzqo
Copy link
Contributor

@nzqo nzqo commented Mar 8, 2023

(Starting with) fixing beef cli option handling. Fixes #2174
Note that this is WIP, I'm opening this to get some feedback on how this should be handled exactly.

Category

Core Functionality

Feature/Issue Description

Q: Please give a brief summary of your feature/fix
A: Beef options were not part of the --help before and not clearly communicated.

Q: Give a technical rundown of what you have changed (if applicable)
A: The problem seems to pertain to Sinatra. Since some extensions use Sinatra, it is required from loader.rb (by requiring the bundle defaults). From then on, Sinatra basically hogs the command line parsing, parsing --helpand then exiting. A few key issues:

  • I couldn't find much on how to best solve this. It seems Sinatra provides little options here. The only approach I could think of so far was to basically parse before Sinatra and then "hand over".
  • Inevitably, this means we can't catch invalid options. We could hard-code Sinatra options to check, but if they ever change this would break.
  • Collisions are also hard to detect. I am guessing that for the port option, it is even desired to share. For others, it might not be?
  • I'm still not sure whether this actually works, i.e. whether Sinatra is properly parsing the remaining options. I tried to stipulate an error by passing garbage, but it didn't work. They are either not checking the argument content on parsing or I am still missing something.

Result

With these changes, we would at least see all the command line options being printed when running ./beef --help, i.e.

Usage: beef [options]
    -x, --reset                      Reset the database
    -v, --verbose                    Display debug information
    -a, --ascii-art                  Prints BeEF ascii art
    -c, --config FILE                Specify configuration file to load (instead of ./config.yaml)
    -p, --port PORT                  Change the default BeEF listening port
    -w, --wsport WS_PORT             Change the default BeEF WebSocket listening port
        --update-disable             Skips update
        --update-auto                Automatic update with no prompt
    -h, --help                       Prints this help

Sinatra webapp options:
Usage: beef [options]
    -p port                          set the port (default is 4567)
    -s server                        specify rack server/handler
    -q                               turn on quiet mode (default is off)
    -x                               turn on the mutex lock (default is off)
    -e env                           set the environment (default is development)
    -o addr                          set the host (default is (env == 'development' ? 'localhost' : '0.0.0.0'))

If anyone has a better idea on handling this, I'd be happy to hear and improve this. I hope I didn't miss anything too obvious :)

@nzqo nzqo had a problem deploying to Integrate Pull Request March 8, 2023 13:34 — with GitHub Actions Failure
@nzqo nzqo closed this by deleting the head repository Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update ./beef launch flags in wiki and --help menu
1 participant