def connect(self): """ Connect to a host on a given (SSL) port, send a STARTTLS command, and perform the SSL handshake. """ sock = socket.create_connection((self.host, self.port), self.timeout) self.sock = sock # Get the SMTP banner sock.recv(2048) # Send a EHLO and wait for the 250 status sock.send('EHLO sslyze.scan\r\n') smtp_resp = sock.recv(2048) if '250 ' not in smtp_resp: raise SSLHandshakeError('SMTP EHLO was rejected ?') # Send a STARTTLS sock.send('STARTTLS\r\n') smtp_resp = sock.recv(2048) if 'Ready to start TLS' not in smtp_resp: raise SSLHandshakeError('SMTP STARTTLS not supported ?') # Do the SSL handshake self.ssl.set_socket(sock) ssl_sock = SSLSocket(self.ssl) ssl_sock.do_handshake() self.sock = ssl_sock
def connect(self): """ Connect to a host on a given (SSL) port. @raise ctSSLHelper.SSLHandshakeRejected: The server explicitly rejected the SSL handshake. @raise ctSSLHelper.SSLHandshakeError: The SSL handshake failed. """ sock = socket.create_connection((self.host, self.port), self.timeout) if self._tunnel_host: self.sock = sock self._tunnel() # Doing something similar to ssl.wrap_socket() but with ctSSL self.ssl.set_socket(sock) ssl_sock = SSLSocket(self.ssl) try: ssl_sock.do_handshake() except Exception as e: filter_handshake_exceptions(e) self.sock = ssl_sock
def connect(self): """ Connect to a host on a given (SSL) port, send a STARTTLS command, and perform the SSL handshake. """ sock = socket.create_connection((self.host, self.port), self.timeout) self.sock = sock # Open an XMPP stream sock.send(self.xmpp_open_stream.format(self.xmpp_to)) sock.recv(2048) # Send a STARTTLS sock.send(self.xmpp_starttls) xmpp_resp = sock.recv(2048) if 'proceed' not in xmpp_resp: raise SSLHandshakeError('XMPP STARTTLS not supported ?') # Do the SSL handshake self.ssl.set_socket(sock) ssl_sock = SSLSocket(self.ssl) ssl_sock.do_handshake() self.sock = ssl_sock
def connect(self): """ Connect to a host on a given (SSL) port. """ sock = socket.create_connection((self.host, self.port), self.timeout) if self._tunnel_host: self.sock = sock self._tunnel() # Doing something similar to ssl.wrap_socket() but with ctSSL self._ssl.set_socket(sock) ssl_sock = SSLSocket(self._ssl) ssl_sock.do_handshake() self.sock = ssl_sock