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

Fix broken hosts and services help command #18813

Conversation

adfoster-r7
Copy link
Contributor

@adfoster-r7 adfoster-r7 commented Feb 9, 2024

Fix the broken help hosts and help services command

Verification

These commands should not crash

help hosts
hosts -h
help services
services -h

Before

msf6 auxiliary(scanner/mssql/mssql_login) > help services
[-] Error while running command help: wrong number of arguments (given 0, expected 1)
msf6 auxiliary(scanner/mssql/mssql_login) > help hosts
[-] Error while running command help: wrong number of arguments (given 0, expected 1)

After

msf6 auxiliary(scanner/mssql/mssql_login) > help services
Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]


OPTIONS:

    -a, --add                  Add the services instead of searching.
    -c, --column <col1,col2>   Only show the given columns.
    -d, --delete               Delete the services instead of searching.
    -h, --help                 Show this help information.
    -O, --order <column id>    Order rows by specified column number.
    -o, --output <filename>    Send output to a file in csv format.
    -p, --port <ports>         Search for a list of ports.
    -r, --protocol <protocol>  Protocol type of the service being added [tcp|udp].
    -R, --rhosts               Set RHOSTS from the results of the search.
    -s, --name <name>          Name of the service to add.
    -S, --search <filter>      Search string to filter by.
    -u, --up                   Only show services which are up.
    -U, --update               Update data for existing service.

Available columns: created_at, info, name, port, proto, state, updated_at
msf6 auxiliary(scanner/mssql/mssql_login) > help hosts
Usage: hosts [ options ] [addr1 addr2 ...]


OPTIONS:

    -a, --add <host>                       Add the hosts instead of searching
    -c, --columns <columns>                Only show the given columns (see list below)
    -C, --columns-until-restart <columns>  Only show the given columns until the next restart (see list below)
    -d, --delete <hosts>                   Delete the hosts instead of searching
    -h, --help                             Show this help information
    -i, --info <info>                      Change the info of a host
    -m, --comment <comment>                Change the comment of a host
    -n, --name <name>                      Change the name of a host
    -O, --order <column id>                Order rows by specified column number
    -o, --output <filename>                Send output to a file in csv format
    -R, --rhosts                           Set RHOSTS from the results of the search
    -S, --search <filter>                  Search string to filter by
    -T, --delete-tag <tag>                 Remove a tag from a range of hosts
    -t, --tag <tag>                        Add or specify a tag to a range of hosts
    -u, --up                               Only show hosts which are up

Available columns: address, arch, comm, comments, created_at, cred_count, detected_arch, exploit_attempt_count, host_detail_count, info, mac, name, note_count, os_family, os_flavor, os_lang, os_name, os_sp, purpose, scope, service_count, state, updated_at, virtual_host, vuln_count, tags

@sjanusz-r7
Copy link
Contributor

Before

msf6 auxiliary(admin/postgres/postgres_readfile) > help hosts
[-] Error while running command help: wrong number of arguments (given 0, expected 1)

Call stack:
/Users/sjanusz/Programming/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:426:in `cmd_hosts_help'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:184:in `block in cmd_help'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:176:in `each'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:176:in `cmd_help'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in `run_command'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in `block in run_single'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:165:in `block in run'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:309:in `block in with_history_manager_context'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell/history_manager.rb:33:in `with_context'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:306:in `with_history_manager_context'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:133:in `run'
/Users/sjanusz/Programming/metasploit-framework/lib/metasploit/framework/command/console.rb:54:in `start'
/Users/sjanusz/Programming/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:23:in `<main>'
msf6 auxiliary(admin/postgres/postgres_readfile) > help services
[-] Error while running command help: wrong number of arguments (given 0, expected 1)

Call stack:
/Users/sjanusz/Programming/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:701:in `cmd_services_help'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:184:in `block in cmd_help'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:176:in `each'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:176:in `cmd_help'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in `run_command'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in `block in run_single'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:165:in `block in run'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:309:in `block in with_history_manager_context'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell/history_manager.rb:33:in `with_context'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:306:in `with_history_manager_context'
/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell.rb:133:in `run'
/Users/sjanusz/Programming/metasploit-framework/lib/metasploit/framework/command/console.rb:54:in `start'
/Users/sjanusz/Programming/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:23:in `<main>'
msf6 auxiliary(admin/postgres/postgres_readfile) > hosts -h
Usage: hosts [ options ] [addr1 addr2 ...]


OPTIONS:

    -a, --add <host>                       Add the hosts instead of searching
    -c, --columns <columns>                Only show the given columns (see list below)
    -C, --columns-until-restart <columns>  Only show the given columns until the next restart (see list below)
    -d, --delete <hosts>                   Delete the hosts instead of searching
    -h, --help                             Show this help information
    -i, --info <info>                      Change the info of a host
    -m, --comment <comment>                Change the comment of a host
    -n, --name <name>                      Change the name of a host
    -O, --order <column id>                Order rows by specified column number
    -o, --output <filename>                Send output to a file in csv format
    -R, --rhosts                           Set RHOSTS from the results of the search
    -S, --search <filter>                  Search string to filter by
    -T, --delete-tag <tag>                 Remove a tag from a range of hosts
    -t, --tag <tag>                        Add or specify a tag to a range of hosts
    -u, --up                               Only show hosts which are up

Available columns: address, arch, comm, comments, created_at, cred_count, detected_arch, exploit_attempt_count, host_detail_count, info, mac, name, note_count, os_family, os_flavor, os_lang, os_name, os_sp, purpose, scope, service_count, state, updated_at, virtual_host, vuln_count, tags

msf6 auxiliary(admin/postgres/postgres_readfile) > services -h
Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]


