Skip to content

Instantly share code, notes, and snippets.

@DoubleYouEl
Forked from lkraider/spam_decode.py
Last active January 23, 2024 15:55
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DoubleYouEl/e3de97293ce3d5452b3be7a336a06ad7 to your computer and use it in GitHub Desktop.
Save DoubleYouEl/e3de97293ce3d5452b3be7a336a06ad7 to your computer and use it in GitHub Desktop.
X-OVH-SPAMCAUSE decoder
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]))
@DoubleYouEl
Copy link
Author

You could just use this main program, instead of using the sys.argv-approach:

spamcause = <your very long string between quotes>
print(decode(spamcause))

@mqu
Copy link

mqu commented Mar 24, 2023

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment