fix: add Python 2.7-3.14+ compatibility for reverse_python_ssl#21311
Open
karandesai2005 wants to merge 1 commit intorapid7:masterfrom
Open
fix: add Python 2.7-3.14+ compatibility for reverse_python_ssl#21311karandesai2005 wants to merge 1 commit intorapid7:masterfrom
karandesai2005 wants to merge 1 commit intorapid7:masterfrom
Conversation
- ssl.wrap_socket() was removed in Python 3.12, causing AttributeError - Added try/except AttributeError polyglot fallback for cross-version support - Maintains full backward compatibility with Python 2.7 and 3.4-3.11 - Preserves CERT_NONE behavior for reverse shell use case Fixes rapid7#21301
RafaCtv
approved these changes
Apr 15, 2026
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.
Summary
Fixes
cmd/unix/reverse_python_sslfailing on Python 3.12+ due to removal ofssl.wrap_socket(), while maintaining full backward compatibility with Python 2.7 and 3.4–3.11 as required.Changes
ssl.wrap_socket(so)call with atry/except AttributeErrorpolyglot fallbackssl.create_default_context().wrap_socket()only on Python 3.12+ wherewrap_socketis missingcheck_hostname=Falseandverify_mode=ssl.CERT_NONEfor reverse shell compatibilityTesting
✅ Ruby syntax validation passed (
ruby -c)✅ Payload generation tested — generated Python passes
py_compileon Python 3.14✅ Fallback logic verified:
try:s=ssl.wrap_socket(so)present in generated payload✅ Backward compatible: Python 2.7/3.4-3.11 use
wrap_socketdirectly, 3.12+ use context APINotes
CERT_NONE) are intentional for penetration testing use casesFixes #21301