Skip to content

Commit 8acf033

Browse files
committed
Code refactoring
1 parent a3d9a7b commit 8acf033

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎lib/controller/checks.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,7 @@ def _(*args, **kwargs):
10691069
if kwargs.get("get"):
10701070
kwargs["get"] = urlencode(kwargs["get"])
10711071
kwargs["raise404"] = False
1072+
kwargs["silent"] = True
10721073
page, headers, code = Request.getPage(*args, **kwargs)
10731074
except Exception:
10741075
pass

‎lib/core/settings.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
# Default value for HTTP Accept-Encoding header
8787
HTTP_ACCEPT_ENCODING_HEADER_VALUE = "gzip,deflate"
8888

89-
# HTTP timeout in silent mode
90-
HTTP_SILENT_TIMEOUT = 3
89+
# Default timeout for running commands over backdoor
90+
BACKDOOR_RUN_CMD_TIMEOUT = 5
9191

9292
# Maximum number of techniques used in inject.py/getValue() per one value
9393
MAX_TECHNIQUES_PER_VALUE = 2

‎lib/request/connect.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
from lib.core.settings import DEFAULT_GET_POST_DELIMITER
6868
from lib.core.settings import HTTP_ACCEPT_HEADER_VALUE
6969
from lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUE
70-
from lib.core.settings import HTTP_SILENT_TIMEOUT
7170
from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE
7271
from lib.core.settings import MAX_CONNECTIONS_REGEX
7372
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
@@ -204,6 +203,7 @@ def getPage(**kwargs):
204203
multipart = kwargs.get("multipart", False)
205204
silent = kwargs.get("silent", False)
206205
raise404 = kwargs.get("raise404", True)
206+
timeout = kwargs.get("timeout", conf.timeout)
207207
auxHeaders = kwargs.get("auxHeaders", None)
208208
response = kwargs.get("response", False)
209209
ignoreTimeout = kwargs.get("ignoreTimeout", kb.ignoreTimeout)
@@ -248,10 +248,7 @@ def getPage(**kwargs):
248248
url = unicodeencode(url)
249249

250250
try:
251-
if silent:
252-
socket.setdefaulttimeout(HTTP_SILENT_TIMEOUT)
253-
else:
254-
socket.setdefaulttimeout(conf.timeout)
251+
socket.setdefaulttimeout(timeout)
255252

256253
if direct_:
257254
if "?" in url:
@@ -529,14 +526,16 @@ def getPage(**kwargs):
529526
if "BadStatusLine" not in tbMsg:
530527
warnMsg += " or proxy"
531528

532-
if "forcibly closed" in tbMsg:
529+
if silent:
530+
return None, None, None
531+
elif "forcibly closed" in tbMsg:
533532
logger.critical(warnMsg)
534533
return None, None, None
535-
elif silent or (ignoreTimeout and any(_ in tbMsg for _ in ("timed out", "IncompleteRead"))):
534+
elif ignoreTimeout and any(_ in tbMsg for _ in ("timed out", "IncompleteRead")):
536535
return None, None, None
537536
elif threadData.retriesCount < conf.retries and not kb.threadException:
538537
warnMsg += ". sqlmap is going to retry the request"
539-
logger.log(logging.CRITICAL if not conf.identifyWaf else logging.DEBUG, warnMsg)
538+
logger.critical(warnMsg)
540539
return Connect._retryProxy(**kwargs)
541540
elif kb.testMode:
542541
logger.critical(warnMsg)

‎lib/takeover/web.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from lib.core.enums import OS
4242
from lib.core.enums import PAYLOAD
4343
from lib.core.enums import WEB_API
44+
from lib.core.settings import BACKDOOR_RUN_CMD_TIMEOUT
4445
from lib.core.settings import EVENTVALIDATION_REGEX
4546
from lib.core.settings import VIEWSTATE_REGEX
4647
from lib.request.connect import Connect as Request
@@ -71,7 +72,7 @@ def webBackdoorRunCmd(self, cmd):
7172
cmd = conf.osCmd
7273

7374
cmdUrl = "%s?cmd=%s" % (self.webBackdoorUrl, cmd)
74-
page, _, _ = Request.getPage(url=cmdUrl, direct=True, silent=True)
75+
page, _, _ = Request.getPage(url=cmdUrl, direct=True, silent=True, timeout=BACKDOOR_RUN_CMD_TIMEOUT)
7576

7677
if page is not None:
7778
output = re.search("<pre>(.+?)</pre>", page, re.I | re.S)

0 commit comments

Comments
 (0)