Example #1
0
def pkmtogts(pkm):
    bin  = '\x00' * 16
    bin += pkm[0x08:0x0a] # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03' # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c] # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00' # Requesting bulba, either, any
    bin += '\xdb\x07\x03\x0a\x00\x00\x00\x00' # Date deposited (10 Mar 2011)
    bin += '\xdb\x07\x03\x16\x01\x30\x00\x00' # Date traded (?)
    bin += pkm[0x00:0x04] # PID
    bin += pkm[0x0c:0x0e] # OT ID
    bin += pkm[0x0e:0x10] # OT Secret ID
    bin += pkm[0x68:0x78] # OT Name
    bin += '\xDB\x02' # Country, City
    bin += '\x46\x01\x15\x02' # Sprite, Exchanged (?), Version, Lang
    bin += '\x01\x00' # Unknown

    return pkmlib.encode(pkm) + bin
Example #2
0
def pkmtogts(pkm):
    bin = '\x00' * 16
    bin += pkm[0x08:0x0a]  # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03'  # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c]  # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00'  # Requesting bulba, either, any
    bin += '\xdb\x07\x03\x0a\x00\x00\x00\x00'  # Date deposited (10 Mar 2011)
    bin += '\xdb\x07\x03\x16\x01\x30\x00\x00'  # Date traded (?)
    bin += pkm[0x00:0x04]  # PID
    bin += pkm[0x0c:0x0e]  # OT ID
    bin += pkm[0x0e:0x10]  # OT Secret ID
    bin += pkm[0x68:0x78]  # OT Name
    bin += '\xDB\x02'  # Country, City
    bin += '\x46\x01\x15\x02'  # Sprite, Exchanged (?), Version, Lang
    bin += '\x01\x00'  # Unknown

    return pkmlib.encode(pkm) + bin
Example #3
0
def sendpkm():

    print 'Note: you must exit the GTS before sending a pkm'
    print '4th Gen Pokemon files are currently unsupported.'
    print 'Enter the path or drag the pkm file here'

    path = raw_input().strip()
    path = os.path.normpath(path)
    if system() != 'Windows':
        path = path.replace('\\', '')

    if path.startswith('"') or path.startswith("'"):
        path = path[1:]
    if path.endswith('"') or path.endswith("'"):
        path = path[:-1]
    if path.lower().endswith('.pkm'):
        with open(path, 'rb') as f:
            pkm = f.read()

        # Adding extra 100 bytes of party data
        if len(pkm) != 220 and len(pkm) != 136:
            print 'Invalid filesize: %d bytes.' % len(pkm)
            return
        if len(pkm) == 136:
            print 'PC-Boxed Pokemon! Adding party data...',
            pkm = makeparty(pkm)
            print 'done.'

        print 'Encoding!'
        bin = encode(pkm)

###
# Support for .3gpkm files. Currently unfinished.
###

#   elif path.lower().endswith('.3gpkm'):
#       print 'Converting GBA file to NDS format...',
#       with open(path, 'rb') as f:
#           pkm = f.read()
#
#       if len(pkm) != 80 and len(pkm) != 100:
#           print 'Invalid filesize.'
#           return
#       pkm = makends(pkm)
#       print 'done.'
#
#       print 'Encoding!'
#       bin = encode(pkm)

