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

Skip to content

Commit 12012b3

Browse files
committed
Automatic disabling of socket-preconnect for known problematic server (SimpleHTTPServer)
1 parent 43c9e21 commit 12012b3

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

lib/controller/checks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
from lib.core.settings import IDS_WAF_CHECK_TIMEOUT
8989
from lib.core.settings import MAX_DIFFLIB_SEQUENCE_LENGTH
9090
from lib.core.settings import NON_SQLI_CHECK_PREFIX_SUFFIX_LENGTH
91+
from lib.core.settings import PRECONNECT_INCOMPATIBLE_SERVERS
9192
from lib.core.settings import SLEEP_TIME_MARKER
9293
from lib.core.settings import SUHOSIN_MAX_VALUE_LENGTH
9394
from lib.core.settings import SUPPORTED_DBMS
@@ -1554,6 +1555,10 @@ def checkConnection(suppressOutput=False):
15541555

15551556
kb.errorIsNone = False
15561557

1558+
if any(_ in (kb.serverHeader or "") for _ in PRECONNECT_INCOMPATIBLE_SERVERS):
1559+
singleTimeWarnMessage("turning off pre-connect mechanism because of incompatible server ('%s')" % kb.serverHeader)
1560+
conf.disablePrecon = True
1561+
15571562
if not kb.originalPage and wasLastResponseHTTPError():
15581563
errMsg = "unable to retrieve page content"
15591564
raise SqlmapConnectionException(errMsg)

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
18521852
kb.safeCharEncode = False
18531853
kb.safeReq = AttribDict()
18541854
kb.secondReq = None
1855+
kb.serverHeader = None
18551856
kb.singleLogFlags = set()
18561857
kb.skipSeqMatcher = False
18571858
kb.reduceTests = None

lib/core/settings.py

Lines changed: 4 additions & 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.2.9.0"
22+
VERSION = "1.2.9.1"
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)
@@ -97,6 +97,9 @@
9797
# Timeout before the pre-connection candidate is being disposed (because of high probability that the web server will reset it)
9898
PRECONNECT_CANDIDATE_TIMEOUT = 10
9999

100+
# Servers known to cause issue with pre-connection mechanism (because of lack of multi-threaded support)
101+
PRECONNECT_INCOMPATIBLE_SERVERS = ("SimpleHTTP",)
102+
100103
# Maximum sleep time in "Murphy" (testing) mode
101104
MAX_MURPHY_SLEEP_TIME = 3
102105

lib/request/connect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ class _(dict):
493493
code = (code or conn.code) if conn.code == kb.originalCode else conn.code # do not override redirection code (for comparison purposes)
494494
responseHeaders = conn.info()
495495
responseHeaders[URI_HTTP_HEADER] = conn.geturl()
496+
kb.serverHeader = responseHeaders.get(HTTP_HEADER.SERVER, kb.serverHeader)
496497
else:
497498
code = None
498499
responseHeaders = {}

txt/checksum.md5

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ b3e60ea4e18a65c48515d04aab28ff68 extra/sqlharvest/sqlharvest.py
2424
1e5532ede194ac9c083891c2f02bca93 extra/wafdetectify/__init__.py
2525
0142de525def5e3f17092dcc1ed67c95 extra/wafdetectify/wafdetectify.py
2626
3459c562a6abb9b4bdcc36925f751f3e lib/controller/action.py
27-
7493c782345a60f6c00c9281d51a494e lib/controller/checks.py
27+
2058987606ad75435c69d28cab11ef9e lib/controller/checks.py
2828
c414cecdb0472c92cf50ed5b01e4438c lib/controller/controller.py
2929
c7443613a0a2505b1faec931cee2a6ef lib/controller/handler.py
3030
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
@@ -43,14 +43,14 @@ cada93357a7321655927fc9625b3bfec lib/core/exception.py
4343
1e5532ede194ac9c083891c2f02bca93 lib/core/__init__.py
4444
458a194764805cd8312c14ecd4be4d1e lib/core/log.py
4545
7d6edc552e08c30f4f4d49fa93b746f1 lib/core/optiondict.py
46-
6826030069e1cd88eb87603a50b2d251 lib/core/option.py
46+
62fb1b8e7a82c726eb9631daac4c82e9 lib/core/option.py
4747
c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4848
6783160150b4711d02c56ee2beadffdb lib/core/profiling.py
4949
6f654e1715571eff68a0f8af3d62dcf8 lib/core/readlineng.py
5050
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
5151
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5252
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
53-
bdb6b2b1b842c4f5e2874fe3a199f648 lib/core/settings.py
53+
153ad66f2a6789909f4a4702650397dc lib/core/settings.py
5454
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
5555
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5656
815d1cf27f0f8738d81531e73149867d lib/core/target.py
@@ -72,7 +72,7 @@ f2af274126ce0a789027d35d367f2b9e lib/parse/payloads.py
7272
30eed3a92a04ed2c29770e1b10d39dc0 lib/request/basicauthhandler.py
7373
2b81435f5a7519298c15c724e3194a0d lib/request/basic.py
7474
859b6ad583e0ffba154f17ee179b5b89 lib/request/comparison.py
75-
e284905d23658b85e94a5dd37bfb80b2 lib/request/connect.py
75+
4ac4e1d10210bb1bc3d64a3532c5ff8b lib/request/connect.py
7676
dd4598675027fae99f2e2475b05986da lib/request/direct.py
7777
2044fce3f4ffa268fcfaaf63241b1e64 lib/request/dns.py
7878
98535d0efca5551e712fcc4b34a3f772 lib/request/httpshandler.py

0 commit comments

Comments
 (0)