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

Skip to content

Commit 17db587

Browse files
committed
Adding some friendly warning messages (regarding blocking)
1 parent 821e4bf commit 17db587

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/core/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,6 +2832,10 @@ def showHttpErrorCodes():
28322832
if code in httplib.responses else '?', count) \
28332833
for code, count in kb.httpErrorCodes.items())
28342834
logger.warn(warnMsg)
2835+
if any(str(_).startswith('4') or str(_).startswith('5') for _ in kb.httpErrorCodes.keys()):
2836+
msg = "too many 4xx and/or 5xx HTTP error codes "
2837+
msg += "usually means that some kind of protection is involved (e.g. WAF)"
2838+
logger.warn(msg)
28352839

28362840
def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="replace"):
28372841
"""

lib/core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
# Regular expression used for recognition of IP addresses
8080
IP_ADDRESS_REGEX = r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
8181

82+
# Regular expression used for recognition of generic "your ip has been blocked" messages
83+
BLOCKED_IP_REGEX = r"(?i)(\A|\b)ip\b.*\b(banned|blocked|block list|firewall)"
84+
8285
# Dumping characters used in GROUP_CONCAT MySQL technique
8386
CONCAT_ROW_DELIMITER = ','
8487
CONCAT_VALUE_DELIMITER = '|'
@@ -541,7 +544,7 @@
541544
CHECK_ZERO_COLUMNS_THRESHOLD = 10
542545

543546
# Boldify all logger messages containing these "patterns"
544-
BOLD_PATTERNS = ("' injectable", "might be injectable", "' is vulnerable", "is not injectable", "test failed", "test passed", "live test final result", "test shows that", "the back-end DBMS is", "created Github")
547+
BOLD_PATTERNS = ("' injectable", "might be injectable", "' is vulnerable", "is not injectable", "test failed", "test passed", "live test final result", "test shows that", "the back-end DBMS is", "created Github", "blocked by the target server", "protection is involved")
545548

546549
# Generic www root directory names
547550
GENERIC_DOC_ROOT_DIRECTORY_NAMES = ("htdocs", "httpdocs", "public", "wwwroot", "www")

lib/request/basic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from lib.core.enums import HTTP_HEADER
2828
from lib.core.enums import PLACE
2929
from lib.core.exception import SqlmapCompressionException
30+
from lib.core.settings import BLOCKED_IP_REGEX
3031
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
3132
from lib.core.settings import EVENTVALIDATION_REGEX
3233
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
@@ -305,6 +306,8 @@ def _(match):
305306
def processResponse(page, responseHeaders):
306307
kb.processResponseCounter += 1
307308

309+
page = page or ""
310+
308311
parseResponse(page, responseHeaders if kb.processResponseCounter < PARSE_HEADERS_LIMIT else None)
309312

310313
if conf.parseErrors:
@@ -323,3 +326,7 @@ def processResponse(page, responseHeaders):
323326
continue
324327
conf.paramDict[PLACE.POST][name] = value
325328
conf.parameters[PLACE.POST] = re.sub("(?i)(%s=)[^&]+" % name, r"\g<1>%s" % value, conf.parameters[PLACE.POST])
329+
330+
if re.search(BLOCKED_IP_REGEX, page):
331+
errMsg = "it appears that you have been blocked by the target server"
332+
singleTimeLogMessage(errMsg, logging.ERROR)

0 commit comments

Comments
 (0)