Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
X-OVH-SPAMCAUSE decoder
def decode(msg):
text = []
for i in range(0, len(msg), 2):
text.append(unrot(msg[i: i + 2]))
return str.join('', text)
def unrot(pair, key=ord('x')):
offset = 0
for c in 'cdefgh':
if c in pair:
offset = (ord('g') - ord(c)) * 16
break
return chr(sum(ord(c) for c in pair) - key - offset)
if __name__ == '__main__':
import sys
print(decode(sys.argv[1]))
@DoubleYouEl

This comment has been minimized.

Copy link

@DoubleYouEl DoubleYouEl commented Mar 23, 2021

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. Check my fork for an update.

@plegrand1

This comment has been minimized.

Copy link

@plegrand1 plegrand1 commented Aug 26, 2021

Hello,
can you explain me how to use it ?
where i have to put the spamcause string ?
Thanks for your help

@DoubleYouEl

This comment has been minimized.

Copy link

@DoubleYouEl DoubleYouEl commented Aug 26, 2021

The spamcause string is the parameter of the decode function, given as command line parameter in the main.
So in most Python environments, you could use the following:
python spam_decode.py "spamcause string"
(but without the quotes)

@plegrand1

This comment has been minimized.

Copy link

@plegrand1 plegrand1 commented Aug 26, 2021

Hello and thanks for your answer

you mean
python spam_decode.py my_very_long_string ?

@plegrand1

This comment has been minimized.

Copy link

@plegrand1 plegrand1 commented Aug 26, 2021

yes thanks a lot it works fine !

@plegrand1

This comment has been minimized.

Copy link

@plegrand1 plegrand1 commented Aug 26, 2021

Just to know, is it normal that the result is truncated
Thanks again

@DoubleYouEl

This comment has been minimized.

Copy link

@DoubleYouEl DoubleYouEl commented Aug 27, 2021

Can you provide an example? In principle, the entire spamcause string is parsed and decoded.

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