Skip to content

Instantly share code, notes, and snippets.

@embeddinglayer
Created June 27, 2024 19:57
Show Gist options
  • Select an option

  • Save embeddinglayer/f3a63728fca77a9b9b5286aa61fe37fc to your computer and use it in GitHub Desktop.

Select an option

Save embeddinglayer/f3a63728fca77a9b9b5286aa61fe37fc to your computer and use it in GitHub Desktop.
Cloudflare obfuscated email decoder
def decode_cf_email(encoded: str) -> str:
"""Decode Cloudflare obfuscate email address.
"""
def r(e: str, t: int):
return int(e[t : t + 2], 16)
def decode(n: str, offset: int)-> str:
result = ""
key = r(n, offset)
for i in range(offset + 2, len(n), 2):
char = r(n, i) ^ key
result += chr(char)
return result
if encoded.startswith("/cdn-cgi/l/email-protection#"):
encoded = encoded[len("/cdn-cgi/l/email-protection#") :]
return decode(encoded, 0)
else:
raise ValueError("Invalid encoded email format")
#decode_cf_email("/cdn-cgi/l/email-protection#HEX_STR...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment