Created
June 27, 2024 19:57
-
-
Save embeddinglayer/f3a63728fca77a9b9b5286aa61fe37fc to your computer and use it in GitHub Desktop.
Cloudflare obfuscated email decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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