Python cx_Oracle.connect() Examples
The following are 30
code examples of cx_Oracle.connect().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cx_Oracle
, or try the search function
.
Example #1
Source File: patator.py From patator with GNU General Public License v2.0 | 9 votes |
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 {{{
Example #2
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 6 votes |
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 {{{
Example #3
Source File: connector.py From EasY_HaCk with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 6 votes |
def execute(self, host, port=None, password=None, timeout='10'): v = VNC() try: with Timing() as timing: code, mesg = 0, v.connect(host, int(port or 5900), int(timeout)) if password is not None: with Timing() as timing: code, mesg = v.login(password) except VNC_Error as e: logger.debug('VNC_Error: %s' % e) code, mesg = 2, str(e) return self.Response(code, mesg, timing) # }}} # DNS {{{
Example #5
Source File: exploit.py From DBScanner with GNU Affero General Public License v3.0 | 6 votes |
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
Example #6
Source File: oracle.py From Archery with Apache License 2.0 | 5 votes |
def get_backup_connection(): """备份库连接""" archer_config = SysConfig() backup_host = archer_config.get('inception_remote_backup_host') backup_port = int(archer_config.get('inception_remote_backup_port', 3306)) backup_user = archer_config.get('inception_remote_backup_user') backup_password = archer_config.get('inception_remote_backup_password') return MySQLdb.connect(host=backup_host, port=backup_port, user=backup_user, passwd=backup_password, charset='utf8mb4', autocommit=True )
Example #7
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port, ssl, timeout): if ssl == '0': if not port: port = 110 fp = POP3(host, int(port), timeout=int(timeout)) else: if not port: port = 995 fp = POP3_SSL(host, int(port)) # timeout=int(timeout)) # no timeout option in python2 return POP_Connection(fp, fp.welcome)
Example #8
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def execute(self, host, port='106', user=None, password=None, timeout='10'): fp = LineReceiver() with Timing() as timing: resp = fp.connect(host, int(port), int(timeout)) trace = resp + '\r\n' try: if user is not None or password is not None: with Timing() as timing: if user is not None: cmd = 'USER %s' % user resp = fp.sendcmd(cmd) trace += '%s\r\n%s\r\n' % (cmd, resp) if password is not None: cmd = 'PASS %s' % password resp = fp.sendcmd(cmd) trace += '%s\r\n%s\r\n' % (cmd, resp) except LineReceiver_Error as e: logger.debug('LineReceiver_Error: %s' % e) resp = str(e) trace += '%s\r\n%s\r\n' % (cmd, resp) finally: fp.close() code, mesg = fp.parse(resp) return self.Response(code, mesg, timing, trace) # }}} # IMAP {{{
Example #9
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port, timeout): fp = Telnet() for i in range(50): try: fp.sock = socket.create_connection((host, int(port)), timeout=int(timeout), source_address=('', 1023 - i)) break except socket.error as e: if (e.errno, e.strerror) != (98, 'Address already in use'): raise e self.need_handshake = True return TCP_Connection(fp)
Example #10
Source File: database.py From sweetest with Mozilla Public License 2.0 | 5 votes |
def fetchone(self, sql): try: self.cursor.execute(sql) data = self.cursor.fetchone() self.connect.commit() return data except: logger.exception('*** Fetchone failure ***') raise
Example #11
Source File: oracle.py From Archery with Apache License 2.0 | 5 votes |
def get_connection(self, db_name=None): if self.conn: return self.conn if self.sid: dsn = cx_Oracle.makedsn(self.host, self.port, self.sid) self.conn = cx_Oracle.connect(self.user, self.password, dsn=dsn, encoding="UTF-8", nencoding="UTF-8") elif self.service_name: dsn = cx_Oracle.makedsn(self.host, self.port, service_name=self.service_name) self.conn = cx_Oracle.connect(self.user, self.password, dsn=dsn, encoding="UTF-8", nencoding="UTF-8") else: raise ValueError('sid 和 dsn 均未填写, 请联系管理页补充该实例配置.') return self.conn
Example #12
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port): # if port == 445, impacket will use <host> instead of '*SMBSERVER' as the remote_name fp = SMBConnection('*SMBSERVER', host, sess_port=int(port)) return SMB_Connection(fp)
Example #13
Source File: Database_Oracle.py From AssmentToolss with GNU General Public License v3.0 | 5 votes |
def conn_oracle(self): self.data = self.conlist try: tns_name = cx_Oracle.makedsn(self.conlist[2], self.conlist[3], "%s"%self.xe) db = cx_Oracle.connect(self.conlist[0],self.conlist[1], tns_name) return db except: self.col.printGreen(u"warning!!!!!!!!!!!!!!!!!!!\n程序出错!\n") print "\n" self.col.printRed(u"脚本连接服务器失败 ,请检查的你的用户名以及密码。或者是否数据库开启权限外链!") sys.exit()
Example #14
Source File: Database_Oracle.py From AssmentToolss with GNU General Public License v3.0 | 5 votes |
def check_statue(self): """ @函数方法:检测错误 :return: """ self.data = self.conlist try: tns_name = cx_Oracle.makedsn(self.conlist[2], self.conlist[3], "%s"%self.xe) cx_Oracle.connect(self.conlist[0], self.conlist[1], tns_name) return (10086, 'access') except Exception as e: return e
Example #15
Source File: database.py From sweetest with Mozilla Public License 2.0 | 5 votes |
def execute(self, sql): try: self.cursor.execute(sql) self.connect.commit() except: logger.exception('*** Execute failure ***') raise
Example #16
Source File: database.py From sweetest with Mozilla Public License 2.0 | 5 votes |
def __del__(self): self.connect.close()
Example #17
Source File: db.py From PythonDBAGraphs with GNU General Public License v3.0 | 5 votes |
def __init__(self,username,password,database): """ Login to database and open cursor """ connect_string = username+'/'+password+'@'+database try: self.con = cx_Oracle.connect(connect_string) except cx_Oracle.DatabaseError as e: print("Error logging in: "+str(e.args[0])) print("Username: "+username) print("Database: "+database) sys.exit(-1) self.cur = self.con.cursor() self.column_names=[]
Example #18
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port, user, password, sid): smbt = transport.SMBTransport(host, int(port), r'\lsarpc', user, password) dce = smbt.get_dce_rpc() dce.connect() dce.bind(lsat.MSRPC_UUID_LSAT) op2 = lsat.hLsarOpenPolicy2(dce, MAXIMUM_ALLOWED | lsat.POLICY_LOOKUP_NAMES) if sid is None: res = lsad.hLsarQueryInformationPolicy2(dce, op2['PolicyHandle'], lsad.POLICY_INFORMATION_CLASS.PolicyAccountDomainInformation) sid = res['PolicyInformation']['PolicyAccountDomainInfo']['DomainSid'].formatCanonical() self.sid = sid self.policy_handle = op2['PolicyHandle'] return DCE_Connection(dce, smbt)
Example #19
Source File: oraclefuz.py From d4rkc0de with GNU General Public License v2.0 | 5 votes |
def connect(): global connection link = "test/test@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.10)(PORT=1521)))" link += "(CONNECT_DATA=(SERVICE_NAME=orcl)))" connection = cx_Oracle.connect(link) connection.rollback() connection.commit()
Example #20
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
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)
Example #21
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port, timeout): self.prompt_count = 0 fp = Telnet(host, int(port), int(timeout)) return TCP_Connection(fp)
Example #22
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port, user): fp = paramiko.Transport('%s:%s' % (host, int(port))) fp.start_client() return TCP_Connection(fp, fp.remote_version)
Example #23
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
def connect(self, host, port, tls, timeout): if tls == '0': fp = FTP(timeout=int(timeout)) else: fp = FTP_TLS(timeout=int(timeout)) banner = fp.connect(host, int(port)) if tls != '0': fp.auth() return TCP_Connection(fp, banner)
Example #24
Source File: patator_ext.py From project-black with GNU General Public License v2.0 | 5 votes |
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
Example #25
Source File: oraclefuz.py From darkc0de-old-stuff with GNU General Public License v3.0 | 5 votes |
def connect(): global connection link = "test/test@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.10)(PORT=1521)))" link += "(CONNECT_DATA=(SERVICE_NAME=orcl)))" connection = cx_Oracle.connect(link) connection.rollback() connection.commit()
Example #26
Source File: oraclefuz.py From darkc0de-old-stuff with GNU General Public License v3.0 | 5 votes |
def fuzzData(data, index): global connection for x in funnydata: try: if type(x) is int: print "Data is number",x else: print "Data is " + str(x)[0:30] + " of length " + str(len(str(x))) varList = [] for var in range(index): varList.append(x) cur = connection.cursor() cur.execute(data, varList) except: error = str(sys.exc_info()[1]) if error.upper().find("ORA-00933") > -1 or error.upper().find("ORA-01756:") > -1 or error.upper().find("ORA-00923:") > -1: print "*** POSSIBLE SQL INJECTION FOUND ***" elif error.upper().find("ORA-03113") > -1: if len(str(x)) > 50: print "*** POSSIBLE BUFFER OVERFLOW ***" else: print "*** INSTANCE CRASHED ***" print "Reconnecting ... " connect() elif error.upper().find("ORA-00600") > -1: print "*** INTERNAL ERROR ***" elif error.upper().find("PLS-00306:") > -1: print "Currently unfuzzable :(" continue elif error.upper().find("ORA-03114") > -1: print "We are not connected :?" connect() print error
Example #27
Source File: oracle.py From Allscanner with MIT License | 5 votes |
def oracleburp(ip,port): addr = (ip,int(port)) with open('oracle\user.txt') as user: users = user.readlines() user.close() with open('oracle\pass.txt') as passs: passwords = passs.readlines() passs.close() sock_1521 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: sock_1521.settimeout(0.5) sock_1521.connect(addr) for un in users: un = un.strip() for pwd in passwords: pwd = pwd.strip() try: conn = cx_Oracle.connect(un, pwd, ip + ':1521/orcl') sys.stdout.write('%s:%d has Oracle SQL WeakPass, %s:%s\n' % (ip, port, un, pwd)) except Exception,e: continue except: sock_1521.close()
Example #28
Source File: OracleInterface.py From stdm with GNU General Public License v2.0 | 5 votes |
def connect(self, info): try: import cx_Oracle except: print "Missing Oracle support through cx_Oracle, see http://www.computronix.com/utilities.shtml#Oracle" return self.version = info['version'] self.conn = cx_Oracle.connect(info['user'], info['pass'], info['dbname']) self.cursor = self.conn.cursor()
Example #29
Source File: base.py From python2017 with MIT License | 5 votes |
def get_new_connection(self, conn_params): return Database.connect(self._connect_string(), **conn_params)
Example #30
Source File: databases.py From piicatcher with Apache License 2.0 | 5 votes |
def _open_connection(self): return pymysql.connect(host=self.host, port=self.port, user=self.user, password=self.password, database=self._mysql_database)