python类_create_unverified_context()的实例源码

f115api.py 文件源码 项目:the-115-api 作者: J3n5en 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def main():
    global mySession
    ssl._create_default_https_context = ssl._create_unverified_context
    headers = {'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2663.0 Safari/537.36'}
    mySession = requests.Session()
    mySession.headers.update(headers)
    if not getInfos(): 
        print(u'??????')
        return
    getQrcode() # ????
    waitLogin() # ????????
    login() # ????
    print('??????')
    threading.Thread(target=keepLogin) # ?????????
    getTasksign() # ????task????
    getUserinfo() # ????????
    # addLinktask("magnet:?xt=urn:btih:690ba0361597ffb2007ad717bd805447f2acc624")
    # addLinktasks([link]) ????list
    # print tsign
    # print "fuck"
    # get_bt_upload_info()
    # upload_torrent()
    add_many_bt()
depotcontroller.py 文件源码 项目:solaris-ips 作者: oracle 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __network_ping(self):
                try:
                        repourl = urljoin(self.get_depot_url(),
                            "versions/0")
                        # Disable SSL peer verification, we just want to check
                        # if the depot is running.
                        url = urlopen(repourl,
                            context=ssl._create_unverified_context())
                        url.close()
                except HTTPError as e:
                        # Server returns NOT_MODIFIED if catalog is up
                        # to date
                        if e.code == http_client.NOT_MODIFIED:
                                return True
                        else:
                                return False
                except URLError as e:
                        return False
                return True
pkg5unittest.py 文件源码 项目:solaris-ips 作者: oracle 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _network_ping(self):
                try:
                        # Ping the versions URL, rather than the default /
                        # so that we don't initialize the BUI code yet.
                        repourl = urljoin(self.url, "versions/0")
                        # Disable SSL peer verification, we just want to check
                        # if the depot is running.
                        urlopen(repourl,
                            context=ssl._create_unverified_context())
                except HTTPError as e:
                        if e.code == http_client.FORBIDDEN:
                                return True
                        return False
                except URLError:
                        return False
                return True
scheduler.py 文件源码 项目:Mini-Spider 作者: ZYunH 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, original_url=None, timeout=2, search=(), ssl_context=None, url_check=True,
                 similarity_threshold=0.6,
                 display_number=100):
        # Parse chinese to ascii and delete parameters.
        self.url = original_url
        if self.url:
            self.url_check = url_check
            self._check_url()
            self.host = self.url.split('//')[0] + '//' + self.url.split('//')[1].split('/')[0]
        # Create ssl context.
        if ssl_context:
            self.ssl_context = ssl_context
        else:
            self.ssl_context = _create_unverified_context()
        # Initialization parameters.
        self.temp_file_name = 'mini-spider.temp'
        self.timeout = timeout
        self.similarity_threshold = similarity_threshold
        self.pattern_list = []
        self.search_list = self._initialize_search(search)
        self.display_number = display_number
        self.result = []
        self.http_flag = 0
https_reader_test.py 文件源码 项目:SuperHoneyPot 作者: TheFixers 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_startUp(self):
        try:
            lock = threading.Lock()
            self.https = https_reader.server_plugin(lock, PORT)

        except Exception as e:
            self.fail("Server Failed to Start")

        time.sleep(1)

        try:
            conn = httplib.HTTPSConnection('localhost', PORT, timeout=5, context=ssl._create_unverified_context())
            connection = True

        except Exception as e:
            print e
            connection = False

        finally:
            self.assertTrue(connection)
            conn.close()
            self.https.server.shutdown()
            self.https.server.server_close()
            time.sleep(1)
utils.py 文件源码 项目:rvo 作者: noqqe 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_title_from_webpage(url):
    """ Fetch <title> of a html site for title element
    :url: str (http url)
    :returns: str
    """

    # LOL SECURITY
    ssl._create_default_https_context = ssl._create_unverified_context

    try:
        h = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'}
        u = urllib2.Request(url, headers=h)
        u = urllib2.urlopen(u)
        soup = BeautifulSoup(u, "html.parser")
        s = soup.title.string.replace('\n', ' ').replace('\r', '').lstrip().rstrip()
        s = s.lstrip()
        return s
    except (AttributeError, MemoryError, ssl.CertificateError, IOError) as e:
        return "No title"
    except ValueError:
        return False
