Skip to content

Instantly share code, notes, and snippets.

@khanzf
Created March 7, 2016 05:02
Show Gist options
  • Save khanzf/f48b608d8bb84cef1821 to your computer and use it in GitHub Desktop.
Save khanzf/f48b608d8bb84cef1821 to your computer and use it in GitHub Desktop.
#!/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