###
#
###

    else:
        print 'Filename must end in .pkm'
        return

    # Adding GTS data to end of file
    bin += '\x00' * 16
    bin += pkm[0x08:0x0a] # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03' # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c] # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00' # Requesting bulba, either, any
    bin += '\xdb\x07\x03\x0a\x00\x00\x00\x00' # Date deposited (10 Mar 2011)
    bin += '\xdb\x07\x03\x16\x01\x30\x00\x00' # Date traded (?)
    bin += pkm[0x00:0x04] # PID
    bin += pkm[0x0c:0x0e] # OT ID
    bin += pkm[0x0e:0x10] # OT Secret ID
    bin += pkm[0x68:0x78] # OT Name
    bin += '\xDB\x02' # Country, City
    bin += '\x46\x01\x15\x02' # Sprite, Exchanged (?), Version, Lang
    bin += '\x01\x00' # Unknown

    sent = False
    response = ''

    print 'Ready to send; you can now enter the GTS...'
    while not sent:
        sock, req = getReq()
        a = req.action
        if len(req.getvars) == 1:
            sendResp(sock, gtsvar.token)
            continue
        elif a == 'info':
            response = '\x01\x00'
            print 'Connection Established.'
        elif a == 'setProfile': response = '\x00' * 8
        elif a == 'post': response = '\x0c\x00'
        elif a == 'search': response = '\x01\x00'
        elif a == 'result': response = bin
        elif a == 'delete':
            response = '\x01\x00'
            sent = True

        m = hashlib.sha1()
        m.update(gtsvar.salt + urlsafe_b64encode(response) + gtsvar.salt)
        response += m.hexdigest()
        sendResp(sock, response)

    print 'Pokemon sent successfully.',
Example #4
0
def sendpkm():

    print 'Note: you must exit the GTS before sending a pkm'
    print '4th Gen Pokemon files are currently unsupported.'
    print 'Enter the path or drag the pkm file here'

    path = raw_input().strip()
    path = os.path.normpath(path)
    if system() != 'Windows':
        path = path.replace('\\', '')

    if path.startswith('"') or path.startswith("'"):
        path = path[1:]
    if path.endswith('"') or path.endswith("'"):
        path = path[:-1]
    if path.lower().endswith('.pkm'):
        with open(path, 'rb') as f:
            pkm = f.read()

        # Adding extra 100 bytes of party data
        if len(pkm) != 220 and len(pkm) != 136:
            print 'Invalid filesize: %d bytes.' % len(pkm)
            return
        if len(pkm) == 136:
            print 'PC-Boxed Pokemon! Adding party data...',
            pkm = makeparty(pkm)
            print 'done.'

        print 'Encoding!'
        bin = encode(pkm)

###
# Support for .3gpkm files. Currently unfinished.
###

#   elif path.lower().endswith('.3gpkm'):
#       print 'Converting GBA file to NDS format...',
#       with open(path, 'rb') as f:
#           pkm = f.read()
#
#       if len(pkm) != 80 and len(pkm) != 100:
#           print 'Invalid filesize.'
#           return
#       pkm = makends(pkm)
#       print 'done.'
#
#       print 'Encoding!'
#       bin = encode(pkm)

###
#
###

    else:
        print 'Filename must end in .pkm'
        return

    # Adding GTS data to end of file
    bin += '\x00' * 16
    bin += pkm[0x08:0x0a]  # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03'  # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c]  # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00'  # Requesting bulba, either, any
    bin += '\xdb\x07\x03\x0a\x00\x00\x00\x00'  # Date deposited (10 Mar 2011)
    bin += '\xdb\x07\x03\x16\x01\x30\x00\x00'  # Date traded (?)
    bin += pkm[0x00:0x04]  # PID
    bin += pkm[0x0c:0x0e]  # OT ID
    bin += pkm[0x0e:0x10]  # OT Secret ID
    bin += pkm[0x68:0x78]  # OT Name
    bin += '\xDB\x02'  # Country, City
    bin += '\x46\x01\x15\x02'  # Sprite, Exchanged (?), Version, Lang
    bin += '\x01\x00'  # Unknown

    sent = False
    response = ''

    print 'Ready to send; you can now enter the GTS...'
    while not sent:
        sock, req = getReq()
        a = req.action
        if len(req.getvars) == 1:
            sendResp(sock, gtsvar.token)
            continue
        elif a == 'info':
            response = '\x01\x00'
            print 'Connection Established.'
        elif a == 'setProfile':
            response = '\x00' * 8
        elif a == 'post':
            response = '\x0c\x00'
        elif a == 'search':
            response = '\x01\x00'
        elif a == 'result':
            response = bin
        elif a == 'delete':
            response = '\x01\x00'
            sent = True

        m = hashlib.sha1()
        m.update(gtsvar.salt + urlsafe_b64encode(response) + gtsvar.salt)
        response += m.hexdigest()
        sendResp(sock, response)

    print 'Pokemon sent successfully.',
