metasploit-framework
metasploit-framework copied to clipboard
Tagging a range causes exception
Steps to reproduce
- start msfconsole
- hosts -a 10.1.1.0/24
- hosts -R 10.1.1.0/24 -t mytag
Expected behavior
Hosts are supposed to be tagged
Current behavior
Exception thrown with the following output:
[-] Error while running command hosts: opts must include a valid :workspace
Call stack:
<REDACTED>/metasploit-framework/lib/msf/util/db_manager.rb:37:in `process_opts_workspace'
<REDACTED>/metasploit-framework/lib/msf/core/db_manager/host.rb:56:in `add_host_tag'
<REDACTED>/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:136:in `method_missing'
<REDACTED>/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:321:in `block (2 levels) in add_host_tag'
/var/lib/gems/2.5.0/gems/rex-socket-0.1.17/lib/rex/socket/range_walker.rb:276:in `each'
<REDACTED>/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:319:in `block in add_host_tag'
<REDACTED>/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:318:in `each'
<REDACTED>/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:318:in `add_host_tag'
<REDACTED>/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:534:in `cmd_hosts'
<REDACTED>/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
<REDACTED>/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
<REDACTED>/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
<REDACTED>/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
<REDACTED>/metasploit-framework/lib/rex/ui/text/shell.rb:151:in `run'
<REDACTED>/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
<REDACTED>/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
<REDACTED>/metasploit-framework/msfconsole:49:in `<top (required)>'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec'
/usr/lib/ruby/vendor_ruby/thor/command.rb:27:in `run'
/usr/lib/ruby/vendor_ruby/thor/invocation.rb:126:in `invoke_command'
/usr/lib/ruby/vendor_ruby/thor.rb:369:in `dispatch'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch'
/usr/lib/ruby/vendor_ruby/thor/base.rb:444:in `start'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/share/rubygems-integration/all/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
/usr/bin/bundle:23:in `load'
/usr/bin/bundle:23:in `<main>'
System stuff
Metasploit version
apt install: Framework: 5.0.41-dev Console : 5.0.41-dev
source install: c0006258152b63b64bf00815f8a44af18498f567
I installed Metasploit with:
- [x] Kali package via apt
- [ ] Omnibus installer (nightly)
- [ ] Commercial/Community installer (from http://www.rapid7.com/products/metasploit/download.jsp)
- [x] Source install (please specify ruby version)
Ruby version: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
OS
Kali Linux 64 bit
I observe the same behavior as @michaelkruglos when connected with the local data service to postgresql.
msf5 > hosts -R 10.1.1.0/24 -t mytag
[-] Error while running command hosts: opts must include a valid :workspace
Call stack:
/home/msfdev/metasploit-framework/lib/msf/util/db_manager.rb:37:in `process_opts_workspace'
/home/msfdev/metasploit-framework/lib/msf/core/db_manager/host.rb:56:in `add_host_tag'
/home/msfdev/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:136:in `method_missing'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:321:in `block (2 levels) in add_host_tag'
/Users/mkienow/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/rex-socket-0.1.17/lib/rex/socket/range_walker.rb:276:in `each'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:319:in `block in add_host_tag'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:318:in `each'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:318:in `add_host_tag'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:534:in `cmd_hosts'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/home/msfdev/metasploit-framework/lib/rex/ui/text/shell.rb:151:in `run'
/home/msfdev/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/home/msfdev/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:49:in `<main>'
However, when connected to the remote data service, I observe a different issue.
msf5 > hosts -R 10.1.1.0/24 -t mytag
[-] Error while running command hosts: undefined method `add_host_tag' for #<Metasploit::Framework::DataService::RemoteHTTPDataService:0x00007fe889c16d98>
Call stack:
/home/msfdev/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:136:in `method_missing'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:321:in `block (2 levels) in add_host_tag'
/Users/mkienow/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/rex-socket-0.1.17/lib/rex/socket/range_walker.rb:276:in `each'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:319:in `block in add_host_tag'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:318:in `each'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:318:in `add_host_tag'
/home/msfdev/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:534:in `cmd_hosts'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/home/msfdev/metasploit-framework/lib/rex/ui/text/shell.rb:151:in `run'
/home/msfdev/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/home/msfdev/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:49:in `<main>'
The Msf::DBManager::Host#add_host_tag method is not exposed via the HostDataService, RemoteHostDataService, and HostDataProxy, however, 466c97f introduced a call to Msf::Util::DBManager.process_opts_workspace(opts, framework) in add_host_tag in order to process a workspace from opts. This DBManager method is more focused on Mdm::Tag rather than Mdm::Host and was likely deferred during MSF5 (Goliath) development.
@mkienow-r7, do you think it's related to #12232 ?
@mkienow-r7, do you think it's related to #12232 ?
Yes, the same underlying reason.
This seems to still exist albeit with some caveats in that it isn't crashing the same as before:
Testing Output
msf6 > hosts -a 10.1.1.0/24
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.0
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.1
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.2
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.3
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.4
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.5
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.6
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.7
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.8
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.9
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.10
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.11
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.12
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.13
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.14
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.15
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.16
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.17
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.18
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.19
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.20
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.21
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.22
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.23
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.24
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.25
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.26
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.27
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.28
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.29
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.30
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.31
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.32
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.33
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.34
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.35
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.36
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.37
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.38
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.39
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.40
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.41
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.42
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.43
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.44
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.45
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.46
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.47
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.48
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.49
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.50
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.51
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.52
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.53
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.54
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.55
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.56
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.57
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.58
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.59
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.60
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.61
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.62
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.63
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.64
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.65
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.66
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.67
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.68
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.69
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.70
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.71
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.72
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.73
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.74
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.75
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.76
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.77
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.78
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.79
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.80
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.81
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.82
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.83
[*] Time: 2023-01-31 21:57:19 UTC Host: host=10.1.1.84
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.85
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.86
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.87
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.88
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.89
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.90
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.91
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.92
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.93
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.94
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.95
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.96
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.97
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.98
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.99
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.100
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.101
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.102
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.103
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.104
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.105
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.106
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.107
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.108
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.109
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.110
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.111
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.112
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.113
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.114
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.115
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.116
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.117
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.118
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.119
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.120
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.121
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.122
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.123
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.124
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.125
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.126
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.127
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.128
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.129
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.130
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.131
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.132
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.133
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.134
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.135
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.136
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.137
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.138
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.139
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.140
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.141
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.142
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.143
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.144
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.145
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.146
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.147
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.148
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.149
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.150
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.151
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.152
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.153
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.154
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.155
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.156
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.157
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.158
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.159
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.160
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.161
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.162
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.163
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.164
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.165
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.166
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.167
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.168
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.169
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.170
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.171
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.172
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.173
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.174
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.175
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.176
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.177
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.178
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.179
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.180
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.181
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.182
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.183
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.184
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.185
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.186
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.187
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.188
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.189
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.190
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.191
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.192
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.193
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.194
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.195
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.196
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.197
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.198
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.199
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.200
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.201
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.202
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.203
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.204
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.205
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.206
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.207
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.208
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.209
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.210
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.211
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.212
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.213
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.214
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.215
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.216
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.217
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.218
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.219
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.220
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.221
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.222
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.223
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.224
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.225
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.226
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.227
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.228
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.229
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.230
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.231
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.232
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.233
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.234
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.235
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.236
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.237
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.238
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.239
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.240
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.241
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.242
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.243
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.244
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.245
[*] Time: 2023-01-31 21:57:20 UTC Host: host=10.1.1.246
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.247
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.248
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.249
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.250
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.251
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.252
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.253
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.254
[*] Time: 2023-01-31 21:57:21 UTC Host: host=10.1.1.255
msf6 > hosts -R 10.1.1.0-255 -t mytag
msf6 > hosts -c address,tags
Hosts
=====
address tags
------- ----
10.1.1.0 mytag
10.1.1.1
10.1.1.2
10.1.1.3
10.1.1.4
10.1.1.5
10.1.1.6
10.1.1.7
10.1.1.8
10.1.1.9
10.1.1.10
10.1.1.11
10.1.1.12
10.1.1.13
10.1.1.14
10.1.1.15
10.1.1.16
10.1.1.17
10.1.1.18
10.1.1.19
10.1.1.20
10.1.1.21
10.1.1.22
10.1.1.23
10.1.1.24
10.1.1.25
10.1.1.26
10.1.1.27
10.1.1.28
10.1.1.29
10.1.1.30
10.1.1.31
10.1.1.32
10.1.1.33
10.1.1.34
10.1.1.35
10.1.1.36
10.1.1.37
10.1.1.38
10.1.1.39
10.1.1.40
10.1.1.41
10.1.1.42
10.1.1.43
10.1.1.44
10.1.1.45
10.1.1.46
10.1.1.47
10.1.1.48
10.1.1.49
10.1.1.50
10.1.1.51
10.1.1.52
10.1.1.53
10.1.1.54
10.1.1.55
10.1.1.56
10.1.1.57
10.1.1.58
10.1.1.59
10.1.1.60
10.1.1.61
10.1.1.62
10.1.1.63
10.1.1.64
10.1.1.65
10.1.1.66
10.1.1.67
10.1.1.68
10.1.1.69
10.1.1.70
10.1.1.71
10.1.1.72
10.1.1.73
10.1.1.74
10.1.1.75
10.1.1.76
10.1.1.77
10.1.1.78
10.1.1.79
10.1.1.80
10.1.1.81
10.1.1.82
10.1.1.83
10.1.1.84
10.1.1.85
10.1.1.86
10.1.1.87
10.1.1.88
10.1.1.89
10.1.1.90
10.1.1.91
10.1.1.92
10.1.1.93
10.1.1.94
10.1.1.95
10.1.1.96
10.1.1.97
10.1.1.98
10.1.1.99
10.1.1.100
10.1.1.101
10.1.1.102
10.1.1.103
10.1.1.104
10.1.1.105
10.1.1.106
10.1.1.107
10.1.1.108
10.1.1.109
10.1.1.110
10.1.1.111
10.1.1.112
10.1.1.113
10.1.1.114
10.1.1.115
10.1.1.116
10.1.1.117
10.1.1.118
10.1.1.119
10.1.1.120
10.1.1.121
10.1.1.122
10.1.1.123
10.1.1.124
10.1.1.125
10.1.1.126
10.1.1.127
10.1.1.128
10.1.1.129
10.1.1.130
10.1.1.131
10.1.1.132
10.1.1.133
10.1.1.134
10.1.1.135
10.1.1.136
10.1.1.137
10.1.1.138
10.1.1.139
10.1.1.140
10.1.1.141
10.1.1.142
10.1.1.143
10.1.1.144
10.1.1.145
10.1.1.146
10.1.1.147
10.1.1.148
10.1.1.149
10.1.1.150
10.1.1.151
10.1.1.152
10.1.1.153
10.1.1.154
10.1.1.155
10.1.1.156
10.1.1.157
10.1.1.158
10.1.1.159
10.1.1.160
10.1.1.161
10.1.1.162
10.1.1.163
10.1.1.164
10.1.1.165
10.1.1.166
10.1.1.167
10.1.1.168
10.1.1.169
10.1.1.170
10.1.1.171
10.1.1.172
10.1.1.173
10.1.1.174
10.1.1.175
10.1.1.176
10.1.1.177
10.1.1.178
10.1.1.179
10.1.1.180
10.1.1.181
10.1.1.182
10.1.1.183
10.1.1.184
10.1.1.185
10.1.1.186
10.1.1.187
10.1.1.188
10.1.1.189
10.1.1.190
10.1.1.191
10.1.1.192
10.1.1.193
10.1.1.194
10.1.1.195
10.1.1.196
10.1.1.197
10.1.1.198
10.1.1.199
10.1.1.200
10.1.1.201
10.1.1.202
10.1.1.203
10.1.1.204
10.1.1.205
10.1.1.206
10.1.1.207
10.1.1.208
10.1.1.209
10.1.1.210
10.1.1.211
10.1.1.212
10.1.1.213
10.1.1.214
10.1.1.215
10.1.1.216
10.1.1.217
10.1.1.218
10.1.1.219
10.1.1.220
10.1.1.221
10.1.1.222
10.1.1.223
10.1.1.224
10.1.1.225
10.1.1.226
10.1.1.227
10.1.1.228
10.1.1.229
10.1.1.230
10.1.1.231
10.1.1.232
10.1.1.233
10.1.1.234
10.1.1.235
10.1.1.236
10.1.1.237
10.1.1.238
10.1.1.239
10.1.1.240
10.1.1.241
10.1.1.242
10.1.1.243
10.1.1.244
10.1.1.245
10.1.1.246
10.1.1.247
10.1.1.248
10.1.1.249
10.1.1.250
10.1.1.251
10.1.1.252
10.1.1.253
10.1.1.254
10.1.1.255
msf6 >
So looks like the crash doesn't happen but the range isn't tagged still. Instead only the first host is tagged. Additionally there are also some other errors like this one I noticed when trying to delete hosts that's probably worth another issue:
msf6 > hosts -d 10.0.0.0/8
[-] Error while running command hosts: Couldn't find Mdm::Host with 'id'=514
Call stack:
/home/gwillcox/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/activerecord-7.0.4.2/lib/active_record/core.rb:284:in `find'
/home/gwillcox/git/metasploit-framework/lib/msf/core/db_manager/host.rb:22:in `block (2 levels) in delete_host'
/home/gwillcox/git/metasploit-framework/lib/msf/core/db_manager/host.rb:21:in `each'
/home/gwillcox/git/metasploit-framework/lib/msf/core/db_manager/host.rb:21:in `block in delete_host'
/home/gwillcox/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/activerecord-7.0.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/home/gwillcox/git/metasploit-framework/lib/msf/core/db_manager/host.rb:19:in `delete_host'
/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/data_service/proxy/host_data_proxy.rb:67:in `block in delete_host'
/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:164:in `data_service_operation'
/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/data_service/proxy/host_data_proxy.rb:66:in `delete_host'
/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:648:in `block in cmd_hosts'
/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/db/common.rb:53:in `block in each_host_range_chunk'
/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/db/common.rb:34:in `each'
/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/db/common.rb:34:in `each_host_range_chunk'
/home/gwillcox/git/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:617:in `cmd_hosts'
/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in `run_command'
/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in `block in run_single'
/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'
/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'
/home/gwillcox/git/metasploit-framework/lib/rex/ui/text/shell.rb:162:in `run'
/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/home/gwillcox/git/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:23:in `<main>'
msf6 >
Debugging this further it looks like by the time we get to add_host_tag inside lib/msf/core/db_manager/host.rb, however for some reason we rely on the opts[:id] to determine if the entry already exists vs the opts[:address] and so accord to the database, we are constantly trying to update an entry with the same ID. Since the code also checks that the entry in question hasn't changed before trying to update it, we end up constantly trying to update the same entry over and over again, realizing its not changing, and then doing this again until the range ends 🤦