Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b14eec

Browse files
committed
Bug fix (reconnecting in case of timeouted direct connection)
1 parent 24eaf55 commit 5b14eec

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

lib/core/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,8 @@ class MKSTEMP_PREFIX:
366366
RESULTS = "sqlmapresults-"
367367
COOKIE_JAR = "sqlmapcookiejar-"
368368
BIG_ARRAY = "sqlmapbigarray-"
369+
370+
class TIMEOUT_STATE:
371+
NORMAL = 0
372+
EXCEPTION = 1
373+
TIMEOUT = 2

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.0.10.41"
22+
VERSION = "1.0.10.42"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/request/direct.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from lib.core.enums import CUSTOM_LOGGING
2525
from lib.core.enums import DBMS
2626
from lib.core.enums import EXPECTED
27+
from lib.core.enums import TIMEOUT_STATE
2728
from lib.core.settings import UNICODE_ENCODING
2829
from lib.utils.timeout import timeout
2930

@@ -51,10 +52,14 @@ def direct(query, content=True):
5152
start = time.time()
5253

5354
if not select and "EXEC " not in query.upper():
54-
_ = timeout(func=conf.dbmsConnector.execute, args=(query,), duration=conf.timeout, default=None)
55+
timeout(func=conf.dbmsConnector.execute, args=(query,), duration=conf.timeout, default=None)
5556
elif not (output and "sqlmapoutput" not in query and "sqlmapfile" not in query):
56-
output = timeout(func=conf.dbmsConnector.select, args=(query,), duration=conf.timeout, default=None)
57-
hashDBWrite(query, output, True)
57+
output, state = timeout(func=conf.dbmsConnector.select, args=(query,), duration=conf.timeout, default=None)
58+
if state == TIMEOUT_STATE.NORMAL:
59+
hashDBWrite(query, output, True)
60+
elif state == TIMEOUT_STATE.TIMEOUT:
61+
conf.dbmsConnector.close()
62+
conf.dbmsConnector.connect()
5863
elif output:
5964
infoMsg = "resumed: %s..." % getUnicode(output, UNICODE_ENCODING)[:20]
6065
logger.info(infoMsg)

lib/utils/timeout.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,29 @@
99

1010
from lib.core.data import logger
1111
from lib.core.enums import CUSTOM_LOGGING
12+
from lib.core.enums import TIMEOUT_STATE
1213

1314
def timeout(func, args=(), kwargs={}, duration=1, default=None):
1415
class InterruptableThread(threading.Thread):
1516
def __init__(self):
1617
threading.Thread.__init__(self)
1718
self.result = None
19+
self.timeout_state = None
1820

1921
def run(self):
2022
try:
2123
self.result = func(*args, **kwargs)
24+
self.timeout_state = TIMEOUT_STATE.NORMAL
2225
except Exception, msg:
2326
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, msg)
2427
self.result = default
28+
self.timeout_state = TIMEOUT_STATE.EXCEPTION
2529

2630
thread = InterruptableThread()
2731
thread.start()
2832
thread.join(duration)
2933

3034
if thread.isAlive():
31-
return default
35+
return default, TIMEOUT_STATE.TIMEOUT
3236
else:
33-
return thread.result
37+
return thread.result, thread.timeout_state

txt/checksum.md5

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ e4ca0fd47f20cf7ba6a5f5cbf980073c lib/core/decorators.py
3434
67f206cf2658145992cc1d7020138325 lib/core/defaults.py
3535
3b2c013b610c5ae3193ced4f19bf1931 lib/core/dicts.py
3636
1f98d3f57ce21d625fd67adb26cfd13c lib/core/dump.py
37-
1128705f593013359497b3959078b650 lib/core/enums.py
37+
b218e03ef7426fb0414881b05add1092 lib/core/enums.py
3838
e4aec2b11c1ad6039d0c3dbbfbc5eb1a lib/core/exception.py
3939
cc9c82cfffd8ee9b25ba3af6284f057e lib/core/__init__.py
4040
91c514013daa796e2cdd940389354eac lib/core/log.py
@@ -45,7 +45,7 @@ e60456db5380840a586654344003d4e6 lib/core/readlineng.py
4545
5ef56abb8671c2ca6ceecb208258e360 lib/core/replication.py
4646
99a2b496b9d5b546b335653ca801153f lib/core/revision.py
4747
7c15dd2777af4dac2c89cab6df17462e lib/core/session.py
48-
3f7524efc2c224678608ae14f372b009 lib/core/settings.py
48+
49b872986ac8a016a5ec7e378eaac419 lib/core/settings.py
4949
7af83e4f18cab6dff5e67840eb65be80 lib/core/shell.py
5050
23657cd7d924e3c6d225719865855827 lib/core/subprocessng.py
5151
c3ace7874a536d801f308cf1fd03df99 lib/core/target.py
@@ -68,7 +68,7 @@ b40a4c5d91770d347df36d3065b63798 lib/parse/sitemap.py
6868
083e7f446909b12009e72ae8e5e5737c lib/request/basic.py
6969
c48285682a61d49982cb508351013cb4 lib/request/comparison.py
7070
fa20d4d117875f9769ef49256d4da61f lib/request/connect.py
71-
49b4c583af68689de5f9acb162de2939 lib/request/direct.py
71+
d4d52c1073c75a6eecd2ebb98b670b96 lib/request/direct.py
7272
1a46f7bb26b23ec0c0d9d9c95828241b lib/request/dns.py
7373
70ceefe39980611494d4f99afb96f652 lib/request/httpshandler.py
7474
cc9c82cfffd8ee9b25ba3af6284f057e lib/request/__init__.py
@@ -112,7 +112,7 @@ da08a0b58c08ff452c7d1da4857d6680 lib/utils/progress.py
112112
4c8895fb543aa5ae81f2d066422613f0 lib/utils/purge.py
113113
cc9b0f68dd58a2576a5a454b7f5f6b9c lib/utils/search.py
114114
4a0374ac0bc9d726446f04c77fbb5697 lib/utils/sqlalchemy.py
115-
8013e4a4c62ad916452434ea3c352a7a lib/utils/timeout.py
115+
93dc08ba9f732d378f02cf85eae89df2 lib/utils/timeout.py
116116
e6fa0e76367a77015da113811dfd9712 lib/utils/versioncheck.py
117117
adafdb28095ba2d03322fee2aae4548f lib/utils/xrange.py
118118
988100b4a1cd3b07acfd8b6ec692aed5 plugins/dbms/access/connector.py

0 commit comments

Comments
 (0)