Skip to content

Instantly share code, notes, and snippets.

@incogbyte
Created January 27, 2025 11:28
Show Gist options
  • Save incogbyte/1004a8d00ad662dea602ff7a27290e14 to your computer and use it in GitHub Desktop.
Save incogbyte/1004a8d00ad662dea602ff7a27290e14 to your computer and use it in GitHub Desktop.
Python script that generates diff encodings techniques. Those techniques can be used to bypass HTTP WAF.
import urllib.parse
"""
By @incogbyte
Python script that generates diff encodings techniques.
Those techniques can be used to bypass HTTP WAF.
"""
def generate_encodings(input_string):
encodings = {}
# 1. Standard Percent-Encoding
percent_encoded = urllib.parse.quote(input_string)
encodings["Percent-Encoding"] = percent_encoded
# 2. Double Percent-Encoding
double_percent_encoded = urllib.parse.quote(percent_encoded)
encodings["Double Percent-Encoding"] = double_percent_encoded
# 3. Second Nibble Hex Encoding
second_nibble_encoded = ''.join(
f"%{char[-1]}" if len(char) == 2 else char for char in percent_encoded.split('%') if char
)
encodings["Second Nibble Hex Encoding"] = second_nibble_encoded
# 4. UTF-16 Encoding
utf16_encoded = ''.join(f"%{hex(ord(char))[2:].zfill(4).upper()}" for char in input_string)
encodings["UTF-16 Encoding"] = utf16_encoded
# 5. Unicode Escaped Encoding
unicode_escaped = ''.join(f"%u{ord(char):04X}" for char in input_string)
encodings["Unicode Escaped Encoding"] = unicode_escaped
# 6. Mixed Encodings
mixed_encoding = ''.join(
f"%{hex(ord(char))[2:].upper() if i % 2 == 0 else char}"
for i, char in enumerate(input_string)
)
encodings["Mixed Encoding"] = mixed_encoding
# 7. Over-encoded (Triple Percent-Encoding)
triple_percent_encoded = urllib.parse.quote(double_percent_encoded)
encodings["Triple Percent-Encoding"] = triple_percent_encoded
# 8. Space Encodings (Specific Case)
space_replaced = input_string.replace(" ", "%20").replace(" ", "+")
encodings["Space Encodings"] = space_replaced
return encodings
if __name__ == "__main__":
print("[*] Enter the string to encode:")
user_input = input().strip()
print("\nGenerated Encodings:\n")
encodings = generate_encodings(user_input)
for encoding_type, encoded_value in encodings.items():
print(f"{encoding_type}:\n{encoded_value}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment