metasploit-framework
metasploit-framework copied to clipboard
Rex: ctrl+c interrupt may terminate msfconsole while resolving host names
I've managed to trigger this bug a few times accidentaly through tactical user error.
Reproduce:
- Work on a module then switch back to
msfconsole
window - Type
rex
and tab-completerexploit
, but don't press enter - Get distracted, forget you typed
rexploit
and type another command, likeset target 1
- press enter
- (optionally type
rex
and attempt tab-completion again pre-emptively) - hold ctrl+c out of frustration, while Metasploit desperately tries and fails to resolve host names
set
,target
and1
- you are here:
msf6 exploit(windows/iis/ms01_033_idq) > rexploit set target 1
[*] Reloading module...
rex
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^CInterrupt: use the 'exit' command to quit
Aborting...
./msfconsole: Interrupt
./msfconsole:26:in `exit': exit (SystemExit)
from ./msfconsole:26:in `rescue in <main>'
from ./msfconsole:9:in `<main>'
/root/Desktop/metasploit-framework/lib/rex/logging/sinks/stream.rb:30:in `flush': Interrupt
from /root/Desktop/metasploit-framework/lib/rex/logging/sinks/stream.rb:30:in `log'
from /root/Desktop/metasploit-framework/lib/rex/logging/log_dispatcher.rb:94:in `block in log'
from /root/Desktop/metasploit-framework/lib/rex/logging/log_dispatcher.rb:90:in `synchronize'
from /root/Desktop/metasploit-framework/lib/rex/logging/log_dispatcher.rb:90:in `log'
from /root/Desktop/metasploit-framework/lib/rex/logging/log_dispatcher.rb:134:in `dlog'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell/history_manager.rb:42:in `pop_context'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:172:in `ensure in run'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:174:in `run'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
from ./msfconsole:23:in `<main>'
/root/Desktop/metasploit-framework/lib/rex/ui/text/output/stdio.rb:89:in `write': Interrupt
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output/stdio.rb:89:in `print'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output/stdio.rb:89:in `print_raw'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output.rb:68:in `print'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:169:in `rescue in run'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:168:in `run'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
from ./msfconsole:23:in `<main>'
/var/lib/gems/3.0.0/gems/rex-core-0.1.28/lib/rex/compat.rb:40:in `is_windows': Interrupt
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output/stdio.rb:105:in `supports_color?'
from /var/lib/gems/3.0.0/gems/rex-text-0.2.38/lib/rex/text/color.rb:49:in `colorize'
from /var/lib/gems/3.0.0/gems/rex-text-0.2.38/lib/rex/text/color.rb:72:in `substitute_colors'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output.rb:68:in `print'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output/stdio.rb:79:in `print_line'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/output.rb:46:in `print_error'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:224:in `print_error'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:537:in `rescue in block in run_single'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:527:in `block in run_single'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:162:in `run'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
from ./msfconsole:23:in `<main>'
/var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket.rb:193:in `getaddrinfo': Interrupt
from /var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket.rb:193:in `getaddresses'
from /var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket/range_walker.rb:391:in `parse_hostname'
from /var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket/range_walker.rb:101:in `block in parse'
from /var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket/range_walker.rb:83:in `each'
from /var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket/range_walker.rb:83:in `parse'
from /var/lib/gems/3.0.0/gems/rex-socket-0.1.39/lib/rex/socket/range_walker.rb:48:in `initialize'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:146:in `new'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:146:in `block (2 levels) in parse'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:114:in `each'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:114:in `block in parse'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:96:in `each'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:96:in `each'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:96:in `all?'
from /root/Desktop/metasploit-framework/lib/msf/core/rhosts_walker.rb:96:in `valid?'
from /root/Desktop/metasploit-framework/lib/msf/core/opt_rhosts.rb:27:in `valid?'
from /root/Desktop/metasploit-framework/lib/msf/core/option_container.rb:198:in `block in validate'
from /root/Desktop/metasploit-framework/lib/msf/core/option_container.rb:197:in `each_pair'
from /root/Desktop/metasploit-framework/lib/msf/core/option_container.rb:197:in `validate'
from /root/Desktop/metasploit-framework/lib/msf/core/module/options.rb:21:in `validate'
from /root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/exploit.rb:135:in `cmd_exploit'
from /root/Desktop/metasploit-framework/lib/msf/ui/console/command_dispatcher/exploit.rb:253:in `cmd_rexploit'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:581:in `run_command'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:530:in `block in run_single'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `each'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:524:in `run_single'
from /root/Desktop/metasploit-framework/lib/rex/ui/text/shell.rb:162:in `run'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
from ./msfconsole:23:in `<main>'
^C
Expected result:
msf6 > Interrupt: use the 'exit' command to quit
msf6 >
Hi!
This issue has been left open with no activity for a while now.
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.
I haven't had a cycle to look at this yet; I assume the rhost walker needs to be updated to handle an interrupt and to bail early - similar to the other patterns in framework.
Hi!
This issue has been left open with no activity for a while now.
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.
Hi!
This issue has been left open with no activity for a while now.
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.
Hi again!
It’s been 60 days since anything happened on this issue, so we are going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.
Hi!
This issue has been left open with no activity for a while now.
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.
Partly fixed in #17409. Closing this issue, as the underlying issue is apparently due to Ruby behaviour: https://bugs.ruby-lang.org/issues/16476
Closing this issue, as the underlying issue is apparently due to Ruby behaviour: https://bugs.ruby-lang.org/issues/16476
I haven't tested it; but Ruby 3.3 is out now - and apparently there's changes to help fix the final issue of supporting interruptible DNS Lookups:
Performance improvements
- ...
- Name resolution such as Socket.getaddrinfo can now be interrupted (in environments where pthreads are available). [Feature #19965]
- ... Source: https://www.ruby-lang.org/en/news/2023/12/25/ruby-3-3-0-released/