Skip to content

Commit f2f7994

Browse files
committed
Minor improvement of generic WAF script
1 parent 42ddfd8 commit f2f7994

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

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.1.12.21"
22+
VERSION = "1.1.12.22"
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)
@@ -84,6 +84,9 @@
8484
# Regular expression used for recognition of generic permission messages
8585
PERMISSION_DENIED_REGEX = r"(command|permission|access)\s*(was|is)?\s*denied"
8686

87+
# Regular expression used in recognition of generic protection mechanisms
88+
GENERIC_PROTECTION_REGEX = r"(?i)\b(rejected|blocked|protection|incident|denied|detected|dangerous|firewall)\b"
89+
8790
# Regular expression used for recognition of generic maximum connection messages
8891
MAX_CONNECTIONS_REGEX = r"\bmax.+?\bconnection"
8992

txt/checksum.md5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ f872699e948d0692ce11b54781da814c lib/core/log.py
4646
760d9df2a27ded29109b390ab202e72d lib/core/replication.py
4747
a2466b62e67f8b31736bac4dac590e51 lib/core/revision.py
4848
02d4762140a72fd44668d3dab5eabda9 lib/core/session.py
49-
8876dee2d5d1f9efbb520c78849b9a3a lib/core/settings.py
49+
ea5aa15bc9cc2d2dc1b68c6e8121b650 lib/core/settings.py
5050
35bffbad762eb9e03db9e93b1c991103 lib/core/shell.py
5151
a59ec28371ae067a6fdd8f810edbee3d lib/core/subprocessng.py
5252
d93501771b41315f9fb949305b6ed257 lib/core/target.py
@@ -407,7 +407,7 @@ d3aa7e5b222811f90c75aa8a0db509a3 waf/dosarrest.py
407407
f4883f1443676f5291b1ef3e2cf0cbfd waf/edgecast.py
408408
cd558b27d5bc4e42fcd5571d8c9c3a10 waf/expressionengine.py
409409
6ccb307f53f878eacf9d08d0e97738e2 waf/fortiweb.py
410-
daf5235e066e18c0d9ba9f9b5bc9e47b waf/generic.py
410+
37c81331b70c755610a5c70ead8fc7b6 waf/generic.py
411411
200d859893c4e84fbae9c32d5099ab65 waf/hyperguard.py
412412
ced90975810f7f68103d38523567ab3f waf/incapsula.py
413413
5fb9aaf874daa47ea2b672a22740e56b waf/__init__.py

waf/generic.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8-
from lib.core.option import kb
8+
import re
9+
10+
from lib.core.data import kb
11+
from lib.core.settings import GENERIC_PROTECTION_REGEX
912
from lib.core.settings import IDS_WAF_CHECK_PAYLOAD
1013
from lib.core.settings import WAF_ATTACK_VECTORS
1114

@@ -14,14 +17,14 @@
1417
def detect(get_page):
1518
retval = False
1619

17-
page, headers, code = get_page()
18-
if page is None or code >= 400:
20+
original, _, code = get_page()
21+
if original is None or code >= 400:
1922
return False
2023

2124
for vector in WAF_ATTACK_VECTORS:
22-
page, _, code = get_page(get=vector)
25+
page, headers, code = get_page(get=vector)
2326

24-
if code >= 400 or IDS_WAF_CHECK_PAYLOAD in vector and code is None:
27+
if code >= 400 or (IDS_WAF_CHECK_PAYLOAD in vector and (code is None or re.search(GENERIC_PROTECTION_REGEX, page or "") and not re.search(GENERIC_PROTECTION_REGEX, original or ""))):
2528
if code is not None:
2629
kb.wafSpecificResponse = "HTTP/1.1 %s\n%s\n%s" % (code, "".join(_ for _ in headers.headers or [] if not _.startswith("URI")), page)
2730

0 commit comments

Comments
 (0)