Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pandora

Name: Anonymous 2008-01-24 20:22

# pandora.com v15 xmlrpc encrypt/decrypt routines
# for data sent to /radio/xmlrpc/v15 in a POST
# usage:
#   _xmlrpc_request_ = pandora_decrypt(_POST_data_)
#   _POST_data_ = pandora_encrypt(_xmlrpc_request_)

P = [0x62b25781, 0x36c6e49e, 0x79cecc68, 0x16a94f4, 0xb23506e5, 0xf3209930, 0x31cc9e6f, 0xf9c1c6f, 0x3ada9d11, 0xf8b18ccf, 0x8788eb, 0x3433eb64, 0x1bccf5a3, 0xdf91b435, 0xa50ea6fa, 0x8c069dcc, 0x1ff83b56, 0xa75abeba]

S = [[],[],[],[]]

S[0] =
see post >>2

S[1] =
see post >>3

S[2] =
see post >>4

S[3] =
see post >>5

def blowfish_round_function(XL):
    F = S[0][XL>
>24]
    F += S[1][(XL>
>16)&0xff]
    F &= 0xffffffff
    F ^= S[2][(XL>
>8)&0xff]
    F += S[3][XL&0xff]
    F &= 0xffffffff
    return F

def blowfish_block_decrypt(XL, XR):
    for i in xrange(17, 1, -1):
            XL ^= P[i]
            XR ^= blowfish_round_function(XL)
            XL, XR = XR, XL
    XL, XR = XR, XL
    XR ^= P[1]
    XL ^= P[0]
    return [XL, XR]

def blowfish_block_encrypt(XL, XR):
    for i in xrange(16):
            XL ^= P[i]
            XR ^= blowfish_round_function(XL)
            XL, XR = XR, XL
    XL, XR = XR, XL
    XR ^= P[16]
    XL ^= P[17]
    return [XL, XR]

def blowfish_intlist_decrypt(Li):
    Lo = []
    for i in xrange(0, len(Li), 2):
        Lo.extend(blowfish_block_decrypt(Li[i], Li[i+1]))
    return Lo

def blowfish_intlist_encrypt(Li):
    Lo = []
    for i in xrange(0, len(Li), 2):
        Lo.extend(blowfish_block_encrypt(Li[i], Li[i+1]))
    return Lo

def hexstr_to_intlist(H):
    L = []
    Hl = len(H)
    Hm = Hl%8
    for i in xrange(0, Hl-Hm, 8):
        L.append(int(H[i:i+8],16))
    if Hm > 0:
        L.append(int(H[Hl-Hm:]+('0'*(8-Hm)),16))
    return L

def intlist_to_hexstr(L):
    H = ""
    for I in L:
        s = hex(I).replace('0x','').replace('L','')
        H += ('0'*(8-len(s)))+s
    return H

def str_to_intlist(S):
    L = []
    Sl = len(s)
    Sm = Sl%4
    if Sm > 0:
        S += chr(0)*(4-Sm)
    for i in xrange(0, len(S), 4):
        L.append((ord(S[i])<<24)+(ord(S[i+1])<<16)+(ord(S[i+2])<<8)+ord(S[i+3]))
    return L

def intlist_to_str(L):
    S = ""
    for I in L:
        S += chr(I>
>24&0xff)+chr(I>>16&0xff)+chr(I>>8&0xff)+chr(I&0xff)
    return S

def pandora_encrypt(S):
    return intlist_to_hexstr(blowfish_intlist_encrypt(str_to_intlist(S)))

def pandora_decrypt(H):
    return intlist_to_str(blowfish_intlist_decrypt(hexstr_to_intlist(H)))

Name: Anonymous 2008-01-25 11:25

### pandora.com xmlrpc routines (v15)

P = [0x62b25781, 0x36c6e49e, 0x79cecc68, 0x16a94f4, 0xb23506e5, 0xf3209930, 0x31cc9e6f, 0xf9c1c6f, 0x3ada9d11, 0xf8b18ccf, 0x8788eb, 0x3433eb64, 0x1bccf5a3, 0xdf91b435, 0xa50ea6fa, 0x8c069dcc, 0x1ff83b56, 0xa75abeba]

S = [[],[],[],[]]

S[0] =
(see post >>2)
S[1] =
(see post >>3)
S[2] =
(see post >>4)
S[3] =
(see post >>5)

def blowfish_round_function(XL):
    F = S[0][XL>
>24]
    F += S[1][(XL>
>16)&0xff]
    F &= 0xffffffff
    F ^= S[2][(XL>
>8)&0xff]
    F += S[3][XL&0xff]
    F &= 0xffffffff
    return F

def blowfish_block_decrypt(XL, XR):
    for i in xrange(17, 1, -1):
            XL ^= P[i]
            XR ^= blowfish_round_function(XL)
            XL, XR = XR, XL
    XL, XR = XR, XL
    XR ^= P[1]
    XL ^= P[0]
    return [XL, XR]

def blowfish_block_encrypt(XL, XR):
    for i in xrange(16):
            XL ^= P[i]
            XR ^= blowfish_round_function(XL)
            XL, XR = XR, XL
    XL, XR = XR, XL
    XR ^= P[16]
    XL ^= P[17]
    return [XL, XR]

def blowfish_intlist_decrypt(Li):
    Lo = []
    for i in xrange(0, len(Li), 2):
        Lo.extend(blowfish_block_decrypt(Li[i], Li[i+1]))
    return Lo

def blowfish_intlist_encrypt(Li):
    Lo = []
    for i in xrange(0, len(Li), 2):
        Lo.extend(blowfish_block_encrypt(Li[i], Li[i+1]))
    return Lo

def hexstr_to_intlist(H):
    L = []
    Hl = len(H)
    Hm = Hl%8
    for i in xrange(0, Hl-Hm, 8):
        L.append(int(H[i:i+8],16))
    if Hm > 0:
        L.append(int(H[Hl-Hm:]+('0'*(8-Hm)),16))
    return L

def intlist_to_hexstr(L):
    H = ""
    for I in L:
        s = hex(I).replace('0x','').replace('L','')
        H += ('0'*(8-len(s)))+s
    return H

def str_to_intlist(S):
    L = []
    Sm = len(S)%8
    if Sm > 0:
        S += chr(0)*(8-Sm)
    for i in xrange(0, len(S), 4):
        L.append((ord(S[i])<<24)+(ord(S[i+1])<<16)+(ord(S[i+2])<<8)+ord(S[i+3]))
    return L

def intlist_to_str(L):
    S = ""
    for I in L:
        S += chr(I>
>24&0xff)+chr(I>>16&0xff)+chr(I>>8&0xff)+chr(I&0xff)
    return S

def pandora_encrypt(S):
    return intlist_to_hexstr(blowfish_intlist_encrypt(str_to_intlist(S)))

def pandora_decrypt(H):
    return intlist_to_str(blowfish_intlist_decrypt(hexstr_to_intlist(H)))

import urllib
import urllib2

def variable_to_xml(A):
    X = "<value>"
    tA = type(A)
    if tA == list:
        X += "<array><data>"
        for B in A:
            X += variable_to_xml(B)
        X += "</data></array>"
    elif tA == dict:
        X += "<struct>"
        for Ak in A:
            X += "<member><name>"
            X += Ak
            X += "</name></member>"
            X += variable_to_xml(A[Ak])
        X += "</struct>"
    elif tA == bool:
        X += "<boolean>"
        X += "1" if A else "0"
        X += "</boolean>"
    elif tA == int or tA == long:
        X += "<int>"
        X += str(A).replace('L','')
        X += "</int>"
    elif tA == str:
        X += "<string>"
        X += A
        X += "</string>"
    X += "</value>"
    return X

def make_xmlrpc_content(method, params):
    X = "<?xml version=\"1.0\"?><methodCall><methodName>"
    X += method
    X += "</methodName><params>"
    for P in params:
        X += "<param>"
        X += variable_to_xml(P)
        X += "</param>"
    X += "</params></methodCall>"
    return X

def pandora_make_url(method, args, ssl, rid, lid):
    url = "http"
    url += "s" if ssl else ""
    url += "://www.pandora.com/radio/xmlrpc/v15?rid="
    url += ('0'*6+str(rid))[-7:]
    url += "P"
    if lid != None:
        url += "&lid="
        url += str(lid)
    url += "&method="
    url += method.split(".")[-1]
    for i in xrange(len(args)):
        url += "&arg"
        url += str(i+1)
        url += "="
        url += urllib.quote_plus(str(args[i]))
    return url

def pandora_xmlrpc_call(method, args, ssl, rid, lid):
    url = pandora_make_url(method, args, ssl, rid, lid)
    data = pandora_encrypt(make_xmlrpc_content(method, args))
    headers = {"User-Agent":"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)","Content-Type":"text/xml","Content-Length":str(len(data))}
    req = urllib2.Request(url, data, headers)
    res = urllib2.urlopen(req)
    return res.read()


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List