OPTIONS:

    -a, --add                  Add the services instead of searching.
    -c, --column <col1,col2>   Only show the given columns.
    -d, --delete               Delete the services instead of searching.
    -h, --help                 Show this help information.
    -O, --order <column id>    Order rows by specified column number.
    -o, --output <filename>    Send output to a file in csv format.
    -p, --port <ports>         Search for a list of ports.
    -r, --protocol <protocol>  Protocol type of the service being added [tcp|udp].
    -R, --rhosts               Set RHOSTS from the results of the search.
    -s, --name <name>          Name of the service to add.
    -S, --search <filter>      Search string to filter by.
    -u, --up                   Only show services which are up.
    -U, --update               Update data for existing service.

Available columns: created_at, info, name, port, proto, state, updated_at

After

msf6 auxiliary(admin/postgres/postgres_readfile) > help hosts
Usage: hosts [ options ] [addr1 addr2 ...]


OPTIONS:

    -a, --add <host>                       Add the hosts instead of searching
    -c, --columns <columns>                Only show the given columns (see list below)
    -C, --columns-until-restart <columns>  Only show the given columns until the next restart (see list below)
    -d, --delete <hosts>                   Delete the hosts instead of searching
    -h, --help                             Show this help information
    -i, --info <info>                      Change the info of a host
    -m, --comment <comment>                Change the comment of a host
    -n, --name <name>                      Change the name of a host
    -O, --order <column id>                Order rows by specified column number
    -o, --output <filename>                Send output to a file in csv format
    -R, --rhosts                           Set RHOSTS from the results of the search
    -S, --search <filter>                  Search string to filter by
    -T, --delete-tag <tag>                 Remove a tag from a range of hosts
    -t, --tag <tag>                        Add or specify a tag to a range of hosts
    -u, --up                               Only show hosts which are up

Available columns: address, arch, comm, comments, created_at, cred_count, detected_arch, exploit_attempt_count, host_detail_count, info, mac, name, note_count, os_family, os_flavor, os_lang, os_name, os_sp, purpose, scope, service_count, state, updated_at, virtual_host, vuln_count, tags

msf6 auxiliary(admin/postgres/postgres_readfile) > help services
Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]


OPTIONS:

    -a, --add                  Add the services instead of searching.
    -c, --column <col1,col2>   Only show the given columns.
    -d, --delete               Delete the services instead of searching.
    -h, --help                 Show this help information.
    -O, --order <column id>    Order rows by specified column number.
    -o, --output <filename>    Send output to a file in csv format.
    -p, --port <ports>         Search for a list of ports.
    -r, --protocol <protocol>  Protocol type of the service being added [tcp|udp].
    -R, --rhosts               Set RHOSTS from the results of the search.
    -s, --name <name>          Name of the service to add.
    -S, --search <filter>      Search string to filter by.
    -u, --up                   Only show services which are up.
    -U, --update               Update data for existing service.

Available columns: created_at, info, name, port, proto, state, updated_at

msf6 auxiliary(admin/postgres/postgres_readfile) > hosts -h
Usage: hosts [ options ] [addr1 addr2 ...]


OPTIONS:

    -a, --add <host>                       Add the hosts instead of searching
    -c, --columns <columns>                Only show the given columns (see list below)
    -C, --columns-until-restart <columns>  Only show the given columns until the next restart (see list below)
    -d, --delete <hosts>                   Delete the hosts instead of searching
    -h, --help                             Show this help information
    -i, --info <info>                      Change the info of a host
    -m, --comment <comment>                Change the comment of a host
    -n, --name <name>                      Change the name of a host
    -O, --order <column id>                Order rows by specified column number
    -o, --output <filename>                Send output to a file in csv format
    -R, --rhosts                           Set RHOSTS from the results of the search
    -S, --search <filter>                  Search string to filter by
    -T, --delete-tag <tag>                 Remove a tag from a range of hosts
    -t, --tag <tag>                        Add or specify a tag to a range of hosts
    -u, --up                               Only show hosts which are up

Available columns: address, arch, comm, comments, created_at, cred_count, detected_arch, exploit_attempt_count, host_detail_count, info, mac, name, note_count, os_family, os_flavor, os_lang, os_name, os_sp, purpose, scope, service_count, state, updated_at, virtual_host, vuln_count, tags

msf6 auxiliary(admin/postgres/postgres_readfile) > services -h
Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]


OPTIONS:

    -a, --add                  Add the services instead of searching.
    -c, --column <col1,col2>   Only show the given columns.
    -d, --delete               Delete the services instead of searching.
    -h, --help                 Show this help information.
    -O, --order <column id>    Order rows by specified column number.
    -o, --output <filename>    Send output to a file in csv format.
    -p, --port <ports>         Search for a list of ports.
    -r, --protocol <protocol>  Protocol type of the service being added [tcp|udp].
    -R, --rhosts               Set RHOSTS from the results of the search.
    -s, --name <name>          Name of the service to add.
    -S, --search <filter>      Search string to filter by.
    -u, --up                   Only show services which are up.
    -U, --update               Update data for existing service.

Available columns: created_at, info, name, port, proto, state, updated_at

LGTM 👍

@adfoster-r7 adfoster-r7 merged commit 3cf3d09 into rapid7:master Feb 12, 2024
35 checks passed
@adfoster-r7 adfoster-r7 deleted the fix-broken-hosts-and-services-help-command branch February 12, 2024 11:50
@adfoster-r7
Copy link
Contributor Author

Release Notes

Fixes a crash when running the help services or help hosts commands

@adfoster-r7 adfoster-r7 added the rn-fix release notes fix label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn-fix release notes fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants