'logic from JPCERTCC emdivi_postdata_decoder.py'

def decode_payload(self, payload):

    decoded = defaultdict()
    if (';' in payload):
        delim = ';'
    else:
        delim = '&'
    fields = [x for x in payload.split(delim) if x]
    for field in fields:
        try:
            (name, value) = field.split('=')
        except ValueError:
            continue
        xor_key = 0
        for c in name:
            xor_key = (ord(c) ^ xor_key)
        plaintext = ''
        for c in urllib.unquote(value):
            plaintext += chr((ord(c) ^ xor_key))
        decoded[name] = plaintext
    return decoded
