-
-
Save DoubleYouEl/e3de97293ce3d5452b3be7a336a06ad7 to your computer and use it in GitHub Desktop.
X-OVH-SPAMCAUSE decoder
This file contains 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(msg): | |
text = "" | |
for i in range(0, len(msg), 2): | |
text += unrot(msg[i: i + 2], i // 2) # add position as extra parameter | |
return text | |
def unrot(pair, pos, key=ord('x')): | |
if pos % 2 == 0: # "even" position => 2nd char is offset | |
pair = pair[1] + pair[0] # swap letters in pair | |
offset = (ord('g') - ord(pair[0])) * 16 # treat 1st char as offset | |
return chr(sum(ord(c) for c in pair) - key - offset) # map to original character | |
if __name__ == '__main__': | |
import sys | |
print(decode(sys.argv[1])) |
Hello. I need to decode a SPAMCAUSE looong string . How can i do this ?
Hello. I need to decode a SPAMCAUSE looong string . How can i do this ?
It depends: how long is this long string? You could copy-paste it into the python code and use it as value to assign to a variable (instead of passing it as an argument).
Thank you for reply.It is indeed very long. Is it correct to enter the long string on the first line :def decode(the_long_string): ?
Sent from Yahoo Mail on Android
On Thu., 17 Nov. 2022 at 5:55 p.m., ***@***.***> wrote:
Re: ***@***.*** commented on this gist.
Hello. I need to decode a SPAMCAUSE looong string . How can i do this ?
It depends: how long is this long string? You could copy-paste it into the python code and use it as value to assign to a variable (instead of passing it as an argument).
—
Reply to this email directly, view it on GitHub or unsubscribe.
You are receiving this email because you commented on a thread.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You could just use this main program, instead of using the sys.argv
-approach:
spamcause = <your very long string between quotes>
print(decode(spamcause))
an other way to use this script:
- feed spamcause header in a file whithout "X-VR-SPAMCAUSE: "
- then run
python3 ./ovh-spam-cause.py $(cat /tmp/temp-file) | sed -e "s/;/\n/g"
Here's an online version : https://f3hj7s.csb.app
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The offset characters (c..g) are alternatingly appended and prepended. So instead of just checking if one of them is in the pair, it is necessary to differentiate between, e.g., fh and hf, by keeping track of even or odd pairs.