-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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 error downloading a file from generic shell #18372
Conversation
@@ -797,7 +797,7 @@ def vprint_status(s) | |||
end | |||
|
|||
def _file_transfer | |||
raise NotImplementedError.new('Session does not support file transfers.') if @session_type.ends_with?(':winpty') | |||
raise NotImplementedError.new('Session does not support file transfers.') if session_type.ends_with?(':winpty') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the tester, we should verify if we need to add in something slightly different here, potentially akin to:
raise NotImplementedError.new('Session does not support file transfers.') if @session.session_type.ends_with?(':winpty')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the tester, we should verify if we need to add in something slightly different here, potentially akin to:
raise NotImplementedError.new('Session does not support file transfers.') if @session.session_type.ends_with?(':winpty')
I've tried with your suggested code but it doesn't work, it comes back to the previous error
I've tested this with the suggested ssh_login module with a simple shell: BeforeBroken download /home/kali/Desktop/win_met_x64_staged.exe /Users/sjanusz/Desktop/temp.exe
[-] Session manipulation failed: undefined method `ends_with?' for nil:NilClass ["/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:800:in `_file_transfer'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:421:in `cmd_download'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:622:in `run_builtin_cmd'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:610:in `run_single'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:774:in `_interact_stream'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:750:in `block in _interact'", "/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell/history_manager.rb:31:in `with_context'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/base/sessions/command_shell.rb:749:in `_interact'", "/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/interactive.rb:53:in `interact'", "/Users/sjanusz/Programming/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:1680:in `cmd_sessions'", "/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:168:in `block in run'", "/Users/sjanusz/Programming/metasploit-framework/lib/rex/ui/text/shell/history_manager.rb:31:in `with_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>'"] AfterWorking download /home/kali/Desktop/win_met_x64_staged.exe /Users/sjanusz/Desktop/temp.exe
[*] Download /home/kali/Desktop/win_met_x64_staged.exe => /Users/sjanusz/Desktop/temp.exe
[+] Done |
Release NotesFixed an issue in the generic shell |
This PR solves the issue #18371 Error downloading a file from generic shell.
I found that it was an issue of scoping of the variable 'session_type' in file lib/msf/base/sessions/command_shell.rb at line 800
The '@' should be removed
Verification
msfconsole
use auxiliary/scanner/ssh/ssh_login