some update

This commit is contained in:
Miroslav Stampar 2010-04-06 14:59:31 +00:00
parent 60f04f0a41
commit c24f1cc07c
8 changed files with 45 additions and 39 deletions

View File

@ -2,22 +2,26 @@
import threading
def timeout(func, args=(), kwargs={}, timeout_duration=1, default=None):
def timeout(func, args=(), kwargs={}, duration=1, default=None):
class InterruptableThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.exceeded = False
self.exceptionMsg = None
self.result = None
def run(self):
try:
self.result = func(*args, **kwargs)
except:
except Exception, msg:
self.exceptionMsg = msg
self.result = default
thread = InterruptableThread()
thread.start()
thread.join(timeout_duration)
if thread.isAlive():
thread.join(duration)
self.exceeded = thread.isAlive()
if self.exceeded:
return default
else:
return thread.result

View File

@ -30,6 +30,7 @@ except ImportError, _:
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -60,11 +61,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except pyodbc.ProgrammingError, msg:
logger.log(8, msg[1])
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg[1])
return retVal
def execute(self, query):
logger.debug(query)

View File

@ -30,6 +30,7 @@ except ImportError, _:
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -59,11 +60,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except kinterbasdb.OperationalError, msg:
logger.log(8, msg[1])
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg[1])
return retVal
def execute(self, query):
logger.debug(query)

View File

@ -31,6 +31,7 @@ except ImportError, _:
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -63,11 +64,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except (pymssql.ProgrammingError, pymssql.OperationalError, _mssql.MssqlDatabaseException), msg:
logger.log(8, msg)
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg)
return retVal
def execute(self, query):
logger.debug(query)

View File

@ -30,6 +30,7 @@ except ImportError, _:
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -59,11 +60,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except MySQLdb.ProgrammingError, msg:
logger.log(8, msg[1])
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg[1])
return retVal
def execute(self, query):
logger.debug(query)

View File

@ -27,8 +27,10 @@ try:
except ImportError, _:
pass
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -60,11 +62,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except cx_Oracle.InterfaceError, msg:
logger.log(8, msg)
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg)
return retVal
def execute(self, query):
logger.debug(query)

View File

@ -27,8 +27,10 @@ try:
except ImportError, _:
pass
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -58,11 +60,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except psycopg2.ProgrammingError, msg:
logger.log(8, msg)
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg)
return retVal
def execute(self, query):
logger.debug(query)

View File

@ -30,6 +30,7 @@ except ImportError, _:
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.utils.timeout import timeout
from plugins.generic.connector import Connector as GenericConnector
@ -60,11 +61,10 @@ class Connector(GenericConnector):
self.connected()
def fetchall(self):
try:
return self.cursor.fetchall()
except sqlite3.OperationalError, msg:
logger.log(8, msg[0])
return None
retVal = timeout(func=self.cursor.fetchall, duration=conf.timeout, default=None)
if self.exceptionMsg:
logger.log(8, self.exceptionMsg[0])
return retVal
def execute(self, query):
logger.debug(query)