Created
January 30, 2015 22:09
-
-
Save andresriancho/77d1d163c9987966ce77 to your computer and use it in GitHub Desktop.
tls
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
import socket | |
import ssl | |
sock = socket.create_connection(('dadario.com.br', 443)) | |
sock = ssl.wrap_socket(sock, None, None, ssl_version=ssl.PROTOCOL_TLSv1) |
Seems like the issue was the lacking SNI support in python 2.7 ssl module. This code works (after installing new dependency, see notes below):
import socket
import ssl
from ssl_sni.openssl import wrap_socket
hostname = 'dadario.com.br'
sock = socket.create_connection((hostname, 443))
sock = wrap_socket(sock, None, None, ssl_version=ssl.PROTOCOL_TLSv1, server_hostname=hostname)
sock.write('GET / HTTP/1.1\r\n')
sock.write('Host: %s\r\n' % hostname)
sock.write('\r\n')
sock.write('\r\n')
print sock.read(850)
sudo apt-get install libffi-dev
pip install ssl_sni
This is a nightmare! Now it doesn't work with w3af because of the timeout 👎
import socket
import ssl
from ssl_sni.openssl import wrap_socket
hostname = 'dadario.com.br'
socket.setdefaulttimeout(1)
sock = socket.create_connection((hostname, 443))
sock = wrap_socket(sock, None, None, ssl_version=ssl.PROTOCOL_TLSv1, server_hostname=hostname)
sock.write('GET / HTTP/1.1\r\n')
sock.write('Host: %s\r\n' % hostname)
sock.write('\r\n')
sock.write('\r\n')
print(sock.read(850))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you've got a couple of minutes help me out by running this code and storing the result, more info here