HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/thread-self/root/usr/share/doc/m2crypto-0.21.1/demo/ssl/socklib.py
"""
socklib provides a way to transparently replace socket.ssl with
M2Crypto.SSL.Connection.

Usage: Import socklib before the 3rd party module that uses socket.ssl. Also,
       call socketlib.setSSLContextFactory() to set it up with a way to get
       secure SSL contexts.

Copyright (c) 2007 Open Source Applications Foundation.
All rights reserved.
"""

sslContextFactory = None

def setSSLContextFactory(factory):
    global sslContextFactory
    sslContextFactory = factory

from M2Crypto.SSL import Connection, Checker
import socket

class ssl_socket(socket.socket):
    def connect(self, addr, *args):
        self.addr = addr
        return super(ssl_socket, self).connect(addr, *args)
        
    def close(self):
        if hasattr(self, 'conn'):
            self.conn.close()
        socket.socket.close(self)

def ssl(sock):
    sock.conn = Connection(ctx=sslContextFactory(), sock=sock)
    sock.conn.addr = sock.addr
    sock.conn.setup_ssl()
    sock.conn.set_connect_state()
    sock.conn.connect_ssl()
    check = getattr(sock.conn, 'postConnectionCheck', sock.conn.clientPostConnectionCheck)
    if check is not None:
        if not check(sock.conn.get_peer_cert(), sock.conn.addr[0]):
            raise Checker.SSLVerificationError, 'post connection check failed'
    return sock.conn

socket.socket = ssl_socket
socket.ssl = ssl