Example #5
0
def sendingpkm(path):       
    with open(path, 'rb') as f:
        pkm = f.read()

    # Adding extra 100 bytes of party data
    if len(pkm) != 220 and len(pkm) != 136:
        print 'Invalid filesize: %d bytes. Needs to be either 136 or 220 bytes.' % len(pkm)
        return
    if len(pkm) == 136:
        print 'Pokemon is in PC format; adding party information now... ',
        pkm = makeparty(pkm)
        print 'Done.'

    print 'Encoding!'
    bin = encode(pkm)

###
# Support for .3gpkm files. Currently unfinished.
###

#   elif path.lower().endswith('.3gpkm'):
#       print 'Converting GBA file to NDS format...',
#       with open(path, 'rb') as f:
#           pkm = f.read()
#
#       if len(pkm) != 80 and len(pkm) != 100:
#           print 'Invalid filesize.'
#           return
#       pkm = makends(pkm)
#       print 'done.'
#
#       print 'Encoding!'
#       bin = encode(pkm)

###
#
###

    # Adding GTS data to end of file
    print 'Adding GTS data... '
    bin += '\x00' * 16
    bin += pkm[0x08:0x0a] # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03' # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c] # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00' # Requesting bulba, either, any
    bin += '\xdb\x07\x03\x0a\x00\x00\x00\x00' # Date deposited (10 Mar 2011)
    bin += '\xdb\x07\x03\x16\x01\x30\x00\x00' # Date traded (?)
    bin += pkm[0x00:0x04] # PID
    bin += pkm[0x0c:0x0e] # OT ID
    bin += pkm[0x0e:0x10] # OT Secret ID
    bin += pkm[0x68:0x78] # OT Name
    bin += '\xDB\x02' # Country, City
    bin += '\x46\x01\x15\x02' # Sprite, Exchanged (?), Version, Lang
    bin += '\x01\x00' # Unknown
    print 'Done.'

    sent = False
    response = ''

    print 'Ready to send; you can now enter the GTS.'
    while not sent:
        sock, req = getReq()
        a = req.action
        if len(req.getvars) == 1:
            sendResp(sock, gtsvar.token)
            continue
        elif a == 'info':
            response = '\x01\x00'
            print 'Connection established.'
        elif a == 'setProfile': response = '\x00' * 8
        elif a == 'post': response = '\x0c\x00'
        elif a == 'search': response = '\x01\x00'
        elif a == 'result': response = bin
        elif a == 'delete':
            response = '\x01\x00'
            sent = True

        m = hashlib.sha1()
        m.update(gtsvar.salt + urlsafe_b64encode(response) + gtsvar.salt)
        response += m.hexdigest()
        sendResp(sock, response)

    print 'Pokemon sent successfully.',
