metasploit-framework
metasploit-framework copied to clipboard
hosts command doesn't expand `~` correctly
When using the -o option to the hosts command, passing a directory of ~/testing/hosts.csv failed with the following error:
msf5 > hosts -c address,os_family,os_name -O 1 -o ~/testing/hosts.csv
[*] Wrote hosts to ~/testing/hosts.csv
[-] Error while running command hosts: No such file or directory @ rb_sysopen - ~/testing/hosts.csv
Call stack:
/usr/share/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:580:in `initialize'
/usr/share/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:580:in `open'
/usr/share/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:580:in `cmd_hosts'
/usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/usr/share/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/usr/share/metasploit-framework/lib/rex/ui/text/shell.rb:158:in `run'
/usr/share/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
/usr/bin/msfconsole:23:in `<main>'
Changing the output directory to /root/testing/hosts.csv worked.
I wouldn't normally care, but immediately prior to this I had dumped the services out using a similar command, and it had worked, so it was weird that one command resolved ~ correctly and one didn't:
msf5 > services -c name,port,info -O 1 -o ~/testing/services.csv
[*] Wrote services to /root/testing/services.csv
Many commands are like this, unfortunately. See #13948.
@adfoster-r7 just a heads up since you closed some recent related issues that this appears to still be an issue on the latest release.
@gwillcox-r7 Thanks! :+1: