rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
34.29k stars 14.01k forks source link

Check for nil res when setting echo shell #19617

Closed sjanusz-r7 closed 2 weeks ago

sjanusz-r7 commented 3 weeks ago

This PR fixes https://github.com/rapid7/metasploit-framework/issues/19615

From the code, shell_read_until_token can return nil. Now the code that broke in the linked issue explicitly checks for a nil.

I wasn't able to reproduce the issue locally using ssh_login against a Kali & Ubuntu VM, and I don't have any vCenter environments to test against.

Verification

Example

[*] SSH session 1 opened (...:56421 -> ...:22) at 2024-11-05 13:37:01 +0000
[*] Scanned 1 of 1 hosts (100% complete)
[*] Scan completed, 1 credential was successful.

Successful logins
=================

    Host             Public  Private
    ----             ------  -------
    ...                 kali    kali

[*] 1 session was opened successfully.
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/ssh/ssh_login) > sessions -i -1
[*] Starting interaction with 1...

shell

[*] Trying to find binary 'python' on the target machine
[*] Found python at /usr/bin/python
[*] Using `python` to pop up an interactive shell
[*] Trying to find binary 'bash' on the target machine
[*] Found bash at /usr/bin/bash

kali@kali:~$ whoami
whoami
kali
adfoster-r7 commented 2 weeks ago

Release Notes

Fixes a crash when running against a shell session which does not echo the executed commands