Example #6
0
def sendpkm():
    token = 'c9KcX1Cry3QKS2Ai7yxL6QiQGeBGeQKR'

    print 'Note: you must exit the GTS before sending a pkm'
    print 'Enter the path or drag the pkm file here'

    path = raw_input().strip()
    path = os.path.normpath(path)
    if system() != 'Windows':
        path = path.replace('\\', '')

    if path.lower().endswith('.pkm'):
        with open(path, 'rb') as f:
            pkm = f.read()

        # Adding extra 100 bytes of party data
        if len(pkm) != 236 and len(pkm) != 136:
            print 'Invalid filesize.'
            return
        if len(pkm) == 136:
            print 'PC-Boxed Pokemon! Adding party data...',
            pkm = makeparty(pkm)
            print 'done.'

        print 'Encoding!'
        bin = encode(pkm)
    elif path.lower().endswith('.3gpkm'):
        print 'Converting GBA file to NDS format...',
        with open(path, 'rb') as f:
            pkm = f.read()

        if len(pkm) != 80 and len(pkm) != 100:
            print 'Invalid filesize.'
            return
        pkm = makends(pkm)
        print 'done.'

        print 'Encoding!'
        bin = encode(pkm)
    else:
        print 'Filename must end in .pkm or .3gpkm'
        return

    # Adding GTS data to end of file
    bin += pkm[0x08:0x0a]  # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03'  # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c]  # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00'  # Requesting bulba, either, any
    bin += '\x00' * 20  # Timestamps and PID
    bin += pkm[0x68:0x78]  # OT Name
    bin += pkm[0x0c:0x0e]  # OT ID
    bin += '\xDB\x02'  # Country, City
    bin += '\x46\x00\x07\x02'  # Sprite, Exchanged (?), Version, Lang

    sent = False
    delete = False
    print 'Ready to send; you can now enter the GTS...'
    while not sent:
        sock, req = getReq()
        a = req.action
        if len(req.getvars) == 1:
            sendResp(sock, token)
        elif a == 'info':
            sendResp(sock, '\x01\x00')
            print 'Connection Established.'
        elif a == 'setProfile':
            sendResp(sock, '\x00' * 8)
        elif a == 'post':
            sendResp(sock, '\x0c\x00')
        elif a == 'search':
            sendResp(sock, '')
        elif a == 'result':
            sendResp(sock, bin)
        elif a == 'delete':
            sendResp(sock, '\x01\x00')
            sent = True

    print 'Pokemon sent successfully.',
Example #7
0
def sendpkm():
    print 'Enter (or simply drag&drop) the path of the directory which contains the Pokémon:'
    path = raw_input().strip()
    if path.startswith('\'') or path.endswith('\''):
        path = path.replace('\'', '')
    path = os.path.normpath(path)
    if system() != 'Windows':
        path = path.replace('\\', '')
        if not path.endswith('/'):
            path = path + '/'
    else:
        if not path.endswith('\\'):
            path = path + '\\'
    while True:
        dirs = [
        ]  # Just you add/remove a file from your Pokémon directory, isn't a good thing killing the software :(
        for i in os.listdir(path):
            if i.lower().endswith('.pkm'):
                dirs.append(i)
        fileName = dirs[random.randint(0, len(dirs) - 1)]
        pokeyman = path + fileName

        # Shifting
        f = open(pokeyman, 'r')
        pkm = f.read()
        f.close()
        pkm = decode(pkm)
        if len(pkm) != 136:
            pkm = pkm[0:136]  #-- only take the top 136 bytes
            new_pkm_file_name = self.path.GetValue() + self.filename.GetValue(
            ) + str(i) + '.pkm'
            new_pkm_fh = open(new_pkm_file_name, 'w')
            new_pkm_fh.write(pkm)
            new_pkm_fh.close()

        f = open(pokeyman, 'r')
        pkm = f.read()
        f.close()

        # Adding extra 100 bytes of party data
        if len(pkm) != 220 and len(pkm) != 136:
            print 'Invalid filesize: %d bytes.' % len(pkm)
            return
        if len(pkm) == 136:
            print 'PC-Boxed Pokemon! Adding party data...',
            pkm = makeparty(pkm)
            print 'done.'
            print 'Encoding!'
            bin = encode(pkm)
        else:
            print 'Filename must end in .pkm'
            return

        # Adding GTS data to end of file
        bin += '\x00' * 16
        bin += pkm[0x08:0x0a]  # id
        if ord(pkm[0x40]) & 0x04: bin += '\x03'  # Gender
        else: bin += chr((ord(pkm[0x40]) & 2) + 1)
        bin += pkm[0x8c]  # Level
        bin += '\x01\x00\x03\x00\x00\x00\x00\x00'  # Requesting bulba, either, any
        bin += '\xdb\x07\x03\x0a\x00\x00\x00\x00'  # Date deposited (10 Mar 2011)
        bin += '\xdb\x07\x03\x16\x01\x30\x00\x00'  # Date traded (?)
        bin += pkm[0x00:0x04]  # PID
        bin += pkm[0x0c:0x0e]  # OT ID
        bin += pkm[0x0e:0x10]  # OT Secret ID
        bin += pkm[0x68:0x78]  # OT Name
        bin += '\xDB\x02'  # Country, City
        bin += '\x46\x01\x15\x02'  # Sprite, Exchanged (?), Version, Lang
        bin += '\x01\x00'  # Unknown

        sent = False
        response = ''
        print 'Ready to send; you can now enter the GTS...'
        while not sent:
            sock, req = getReq()
            a = req.action
            if len(req.getvars) == 1:
                sendResp(sock, gtsvar.token)
                continue
            elif a == 'info':
                response = '\x01\x00'
                print 'Connection Established.'
            elif a == 'setProfile':
                response = '\x00' * 8
            elif a == 'post':
                response = '\x0c\x00'
            elif a == 'search':
                response = '\x01\x00'
            elif a == 'result':
                response = bin
            elif a == 'delete':
                response = '\x01\x00'
                sent = True

            m = hashlib.sha1()
            m.update(gtsvar.salt + urlsafe_b64encode(response) + gtsvar.salt)
            response += m.hexdigest()
            sendResp(sock, response)

        print fileName + ' sent successfully.'
