Created
March 7, 2016 05:02
-
-
Save khanzf/f48b608d8bb84cef1821 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/python3 | |
# Utilizing strong ciphers, TLSv1.2, strong everything | |
# Basically binds to your IPv6 Interfaces | |
# Change AF_INET6 to AF_INET for IPv4 | |
import socket, ssl | |
ciphers = 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:ECDHE-RSA-AES256-GCM-SHA384' | |
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) | |
s.bind(('', 5005)) | |
s.listen(5) | |
while True: | |
client, address = s.accept() | |
try: | |
connstream = ssl.wrap_socket(client, | |
server_side=True, | |
certfile="server.crt", | |
keyfile="server.key", | |
ssl_version=ssl.PROTOCOL_TLSv1_2, | |
ciphers=ciphers) | |
print(connstream.cipher() ) | |
data = connstream.read() | |
while data: | |
print(data) | |
data = connstream.read() | |
connstream.write('Testing') | |
connstream.shutdown(socket.SHUT_RDWR) | |
connstream.close() | |
except: | |
pass | |
finally: | |
client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment