当前位置: 首页>>代码示例>>Python>>正文


Python cx_Oracle.connect方法代码示例

本文整理汇总了Python中cx_Oracle.connect方法的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.connect方法的具体用法?Python cx_Oracle.connect怎么用?Python cx_Oracle.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cx_Oracle的用法示例。


在下文中一共展示了cx_Oracle.connect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bind

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def bind(self, host, port, *args, **kwargs):

    hp = '%s:%s' % (host, port)
    key = ':'.join(map(str, args))

    if hp in self.cache:
      k, c = self.cache[hp]

      if key == k:
        self.curr = hp, k, c
        return c.fp, c.banner

      else:
        c.close()
        del self.cache[hp]

    self.curr = None

    logger.debug('connect')
    conn = self.connect(host, port, *args, **kwargs)

    self.cache[hp] = (key, conn)
    self.curr = hp, key, conn

    return conn.fp, conn.banner 
开发者ID:lanjelot,项目名称:patator,代码行数:27,代码来源:patator.py

示例2: connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def connect(self, host, port, ssl, helo, starttls, timeout):

    if ssl == '0':
      if not port:
        port = 25
      fp = SMTP(timeout=int(timeout))
    else:
      if not port:
        port = 465
      fp = SMTP_SSL(timeout=int(timeout))

    resp = fp.connect(host, int(port))

    if helo:
      cmd, name = helo.split(' ', 1)

      if cmd.lower() == 'ehlo':
        resp = fp.ehlo(name)
      else:
        resp = fp.helo(name)

    if not starttls == '0':
      resp = fp.starttls()

    return TCP_Connection(fp, resp) 
开发者ID:lanjelot,项目名称:patator,代码行数:27,代码来源:patator.py

示例3: execute

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def execute(self, host, port='1521', user='', password='', sid='', service_name=''):

    if sid:
      dsn = cx_Oracle.makedsn(host=host, port=port, sid=sid)
    elif service_name:
      dsn = cx_Oracle.makedsn(host=host, port=port, service_name=service_name)
    else:
      raise ValueError('Options sid and service_name cannot be both empty')

    try:
      with Timing() as timing:
        fp = cx_Oracle.connect(user, password, dsn, threaded=True)

      code, mesg = '0', fp.version

    except cx_Oracle.DatabaseError as e:
      code, mesg = e.args[0].message[:-1].split(': ', 1)

    return self.Response(code, mesg, timing)

# }}}

# PostgreSQL {{{ 
开发者ID:lanjelot,项目名称:patator,代码行数:25,代码来源:patator.py

示例4: oracle

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def oracle(self, ip):
		for i in range(1, len(oracle_user)):
			try:
				user = oracle_user[i]
				pwd  = oracle_pass_default[i]
				conn = cx_Oracle.connect(user, pwd, ip+':1521/orcl')
				print u'{}[+] {}:1521  Oracle存在弱口令: {} {}{}'.format(G, ip, user, pwd, W)
				conn.close()
			except Exception as e:
				pass
		for pwd in passwd:
			try:
				pwd = pwd.replace('{user}', 'sys')
				conn = cx_Oracle.connect('sys', pwd, ip+':1521/orcl')
				print u'{}[+] {}:1521  Oracle存在弱口令: sys {}{}'.format(G, ip, pwd, W)
				conn.close()
				break
			except Exception as e:
				pass 
开发者ID:se55i0n,项目名称:DBScanner,代码行数:21,代码来源:exploit.py

示例5: redis

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def redis(self, ip):
		try:
			s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
			s.connect((ip, 6379))
			s.send('INFO\r\n')
			if 'redis_version' in s.recv(1024):
				print u'{}[+] {}:6379  Redis存在未授权访问{}'.format(G, ip, W)
			else:
				for pwd in passwd:
					try:
						pwd = pwd.replace('{user}', 'admin')
						s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
						s.connect((ip, 6379))
						s.send('AUTH {}\r\n'.format(pwd))
						if '+OK' in s.recv(1024):
							print u'{}[+] {}:6379  Redis存在弱口令: {}{}'.format(G, ip, pwd, W)
							break
					except Exception as e:
						pass
					finally:
						s.close()
		except Exception as e:
			pass
		finally:
			s.close() 
开发者ID:se55i0n,项目名称:DBScanner,代码行数:27,代码来源:exploit.py

示例6: connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def connect(self, host, port, ssl, helo, starttls, timeout):

    if ssl == '0':
      if not port: port = 25
      fp = SMTP(timeout=int(timeout))
    else:
      if not port: port = 465
      fp = SMTP_SSL(timeout=int(timeout))

    resp = fp.connect(host, int(port))

    if helo:
      cmd, name = helo.split(' ', 1)

      if cmd.lower() == 'ehlo':
        resp = fp.ehlo(name)
      else:
        resp = fp.helo(name)

    if not starttls == '0':
      resp = fp.starttls()

    return TCP_Connection(fp, resp) 
开发者ID:c0rvax,项目名称:project-black,代码行数:25,代码来源:patator_ext.py

示例7: connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def connect(self):
        self.initConnection()
        self.__dsn = cx_Oracle.makedsn(self.hostname, self.port, self.db)
        self.__dsn = utf8encode(self.__dsn)
        self.user = utf8encode(self.user)
        self.password = utf8encode(self.password)

        try:
            self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password, mode=cx_Oracle.SYSDBA)
            logger.info("successfully connected as SYSDBA")
        except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError), ex:
            if "Oracle Client library" in str(ex):
                msg = re.sub(r"DPI-\d+:\s+", "", str(ex))
                msg = re.sub(r': ("[^"]+")', r" (\g<1>)", msg)
                msg = re.sub(r". See (http[^ ]+)", r'. See "\g<1>"', msg)
                raise SqlmapConnectionException(msg)

            try:
                self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password)
            except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError), msg:
                raise SqlmapConnectionException(msg) 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:23,代码来源:connector.py

示例8: db_connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def db_connect(args):
    if args.type == "mysql" or args.type == "mariadb":
        import mysql.connector
        try:
            connection = mysql.connector.connect(
                user=args.user,
                password=args.password,
                database=args.db)
        except mysql.connector.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None
    elif args.type == "mssql":
        import pymssql
        try:
            connection = pymssql.connect(server="localhost", database=args.db)
        except pymssql.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None
    elif args.type == "pgsql":
        import psycopg2
        try:
            connection = psycopg2.connect(
                "dbname='{}' user='{}' password='{}'".format(
                    args.db, args.user, args.password))
        except psycopg2.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None
    elif args.type == "oracle":
        import cx_Oracle
        try:
            connection = cx_Oracle.connect(
                args.user, args.password, cx_Oracle.makedsn(
                    '127.0.0.1', 1521, args.db), mode=cx_Oracle.SYSDBA)
        except cx_Oracle.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None

    return connection 
开发者ID:migolovanov,项目名称:libinjection-fuzzer,代码行数:40,代码来源:fuzzer.py

示例9: _open_connection

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def _open_connection(self):
        return pymysql.connect(host=self.host,
                               port=self.port,
                               user=self.user,
                               password=self.password,
                               database=self._mysql_database) 
开发者ID:tokern,项目名称:piicatcher,代码行数:8,代码来源:databases.py

示例10: get_new_connection

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def get_new_connection(self, conn_params):
        conn_string = convert_unicode(self._connect_string())
        return Database.connect(conn_string, **conn_params) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:5,代码来源:base.py

示例11: get_new_connection

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def get_new_connection(self, conn_params):
        return Database.connect(self._connect_string(), **conn_params) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:4,代码来源:base.py


注:本文中的cx_Oracle.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。