Example #8
0
def sendpkm():
    token = 'c9KcX1Cry3QKS2Ai7yxL6QiQGeBGeQKR'

    print 'Note: you must exit the GTS before sending a pkm'
    print 'Enter the path or drag the pkm file here'

    path = raw_input().strip()
    path = os.path.normpath(path)
    if system() != 'Windows':
        path = path.replace('\\', '')

    if path.lower().endswith('.pkm'):
        with open(path, 'rb') as f:
            pkm = f.read()

        # Adding extra 100 bytes of party data
        if len(pkm) != 236 and len(pkm) != 136:
            print 'Invalid filesize.'
            return
        if len(pkm) == 136:
            print 'PC-Boxed Pokemon! Adding party data...',
            pkm = makeparty(pkm)
            print 'done.'

        print 'Encoding!'
        bin = encode(pkm)
    elif path.lower().endswith('.3gpkm'):
        print 'Converting GBA file to NDS format...',
        with open(path, 'rb') as f:
            pkm = f.read()

        if len(pkm) != 80 and len(pkm) != 100:
            print 'Invalid filesize.'
            return
        pkm = makends(pkm)
        print 'done.'

        print 'Encoding!'
        bin = encode(pkm)
    else:
        print 'Filename must end in .pkm or .3gpkm'
        return

    # Adding GTS data to end of file
    bin += pkm[0x08:0x0a] # id
    if ord(pkm[0x40]) & 0x04: bin += '\x03' # Gender
    else: bin += chr((ord(pkm[0x40]) & 2) + 1)
    bin += pkm[0x8c] # Level
    bin += '\x01\x00\x03\x00\x00\x00\x00\x00' # Requesting bulba, either, any
    bin += '\x00' * 20 # Timestamps and PID
    bin += pkm[0x68:0x78] # OT Name
    bin += pkm[0x0c:0x0e] # OT ID
    bin += '\xDB\x02' # Country, City
    bin += '\x46\x00\x07\x02' # Sprite, Exchanged (?), Version, Lang

    sent = False
    delete = False
    print 'Ready to send; you can now enter the GTS...'
    while not sent:
        sock, req = getReq()
        a = req.action
        if len(req.getvars) == 1:
            sendResp(sock, token)
        elif a == 'info':
            sendResp(sock, '\x01\x00')
            print 'Connection Established.'
        elif a == 'setProfile': sendResp(sock, '\x00' * 8)
        elif a == 'post': sendResp(sock, '\x0c\x00')
        elif a == 'search': sendResp(sock, '')
        elif a == 'result': sendResp(sock, bin)
        elif a == 'delete':
            sendResp(sock, '\x01\x00')
            sent = True

    print 'Pokemon sent successfully.',