SoftwareUpdate.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def getLatestImageTimestamp(self):
        # TODO: Impement own sh4 timestamp
        return ""

        currentTimeoutDefault = socket.getdefaulttimeout()
        socket.setdefaulttimeout(3)
        try:
            # TODO: Use Twisted's URL fetcher, urlopen is evil. And it can
            # run in parallel to the package update.
            from time import strftime
            from datetime import datetime
            imageVersion = about.getImageTypeString().split(" ")[1]
            imageVersion = (int(imageVersion) < 5 and "%.1f" or "%s") % int(imageVersion)
            url = "http://openpli.org/download/timestamp/%s~%s" % (HardwareInfo().get_device_model(), imageVersion)
            try:
                latestImageTimestamp = datetime.fromtimestamp(int(urlopen(url, timeout=5).read())).strftime(_("%Y-%m-%d %H:%M"))
            except:
                # OpenPli 5.0 uses python 2.7.11 and here we need to bypass the certificate check
                from ssl import _create_unverified_context
                latestImageTimestamp = datetime.fromtimestamp(int(urlopen(url, timeout=5, context=_create_unverified_context()).read())).strftime(_("%Y-%m-%d %H:%M"))
        except:
            latestImageTimestamp = ""
        socket.setdefaulttimeout(currentTimeoutDefault)
        return latestImageTimestamp
https.py 文件源码 项目:python-spider 作者: titrxw 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __run(self,req):
        try:
            ssl._create_default_https_context = ssl._create_unverified_context
            if self.__opener is not None:
                response=self.__opener.open(req)
                self.__code=response.code
                return response.read()
            else:
                context = ssl._create_unverified_context()
                response=urllib2.urlopen(req,context=context)
                self.__code=response.code
                return response.read()
        except Exception,e:
            raise Exception(e.message)
https.py 文件源码 项目:python-spider 作者: titrxw 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __run(self,req):
        try:
            ssl._create_default_https_context = ssl._create_unverified_context
            if self.__opener is not None:
                response=self.__opener.open(req)
                self.__code=response.code
                return response.read()
            else:
                context = ssl._create_unverified_context()
                response=urllib2.urlopen(req,context=context)
                self.__code=response.code
                return response.read()
        except Exception,e:
            print(e)
            return None
test.py 文件源码 项目:admin-sites 作者: istio 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def do_get(url):
    parsed = urlparse.urlparse(url)
    path = parsed.path
    if parsed.query:
        path = '%s?%s' % (path, parsed.query)
    if parsed.scheme == 'http':
        conn = httplib.HTTPConnection(TARGET_IP)
    elif parsed.scheme == 'https':
        conn = httplib.HTTPSConnection(TARGET_IP, timeout=8, context=ssl._create_unverified_context())
    conn.request('GET', path, headers={'Host': parsed.netloc})
    resp = conn.getresponse()
    body = resp.read().decode('utf8')
    resp.close()
    conn.close()
    return resp, body
About.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def readGithubCommitLogs(self):
        url = 'https://api.github.com/repos/OpenLD/%s/commits' % self.projects[self.project][0]
        commitlog = ""
        from datetime import datetime
        from json import loads
        from urllib2 import urlopen
        try:
            commitlog += 80 * '-' + '\n'
            commitlog += url.split('/')[-2] + '\n'
            commitlog += 80 * '-' + '\n'
            try:
                # OpenLD 3.0 uses python 2.7.12 and here we need to bypass the certificate check
                from ssl import _create_unverified_context
                log = loads(urlopen(url, timeout=5, context=_create_unverified_context()).read())
            except:
                log = loads(urlopen(url, timeout=5).read())
            for c in log:
                creator = c['commit']['author']['name']
                title = c['commit']['message']
                date = datetime.strptime(c['commit']['committer']['date'], '%Y-%m-%dT%H:%M:%SZ').strftime('%x %X')
                commitlog += date + ' ' + creator + '\n' + title + 2 * '\n'
            commitlog = commitlog.encode('utf-8')
            self.cachedProjects[self.projects[self.project][1]] = commitlog
        except:
            commitlog += _("Currently the commit log cannot be retrieved - please try later again")
        self["AboutScrollLabel"].setText(commitlog)
sflib.py 文件源码 项目:llk 作者: Tycx2ry 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, options, handle=None):
        self.handle = handle
        self.opts = deepcopy(options)
        # This is ugly but we don't want any fetches to fail - we expect
        # to encounter unverified SSL certs!
        if sys.version_info >= (2, 7, 9):
            ssl._create_default_https_context = ssl._create_unverified_context

    # Bit of a hack to support SOCKS because of the loading order of
    # modules. sfscan will call this to update the socket reference
    # to the SOCKS one.
