Fix incompatibility with ssl.wrap_socket() in newer python versions in payloads using it #21303
Open
jeanmtr wants to merge 6 commits intorapid7:masterfrom
Open
Fix incompatibility with ssl.wrap_socket() in newer python versions in payloads using it #21303jeanmtr wants to merge 6 commits intorapid7:masterfrom
jeanmtr wants to merge 6 commits intorapid7:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #21301
Changes
python/meterpreter/reverse_tcp_ssl,cmd/unix/reverse_python_sslandpython/shell_reverse_tcp_sslto useSSLContext.wrap_socket()instead ofssl.wrap_socket(). However since the protocols that can be used in version 3.14 and 2.7.18 are not the same, i cannot usessl.PROTOCOL_TLS_CLIENTfor both. Instead, we check if ssl.PROTOCOL_TLS_CLIENT exists and if not, we use ssl.wrap_socket the old way. There is probably a better solution but i cannot find it. One other thing that could work is to usessl.PROTOCOL_TLSv1_2which existe both on 2.7.18 and on 3.14 (and in version in between) but it is marked as deprecated therefore it is not really future proof.Verification
For
cmd/unix/reverse_python_sslopenssl s_server -accept 4444 -cert server.crt -key server.key -quietpyenv local [version])msfvenom -p cmd/unix/reverse_python_ssl LHOST=[host to test]For
python/shell_reverse_tcp_sslopenssl s_server -accept 4444 -cert server.crt -key server.key -quietpyenv local [version])msfvenom -p cmd/unix/reverse_python_ssl LHOST=[host to test]For
python/meterpreter/reverse_tcp_ssl(on the host)
(on the attacked machine)
pyenv local [version])msfvenom -p cmd/unix/reverse_python_ssl LHOST=[host to test]