Last active
February 26, 2025 21:36
-
-
Save Andoryuuta/3e863e70c771ec7e71221f42e86ece0b to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import socket | |
import ssl | |
import time | |
from unittest.mock import patch | |
def send_truncated_ssl_handshake(target_host='localhost', target_port=9560, truncate_to=None): | |
# Get original socket.send before any patching occurs | |
original_send = socket.socket.send | |
def truncated_send(self, data, *args, **kwargs): | |
if truncate_to is not None and len(data) > truncate_to: | |
truncated_data = data[:truncate_to] | |
return original_send(self, truncated_data, *args, **kwargs) | |
return original_send(self, data, *args, **kwargs) | |
# Patch the underlying socket.send method | |
socket.socket.send = truncated_send | |
try: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.settimeout(2.0) | |
sock.connect((target_host, target_port)) | |
context = ssl.create_default_context() | |
context.check_hostname = False | |
context.verify_mode = ssl.CERT_NONE | |
ssl_sock = context.wrap_socket(sock, server_hostname=target_host) | |
ssl_sock.close() | |
return True | |
except Exception as e: | |
return False | |
finally: | |
# Restore the original socket.send method | |
socket.socket.send = original_send | |
def fuzz_ssl_server(host='localhost', port=9560, max_bytes=512, min_bytes=0, delay=0.1): | |
print(f"Starting SSL fuzzing on {host}:{port}") | |
for length in range(max_bytes, min_bytes - 1, -1): | |
success = send_truncated_ssl_handshake(host, port, length) | |
status = "✓" if success else "✗" | |
print(f"Testing with {length} bytes: {status}") | |
time.sleep(delay) | |
print("Fuzzing complete") | |
fuzz_ssl_server(host='localhost', port=9560, max_bytes=512, min_bytes=0, delay=0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment