SIGN IN SIGN UP
sqlmapproject / sqlmap UNCLAIMED

Automatic SQL injection and database takeover tool

0 0 5 Python
2010-04-06 14:33:57 +00:00
#!/usr/bin/env python
import threading
2010-04-06 14:59:31 +00:00
def timeout(func, args=(), kwargs={}, duration=1, default=None):
2010-04-06 14:33:57 +00:00
class InterruptableThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
2010-04-06 14:59:31 +00:00
self.exceeded = False
2010-04-06 14:33:57 +00:00
self.result = None
def run(self):
try:
self.result = func(*args, **kwargs)
2010-04-06 15:12:52 +00:00
except:
2010-04-06 14:33:57 +00:00
self.result = default
thread = InterruptableThread()
thread.start()
2010-04-06 14:59:31 +00:00
thread.join(duration)
self.exceeded = thread.isAlive()
if self.exceeded:
2010-04-06 14:33:57 +00:00
return default
else:
return thread.result