rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
34.21k stars 13.99k forks source link

msfconsole cannot input Chinese characters, and pasting Chinese characters will result in an error #19513

Closed sunlewuyou closed 2 weeks ago

sunlewuyou commented 1 month ago

Steps to reproduce

How'd you do it?

  1. run msfconsole

Expected behavior

Can input Chinese characters

Current behavior

The console cannot input Chinese characters. If you forcibly paste Chinese characters, an error will be reported as follows:

msf6 > /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/unicode.rb:137:in `encode': "\xE8" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/unicode.rb:137:in `split_by_width'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/line_editor.rb:300:in `split_by_width'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/line_editor.rb:439:in `wrapped_cursor_position'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/line_editor.rb:1182:in `scroll_into_view'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:358:in `block (3 levels) in inner_readline'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:354:in `each'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:354:in `block (2 levels) in inner_readline'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:405:in `block in read_io'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:392:in `loop'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:392:in `read_io'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:352:in `block in inner_readline'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:351:in `loop'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:351:in `inner_readline'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:291:in `block (2 levels) in readline'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/ansi.rb:162:in `block in with_raw_input'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/ansi.rb:162:in `raw'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline/ansi.rb:162:in `with_raw_input'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:290:in `block in readline'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:288:in `synchronize'
    from /opt/metasploit-framework/embedded/lib/ruby/gems/3.2.0/gems/reline-0.5.8/lib/reline.rb:288:in `readline'
    from /opt/metasploit-framework/embedded/lib/ruby/3.2.0/forwardable.rb:240:in `readline'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/input/readline.rb:146:in `readline_with_output'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/input/readline.rb:91:in `pgets'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell.rb:344:in `get_input_line'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell.rb:145:in `block in run'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell.rb:312:in `block in with_history_manager_context'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell/history_manager.rb:35:in `with_context'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell.rb:309:in `with_history_manager_context'
    from /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell.rb:136:in `run'
    from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:54:in `start'
    from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
    from /opt/metasploit-framework/bin/../embedded/framework/msfconsole:25:in `<main>'

Metasploit version

metasploit v6.4.28-dev-

cn-kali-team commented 1 month ago

您好,怎么复现这个错误呢?可以提供一下详细的操作步骤吗?

sunlewuyou commented 1 month ago

@cn-kali-team

  1. run msfconsole
  2. force paste Chinese characters into the console
adfoster-r7 commented 1 month ago

Similar issue with tab completion too:

sf6 > ls
[*] exec: ls

メタスプロイトが大好きです
msf6 > use linux/x64/meterpreter/reverse_tcp
msf6 payload(linux/x64/meterpreter/reverse_tcp) > ;s
[-] Unknown command: ;s. Run the help command for more details.
msf6 payload(linux/x64/meterpreter/reverse_tcp) > ls
[*] exec: ls

メタスプロイトが大好きです
msf6 payload(linux/x64/meterpreter/reverse_tcp) > generate -f elf -o meterpreter.elf
[-] Payload generation failed: One or more options failed to validate: LHOST.
msf6 payload(linux/x64/meterpreter/reverse_tcp) > set lhost 127.0.0.1
lhost => 127.0.0.1
msf6 payload(linux/x64/meterpreter/reverse_tcp) > generate -f elf -o meterpreter.elf
[*] Writing 250 bytes to meterpreter.elf...
msf6 payload(linux/x64/meterpreter/reverse_tcp) > generate -f elf -o ./<TAB>/home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/unicode.rb:127:in `encode': "\\xE3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/unicode.rb:127:in `calculate_width'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/line_editor.rb:60:in `block in lines'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/line_editor.rb:60:in `map'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/line_editor.rb:60:in `lines'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/line_editor.rb:509:in `render_differential'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/line_editor.rb:569:in `rerender'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:369:in `block in inner_readline'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:351:in `loop'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:351:in `inner_readline'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:291:in `block (2 levels) in readline'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/ansi.rb:162:in `block in with_raw_input'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/ansi.rb:162:in `raw'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline/ansi.rb:162:in `with_raw_input'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:290:in `block in readline'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:288:in `synchronize'
    from /home/kali/.rvm/gems/ruby-3.1.5@metasploit-framework/gems/reline-0.5.8/lib/reline.rb:288:in `readline'
    from /home/kali/.rvm/rubies/ruby-3.1.5/lib/ruby/3.1.0/forwardable.rb:238:in `readline'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/input/readline.rb:146:in `readline_with_output'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/input/readline.rb:91:in `pgets'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/shell.rb:344:in `get_input_line'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/shell.rb:145:in `block in run'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/shell.rb:312:in `block in with_history_manager_context'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/shell/history_manager.rb:35:in `with_context'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/shell.rb:309:in `with_history_manager_context'
    from /home/kali/Documents/github/metasploit-framework/lib/rex/ui/text/shell.rb:136:in `run'
    from /home/kali/Documents/github/metasploit-framework/lib/metasploit/framework/command/console.rb:54:in `start'
    from /home/kali/Documents/github/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
    from ./msfconsole:25:in `<main>'

┌──(kali㉿kali)-[~/Documents/github/metasploit-framework]
└─$        

Replicating with generate with -o ./<TAB>