vulnlab.py 文件源码 项目:vulnlab 作者: timkent 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def main():

    # ignore invalid cert on ESX box
    import ssl
    _create_unverified_https_context = ssl._create_unverified_context
    ssl._create_default_https_context = _create_unverified_https_context

    vm_list = get_vm_list()

    app = Flask(__name__)

    @app.route("/")
    def index():
        result = '''<!DOCTYPE html>
<html>
  <head>
    <title>VulnLab</title>
  </head>
  <body>
    <h1>Reset</h1>
'''
        for name, uuid in sorted(vm_list.items()):
            result += '    <a href="/reset/' + name + '">' + name + '</a><br>\n'

        result += '''  </body>
</html>
'''
        return result, 200

    @app.route("/reset/<string:vm_name>")
    def reset(vm_name):
        reset_vm(vm_list, vm_name)
        return 'OK\n', 200

    # start the web server
    app.run(host="0.0.0.0", port=5000)
DownloaderClass.py 文件源码 项目:Boards-Image-Downloader 作者: Wolfterro 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, chosenDir):
        self.chosenDir = chosenDir
        self.replaceFiles = False
        self.messageBox = ShowMessageBox()
        self.changeDir()
        self.context = ssl._create_unverified_context()

    # Alterando pasta local para armazenar os arquivos do tópico
    # ==========================================================
sflib.py 文件源码 项目:spiderfoot 作者: wi-fi-analyzer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, options, handle=None):
        self.handle = handle
        self.opts = deepcopy(options)
        # This is ugly but we don't want any fetches to fail - we expect
        # to encounter unverified SSL certs!
        if sys.version_info >= (2, 7, 9):
            ssl._create_default_https_context = ssl._create_unverified_context

    # Bit of a hack to support SOCKS because of the loading order of
    # modules. sfscan will call this to update the socket reference
    # to the SOCKS one.
collectPerfStats.py 文件源码 项目:XtremPerfProbe 作者: nachiketkarmarkar 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getVmwServiceContent(vcip, vcuser, vcpwd):
    unverified_context=ssl._create_unverified_context
    ssl._create_default_https_context=unverified_context
    si=Connect(host=vcip,port=443,user=vcuser,pwd=vcpwd)
    return si.RetrieveContent()
GetSession.py 文件源码 项目:delphixpy-examples 作者: CloudSurgeon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def serversess(self, f_engine_address, f_engine_username,
                   f_engine_password, f_engine_namespace='DOMAIN'):
        """
        Method to setup the session with the Virtualization Engine

        f_engine_address: The Virtualization Engine's address (IP/DNS Name)
        f_engine_username: Username to authenticate
        f_engine_password: User's password
        f_engine_namespace: Namespace to use for this session. Default: DOMAIN
        """

#        if use_https:
#            if hasattr(ssl, '_create_unverified_context'):
#                ssl._create_default_https_context = \
#                    ssl._create_unverified_context

        try:
            if f_engine_password:
                self.server_session = DelphixEngine(f_engine_address,
                                                    f_engine_username,
                                                    f_engine_password,
                                                    f_engine_namespace)
            elif f_engine_password is None:
                self.server_session = DelphixEngine(f_engine_address,
                                                    f_engine_username,
                                                    None, f_engine_namespace)

        except (HttpError, RequestError, JobError) as e:
            raise DlpxException('ERROR: An error occurred while authenticating'
                                ' to {}:\n {}\n'.format(f_engine_address, e))
appleLoops.py 文件源码 项目:appleLoops 作者: carlashley 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def response_code(self, url):
        try:
            if self.allow_insecure:
                return urllib2.urlopen(url, timeout=self.timeout, context=ssl._create_unverified_context()).getcode()  # NOQA
            else:
                return urllib2.urlopen(url, timeout=self.timeout).getcode()
        except urllib2.HTTPError as e:
            return e.getcode()
        except urllib2.URLError as e:
            return e
appleLoops.py 文件源码 项目:appleLoops 作者: carlashley 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_headers(self, url):
        try:
            if self.allow_insecure:
                return dict(urllib2.urlopen(url, timeout=self.timeout, context=ssl._create_unverified_context()).info())  # NOQA
            else:
                return dict(urllib2.urlopen(url, timeout=self.timeout).info())
        except Exception as e:
            return e
appleLoops.py 文件源码 项目:appleLoops 作者: carlashley 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def read_data(self, url):
        try:
            if self.allow_insecure:
                return urllib2.urlopen(url, timeout=self.timeout, context=ssl._create_unverified_context()).read()  # NOQA
            else:
                return urllib2.urlopen(url, timeout=self.timeout).read()
        except Exception as e:
            return e


# AppleLoops


问题


面经


文章

微信
公众号

扫码关注公众号